1
0

@tresjs_cientos.js 549 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177
  1. import {
  2. ACESFilmicToneMapping,
  3. AmbientLight,
  4. AnimationClip,
  5. AnimationMixer,
  6. Bone,
  7. Box3,
  8. BoxGeometry,
  9. BufferAttribute,
  10. BufferGeometry,
  11. ClampToEdgeWrapping,
  12. Clock,
  13. Color,
  14. CubeReflectionMapping,
  15. CubeTextureLoader,
  16. Curve,
  17. CylinderGeometry,
  18. DataTextureLoader,
  19. DataUtils,
  20. DirectionalLight,
  21. DoubleSide,
  22. EquirectangularReflectionMapping,
  23. Euler,
  24. EventDispatcher,
  25. ExtrudeGeometry,
  26. FileLoader,
  27. Float32BufferAttribute,
  28. FloatType,
  29. FrontSide,
  30. Group,
  31. HalfFloatType,
  32. ImageBitmapLoader,
  33. InterleavedBuffer,
  34. InterleavedBufferAttribute,
  35. Interpolant,
  36. InterpolateDiscrete,
  37. InterpolateLinear,
  38. Line,
  39. LineBasicMaterial,
  40. LineLoop,
  41. LineSegments,
  42. LinearEncoding,
  43. LinearFilter,
  44. LinearMipmapLinearFilter,
  45. LinearMipmapNearestFilter,
  46. Loader,
  47. LoaderUtils,
  48. MOUSE,
  49. Material,
  50. MathUtils,
  51. Matrix3,
  52. Matrix4,
  53. Mesh,
  54. MeshBasicMaterial,
  55. MeshLambertMaterial,
  56. MeshPhongMaterial,
  57. MeshPhysicalMaterial,
  58. MeshStandardMaterial,
  59. MirroredRepeatWrapping,
  60. NearestFilter,
  61. NearestMipmapLinearFilter,
  62. NearestMipmapNearestFilter,
  63. NoToneMapping,
  64. NumberKeyframeTrack,
  65. Object3D,
  66. OctahedronGeometry,
  67. OrthographicCamera,
  68. PCFShadowMap,
  69. PCFSoftShadowMap,
  70. PerspectiveCamera,
  71. PlaneGeometry,
  72. PointLight,
  73. Points,
  74. PointsMaterial,
  75. PropertyBinding,
  76. QuadraticBezierCurve3,
  77. Quaternion,
  78. QuaternionKeyframeTrack,
  79. Raycaster,
  80. RepeatWrapping,
  81. Scene,
  82. ShapePath,
  83. Skeleton,
  84. SkinnedMesh,
  85. Sphere,
  86. SphereGeometry,
  87. Spherical,
  88. SpotLight,
  89. TOUCH,
  90. TangentSpaceNormalMap,
  91. Texture,
  92. TextureLoader,
  93. TorusGeometry,
  94. TriangleFanDrawMode,
  95. TriangleStripDrawMode,
  96. Uint16BufferAttribute,
  97. Vector2,
  98. Vector3,
  99. Vector4,
  100. VectorKeyframeTrack,
  101. WebGLRenderer,
  102. sRGBEncoding,
  103. three_module_exports
  104. } from "./chunk-4QXXOI63.js";
  105. import {
  106. createEventHook,
  107. resolveUnref,
  108. unrefElement,
  109. useDevicePixelRatio,
  110. useElementSize,
  111. useRafFn,
  112. useWindowSize
  113. } from "./chunk-FNDP46OK.js";
  114. import {
  115. computed,
  116. createBlock,
  117. createCommentVNode,
  118. createVNode,
  119. defineComponent,
  120. getCurrentInstance,
  121. getCurrentScope,
  122. h,
  123. inject,
  124. mergeProps,
  125. nextTick,
  126. onBeforeUnmount,
  127. onMounted,
  128. onScopeDispose,
  129. onUnmounted,
  130. openBlock,
  131. provide,
  132. ref,
  133. renderSlot,
  134. resolveComponent,
  135. shallowReactive,
  136. shallowRef,
  137. toRef,
  138. toRefs,
  139. unref,
  140. useSlots,
  141. watch,
  142. watchEffect,
  143. withAsyncContext,
  144. withCtx
  145. } from "./chunk-LZPJ5JBW.js";
  146. import "./chunk-JC4IRQUL.js";
  147. // node_modules/.pnpm/@tresjs+core@1.8.1_three@0.150.1/node_modules/@tresjs/core/dist/tres.js
  148. var qe = ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(qe || {});
  149. var Qe = 45;
  150. var b;
  151. function Se() {
  152. const { state: e, setState: n } = $(), o = inject("aspect-ratio");
  153. function a(t = "Perspective", r) {
  154. var l, s, i;
  155. if (t === "Perspective") {
  156. const { near: u, far: d, fov: p } = r || {
  157. near: 0.1,
  158. far: 1e3,
  159. fov: Qe
  160. };
  161. b = new PerspectiveCamera(p, ((l = e.aspectRatio) == null ? void 0 : l.value) || window.innerWidth / window.innerHeight, u, d), (s = e.cameras) == null || s.push(b);
  162. } else {
  163. const { left: u, right: d, top: p, bottom: m, near: g, far: R } = r || {
  164. left: -100,
  165. right: 100,
  166. top: 100,
  167. bottom: -100,
  168. near: 0.1,
  169. far: 1e3
  170. };
  171. b = new OrthographicCamera(u, d, p, m, g, R), (i = e.cameras) == null || i.push(b);
  172. }
  173. return e.camera = b, n("camera", e.camera), b;
  174. }
  175. function c() {
  176. var t;
  177. e.camera instanceof PerspectiveCamera && e.aspectRatio && (e.camera.aspect = e.aspectRatio.value), (t = e.camera) == null || t.updateProjectionMatrix();
  178. }
  179. function f(t) {
  180. var r;
  181. (r = e.cameras) == null || r.push(t), t instanceof PerspectiveCamera && e.aspectRatio && (t.aspect = e.aspectRatio.value), t.updateProjectionMatrix(), n("camera", t);
  182. }
  183. function h2() {
  184. e.cameras = [];
  185. }
  186. return o && watch(o, c), {
  187. activeCamera: toRef(e, "camera"),
  188. createCamera: a,
  189. updateCamera: c,
  190. pushCamera: f,
  191. clearCameras: h2
  192. };
  193. }
  194. var fe = "[TresJS ▲ ■ ●] ";
  195. function F() {
  196. function e(a, c) {
  197. console.error(`${fe} ${a}`, c || "");
  198. }
  199. function n(a) {
  200. console.warn(`${fe} ${a}`);
  201. }
  202. function o(a, c) {
  203. }
  204. return {
  205. logError: e,
  206. logWarning: n,
  207. logMessage: o
  208. };
  209. }
  210. var D = ref({ ...three_module_exports, uuid: MathUtils.generateUUID() });
  211. delete D.value.Scene;
  212. var N = (e) => !!e && e.constructor === Array;
  213. function rt(e) {
  214. return e instanceof Color ? e : Array.isArray(e) ? new Color(...e) : new Color(e);
  215. }
  216. var Ee = createEventHook();
  217. var Re = createEventHook();
  218. var te = createEventHook();
  219. var I = new Clock();
  220. var W = 0;
  221. var k = 0;
  222. var { pause: st, resume: ct, isActive: lt } = useRafFn(
  223. () => {
  224. Ee.trigger({ delta: W, elapsed: k, clock: I }), Re.trigger({ delta: W, elapsed: k, clock: I }), te.trigger({ delta: W, elapsed: k, clock: I });
  225. },
  226. { immediate: false }
  227. );
  228. te.on(() => {
  229. W = I.getDelta(), k = I.getElapsedTime();
  230. });
  231. function ne() {
  232. return {
  233. onBeforeLoop: Ee.on,
  234. onLoop: Re.on,
  235. onAfterLoop: te.on,
  236. pause: st,
  237. resume: ct,
  238. isActive: lt
  239. };
  240. }
  241. var ut = shallowRef(new Scene());
  242. function ft() {
  243. return {
  244. scene: ut
  245. };
  246. }
  247. function pt(e) {
  248. const n = { nodes: {}, materials: {} };
  249. return e && e.traverse((o) => {
  250. o.name && (n.nodes[o.name] = o), o.material && !n.materials[o.material.name] && (n.materials[o.material.name] = o.material);
  251. }), n;
  252. }
  253. async function Ct(e, n, o, a, c) {
  254. const { logError: f } = F(), h2 = new e();
  255. c && c(h2), o && o(h2);
  256. const r = (Array.isArray(n) ? n : [n]).map(
  257. (l) => new Promise((s, i) => {
  258. h2.load(
  259. l,
  260. (u) => {
  261. u.scene && Object.assign(u, pt(u.scene)), s(u);
  262. },
  263. a,
  264. (u) => i(f("[useLoader] - Failed to load resource", u))
  265. );
  266. })
  267. );
  268. return N(n) ? await Promise.all(r) : await r[0];
  269. }
  270. var U = shallowReactive({
  271. camera: void 0,
  272. cameras: [],
  273. aspectRatio: computed(() => window.innerWidth / window.innerHeight)
  274. });
  275. function $() {
  276. function e(o) {
  277. return U[o];
  278. }
  279. function n(o, a) {
  280. U[o] = a;
  281. }
  282. return {
  283. state: U,
  284. ...toRefs(U),
  285. getState: e,
  286. setState: n
  287. };
  288. }
  289. var X = shallowRef(new Raycaster());
  290. var B = ref(new Vector2());
  291. var me = ref(null);
  292. function mt() {
  293. const { setState: e } = $();
  294. e("raycaster", X.value), e("pointer", B), e("currentInstance", me), provide("raycaster", X), provide("pointer", B), provide("currentInstance", me);
  295. function n(o) {
  296. B.value.x = o.clientX / window.innerWidth * 2 - 1, B.value.y = -(o.clientY / window.innerHeight) * 2 + 1;
  297. }
  298. return window.addEventListener("pointermove", n), onUnmounted(() => {
  299. window.removeEventListener("pointermove", n);
  300. }), {
  301. raycaster: X,
  302. pointer: B
  303. };
  304. }
  305. var Y = {
  306. realistic: {
  307. outputEncoding: sRGBEncoding,
  308. toneMapping: ACESFilmicToneMapping,
  309. toneMappingExposure: 3,
  310. shadowMap: {
  311. enabled: true,
  312. type: PCFSoftShadowMap
  313. }
  314. }
  315. };
  316. var Me = (e, n) => {
  317. for (const o of Object.keys(n))
  318. n[o] instanceof Object && Object.assign(n[o], Me(e[o], n[o]));
  319. return Object.assign(e || {}, n), e;
  320. };
  321. var y = shallowRef();
  322. var J = ref(false);
  323. function dt(e, n, o) {
  324. const {
  325. alpha: a = true,
  326. antialias: c = true,
  327. depth: f,
  328. logarithmicDepthBuffer: h2,
  329. failIfMajorPerformanceCaveat: t,
  330. precision: r,
  331. premultipliedAlpha: l,
  332. stencil: s,
  333. shadows: i = false,
  334. shadowMapType: u = PCFShadowMap,
  335. physicallyCorrectLights: d = false,
  336. useLegacyLights: p = false,
  337. outputEncoding: m = LinearEncoding,
  338. toneMapping: g = NoToneMapping,
  339. toneMappingExposure: R = 1,
  340. context: v = void 0,
  341. powerPreference: _ = "default",
  342. preserveDrawingBuffer: S = false,
  343. clearColor: C,
  344. windowSize: E = false,
  345. preset: O = void 0
  346. } = toRefs(o), { setState: x } = $(), { width: re, height: oe2 } = resolveUnref(E) ? useWindowSize() : useElementSize(n), { logError: Le } = F(), { pixelRatio: ae2 } = useDevicePixelRatio(), { pause: xe, resume: Pe } = ne(), V = computed(() => re.value / oe2.value), ie = () => {
  347. y.value && (y.value.setSize(re.value, oe2.value), y.value.setPixelRatio(Math.min(ae2.value, 2)));
  348. }, se = () => {
  349. if (!y.value)
  350. return;
  351. const P2 = resolveUnref(O);
  352. if (P2) {
  353. P2 in Y || Le("Renderer Preset must be one of these: " + Object.keys(Y).join(", ")), Me(y.value, Y[P2]);
  354. return;
  355. }
  356. y.value.shadowMap.enabled = resolveUnref(i), y.value.shadowMap.type = resolveUnref(u), y.value.toneMapping = resolveUnref(g) || NoToneMapping, y.value.toneMappingExposure = resolveUnref(R), y.value.outputEncoding = resolveUnref(m) || LinearEncoding, C != null && C.value && y.value.setClearColor(rt(resolveUnref(C))), y.value.useLegacyLights = resolveUnref(p);
  357. }, be = () => {
  358. const P2 = unrefElement(e);
  359. y.value || !P2 || (y.value = new WebGLRenderer({
  360. canvas: P2,
  361. alpha: resolveUnref(a),
  362. antialias: resolveUnref(c),
  363. context: resolveUnref(v),
  364. depth: resolveUnref(f),
  365. failIfMajorPerformanceCaveat: resolveUnref(t),
  366. logarithmicDepthBuffer: resolveUnref(h2),
  367. powerPreference: resolveUnref(_),
  368. precision: resolveUnref(r),
  369. stencil: resolveUnref(s),
  370. preserveDrawingBuffer: resolveUnref(S),
  371. premultipliedAlpha: resolveUnref(l)
  372. }), x("renderer", y.value), x("clock", new Clock()), x("aspectRatio", V), se(), ie(), Pe(), J.value = true);
  373. }, Te = () => {
  374. y.value && (y.value.dispose(), y.value = void 0, J.value = false, xe());
  375. };
  376. return watch([V, ae2], ie), watch(
  377. [i, u, m, p, g, R, C],
  378. se
  379. ), watch(
  380. () => [e, n],
  381. () => {
  382. unrefElement(e) && unrefElement(n) && be();
  383. },
  384. { immediate: true, deep: true }
  385. ), {
  386. renderer: y,
  387. isReady: J,
  388. dispose: Te,
  389. aspectRatio: V
  390. };
  391. }
  392. var { logError: de, logWarning: gt } = F();
  393. var ht = defineComponent({
  394. name: "TresCanvas",
  395. props: {
  396. shadows: Boolean,
  397. shadowMapType: Number,
  398. physicallyCorrectLights: {
  399. type: Boolean,
  400. default: false,
  401. validator: (e) => (e && gt("physicallyCorrectLights is deprecated. Use useLegacyLights instead."), true)
  402. },
  403. useLegacyLights: Boolean,
  404. outputEncoding: Number,
  405. toneMapping: Number,
  406. toneMappingExposure: Number,
  407. context: Object,
  408. powerPreference: String,
  409. preserveDrawingBuffer: Boolean,
  410. clearColor: String,
  411. windowSize: { type: Boolean, default: false },
  412. preset: String
  413. },
  414. setup(e, { slots: n, attrs: o }) {
  415. const a = ref(), c = ref(), { renderer: f, dispose: h2, aspectRatio: t } = dt(a, c, e);
  416. return provide("aspect-ratio", t), provide("renderer", f), n.default && !n.default().some((r) => r.type.name === "Scene") && de("TresCanvas must contain a Scene component."), n.default && !n.default().some((r) => {
  417. var l;
  418. return (l = r.type.name) == null ? void 0 : l.includes("Camera");
  419. }) && de("Scene must contain a Camera component."), onBeforeUnmount(() => h2()), () => {
  420. if (n.default)
  421. return h(
  422. "div",
  423. {
  424. ref: c,
  425. style: {
  426. position: "relative",
  427. width: "100%",
  428. height: "100%",
  429. overflow: "hidden",
  430. pointerEvents: "auto",
  431. touchAction: "none",
  432. ...o.style
  433. }
  434. },
  435. [
  436. h(
  437. "div",
  438. {
  439. style: {
  440. width: "100%",
  441. height: "100%"
  442. }
  443. },
  444. [
  445. h("canvas", {
  446. ref: a,
  447. style: {
  448. display: "block",
  449. width: "100%",
  450. height: "100%",
  451. position: e.windowSize ? "fixed" : "absolute",
  452. top: 0,
  453. left: 0
  454. }
  455. }),
  456. n.default()
  457. ]
  458. )
  459. ]
  460. );
  461. };
  462. }
  463. });
  464. var wt = defineComponent({
  465. name: "Scene",
  466. setup(e, { slots: n }) {
  467. const { setState: o } = $(), { scene: a } = ft(), c = inject("renderer"), { activeCamera: f } = Se(), { raycaster: h2, pointer: t } = mt(), { onLoop: r } = ne();
  468. return provide("local-scene", a), o("scene", a.value), r(() => {
  469. f.value && (h2.value.setFromCamera(t.value, f.value), c != null && c.value && f && (a != null && a.value) && c.value.render(a == null ? void 0 : a.value, f.value));
  470. }), () => {
  471. if (n.default)
  472. return n.default();
  473. };
  474. }
  475. });
  476. var Rt = Symbol("UseTresState");
  477. // node_modules/.pnpm/@tresjs+cientos@1.8.0_three@0.150.1/node_modules/@tresjs/cientos/dist/trescientos.js
  478. function Bp(b2, i) {
  479. for (var r = 0; r < i.length; r++) {
  480. const s = i[r];
  481. if (typeof s != "string" && !Array.isArray(s)) {
  482. for (const a in s)
  483. if (a !== "default" && !(a in b2)) {
  484. const c = Object.getOwnPropertyDescriptor(s, a);
  485. c && Object.defineProperty(b2, a, c.get ? c : {
  486. enumerable: true,
  487. get: () => s[a]
  488. });
  489. }
  490. }
  491. }
  492. return Object.freeze(Object.defineProperty(b2, Symbol.toStringTag, { value: "Module" }));
  493. }
  494. function Qi(b2) {
  495. return Qi = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(i) {
  496. return typeof i;
  497. } : function(i) {
  498. return i && typeof Symbol == "function" && i.constructor === Symbol && i !== Symbol.prototype ? "symbol" : typeof i;
  499. }, Qi(b2);
  500. }
  501. function jp(b2, i) {
  502. if (Qi(b2) !== "object" || b2 === null)
  503. return b2;
  504. var r = b2[Symbol.toPrimitive];
  505. if (r !== void 0) {
  506. var s = r.call(b2, i || "default");
  507. if (Qi(s) !== "object")
  508. return s;
  509. throw new TypeError("@@toPrimitive must return a primitive value.");
  510. }
  511. return (i === "string" ? String : Number)(b2);
  512. }
  513. function zp(b2) {
  514. var i = jp(b2, "string");
  515. return Qi(i) === "symbol" ? i : String(i);
  516. }
  517. function P(b2, i, r) {
  518. return i = zp(i), i in b2 ? Object.defineProperty(b2, i, {
  519. value: r,
  520. enumerable: true,
  521. configurable: true,
  522. writable: true
  523. }) : b2[i] = r, b2;
  524. }
  525. var ht2 = Uint8Array;
  526. var rn = Uint16Array;
  527. var lo = Uint32Array;
  528. var za = new ht2([
  529. 0,
  530. 0,
  531. 0,
  532. 0,
  533. 0,
  534. 0,
  535. 0,
  536. 0,
  537. 1,
  538. 1,
  539. 1,
  540. 1,
  541. 2,
  542. 2,
  543. 2,
  544. 2,
  545. 3,
  546. 3,
  547. 3,
  548. 3,
  549. 4,
  550. 4,
  551. 4,
  552. 4,
  553. 5,
  554. 5,
  555. 5,
  556. 5,
  557. 0,
  558. /* unused */
  559. 0,
  560. 0,
  561. /* impossible */
  562. 0
  563. ]);
  564. var Ua = new ht2([
  565. 0,
  566. 0,
  567. 0,
  568. 0,
  569. 1,
  570. 1,
  571. 2,
  572. 2,
  573. 3,
  574. 3,
  575. 4,
  576. 4,
  577. 5,
  578. 5,
  579. 6,
  580. 6,
  581. 7,
  582. 7,
  583. 8,
  584. 8,
  585. 9,
  586. 9,
  587. 10,
  588. 10,
  589. 11,
  590. 11,
  591. 12,
  592. 12,
  593. 13,
  594. 13,
  595. /* unused */
  596. 0,
  597. 0
  598. ]);
  599. var Up = new ht2([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
  600. var Ga = function(b2, i) {
  601. for (var r = new rn(31), s = 0; s < 31; ++s)
  602. r[s] = i += 1 << b2[s - 1];
  603. for (var a = new lo(r[30]), s = 1; s < 30; ++s)
  604. for (var c = r[s]; c < r[s + 1]; ++c)
  605. a[c] = c - r[s] << 5 | s;
  606. return [r, a];
  607. };
  608. var Ha = Ga(za, 2);
  609. var Ka = Ha[0];
  610. var Gp = Ha[1];
  611. Ka[28] = 258, Gp[258] = 28;
  612. var Hp = Ga(Ua, 0);
  613. var Kp = Hp[0];
  614. var co = new rn(32768);
  615. for (Te = 0; Te < 32768; ++Te) {
  616. tn = (Te & 43690) >>> 1 | (Te & 21845) << 1;
  617. tn = (tn & 52428) >>> 2 | (tn & 13107) << 2, tn = (tn & 61680) >>> 4 | (tn & 3855) << 4, co[Te] = ((tn & 65280) >>> 8 | (tn & 255) << 8) >>> 1;
  618. }
  619. var tn;
  620. var Te;
  621. var $i = function(b2, i, r) {
  622. for (var s = b2.length, a = 0, c = new rn(i); a < s; ++a)
  623. ++c[b2[a] - 1];
  624. var u = new rn(i);
  625. for (a = 0; a < i; ++a)
  626. u[a] = u[a - 1] + c[a - 1] << 1;
  627. var h2;
  628. if (r) {
  629. h2 = new rn(1 << i);
  630. var m = 15 - i;
  631. for (a = 0; a < s; ++a)
  632. if (b2[a])
  633. for (var g = a << 4 | b2[a], w = i - b2[a], _ = u[b2[a] - 1]++ << w, y2 = _ | (1 << w) - 1; _ <= y2; ++_)
  634. h2[co[_] >>> m] = g;
  635. } else
  636. for (h2 = new rn(s), a = 0; a < s; ++a)
  637. b2[a] && (h2[a] = co[u[b2[a] - 1]++] >>> 15 - b2[a]);
  638. return h2;
  639. };
  640. var Ji = new ht2(288);
  641. for (Te = 0; Te < 144; ++Te)
  642. Ji[Te] = 8;
  643. var Te;
  644. for (Te = 144; Te < 256; ++Te)
  645. Ji[Te] = 9;
  646. var Te;
  647. for (Te = 256; Te < 280; ++Te)
  648. Ji[Te] = 7;
  649. var Te;
  650. for (Te = 280; Te < 288; ++Te)
  651. Ji[Te] = 8;
  652. var Te;
  653. var $a = new ht2(32);
  654. for (Te = 0; Te < 32; ++Te)
  655. $a[Te] = 5;
  656. var Te;
  657. var $p = $i(Ji, 9, 1);
  658. var Xp = $i($a, 5, 1);
  659. var Qr = function(b2) {
  660. for (var i = b2[0], r = 1; r < b2.length; ++r)
  661. b2[r] > i && (i = b2[r]);
  662. return i;
  663. };
  664. var wt2 = function(b2, i, r) {
  665. var s = i / 8 | 0;
  666. return (b2[s] | b2[s + 1] << 8) >> (i & 7) & r;
  667. };
  668. var Zr = function(b2, i) {
  669. var r = i / 8 | 0;
  670. return (b2[r] | b2[r + 1] << 8 | b2[r + 2] << 16) >> (i & 7);
  671. };
  672. var Yp = function(b2) {
  673. return (b2 / 8 | 0) + (b2 & 7 && 1);
  674. };
  675. var qp = function(b2, i, r) {
  676. (i == null || i < 0) && (i = 0), (r == null || r > b2.length) && (r = b2.length);
  677. var s = new (b2 instanceof rn ? rn : b2 instanceof lo ? lo : ht2)(r - i);
  678. return s.set(b2.subarray(i, r)), s;
  679. };
  680. var Qp = function(b2, i, r) {
  681. var s = b2.length;
  682. if (!s || r && !r.l && s < 5)
  683. return i || new ht2(0);
  684. var a = !i || r, c = !r || r.i;
  685. r || (r = {}), i || (i = new ht2(s * 3));
  686. var u = function(Oe) {
  687. var je = i.length;
  688. if (Oe > je) {
  689. var ye = new ht2(Math.max(je * 2, Oe));
  690. ye.set(i), i = ye;
  691. }
  692. }, h2 = r.f || 0, m = r.p || 0, g = r.b || 0, w = r.l, _ = r.d, y2 = r.m, C = r.n, I2 = s * 8;
  693. do {
  694. if (!w) {
  695. r.f = h2 = wt2(b2, m, 1);
  696. var S = wt2(b2, m + 1, 3);
  697. if (m += 3, S)
  698. if (S == 1)
  699. w = $p, _ = Xp, y2 = 9, C = 5;
  700. else if (S == 2) {
  701. var V = wt2(b2, m, 31) + 257, D2 = wt2(b2, m + 10, 15) + 4, Y2 = V + wt2(b2, m + 5, 31) + 1;
  702. m += 14;
  703. for (var G = new ht2(Y2), N2 = new ht2(19), O = 0; O < D2; ++O)
  704. N2[Up[O]] = wt2(b2, m + O * 3, 7);
  705. m += D2 * 3;
  706. for (var H = Qr(N2), K = (1 << H) - 1, q = $i(N2, H, 1), O = 0; O < Y2; ) {
  707. var he = q[wt2(b2, m, K)];
  708. m += he & 15;
  709. var R = he >>> 4;
  710. if (R < 16)
  711. G[O++] = R;
  712. else {
  713. var _e = 0, pe = 0;
  714. for (R == 16 ? (pe = 3 + wt2(b2, m, 3), m += 2, _e = G[O - 1]) : R == 17 ? (pe = 3 + wt2(b2, m, 7), m += 3) : R == 18 && (pe = 11 + wt2(b2, m, 127), m += 7); pe--; )
  715. G[O++] = _e;
  716. }
  717. }
  718. var fe2 = G.subarray(0, V), de2 = G.subarray(V);
  719. y2 = Qr(fe2), C = Qr(de2), w = $i(fe2, y2, 1), _ = $i(de2, C, 1);
  720. } else
  721. throw "invalid block type";
  722. else {
  723. var R = Yp(m) + 4, j = b2[R - 4] | b2[R - 3] << 8, F2 = R + j;
  724. if (F2 > s) {
  725. if (c)
  726. throw "unexpected EOF";
  727. break;
  728. }
  729. a && u(g + j), i.set(b2.subarray(R, F2), g), r.b = g += j, r.p = m = F2 * 8;
  730. continue;
  731. }
  732. if (m > I2) {
  733. if (c)
  734. throw "unexpected EOF";
  735. break;
  736. }
  737. }
  738. a && u(g + 131072);
  739. for (var te2 = (1 << y2) - 1, X2 = (1 << C) - 1, ke = m; ; ke = m) {
  740. var _e = w[Zr(b2, m) & te2], ve = _e >>> 4;
  741. if (m += _e & 15, m > I2) {
  742. if (c)
  743. throw "unexpected EOF";
  744. break;
  745. }
  746. if (!_e)
  747. throw "invalid length/literal";
  748. if (ve < 256)
  749. i[g++] = ve;
  750. else if (ve == 256) {
  751. ke = m, w = null;
  752. break;
  753. } else {
  754. var le = ve - 254;
  755. if (ve > 264) {
  756. var O = ve - 257, ie = za[O];
  757. le = wt2(b2, m, (1 << ie) - 1) + Ka[O], m += ie;
  758. }
  759. var ge = _[Zr(b2, m) & X2], M = ge >>> 4;
  760. if (!ge)
  761. throw "invalid distance";
  762. m += ge & 15;
  763. var de2 = Kp[M];
  764. if (M > 3) {
  765. var ie = Ua[M];
  766. de2 += Zr(b2, m) & (1 << ie) - 1, m += ie;
  767. }
  768. if (m > I2) {
  769. if (c)
  770. throw "unexpected EOF";
  771. break;
  772. }
  773. a && u(g + 131072);
  774. for (var ce = g + le; g < ce; g += 4)
  775. i[g] = i[g - de2], i[g + 1] = i[g + 1 - de2], i[g + 2] = i[g + 2 - de2], i[g + 3] = i[g + 3 - de2];
  776. g = ce;
  777. }
  778. }
  779. r.l = w, r.p = ke, r.b = g, w && (h2 = 1, r.m = y2, r.d = _, r.n = C);
  780. } while (!h2);
  781. return g == i.length ? i : qp(i, 0, g);
  782. };
  783. var Zp = new ht2(0);
  784. var Wp = function(b2) {
  785. if ((b2[0] & 15) != 8 || b2[0] >>> 4 > 7 || (b2[0] << 8 | b2[1]) % 31)
  786. throw "invalid zlib data";
  787. if (b2[1] & 32)
  788. throw "invalid zlib data: preset dictionaries not supported";
  789. };
  790. function Jp(b2, i) {
  791. return Qp((Wp(b2), b2.subarray(2, -4)), i);
  792. }
  793. var eu = typeof TextDecoder < "u" && new TextDecoder();
  794. var tu = 0;
  795. try {
  796. eu.decode(Zp, { stream: true }), tu = 1;
  797. } catch {
  798. }
  799. var nu = class extends Object3D {
  800. // events
  801. constructor(i, r) {
  802. 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", {
  803. X: new Vector3(1, 0, 0),
  804. Y: new Vector3(0, 1, 0),
  805. Z: new Vector3(0, 0, 1)
  806. }), 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", {
  807. type: "change"
  808. }), P(this, "mouseDownEvent", {
  809. type: "mouseDown",
  810. mode: this.mode
  811. }), P(this, "mouseUpEvent", {
  812. type: "mouseUp",
  813. mode: this.mode
  814. }), P(this, "objectChangeEvent", {
  815. type: "objectChange"
  816. }), P(this, "intersectObjectWithRay", (a, c, u) => {
  817. const h2 = c.intersectObject(a, true);
  818. for (let m = 0; m < h2.length; m++)
  819. if (h2[m].object.visible || u)
  820. return h2[m];
  821. return false;
  822. }), P(this, "attach", (a) => (this.object = a, 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", () => {
  823. 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();
  824. }), P(this, "pointerHover", (a) => {
  825. if (this.object === void 0 || this.dragging === true)
  826. return;
  827. this.raycaster.setFromCamera(a, this.camera);
  828. const c = this.intersectObjectWithRay(this.gizmo.picker[this.mode], this.raycaster);
  829. c ? this.axis = c.object.name : this.axis = null;
  830. }), P(this, "pointerDown", (a) => {
  831. if (!(this.object === void 0 || this.dragging === true || a.button !== 0) && this.axis !== null) {
  832. this.raycaster.setFromCamera(a, this.camera);
  833. const c = this.intersectObjectWithRay(this.plane, this.raycaster, true);
  834. if (c) {
  835. let u = this.space;
  836. if (this.mode === "scale" ? u = "local" : (this.axis === "E" || this.axis === "XYZE" || this.axis === "XYZ") && (u = "world"), u === "local" && this.mode === "rotate") {
  837. const h2 = this.rotationSnap;
  838. 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);
  839. }
  840. 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);
  841. }
  842. this.dragging = true, this.mouseDownEvent.mode = this.mode, this.dispatchEvent(this.mouseDownEvent);
  843. }
  844. }), P(this, "pointerMove", (a) => {
  845. const c = this.axis, u = this.mode, h2 = this.object;
  846. let m = this.space;
  847. if (u === "scale" ? m = "local" : (c === "E" || c === "XYZE" || c === "XYZ") && (m = "world"), h2 === void 0 || c === null || this.dragging === false || a.button !== -1)
  848. return;
  849. this.raycaster.setFromCamera(a, this.camera);
  850. const g = this.intersectObjectWithRay(this.plane, this.raycaster, true);
  851. if (g) {
  852. if (this.pointEnd.copy(g.point).sub(this.worldPositionStart), u === "translate")
  853. 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))));
  854. else if (u === "scale") {
  855. if (c.search("XYZ") !== -1) {
  856. let w = this.pointEnd.length() / this.pointStart.length();
  857. this.pointEnd.dot(this.pointStart) < 0 && (w *= -1), this.tempVector2.set(w, w, w);
  858. } else
  859. 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);
  860. 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));
  861. } else if (u === "rotate") {
  862. this.offset.copy(this.pointEnd).sub(this.pointStart);
  863. const w = 20 / this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));
  864. 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());
  865. }
  866. this.dispatchEvent(this.changeEvent), this.dispatchEvent(this.objectChangeEvent);
  867. }
  868. }), P(this, "pointerUp", (a) => {
  869. a.button === 0 && (this.dragging && this.axis !== null && (this.mouseUpEvent.mode = this.mode, this.dispatchEvent(this.mouseUpEvent)), this.dragging = false, this.axis = null);
  870. }), P(this, "getPointer", (a) => {
  871. var c;
  872. if (this.domElement && (c = this.domElement.ownerDocument) !== null && c !== void 0 && c.pointerLockElement)
  873. return {
  874. x: 0,
  875. y: 0,
  876. button: a.button
  877. };
  878. {
  879. var u;
  880. const h2 = a.changedTouches ? a.changedTouches[0] : a, m = (u = this.domElement) === null || u === void 0 ? void 0 : u.getBoundingClientRect();
  881. return {
  882. x: (h2.clientX - m.left) / m.width * 2 - 1,
  883. y: -(h2.clientY - m.top) / m.height * 2 + 1,
  884. button: a.button
  885. };
  886. }
  887. }), P(this, "onPointerHover", (a) => {
  888. if (this.enabled)
  889. switch (a.pointerType) {
  890. case "mouse":
  891. case "pen":
  892. this.pointerHover(this.getPointer(a));
  893. break;
  894. }
  895. }), P(this, "onPointerDown", (a) => {
  896. !this.enabled || !this.domElement || (this.domElement.style.touchAction = "none", this.domElement.ownerDocument.addEventListener("pointermove", this.onPointerMove), this.pointerHover(this.getPointer(a)), this.pointerDown(this.getPointer(a)));
  897. }), P(this, "onPointerMove", (a) => {
  898. this.enabled && this.pointerMove(this.getPointer(a));
  899. }), P(this, "onPointerUp", (a) => {
  900. !this.enabled || !this.domElement || (this.domElement.style.touchAction = "", this.domElement.ownerDocument.removeEventListener("pointermove", this.onPointerMove), this.pointerUp(this.getPointer(a)));
  901. }), P(this, "getMode", () => this.mode), P(this, "setMode", (a) => {
  902. this.mode = a;
  903. }), P(this, "setTranslationSnap", (a) => {
  904. this.translationSnap = a;
  905. }), P(this, "setRotationSnap", (a) => {
  906. this.rotationSnap = a;
  907. }), P(this, "setScaleSnap", (a) => {
  908. this.scaleSnap = a;
  909. }), P(this, "setSize", (a) => {
  910. this.size = a;
  911. }), P(this, "setSpace", (a) => {
  912. this.space = a;
  913. }), P(this, "update", () => {
  914. console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.");
  915. }), P(this, "connect", (a) => {
  916. a === document && console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'), this.domElement = a, this.domElement.addEventListener("pointerdown", this.onPointerDown), this.domElement.addEventListener("pointermove", this.onPointerHover), this.domElement.ownerDocument.addEventListener("pointerup", this.onPointerUp);
  917. }), P(this, "dispose", () => {
  918. var a, c, u, h2, m, g;
  919. (a = this.domElement) === null || a === void 0 || a.removeEventListener("pointerdown", this.onPointerDown), (c = this.domElement) === null || c === void 0 || c.removeEventListener("pointermove", this.onPointerHover), (u = this.domElement) === null || u === void 0 || (h2 = u.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) => {
  920. const _ = w;
  921. _.geometry && _.geometry.dispose(), _.material && _.material.dispose();
  922. });
  923. }), this.domElement = r, this.camera = i, this.gizmo = new iu(), this.add(this.gizmo), this.plane = new su(), this.add(this.plane);
  924. const s = (a, c) => {
  925. let u = c;
  926. Object.defineProperty(this, a, {
  927. get: function() {
  928. return u !== void 0 ? u : c;
  929. },
  930. set: function(h2) {
  931. u !== h2 && (u = h2, this.plane[a] = h2, this.gizmo[a] = h2, this.dispatchEvent({
  932. type: a + "-changed",
  933. value: h2
  934. }), this.dispatchEvent(this.changeEvent));
  935. }
  936. }), this[a] = c, this.plane[a] = c, this.gizmo[a] = c;
  937. };
  938. s("camera", this.camera), s("object", this.object), s("enabled", this.enabled), s("axis", this.axis), s("mode", this.mode), s("translationSnap", this.translationSnap), s("rotationSnap", this.rotationSnap), s("scaleSnap", this.scaleSnap), s("space", this.space), s("size", this.size), s("dragging", this.dragging), s("showX", this.showX), s("showY", this.showY), s("showZ", this.showZ), s("worldPosition", this.worldPosition), s("worldPositionStart", this.worldPositionStart), s("worldQuaternion", this.worldQuaternion), s("worldQuaternionStart", this.worldQuaternionStart), s("cameraPosition", this.cameraPosition), s("cameraQuaternion", this.cameraQuaternion), s("pointStart", this.pointStart), s("pointEnd", this.pointEnd), s("rotationAxis", this.rotationAxis), s("rotationAngle", this.rotationAngle), s("eye", this.eye), r !== void 0 && this.connect(r);
  939. }
  940. };
  941. var iu = class extends Object3D {
  942. // these are set from parent class TransformControls
  943. constructor() {
  944. 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", () => {
  945. let ve = this.space;
  946. this.mode === "scale" && (ve = "local");
  947. const le = ve === "local" ? this.worldQuaternion : this.identityQuaternion;
  948. 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";
  949. let ie = [];
  950. ie = ie.concat(this.picker[this.mode].children), ie = ie.concat(this.gizmo[this.mode].children), ie = ie.concat(this.helper[this.mode].children);
  951. for (let ge = 0; ge < ie.length; ge++) {
  952. const M = ie[ge];
  953. M.visible = true, M.rotation.set(0, 0, 0), M.position.copy(this.worldPosition);
  954. let ce;
  955. if (this.camera.isOrthographicCamera ? ce = (this.camera.top - this.camera.bottom) / this.camera.zoom : ce = this.worldPosition.distanceTo(this.cameraPosition) * Math.min(1.9 * Math.tan(Math.PI * this.camera.fov / 360) / this.camera.zoom, 7), M.scale.set(1, 1, 1).multiplyScalar(ce * this.size / 7), M.tag === "helper") {
  956. M.visible = false, M.name === "AXIS" ? (M.position.copy(this.worldPositionStart), M.visible = !!this.axis, this.axis === "X" && (this.tempQuaternion.setFromEuler(this.tempEuler.set(0, 0, 0)), M.quaternion.copy(le).multiply(this.tempQuaternion), Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(le).dot(this.eye)) > 0.9 && (M.visible = false)), this.axis === "Y" && (this.tempQuaternion.setFromEuler(this.tempEuler.set(0, 0, Math.PI / 2)), M.quaternion.copy(le).multiply(this.tempQuaternion), Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(le).dot(this.eye)) > 0.9 && (M.visible = false)), this.axis === "Z" && (this.tempQuaternion.setFromEuler(this.tempEuler.set(0, Math.PI / 2, 0)), M.quaternion.copy(le).multiply(this.tempQuaternion), Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(le).dot(this.eye)) > 0.9 && (M.visible = false)), this.axis === "XYZE" && (this.tempQuaternion.setFromEuler(this.tempEuler.set(0, Math.PI / 2, 0)), this.alignVector.copy(this.rotationAxis), M.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector, this.alignVector, this.unitY)), M.quaternion.multiply(this.tempQuaternion), M.visible = this.dragging), this.axis === "E" && (M.visible = false)) : M.name === "START" ? (M.position.copy(this.worldPositionStart), M.visible = this.dragging) : M.name === "END" ? (M.position.copy(this.worldPosition), M.visible = this.dragging) : M.name === "DELTA" ? (M.position.copy(this.worldPositionStart), M.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()), M.scale.copy(this.tempVector), M.visible = this.dragging) : (M.quaternion.copy(le), this.dragging ? M.position.copy(this.worldPositionStart) : M.position.copy(this.worldPosition), this.axis && (M.visible = this.axis.search(M.name) !== -1));
  957. continue;
  958. }
  959. M.quaternion.copy(le), this.mode === "translate" || this.mode === "scale" ? ((M.name === "X" || M.name === "XYZX") && Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(le).dot(this.eye)) > 0.99 && (M.scale.set(1e-10, 1e-10, 1e-10), M.visible = false), (M.name === "Y" || M.name === "XYZY") && Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(le).dot(this.eye)) > 0.99 && (M.scale.set(1e-10, 1e-10, 1e-10), M.visible = false), (M.name === "Z" || M.name === "XYZZ") && Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(le).dot(this.eye)) > 0.99 && (M.scale.set(1e-10, 1e-10, 1e-10), M.visible = false), M.name === "XY" && Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(le).dot(this.eye)) < 0.2 && (M.scale.set(1e-10, 1e-10, 1e-10), M.visible = false), M.name === "YZ" && Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(le).dot(this.eye)) < 0.2 && (M.scale.set(1e-10, 1e-10, 1e-10), M.visible = false), M.name === "XZ" && Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(le).dot(this.eye)) < 0.2 && (M.scale.set(1e-10, 1e-10, 1e-10), M.visible = false), M.name.search("X") !== -1 && (this.alignVector.copy(this.unitX).applyQuaternion(le).dot(this.eye) < 0 ? M.tag === "fwd" ? M.visible = false : M.scale.x *= -1 : M.tag === "bwd" && (M.visible = false)), M.name.search("Y") !== -1 && (this.alignVector.copy(this.unitY).applyQuaternion(le).dot(this.eye) < 0 ? M.tag === "fwd" ? M.visible = false : M.scale.y *= -1 : M.tag === "bwd" && (M.visible = false)), M.name.search("Z") !== -1 && (this.alignVector.copy(this.unitZ).applyQuaternion(le).dot(this.eye) < 0 ? M.tag === "fwd" ? M.visible = false : M.scale.z *= -1 : M.tag === "bwd" && (M.visible = false))) : this.mode === "rotate" && (this.tempQuaternion2.copy(le), this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(le).invert()), M.name.search("E") !== -1 && M.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye, this.zeroVector, this.unitY)), M.name === "X" && (this.tempQuaternion.setFromAxisAngle(this.unitX, Math.atan2(-this.alignVector.y, this.alignVector.z)), this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2, this.tempQuaternion), M.quaternion.copy(this.tempQuaternion)), M.name === "Y" && (this.tempQuaternion.setFromAxisAngle(this.unitY, Math.atan2(this.alignVector.x, this.alignVector.z)), this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2, this.tempQuaternion), M.quaternion.copy(this.tempQuaternion)), M.name === "Z" && (this.tempQuaternion.setFromAxisAngle(this.unitZ, Math.atan2(this.alignVector.y, this.alignVector.x)), this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2, this.tempQuaternion), M.quaternion.copy(this.tempQuaternion))), M.visible = M.visible && (M.name.indexOf("X") === -1 || this.showX), M.visible = M.visible && (M.name.indexOf("Y") === -1 || this.showY), M.visible = M.visible && (M.name.indexOf("Z") === -1 || this.showZ), M.visible = M.visible && (M.name.indexOf("E") === -1 || this.showX && this.showY && this.showZ), M.material.tempOpacity = M.material.tempOpacity || M.material.opacity, M.material.tempColor = M.material.tempColor || M.material.color.clone(), M.material.color.copy(M.material.tempColor), M.material.opacity = M.material.tempOpacity, this.enabled ? this.axis && (M.name === this.axis ? (M.material.opacity = 1, M.material.color.lerp(new Color(1, 1, 1), 0.5)) : this.axis.split("").some(function(Oe) {
  960. return M.name === Oe;
  961. }) ? (M.material.opacity = 1, M.material.color.lerp(new Color(1, 1, 1), 0.5)) : (M.material.opacity *= 0.25, M.material.color.lerp(new Color(1, 1, 1), 0.5))) : (M.material.opacity *= 0.5, M.material.color.lerp(new Color(1, 1, 1), 0.5));
  962. }
  963. super.updateMatrixWorld();
  964. });
  965. const i = new MeshBasicMaterial({
  966. depthTest: false,
  967. depthWrite: false,
  968. transparent: true,
  969. side: DoubleSide,
  970. fog: false,
  971. toneMapped: false
  972. }), r = new LineBasicMaterial({
  973. depthTest: false,
  974. depthWrite: false,
  975. transparent: true,
  976. linewidth: 1,
  977. fog: false,
  978. toneMapped: false
  979. }), s = i.clone();
  980. s.opacity = 0.15;
  981. const a = i.clone();
  982. a.opacity = 0.33;
  983. const c = i.clone();
  984. c.color.set(16711680);
  985. const u = i.clone();
  986. u.color.set(65280);
  987. const h2 = i.clone();
  988. h2.color.set(255);
  989. const m = i.clone();
  990. m.opacity = 0.25;
  991. const g = m.clone();
  992. g.color.set(16776960);
  993. const w = m.clone();
  994. w.color.set(65535);
  995. const _ = m.clone();
  996. _.color.set(16711935), i.clone().color.set(16776960);
  997. const C = r.clone();
  998. C.color.set(16711680);
  999. const I2 = r.clone();
  1000. I2.color.set(65280);
  1001. const S = r.clone();
  1002. S.color.set(255);
  1003. const R = r.clone();
  1004. R.color.set(65535);
  1005. const j = r.clone();
  1006. j.color.set(16711935);
  1007. const F2 = r.clone();
  1008. F2.color.set(16776960);
  1009. const V = r.clone();
  1010. V.color.set(7895160);
  1011. const D2 = F2.clone();
  1012. D2.opacity = 0.25;
  1013. const Y2 = new CylinderGeometry(0, 0.05, 0.2, 12, 1, false), G = new BoxGeometry(0.125, 0.125, 0.125), N2 = new BufferGeometry();
  1014. N2.setAttribute("position", new Float32BufferAttribute([0, 0, 0, 1, 0, 0], 3));
  1015. const O = (ve, le) => {
  1016. const ie = new BufferGeometry(), ge = [];
  1017. for (let M = 0; M <= 64 * le; ++M)
  1018. ge.push(0, Math.cos(M / 32 * Math.PI) * ve, Math.sin(M / 32 * Math.PI) * ve);
  1019. return ie.setAttribute("position", new Float32BufferAttribute(ge, 3)), ie;
  1020. }, H = () => {
  1021. const ve = new BufferGeometry();
  1022. return ve.setAttribute("position", new Float32BufferAttribute([0, 0, 0, 1, 1, 1], 3)), ve;
  1023. }, K = {
  1024. X: [[new Mesh(Y2, c), [1, 0, 0], [0, 0, -Math.PI / 2], null, "fwd"], [new Mesh(Y2, c), [1, 0, 0], [0, 0, Math.PI / 2], null, "bwd"], [new Line(N2, C)]],
  1025. Y: [[new Mesh(Y2, u), [0, 1, 0], null, null, "fwd"], [new Mesh(Y2, u), [0, 1, 0], [Math.PI, 0, 0], null, "bwd"], [new Line(N2, I2), null, [0, 0, Math.PI / 2]]],
  1026. Z: [[new Mesh(Y2, h2), [0, 0, 1], [Math.PI / 2, 0, 0], null, "fwd"], [new Mesh(Y2, h2), [0, 0, 1], [-Math.PI / 2, 0, 0], null, "bwd"], [new Line(N2, S), null, [0, -Math.PI / 2, 0]]],
  1027. XYZ: [[new Mesh(new OctahedronGeometry(0.1, 0), m.clone()), [0, 0, 0], [0, 0, 0]]],
  1028. XY: [[new Mesh(new PlaneGeometry(0.295, 0.295), g.clone()), [0.15, 0.15, 0]], [new Line(N2, F2), [0.18, 0.3, 0], null, [0.125, 1, 1]], [new Line(N2, F2), [0.3, 0.18, 0], [0, 0, Math.PI / 2], [0.125, 1, 1]]],
  1029. YZ: [[new Mesh(new PlaneGeometry(0.295, 0.295), w.clone()), [0, 0.15, 0.15], [0, Math.PI / 2, 0]], [new Line(N2, R), [0, 0.18, 0.3], [0, 0, Math.PI / 2], [0.125, 1, 1]], [new Line(N2, R), [0, 0.3, 0.18], [0, -Math.PI / 2, 0], [0.125, 1, 1]]],
  1030. XZ: [[new Mesh(new PlaneGeometry(0.295, 0.295), _.clone()), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]], [new Line(N2, j), [0.18, 0, 0.3], null, [0.125, 1, 1]], [new Line(N2, j), [0.3, 0, 0.18], [0, -Math.PI / 2, 0], [0.125, 1, 1]]]
  1031. }, q = {
  1032. X: [[new Mesh(new CylinderGeometry(0.2, 0, 1, 4, 1, false), s), [0.6, 0, 0], [0, 0, -Math.PI / 2]]],
  1033. Y: [[new Mesh(new CylinderGeometry(0.2, 0, 1, 4, 1, false), s), [0, 0.6, 0]]],
  1034. Z: [[new Mesh(new CylinderGeometry(0.2, 0, 1, 4, 1, false), s), [0, 0, 0.6], [Math.PI / 2, 0, 0]]],
  1035. XYZ: [[new Mesh(new OctahedronGeometry(0.2, 0), s)]],
  1036. XY: [[new Mesh(new PlaneGeometry(0.4, 0.4), s), [0.2, 0.2, 0]]],
  1037. YZ: [[new Mesh(new PlaneGeometry(0.4, 0.4), s), [0, 0.2, 0.2], [0, Math.PI / 2, 0]]],
  1038. XZ: [[new Mesh(new PlaneGeometry(0.4, 0.4), s), [0.2, 0, 0.2], [-Math.PI / 2, 0, 0]]]
  1039. }, he = {
  1040. START: [[new Mesh(new OctahedronGeometry(0.01, 2), a), null, null, null, "helper"]],
  1041. END: [[new Mesh(new OctahedronGeometry(0.01, 2), a), null, null, null, "helper"]],
  1042. DELTA: [[new Line(H(), a), null, null, null, "helper"]],
  1043. X: [[new Line(N2, a.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]],
  1044. Y: [[new Line(N2, a.clone()), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]],
  1045. Z: [[new Line(N2, a.clone()), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]]
  1046. }, _e = {
  1047. X: [[new Line(O(1, 0.5), C)], [new Mesh(new OctahedronGeometry(0.04, 0), c), [0, 0, 0.99], null, [1, 3, 1]]],
  1048. Y: [[new Line(O(1, 0.5), I2), null, [0, 0, -Math.PI / 2]], [new Mesh(new OctahedronGeometry(0.04, 0), u), [0, 0, 0.99], null, [3, 1, 1]]],
  1049. Z: [[new Line(O(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]]],
  1050. E: [[new Line(O(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]]],
  1051. XYZE: [[new Line(O(1, 1), V), null, [0, Math.PI / 2, 0]]]
  1052. }, pe = {
  1053. AXIS: [[new Line(N2, a.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]]
  1054. }, fe2 = {
  1055. X: [[new Mesh(new TorusGeometry(1, 0.1, 4, 24), s), [0, 0, 0], [0, -Math.PI / 2, -Math.PI / 2]]],
  1056. Y: [[new Mesh(new TorusGeometry(1, 0.1, 4, 24), s), [0, 0, 0], [Math.PI / 2, 0, 0]]],
  1057. Z: [[new Mesh(new TorusGeometry(1, 0.1, 4, 24), s), [0, 0, 0], [0, 0, -Math.PI / 2]]],
  1058. E: [[new Mesh(new TorusGeometry(1.25, 0.1, 2, 24), s)]],
  1059. XYZE: [[new Mesh(new SphereGeometry(0.7, 10, 8), s)]]
  1060. }, de2 = {
  1061. X: [[new Mesh(G, c), [0.8, 0, 0], [0, 0, -Math.PI / 2]], [new Line(N2, C), null, null, [0.8, 1, 1]]],
  1062. Y: [[new Mesh(G, u), [0, 0.8, 0]], [new Line(N2, I2), null, [0, 0, Math.PI / 2], [0.8, 1, 1]]],
  1063. Z: [[new Mesh(G, h2), [0, 0, 0.8], [Math.PI / 2, 0, 0]], [new Line(N2, S), null, [0, -Math.PI / 2, 0], [0.8, 1, 1]]],
  1064. XY: [[new Mesh(G, g), [0.85, 0.85, 0], null, [2, 2, 0.2]], [new Line(N2, F2), [0.855, 0.98, 0], null, [0.125, 1, 1]], [new Line(N2, F2), [0.98, 0.855, 0], [0, 0, Math.PI / 2], [0.125, 1, 1]]],
  1065. YZ: [[new Mesh(G, w), [0, 0.85, 0.85], null, [0.2, 2, 2]], [new Line(N2, R), [0, 0.855, 0.98], [0, 0, Math.PI / 2], [0.125, 1, 1]], [new Line(N2, R), [0, 0.98, 0.855], [0, -Math.PI / 2, 0], [0.125, 1, 1]]],
  1066. XZ: [[new Mesh(G, _), [0.85, 0, 0.85], null, [2, 0.2, 2]], [new Line(N2, j), [0.855, 0, 0.98], null, [0.125, 1, 1]], [new Line(N2, j), [0.98, 0, 0.855], [0, -Math.PI / 2, 0], [0.125, 1, 1]]],
  1067. XYZX: [[new Mesh(new BoxGeometry(0.125, 0.125, 0.125), m.clone()), [1.1, 0, 0]]],
  1068. XYZY: [[new Mesh(new BoxGeometry(0.125, 0.125, 0.125), m.clone()), [0, 1.1, 0]]],
  1069. XYZZ: [[new Mesh(new BoxGeometry(0.125, 0.125, 0.125), m.clone()), [0, 0, 1.1]]]
  1070. }, te2 = {
  1071. X: [[new Mesh(new CylinderGeometry(0.2, 0, 0.8, 4, 1, false), s), [0.5, 0, 0], [0, 0, -Math.PI / 2]]],
  1072. Y: [[new Mesh(new CylinderGeometry(0.2, 0, 0.8, 4, 1, false), s), [0, 0.5, 0]]],
  1073. Z: [[new Mesh(new CylinderGeometry(0.2, 0, 0.8, 4, 1, false), s), [0, 0, 0.5], [Math.PI / 2, 0, 0]]],
  1074. XY: [[new Mesh(G, s), [0.85, 0.85, 0], null, [3, 3, 0.2]]],
  1075. YZ: [[new Mesh(G, s), [0, 0.85, 0.85], null, [0.2, 3, 3]]],
  1076. XZ: [[new Mesh(G, s), [0.85, 0, 0.85], null, [3, 0.2, 3]]],
  1077. XYZX: [[new Mesh(new BoxGeometry(0.2, 0.2, 0.2), s), [1.1, 0, 0]]],
  1078. XYZY: [[new Mesh(new BoxGeometry(0.2, 0.2, 0.2), s), [0, 1.1, 0]]],
  1079. XYZZ: [[new Mesh(new BoxGeometry(0.2, 0.2, 0.2), s), [0, 0, 1.1]]]
  1080. }, X2 = {
  1081. X: [[new Line(N2, a.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]],
  1082. Y: [[new Line(N2, a.clone()), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]],
  1083. Z: [[new Line(N2, a.clone()), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]]
  1084. }, ke = (ve) => {
  1085. const le = new Object3D();
  1086. for (let ie in ve)
  1087. for (let ge = ve[ie].length; ge--; ) {
  1088. const M = ve[ie][ge][0].clone(), ce = ve[ie][ge][1], Oe = ve[ie][ge][2], je = ve[ie][ge][3], ye = ve[ie][ge][4];
  1089. M.name = ie, M.tag = ye, ce && M.position.set(ce[0], ce[1], ce[2]), Oe && M.rotation.set(Oe[0], Oe[1], Oe[2]), je && M.scale.set(je[0], je[1], je[2]), M.updateMatrix();
  1090. const st2 = M.geometry.clone();
  1091. st2.applyMatrix4(M.matrix), M.geometry = st2, M.renderOrder = 1 / 0, M.position.set(0, 0, 0), M.rotation.set(0, 0, 0), M.scale.set(1, 1, 1), le.add(M);
  1092. }
  1093. return le;
  1094. };
  1095. this.gizmo = {}, this.picker = {}, this.helper = {}, this.add(this.gizmo.translate = ke(K)), this.add(this.gizmo.rotate = ke(_e)), this.add(this.gizmo.scale = ke(de2)), this.add(this.picker.translate = ke(q)), this.add(this.picker.rotate = ke(fe2)), this.add(this.picker.scale = ke(te2)), this.add(this.helper.translate = ke(he)), this.add(this.helper.rotate = ke(pe)), this.add(this.helper.scale = ke(X2)), this.picker.translate.visible = false, this.picker.rotate.visible = false, this.picker.scale.visible = false;
  1096. }
  1097. // updateMatrixWorld will update transformations and appearance of individual handles
  1098. };
  1099. var su = class extends Mesh {
  1100. constructor() {
  1101. super(new PlaneGeometry(1e5, 1e5, 2, 2), new MeshBasicMaterial({
  1102. visible: false,
  1103. wireframe: true,
  1104. side: DoubleSide,
  1105. transparent: true,
  1106. opacity: 0.1,
  1107. toneMapped: false
  1108. })), 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", () => {
  1109. let i = this.space;
  1110. 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) {
  1111. case "translate":
  1112. case "scale":
  1113. switch (this.axis) {
  1114. case "X":
  1115. this.alignVector.copy(this.eye).cross(this.unitX), this.dirVector.copy(this.unitX).cross(this.alignVector);
  1116. break;
  1117. case "Y":
  1118. this.alignVector.copy(this.eye).cross(this.unitY), this.dirVector.copy(this.unitY).cross(this.alignVector);
  1119. break;
  1120. case "Z":
  1121. this.alignVector.copy(this.eye).cross(this.unitZ), this.dirVector.copy(this.unitZ).cross(this.alignVector);
  1122. break;
  1123. case "XY":
  1124. this.dirVector.copy(this.unitZ);
  1125. break;
  1126. case "YZ":
  1127. this.dirVector.copy(this.unitX);
  1128. break;
  1129. case "XZ":
  1130. this.alignVector.copy(this.unitZ), this.dirVector.copy(this.unitY);
  1131. break;
  1132. case "XYZ":
  1133. case "E":
  1134. this.dirVector.set(0, 0, 0);
  1135. break;
  1136. }
  1137. break;
  1138. case "rotate":
  1139. default:
  1140. this.dirVector.set(0, 0, 0);
  1141. }
  1142. 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();
  1143. });
  1144. }
  1145. };
  1146. var la = (b2, i) => (b2 % i + i) % i;
  1147. var ru = class extends EventDispatcher {
  1148. // Set to false to disable this control
  1149. // "target" sets the location of focus, where the object orbits around
  1150. // How far you can dolly in and out ( PerspectiveCamera only )
  1151. // How far you can zoom in and out ( OrthographicCamera only )
  1152. // How far you can orbit vertically, upper and lower limits.
  1153. // Range is 0 to Math.PI radians.
  1154. // radians
  1155. // radians
  1156. // How far you can orbit horizontally, upper and lower limits.
  1157. // If set, the interval [ min, max ] must be a sub-interval of [ - 2 PI, 2 PI ], with ( max - min < 2 PI )
  1158. // radians
  1159. // radians
  1160. // Set to true to enable damping (inertia)
  1161. // If damping is enabled, you must call controls.update() in your animation loop
  1162. // This option actually enables dollying in and out; left as "zoom" for backwards compatibility.
  1163. // Set to false to disable zooming
  1164. // Set to false to disable rotating
  1165. // Set to false to disable panning
  1166. // if false, pan orthogonal to world-space direction camera.up
  1167. // pixels moved per arrow key push
  1168. // Set to true to automatically rotate around the target
  1169. // If auto-rotate is enabled, you must call controls.update() in your animation loop
  1170. // 30 seconds per orbit when fps is 60
  1171. // true if you want to reverse the orbit to mouse drag from left to right = orbits left
  1172. // The four arrow keys
  1173. // Mouse buttons
  1174. // Touch fingers
  1175. // the target DOM element for key events
  1176. constructor(i, r) {
  1177. 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", {
  1178. LEFT: "ArrowLeft",
  1179. UP: "ArrowUp",
  1180. RIGHT: "ArrowRight",
  1181. BOTTOM: "ArrowDown"
  1182. }), P(this, "mouseButtons", {
  1183. LEFT: MOUSE.ROTATE,
  1184. MIDDLE: MOUSE.DOLLY,
  1185. RIGHT: MOUSE.PAN
  1186. }), P(this, "touches", {
  1187. ONE: TOUCH.ROTATE,
  1188. TWO: TOUCH.DOLLY_PAN
  1189. }), 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 = r, 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 = (A) => {
  1190. let U2 = la(A, 2 * Math.PI), J2 = w.phi;
  1191. J2 < 0 && (J2 += 2 * Math.PI), U2 < 0 && (U2 += 2 * Math.PI);
  1192. let se = Math.abs(U2 - J2);
  1193. 2 * Math.PI - se < se && (U2 < J2 ? U2 += 2 * Math.PI : J2 += 2 * Math.PI), _.phi = U2 - J2, s.update();
  1194. }, this.setAzimuthalAngle = (A) => {
  1195. let U2 = la(A, 2 * Math.PI), J2 = w.theta;
  1196. J2 < 0 && (J2 += 2 * Math.PI), U2 < 0 && (U2 += 2 * Math.PI);
  1197. let se = Math.abs(U2 - J2);
  1198. 2 * Math.PI - se < se && (U2 < J2 ? U2 += 2 * Math.PI : J2 += 2 * Math.PI), _.theta = U2 - J2, s.update();
  1199. }, this.getDistance = () => s.object.position.distanceTo(s.target), this.listenToKeyEvents = (A) => {
  1200. A.addEventListener("keydown", xt), this._domElementKeyEvents = A;
  1201. }, this.saveState = () => {
  1202. s.target0.copy(s.target), s.position0.copy(s.object.position), s.zoom0 = s.object instanceof PerspectiveCamera ? s.object.zoom : 1;
  1203. }, this.reset = () => {
  1204. s.target.copy(s.target0), s.object.position.copy(s.position0), s.object instanceof PerspectiveCamera && (s.object.zoom = s.zoom0, s.object.updateProjectionMatrix()), s.dispatchEvent(a), s.update(), m = h2.NONE;
  1205. }, this.update = (() => {
  1206. const A = new Vector3(), U2 = new Quaternion().setFromUnitVectors(i.up, new Vector3(0, 1, 0)), J2 = U2.clone().invert(), se = new Vector3(), xe = new Quaternion(), Ne = 2 * Math.PI;
  1207. return function() {
  1208. const cn = s.object.position;
  1209. A.copy(cn).sub(s.target), A.applyQuaternion(U2), w.setFromVector3(A), s.autoRotate && m === h2.NONE && he(K()), s.enableDamping ? (w.theta += _.theta * s.dampingFactor, w.phi += _.phi * s.dampingFactor) : (w.theta += _.theta, w.phi += _.phi);
  1210. let Ke = s.minAzimuthAngle, $e = s.maxAzimuthAngle;
  1211. return isFinite(Ke) && isFinite($e) && (Ke < -Math.PI ? Ke += Ne : Ke > Math.PI && (Ke -= Ne), $e < -Math.PI ? $e += Ne : $e > Math.PI && ($e -= Ne), Ke <= $e ? w.theta = Math.max(Ke, Math.min($e, w.theta)) : w.theta = w.theta > (Ke + $e) / 2 ? Math.max(Ke, w.theta) : Math.min($e, w.theta)), w.phi = Math.max(s.minPolarAngle, Math.min(s.maxPolarAngle, w.phi)), w.makeSafe(), w.radius *= y2, w.radius = Math.max(s.minDistance, Math.min(s.maxDistance, w.radius)), s.enableDamping === true ? s.target.addScaledVector(C, s.dampingFactor) : s.target.add(C), A.setFromSpherical(w), A.applyQuaternion(J2), cn.copy(s.target).add(A), s.object.lookAt(s.target), s.enableDamping === true ? (_.theta *= 1 - s.dampingFactor, _.phi *= 1 - s.dampingFactor, C.multiplyScalar(1 - s.dampingFactor)) : (_.set(0, 0, 0), C.set(0, 0, 0)), y2 = 1, I2 || se.distanceToSquared(s.object.position) > g || 8 * (1 - xe.dot(s.object.quaternion)) > g ? (s.dispatchEvent(a), se.copy(s.object.position), xe.copy(s.object.quaternion), I2 = false, true) : false;
  1212. };
  1213. })(), this.connect = (A) => {
  1214. A === document && console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'), s.domElement = A, s.domElement.style.touchAction = "none", s.domElement.addEventListener("contextmenu", ln), s.domElement.addEventListener("pointerdown", rt2), s.domElement.addEventListener("pointercancel", jn), s.domElement.addEventListener("wheel", Un);
  1215. }, this.dispose = () => {
  1216. var A, U2, J2, se, xe, Ne;
  1217. (A = s.domElement) === null || A === void 0 || A.removeEventListener("contextmenu", ln), (U2 = s.domElement) === null || U2 === void 0 || U2.removeEventListener("pointerdown", rt2), (J2 = s.domElement) === null || J2 === void 0 || J2.removeEventListener("pointercancel", jn), (se = s.domElement) === null || se === void 0 || se.removeEventListener("wheel", Un), (xe = s.domElement) === null || xe === void 0 || xe.ownerDocument.removeEventListener("pointermove", an), (Ne = s.domElement) === null || Ne === void 0 || Ne.ownerDocument.removeEventListener("pointerup", ft2), s._domElementKeyEvents !== null && s._domElementKeyEvents.removeEventListener("keydown", xt);
  1218. };
  1219. const s = this, a = {
  1220. type: "change"
  1221. }, c = {
  1222. type: "start"
  1223. }, u = {
  1224. type: "end"
  1225. }, h2 = {
  1226. NONE: -1,
  1227. ROTATE: 0,
  1228. DOLLY: 1,
  1229. PAN: 2,
  1230. TOUCH_ROTATE: 3,
  1231. TOUCH_PAN: 4,
  1232. TOUCH_DOLLY_PAN: 5,
  1233. TOUCH_DOLLY_ROTATE: 6
  1234. };
  1235. let m = h2.NONE;
  1236. const g = 1e-6, w = new Spherical(), _ = new Spherical();
  1237. let y2 = 1;
  1238. const C = new Vector3();
  1239. let I2 = false;
  1240. const S = new Vector2(), R = new Vector2(), j = new Vector2(), F2 = new Vector2(), V = new Vector2(), D2 = new Vector2(), Y2 = new Vector2(), G = new Vector2(), N2 = new Vector2(), O = [], H = {};
  1241. function K() {
  1242. return 2 * Math.PI / 60 / 60 * s.autoRotateSpeed;
  1243. }
  1244. function q() {
  1245. return Math.pow(0.95, s.zoomSpeed);
  1246. }
  1247. function he(A) {
  1248. s.reverseOrbit ? _.theta += A : _.theta -= A;
  1249. }
  1250. function _e(A) {
  1251. s.reverseOrbit ? _.phi += A : _.phi -= A;
  1252. }
  1253. const pe = (() => {
  1254. const A = new Vector3();
  1255. return function(J2, se) {
  1256. A.setFromMatrixColumn(se, 0), A.multiplyScalar(-J2), C.add(A);
  1257. };
  1258. })(), fe2 = (() => {
  1259. const A = new Vector3();
  1260. return function(J2, se) {
  1261. s.screenSpacePanning === true ? A.setFromMatrixColumn(se, 1) : (A.setFromMatrixColumn(se, 0), A.crossVectors(s.object.up, A)), A.multiplyScalar(J2), C.add(A);
  1262. };
  1263. })(), de2 = (() => {
  1264. const A = new Vector3();
  1265. return function(J2, se) {
  1266. const xe = s.domElement;
  1267. if (xe && s.object instanceof PerspectiveCamera && s.object.isPerspectiveCamera) {
  1268. const Ne = s.object.position;
  1269. A.copy(Ne).sub(s.target);
  1270. let Ut = A.length();
  1271. Ut *= Math.tan(s.object.fov / 2 * Math.PI / 180), pe(2 * J2 * Ut / xe.clientHeight, s.object.matrix), fe2(2 * se * Ut / xe.clientHeight, s.object.matrix);
  1272. } else
  1273. xe && s.object instanceof OrthographicCamera && s.object.isOrthographicCamera ? (pe(J2 * (s.object.right - s.object.left) / s.object.zoom / xe.clientWidth, s.object.matrix), fe2(se * (s.object.top - s.object.bottom) / s.object.zoom / xe.clientHeight, s.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), s.enablePan = false);
  1274. };
  1275. })();
  1276. function te2(A) {
  1277. s.object instanceof PerspectiveCamera && s.object.isPerspectiveCamera ? y2 /= A : s.object instanceof OrthographicCamera && s.object.isOrthographicCamera ? (s.object.zoom = Math.max(s.minZoom, Math.min(s.maxZoom, s.object.zoom * A)), s.object.updateProjectionMatrix(), I2 = true) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), s.enableZoom = false);
  1278. }
  1279. function X2(A) {
  1280. s.object instanceof PerspectiveCamera && s.object.isPerspectiveCamera ? y2 *= A : s.object instanceof OrthographicCamera && s.object.isOrthographicCamera ? (s.object.zoom = Math.max(s.minZoom, Math.min(s.maxZoom, s.object.zoom / A)), s.object.updateProjectionMatrix(), I2 = true) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), s.enableZoom = false);
  1281. }
  1282. function ke(A) {
  1283. S.set(A.clientX, A.clientY);
  1284. }
  1285. function ve(A) {
  1286. Y2.set(A.clientX, A.clientY);
  1287. }
  1288. function le(A) {
  1289. F2.set(A.clientX, A.clientY);
  1290. }
  1291. function ie(A) {
  1292. R.set(A.clientX, A.clientY), j.subVectors(R, S).multiplyScalar(s.rotateSpeed);
  1293. const U2 = s.domElement;
  1294. U2 && (he(2 * Math.PI * j.x / U2.clientHeight), _e(2 * Math.PI * j.y / U2.clientHeight)), S.copy(R), s.update();
  1295. }
  1296. function ge(A) {
  1297. G.set(A.clientX, A.clientY), N2.subVectors(G, Y2), N2.y > 0 ? te2(q()) : N2.y < 0 && X2(q()), Y2.copy(G), s.update();
  1298. }
  1299. function M(A) {
  1300. V.set(A.clientX, A.clientY), D2.subVectors(V, F2).multiplyScalar(s.panSpeed), de2(D2.x, D2.y), F2.copy(V), s.update();
  1301. }
  1302. function ce(A) {
  1303. A.deltaY < 0 ? X2(q()) : A.deltaY > 0 && te2(q()), s.update();
  1304. }
  1305. function Oe(A) {
  1306. let U2 = false;
  1307. switch (A.code) {
  1308. case s.keys.UP:
  1309. de2(0, s.keyPanSpeed), U2 = true;
  1310. break;
  1311. case s.keys.BOTTOM:
  1312. de2(0, -s.keyPanSpeed), U2 = true;
  1313. break;
  1314. case s.keys.LEFT:
  1315. de2(s.keyPanSpeed, 0), U2 = true;
  1316. break;
  1317. case s.keys.RIGHT:
  1318. de2(-s.keyPanSpeed, 0), U2 = true;
  1319. break;
  1320. }
  1321. U2 && (A.preventDefault(), s.update());
  1322. }
  1323. function je() {
  1324. if (O.length == 1)
  1325. S.set(O[0].pageX, O[0].pageY);
  1326. else {
  1327. const A = 0.5 * (O[0].pageX + O[1].pageX), U2 = 0.5 * (O[0].pageY + O[1].pageY);
  1328. S.set(A, U2);
  1329. }
  1330. }
  1331. function ye() {
  1332. if (O.length == 1)
  1333. F2.set(O[0].pageX, O[0].pageY);
  1334. else {
  1335. const A = 0.5 * (O[0].pageX + O[1].pageX), U2 = 0.5 * (O[0].pageY + O[1].pageY);
  1336. F2.set(A, U2);
  1337. }
  1338. }
  1339. function st2() {
  1340. const A = O[0].pageX - O[1].pageX, U2 = O[0].pageY - O[1].pageY, J2 = Math.sqrt(A * A + U2 * U2);
  1341. Y2.set(0, J2);
  1342. }
  1343. function Fn() {
  1344. s.enableZoom && st2(), s.enablePan && ye();
  1345. }
  1346. function Qe2() {
  1347. s.enableZoom && st2(), s.enableRotate && je();
  1348. }
  1349. function Bn(A) {
  1350. if (O.length == 1)
  1351. R.set(A.pageX, A.pageY);
  1352. else {
  1353. const J2 = Rt2(A), se = 0.5 * (A.pageX + J2.x), xe = 0.5 * (A.pageY + J2.y);
  1354. R.set(se, xe);
  1355. }
  1356. j.subVectors(R, S).multiplyScalar(s.rotateSpeed);
  1357. const U2 = s.domElement;
  1358. U2 && (he(2 * Math.PI * j.x / U2.clientHeight), _e(2 * Math.PI * j.y / U2.clientHeight)), S.copy(R);
  1359. }
  1360. function on(A) {
  1361. if (O.length == 1)
  1362. V.set(A.pageX, A.pageY);
  1363. else {
  1364. const U2 = Rt2(A), J2 = 0.5 * (A.pageX + U2.x), se = 0.5 * (A.pageY + U2.y);
  1365. V.set(J2, se);
  1366. }
  1367. D2.subVectors(V, F2).multiplyScalar(s.panSpeed), de2(D2.x, D2.y), F2.copy(V);
  1368. }
  1369. function mt2(A) {
  1370. const U2 = Rt2(A), J2 = A.pageX - U2.x, se = A.pageY - U2.y, xe = Math.sqrt(J2 * J2 + se * se);
  1371. G.set(0, xe), N2.set(0, Math.pow(G.y / Y2.y, s.zoomSpeed)), te2(N2.y), Y2.copy(G);
  1372. }
  1373. function At(A) {
  1374. s.enableZoom && mt2(A), s.enablePan && on(A);
  1375. }
  1376. function He(A) {
  1377. s.enableZoom && mt2(A), s.enableRotate && Bn(A);
  1378. }
  1379. function rt2(A) {
  1380. if (s.enabled !== false) {
  1381. if (O.length === 0) {
  1382. var U2, J2;
  1383. (U2 = s.domElement) === null || U2 === void 0 || U2.ownerDocument.addEventListener("pointermove", an), (J2 = s.domElement) === null || J2 === void 0 || J2.ownerDocument.addEventListener("pointerup", ft2);
  1384. }
  1385. Hn(A), A.pointerType === "touch" ? Lt(A) : ui(A);
  1386. }
  1387. }
  1388. function an(A) {
  1389. s.enabled !== false && (A.pointerType === "touch" ? Gn(A) : zn(A));
  1390. }
  1391. function ft2(A) {
  1392. if (Et(A), O.length === 0) {
  1393. var U2, J2, se;
  1394. (U2 = s.domElement) === null || U2 === void 0 || U2.releasePointerCapture(A.pointerId), (J2 = s.domElement) === null || J2 === void 0 || J2.ownerDocument.removeEventListener("pointermove", an), (se = s.domElement) === null || se === void 0 || se.ownerDocument.removeEventListener("pointerup", ft2);
  1395. }
  1396. s.dispatchEvent(u), m = h2.NONE;
  1397. }
  1398. function jn(A) {
  1399. Et(A);
  1400. }
  1401. function ui(A) {
  1402. let U2;
  1403. switch (A.button) {
  1404. case 0:
  1405. U2 = s.mouseButtons.LEFT;
  1406. break;
  1407. case 1:
  1408. U2 = s.mouseButtons.MIDDLE;
  1409. break;
  1410. case 2:
  1411. U2 = s.mouseButtons.RIGHT;
  1412. break;
  1413. default:
  1414. U2 = -1;
  1415. }
  1416. switch (U2) {
  1417. case MOUSE.DOLLY:
  1418. if (s.enableZoom === false)
  1419. return;
  1420. ve(A), m = h2.DOLLY;
  1421. break;
  1422. case MOUSE.ROTATE:
  1423. if (A.ctrlKey || A.metaKey || A.shiftKey) {
  1424. if (s.enablePan === false)
  1425. return;
  1426. le(A), m = h2.PAN;
  1427. } else {
  1428. if (s.enableRotate === false)
  1429. return;
  1430. ke(A), m = h2.ROTATE;
  1431. }
  1432. break;
  1433. case MOUSE.PAN:
  1434. if (A.ctrlKey || A.metaKey || A.shiftKey) {
  1435. if (s.enableRotate === false)
  1436. return;
  1437. ke(A), m = h2.ROTATE;
  1438. } else {
  1439. if (s.enablePan === false)
  1440. return;
  1441. le(A), m = h2.PAN;
  1442. }
  1443. break;
  1444. default:
  1445. m = h2.NONE;
  1446. }
  1447. m !== h2.NONE && s.dispatchEvent(c);
  1448. }
  1449. function zn(A) {
  1450. if (s.enabled !== false)
  1451. switch (m) {
  1452. case h2.ROTATE:
  1453. if (s.enableRotate === false)
  1454. return;
  1455. ie(A);
  1456. break;
  1457. case h2.DOLLY:
  1458. if (s.enableZoom === false)
  1459. return;
  1460. ge(A);
  1461. break;
  1462. case h2.PAN:
  1463. if (s.enablePan === false)
  1464. return;
  1465. M(A);
  1466. break;
  1467. }
  1468. }
  1469. function Un(A) {
  1470. s.enabled === false || s.enableZoom === false || m !== h2.NONE && m !== h2.ROTATE || (A.preventDefault(), s.dispatchEvent(c), ce(A), s.dispatchEvent(u));
  1471. }
  1472. function xt(A) {
  1473. s.enabled === false || s.enablePan === false || Oe(A);
  1474. }
  1475. function Lt(A) {
  1476. switch (vt(A), O.length) {
  1477. case 1:
  1478. switch (s.touches.ONE) {
  1479. case TOUCH.ROTATE:
  1480. if (s.enableRotate === false)
  1481. return;
  1482. je(), m = h2.TOUCH_ROTATE;
  1483. break;
  1484. case TOUCH.PAN:
  1485. if (s.enablePan === false)
  1486. return;
  1487. ye(), m = h2.TOUCH_PAN;
  1488. break;
  1489. default:
  1490. m = h2.NONE;
  1491. }
  1492. break;
  1493. case 2:
  1494. switch (s.touches.TWO) {
  1495. case TOUCH.DOLLY_PAN:
  1496. if (s.enableZoom === false && s.enablePan === false)
  1497. return;
  1498. Fn(), m = h2.TOUCH_DOLLY_PAN;
  1499. break;
  1500. case TOUCH.DOLLY_ROTATE:
  1501. if (s.enableZoom === false && s.enableRotate === false)
  1502. return;
  1503. Qe2(), m = h2.TOUCH_DOLLY_ROTATE;
  1504. break;
  1505. default:
  1506. m = h2.NONE;
  1507. }
  1508. break;
  1509. default:
  1510. m = h2.NONE;
  1511. }
  1512. m !== h2.NONE && s.dispatchEvent(c);
  1513. }
  1514. function Gn(A) {
  1515. switch (vt(A), m) {
  1516. case h2.TOUCH_ROTATE:
  1517. if (s.enableRotate === false)
  1518. return;
  1519. Bn(A), s.update();
  1520. break;
  1521. case h2.TOUCH_PAN:
  1522. if (s.enablePan === false)
  1523. return;
  1524. on(A), s.update();
  1525. break;
  1526. case h2.TOUCH_DOLLY_PAN:
  1527. if (s.enableZoom === false && s.enablePan === false)
  1528. return;
  1529. At(A), s.update();
  1530. break;
  1531. case h2.TOUCH_DOLLY_ROTATE:
  1532. if (s.enableZoom === false && s.enableRotate === false)
  1533. return;
  1534. He(A), s.update();
  1535. break;
  1536. default:
  1537. m = h2.NONE;
  1538. }
  1539. }
  1540. function ln(A) {
  1541. s.enabled !== false && A.preventDefault();
  1542. }
  1543. function Hn(A) {
  1544. O.push(A);
  1545. }
  1546. function Et(A) {
  1547. delete H[A.pointerId];
  1548. for (let U2 = 0; U2 < O.length; U2++)
  1549. if (O[U2].pointerId == A.pointerId) {
  1550. O.splice(U2, 1);
  1551. return;
  1552. }
  1553. }
  1554. function vt(A) {
  1555. let U2 = H[A.pointerId];
  1556. U2 === void 0 && (U2 = new Vector2(), H[A.pointerId] = U2), U2.set(A.pageX, A.pageY);
  1557. }
  1558. function Rt2(A) {
  1559. const U2 = A.pointerId === O[0].pointerId ? O[1] : O[0];
  1560. return H[U2.pointerId];
  1561. }
  1562. r !== void 0 && this.connect(r), this.update();
  1563. }
  1564. };
  1565. var ou = class extends Loader {
  1566. constructor(i) {
  1567. super(i), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(r) {
  1568. return new uu(r);
  1569. }), this.register(function(r) {
  1570. return new gu(r);
  1571. }), this.register(function(r) {
  1572. return new _u(r);
  1573. }), this.register(function(r) {
  1574. return new du(r);
  1575. }), this.register(function(r) {
  1576. return new mu(r);
  1577. }), this.register(function(r) {
  1578. return new fu(r);
  1579. }), this.register(function(r) {
  1580. return new vu(r);
  1581. }), this.register(function(r) {
  1582. return new pu(r);
  1583. }), this.register(function(r) {
  1584. return new bu(r);
  1585. }), this.register(function(r) {
  1586. return new hu(r);
  1587. }), this.register(function(r) {
  1588. return new lu(r);
  1589. }), this.register(function(r) {
  1590. return new wu(r);
  1591. });
  1592. }
  1593. load(i, r, s, a) {
  1594. const c = this;
  1595. let u;
  1596. this.resourcePath !== "" ? u = this.resourcePath : this.path !== "" ? u = this.path : u = LoaderUtils.extractUrlBase(i), this.manager.itemStart(i);
  1597. const h2 = function(g) {
  1598. a ? a(g) : console.error(g), c.manager.itemError(i), c.manager.itemEnd(i);
  1599. }, m = new FileLoader(this.manager);
  1600. m.setPath(this.path), m.setResponseType("arraybuffer"), m.setRequestHeader(this.requestHeader), m.setWithCredentials(this.withCredentials), m.load(i, function(g) {
  1601. try {
  1602. c.parse(g, u, function(w) {
  1603. r(w), c.manager.itemEnd(i);
  1604. }, h2);
  1605. } catch (w) {
  1606. h2(w);
  1607. }
  1608. }, s, h2);
  1609. }
  1610. setDRACOLoader(i) {
  1611. return this.dracoLoader = i, this;
  1612. }
  1613. setDDSLoader() {
  1614. throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".');
  1615. }
  1616. setKTX2Loader(i) {
  1617. return this.ktx2Loader = i, this;
  1618. }
  1619. setMeshoptDecoder(i) {
  1620. return this.meshoptDecoder = i, this;
  1621. }
  1622. register(i) {
  1623. return this.pluginCallbacks.indexOf(i) === -1 && this.pluginCallbacks.push(i), this;
  1624. }
  1625. unregister(i) {
  1626. return this.pluginCallbacks.indexOf(i) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(i), 1), this;
  1627. }
  1628. parse(i, r, s, a) {
  1629. let c;
  1630. const u = {}, h2 = {};
  1631. if (typeof i == "string")
  1632. c = i;
  1633. else if (LoaderUtils.decodeText(new Uint8Array(i, 0, 4)) === Xa) {
  1634. try {
  1635. u[ae.KHR_BINARY_GLTF] = new yu(i);
  1636. } catch (_) {
  1637. a && a(_);
  1638. return;
  1639. }
  1640. c = u[ae.KHR_BINARY_GLTF].content;
  1641. } else
  1642. c = LoaderUtils.decodeText(new Uint8Array(i));
  1643. const m = JSON.parse(c);
  1644. if (m.asset === void 0 || m.asset.version[0] < 2) {
  1645. a && a(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
  1646. return;
  1647. }
  1648. const g = new Vu(m, {
  1649. path: r || this.resourcePath || "",
  1650. crossOrigin: this.crossOrigin,
  1651. requestHeader: this.requestHeader,
  1652. manager: this.manager,
  1653. ktx2Loader: this.ktx2Loader,
  1654. meshoptDecoder: this.meshoptDecoder
  1655. });
  1656. g.fileLoader.setRequestHeader(this.requestHeader);
  1657. for (let w = 0; w < this.pluginCallbacks.length; w++) {
  1658. const _ = this.pluginCallbacks[w](g);
  1659. h2[_.name] = _, u[_.name] = true;
  1660. }
  1661. if (m.extensionsUsed)
  1662. for (let w = 0; w < m.extensionsUsed.length; ++w) {
  1663. const _ = m.extensionsUsed[w], y2 = m.extensionsRequired || [];
  1664. switch (_) {
  1665. case ae.KHR_MATERIALS_UNLIT:
  1666. u[_] = new cu();
  1667. break;
  1668. case ae.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:
  1669. u[_] = new Cu();
  1670. break;
  1671. case ae.KHR_DRACO_MESH_COMPRESSION:
  1672. u[_] = new xu(m, this.dracoLoader);
  1673. break;
  1674. case ae.KHR_TEXTURE_TRANSFORM:
  1675. u[_] = new Eu();
  1676. break;
  1677. case ae.KHR_MESH_QUANTIZATION:
  1678. u[_] = new Pu();
  1679. break;
  1680. default:
  1681. y2.indexOf(_) >= 0 && h2[_] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + _ + '".');
  1682. }
  1683. }
  1684. g.setExtensions(u), g.setPlugins(h2), g.parse(s, a);
  1685. }
  1686. parseAsync(i, r) {
  1687. const s = this;
  1688. return new Promise(function(a, c) {
  1689. s.parse(i, r, a, c);
  1690. });
  1691. }
  1692. };
  1693. function au() {
  1694. let b2 = {};
  1695. return {
  1696. get: function(i) {
  1697. return b2[i];
  1698. },
  1699. add: function(i, r) {
  1700. b2[i] = r;
  1701. },
  1702. remove: function(i) {
  1703. delete b2[i];
  1704. },
  1705. removeAll: function() {
  1706. b2 = {};
  1707. }
  1708. };
  1709. }
  1710. var ae = {
  1711. KHR_BINARY_GLTF: "KHR_binary_glTF",
  1712. KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
  1713. KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
  1714. KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
  1715. KHR_MATERIALS_IOR: "KHR_materials_ior",
  1716. KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: "KHR_materials_pbrSpecularGlossiness",
  1717. KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
  1718. KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
  1719. KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
  1720. KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
  1721. KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
  1722. KHR_MATERIALS_VOLUME: "KHR_materials_volume",
  1723. KHR_TEXTURE_BASISU: "KHR_texture_basisu",
  1724. KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
  1725. KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
  1726. KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
  1727. EXT_TEXTURE_WEBP: "EXT_texture_webp",
  1728. EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression"
  1729. };
  1730. var lu = class {
  1731. constructor(i) {
  1732. this.parser = i, this.name = ae.KHR_LIGHTS_PUNCTUAL, this.cache = {
  1733. refs: {},
  1734. uses: {}
  1735. };
  1736. }
  1737. _markDefs() {
  1738. const i = this.parser, r = this.parser.json.nodes || [];
  1739. for (let s = 0, a = r.length; s < a; s++) {
  1740. const c = r[s];
  1741. c.extensions && c.extensions[this.name] && c.extensions[this.name].light !== void 0 && i._addNodeRef(this.cache, c.extensions[this.name].light);
  1742. }
  1743. }
  1744. _loadLight(i) {
  1745. const r = this.parser, s = "light:" + i;
  1746. let a = r.cache.get(s);
  1747. if (a)
  1748. return a;
  1749. const c = r.json, m = ((c.extensions && c.extensions[this.name] || {}).lights || [])[i];
  1750. let g;
  1751. const w = new Color(16777215);
  1752. m.color !== void 0 && w.fromArray(m.color);
  1753. const _ = m.range !== void 0 ? m.range : 0;
  1754. switch (m.type) {
  1755. case "directional":
  1756. g = new DirectionalLight(w), g.target.position.set(0, 0, -1), g.add(g.target);
  1757. break;
  1758. case "point":
  1759. g = new PointLight(w), g.distance = _;
  1760. break;
  1761. case "spot":
  1762. g = new SpotLight(w), g.distance = _, 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);
  1763. break;
  1764. default:
  1765. throw new Error("THREE.GLTFLoader: Unexpected light type: " + m.type);
  1766. }
  1767. return g.position.set(0, 0, 0), g.decay = 2, m.intensity !== void 0 && (g.intensity = m.intensity), g.name = r.createUniqueName(m.name || "light_" + i), a = Promise.resolve(g), r.cache.add(s, a), a;
  1768. }
  1769. createNodeAttachment(i) {
  1770. const r = this, s = this.parser, c = s.json.nodes[i], h2 = (c.extensions && c.extensions[this.name] || {}).light;
  1771. return h2 === void 0 ? null : this._loadLight(h2).then(function(m) {
  1772. return s._getNodeRef(r.cache, h2, m);
  1773. });
  1774. }
  1775. };
  1776. var cu = class {
  1777. constructor() {
  1778. this.name = ae.KHR_MATERIALS_UNLIT;
  1779. }
  1780. getMaterialType() {
  1781. return MeshBasicMaterial;
  1782. }
  1783. extendParams(i, r, s) {
  1784. const a = [];
  1785. i.color = new Color(1, 1, 1), i.opacity = 1;
  1786. const c = r.pbrMetallicRoughness;
  1787. if (c) {
  1788. if (Array.isArray(c.baseColorFactor)) {
  1789. const u = c.baseColorFactor;
  1790. i.color.fromArray(u), i.opacity = u[3];
  1791. }
  1792. c.baseColorTexture !== void 0 && a.push(s.assignTexture(i, "map", c.baseColorTexture, sRGBEncoding));
  1793. }
  1794. return Promise.all(a);
  1795. }
  1796. };
  1797. var pu = class {
  1798. constructor(i) {
  1799. this.parser = i, this.name = ae.KHR_MATERIALS_EMISSIVE_STRENGTH;
  1800. }
  1801. extendMaterialParams(i, r) {
  1802. const a = this.parser.json.materials[i];
  1803. if (!a.extensions || !a.extensions[this.name])
  1804. return Promise.resolve();
  1805. const c = a.extensions[this.name].emissiveStrength;
  1806. return c !== void 0 && (r.emissiveIntensity = c), Promise.resolve();
  1807. }
  1808. };
  1809. var uu = class {
  1810. constructor(i) {
  1811. this.parser = i, this.name = ae.KHR_MATERIALS_CLEARCOAT;
  1812. }
  1813. getMaterialType(i) {
  1814. const s = this.parser.json.materials[i];
  1815. return !s.extensions || !s.extensions[this.name] ? null : MeshPhysicalMaterial;
  1816. }
  1817. extendMaterialParams(i, r) {
  1818. const s = this.parser, a = s.json.materials[i];
  1819. if (!a.extensions || !a.extensions[this.name])
  1820. return Promise.resolve();
  1821. const c = [], u = a.extensions[this.name];
  1822. if (u.clearcoatFactor !== void 0 && (r.clearcoat = u.clearcoatFactor), u.clearcoatTexture !== void 0 && c.push(s.assignTexture(r, "clearcoatMap", u.clearcoatTexture)), u.clearcoatRoughnessFactor !== void 0 && (r.clearcoatRoughness = u.clearcoatRoughnessFactor), u.clearcoatRoughnessTexture !== void 0 && c.push(s.assignTexture(r, "clearcoatRoughnessMap", u.clearcoatRoughnessTexture)), u.clearcoatNormalTexture !== void 0 && (c.push(s.assignTexture(r, "clearcoatNormalMap", u.clearcoatNormalTexture)), u.clearcoatNormalTexture.scale !== void 0)) {
  1823. const h2 = u.clearcoatNormalTexture.scale;
  1824. r.clearcoatNormalScale = new Vector2(h2, h2);
  1825. }
  1826. return Promise.all(c);
  1827. }
  1828. };
  1829. var hu = class {
  1830. constructor(i) {
  1831. this.parser = i, this.name = ae.KHR_MATERIALS_IRIDESCENCE;
  1832. }
  1833. getMaterialType(i) {
  1834. const s = this.parser.json.materials[i];
  1835. return !s.extensions || !s.extensions[this.name] ? null : MeshPhysicalMaterial;
  1836. }
  1837. extendMaterialParams(i, r) {
  1838. const s = this.parser, a = s.json.materials[i];
  1839. if (!a.extensions || !a.extensions[this.name])
  1840. return Promise.resolve();
  1841. const c = [], u = a.extensions[this.name];
  1842. return u.iridescenceFactor !== void 0 && (r.iridescence = u.iridescenceFactor), u.iridescenceTexture !== void 0 && c.push(s.assignTexture(r, "iridescenceMap", u.iridescenceTexture)), u.iridescenceIor !== void 0 && (r.iridescenceIOR = u.iridescenceIor), r.iridescenceThicknessRange === void 0 && (r.iridescenceThicknessRange = [100, 400]), u.iridescenceThicknessMinimum !== void 0 && (r.iridescenceThicknessRange[0] = u.iridescenceThicknessMinimum), u.iridescenceThicknessMaximum !== void 0 && (r.iridescenceThicknessRange[1] = u.iridescenceThicknessMaximum), u.iridescenceThicknessTexture !== void 0 && c.push(s.assignTexture(r, "iridescenceThicknessMap", u.iridescenceThicknessTexture)), Promise.all(c);
  1843. }
  1844. };
  1845. var du = class {
  1846. constructor(i) {
  1847. this.parser = i, this.name = ae.KHR_MATERIALS_SHEEN;
  1848. }
  1849. getMaterialType(i) {
  1850. const s = this.parser.json.materials[i];
  1851. return !s.extensions || !s.extensions[this.name] ? null : MeshPhysicalMaterial;
  1852. }
  1853. extendMaterialParams(i, r) {
  1854. const s = this.parser, a = s.json.materials[i];
  1855. if (!a.extensions || !a.extensions[this.name])
  1856. return Promise.resolve();
  1857. const c = [];
  1858. r.sheenColor = new Color(0, 0, 0), r.sheenRoughness = 0, r.sheen = 1;
  1859. const u = a.extensions[this.name];
  1860. return u.sheenColorFactor !== void 0 && r.sheenColor.fromArray(u.sheenColorFactor), u.sheenRoughnessFactor !== void 0 && (r.sheenRoughness = u.sheenRoughnessFactor), u.sheenColorTexture !== void 0 && c.push(s.assignTexture(r, "sheenColorMap", u.sheenColorTexture, sRGBEncoding)), u.sheenRoughnessTexture !== void 0 && c.push(s.assignTexture(r, "sheenRoughnessMap", u.sheenRoughnessTexture)), Promise.all(c);
  1861. }
  1862. };
  1863. var mu = class {
  1864. constructor(i) {
  1865. this.parser = i, this.name = ae.KHR_MATERIALS_TRANSMISSION;
  1866. }
  1867. getMaterialType(i) {
  1868. const s = this.parser.json.materials[i];
  1869. return !s.extensions || !s.extensions[this.name] ? null : MeshPhysicalMaterial;
  1870. }
  1871. extendMaterialParams(i, r) {
  1872. const s = this.parser, a = s.json.materials[i];
  1873. if (!a.extensions || !a.extensions[this.name])
  1874. return Promise.resolve();
  1875. const c = [], u = a.extensions[this.name];
  1876. return u.transmissionFactor !== void 0 && (r.transmission = u.transmissionFactor), u.transmissionTexture !== void 0 && c.push(s.assignTexture(r, "transmissionMap", u.transmissionTexture)), Promise.all(c);
  1877. }
  1878. };
  1879. var fu = class {
  1880. constructor(i) {
  1881. this.parser = i, this.name = ae.KHR_MATERIALS_VOLUME;
  1882. }
  1883. getMaterialType(i) {
  1884. const s = this.parser.json.materials[i];
  1885. return !s.extensions || !s.extensions[this.name] ? null : MeshPhysicalMaterial;
  1886. }
  1887. extendMaterialParams(i, r) {
  1888. const s = this.parser, a = s.json.materials[i];
  1889. if (!a.extensions || !a.extensions[this.name])
  1890. return Promise.resolve();
  1891. const c = [], u = a.extensions[this.name];
  1892. r.thickness = u.thicknessFactor !== void 0 ? u.thicknessFactor : 0, u.thicknessTexture !== void 0 && c.push(s.assignTexture(r, "thicknessMap", u.thicknessTexture)), r.attenuationDistance = u.attenuationDistance || 1 / 0;
  1893. const h2 = u.attenuationColor || [1, 1, 1];
  1894. return r.attenuationColor = new Color(h2[0], h2[1], h2[2]), Promise.all(c);
  1895. }
  1896. };
  1897. var vu = class {
  1898. constructor(i) {
  1899. this.parser = i, this.name = ae.KHR_MATERIALS_IOR;
  1900. }
  1901. getMaterialType(i) {
  1902. const s = this.parser.json.materials[i];
  1903. return !s.extensions || !s.extensions[this.name] ? null : MeshPhysicalMaterial;
  1904. }
  1905. extendMaterialParams(i, r) {
  1906. const a = this.parser.json.materials[i];
  1907. if (!a.extensions || !a.extensions[this.name])
  1908. return Promise.resolve();
  1909. const c = a.extensions[this.name];
  1910. return r.ior = c.ior !== void 0 ? c.ior : 1.5, Promise.resolve();
  1911. }
  1912. };
  1913. var bu = class {
  1914. constructor(i) {
  1915. this.parser = i, this.name = ae.KHR_MATERIALS_SPECULAR;
  1916. }
  1917. getMaterialType(i) {
  1918. const s = this.parser.json.materials[i];
  1919. return !s.extensions || !s.extensions[this.name] ? null : MeshPhysicalMaterial;
  1920. }
  1921. extendMaterialParams(i, r) {
  1922. const s = this.parser, a = s.json.materials[i];
  1923. if (!a.extensions || !a.extensions[this.name])
  1924. return Promise.resolve();
  1925. const c = [], u = a.extensions[this.name];
  1926. r.specularIntensity = u.specularFactor !== void 0 ? u.specularFactor : 1, u.specularTexture !== void 0 && c.push(s.assignTexture(r, "specularIntensityMap", u.specularTexture));
  1927. const h2 = u.specularColorFactor || [1, 1, 1];
  1928. return r.specularColor = new Color(h2[0], h2[1], h2[2]), u.specularColorTexture !== void 0 && c.push(s.assignTexture(r, "specularColorMap", u.specularColorTexture, sRGBEncoding)), Promise.all(c);
  1929. }
  1930. };
  1931. var gu = class {
  1932. constructor(i) {
  1933. this.parser = i, this.name = ae.KHR_TEXTURE_BASISU;
  1934. }
  1935. loadTexture(i) {
  1936. const r = this.parser, s = r.json, a = s.textures[i];
  1937. if (!a.extensions || !a.extensions[this.name])
  1938. return null;
  1939. const c = a.extensions[this.name], u = r.options.ktx2Loader;
  1940. if (!u) {
  1941. if (s.extensionsRequired && s.extensionsRequired.indexOf(this.name) >= 0)
  1942. throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
  1943. return null;
  1944. }
  1945. return r.loadTextureImage(i, c.source, u);
  1946. }
  1947. };
  1948. var _u = class {
  1949. constructor(i) {
  1950. this.parser = i, this.name = ae.EXT_TEXTURE_WEBP, this.isSupported = null;
  1951. }
  1952. loadTexture(i) {
  1953. const r = this.name, s = this.parser, a = s.json, c = a.textures[i];
  1954. if (!c.extensions || !c.extensions[r])
  1955. return null;
  1956. const u = c.extensions[r], h2 = a.images[u.source];
  1957. let m = s.textureLoader;
  1958. if (h2.uri) {
  1959. const g = s.options.manager.getHandler(h2.uri);
  1960. g !== null && (m = g);
  1961. }
  1962. return this.detectSupport().then(function(g) {
  1963. if (g)
  1964. return s.loadTextureImage(i, u.source, m);
  1965. if (a.extensionsRequired && a.extensionsRequired.indexOf(r) >= 0)
  1966. throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");
  1967. return s.loadTexture(i);
  1968. });
  1969. }
  1970. detectSupport() {
  1971. return this.isSupported || (this.isSupported = new Promise(function(i) {
  1972. const r = new Image();
  1973. r.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA", r.onload = r.onerror = function() {
  1974. i(r.height === 1);
  1975. };
  1976. })), this.isSupported;
  1977. }
  1978. };
  1979. var wu = class {
  1980. constructor(i) {
  1981. this.name = ae.EXT_MESHOPT_COMPRESSION, this.parser = i;
  1982. }
  1983. loadBufferView(i) {
  1984. const r = this.parser.json, s = r.bufferViews[i];
  1985. if (s.extensions && s.extensions[this.name]) {
  1986. const a = s.extensions[this.name], c = this.parser.getDependency("buffer", a.buffer), u = this.parser.options.meshoptDecoder;
  1987. if (!u || !u.supported) {
  1988. if (r.extensionsRequired && r.extensionsRequired.indexOf(this.name) >= 0)
  1989. throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
  1990. return null;
  1991. }
  1992. return c.then(function(h2) {
  1993. const m = a.byteOffset || 0, g = a.byteLength || 0, w = a.count, _ = a.byteStride, y2 = new Uint8Array(h2, m, g);
  1994. return u.decodeGltfBufferAsync ? u.decodeGltfBufferAsync(w, _, y2, a.mode, a.filter).then(function(C) {
  1995. return C.buffer;
  1996. }) : u.ready.then(function() {
  1997. const C = new ArrayBuffer(w * _);
  1998. return u.decodeGltfBuffer(new Uint8Array(C), w, _, y2, a.mode, a.filter), C;
  1999. });
  2000. });
  2001. } else
  2002. return null;
  2003. }
  2004. };
  2005. var Xa = "glTF";
  2006. var Ui = 12;
  2007. var ca = {
  2008. JSON: 1313821514,
  2009. BIN: 5130562
  2010. };
  2011. var yu = class {
  2012. constructor(i) {
  2013. this.name = ae.KHR_BINARY_GLTF, this.content = null, this.body = null;
  2014. const r = new DataView(i, 0, Ui);
  2015. if (this.header = {
  2016. magic: LoaderUtils.decodeText(new Uint8Array(i.slice(0, 4))),
  2017. version: r.getUint32(4, true),
  2018. length: r.getUint32(8, true)
  2019. }, this.header.magic !== Xa)
  2020. throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
  2021. if (this.header.version < 2)
  2022. throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
  2023. const s = this.header.length - Ui, a = new DataView(i, Ui);
  2024. let c = 0;
  2025. for (; c < s; ) {
  2026. const u = a.getUint32(c, true);
  2027. c += 4;
  2028. const h2 = a.getUint32(c, true);
  2029. if (c += 4, h2 === ca.JSON) {
  2030. const m = new Uint8Array(i, Ui + c, u);
  2031. this.content = LoaderUtils.decodeText(m);
  2032. } else if (h2 === ca.BIN) {
  2033. const m = Ui + c;
  2034. this.body = i.slice(m, m + u);
  2035. }
  2036. c += u;
  2037. }
  2038. if (this.content === null)
  2039. throw new Error("THREE.GLTFLoader: JSON content not found.");
  2040. }
  2041. };
  2042. var xu = class {
  2043. constructor(i, r) {
  2044. if (!r)
  2045. throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
  2046. this.name = ae.KHR_DRACO_MESH_COMPRESSION, this.json = i, this.dracoLoader = r, this.dracoLoader.preload();
  2047. }
  2048. decodePrimitive(i, r) {
  2049. const s = this.json, a = this.dracoLoader, c = i.extensions[this.name].bufferView, u = i.extensions[this.name].attributes, h2 = {}, m = {}, g = {};
  2050. for (const w in u) {
  2051. const _ = uo[w] || w.toLowerCase();
  2052. h2[_] = u[w];
  2053. }
  2054. for (const w in i.attributes) {
  2055. const _ = uo[w] || w.toLowerCase();
  2056. if (u[w] !== void 0) {
  2057. const y2 = s.accessors[i.attributes[w]], C = Zi[y2.componentType];
  2058. g[_] = C.name, m[_] = y2.normalized === true;
  2059. }
  2060. }
  2061. return r.getDependency("bufferView", c).then(function(w) {
  2062. return new Promise(function(_) {
  2063. a.decodeDracoFile(w, function(y2) {
  2064. for (const C in y2.attributes) {
  2065. const I2 = y2.attributes[C], S = m[C];
  2066. S !== void 0 && (I2.normalized = S);
  2067. }
  2068. _(y2);
  2069. }, h2, g);
  2070. });
  2071. });
  2072. }
  2073. };
  2074. var Eu = class {
  2075. constructor() {
  2076. this.name = ae.KHR_TEXTURE_TRANSFORM;
  2077. }
  2078. extendTexture(i, r) {
  2079. return r.texCoord !== void 0 && console.warn('THREE.GLTFLoader: Custom UV sets in "' + this.name + '" extension not yet supported.'), r.offset === void 0 && r.rotation === void 0 && r.scale === void 0 || (i = i.clone(), r.offset !== void 0 && i.offset.fromArray(r.offset), r.rotation !== void 0 && (i.rotation = r.rotation), r.scale !== void 0 && i.repeat.fromArray(r.scale), i.needsUpdate = true), i;
  2080. }
  2081. };
  2082. var po = class extends MeshStandardMaterial {
  2083. constructor(i) {
  2084. super(), this.isGLTFSpecularGlossinessMaterial = true;
  2085. const r = ["#ifdef USE_SPECULARMAP", " uniform sampler2D specularMap;", "#endif"].join(`
  2086. `), s = ["#ifdef USE_GLOSSINESSMAP", " uniform sampler2D glossinessMap;", "#endif"].join(`
  2087. `), a = ["vec3 specularFactor = specular;", "#ifdef USE_SPECULARMAP", " vec4 texelSpecular = texture2D( specularMap, vUv );", " // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture", " specularFactor *= texelSpecular.rgb;", "#endif"].join(`
  2088. `), c = ["float glossinessFactor = glossiness;", "#ifdef USE_GLOSSINESSMAP", " vec4 texelGlossiness = texture2D( glossinessMap, vUv );", " // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture", " glossinessFactor *= texelGlossiness.a;", "#endif"].join(`
  2089. `), u = ["PhysicalMaterial material;", "material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );", "vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );", "float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );", "material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.", "material.roughness += geometryRoughness;", "material.roughness = min( material.roughness, 1.0 );", "material.specularColor = specularFactor;"].join(`
  2090. `), h2 = {
  2091. specular: {
  2092. value: new Color().setHex(16777215)
  2093. },
  2094. glossiness: {
  2095. value: 1
  2096. },
  2097. specularMap: {
  2098. value: null
  2099. },
  2100. glossinessMap: {
  2101. value: null
  2102. }
  2103. };
  2104. this._extraUniforms = h2, this.onBeforeCompile = function(m) {
  2105. for (const g in h2)
  2106. m.uniforms[g] = h2[g];
  2107. m.fragmentShader = m.fragmentShader.replace("uniform float roughness;", "uniform vec3 specular;").replace("uniform float metalness;", "uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>", r).replace("#include <metalnessmap_pars_fragment>", s).replace("#include <roughnessmap_fragment>", a).replace("#include <metalnessmap_fragment>", c).replace("#include <lights_physical_fragment>", u);
  2108. }, Object.defineProperties(this, {
  2109. specular: {
  2110. get: function() {
  2111. return h2.specular.value;
  2112. },
  2113. set: function(m) {
  2114. h2.specular.value = m;
  2115. }
  2116. },
  2117. specularMap: {
  2118. get: function() {
  2119. return h2.specularMap.value;
  2120. },
  2121. set: function(m) {
  2122. h2.specularMap.value = m, m ? this.defines.USE_SPECULARMAP = "" : delete this.defines.USE_SPECULARMAP;
  2123. }
  2124. },
  2125. glossiness: {
  2126. get: function() {
  2127. return h2.glossiness.value;
  2128. },
  2129. set: function(m) {
  2130. h2.glossiness.value = m;
  2131. }
  2132. },
  2133. glossinessMap: {
  2134. get: function() {
  2135. return h2.glossinessMap.value;
  2136. },
  2137. set: function(m) {
  2138. h2.glossinessMap.value = m, m ? (this.defines.USE_GLOSSINESSMAP = "", this.defines.USE_UV = "") : (delete this.defines.USE_GLOSSINESSMAP, delete this.defines.USE_UV);
  2139. }
  2140. }
  2141. }), delete this.metalness, delete this.roughness, delete this.metalnessMap, delete this.roughnessMap, this.setValues(i);
  2142. }
  2143. copy(i) {
  2144. return super.copy(i), this.specularMap = i.specularMap, this.specular.copy(i.specular), this.glossinessMap = i.glossinessMap, this.glossiness = i.glossiness, delete this.metalness, delete this.roughness, delete this.metalnessMap, delete this.roughnessMap, this;
  2145. }
  2146. };
  2147. var Cu = class {
  2148. constructor() {
  2149. this.name = ae.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS, this.specularGlossinessParams = ["color", "map", "lightMap", "lightMapIntensity", "aoMap", "aoMapIntensity", "emissive", "emissiveIntensity", "emissiveMap", "bumpMap", "bumpScale", "normalMap", "normalMapType", "displacementMap", "displacementScale", "displacementBias", "specularMap", "specular", "glossinessMap", "glossiness", "alphaMap", "envMap", "envMapIntensity", "refractionRatio"];
  2150. }
  2151. getMaterialType() {
  2152. return po;
  2153. }
  2154. extendParams(i, r, s) {
  2155. const a = r.extensions[this.name];
  2156. i.color = new Color(1, 1, 1), i.opacity = 1;
  2157. const c = [];
  2158. if (Array.isArray(a.diffuseFactor)) {
  2159. const u = a.diffuseFactor;
  2160. i.color.fromArray(u), i.opacity = u[3];
  2161. }
  2162. if (a.diffuseTexture !== void 0 && c.push(s.assignTexture(i, "map", a.diffuseTexture, sRGBEncoding)), i.emissive = new Color(0, 0, 0), i.glossiness = a.glossinessFactor !== void 0 ? a.glossinessFactor : 1, i.specular = new Color(1, 1, 1), Array.isArray(a.specularFactor) && i.specular.fromArray(a.specularFactor), a.specularGlossinessTexture !== void 0) {
  2163. const u = a.specularGlossinessTexture;
  2164. c.push(s.assignTexture(i, "glossinessMap", u)), c.push(s.assignTexture(i, "specularMap", u, sRGBEncoding));
  2165. }
  2166. return Promise.all(c);
  2167. }
  2168. createMaterial(i) {
  2169. const r = new po(i);
  2170. return r.fog = true, r.color = i.color, r.map = i.map === void 0 ? null : i.map, r.lightMap = null, r.lightMapIntensity = 1, r.aoMap = i.aoMap === void 0 ? null : i.aoMap, r.aoMapIntensity = 1, r.emissive = i.emissive, r.emissiveIntensity = i.emissiveIntensity === void 0 ? 1 : i.emissiveIntensity, r.emissiveMap = i.emissiveMap === void 0 ? null : i.emissiveMap, r.bumpMap = i.bumpMap === void 0 ? null : i.bumpMap, r.bumpScale = 1, r.normalMap = i.normalMap === void 0 ? null : i.normalMap, r.normalMapType = TangentSpaceNormalMap, i.normalScale && (r.normalScale = i.normalScale), r.displacementMap = null, r.displacementScale = 1, r.displacementBias = 0, r.specularMap = i.specularMap === void 0 ? null : i.specularMap, r.specular = i.specular, r.glossinessMap = i.glossinessMap === void 0 ? null : i.glossinessMap, r.glossiness = i.glossiness, r.alphaMap = null, r.envMap = i.envMap === void 0 ? null : i.envMap, r.envMapIntensity = 1, r.refractionRatio = 0.98, r;
  2171. }
  2172. };
  2173. var Pu = class {
  2174. constructor() {
  2175. this.name = ae.KHR_MESH_QUANTIZATION;
  2176. }
  2177. };
  2178. var Ya = class extends Interpolant {
  2179. constructor(i, r, s, a) {
  2180. super(i, r, s, a);
  2181. }
  2182. copySampleValue_(i) {
  2183. const r = this.resultBuffer, s = this.sampleValues, a = this.valueSize, c = i * a * 3 + a;
  2184. for (let u = 0; u !== a; u++)
  2185. r[u] = s[c + u];
  2186. return r;
  2187. }
  2188. interpolate_(i, r, s, a) {
  2189. const c = this.resultBuffer, u = this.sampleValues, h2 = this.valueSize, m = h2 * 2, g = h2 * 3, w = a - r, _ = (s - r) / w, y2 = _ * _, C = y2 * _, I2 = i * g, S = I2 - g, R = -2 * C + 3 * y2, j = C - y2, F2 = 1 - R, V = j - y2 + _;
  2190. for (let D2 = 0; D2 !== h2; D2++) {
  2191. const Y2 = u[S + D2 + h2], G = u[S + D2 + m] * w, N2 = u[I2 + D2 + h2], O = u[I2 + D2] * w;
  2192. c[D2] = F2 * Y2 + V * G + R * N2 + j * O;
  2193. }
  2194. return c;
  2195. }
  2196. };
  2197. var Tu = new Quaternion();
  2198. var ku = class extends Ya {
  2199. interpolate_(i, r, s, a) {
  2200. const c = super.interpolate_(i, r, s, a);
  2201. return Tu.fromArray(c).normalize().toArray(c), c;
  2202. }
  2203. };
  2204. var Bt = {
  2205. FLOAT: 5126,
  2206. //FLOAT_MAT2: 35674,
  2207. FLOAT_MAT3: 35675,
  2208. FLOAT_MAT4: 35676,
  2209. FLOAT_VEC2: 35664,
  2210. FLOAT_VEC3: 35665,
  2211. FLOAT_VEC4: 35666,
  2212. LINEAR: 9729,
  2213. REPEAT: 10497,
  2214. SAMPLER_2D: 35678,
  2215. POINTS: 0,
  2216. LINES: 1,
  2217. LINE_LOOP: 2,
  2218. LINE_STRIP: 3,
  2219. TRIANGLES: 4,
  2220. TRIANGLE_STRIP: 5,
  2221. TRIANGLE_FAN: 6,
  2222. UNSIGNED_BYTE: 5121,
  2223. UNSIGNED_SHORT: 5123
  2224. };
  2225. var Zi = {
  2226. 5120: Int8Array,
  2227. 5121: Uint8Array,
  2228. 5122: Int16Array,
  2229. 5123: Uint16Array,
  2230. 5125: Uint32Array,
  2231. 5126: Float32Array
  2232. };
  2233. var pa = {
  2234. 9728: NearestFilter,
  2235. 9729: LinearFilter,
  2236. 9984: NearestMipmapNearestFilter,
  2237. 9985: LinearMipmapNearestFilter,
  2238. 9986: NearestMipmapLinearFilter,
  2239. 9987: LinearMipmapLinearFilter
  2240. };
  2241. var ua = {
  2242. 33071: ClampToEdgeWrapping,
  2243. 33648: MirroredRepeatWrapping,
  2244. 10497: RepeatWrapping
  2245. };
  2246. var ha = {
  2247. SCALAR: 1,
  2248. VEC2: 2,
  2249. VEC3: 3,
  2250. VEC4: 4,
  2251. MAT2: 4,
  2252. MAT3: 9,
  2253. MAT4: 16
  2254. };
  2255. var uo = {
  2256. POSITION: "position",
  2257. NORMAL: "normal",
  2258. TANGENT: "tangent",
  2259. TEXCOORD_0: "uv",
  2260. TEXCOORD_1: "uv2",
  2261. COLOR_0: "color",
  2262. WEIGHTS_0: "skinWeight",
  2263. JOINTS_0: "skinIndex"
  2264. };
  2265. var nn = {
  2266. scale: "scale",
  2267. translation: "position",
  2268. rotation: "quaternion",
  2269. weights: "morphTargetInfluences"
  2270. };
  2271. var Mu = {
  2272. CUBICSPLINE: void 0,
  2273. // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
  2274. // keyframe track will be initialized with a default interpolation type, then modified.
  2275. LINEAR: InterpolateLinear,
  2276. STEP: InterpolateDiscrete
  2277. };
  2278. var Wr = {
  2279. OPAQUE: "OPAQUE",
  2280. MASK: "MASK",
  2281. BLEND: "BLEND"
  2282. };
  2283. function Su(b2) {
  2284. return b2.DefaultMaterial === void 0 && (b2.DefaultMaterial = new MeshStandardMaterial({
  2285. color: 16777215,
  2286. emissive: 0,
  2287. metalness: 1,
  2288. roughness: 1,
  2289. transparent: false,
  2290. depthTest: true,
  2291. side: FrontSide
  2292. })), b2.DefaultMaterial;
  2293. }
  2294. function Gi(b2, i, r) {
  2295. for (const s in r.extensions)
  2296. b2[s] === void 0 && (i.userData.gltfExtensions = i.userData.gltfExtensions || {}, i.userData.gltfExtensions[s] = r.extensions[s]);
  2297. }
  2298. function Ln(b2, i) {
  2299. i.extras !== void 0 && (typeof i.extras == "object" ? Object.assign(b2.userData, i.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + i.extras));
  2300. }
  2301. function Au(b2, i, r) {
  2302. let s = false, a = false, c = false;
  2303. for (let g = 0, w = i.length; g < w; g++) {
  2304. const _ = i[g];
  2305. if (_.POSITION !== void 0 && (s = true), _.NORMAL !== void 0 && (a = true), _.COLOR_0 !== void 0 && (c = true), s && a && c)
  2306. break;
  2307. }
  2308. if (!s && !a && !c)
  2309. return Promise.resolve(b2);
  2310. const u = [], h2 = [], m = [];
  2311. for (let g = 0, w = i.length; g < w; g++) {
  2312. const _ = i[g];
  2313. if (s) {
  2314. const y2 = _.POSITION !== void 0 ? r.getDependency("accessor", _.POSITION) : b2.attributes.position;
  2315. u.push(y2);
  2316. }
  2317. if (a) {
  2318. const y2 = _.NORMAL !== void 0 ? r.getDependency("accessor", _.NORMAL) : b2.attributes.normal;
  2319. h2.push(y2);
  2320. }
  2321. if (c) {
  2322. const y2 = _.COLOR_0 !== void 0 ? r.getDependency("accessor", _.COLOR_0) : b2.attributes.color;
  2323. m.push(y2);
  2324. }
  2325. }
  2326. return Promise.all([Promise.all(u), Promise.all(h2), Promise.all(m)]).then(function(g) {
  2327. const w = g[0], _ = g[1], y2 = g[2];
  2328. return s && (b2.morphAttributes.position = w), a && (b2.morphAttributes.normal = _), c && (b2.morphAttributes.color = y2), b2.morphTargetsRelative = true, b2;
  2329. });
  2330. }
  2331. function Lu(b2, i) {
  2332. if (b2.updateMorphTargets(), i.weights !== void 0)
  2333. for (let r = 0, s = i.weights.length; r < s; r++)
  2334. b2.morphTargetInfluences[r] = i.weights[r];
  2335. if (i.extras && Array.isArray(i.extras.targetNames)) {
  2336. const r = i.extras.targetNames;
  2337. if (b2.morphTargetInfluences.length === r.length) {
  2338. b2.morphTargetDictionary = {};
  2339. for (let s = 0, a = r.length; s < a; s++)
  2340. b2.morphTargetDictionary[r[s]] = s;
  2341. } else
  2342. console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
  2343. }
  2344. }
  2345. function Ru(b2) {
  2346. const i = b2.extensions && b2.extensions[ae.KHR_DRACO_MESH_COMPRESSION];
  2347. let r;
  2348. return i ? r = "draco:" + i.bufferView + ":" + i.indices + ":" + da(i.attributes) : r = b2.indices + ":" + da(b2.attributes) + ":" + b2.mode, r;
  2349. }
  2350. function da(b2) {
  2351. let i = "";
  2352. const r = Object.keys(b2).sort();
  2353. for (let s = 0, a = r.length; s < a; s++)
  2354. i += r[s] + ":" + b2[r[s]] + ";";
  2355. return i;
  2356. }
  2357. function ho(b2) {
  2358. switch (b2) {
  2359. case Int8Array:
  2360. return 1 / 127;
  2361. case Uint8Array:
  2362. return 1 / 255;
  2363. case Int16Array:
  2364. return 1 / 32767;
  2365. case Uint16Array:
  2366. return 1 / 65535;
  2367. default:
  2368. throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
  2369. }
  2370. }
  2371. function Iu(b2) {
  2372. return b2.search(/\.jpe?g($|\?)/i) > 0 || b2.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : b2.search(/\.webp($|\?)/i) > 0 || b2.search(/^data\:image\/webp/) === 0 ? "image/webp" : "image/png";
  2373. }
  2374. var Vu = class {
  2375. constructor(i = {}, r = {}) {
  2376. var s, a;
  2377. this.json = i, this.extensions = {}, this.plugins = {}, this.options = r, this.cache = new au(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.meshCache = {
  2378. refs: {},
  2379. uses: {}
  2380. }, this.cameraCache = {
  2381. refs: {},
  2382. uses: {}
  2383. }, this.lightCache = {
  2384. refs: {},
  2385. uses: {}
  2386. }, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {};
  2387. const c = typeof navigator < "u" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent) === true, u = typeof navigator < "u" && ((s = navigator.userAgent) === null || s === void 0 ? void 0 : s.indexOf("Firefox")) > -1, h2 = typeof navigator < "u" && u ? (a = navigator.userAgent) === null || a === void 0 ? void 0 : a.match(/Firefox\/([0-9]+)\./)[1] : -1;
  2388. typeof createImageBitmap > "u" || c || u && h2 < 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);
  2389. }
  2390. setExtensions(i) {
  2391. this.extensions = i;
  2392. }
  2393. setPlugins(i) {
  2394. this.plugins = i;
  2395. }
  2396. parse(i, r) {
  2397. const s = this, a = this.json, c = this.extensions;
  2398. this.cache.removeAll(), this._invokeAll(function(u) {
  2399. return u._markDefs && u._markDefs();
  2400. }), Promise.all(this._invokeAll(function(u) {
  2401. return u.beforeRoot && u.beforeRoot();
  2402. })).then(function() {
  2403. return Promise.all([s.getDependencies("scene"), s.getDependencies("animation"), s.getDependencies("camera")]);
  2404. }).then(function(u) {
  2405. const h2 = {
  2406. scene: u[0][a.scene || 0],
  2407. scenes: u[0],
  2408. animations: u[1],
  2409. cameras: u[2],
  2410. asset: a.asset,
  2411. parser: s,
  2412. userData: {}
  2413. };
  2414. Gi(c, h2, a), Ln(h2, a), Promise.all(s._invokeAll(function(m) {
  2415. return m.afterRoot && m.afterRoot(h2);
  2416. })).then(function() {
  2417. i(h2);
  2418. });
  2419. }).catch(r);
  2420. }
  2421. /**
  2422. * Marks the special nodes/meshes in json for efficient parse.
  2423. */
  2424. _markDefs() {
  2425. const i = this.json.nodes || [], r = this.json.skins || [], s = this.json.meshes || [];
  2426. for (let a = 0, c = r.length; a < c; a++) {
  2427. const u = r[a].joints;
  2428. for (let h2 = 0, m = u.length; h2 < m; h2++)
  2429. i[u[h2]].isBone = true;
  2430. }
  2431. for (let a = 0, c = i.length; a < c; a++) {
  2432. const u = i[a];
  2433. u.mesh !== void 0 && (this._addNodeRef(this.meshCache, u.mesh), u.skin !== void 0 && (s[u.mesh].isSkinnedMesh = true)), u.camera !== void 0 && this._addNodeRef(this.cameraCache, u.camera);
  2434. }
  2435. }
  2436. /**
  2437. * Counts references to shared node / Object3D resources. These resources
  2438. * can be reused, or "instantiated", at multiple nodes in the scene
  2439. * hierarchy. Mesh, Camera, and Light instances are instantiated and must
  2440. * be marked. Non-scenegraph resources (like Materials, Geometries, and
  2441. * Textures) can be reused directly and are not marked here.
  2442. *
  2443. * Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
  2444. */
  2445. _addNodeRef(i, r) {
  2446. r !== void 0 && (i.refs[r] === void 0 && (i.refs[r] = i.uses[r] = 0), i.refs[r]++);
  2447. }
  2448. /** Returns a reference to a shared resource, cloning it if necessary. */
  2449. _getNodeRef(i, r, s) {
  2450. if (i.refs[r] <= 1)
  2451. return s;
  2452. const a = s.clone(), c = (u, h2) => {
  2453. const m = this.associations.get(u);
  2454. m != null && this.associations.set(h2, m);
  2455. for (const [g, w] of u.children.entries())
  2456. c(w, h2.children[g]);
  2457. };
  2458. return c(s, a), a.name += "_instance_" + i.uses[r]++, a;
  2459. }
  2460. _invokeOne(i) {
  2461. const r = Object.values(this.plugins);
  2462. r.push(this);
  2463. for (let s = 0; s < r.length; s++) {
  2464. const a = i(r[s]);
  2465. if (a)
  2466. return a;
  2467. }
  2468. return null;
  2469. }
  2470. _invokeAll(i) {
  2471. const r = Object.values(this.plugins);
  2472. r.unshift(this);
  2473. const s = [];
  2474. for (let a = 0; a < r.length; a++) {
  2475. const c = i(r[a]);
  2476. c && s.push(c);
  2477. }
  2478. return s;
  2479. }
  2480. /**
  2481. * Requests the specified dependency asynchronously, with caching.
  2482. * @param {string} type
  2483. * @param {number} index
  2484. * @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
  2485. */
  2486. getDependency(i, r) {
  2487. const s = i + ":" + r;
  2488. let a = this.cache.get(s);
  2489. if (!a) {
  2490. switch (i) {
  2491. case "scene":
  2492. a = this.loadScene(r);
  2493. break;
  2494. case "node":
  2495. a = this.loadNode(r);
  2496. break;
  2497. case "mesh":
  2498. a = this._invokeOne(function(c) {
  2499. return c.loadMesh && c.loadMesh(r);
  2500. });
  2501. break;
  2502. case "accessor":
  2503. a = this.loadAccessor(r);
  2504. break;
  2505. case "bufferView":
  2506. a = this._invokeOne(function(c) {
  2507. return c.loadBufferView && c.loadBufferView(r);
  2508. });
  2509. break;
  2510. case "buffer":
  2511. a = this.loadBuffer(r);
  2512. break;
  2513. case "material":
  2514. a = this._invokeOne(function(c) {
  2515. return c.loadMaterial && c.loadMaterial(r);
  2516. });
  2517. break;
  2518. case "texture":
  2519. a = this._invokeOne(function(c) {
  2520. return c.loadTexture && c.loadTexture(r);
  2521. });
  2522. break;
  2523. case "skin":
  2524. a = this.loadSkin(r);
  2525. break;
  2526. case "animation":
  2527. a = this._invokeOne(function(c) {
  2528. return c.loadAnimation && c.loadAnimation(r);
  2529. });
  2530. break;
  2531. case "camera":
  2532. a = this.loadCamera(r);
  2533. break;
  2534. default:
  2535. throw new Error("Unknown type: " + i);
  2536. }
  2537. this.cache.add(s, a);
  2538. }
  2539. return a;
  2540. }
  2541. /**
  2542. * Requests all dependencies of the specified type asynchronously, with caching.
  2543. * @param {string} type
  2544. * @return {Promise<Array<Object>>}
  2545. */
  2546. getDependencies(i) {
  2547. let r = this.cache.get(i);
  2548. if (!r) {
  2549. const s = this, a = this.json[i + (i === "mesh" ? "es" : "s")] || [];
  2550. r = Promise.all(a.map(function(c, u) {
  2551. return s.getDependency(i, u);
  2552. })), this.cache.add(i, r);
  2553. }
  2554. return r;
  2555. }
  2556. /**
  2557. * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
  2558. * @param {number} bufferIndex
  2559. * @return {Promise<ArrayBuffer>}
  2560. */
  2561. loadBuffer(i) {
  2562. const r = this.json.buffers[i], s = this.fileLoader;
  2563. if (r.type && r.type !== "arraybuffer")
  2564. throw new Error("THREE.GLTFLoader: " + r.type + " buffer type is not supported.");
  2565. if (r.uri === void 0 && i === 0)
  2566. return Promise.resolve(this.extensions[ae.KHR_BINARY_GLTF].body);
  2567. const a = this.options;
  2568. return new Promise(function(c, u) {
  2569. s.load(LoaderUtils.resolveURL(r.uri, a.path), c, void 0, function() {
  2570. u(new Error('THREE.GLTFLoader: Failed to load buffer "' + r.uri + '".'));
  2571. });
  2572. });
  2573. }
  2574. /**
  2575. * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
  2576. * @param {number} bufferViewIndex
  2577. * @return {Promise<ArrayBuffer>}
  2578. */
  2579. loadBufferView(i) {
  2580. const r = this.json.bufferViews[i];
  2581. return this.getDependency("buffer", r.buffer).then(function(s) {
  2582. const a = r.byteLength || 0, c = r.byteOffset || 0;
  2583. return s.slice(c, c + a);
  2584. });
  2585. }
  2586. /**
  2587. * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
  2588. * @param {number} accessorIndex
  2589. * @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
  2590. */
  2591. loadAccessor(i) {
  2592. const r = this, s = this.json, a = this.json.accessors[i];
  2593. if (a.bufferView === void 0 && a.sparse === void 0)
  2594. return Promise.resolve(null);
  2595. const c = [];
  2596. return a.bufferView !== void 0 ? c.push(this.getDependency("bufferView", a.bufferView)) : c.push(null), a.sparse !== void 0 && (c.push(this.getDependency("bufferView", a.sparse.indices.bufferView)), c.push(this.getDependency("bufferView", a.sparse.values.bufferView))), Promise.all(c).then(function(u) {
  2597. const h2 = u[0], m = ha[a.type], g = Zi[a.componentType], w = g.BYTES_PER_ELEMENT, _ = w * m, y2 = a.byteOffset || 0, C = a.bufferView !== void 0 ? s.bufferViews[a.bufferView].byteStride : void 0, I2 = a.normalized === true;
  2598. let S, R;
  2599. if (C && C !== _) {
  2600. const j = Math.floor(y2 / C), F2 = "InterleavedBuffer:" + a.bufferView + ":" + a.componentType + ":" + j + ":" + a.count;
  2601. let V = r.cache.get(F2);
  2602. V || (S = new g(h2, j * C, a.count * C / w), V = new InterleavedBuffer(S, C / w), r.cache.add(F2, V)), R = new InterleavedBufferAttribute(V, m, y2 % C / w, I2);
  2603. } else
  2604. h2 === null ? S = new g(a.count * m) : S = new g(h2, y2, a.count * m), R = new BufferAttribute(S, m, I2);
  2605. if (a.sparse !== void 0) {
  2606. const j = ha.SCALAR, F2 = Zi[a.sparse.indices.componentType], V = a.sparse.indices.byteOffset || 0, D2 = a.sparse.values.byteOffset || 0, Y2 = new F2(u[1], V, a.sparse.count * j), G = new g(u[2], D2, a.sparse.count * m);
  2607. h2 !== null && (R = new BufferAttribute(R.array.slice(), R.itemSize, R.normalized));
  2608. for (let N2 = 0, O = Y2.length; N2 < O; N2++) {
  2609. const H = Y2[N2];
  2610. if (R.setX(H, G[N2 * m]), m >= 2 && R.setY(H, G[N2 * m + 1]), m >= 3 && R.setZ(H, G[N2 * m + 2]), m >= 4 && R.setW(H, G[N2 * m + 3]), m >= 5)
  2611. throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
  2612. }
  2613. }
  2614. return R;
  2615. });
  2616. }
  2617. /**
  2618. * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
  2619. * @param {number} textureIndex
  2620. * @return {Promise<THREE.Texture>}
  2621. */
  2622. loadTexture(i) {
  2623. const r = this.json, s = this.options, c = r.textures[i].source, u = r.images[c];
  2624. let h2 = this.textureLoader;
  2625. if (u.uri) {
  2626. const m = s.manager.getHandler(u.uri);
  2627. m !== null && (h2 = m);
  2628. }
  2629. return this.loadTextureImage(i, c, h2);
  2630. }
  2631. loadTextureImage(i, r, s) {
  2632. const a = this, c = this.json, u = c.textures[i], h2 = c.images[r], m = (h2.uri || h2.bufferView) + ":" + u.sampler;
  2633. if (this.textureCache[m])
  2634. return this.textureCache[m];
  2635. const g = this.loadImageSource(r, s).then(function(w) {
  2636. w.flipY = false, u.name && (w.name = u.name);
  2637. const y2 = (c.samplers || {})[u.sampler] || {};
  2638. return w.magFilter = pa[y2.magFilter] || LinearFilter, w.minFilter = pa[y2.minFilter] || LinearMipmapLinearFilter, w.wrapS = ua[y2.wrapS] || RepeatWrapping, w.wrapT = ua[y2.wrapT] || RepeatWrapping, a.associations.set(w, {
  2639. textures: i
  2640. }), w;
  2641. }).catch(function() {
  2642. return null;
  2643. });
  2644. return this.textureCache[m] = g, g;
  2645. }
  2646. loadImageSource(i, r) {
  2647. const s = this, a = this.json, c = this.options;
  2648. if (this.sourceCache[i] !== void 0)
  2649. return this.sourceCache[i].then((_) => _.clone());
  2650. const u = a.images[i], h2 = self.URL || self.webkitURL;
  2651. let m = u.uri || "", g = false;
  2652. if (u.bufferView !== void 0)
  2653. m = s.getDependency("bufferView", u.bufferView).then(function(_) {
  2654. g = true;
  2655. const y2 = new Blob([_], {
  2656. type: u.mimeType
  2657. });
  2658. return m = h2.createObjectURL(y2), m;
  2659. });
  2660. else if (u.uri === void 0)
  2661. throw new Error("THREE.GLTFLoader: Image " + i + " is missing URI and bufferView");
  2662. const w = Promise.resolve(m).then(function(_) {
  2663. return new Promise(function(y2, C) {
  2664. let I2 = y2;
  2665. r.isImageBitmapLoader === true && (I2 = function(S) {
  2666. const R = new Texture(S);
  2667. R.needsUpdate = true, y2(R);
  2668. }), r.load(LoaderUtils.resolveURL(_, c.path), I2, void 0, C);
  2669. });
  2670. }).then(function(_) {
  2671. return g === true && h2.revokeObjectURL(m), _.userData.mimeType = u.mimeType || Iu(u.uri), _;
  2672. }).catch(function(_) {
  2673. throw console.error("THREE.GLTFLoader: Couldn't load texture", m), _;
  2674. });
  2675. return this.sourceCache[i] = w, w;
  2676. }
  2677. /**
  2678. * Asynchronously assigns a texture to the given material parameters.
  2679. * @param {Object} materialParams
  2680. * @param {string} mapName
  2681. * @param {Object} mapDef
  2682. * @return {Promise<Texture>}
  2683. */
  2684. assignTexture(i, r, s, a) {
  2685. const c = this;
  2686. return this.getDependency("texture", s.index).then(function(u) {
  2687. if (s.texCoord !== void 0 && s.texCoord != 0 && !(r === "aoMap" && s.texCoord == 1) && console.warn("THREE.GLTFLoader: Custom UV set " + s.texCoord + " for texture " + r + " not yet supported."), c.extensions[ae.KHR_TEXTURE_TRANSFORM]) {
  2688. const h2 = s.extensions !== void 0 ? s.extensions[ae.KHR_TEXTURE_TRANSFORM] : void 0;
  2689. if (h2) {
  2690. const m = c.associations.get(u);
  2691. u = c.extensions[ae.KHR_TEXTURE_TRANSFORM].extendTexture(u, h2), c.associations.set(u, m);
  2692. }
  2693. }
  2694. return a !== void 0 && (u.encoding = a), i[r] = u, u;
  2695. });
  2696. }
  2697. /**
  2698. * Assigns final material to a Mesh, Line, or Points instance. The instance
  2699. * already has a material (generated from the glTF material options alone)
  2700. * but reuse of the same glTF material may require multiple threejs materials
  2701. * to accommodate different primitive types, defines, etc. New materials will
  2702. * be created if necessary, and reused from a cache.
  2703. * @param {Object3D} mesh Mesh, Line, or Points instance.
  2704. */
  2705. assignFinalMaterial(i) {
  2706. const r = i.geometry;
  2707. let s = i.material;
  2708. const a = r.attributes.tangent === void 0, c = r.attributes.color !== void 0, u = r.attributes.normal === void 0;
  2709. if (i.isPoints) {
  2710. const h2 = "PointsMaterial:" + s.uuid;
  2711. let m = this.cache.get(h2);
  2712. m || (m = new PointsMaterial(), Material.prototype.copy.call(m, s), m.color.copy(s.color), m.map = s.map, m.sizeAttenuation = false, this.cache.add(h2, m)), s = m;
  2713. } else if (i.isLine) {
  2714. const h2 = "LineBasicMaterial:" + s.uuid;
  2715. let m = this.cache.get(h2);
  2716. m || (m = new LineBasicMaterial(), Material.prototype.copy.call(m, s), m.color.copy(s.color), this.cache.add(h2, m)), s = m;
  2717. }
  2718. if (a || c || u) {
  2719. let h2 = "ClonedMaterial:" + s.uuid + ":";
  2720. s.isGLTFSpecularGlossinessMaterial && (h2 += "specular-glossiness:"), a && (h2 += "derivative-tangents:"), c && (h2 += "vertex-colors:"), u && (h2 += "flat-shading:");
  2721. let m = this.cache.get(h2);
  2722. m || (m = s.clone(), c && (m.vertexColors = true), u && (m.flatShading = true), a && (m.normalScale && (m.normalScale.y *= -1), m.clearcoatNormalScale && (m.clearcoatNormalScale.y *= -1)), this.cache.add(h2, m), this.associations.set(m, this.associations.get(s))), s = m;
  2723. }
  2724. s.aoMap && r.attributes.uv2 === void 0 && r.attributes.uv !== void 0 && r.setAttribute("uv2", r.attributes.uv), i.material = s;
  2725. }
  2726. getMaterialType() {
  2727. return MeshStandardMaterial;
  2728. }
  2729. /**
  2730. * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
  2731. * @param {number} materialIndex
  2732. * @return {Promise<Material>}
  2733. */
  2734. loadMaterial(i) {
  2735. const r = this, s = this.json, a = this.extensions, c = s.materials[i];
  2736. let u;
  2737. const h2 = {}, m = c.extensions || {}, g = [];
  2738. if (m[ae.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]) {
  2739. const _ = a[ae.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];
  2740. u = _.getMaterialType(), g.push(_.extendParams(h2, c, r));
  2741. } else if (m[ae.KHR_MATERIALS_UNLIT]) {
  2742. const _ = a[ae.KHR_MATERIALS_UNLIT];
  2743. u = _.getMaterialType(), g.push(_.extendParams(h2, c, r));
  2744. } else {
  2745. const _ = c.pbrMetallicRoughness || {};
  2746. if (h2.color = new Color(1, 1, 1), h2.opacity = 1, Array.isArray(_.baseColorFactor)) {
  2747. const y2 = _.baseColorFactor;
  2748. h2.color.fromArray(y2), h2.opacity = y2[3];
  2749. }
  2750. _.baseColorTexture !== void 0 && g.push(r.assignTexture(h2, "map", _.baseColorTexture, sRGBEncoding)), h2.metalness = _.metallicFactor !== void 0 ? _.metallicFactor : 1, h2.roughness = _.roughnessFactor !== void 0 ? _.roughnessFactor : 1, _.metallicRoughnessTexture !== void 0 && (g.push(r.assignTexture(h2, "metalnessMap", _.metallicRoughnessTexture)), g.push(r.assignTexture(h2, "roughnessMap", _.metallicRoughnessTexture))), u = this._invokeOne(function(y2) {
  2751. return y2.getMaterialType && y2.getMaterialType(i);
  2752. }), g.push(Promise.all(this._invokeAll(function(y2) {
  2753. return y2.extendMaterialParams && y2.extendMaterialParams(i, h2);
  2754. })));
  2755. }
  2756. c.doubleSided === true && (h2.side = DoubleSide);
  2757. const w = c.alphaMode || Wr.OPAQUE;
  2758. if (w === Wr.BLEND ? (h2.transparent = true, h2.depthWrite = false) : (h2.transparent = false, w === Wr.MASK && (h2.alphaTest = c.alphaCutoff !== void 0 ? c.alphaCutoff : 0.5)), c.normalTexture !== void 0 && u !== MeshBasicMaterial && (g.push(r.assignTexture(h2, "normalMap", c.normalTexture)), h2.normalScale = new Vector2(1, 1), c.normalTexture.scale !== void 0)) {
  2759. const _ = c.normalTexture.scale;
  2760. h2.normalScale.set(_, _);
  2761. }
  2762. return c.occlusionTexture !== void 0 && u !== MeshBasicMaterial && (g.push(r.assignTexture(h2, "aoMap", c.occlusionTexture)), c.occlusionTexture.strength !== void 0 && (h2.aoMapIntensity = c.occlusionTexture.strength)), c.emissiveFactor !== void 0 && u !== MeshBasicMaterial && (h2.emissive = new Color().fromArray(c.emissiveFactor)), c.emissiveTexture !== void 0 && u !== MeshBasicMaterial && g.push(r.assignTexture(h2, "emissiveMap", c.emissiveTexture, sRGBEncoding)), Promise.all(g).then(function() {
  2763. let _;
  2764. return u === po ? _ = a[ae.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(h2) : _ = new u(h2), c.name && (_.name = c.name), Ln(_, c), r.associations.set(_, {
  2765. materials: i
  2766. }), c.extensions && Gi(a, _, c), _;
  2767. });
  2768. }
  2769. /** When Object3D instances are targeted by animation, they need unique names. */
  2770. createUniqueName(i) {
  2771. const r = PropertyBinding.sanitizeNodeName(i || "");
  2772. let s = r;
  2773. for (let a = 1; this.nodeNamesUsed[s]; ++a)
  2774. s = r + "_" + a;
  2775. return this.nodeNamesUsed[s] = true, s;
  2776. }
  2777. /**
  2778. * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
  2779. *
  2780. * Creates BufferGeometries from primitives.
  2781. *
  2782. * @param {Array<GLTF.Primitive>} primitives
  2783. * @return {Promise<Array<BufferGeometry>>}
  2784. */
  2785. loadGeometries(i) {
  2786. const r = this, s = this.extensions, a = this.primitiveCache;
  2787. function c(h2) {
  2788. return s[ae.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(h2, r).then(function(m) {
  2789. return ma(m, h2, r);
  2790. });
  2791. }
  2792. const u = [];
  2793. for (let h2 = 0, m = i.length; h2 < m; h2++) {
  2794. const g = i[h2], w = Ru(g), _ = a[w];
  2795. if (_)
  2796. u.push(_.promise);
  2797. else {
  2798. let y2;
  2799. g.extensions && g.extensions[ae.KHR_DRACO_MESH_COMPRESSION] ? y2 = c(g) : y2 = ma(new BufferGeometry(), g, r), a[w] = {
  2800. primitive: g,
  2801. promise: y2
  2802. }, u.push(y2);
  2803. }
  2804. }
  2805. return Promise.all(u);
  2806. }
  2807. /**
  2808. * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
  2809. * @param {number} meshIndex
  2810. * @return {Promise<Group|Mesh|SkinnedMesh>}
  2811. */
  2812. loadMesh(i) {
  2813. const r = this, s = this.json, a = this.extensions, c = s.meshes[i], u = c.primitives, h2 = [];
  2814. for (let m = 0, g = u.length; m < g; m++) {
  2815. const w = u[m].material === void 0 ? Su(this.cache) : this.getDependency("material", u[m].material);
  2816. h2.push(w);
  2817. }
  2818. return h2.push(r.loadGeometries(u)), Promise.all(h2).then(function(m) {
  2819. const g = m.slice(0, m.length - 1), w = m[m.length - 1], _ = [];
  2820. for (let C = 0, I2 = w.length; C < I2; C++) {
  2821. const S = w[C], R = u[C];
  2822. let j;
  2823. const F2 = g[C];
  2824. if (R.mode === Bt.TRIANGLES || R.mode === Bt.TRIANGLE_STRIP || R.mode === Bt.TRIANGLE_FAN || R.mode === void 0)
  2825. j = c.isSkinnedMesh === true ? new SkinnedMesh(S, F2) : new Mesh(S, F2), j.isSkinnedMesh === true && !j.geometry.attributes.skinWeight.normalized && j.normalizeSkinWeights(), R.mode === Bt.TRIANGLE_STRIP ? j.geometry = fa(j.geometry, TriangleStripDrawMode) : R.mode === Bt.TRIANGLE_FAN && (j.geometry = fa(j.geometry, TriangleFanDrawMode));
  2826. else if (R.mode === Bt.LINES)
  2827. j = new LineSegments(S, F2);
  2828. else if (R.mode === Bt.LINE_STRIP)
  2829. j = new Line(S, F2);
  2830. else if (R.mode === Bt.LINE_LOOP)
  2831. j = new LineLoop(S, F2);
  2832. else if (R.mode === Bt.POINTS)
  2833. j = new Points(S, F2);
  2834. else
  2835. throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + R.mode);
  2836. Object.keys(j.geometry.morphAttributes).length > 0 && Lu(j, c), j.name = r.createUniqueName(c.name || "mesh_" + i), Ln(j, c), R.extensions && Gi(a, j, R), r.assignFinalMaterial(j), _.push(j);
  2837. }
  2838. for (let C = 0, I2 = _.length; C < I2; C++)
  2839. r.associations.set(_[C], {
  2840. meshes: i,
  2841. primitives: C
  2842. });
  2843. if (_.length === 1)
  2844. return _[0];
  2845. const y2 = new Group();
  2846. r.associations.set(y2, {
  2847. meshes: i
  2848. });
  2849. for (let C = 0, I2 = _.length; C < I2; C++)
  2850. y2.add(_[C]);
  2851. return y2;
  2852. });
  2853. }
  2854. /**
  2855. * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
  2856. * @param {number} cameraIndex
  2857. * @return {Promise<THREE.Camera>}
  2858. */
  2859. loadCamera(i) {
  2860. let r;
  2861. const s = this.json.cameras[i], a = s[s.type];
  2862. if (!a) {
  2863. console.warn("THREE.GLTFLoader: Missing camera parameters.");
  2864. return;
  2865. }
  2866. return s.type === "perspective" ? r = new PerspectiveCamera(MathUtils.radToDeg(a.yfov), a.aspectRatio || 1, a.znear || 1, a.zfar || 2e6) : s.type === "orthographic" && (r = new OrthographicCamera(-a.xmag, a.xmag, a.ymag, -a.ymag, a.znear, a.zfar)), s.name && (r.name = this.createUniqueName(s.name)), Ln(r, s), Promise.resolve(r);
  2867. }
  2868. /**
  2869. * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
  2870. * @param {number} skinIndex
  2871. * @return {Promise<Object>}
  2872. */
  2873. loadSkin(i) {
  2874. const r = this.json.skins[i], s = {
  2875. joints: r.joints
  2876. };
  2877. return r.inverseBindMatrices === void 0 ? Promise.resolve(s) : this.getDependency("accessor", r.inverseBindMatrices).then(function(a) {
  2878. return s.inverseBindMatrices = a, s;
  2879. });
  2880. }
  2881. /**
  2882. * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
  2883. * @param {number} animationIndex
  2884. * @return {Promise<AnimationClip>}
  2885. */
  2886. loadAnimation(i) {
  2887. const s = this.json.animations[i], a = [], c = [], u = [], h2 = [], m = [];
  2888. for (let g = 0, w = s.channels.length; g < w; g++) {
  2889. const _ = s.channels[g], y2 = s.samplers[_.sampler], C = _.target, I2 = C.node, S = s.parameters !== void 0 ? s.parameters[y2.input] : y2.input, R = s.parameters !== void 0 ? s.parameters[y2.output] : y2.output;
  2890. a.push(this.getDependency("node", I2)), c.push(this.getDependency("accessor", S)), u.push(this.getDependency("accessor", R)), h2.push(y2), m.push(C);
  2891. }
  2892. return Promise.all([Promise.all(a), Promise.all(c), Promise.all(u), Promise.all(h2), Promise.all(m)]).then(function(g) {
  2893. const w = g[0], _ = g[1], y2 = g[2], C = g[3], I2 = g[4], S = [];
  2894. for (let j = 0, F2 = w.length; j < F2; j++) {
  2895. const V = w[j], D2 = _[j], Y2 = y2[j], G = C[j], N2 = I2[j];
  2896. if (V === void 0)
  2897. continue;
  2898. V.updateMatrix();
  2899. let O;
  2900. switch (nn[N2.path]) {
  2901. case nn.weights:
  2902. O = NumberKeyframeTrack;
  2903. break;
  2904. case nn.rotation:
  2905. O = QuaternionKeyframeTrack;
  2906. break;
  2907. case nn.position:
  2908. case nn.scale:
  2909. default:
  2910. O = VectorKeyframeTrack;
  2911. break;
  2912. }
  2913. const H = V.name ? V.name : V.uuid, K = G.interpolation !== void 0 ? Mu[G.interpolation] : InterpolateLinear, q = [];
  2914. nn[N2.path] === nn.weights ? V.traverse(function(_e) {
  2915. _e.morphTargetInfluences && q.push(_e.name ? _e.name : _e.uuid);
  2916. }) : q.push(H);
  2917. let he = Y2.array;
  2918. if (Y2.normalized) {
  2919. const _e = ho(he.constructor), pe = new Float32Array(he.length);
  2920. for (let fe2 = 0, de2 = he.length; fe2 < de2; fe2++)
  2921. pe[fe2] = he[fe2] * _e;
  2922. he = pe;
  2923. }
  2924. for (let _e = 0, pe = q.length; _e < pe; _e++) {
  2925. const fe2 = new O(q[_e] + "." + nn[N2.path], D2.array, he, K);
  2926. G.interpolation === "CUBICSPLINE" && (fe2.createInterpolant = function(te2) {
  2927. const X2 = this instanceof QuaternionKeyframeTrack ? ku : Ya;
  2928. return new X2(this.times, this.values, this.getValueSize() / 3, te2);
  2929. }, fe2.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true), S.push(fe2);
  2930. }
  2931. }
  2932. const R = s.name ? s.name : "animation_" + i;
  2933. return new AnimationClip(R, void 0, S);
  2934. });
  2935. }
  2936. createNodeMesh(i) {
  2937. const r = this.json, s = this, a = r.nodes[i];
  2938. return a.mesh === void 0 ? null : s.getDependency("mesh", a.mesh).then(function(c) {
  2939. const u = s._getNodeRef(s.meshCache, a.mesh, c);
  2940. return a.weights !== void 0 && u.traverse(function(h2) {
  2941. if (h2.isMesh)
  2942. for (let m = 0, g = a.weights.length; m < g; m++)
  2943. h2.morphTargetInfluences[m] = a.weights[m];
  2944. }), u;
  2945. });
  2946. }
  2947. /**
  2948. * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
  2949. * @param {number} nodeIndex
  2950. * @return {Promise<Object3D>}
  2951. */
  2952. loadNode(i) {
  2953. const r = this.json, s = this.extensions, a = this, c = r.nodes[i], u = c.name ? a.createUniqueName(c.name) : "";
  2954. return function() {
  2955. const h2 = [], m = a._invokeOne(function(g) {
  2956. return g.createNodeMesh && g.createNodeMesh(i);
  2957. });
  2958. return m && h2.push(m), c.camera !== void 0 && h2.push(a.getDependency("camera", c.camera).then(function(g) {
  2959. return a._getNodeRef(a.cameraCache, c.camera, g);
  2960. })), a._invokeAll(function(g) {
  2961. return g.createNodeAttachment && g.createNodeAttachment(i);
  2962. }).forEach(function(g) {
  2963. h2.push(g);
  2964. }), Promise.all(h2);
  2965. }().then(function(h2) {
  2966. let m;
  2967. if (c.isBone === true ? m = new Bone() : h2.length > 1 ? m = new Group() : h2.length === 1 ? m = h2[0] : m = new Object3D(), m !== h2[0])
  2968. for (let g = 0, w = h2.length; g < w; g++)
  2969. m.add(h2[g]);
  2970. if (c.name && (m.userData.name = c.name, m.name = u), Ln(m, c), c.extensions && Gi(s, m, c), c.matrix !== void 0) {
  2971. const g = new Matrix4();
  2972. g.fromArray(c.matrix), m.applyMatrix4(g);
  2973. } else
  2974. c.translation !== void 0 && m.position.fromArray(c.translation), c.rotation !== void 0 && m.quaternion.fromArray(c.rotation), c.scale !== void 0 && m.scale.fromArray(c.scale);
  2975. return a.associations.has(m) || a.associations.set(m, {}), a.associations.get(m).nodes = i, m;
  2976. });
  2977. }
  2978. /**
  2979. * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
  2980. * @param {number} sceneIndex
  2981. * @return {Promise<Group>}
  2982. */
  2983. loadScene(i) {
  2984. const r = this.json, s = this.extensions, a = this.json.scenes[i], c = this, u = new Group();
  2985. a.name && (u.name = c.createUniqueName(a.name)), Ln(u, a), a.extensions && Gi(s, u, a);
  2986. const h2 = a.nodes || [], m = [];
  2987. for (let g = 0, w = h2.length; g < w; g++)
  2988. m.push(qa(h2[g], u, r, c));
  2989. return Promise.all(m).then(function() {
  2990. const g = (w) => {
  2991. const _ = /* @__PURE__ */ new Map();
  2992. for (const [y2, C] of c.associations)
  2993. (y2 instanceof Material || y2 instanceof Texture) && _.set(y2, C);
  2994. return w.traverse((y2) => {
  2995. const C = c.associations.get(y2);
  2996. C != null && _.set(y2, C);
  2997. }), _;
  2998. };
  2999. return c.associations = g(u), u;
  3000. });
  3001. }
  3002. };
  3003. function qa(b2, i, r, s) {
  3004. const a = r.nodes[b2];
  3005. return s.getDependency("node", b2).then(function(c) {
  3006. if (a.skin === void 0)
  3007. return c;
  3008. let u;
  3009. return s.getDependency("skin", a.skin).then(function(h2) {
  3010. u = h2;
  3011. const m = [];
  3012. for (let g = 0, w = u.joints.length; g < w; g++)
  3013. m.push(s.getDependency("node", u.joints[g]));
  3014. return Promise.all(m);
  3015. }).then(function(h2) {
  3016. return c.traverse(function(m) {
  3017. if (!m.isMesh)
  3018. return;
  3019. const g = [], w = [];
  3020. for (let _ = 0, y2 = h2.length; _ < y2; _++) {
  3021. const C = h2[_];
  3022. if (C) {
  3023. g.push(C);
  3024. const I2 = new Matrix4();
  3025. u.inverseBindMatrices !== void 0 && I2.fromArray(u.inverseBindMatrices.array, _ * 16), w.push(I2);
  3026. } else
  3027. console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', u.joints[_]);
  3028. }
  3029. m.bind(new Skeleton(g, w), m.matrixWorld);
  3030. }), c;
  3031. });
  3032. }).then(function(c) {
  3033. i.add(c);
  3034. const u = [];
  3035. if (a.children) {
  3036. const h2 = a.children;
  3037. for (let m = 0, g = h2.length; m < g; m++) {
  3038. const w = h2[m];
  3039. u.push(qa(w, c, r, s));
  3040. }
  3041. }
  3042. return Promise.all(u);
  3043. });
  3044. }
  3045. function Du(b2, i, r) {
  3046. const s = i.attributes, a = new Box3();
  3047. if (s.POSITION !== void 0) {
  3048. const h2 = r.json.accessors[s.POSITION], m = h2.min, g = h2.max;
  3049. if (m !== void 0 && g !== void 0) {
  3050. if (a.set(new Vector3(m[0], m[1], m[2]), new Vector3(g[0], g[1], g[2])), h2.normalized) {
  3051. const w = ho(Zi[h2.componentType]);
  3052. a.min.multiplyScalar(w), a.max.multiplyScalar(w);
  3053. }
  3054. } else {
  3055. console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
  3056. return;
  3057. }
  3058. } else
  3059. return;
  3060. const c = i.targets;
  3061. if (c !== void 0) {
  3062. const h2 = new Vector3(), m = new Vector3();
  3063. for (let g = 0, w = c.length; g < w; g++) {
  3064. const _ = c[g];
  3065. if (_.POSITION !== void 0) {
  3066. const y2 = r.json.accessors[_.POSITION], C = y2.min, I2 = y2.max;
  3067. if (C !== void 0 && I2 !== void 0) {
  3068. if (m.setX(Math.max(Math.abs(C[0]), Math.abs(I2[0]))), m.setY(Math.max(Math.abs(C[1]), Math.abs(I2[1]))), m.setZ(Math.max(Math.abs(C[2]), Math.abs(I2[2]))), y2.normalized) {
  3069. const S = ho(Zi[y2.componentType]);
  3070. m.multiplyScalar(S);
  3071. }
  3072. h2.max(m);
  3073. } else
  3074. console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
  3075. }
  3076. }
  3077. a.expandByVector(h2);
  3078. }
  3079. b2.boundingBox = a;
  3080. const u = new Sphere();
  3081. a.getCenter(u.center), u.radius = a.min.distanceTo(a.max) / 2, b2.boundingSphere = u;
  3082. }
  3083. function ma(b2, i, r) {
  3084. const s = i.attributes, a = [];
  3085. function c(u, h2) {
  3086. return r.getDependency("accessor", u).then(function(m) {
  3087. b2.setAttribute(h2, m);
  3088. });
  3089. }
  3090. for (const u in s) {
  3091. const h2 = uo[u] || u.toLowerCase();
  3092. h2 in b2.attributes || a.push(c(s[u], h2));
  3093. }
  3094. if (i.indices !== void 0 && !b2.index) {
  3095. const u = r.getDependency("accessor", i.indices).then(function(h2) {
  3096. b2.setIndex(h2);
  3097. });
  3098. a.push(u);
  3099. }
  3100. return Ln(b2, i), Du(b2, i, r), Promise.all(a).then(function() {
  3101. return i.targets !== void 0 ? Au(b2, i.targets, r) : b2;
  3102. });
  3103. }
  3104. function fa(b2, i) {
  3105. let r = b2.getIndex();
  3106. if (r === null) {
  3107. const u = [], h2 = b2.getAttribute("position");
  3108. if (h2 !== void 0) {
  3109. for (let m = 0; m < h2.count; m++)
  3110. u.push(m);
  3111. b2.setIndex(u), r = b2.getIndex();
  3112. } else
  3113. return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), b2;
  3114. }
  3115. const s = r.count - 2, a = [];
  3116. if (i === TriangleFanDrawMode)
  3117. for (let u = 1; u <= s; u++)
  3118. a.push(r.getX(0)), a.push(r.getX(u)), a.push(r.getX(u + 1));
  3119. else
  3120. for (let u = 0; u < s; u++)
  3121. u % 2 === 0 ? (a.push(r.getX(u)), a.push(r.getX(u + 1)), a.push(r.getX(u + 2))) : (a.push(r.getX(u + 2)), a.push(r.getX(u + 1)), a.push(r.getX(u)));
  3122. a.length / 3 !== s && console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
  3123. const c = b2.clone();
  3124. return c.setIndex(a), c;
  3125. }
  3126. var Ou = class extends ExtrudeGeometry {
  3127. constructor(i, r = {}) {
  3128. const {
  3129. bevelEnabled: s = false,
  3130. bevelSize: a = 8,
  3131. bevelThickness: c = 10,
  3132. font: u,
  3133. height: h2 = 50,
  3134. size: m = 100,
  3135. lineHeight: g = 1,
  3136. letterSpacing: w = 0,
  3137. ..._
  3138. } = r;
  3139. if (u === void 0)
  3140. super();
  3141. else {
  3142. const y2 = u.generateShapes(i, m, {
  3143. lineHeight: g,
  3144. letterSpacing: w
  3145. });
  3146. super(y2, {
  3147. ..._,
  3148. bevelEnabled: s,
  3149. bevelSize: a,
  3150. bevelThickness: c,
  3151. depth: h2
  3152. });
  3153. }
  3154. this.type = "TextGeometry";
  3155. }
  3156. };
  3157. function Qa(b2, i, r) {
  3158. const s = r.length - b2 - 1;
  3159. if (i >= r[s])
  3160. return s - 1;
  3161. if (i <= r[b2])
  3162. return b2;
  3163. let a = b2, c = s, u = Math.floor((a + c) / 2);
  3164. for (; i < r[u] || i >= r[u + 1]; )
  3165. i < r[u] ? c = u : a = u, u = Math.floor((a + c) / 2);
  3166. return u;
  3167. }
  3168. function Nu(b2, i, r, s) {
  3169. const a = [], c = [], u = [];
  3170. a[0] = 1;
  3171. for (let h2 = 1; h2 <= r; ++h2) {
  3172. c[h2] = i - s[b2 + 1 - h2], u[h2] = s[b2 + h2] - i;
  3173. let m = 0;
  3174. for (let g = 0; g < h2; ++g) {
  3175. const w = u[g + 1], _ = c[h2 - g], y2 = a[g] / (w + _);
  3176. a[g] = m + w * y2, m = _ * y2;
  3177. }
  3178. a[h2] = m;
  3179. }
  3180. return a;
  3181. }
  3182. function Fu(b2, i, r, s) {
  3183. const a = Qa(b2, s, i), c = Nu(a, s, b2, i), u = new Vector4(0, 0, 0, 0);
  3184. for (let h2 = 0; h2 <= b2; ++h2) {
  3185. const m = r[a - b2 + h2], g = c[h2], w = m.w * g;
  3186. u.x += m.x * w, u.y += m.y * w, u.z += m.z * w, u.w += m.w * g;
  3187. }
  3188. return u;
  3189. }
  3190. function Bu(b2, i, r, s, a) {
  3191. const c = [];
  3192. for (let y2 = 0; y2 <= r; ++y2)
  3193. c[y2] = 0;
  3194. const u = [];
  3195. for (let y2 = 0; y2 <= s; ++y2)
  3196. u[y2] = c.slice(0);
  3197. const h2 = [];
  3198. for (let y2 = 0; y2 <= r; ++y2)
  3199. h2[y2] = c.slice(0);
  3200. h2[0][0] = 1;
  3201. const m = c.slice(0), g = c.slice(0);
  3202. for (let y2 = 1; y2 <= r; ++y2) {
  3203. m[y2] = i - a[b2 + 1 - y2], g[y2] = a[b2 + y2] - i;
  3204. let C = 0;
  3205. for (let I2 = 0; I2 < y2; ++I2) {
  3206. const S = g[I2 + 1], R = m[y2 - I2];
  3207. h2[y2][I2] = S + R;
  3208. const j = h2[I2][y2 - 1] / h2[y2][I2];
  3209. h2[I2][y2] = C + S * j, C = R * j;
  3210. }
  3211. h2[y2][y2] = C;
  3212. }
  3213. for (let y2 = 0; y2 <= r; ++y2)
  3214. u[0][y2] = h2[y2][r];
  3215. for (let y2 = 0; y2 <= r; ++y2) {
  3216. let C = 0, I2 = 1;
  3217. const S = [];
  3218. for (let R = 0; R <= r; ++R)
  3219. S[R] = c.slice(0);
  3220. S[0][0] = 1;
  3221. for (let R = 1; R <= s; ++R) {
  3222. let j = 0;
  3223. const F2 = y2 - R, V = r - R;
  3224. y2 >= R && (S[I2][0] = S[C][0] / h2[V + 1][F2], j = S[I2][0] * h2[F2][V]);
  3225. const D2 = F2 >= -1 ? 1 : -F2, Y2 = y2 - 1 <= V ? R - 1 : r - y2;
  3226. for (let G = D2; G <= Y2; ++G)
  3227. S[I2][G] = (S[C][G] - S[C][G - 1]) / h2[V + 1][F2 + G], j += S[I2][G] * h2[F2 + G][V];
  3228. y2 <= V && (S[I2][R] = -S[C][R - 1] / h2[V + 1][y2], j += S[I2][R] * h2[y2][V]), u[R][y2] = j;
  3229. var w = C;
  3230. C = I2, I2 = w;
  3231. }
  3232. }
  3233. var _ = r;
  3234. for (let y2 = 1; y2 <= s; ++y2) {
  3235. for (let C = 0; C <= r; ++C)
  3236. u[y2][C] *= _;
  3237. _ *= r - y2;
  3238. }
  3239. return u;
  3240. }
  3241. function ju(b2, i, r, s, a) {
  3242. const c = a < b2 ? a : b2, u = [], h2 = Qa(b2, s, i), m = Bu(h2, s, b2, c, i), g = [];
  3243. for (let _ = 0; _ < r.length; ++_) {
  3244. var w = r[_].clone();
  3245. const y2 = w.w;
  3246. w.x *= y2, w.y *= y2, w.z *= y2, g[_] = w;
  3247. }
  3248. for (let _ = 0; _ <= c; ++_) {
  3249. var w = g[h2 - b2].clone().multiplyScalar(m[_][0]);
  3250. for (let C = 1; C <= b2; ++C)
  3251. w.add(g[h2 - b2 + C].clone().multiplyScalar(m[_][C]));
  3252. u[_] = w;
  3253. }
  3254. for (let _ = c + 1; _ <= a + 1; ++_)
  3255. u[_] = new Vector4(0, 0, 0);
  3256. return u;
  3257. }
  3258. function zu(b2, i) {
  3259. let r = 1;
  3260. for (let a = 2; a <= b2; ++a)
  3261. r *= a;
  3262. let s = 1;
  3263. for (let a = 2; a <= i; ++a)
  3264. s *= a;
  3265. for (let a = 2; a <= b2 - i; ++a)
  3266. s *= a;
  3267. return r / s;
  3268. }
  3269. function Uu(b2) {
  3270. const i = b2.length, r = [], s = [];
  3271. for (let c = 0; c < i; ++c) {
  3272. const u = b2[c];
  3273. r[c] = new Vector3(u.x, u.y, u.z), s[c] = u.w;
  3274. }
  3275. const a = [];
  3276. for (let c = 0; c < i; ++c) {
  3277. const u = r[c].clone();
  3278. for (let h2 = 1; h2 <= c; ++h2)
  3279. u.sub(a[c - h2].clone().multiplyScalar(zu(c, h2) * s[h2]));
  3280. a[c] = u.divideScalar(s[0]);
  3281. }
  3282. return a;
  3283. }
  3284. function Gu(b2, i, r, s, a) {
  3285. const c = ju(b2, i, r, s, a);
  3286. return Uu(c);
  3287. }
  3288. var va = class extends Curve {
  3289. constructor(i, r, s, a, c) {
  3290. super(), this.degree = i, this.knots = r, this.controlPoints = [], this.startKnot = a || 0, this.endKnot = c || this.knots.length - 1;
  3291. for (let u = 0; u < s.length; ++u) {
  3292. const h2 = s[u];
  3293. this.controlPoints[u] = new Vector4(h2.x, h2.y, h2.z, h2.w);
  3294. }
  3295. }
  3296. getPoint(i, r) {
  3297. const s = r || new Vector3(), a = this.knots[this.startKnot] + i * (this.knots[this.endKnot] - this.knots[this.startKnot]), c = Fu(this.degree, this.knots, this.controlPoints, a);
  3298. return c.w != 1 && c.divideScalar(c.w), s.set(c.x, c.y, c.z);
  3299. }
  3300. getTangent(i, r) {
  3301. const s = r || new Vector3(), a = this.knots[0] + i * (this.knots[this.knots.length - 1] - this.knots[0]), c = Gu(this.degree, this.knots, this.controlPoints, a, 1);
  3302. return s.copy(c[1]).normalize(), s;
  3303. }
  3304. };
  3305. var oe;
  3306. var Re2;
  3307. var We;
  3308. var Hu = class extends Loader {
  3309. constructor(i) {
  3310. super(i);
  3311. }
  3312. load(i, r, s, a) {
  3313. const c = this, u = c.path === "" ? LoaderUtils.extractUrlBase(i) : c.path, h2 = new FileLoader(this.manager);
  3314. h2.setPath(c.path), h2.setResponseType("arraybuffer"), h2.setRequestHeader(c.requestHeader), h2.setWithCredentials(c.withCredentials), h2.load(i, function(m) {
  3315. try {
  3316. r(c.parse(m, u));
  3317. } catch (g) {
  3318. a ? a(g) : console.error(g), c.manager.itemError(i);
  3319. }
  3320. }, s, a);
  3321. }
  3322. parse(i, r) {
  3323. if (Qu(i))
  3324. oe = new qu().parse(i);
  3325. else {
  3326. const a = el(i);
  3327. if (!Zu(a))
  3328. throw new Error("THREE.FBXLoader: Unknown format.");
  3329. if (ga(a) < 7e3)
  3330. throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: " + ga(a));
  3331. oe = new Yu().parse(a);
  3332. }
  3333. const s = new TextureLoader(this.manager).setPath(this.resourcePath || r).setCrossOrigin(this.crossOrigin);
  3334. return new Ku(s, this.manager).parse(oe);
  3335. }
  3336. };
  3337. var Ku = class {
  3338. constructor(i, r) {
  3339. this.textureLoader = i, this.manager = r;
  3340. }
  3341. parse() {
  3342. Re2 = this.parseConnections();
  3343. const i = this.parseImages(), r = this.parseTextures(i), s = this.parseMaterials(r), a = this.parseDeformers(), c = new $u().parse(a);
  3344. return this.parseScene(a, c, s), We;
  3345. }
  3346. // Parses FBXTree.Connections which holds parent-child connections between objects (e.g. material -> texture, model->geometry )
  3347. // and details the connection type
  3348. parseConnections() {
  3349. const i = /* @__PURE__ */ new Map();
  3350. return "Connections" in oe && oe.Connections.connections.forEach(function(s) {
  3351. const a = s[0], c = s[1], u = s[2];
  3352. i.has(a) || i.set(a, {
  3353. parents: [],
  3354. children: []
  3355. });
  3356. const h2 = {
  3357. ID: c,
  3358. relationship: u
  3359. };
  3360. i.get(a).parents.push(h2), i.has(c) || i.set(c, {
  3361. parents: [],
  3362. children: []
  3363. });
  3364. const m = {
  3365. ID: a,
  3366. relationship: u
  3367. };
  3368. i.get(c).children.push(m);
  3369. }), i;
  3370. }
  3371. // Parse FBXTree.Objects.Video for embedded image data
  3372. // These images are connected to textures in FBXTree.Objects.Textures
  3373. // via FBXTree.Connections.
  3374. parseImages() {
  3375. const i = {}, r = {};
  3376. if ("Video" in oe.Objects) {
  3377. const s = oe.Objects.Video;
  3378. for (const a in s) {
  3379. const c = s[a], u = parseInt(a);
  3380. if (i[u] = c.RelativeFilename || c.Filename, "Content" in c) {
  3381. const h2 = c.Content instanceof ArrayBuffer && c.Content.byteLength > 0, m = typeof c.Content == "string" && c.Content !== "";
  3382. if (h2 || m) {
  3383. const g = this.parseImage(s[a]);
  3384. r[c.RelativeFilename || c.Filename] = g;
  3385. }
  3386. }
  3387. }
  3388. }
  3389. for (const s in i) {
  3390. const a = i[s];
  3391. r[a] !== void 0 ? i[s] = r[a] : i[s] = i[s].split("\\").pop();
  3392. }
  3393. return i;
  3394. }
  3395. // Parse embedded image data in FBXTree.Video.Content
  3396. parseImage(i) {
  3397. const r = i.Content, s = i.RelativeFilename || i.Filename, a = s.slice(s.lastIndexOf(".") + 1).toLowerCase();
  3398. let c;
  3399. switch (a) {
  3400. case "bmp":
  3401. c = "image/bmp";
  3402. break;
  3403. case "jpg":
  3404. case "jpeg":
  3405. c = "image/jpeg";
  3406. break;
  3407. case "png":
  3408. c = "image/png";
  3409. break;
  3410. case "tif":
  3411. c = "image/tiff";
  3412. break;
  3413. case "tga":
  3414. this.manager.getHandler(".tga") === null && console.warn("FBXLoader: TGA loader not found, skipping ", s), c = "image/tga";
  3415. break;
  3416. default:
  3417. console.warn('FBXLoader: Image type "' + a + '" is not supported.');
  3418. return;
  3419. }
  3420. if (typeof r == "string")
  3421. return "data:" + c + ";base64," + r;
  3422. {
  3423. const u = new Uint8Array(r);
  3424. return window.URL.createObjectURL(new Blob([u], {
  3425. type: c
  3426. }));
  3427. }
  3428. }
  3429. // Parse nodes in FBXTree.Objects.Texture
  3430. // These contain details such as UV scaling, cropping, rotation etc and are connected
  3431. // to images in FBXTree.Objects.Video
  3432. parseTextures(i) {
  3433. const r = /* @__PURE__ */ new Map();
  3434. if ("Texture" in oe.Objects) {
  3435. const s = oe.Objects.Texture;
  3436. for (const a in s) {
  3437. const c = this.parseTexture(s[a], i);
  3438. r.set(parseInt(a), c);
  3439. }
  3440. }
  3441. return r;
  3442. }
  3443. // Parse individual node in FBXTree.Objects.Texture
  3444. parseTexture(i, r) {
  3445. const s = this.loadTexture(i, r);
  3446. s.ID = i.id, s.name = i.attrName;
  3447. const a = i.WrapModeU, c = i.WrapModeV, u = a !== void 0 ? a.value : 0, h2 = c !== void 0 ? c.value : 0;
  3448. if (s.wrapS = u === 0 ? RepeatWrapping : ClampToEdgeWrapping, s.wrapT = h2 === 0 ? RepeatWrapping : ClampToEdgeWrapping, "Scaling" in i) {
  3449. const m = i.Scaling.value;
  3450. s.repeat.x = m[0], s.repeat.y = m[1];
  3451. }
  3452. return s;
  3453. }
  3454. // load a texture specified as a blob or data URI, or via an external URL using TextureLoader
  3455. loadTexture(i, r) {
  3456. let s;
  3457. const a = this.textureLoader.path, c = Re2.get(i.id).children;
  3458. c !== void 0 && c.length > 0 && r[c[0].ID] !== void 0 && (s = r[c[0].ID], (s.indexOf("blob:") === 0 || s.indexOf("data:") === 0) && this.textureLoader.setPath(void 0));
  3459. let u;
  3460. const h2 = i.FileName.slice(-3).toLowerCase();
  3461. if (h2 === "tga") {
  3462. const m = this.manager.getHandler(".tga");
  3463. m === null ? (console.warn("FBXLoader: TGA loader not found, creating placeholder texture for", i.RelativeFilename), u = new Texture()) : (m.setPath(this.textureLoader.path), u = m.load(s));
  3464. } else
  3465. h2 === "psd" ? (console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for", i.RelativeFilename), u = new Texture()) : u = this.textureLoader.load(s);
  3466. return this.textureLoader.setPath(a), u;
  3467. }
  3468. // Parse nodes in FBXTree.Objects.Material
  3469. parseMaterials(i) {
  3470. const r = /* @__PURE__ */ new Map();
  3471. if ("Material" in oe.Objects) {
  3472. const s = oe.Objects.Material;
  3473. for (const a in s) {
  3474. const c = this.parseMaterial(s[a], i);
  3475. c !== null && r.set(parseInt(a), c);
  3476. }
  3477. }
  3478. return r;
  3479. }
  3480. // Parse single node in FBXTree.Objects.Material
  3481. // Materials are connected to texture maps in FBXTree.Objects.Textures
  3482. // FBX format currently only supports Lambert and Phong shading models
  3483. parseMaterial(i, r) {
  3484. const s = i.id, a = i.attrName;
  3485. let c = i.ShadingModel;
  3486. if (typeof c == "object" && (c = c.value), !Re2.has(s))
  3487. return null;
  3488. const u = this.parseParameters(i, r, s);
  3489. let h2;
  3490. switch (c.toLowerCase()) {
  3491. case "phong":
  3492. h2 = new MeshPhongMaterial();
  3493. break;
  3494. case "lambert":
  3495. h2 = new MeshLambertMaterial();
  3496. break;
  3497. default:
  3498. console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.', c), h2 = new MeshPhongMaterial();
  3499. break;
  3500. }
  3501. return h2.setValues(u), h2.name = a, h2;
  3502. }
  3503. // Parse FBX material and return parameters suitable for a three.js material
  3504. // Also parse the texture map and return any textures associated with the material
  3505. parseParameters(i, r, s) {
  3506. const a = {};
  3507. i.BumpFactor && (a.bumpScale = i.BumpFactor.value), i.Diffuse ? a.color = new Color().fromArray(i.Diffuse.value) : i.DiffuseColor && (i.DiffuseColor.type === "Color" || i.DiffuseColor.type === "ColorRGB") && (a.color = new Color().fromArray(i.DiffuseColor.value)), i.DisplacementFactor && (a.displacementScale = i.DisplacementFactor.value), i.Emissive ? a.emissive = new Color().fromArray(i.Emissive.value) : i.EmissiveColor && (i.EmissiveColor.type === "Color" || i.EmissiveColor.type === "ColorRGB") && (a.emissive = new Color().fromArray(i.EmissiveColor.value)), i.EmissiveFactor && (a.emissiveIntensity = parseFloat(i.EmissiveFactor.value)), i.Opacity && (a.opacity = parseFloat(i.Opacity.value)), a.opacity < 1 && (a.transparent = true), i.ReflectionFactor && (a.reflectivity = i.ReflectionFactor.value), i.Shininess && (a.shininess = i.Shininess.value), i.Specular ? a.specular = new Color().fromArray(i.Specular.value) : i.SpecularColor && i.SpecularColor.type === "Color" && (a.specular = new Color().fromArray(i.SpecularColor.value));
  3508. const c = this;
  3509. return Re2.get(s).children.forEach(function(u) {
  3510. const h2 = u.relationship;
  3511. switch (h2) {
  3512. case "Bump":
  3513. a.bumpMap = c.getTexture(r, u.ID);
  3514. break;
  3515. case "Maya|TEX_ao_map":
  3516. a.aoMap = c.getTexture(r, u.ID);
  3517. break;
  3518. case "DiffuseColor":
  3519. case "Maya|TEX_color_map":
  3520. a.map = c.getTexture(r, u.ID), a.map !== void 0 && (a.map.encoding = sRGBEncoding);
  3521. break;
  3522. case "DisplacementColor":
  3523. a.displacementMap = c.getTexture(r, u.ID);
  3524. break;
  3525. case "EmissiveColor":
  3526. a.emissiveMap = c.getTexture(r, u.ID), a.emissiveMap !== void 0 && (a.emissiveMap.encoding = sRGBEncoding);
  3527. break;
  3528. case "NormalMap":
  3529. case "Maya|TEX_normal_map":
  3530. a.normalMap = c.getTexture(r, u.ID);
  3531. break;
  3532. case "ReflectionColor":
  3533. a.envMap = c.getTexture(r, u.ID), a.envMap !== void 0 && (a.envMap.mapping = EquirectangularReflectionMapping, a.envMap.encoding = sRGBEncoding);
  3534. break;
  3535. case "SpecularColor":
  3536. a.specularMap = c.getTexture(r, u.ID), a.specularMap !== void 0 && (a.specularMap.encoding = sRGBEncoding);
  3537. break;
  3538. case "TransparentColor":
  3539. case "TransparencyFactor":
  3540. a.alphaMap = c.getTexture(r, u.ID), a.transparent = true;
  3541. break;
  3542. case "AmbientColor":
  3543. case "ShininessExponent":
  3544. case "SpecularFactor":
  3545. case "VectorDisplacementColor":
  3546. default:
  3547. console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.", h2);
  3548. break;
  3549. }
  3550. }), a;
  3551. }
  3552. // get a texture from the textureMap for use by a material.
  3553. getTexture(i, r) {
  3554. return "LayeredTexture" in oe.Objects && r in oe.Objects.LayeredTexture && (console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."), r = Re2.get(r).children[0].ID), i.get(r);
  3555. }
  3556. // Parse nodes in FBXTree.Objects.Deformer
  3557. // Deformer node can contain skinning or Vertex Cache animation data, however only skinning is supported here
  3558. // Generates map of Skeleton-like objects for use later when generating and binding skeletons.
  3559. parseDeformers() {
  3560. const i = {}, r = {};
  3561. if ("Deformer" in oe.Objects) {
  3562. const s = oe.Objects.Deformer;
  3563. for (const a in s) {
  3564. const c = s[a], u = Re2.get(parseInt(a));
  3565. if (c.attrType === "Skin") {
  3566. const h2 = this.parseSkeleton(u, s);
  3567. h2.ID = a, u.parents.length > 1 && console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."), h2.geometryID = u.parents[0].ID, i[a] = h2;
  3568. } else if (c.attrType === "BlendShape") {
  3569. const h2 = {
  3570. id: a
  3571. };
  3572. h2.rawTargets = this.parseMorphTargets(u, s), h2.id = a, u.parents.length > 1 && console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."), r[a] = h2;
  3573. }
  3574. }
  3575. }
  3576. return {
  3577. skeletons: i,
  3578. morphTargets: r
  3579. };
  3580. }
  3581. // Parse single nodes in FBXTree.Objects.Deformer
  3582. // The top level skeleton node has type 'Skin' and sub nodes have type 'Cluster'
  3583. // Each skin node represents a skeleton and each cluster node represents a bone
  3584. parseSkeleton(i, r) {
  3585. const s = [];
  3586. return i.children.forEach(function(a) {
  3587. const c = r[a.ID];
  3588. if (c.attrType !== "Cluster")
  3589. return;
  3590. const u = {
  3591. ID: a.ID,
  3592. indices: [],
  3593. weights: [],
  3594. transformLink: new Matrix4().fromArray(c.TransformLink.a)
  3595. // transform: new Matrix4().fromArray( boneNode.Transform.a ),
  3596. // linkMode: boneNode.Mode,
  3597. };
  3598. "Indexes" in c && (u.indices = c.Indexes.a, u.weights = c.Weights.a), s.push(u);
  3599. }), {
  3600. rawBones: s,
  3601. bones: []
  3602. };
  3603. }
  3604. // The top level morph deformer node has type "BlendShape" and sub nodes have type "BlendShapeChannel"
  3605. parseMorphTargets(i, r) {
  3606. const s = [];
  3607. for (let a = 0; a < i.children.length; a++) {
  3608. const c = i.children[a], u = r[c.ID], h2 = {
  3609. name: u.attrName,
  3610. initialWeight: u.DeformPercent,
  3611. id: u.id,
  3612. fullWeights: u.FullWeights.a
  3613. };
  3614. if (u.attrType !== "BlendShapeChannel")
  3615. return;
  3616. h2.geoID = Re2.get(parseInt(c.ID)).children.filter(function(m) {
  3617. return m.relationship === void 0;
  3618. })[0].ID, s.push(h2);
  3619. }
  3620. return s;
  3621. }
  3622. // create the main Group() to be returned by the loader
  3623. parseScene(i, r, s) {
  3624. We = new Group();
  3625. const a = this.parseModels(i.skeletons, r, s), c = oe.Objects.Model, u = this;
  3626. a.forEach(function(m) {
  3627. const g = c[m.ID];
  3628. u.setLookAtProperties(m, g), Re2.get(m.ID).parents.forEach(function(_) {
  3629. const y2 = a.get(_.ID);
  3630. y2 !== void 0 && y2.add(m);
  3631. }), m.parent === null && We.add(m);
  3632. }), this.bindSkeleton(i.skeletons, r, a), this.createAmbientLight(), We.traverse(function(m) {
  3633. if (m.userData.transformData) {
  3634. m.parent && (m.userData.transformData.parentMatrix = m.parent.matrix, m.userData.transformData.parentMatrixWorld = m.parent.matrixWorld);
  3635. const g = Wa(m.userData.transformData);
  3636. m.applyMatrix4(g), m.updateWorldMatrix();
  3637. }
  3638. });
  3639. const h2 = new Xu().parse();
  3640. We.children.length === 1 && We.children[0].isGroup && (We.children[0].animations = h2, We = We.children[0]), We.animations = h2;
  3641. }
  3642. // parse nodes in FBXTree.Objects.Model
  3643. parseModels(i, r, s) {
  3644. const a = /* @__PURE__ */ new Map(), c = oe.Objects.Model;
  3645. for (const u in c) {
  3646. const h2 = parseInt(u), m = c[u], g = Re2.get(h2);
  3647. let w = this.buildSkeleton(g, i, h2, m.attrName);
  3648. if (!w) {
  3649. switch (m.attrType) {
  3650. case "Camera":
  3651. w = this.createCamera(g);
  3652. break;
  3653. case "Light":
  3654. w = this.createLight(g);
  3655. break;
  3656. case "Mesh":
  3657. w = this.createMesh(g, r, s);
  3658. break;
  3659. case "NurbsCurve":
  3660. w = this.createCurve(g, r);
  3661. break;
  3662. case "LimbNode":
  3663. case "Root":
  3664. w = new Bone();
  3665. break;
  3666. case "Null":
  3667. default:
  3668. w = new Group();
  3669. break;
  3670. }
  3671. w.name = m.attrName ? PropertyBinding.sanitizeNodeName(m.attrName) : "", w.ID = h2;
  3672. }
  3673. this.getTransformData(w, m), a.set(h2, w);
  3674. }
  3675. return a;
  3676. }
  3677. buildSkeleton(i, r, s, a) {
  3678. let c = null;
  3679. return i.parents.forEach(function(u) {
  3680. for (const h2 in r) {
  3681. const m = r[h2];
  3682. m.rawBones.forEach(function(g, w) {
  3683. if (g.ID === u.ID) {
  3684. const _ = c;
  3685. c = new Bone(), c.matrixWorld.copy(g.transformLink), c.name = a ? PropertyBinding.sanitizeNodeName(a) : "", c.ID = s, m.bones[w] = c, _ !== null && c.add(_);
  3686. }
  3687. });
  3688. }
  3689. }), c;
  3690. }
  3691. // create a PerspectiveCamera or OrthographicCamera
  3692. createCamera(i) {
  3693. let r, s;
  3694. if (i.children.forEach(function(a) {
  3695. const c = oe.Objects.NodeAttribute[a.ID];
  3696. c !== void 0 && (s = c);
  3697. }), s === void 0)
  3698. r = new Object3D();
  3699. else {
  3700. let a = 0;
  3701. s.CameraProjectionType !== void 0 && s.CameraProjectionType.value === 1 && (a = 1);
  3702. let c = 1;
  3703. s.NearPlane !== void 0 && (c = s.NearPlane.value / 1e3);
  3704. let u = 1e3;
  3705. s.FarPlane !== void 0 && (u = s.FarPlane.value / 1e3);
  3706. let h2 = window.innerWidth, m = window.innerHeight;
  3707. s.AspectWidth !== void 0 && s.AspectHeight !== void 0 && (h2 = s.AspectWidth.value, m = s.AspectHeight.value);
  3708. const g = h2 / m;
  3709. let w = 45;
  3710. s.FieldOfView !== void 0 && (w = s.FieldOfView.value);
  3711. const _ = s.FocalLength ? s.FocalLength.value : null;
  3712. switch (a) {
  3713. case 0:
  3714. r = new PerspectiveCamera(w, g, c, u), _ !== null && r.setFocalLength(_);
  3715. break;
  3716. case 1:
  3717. r = new OrthographicCamera(-h2 / 2, h2 / 2, m / 2, -m / 2, c, u);
  3718. break;
  3719. default:
  3720. console.warn("THREE.FBXLoader: Unknown camera type " + a + "."), r = new Object3D();
  3721. break;
  3722. }
  3723. }
  3724. return r;
  3725. }
  3726. // Create a DirectionalLight, PointLight or SpotLight
  3727. createLight(i) {
  3728. let r, s;
  3729. if (i.children.forEach(function(a) {
  3730. const c = oe.Objects.NodeAttribute[a.ID];
  3731. c !== void 0 && (s = c);
  3732. }), s === void 0)
  3733. r = new Object3D();
  3734. else {
  3735. let a;
  3736. s.LightType === void 0 ? a = 0 : a = s.LightType.value;
  3737. let c = 16777215;
  3738. s.Color !== void 0 && (c = new Color().fromArray(s.Color.value));
  3739. let u = s.Intensity === void 0 ? 1 : s.Intensity.value / 100;
  3740. s.CastLightOnObject !== void 0 && s.CastLightOnObject.value === 0 && (u = 0);
  3741. let h2 = 0;
  3742. s.FarAttenuationEnd !== void 0 && (s.EnableFarAttenuation !== void 0 && s.EnableFarAttenuation.value === 0 ? h2 = 0 : h2 = s.FarAttenuationEnd.value);
  3743. const m = 1;
  3744. switch (a) {
  3745. case 0:
  3746. r = new PointLight(c, u, h2, m);
  3747. break;
  3748. case 1:
  3749. r = new DirectionalLight(c, u);
  3750. break;
  3751. case 2:
  3752. let g = Math.PI / 3;
  3753. s.InnerAngle !== void 0 && (g = MathUtils.degToRad(s.InnerAngle.value));
  3754. let w = 0;
  3755. s.OuterAngle !== void 0 && (w = MathUtils.degToRad(s.OuterAngle.value), w = Math.max(w, 1)), r = new SpotLight(c, u, h2, g, w, m);
  3756. break;
  3757. default:
  3758. console.warn("THREE.FBXLoader: Unknown light type " + s.LightType.value + ", defaulting to a PointLight."), r = new PointLight(c, u);
  3759. break;
  3760. }
  3761. s.CastShadows !== void 0 && s.CastShadows.value === 1 && (r.castShadow = true);
  3762. }
  3763. return r;
  3764. }
  3765. createMesh(i, r, s) {
  3766. let a, c = null, u = null;
  3767. const h2 = [];
  3768. return i.children.forEach(function(m) {
  3769. r.has(m.ID) && (c = r.get(m.ID)), s.has(m.ID) && h2.push(s.get(m.ID));
  3770. }), h2.length > 1 ? u = h2 : h2.length > 0 ? u = h2[0] : (u = new MeshPhongMaterial({
  3771. color: 13421772
  3772. }), h2.push(u)), "color" in c.attributes && h2.forEach(function(m) {
  3773. m.vertexColors = true;
  3774. }), c.FBX_Deformer ? (a = new SkinnedMesh(c, u), a.normalizeSkinWeights()) : a = new Mesh(c, u), a;
  3775. }
  3776. createCurve(i, r) {
  3777. const s = i.children.reduce(function(c, u) {
  3778. return r.has(u.ID) && (c = r.get(u.ID)), c;
  3779. }, null), a = new LineBasicMaterial({
  3780. color: 3342591,
  3781. linewidth: 1
  3782. });
  3783. return new Line(s, a);
  3784. }
  3785. // parse the model node for transform data
  3786. getTransformData(i, r) {
  3787. const s = {};
  3788. "InheritType" in r && (s.inheritType = parseInt(r.InheritType.value)), "RotationOrder" in r ? s.eulerOrder = Ja(r.RotationOrder.value) : s.eulerOrder = "ZYX", "Lcl_Translation" in r && (s.translation = r.Lcl_Translation.value), "PreRotation" in r && (s.preRotation = r.PreRotation.value), "Lcl_Rotation" in r && (s.rotation = r.Lcl_Rotation.value), "PostRotation" in r && (s.postRotation = r.PostRotation.value), "Lcl_Scaling" in r && (s.scale = r.Lcl_Scaling.value), "ScalingOffset" in r && (s.scalingOffset = r.ScalingOffset.value), "ScalingPivot" in r && (s.scalingPivot = r.ScalingPivot.value), "RotationOffset" in r && (s.rotationOffset = r.RotationOffset.value), "RotationPivot" in r && (s.rotationPivot = r.RotationPivot.value), i.userData.transformData = s;
  3789. }
  3790. setLookAtProperties(i, r) {
  3791. "LookAtProperty" in r && Re2.get(i.ID).children.forEach(function(a) {
  3792. if (a.relationship === "LookAtProperty") {
  3793. const c = oe.Objects.Model[a.ID];
  3794. if ("Lcl_Translation" in c) {
  3795. const u = c.Lcl_Translation.value;
  3796. i.target !== void 0 ? (i.target.position.fromArray(u), We.add(i.target)) : i.lookAt(new Vector3().fromArray(u));
  3797. }
  3798. }
  3799. });
  3800. }
  3801. bindSkeleton(i, r, s) {
  3802. const a = this.parsePoseNodes();
  3803. for (const c in i) {
  3804. const u = i[c];
  3805. Re2.get(parseInt(u.ID)).parents.forEach(function(m) {
  3806. if (r.has(m.ID)) {
  3807. const g = m.ID;
  3808. Re2.get(g).parents.forEach(function(_) {
  3809. s.has(_.ID) && s.get(_.ID).bind(new Skeleton(u.bones), a[_.ID]);
  3810. });
  3811. }
  3812. });
  3813. }
  3814. }
  3815. parsePoseNodes() {
  3816. const i = {};
  3817. if ("Pose" in oe.Objects) {
  3818. const r = oe.Objects.Pose;
  3819. for (const s in r)
  3820. if (r[s].attrType === "BindPose" && r[s].NbPoseNodes > 0) {
  3821. const a = r[s].PoseNode;
  3822. Array.isArray(a) ? a.forEach(function(c) {
  3823. i[c.Node] = new Matrix4().fromArray(c.Matrix.a);
  3824. }) : i[a.Node] = new Matrix4().fromArray(a.Matrix.a);
  3825. }
  3826. }
  3827. return i;
  3828. }
  3829. // Parse ambient color in FBXTree.GlobalSettings - if it's not set to black (default), create an ambient light
  3830. createAmbientLight() {
  3831. if ("GlobalSettings" in oe && "AmbientColor" in oe.GlobalSettings) {
  3832. const i = oe.GlobalSettings.AmbientColor.value, r = i[0], s = i[1], a = i[2];
  3833. if (r !== 0 || s !== 0 || a !== 0) {
  3834. const c = new Color(r, s, a);
  3835. We.add(new AmbientLight(c, 1));
  3836. }
  3837. }
  3838. }
  3839. };
  3840. var $u = class {
  3841. // Parse nodes in FBXTree.Objects.Geometry
  3842. parse(i) {
  3843. const r = /* @__PURE__ */ new Map();
  3844. if ("Geometry" in oe.Objects) {
  3845. const s = oe.Objects.Geometry;
  3846. for (const a in s) {
  3847. const c = Re2.get(parseInt(a)), u = this.parseGeometry(c, s[a], i);
  3848. r.set(parseInt(a), u);
  3849. }
  3850. }
  3851. return r;
  3852. }
  3853. // Parse single node in FBXTree.Objects.Geometry
  3854. parseGeometry(i, r, s) {
  3855. switch (r.attrType) {
  3856. case "Mesh":
  3857. return this.parseMeshGeometry(i, r, s);
  3858. case "NurbsCurve":
  3859. return this.parseNurbsGeometry(r);
  3860. }
  3861. }
  3862. // Parse single node mesh geometry in FBXTree.Objects.Geometry
  3863. parseMeshGeometry(i, r, s) {
  3864. const a = s.skeletons, c = [], u = i.parents.map(function(_) {
  3865. return oe.Objects.Model[_.ID];
  3866. });
  3867. if (u.length === 0)
  3868. return;
  3869. const h2 = i.children.reduce(function(_, y2) {
  3870. return a[y2.ID] !== void 0 && (_ = a[y2.ID]), _;
  3871. }, null);
  3872. i.children.forEach(function(_) {
  3873. s.morphTargets[_.ID] !== void 0 && c.push(s.morphTargets[_.ID]);
  3874. });
  3875. const m = u[0], g = {};
  3876. "RotationOrder" in m && (g.eulerOrder = Ja(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);
  3877. const w = Wa(g);
  3878. return this.genGeometry(r, h2, c, w);
  3879. }
  3880. // Generate a BufferGeometry from a node in FBXTree.Objects.Geometry
  3881. genGeometry(i, r, s, a) {
  3882. const c = new BufferGeometry();
  3883. i.attrName && (c.name = i.attrName);
  3884. const u = this.parseGeoNode(i, r), h2 = this.genBuffers(u), m = new Float32BufferAttribute(h2.vertex, 3);
  3885. if (m.applyMatrix4(a), c.setAttribute("position", m), h2.colors.length > 0 && c.setAttribute("color", new Float32BufferAttribute(h2.colors, 3)), r && (c.setAttribute("skinIndex", new Uint16BufferAttribute(h2.weightsIndices, 4)), c.setAttribute("skinWeight", new Float32BufferAttribute(h2.vertexWeights, 4)), c.FBX_Deformer = r), h2.normal.length > 0) {
  3886. const g = new Matrix3().getNormalMatrix(a), w = new Float32BufferAttribute(h2.normal, 3);
  3887. w.applyNormalMatrix(g), c.setAttribute("normal", w);
  3888. }
  3889. if (h2.uvs.forEach(function(g, w) {
  3890. let _ = "uv" + (w + 1).toString();
  3891. w === 0 && (_ = "uv"), c.setAttribute(_, new Float32BufferAttribute(h2.uvs[w], 2));
  3892. }), u.material && u.material.mappingType !== "AllSame") {
  3893. let g = h2.materialIndex[0], w = 0;
  3894. if (h2.materialIndex.forEach(function(_, y2) {
  3895. _ !== g && (c.addGroup(w, y2 - w, g), g = _, w = y2);
  3896. }), c.groups.length > 0) {
  3897. const _ = c.groups[c.groups.length - 1], y2 = _.start + _.count;
  3898. y2 !== h2.materialIndex.length && c.addGroup(y2, h2.materialIndex.length - y2, g);
  3899. }
  3900. c.groups.length === 0 && c.addGroup(0, h2.materialIndex.length, h2.materialIndex[0]);
  3901. }
  3902. return this.addMorphTargets(c, i, s, a), c;
  3903. }
  3904. parseGeoNode(i, r) {
  3905. const s = {};
  3906. if (s.vertexPositions = i.Vertices !== void 0 ? i.Vertices.a : [], s.vertexIndices = i.PolygonVertexIndex !== void 0 ? i.PolygonVertexIndex.a : [], i.LayerElementColor && (s.color = this.parseVertexColors(i.LayerElementColor[0])), i.LayerElementMaterial && (s.material = this.parseMaterialIndices(i.LayerElementMaterial[0])), i.LayerElementNormal && (s.normal = this.parseNormals(i.LayerElementNormal[0])), i.LayerElementUV) {
  3907. s.uv = [];
  3908. let a = 0;
  3909. for (; i.LayerElementUV[a]; )
  3910. i.LayerElementUV[a].UV && s.uv.push(this.parseUVs(i.LayerElementUV[a])), a++;
  3911. }
  3912. return s.weightTable = {}, r !== null && (s.skeleton = r, r.rawBones.forEach(function(a, c) {
  3913. a.indices.forEach(function(u, h2) {
  3914. s.weightTable[u] === void 0 && (s.weightTable[u] = []), s.weightTable[u].push({
  3915. id: c,
  3916. weight: a.weights[h2]
  3917. });
  3918. });
  3919. })), s;
  3920. }
  3921. genBuffers(i) {
  3922. const r = {
  3923. vertex: [],
  3924. normal: [],
  3925. colors: [],
  3926. uvs: [],
  3927. materialIndex: [],
  3928. vertexWeights: [],
  3929. weightsIndices: []
  3930. };
  3931. let s = 0, a = 0, c = false, u = [], h2 = [], m = [], g = [], w = [], _ = [];
  3932. const y2 = this;
  3933. return i.vertexIndices.forEach(function(C, I2) {
  3934. let S, R = false;
  3935. C < 0 && (C = C ^ -1, R = true);
  3936. let j = [], F2 = [];
  3937. if (u.push(C * 3, C * 3 + 1, C * 3 + 2), i.color) {
  3938. const V = Vs(I2, s, C, i.color);
  3939. m.push(V[0], V[1], V[2]);
  3940. }
  3941. if (i.skeleton) {
  3942. if (i.weightTable[C] !== void 0 && i.weightTable[C].forEach(function(V) {
  3943. F2.push(V.weight), j.push(V.id);
  3944. }), F2.length > 4) {
  3945. c || (console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."), c = true);
  3946. const V = [0, 0, 0, 0], D2 = [0, 0, 0, 0];
  3947. F2.forEach(function(Y2, G) {
  3948. let N2 = Y2, O = j[G];
  3949. D2.forEach(function(H, K, q) {
  3950. if (N2 > H) {
  3951. q[K] = N2, N2 = H;
  3952. const he = V[K];
  3953. V[K] = O, O = he;
  3954. }
  3955. });
  3956. }), j = V, F2 = D2;
  3957. }
  3958. for (; F2.length < 4; )
  3959. F2.push(0), j.push(0);
  3960. for (let V = 0; V < 4; ++V)
  3961. w.push(F2[V]), _.push(j[V]);
  3962. }
  3963. if (i.normal) {
  3964. const V = Vs(I2, s, C, i.normal);
  3965. h2.push(V[0], V[1], V[2]);
  3966. }
  3967. i.material && i.material.mappingType !== "AllSame" && (S = Vs(I2, s, C, i.material)[0]), i.uv && i.uv.forEach(function(V, D2) {
  3968. const Y2 = Vs(I2, s, C, V);
  3969. g[D2] === void 0 && (g[D2] = []), g[D2].push(Y2[0]), g[D2].push(Y2[1]);
  3970. }), a++, R && (y2.genFace(r, i, u, S, h2, m, g, w, _, a), s++, a = 0, u = [], h2 = [], m = [], g = [], w = [], _ = []);
  3971. }), r;
  3972. }
  3973. // Generate data for a single face in a geometry. If the face is a quad then split it into 2 tris
  3974. genFace(i, r, s, a, c, u, h2, m, g, w) {
  3975. for (let _ = 2; _ < w; _++)
  3976. i.vertex.push(r.vertexPositions[s[0]]), i.vertex.push(r.vertexPositions[s[1]]), i.vertex.push(r.vertexPositions[s[2]]), i.vertex.push(r.vertexPositions[s[(_ - 1) * 3]]), i.vertex.push(r.vertexPositions[s[(_ - 1) * 3 + 1]]), i.vertex.push(r.vertexPositions[s[(_ - 1) * 3 + 2]]), i.vertex.push(r.vertexPositions[s[_ * 3]]), i.vertex.push(r.vertexPositions[s[_ * 3 + 1]]), i.vertex.push(r.vertexPositions[s[_ * 3 + 2]]), r.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[(_ - 1) * 4]), i.vertexWeights.push(m[(_ - 1) * 4 + 1]), i.vertexWeights.push(m[(_ - 1) * 4 + 2]), i.vertexWeights.push(m[(_ - 1) * 4 + 3]), i.vertexWeights.push(m[_ * 4]), i.vertexWeights.push(m[_ * 4 + 1]), i.vertexWeights.push(m[_ * 4 + 2]), i.vertexWeights.push(m[_ * 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[(_ - 1) * 4]), i.weightsIndices.push(g[(_ - 1) * 4 + 1]), i.weightsIndices.push(g[(_ - 1) * 4 + 2]), i.weightsIndices.push(g[(_ - 1) * 4 + 3]), i.weightsIndices.push(g[_ * 4]), i.weightsIndices.push(g[_ * 4 + 1]), i.weightsIndices.push(g[_ * 4 + 2]), i.weightsIndices.push(g[_ * 4 + 3])), r.color && (i.colors.push(u[0]), i.colors.push(u[1]), i.colors.push(u[2]), i.colors.push(u[(_ - 1) * 3]), i.colors.push(u[(_ - 1) * 3 + 1]), i.colors.push(u[(_ - 1) * 3 + 2]), i.colors.push(u[_ * 3]), i.colors.push(u[_ * 3 + 1]), i.colors.push(u[_ * 3 + 2])), r.material && r.material.mappingType !== "AllSame" && (i.materialIndex.push(a), i.materialIndex.push(a), i.materialIndex.push(a)), r.normal && (i.normal.push(c[0]), i.normal.push(c[1]), i.normal.push(c[2]), i.normal.push(c[(_ - 1) * 3]), i.normal.push(c[(_ - 1) * 3 + 1]), i.normal.push(c[(_ - 1) * 3 + 2]), i.normal.push(c[_ * 3]), i.normal.push(c[_ * 3 + 1]), i.normal.push(c[_ * 3 + 2])), r.uv && r.uv.forEach(function(y2, C) {
  3977. 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][(_ - 1) * 2]), i.uvs[C].push(h2[C][(_ - 1) * 2 + 1]), i.uvs[C].push(h2[C][_ * 2]), i.uvs[C].push(h2[C][_ * 2 + 1]);
  3978. });
  3979. }
  3980. addMorphTargets(i, r, s, a) {
  3981. if (s.length === 0)
  3982. return;
  3983. i.morphTargetsRelative = true, i.morphAttributes.position = [];
  3984. const c = this;
  3985. s.forEach(function(u) {
  3986. u.rawTargets.forEach(function(h2) {
  3987. const m = oe.Objects.Geometry[h2.geoID];
  3988. m !== void 0 && c.genMorphGeometry(i, r, m, a, h2.name);
  3989. });
  3990. });
  3991. }
  3992. // a morph geometry node is similar to a standard node, and the node is also contained
  3993. // in FBXTree.Objects.Geometry, however it can only have attributes for position, normal
  3994. // and a special attribute Index defining which vertices of the original geometry are affected
  3995. // Normal and position attributes only have data for the vertices that are affected by the morph
  3996. genMorphGeometry(i, r, s, a, c) {
  3997. const u = r.PolygonVertexIndex !== void 0 ? r.PolygonVertexIndex.a : [], h2 = s.Vertices !== void 0 ? s.Vertices.a : [], m = s.Indexes !== void 0 ? s.Indexes.a : [], g = i.attributes.position.count * 3, w = new Float32Array(g);
  3998. for (let I2 = 0; I2 < m.length; I2++) {
  3999. const S = m[I2] * 3;
  4000. w[S] = h2[I2 * 3], w[S + 1] = h2[I2 * 3 + 1], w[S + 2] = h2[I2 * 3 + 2];
  4001. }
  4002. const _ = {
  4003. vertexIndices: u,
  4004. vertexPositions: w
  4005. }, y2 = this.genBuffers(_), C = new Float32BufferAttribute(y2.vertex, 3);
  4006. C.name = c || s.attrName, C.applyMatrix4(a), i.morphAttributes.position.push(C);
  4007. }
  4008. // Parse normal from FBXTree.Objects.Geometry.LayerElementNormal if it exists
  4009. parseNormals(i) {
  4010. const r = i.MappingInformationType, s = i.ReferenceInformationType, a = i.Normals.a;
  4011. let c = [];
  4012. return s === "IndexToDirect" && ("NormalIndex" in i ? c = i.NormalIndex.a : "NormalsIndex" in i && (c = i.NormalsIndex.a)), {
  4013. dataSize: 3,
  4014. buffer: a,
  4015. indices: c,
  4016. mappingType: r,
  4017. referenceType: s
  4018. };
  4019. }
  4020. // Parse UVs from FBXTree.Objects.Geometry.LayerElementUV if it exists
  4021. parseUVs(i) {
  4022. const r = i.MappingInformationType, s = i.ReferenceInformationType, a = i.UV.a;
  4023. let c = [];
  4024. return s === "IndexToDirect" && (c = i.UVIndex.a), {
  4025. dataSize: 2,
  4026. buffer: a,
  4027. indices: c,
  4028. mappingType: r,
  4029. referenceType: s
  4030. };
  4031. }
  4032. // Parse Vertex Colors from FBXTree.Objects.Geometry.LayerElementColor if it exists
  4033. parseVertexColors(i) {
  4034. const r = i.MappingInformationType, s = i.ReferenceInformationType, a = i.Colors.a;
  4035. let c = [];
  4036. return s === "IndexToDirect" && (c = i.ColorIndex.a), {
  4037. dataSize: 4,
  4038. buffer: a,
  4039. indices: c,
  4040. mappingType: r,
  4041. referenceType: s
  4042. };
  4043. }
  4044. // Parse mapping and material data in FBXTree.Objects.Geometry.LayerElementMaterial if it exists
  4045. parseMaterialIndices(i) {
  4046. const r = i.MappingInformationType, s = i.ReferenceInformationType;
  4047. if (r === "NoMappingInformation")
  4048. return {
  4049. dataSize: 1,
  4050. buffer: [0],
  4051. indices: [0],
  4052. mappingType: "AllSame",
  4053. referenceType: s
  4054. };
  4055. const a = i.Materials.a, c = [];
  4056. for (let u = 0; u < a.length; ++u)
  4057. c.push(u);
  4058. return {
  4059. dataSize: 1,
  4060. buffer: a,
  4061. indices: c,
  4062. mappingType: r,
  4063. referenceType: s
  4064. };
  4065. }
  4066. // Generate a NurbGeometry from a node in FBXTree.Objects.Geometry
  4067. parseNurbsGeometry(i) {
  4068. if (va === void 0)
  4069. 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();
  4070. const r = parseInt(i.Order);
  4071. if (isNaN(r))
  4072. return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s", i.Order, i.id), new BufferGeometry();
  4073. const s = r - 1, a = i.KnotVector.a, c = [], u = i.Points.a;
  4074. for (let _ = 0, y2 = u.length; _ < y2; _ += 4)
  4075. c.push(new Vector4().fromArray(u, _));
  4076. let h2, m;
  4077. if (i.Form === "Closed")
  4078. c.push(c[0]);
  4079. else if (i.Form === "Periodic") {
  4080. h2 = s, m = a.length - 1 - h2;
  4081. for (let _ = 0; _ < s; ++_)
  4082. c.push(c[_]);
  4083. }
  4084. const w = new va(s, a, c, h2, m).getPoints(c.length * 12);
  4085. return new BufferGeometry().setFromPoints(w);
  4086. }
  4087. };
  4088. var Xu = class {
  4089. // take raw animation clips and turn them into three.js animation clips
  4090. parse() {
  4091. const i = [], r = this.parseClips();
  4092. if (r !== void 0)
  4093. for (const s in r) {
  4094. const a = r[s], c = this.addClip(a);
  4095. i.push(c);
  4096. }
  4097. return i;
  4098. }
  4099. parseClips() {
  4100. if (oe.Objects.AnimationCurve === void 0)
  4101. return;
  4102. const i = this.parseAnimationCurveNodes();
  4103. this.parseAnimationCurves(i);
  4104. const r = this.parseAnimationLayers(i);
  4105. return this.parseAnimStacks(r);
  4106. }
  4107. // parse nodes in FBXTree.Objects.AnimationCurveNode
  4108. // each AnimationCurveNode holds data for an animation transform for a model (e.g. left arm rotation )
  4109. // and is referenced by an AnimationLayer
  4110. parseAnimationCurveNodes() {
  4111. const i = oe.Objects.AnimationCurveNode, r = /* @__PURE__ */ new Map();
  4112. for (const s in i) {
  4113. const a = i[s];
  4114. if (a.attrName.match(/S|R|T|DeformPercent/) !== null) {
  4115. const c = {
  4116. id: a.id,
  4117. attr: a.attrName,
  4118. curves: {}
  4119. };
  4120. r.set(c.id, c);
  4121. }
  4122. }
  4123. return r;
  4124. }
  4125. // parse nodes in FBXTree.Objects.AnimationCurve and connect them up to
  4126. // previously parsed AnimationCurveNodes. Each AnimationCurve holds data for a single animated
  4127. // axis ( e.g. times and values of x rotation)
  4128. parseAnimationCurves(i) {
  4129. const r = oe.Objects.AnimationCurve;
  4130. for (const s in r) {
  4131. const a = {
  4132. id: r[s].id,
  4133. times: r[s].KeyTime.a.map(Wu),
  4134. values: r[s].KeyValueFloat.a
  4135. }, c = Re2.get(a.id);
  4136. if (c !== void 0) {
  4137. const u = c.parents[0].ID, h2 = c.parents[0].relationship;
  4138. h2.match(/X/) ? i.get(u).curves.x = a : h2.match(/Y/) ? i.get(u).curves.y = a : h2.match(/Z/) ? i.get(u).curves.z = a : h2.match(/d|DeformPercent/) && i.has(u) && (i.get(u).curves.morph = a);
  4139. }
  4140. }
  4141. }
  4142. // parse nodes in FBXTree.Objects.AnimationLayer. Each layers holds references
  4143. // to various AnimationCurveNodes and is referenced by an AnimationStack node
  4144. // note: theoretically a stack can have multiple layers, however in practice there always seems to be one per stack
  4145. parseAnimationLayers(i) {
  4146. const r = oe.Objects.AnimationLayer, s = /* @__PURE__ */ new Map();
  4147. for (const a in r) {
  4148. const c = [], u = Re2.get(parseInt(a));
  4149. u !== void 0 && (u.children.forEach(function(m, g) {
  4150. if (i.has(m.ID)) {
  4151. const w = i.get(m.ID);
  4152. if (w.curves.x !== void 0 || w.curves.y !== void 0 || w.curves.z !== void 0) {
  4153. if (c[g] === void 0) {
  4154. const _ = Re2.get(m.ID).parents.filter(function(y2) {
  4155. return y2.relationship !== void 0;
  4156. })[0].ID;
  4157. if (_ !== void 0) {
  4158. const y2 = oe.Objects.Model[_.toString()];
  4159. if (y2 === void 0) {
  4160. console.warn("THREE.FBXLoader: Encountered a unused curve.", m);
  4161. return;
  4162. }
  4163. const C = {
  4164. modelName: y2.attrName ? PropertyBinding.sanitizeNodeName(y2.attrName) : "",
  4165. ID: y2.id,
  4166. initialPosition: [0, 0, 0],
  4167. initialRotation: [0, 0, 0],
  4168. initialScale: [1, 1, 1]
  4169. };
  4170. We.traverse(function(I2) {
  4171. I2.ID === y2.id && (C.transform = I2.matrix, I2.userData.transformData && (C.eulerOrder = I2.userData.transformData.eulerOrder));
  4172. }), C.transform || (C.transform = new Matrix4()), "PreRotation" in y2 && (C.preRotation = y2.PreRotation.value), "PostRotation" in y2 && (C.postRotation = y2.PostRotation.value), c[g] = C;
  4173. }
  4174. }
  4175. c[g] && (c[g][w.attr] = w);
  4176. } else if (w.curves.morph !== void 0) {
  4177. if (c[g] === void 0) {
  4178. const _ = Re2.get(m.ID).parents.filter(function(j) {
  4179. return j.relationship !== void 0;
  4180. })[0].ID, y2 = Re2.get(_).parents[0].ID, C = Re2.get(y2).parents[0].ID, I2 = Re2.get(C).parents[0].ID, S = oe.Objects.Model[I2], R = {
  4181. modelName: S.attrName ? PropertyBinding.sanitizeNodeName(S.attrName) : "",
  4182. morphName: oe.Objects.Deformer[_].attrName
  4183. };
  4184. c[g] = R;
  4185. }
  4186. c[g][w.attr] = w;
  4187. }
  4188. }
  4189. }), s.set(parseInt(a), c));
  4190. }
  4191. return s;
  4192. }
  4193. // parse nodes in FBXTree.Objects.AnimationStack. These are the top level node in the animation
  4194. // hierarchy. Each Stack node will be used to create a AnimationClip
  4195. parseAnimStacks(i) {
  4196. const r = oe.Objects.AnimationStack, s = {};
  4197. for (const a in r) {
  4198. const c = Re2.get(parseInt(a)).children;
  4199. c.length > 1 && console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");
  4200. const u = i.get(c[0].ID);
  4201. s[a] = {
  4202. name: r[a].attrName,
  4203. layer: u
  4204. };
  4205. }
  4206. return s;
  4207. }
  4208. addClip(i) {
  4209. let r = [];
  4210. const s = this;
  4211. return i.layer.forEach(function(a) {
  4212. r = r.concat(s.generateTracks(a));
  4213. }), new AnimationClip(i.name, -1, r);
  4214. }
  4215. generateTracks(i) {
  4216. const r = [];
  4217. let s = new Vector3(), a = new Quaternion(), c = new Vector3();
  4218. if (i.transform && i.transform.decompose(s, a, c), s = s.toArray(), a = new Euler().setFromQuaternion(a, i.eulerOrder).toArray(), c = c.toArray(), i.T !== void 0 && Object.keys(i.T.curves).length > 0) {
  4219. const u = this.generateVectorTrack(i.modelName, i.T.curves, s, "position");
  4220. u !== void 0 && r.push(u);
  4221. }
  4222. if (i.R !== void 0 && Object.keys(i.R.curves).length > 0) {
  4223. const u = this.generateRotationTrack(i.modelName, i.R.curves, a, i.preRotation, i.postRotation, i.eulerOrder);
  4224. u !== void 0 && r.push(u);
  4225. }
  4226. if (i.S !== void 0 && Object.keys(i.S.curves).length > 0) {
  4227. const u = this.generateVectorTrack(i.modelName, i.S.curves, c, "scale");
  4228. u !== void 0 && r.push(u);
  4229. }
  4230. if (i.DeformPercent !== void 0) {
  4231. const u = this.generateMorphTrack(i);
  4232. u !== void 0 && r.push(u);
  4233. }
  4234. return r;
  4235. }
  4236. generateVectorTrack(i, r, s, a) {
  4237. const c = this.getTimesForAllAxes(r), u = this.getKeyframeTrackValues(c, r, s);
  4238. return new VectorKeyframeTrack(i + "." + a, c, u);
  4239. }
  4240. generateRotationTrack(i, r, s, a, c, u) {
  4241. r.x !== void 0 && (this.interpolateRotations(r.x), r.x.values = r.x.values.map(MathUtils.degToRad)), r.y !== void 0 && (this.interpolateRotations(r.y), r.y.values = r.y.values.map(MathUtils.degToRad)), r.z !== void 0 && (this.interpolateRotations(r.z), r.z.values = r.z.values.map(MathUtils.degToRad));
  4242. const h2 = this.getTimesForAllAxes(r), m = this.getKeyframeTrackValues(h2, r, s);
  4243. a !== void 0 && (a = a.map(MathUtils.degToRad), a.push(u), a = new Euler().fromArray(a), a = new Quaternion().setFromEuler(a)), c !== void 0 && (c = c.map(MathUtils.degToRad), c.push(u), c = new Euler().fromArray(c), c = new Quaternion().setFromEuler(c).invert());
  4244. const g = new Quaternion(), w = new Euler(), _ = [];
  4245. for (let y2 = 0; y2 < m.length; y2 += 3)
  4246. w.set(m[y2], m[y2 + 1], m[y2 + 2], u), g.setFromEuler(w), a !== void 0 && g.premultiply(a), c !== void 0 && g.multiply(c), g.toArray(_, y2 / 3 * 4);
  4247. return new QuaternionKeyframeTrack(i + ".quaternion", h2, _);
  4248. }
  4249. generateMorphTrack(i) {
  4250. const r = i.DeformPercent.curves.morph, s = r.values.map(function(c) {
  4251. return c / 100;
  4252. }), a = We.getObjectByName(i.modelName).morphTargetDictionary[i.morphName];
  4253. return new NumberKeyframeTrack(i.modelName + ".morphTargetInfluences[" + a + "]", r.times, s);
  4254. }
  4255. // For all animated objects, times are defined separately for each axis
  4256. // Here we'll combine the times into one sorted array without duplicates
  4257. getTimesForAllAxes(i) {
  4258. let r = [];
  4259. if (i.x !== void 0 && (r = r.concat(i.x.times)), i.y !== void 0 && (r = r.concat(i.y.times)), i.z !== void 0 && (r = r.concat(i.z.times)), r = r.sort(function(s, a) {
  4260. return s - a;
  4261. }), r.length > 1) {
  4262. let s = 1, a = r[0];
  4263. for (let c = 1; c < r.length; c++) {
  4264. const u = r[c];
  4265. u !== a && (r[s] = u, a = u, s++);
  4266. }
  4267. r = r.slice(0, s);
  4268. }
  4269. return r;
  4270. }
  4271. getKeyframeTrackValues(i, r, s) {
  4272. const a = s, c = [];
  4273. let u = -1, h2 = -1, m = -1;
  4274. return i.forEach(function(g) {
  4275. if (r.x && (u = r.x.times.indexOf(g)), r.y && (h2 = r.y.times.indexOf(g)), r.z && (m = r.z.times.indexOf(g)), u !== -1) {
  4276. const w = r.x.values[u];
  4277. c.push(w), a[0] = w;
  4278. } else
  4279. c.push(a[0]);
  4280. if (h2 !== -1) {
  4281. const w = r.y.values[h2];
  4282. c.push(w), a[1] = w;
  4283. } else
  4284. c.push(a[1]);
  4285. if (m !== -1) {
  4286. const w = r.z.values[m];
  4287. c.push(w), a[2] = w;
  4288. } else
  4289. c.push(a[2]);
  4290. }), c;
  4291. }
  4292. // Rotations are defined as Euler angles which can have values of any size
  4293. // These will be converted to quaternions which don't support values greater than
  4294. // PI, so we'll interpolate large rotations
  4295. interpolateRotations(i) {
  4296. for (let r = 1; r < i.values.length; r++) {
  4297. const s = i.values[r - 1], a = i.values[r] - s, c = Math.abs(a);
  4298. if (c >= 180) {
  4299. const u = c / 180, h2 = a / u;
  4300. let m = s + h2;
  4301. const g = i.times[r - 1], _ = (i.times[r] - g) / u;
  4302. let y2 = g + _;
  4303. const C = [], I2 = [];
  4304. for (; y2 < i.times[r]; )
  4305. C.push(y2), y2 += _, I2.push(m), m += h2;
  4306. i.times = _a(i.times, r, C), i.values = _a(i.values, r, I2);
  4307. }
  4308. }
  4309. }
  4310. };
  4311. var Yu = class {
  4312. getPrevNode() {
  4313. return this.nodeStack[this.currentIndent - 2];
  4314. }
  4315. getCurrentNode() {
  4316. return this.nodeStack[this.currentIndent - 1];
  4317. }
  4318. getCurrentProp() {
  4319. return this.currentProp;
  4320. }
  4321. pushStack(i) {
  4322. this.nodeStack.push(i), this.currentIndent += 1;
  4323. }
  4324. popStack() {
  4325. this.nodeStack.pop(), this.currentIndent -= 1;
  4326. }
  4327. setCurrentProp(i, r) {
  4328. this.currentProp = i, this.currentPropName = r;
  4329. }
  4330. parse(i) {
  4331. this.currentIndent = 0, this.allNodes = new Za(), this.nodeStack = [], this.currentProp = [], this.currentPropName = "";
  4332. const r = this, s = i.split(/[\r\n]+/);
  4333. return s.forEach(function(a, c) {
  4334. const u = a.match(/^[\s\t]*;/), h2 = a.match(/^[\s\t]*$/);
  4335. if (u || h2)
  4336. return;
  4337. const m = a.match("^\\t{" + r.currentIndent + "}(\\w+):(.*){", ""), g = a.match("^\\t{" + r.currentIndent + "}(\\w+):[\\s\\t\\r\\n](.*)"), w = a.match("^\\t{" + (r.currentIndent - 1) + "}}");
  4338. m ? r.parseNodeBegin(a, m) : g ? r.parseNodeProperty(a, g, s[++c]) : w ? r.popStack() : a.match(/^[^\s\t}]/) && r.parseNodePropertyContinued(a);
  4339. }), this.allNodes;
  4340. }
  4341. parseNodeBegin(i, r) {
  4342. const s = r[1].trim().replace(/^"/, "").replace(/"$/, ""), a = r[2].split(",").map(function(m) {
  4343. return m.trim().replace(/^"/, "").replace(/"$/, "");
  4344. }), c = {
  4345. name: s
  4346. }, u = this.parseNodeAttr(a), h2 = this.getCurrentNode();
  4347. this.currentIndent === 0 ? this.allNodes.add(s, c) : s in h2 ? (s === "PoseNode" ? h2.PoseNode.push(c) : h2[s].id !== void 0 && (h2[s] = {}, h2[s][h2[s].id] = h2[s]), u.id !== "" && (h2[s][u.id] = c)) : typeof u.id == "number" ? (h2[s] = {}, h2[s][u.id] = c) : s !== "Properties70" && (s === "PoseNode" ? h2[s] = [c] : h2[s] = c), typeof u.id == "number" && (c.id = u.id), u.name !== "" && (c.attrName = u.name), u.type !== "" && (c.attrType = u.type), this.pushStack(c);
  4348. }
  4349. parseNodeAttr(i) {
  4350. let r = i[0];
  4351. i[0] !== "" && (r = parseInt(i[0]), isNaN(r) && (r = i[0]));
  4352. let s = "", a = "";
  4353. return i.length > 1 && (s = i[1].replace(/^(\w+)::/, ""), a = i[2]), {
  4354. id: r,
  4355. name: s,
  4356. type: a
  4357. };
  4358. }
  4359. parseNodeProperty(i, r, s) {
  4360. let a = r[1].replace(/^"/, "").replace(/"$/, "").trim(), c = r[2].replace(/^"/, "").replace(/"$/, "").trim();
  4361. a === "Content" && c === "," && (c = s.replace(/"/g, "").replace(/,$/, "").trim());
  4362. const u = this.getCurrentNode();
  4363. if (u.name === "Properties70") {
  4364. this.parseNodeSpecialProperty(i, a, c);
  4365. return;
  4366. }
  4367. if (a === "C") {
  4368. const m = c.split(",").slice(1), g = parseInt(m[0]), w = parseInt(m[1]);
  4369. let _ = c.split(",").slice(3);
  4370. _ = _.map(function(y2) {
  4371. return y2.trim().replace(/^"/, "");
  4372. }), a = "connections", c = [g, w], eh(c, _), u[a] === void 0 && (u[a] = []);
  4373. }
  4374. a === "Node" && (u.id = c), a in u && Array.isArray(u[a]) ? u[a].push(c) : a !== "a" ? u[a] = c : u.a = c, this.setCurrentProp(u, a), a === "a" && c.slice(-1) !== "," && (u.a = eo(c));
  4375. }
  4376. parseNodePropertyContinued(i) {
  4377. const r = this.getCurrentNode();
  4378. r.a += i, i.slice(-1) !== "," && (r.a = eo(r.a));
  4379. }
  4380. // parse "Property70"
  4381. parseNodeSpecialProperty(i, r, s) {
  4382. const a = s.split('",').map(function(w) {
  4383. return w.trim().replace(/^\"/, "").replace(/\s/, "_");
  4384. }), c = a[0], u = a[1], h2 = a[2], m = a[3];
  4385. let g = a[4];
  4386. switch (u) {
  4387. case "int":
  4388. case "enum":
  4389. case "bool":
  4390. case "ULongLong":
  4391. case "double":
  4392. case "Number":
  4393. case "FieldOfView":
  4394. g = parseFloat(g);
  4395. break;
  4396. case "Color":
  4397. case "ColorRGB":
  4398. case "Vector3D":
  4399. case "Lcl_Translation":
  4400. case "Lcl_Rotation":
  4401. case "Lcl_Scaling":
  4402. g = eo(g);
  4403. break;
  4404. }
  4405. this.getPrevNode()[c] = {
  4406. type: u,
  4407. type2: h2,
  4408. flag: m,
  4409. value: g
  4410. }, this.setCurrentProp(this.getPrevNode(), c);
  4411. }
  4412. };
  4413. var qu = class {
  4414. parse(i) {
  4415. const r = new ba(i);
  4416. r.skip(23);
  4417. const s = r.getUint32();
  4418. if (s < 6400)
  4419. throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: " + s);
  4420. const a = new Za();
  4421. for (; !this.endOfContent(r); ) {
  4422. const c = this.parseNode(r, s);
  4423. c !== null && a.add(c.name, c);
  4424. }
  4425. return a;
  4426. }
  4427. // Check if reader has reached the end of content.
  4428. endOfContent(i) {
  4429. return i.size() % 16 === 0 ? (i.getOffset() + 160 + 16 & -16) >= i.size() : i.getOffset() + 160 + 16 >= i.size();
  4430. }
  4431. // recursively parse nodes until the end of the file is reached
  4432. parseNode(i, r) {
  4433. const s = {}, a = r >= 7500 ? i.getUint64() : i.getUint32(), c = r >= 7500 ? i.getUint64() : i.getUint32();
  4434. r >= 7500 ? i.getUint64() : i.getUint32();
  4435. const u = i.getUint8(), h2 = i.getString(u);
  4436. if (a === 0)
  4437. return null;
  4438. const m = [];
  4439. for (let y2 = 0; y2 < c; y2++)
  4440. m.push(this.parseProperty(i));
  4441. const g = m.length > 0 ? m[0] : "", w = m.length > 1 ? m[1] : "", _ = m.length > 2 ? m[2] : "";
  4442. for (s.singleProperty = c === 1 && i.getOffset() === a; a > i.getOffset(); ) {
  4443. const y2 = this.parseNode(i, r);
  4444. y2 !== null && this.parseSubNode(h2, s, y2);
  4445. }
  4446. return s.propertyList = m, typeof g == "number" && (s.id = g), w !== "" && (s.attrName = w), _ !== "" && (s.attrType = _), h2 !== "" && (s.name = h2), s;
  4447. }
  4448. parseSubNode(i, r, s) {
  4449. if (s.singleProperty === true) {
  4450. const a = s.propertyList[0];
  4451. Array.isArray(a) ? (r[s.name] = s, s.a = a) : r[s.name] = a;
  4452. } else if (i === "Connections" && s.name === "C") {
  4453. const a = [];
  4454. s.propertyList.forEach(function(c, u) {
  4455. u !== 0 && a.push(c);
  4456. }), r.connections === void 0 && (r.connections = []), r.connections.push(a);
  4457. } else if (s.name === "Properties70")
  4458. Object.keys(s).forEach(function(c) {
  4459. r[c] = s[c];
  4460. });
  4461. else if (i === "Properties70" && s.name === "P") {
  4462. let a = s.propertyList[0], c = s.propertyList[1];
  4463. const u = s.propertyList[2], h2 = s.propertyList[3];
  4464. let m;
  4465. a.indexOf("Lcl ") === 0 && (a = a.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 = [s.propertyList[4], s.propertyList[5], s.propertyList[6]] : m = s.propertyList[4], r[a] = {
  4466. type: c,
  4467. type2: u,
  4468. flag: h2,
  4469. value: m
  4470. };
  4471. } else
  4472. r[s.name] === void 0 ? typeof s.id == "number" ? (r[s.name] = {}, r[s.name][s.id] = s) : r[s.name] = s : s.name === "PoseNode" ? (Array.isArray(r[s.name]) || (r[s.name] = [r[s.name]]), r[s.name].push(s)) : r[s.name][s.id] === void 0 && (r[s.name][s.id] = s);
  4473. }
  4474. parseProperty(i) {
  4475. const r = i.getString(1);
  4476. let s;
  4477. switch (r) {
  4478. case "C":
  4479. return i.getBoolean();
  4480. case "D":
  4481. return i.getFloat64();
  4482. case "F":
  4483. return i.getFloat32();
  4484. case "I":
  4485. return i.getInt32();
  4486. case "L":
  4487. return i.getInt64();
  4488. case "R":
  4489. return s = i.getUint32(), i.getArrayBuffer(s);
  4490. case "S":
  4491. return s = i.getUint32(), i.getString(s);
  4492. case "Y":
  4493. return i.getInt16();
  4494. case "b":
  4495. case "c":
  4496. case "d":
  4497. case "f":
  4498. case "i":
  4499. case "l":
  4500. const a = i.getUint32(), c = i.getUint32(), u = i.getUint32();
  4501. if (c === 0)
  4502. switch (r) {
  4503. case "b":
  4504. case "c":
  4505. return i.getBooleanArray(a);
  4506. case "d":
  4507. return i.getFloat64Array(a);
  4508. case "f":
  4509. return i.getFloat32Array(a);
  4510. case "i":
  4511. return i.getInt32Array(a);
  4512. case "l":
  4513. return i.getInt64Array(a);
  4514. }
  4515. const h2 = Jp(new Uint8Array(i.getArrayBuffer(u))), m = new ba(h2.buffer);
  4516. switch (r) {
  4517. case "b":
  4518. case "c":
  4519. return m.getBooleanArray(a);
  4520. case "d":
  4521. return m.getFloat64Array(a);
  4522. case "f":
  4523. return m.getFloat32Array(a);
  4524. case "i":
  4525. return m.getInt32Array(a);
  4526. case "l":
  4527. return m.getInt64Array(a);
  4528. }
  4529. default:
  4530. throw new Error("THREE.FBXLoader: Unknown property type " + r);
  4531. }
  4532. }
  4533. };
  4534. var ba = class {
  4535. constructor(i, r) {
  4536. this.dv = new DataView(i), this.offset = 0, this.littleEndian = r !== void 0 ? r : true;
  4537. }
  4538. getOffset() {
  4539. return this.offset;
  4540. }
  4541. size() {
  4542. return this.dv.buffer.byteLength;
  4543. }
  4544. skip(i) {
  4545. this.offset += i;
  4546. }
  4547. // seems like true/false representation depends on exporter.
  4548. // true: 1 or 'Y'(=0x59), false: 0 or 'T'(=0x54)
  4549. // then sees LSB.
  4550. getBoolean() {
  4551. return (this.getUint8() & 1) === 1;
  4552. }
  4553. getBooleanArray(i) {
  4554. const r = [];
  4555. for (let s = 0; s < i; s++)
  4556. r.push(this.getBoolean());
  4557. return r;
  4558. }
  4559. getUint8() {
  4560. const i = this.dv.getUint8(this.offset);
  4561. return this.offset += 1, i;
  4562. }
  4563. getInt16() {
  4564. const i = this.dv.getInt16(this.offset, this.littleEndian);
  4565. return this.offset += 2, i;
  4566. }
  4567. getInt32() {
  4568. const i = this.dv.getInt32(this.offset, this.littleEndian);
  4569. return this.offset += 4, i;
  4570. }
  4571. getInt32Array(i) {
  4572. const r = [];
  4573. for (let s = 0; s < i; s++)
  4574. r.push(this.getInt32());
  4575. return r;
  4576. }
  4577. getUint32() {
  4578. const i = this.dv.getUint32(this.offset, this.littleEndian);
  4579. return this.offset += 4, i;
  4580. }
  4581. // JavaScript doesn't support 64-bit integer so calculate this here
  4582. // 1 << 32 will return 1 so using multiply operation instead here.
  4583. // There's a possibility that this method returns wrong value if the value
  4584. // is out of the range between Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER.
  4585. // TODO: safely handle 64-bit integer
  4586. getInt64() {
  4587. let i, r;
  4588. return this.littleEndian ? (i = this.getUint32(), r = this.getUint32()) : (r = this.getUint32(), i = this.getUint32()), r & 2147483648 ? (r = ~r & 4294967295, i = ~i & 4294967295, i === 4294967295 && (r = r + 1 & 4294967295), i = i + 1 & 4294967295, -(r * 4294967296 + i)) : r * 4294967296 + i;
  4589. }
  4590. getInt64Array(i) {
  4591. const r = [];
  4592. for (let s = 0; s < i; s++)
  4593. r.push(this.getInt64());
  4594. return r;
  4595. }
  4596. // Note: see getInt64() comment
  4597. getUint64() {
  4598. let i, r;
  4599. return this.littleEndian ? (i = this.getUint32(), r = this.getUint32()) : (r = this.getUint32(), i = this.getUint32()), r * 4294967296 + i;
  4600. }
  4601. getFloat32() {
  4602. const i = this.dv.getFloat32(this.offset, this.littleEndian);
  4603. return this.offset += 4, i;
  4604. }
  4605. getFloat32Array(i) {
  4606. const r = [];
  4607. for (let s = 0; s < i; s++)
  4608. r.push(this.getFloat32());
  4609. return r;
  4610. }
  4611. getFloat64() {
  4612. const i = this.dv.getFloat64(this.offset, this.littleEndian);
  4613. return this.offset += 8, i;
  4614. }
  4615. getFloat64Array(i) {
  4616. const r = [];
  4617. for (let s = 0; s < i; s++)
  4618. r.push(this.getFloat64());
  4619. return r;
  4620. }
  4621. getArrayBuffer(i) {
  4622. const r = this.dv.buffer.slice(this.offset, this.offset + i);
  4623. return this.offset += i, r;
  4624. }
  4625. getString(i) {
  4626. let r = [];
  4627. for (let a = 0; a < i; a++)
  4628. r[a] = this.getUint8();
  4629. const s = r.indexOf(0);
  4630. return s >= 0 && (r = r.slice(0, s)), LoaderUtils.decodeText(new Uint8Array(r));
  4631. }
  4632. };
  4633. var Za = class {
  4634. add(i, r) {
  4635. this[i] = r;
  4636. }
  4637. };
  4638. function Qu(b2) {
  4639. const i = "Kaydara FBX Binary \0";
  4640. return b2.byteLength >= i.length && i === el(b2, 0, i.length);
  4641. }
  4642. function Zu(b2) {
  4643. const i = ["K", "a", "y", "d", "a", "r", "a", "\\", "F", "B", "X", "\\", "B", "i", "n", "a", "r", "y", "\\", "\\"];
  4644. let r = 0;
  4645. function s(a) {
  4646. const c = b2[a - 1];
  4647. return b2 = b2.slice(r + a), r++, c;
  4648. }
  4649. for (let a = 0; a < i.length; ++a)
  4650. if (s(1) === i[a])
  4651. return false;
  4652. return true;
  4653. }
  4654. function ga(b2) {
  4655. const i = /FBXVersion: (\d+)/, r = b2.match(i);
  4656. if (r)
  4657. return parseInt(r[1]);
  4658. throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.");
  4659. }
  4660. function Wu(b2) {
  4661. return b2 / 46186158e3;
  4662. }
  4663. var Ju = [];
  4664. function Vs(b2, i, r, s) {
  4665. let a;
  4666. switch (s.mappingType) {
  4667. case "ByPolygonVertex":
  4668. a = b2;
  4669. break;
  4670. case "ByPolygon":
  4671. a = i;
  4672. break;
  4673. case "ByVertice":
  4674. a = r;
  4675. break;
  4676. case "AllSame":
  4677. a = s.indices[0];
  4678. break;
  4679. default:
  4680. console.warn("THREE.FBXLoader: unknown attribute mapping type " + s.mappingType);
  4681. }
  4682. s.referenceType === "IndexToDirect" && (a = s.indices[a]);
  4683. const c = a * s.dataSize, u = c + s.dataSize;
  4684. return th(Ju, s.buffer, c, u);
  4685. }
  4686. var Jr = new Euler();
  4687. var li = new Vector3();
  4688. function Wa(b2) {
  4689. const i = new Matrix4(), r = new Matrix4(), s = new Matrix4(), a = new Matrix4(), c = new Matrix4(), u = new Matrix4(), h2 = new Matrix4(), m = new Matrix4(), g = new Matrix4(), w = new Matrix4(), _ = new Matrix4(), y2 = new Matrix4(), C = b2.inheritType ? b2.inheritType : 0;
  4690. if (b2.translation && i.setPosition(li.fromArray(b2.translation)), b2.preRotation) {
  4691. const K = b2.preRotation.map(MathUtils.degToRad);
  4692. K.push(b2.eulerOrder), r.makeRotationFromEuler(Jr.fromArray(K));
  4693. }
  4694. if (b2.rotation) {
  4695. const K = b2.rotation.map(MathUtils.degToRad);
  4696. K.push(b2.eulerOrder), s.makeRotationFromEuler(Jr.fromArray(K));
  4697. }
  4698. if (b2.postRotation) {
  4699. const K = b2.postRotation.map(MathUtils.degToRad);
  4700. K.push(b2.eulerOrder), a.makeRotationFromEuler(Jr.fromArray(K)), a.invert();
  4701. }
  4702. b2.scale && c.scale(li.fromArray(b2.scale)), b2.scalingOffset && h2.setPosition(li.fromArray(b2.scalingOffset)), b2.scalingPivot && u.setPosition(li.fromArray(b2.scalingPivot)), b2.rotationOffset && m.setPosition(li.fromArray(b2.rotationOffset)), b2.rotationPivot && g.setPosition(li.fromArray(b2.rotationPivot)), b2.parentMatrixWorld && (_.copy(b2.parentMatrix), w.copy(b2.parentMatrixWorld));
  4703. const I2 = r.clone().multiply(s).multiply(a), S = new Matrix4();
  4704. S.extractRotation(w);
  4705. const R = new Matrix4();
  4706. R.copyPosition(w);
  4707. const j = R.clone().invert().multiply(w), F2 = S.clone().invert().multiply(j), V = c, D2 = new Matrix4();
  4708. if (C === 0)
  4709. D2.copy(S).multiply(I2).multiply(F2).multiply(V);
  4710. else if (C === 1)
  4711. D2.copy(S).multiply(F2).multiply(I2).multiply(V);
  4712. else {
  4713. const q = new Matrix4().scale(new Vector3().setFromMatrixScale(_)).clone().invert(), he = F2.clone().multiply(q);
  4714. D2.copy(S).multiply(I2).multiply(he).multiply(V);
  4715. }
  4716. const Y2 = g.clone().invert(), G = u.clone().invert();
  4717. let N2 = i.clone().multiply(m).multiply(g).multiply(r).multiply(s).multiply(a).multiply(Y2).multiply(h2).multiply(u).multiply(c).multiply(G);
  4718. const O = new Matrix4().copyPosition(N2), H = w.clone().multiply(O);
  4719. return y2.copyPosition(H), N2 = y2.clone().multiply(D2), N2.premultiply(w.invert()), N2;
  4720. }
  4721. function Ja(b2) {
  4722. b2 = b2 || 0;
  4723. const i = [
  4724. "ZYX",
  4725. // -> XYZ extrinsic
  4726. "YZX",
  4727. // -> XZY extrinsic
  4728. "XZY",
  4729. // -> YZX extrinsic
  4730. "ZXY",
  4731. // -> YXZ extrinsic
  4732. "YXZ",
  4733. // -> ZXY extrinsic
  4734. "XYZ"
  4735. // -> ZYX extrinsic
  4736. //'SphericXYZ', // not possible to support
  4737. ];
  4738. return b2 === 6 ? (console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."), i[0]) : i[b2];
  4739. }
  4740. function eo(b2) {
  4741. return b2.split(",").map(function(r) {
  4742. return parseFloat(r);
  4743. });
  4744. }
  4745. function el(b2, i, r) {
  4746. return i === void 0 && (i = 0), r === void 0 && (r = b2.byteLength), LoaderUtils.decodeText(new Uint8Array(b2, i, r));
  4747. }
  4748. function eh(b2, i) {
  4749. for (let r = 0, s = b2.length, a = i.length; r < a; r++, s++)
  4750. b2[s] = i[r];
  4751. }
  4752. function th(b2, i, r, s) {
  4753. for (let a = r, c = 0; a < s; a++, c++)
  4754. b2[c] = i[a];
  4755. return b2;
  4756. }
  4757. function _a(b2, i, r) {
  4758. return b2.slice(0, i).concat(r).concat(b2.slice(i));
  4759. }
  4760. var nh = class extends Loader {
  4761. constructor(i) {
  4762. super(i);
  4763. }
  4764. load(i, r, s, a) {
  4765. const c = new FileLoader(this.manager);
  4766. c.setPath(this.path), c.setRequestHeader(this.requestHeader), c.setWithCredentials(this.withCredentials), c.load(i, (u) => {
  4767. if (typeof u != "string")
  4768. throw new Error("unsupported data type");
  4769. const h2 = JSON.parse(u), m = this.parse(h2);
  4770. r && r(m);
  4771. }, s, a);
  4772. }
  4773. parse(i) {
  4774. return new wo(i);
  4775. }
  4776. };
  4777. var wo = class {
  4778. constructor(i) {
  4779. P(this, "data", void 0), this.data = i;
  4780. }
  4781. generateShapes(i, r = 100, s) {
  4782. const a = [], c = {
  4783. letterSpacing: 0,
  4784. lineHeight: 1,
  4785. ...s
  4786. }, u = ih(i, r, this.data, c);
  4787. for (let h2 = 0, m = u.length; h2 < m; h2++)
  4788. Array.prototype.push.apply(a, u[h2].toShapes(false));
  4789. return a;
  4790. }
  4791. };
  4792. P(wo, "isFont", void 0);
  4793. P(wo, "type", void 0);
  4794. function ih(b2, i, r, s) {
  4795. const a = Array.from(b2), c = i / r.resolution, u = (r.boundingBox.yMax - r.boundingBox.yMin + r.underlineThickness) * c, h2 = [];
  4796. let m = 0, g = 0;
  4797. for (let w = 0; w < a.length; w++) {
  4798. const _ = a[w];
  4799. if (_ === `
  4800. `)
  4801. m = 0, g -= u * s.lineHeight;
  4802. else {
  4803. const y2 = sh(_, c, m, g, r);
  4804. y2 && (m += y2.offsetX + s.letterSpacing, h2.push(y2.path));
  4805. }
  4806. }
  4807. return h2;
  4808. }
  4809. function sh(b2, i, r, s, a) {
  4810. const c = a.glyphs[b2] || a.glyphs["?"];
  4811. if (!c) {
  4812. console.error('THREE.Font: character "' + b2 + '" does not exists in font family ' + a.familyName + ".");
  4813. return;
  4814. }
  4815. const u = new ShapePath();
  4816. let h2, m, g, w, _, y2, C, I2;
  4817. if (c.o) {
  4818. const S = c._cachedOutline || (c._cachedOutline = c.o.split(" "));
  4819. for (let R = 0, j = S.length; R < j; )
  4820. switch (S[R++]) {
  4821. case "m":
  4822. h2 = parseInt(S[R++]) * i + r, m = parseInt(S[R++]) * i + s, u.moveTo(h2, m);
  4823. break;
  4824. case "l":
  4825. h2 = parseInt(S[R++]) * i + r, m = parseInt(S[R++]) * i + s, u.lineTo(h2, m);
  4826. break;
  4827. case "q":
  4828. g = parseInt(S[R++]) * i + r, w = parseInt(S[R++]) * i + s, _ = parseInt(S[R++]) * i + r, y2 = parseInt(S[R++]) * i + s, u.quadraticCurveTo(_, y2, g, w);
  4829. break;
  4830. case "b":
  4831. g = parseInt(S[R++]) * i + r, w = parseInt(S[R++]) * i + s, _ = parseInt(S[R++]) * i + r, y2 = parseInt(S[R++]) * i + s, C = parseInt(S[R++]) * i + r, I2 = parseInt(S[R++]) * i + s, u.bezierCurveTo(_, y2, C, I2, g, w);
  4832. break;
  4833. }
  4834. }
  4835. return {
  4836. offsetX: c.ha * i,
  4837. path: u
  4838. };
  4839. }
  4840. var tl = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
  4841. function rh(b2) {
  4842. return b2 && b2.__esModule && Object.prototype.hasOwnProperty.call(b2, "default") ? b2.default : b2;
  4843. }
  4844. var oh = class extends DataTextureLoader {
  4845. constructor(i) {
  4846. super(i), this.type = HalfFloatType;
  4847. }
  4848. // adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html
  4849. parse(i) {
  4850. const h2 = function(V, D2) {
  4851. switch (V) {
  4852. case 1:
  4853. console.error("THREE.RGBELoader Read Error: " + (D2 || ""));
  4854. break;
  4855. case 2:
  4856. console.error("THREE.RGBELoader Write Error: " + (D2 || ""));
  4857. break;
  4858. case 3:
  4859. console.error("THREE.RGBELoader Bad File Format: " + (D2 || ""));
  4860. break;
  4861. default:
  4862. case 4:
  4863. console.error("THREE.RGBELoader: Error: " + (D2 || ""));
  4864. }
  4865. return -1;
  4866. }, _ = `
  4867. `, y2 = function(V, D2, Y2) {
  4868. D2 = D2 || 1024;
  4869. let N2 = V.pos, O = -1, H = 0, K = "", q = String.fromCharCode.apply(null, new Uint16Array(V.subarray(N2, N2 + 128)));
  4870. for (; 0 > (O = q.indexOf(_)) && H < D2 && N2 < V.byteLength; )
  4871. K += q, H += q.length, N2 += 128, q += String.fromCharCode.apply(null, new Uint16Array(V.subarray(N2, N2 + 128)));
  4872. return -1 < O ? (Y2 !== false && (V.pos += H + O + 1), K + q.slice(0, O)) : false;
  4873. }, C = function(V) {
  4874. const D2 = /^#\?(\S+)/, Y2 = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/, G = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/, N2 = /^\s*FORMAT=(\S+)\s*$/, O = /^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/, H = {
  4875. valid: 0,
  4876. string: "",
  4877. comments: "",
  4878. programtype: "RGBE",
  4879. format: "",
  4880. gamma: 1,
  4881. exposure: 1,
  4882. width: 0,
  4883. height: 0
  4884. /* image dimensions, width/height */
  4885. };
  4886. let K, q;
  4887. if (V.pos >= V.byteLength || !(K = y2(V)))
  4888. return h2(1, "no header found");
  4889. if (!(q = K.match(D2)))
  4890. return h2(3, "bad initial token");
  4891. for (H.valid |= 1, H.programtype = q[1], H.string += K + `
  4892. `; K = y2(V), K !== false; ) {
  4893. if (H.string += K + `
  4894. `, K.charAt(0) === "#") {
  4895. H.comments += K + `
  4896. `;
  4897. continue;
  4898. }
  4899. if ((q = K.match(Y2)) && (H.gamma = parseFloat(q[1])), (q = K.match(G)) && (H.exposure = parseFloat(q[1])), (q = K.match(N2)) && (H.valid |= 2, H.format = q[1]), (q = K.match(O)) && (H.valid |= 4, H.height = parseInt(q[1], 10), H.width = parseInt(q[2], 10)), H.valid & 2 && H.valid & 4)
  4900. break;
  4901. }
  4902. return H.valid & 2 ? H.valid & 4 ? H : h2(3, "missing image size specifier") : h2(3, "missing format specifier");
  4903. }, I2 = function(V, D2, Y2) {
  4904. const G = D2;
  4905. if (
  4906. // run length encoding is not allowed so read flat
  4907. G < 8 || G > 32767 || // this file is not run length encoded
  4908. V[0] !== 2 || V[1] !== 2 || V[2] & 128
  4909. )
  4910. return new Uint8Array(V);
  4911. if (G !== (V[2] << 8 | V[3]))
  4912. return h2(3, "wrong scanline width");
  4913. const N2 = new Uint8Array(4 * D2 * Y2);
  4914. if (!N2.length)
  4915. return h2(4, "unable to allocate buffer space");
  4916. let O = 0, H = 0;
  4917. const K = 4 * G, q = new Uint8Array(4), he = new Uint8Array(K);
  4918. let _e = Y2;
  4919. for (; _e > 0 && H < V.byteLength; ) {
  4920. if (H + 4 > V.byteLength)
  4921. return h2(1);
  4922. if (q[0] = V[H++], q[1] = V[H++], q[2] = V[H++], q[3] = V[H++], q[0] != 2 || q[1] != 2 || (q[2] << 8 | q[3]) != G)
  4923. return h2(3, "bad rgbe scanline format");
  4924. let pe = 0, fe2;
  4925. for (; pe < K && H < V.byteLength; ) {
  4926. fe2 = V[H++];
  4927. const te2 = fe2 > 128;
  4928. if (te2 && (fe2 -= 128), fe2 === 0 || pe + fe2 > K)
  4929. return h2(3, "bad scanline data");
  4930. if (te2) {
  4931. const X2 = V[H++];
  4932. for (let ke = 0; ke < fe2; ke++)
  4933. he[pe++] = X2;
  4934. } else
  4935. he.set(V.subarray(H, H + fe2), pe), pe += fe2, H += fe2;
  4936. }
  4937. const de2 = G;
  4938. for (let te2 = 0; te2 < de2; te2++) {
  4939. let X2 = 0;
  4940. N2[O] = he[te2 + X2], X2 += G, N2[O + 1] = he[te2 + X2], X2 += G, N2[O + 2] = he[te2 + X2], X2 += G, N2[O + 3] = he[te2 + X2], O += 4;
  4941. }
  4942. _e--;
  4943. }
  4944. return N2;
  4945. }, S = function(V, D2, Y2, G) {
  4946. const N2 = V[D2 + 3], O = Math.pow(2, N2 - 128) / 255;
  4947. Y2[G + 0] = V[D2 + 0] * O, Y2[G + 1] = V[D2 + 1] * O, Y2[G + 2] = V[D2 + 2] * O, Y2[G + 3] = 1;
  4948. }, R = function(V, D2, Y2, G) {
  4949. const N2 = V[D2 + 3], O = Math.pow(2, N2 - 128) / 255;
  4950. Y2[G + 0] = DataUtils.toHalfFloat(Math.min(V[D2 + 0] * O, 65504)), Y2[G + 1] = DataUtils.toHalfFloat(Math.min(V[D2 + 1] * O, 65504)), Y2[G + 2] = DataUtils.toHalfFloat(Math.min(V[D2 + 2] * O, 65504)), Y2[G + 3] = DataUtils.toHalfFloat(1);
  4951. }, j = new Uint8Array(i);
  4952. j.pos = 0;
  4953. const F2 = C(j);
  4954. if (F2 !== -1) {
  4955. const V = F2.width, D2 = F2.height, Y2 = I2(j.subarray(j.pos), V, D2);
  4956. if (Y2 !== -1) {
  4957. let G, N2, O;
  4958. switch (this.type) {
  4959. case FloatType:
  4960. O = Y2.length / 4;
  4961. const H = new Float32Array(O * 4);
  4962. for (let q = 0; q < O; q++)
  4963. S(Y2, q * 4, H, q * 4);
  4964. G = H, N2 = FloatType;
  4965. break;
  4966. case HalfFloatType:
  4967. O = Y2.length / 4;
  4968. const K = new Uint16Array(O * 4);
  4969. for (let q = 0; q < O; q++)
  4970. R(Y2, q * 4, K, q * 4);
  4971. G = K, N2 = HalfFloatType;
  4972. break;
  4973. default:
  4974. console.error("THREE.RGBELoader: unsupported type: ", this.type);
  4975. break;
  4976. }
  4977. return {
  4978. width: V,
  4979. height: D2,
  4980. data: G,
  4981. header: F2.string,
  4982. gamma: F2.gamma,
  4983. exposure: F2.exposure,
  4984. type: N2
  4985. };
  4986. }
  4987. }
  4988. return null;
  4989. }
  4990. setDataType(i) {
  4991. return this.type = i, this;
  4992. }
  4993. load(i, r, s, a) {
  4994. function c(u, h2) {
  4995. switch (u.type) {
  4996. case FloatType:
  4997. case HalfFloatType:
  4998. u.encoding = LinearEncoding, u.minFilter = LinearFilter, u.magFilter = LinearFilter, u.generateMipmaps = false, u.flipY = true;
  4999. break;
  5000. }
  5001. r && r(u, h2);
  5002. }
  5003. return super.load(i, c, s, a);
  5004. }
  5005. };
  5006. var to = /* @__PURE__ */ new WeakMap();
  5007. var ah = class extends Loader {
  5008. constructor(i) {
  5009. super(i), this.decoderPath = "", this.decoderConfig = {}, this.decoderBinary = null, this.decoderPending = null, this.workerLimit = 4, this.workerPool = [], this.workerNextTaskID = 1, this.workerSourceURL = "", this.defaultAttributeIDs = {
  5010. position: "POSITION",
  5011. normal: "NORMAL",
  5012. color: "COLOR",
  5013. uv: "TEX_COORD"
  5014. }, this.defaultAttributeTypes = {
  5015. position: "Float32Array",
  5016. normal: "Float32Array",
  5017. color: "Float32Array",
  5018. uv: "Float32Array"
  5019. };
  5020. }
  5021. setDecoderPath(i) {
  5022. return this.decoderPath = i, this;
  5023. }
  5024. setDecoderConfig(i) {
  5025. return this.decoderConfig = i, this;
  5026. }
  5027. setWorkerLimit(i) {
  5028. return this.workerLimit = i, this;
  5029. }
  5030. load(i, r, s, a) {
  5031. const c = new FileLoader(this.manager);
  5032. c.setPath(this.path), c.setResponseType("arraybuffer"), c.setRequestHeader(this.requestHeader), c.setWithCredentials(this.withCredentials), c.load(i, (u) => {
  5033. const h2 = {
  5034. attributeIDs: this.defaultAttributeIDs,
  5035. attributeTypes: this.defaultAttributeTypes,
  5036. useUniqueIDs: false
  5037. };
  5038. this.decodeGeometry(u, h2).then(r).catch(a);
  5039. }, s, a);
  5040. }
  5041. /** @deprecated Kept for backward-compatibility with previous DRACOLoader versions. */
  5042. decodeDracoFile(i, r, s, a) {
  5043. const c = {
  5044. attributeIDs: s || this.defaultAttributeIDs,
  5045. attributeTypes: a || this.defaultAttributeTypes,
  5046. useUniqueIDs: !!s
  5047. };
  5048. this.decodeGeometry(i, c).then(r);
  5049. }
  5050. decodeGeometry(i, r) {
  5051. for (const m in r.attributeTypes) {
  5052. const g = r.attributeTypes[m];
  5053. g.BYTES_PER_ELEMENT !== void 0 && (r.attributeTypes[m] = g.name);
  5054. }
  5055. const s = JSON.stringify(r);
  5056. if (to.has(i)) {
  5057. const m = to.get(i);
  5058. if (m.key === s)
  5059. return m.promise;
  5060. if (i.byteLength === 0)
  5061. throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.");
  5062. }
  5063. let a;
  5064. const c = this.workerNextTaskID++, u = i.byteLength, h2 = this._getWorker(c, u).then((m) => (a = m, new Promise((g, w) => {
  5065. a._callbacks[c] = {
  5066. resolve: g,
  5067. reject: w
  5068. }, a.postMessage({
  5069. type: "decode",
  5070. id: c,
  5071. taskConfig: r,
  5072. buffer: i
  5073. }, [i]);
  5074. }))).then((m) => this._createGeometry(m.geometry));
  5075. return h2.catch(() => true).then(() => {
  5076. a && c && this._releaseTask(a, c);
  5077. }), to.set(i, {
  5078. key: s,
  5079. promise: h2
  5080. }), h2;
  5081. }
  5082. _createGeometry(i) {
  5083. const r = new BufferGeometry();
  5084. i.index && r.setIndex(new BufferAttribute(i.index.array, 1));
  5085. for (let s = 0; s < i.attributes.length; s++) {
  5086. const a = i.attributes[s], c = a.name, u = a.array, h2 = a.itemSize;
  5087. r.setAttribute(c, new BufferAttribute(u, h2));
  5088. }
  5089. return r;
  5090. }
  5091. _loadLibrary(i, r) {
  5092. const s = new FileLoader(this.manager);
  5093. return s.setPath(this.decoderPath), s.setResponseType(r), s.setWithCredentials(this.withCredentials), new Promise((a, c) => {
  5094. s.load(i, a, void 0, c);
  5095. });
  5096. }
  5097. preload() {
  5098. return this._initDecoder(), this;
  5099. }
  5100. _initDecoder() {
  5101. if (this.decoderPending)
  5102. return this.decoderPending;
  5103. const i = typeof WebAssembly != "object" || this.decoderConfig.type === "js", r = [];
  5104. return i ? r.push(this._loadLibrary("draco_decoder.js", "text")) : (r.push(this._loadLibrary("draco_wasm_wrapper.js", "text")), r.push(this._loadLibrary("draco_decoder.wasm", "arraybuffer"))), this.decoderPending = Promise.all(r).then((s) => {
  5105. const a = s[0];
  5106. i || (this.decoderConfig.wasmBinary = s[1]);
  5107. const c = lh.toString(), u = ["/* draco decoder */", a, "", "/* worker */", c.substring(c.indexOf("{") + 1, c.lastIndexOf("}"))].join(`
  5108. `);
  5109. this.workerSourceURL = URL.createObjectURL(new Blob([u]));
  5110. }), this.decoderPending;
  5111. }
  5112. _getWorker(i, r) {
  5113. return this._initDecoder().then(() => {
  5114. if (this.workerPool.length < this.workerLimit) {
  5115. const a = new Worker(this.workerSourceURL);
  5116. a._callbacks = {}, a._taskCosts = {}, a._taskLoad = 0, a.postMessage({
  5117. type: "init",
  5118. decoderConfig: this.decoderConfig
  5119. }), a.onmessage = function(c) {
  5120. const u = c.data;
  5121. switch (u.type) {
  5122. case "decode":
  5123. a._callbacks[u.id].resolve(u);
  5124. break;
  5125. case "error":
  5126. a._callbacks[u.id].reject(u);
  5127. break;
  5128. default:
  5129. console.error('THREE.DRACOLoader: Unexpected message, "' + u.type + '"');
  5130. }
  5131. }, this.workerPool.push(a);
  5132. } else
  5133. this.workerPool.sort(function(a, c) {
  5134. return a._taskLoad > c._taskLoad ? -1 : 1;
  5135. });
  5136. const s = this.workerPool[this.workerPool.length - 1];
  5137. return s._taskCosts[i] = r, s._taskLoad += r, s;
  5138. });
  5139. }
  5140. _releaseTask(i, r) {
  5141. i._taskLoad -= i._taskCosts[r], delete i._callbacks[r], delete i._taskCosts[r];
  5142. }
  5143. debug() {
  5144. console.log("Task load: ", this.workerPool.map((i) => i._taskLoad));
  5145. }
  5146. dispose() {
  5147. for (let i = 0; i < this.workerPool.length; ++i)
  5148. this.workerPool[i].terminate();
  5149. return this.workerPool.length = 0, this;
  5150. }
  5151. };
  5152. function lh() {
  5153. let b2, i;
  5154. onmessage = function(u) {
  5155. const h2 = u.data;
  5156. switch (h2.type) {
  5157. case "init":
  5158. b2 = h2.decoderConfig, i = new Promise(function(w) {
  5159. b2.onModuleLoaded = function(_) {
  5160. w({
  5161. draco: _
  5162. });
  5163. }, DracoDecoderModule(b2);
  5164. });
  5165. break;
  5166. case "decode":
  5167. const m = h2.buffer, g = h2.taskConfig;
  5168. i.then((w) => {
  5169. const _ = w.draco, y2 = new _.Decoder(), C = new _.DecoderBuffer();
  5170. C.Init(new Int8Array(m), m.byteLength);
  5171. try {
  5172. const I2 = r(_, y2, C, g), S = I2.attributes.map((R) => R.array.buffer);
  5173. I2.index && S.push(I2.index.array.buffer), self.postMessage({
  5174. type: "decode",
  5175. id: h2.id,
  5176. geometry: I2
  5177. }, S);
  5178. } catch (I2) {
  5179. console.error(I2), self.postMessage({
  5180. type: "error",
  5181. id: h2.id,
  5182. error: I2.message
  5183. });
  5184. } finally {
  5185. _.destroy(C), _.destroy(y2);
  5186. }
  5187. });
  5188. break;
  5189. }
  5190. };
  5191. function r(u, h2, m, g) {
  5192. const w = g.attributeIDs, _ = g.attributeTypes;
  5193. let y2, C;
  5194. const I2 = h2.GetEncodedGeometryType(m);
  5195. if (I2 === u.TRIANGULAR_MESH)
  5196. y2 = new u.Mesh(), C = h2.DecodeBufferToMesh(m, y2);
  5197. else if (I2 === u.POINT_CLOUD)
  5198. y2 = new u.PointCloud(), C = h2.DecodeBufferToPointCloud(m, y2);
  5199. else
  5200. throw new Error("THREE.DRACOLoader: Unexpected geometry type.");
  5201. if (!C.ok() || y2.ptr === 0)
  5202. throw new Error("THREE.DRACOLoader: Decoding failed: " + C.error_msg());
  5203. const S = {
  5204. index: null,
  5205. attributes: []
  5206. };
  5207. for (const R in w) {
  5208. const j = self[_[R]];
  5209. let F2, V;
  5210. if (g.useUniqueIDs)
  5211. V = w[R], F2 = h2.GetAttributeByUniqueId(y2, V);
  5212. else {
  5213. if (V = h2.GetAttributeId(y2, u[w[R]]), V === -1)
  5214. continue;
  5215. F2 = h2.GetAttribute(y2, V);
  5216. }
  5217. S.attributes.push(a(u, h2, y2, R, j, F2));
  5218. }
  5219. return I2 === u.TRIANGULAR_MESH && (S.index = s(u, h2, y2)), u.destroy(y2), S;
  5220. }
  5221. function s(u, h2, m) {
  5222. const w = m.num_faces() * 3, _ = w * 4, y2 = u._malloc(_);
  5223. h2.GetTrianglesUInt32Array(m, _, y2);
  5224. const C = new Uint32Array(u.HEAPF32.buffer, y2, w).slice();
  5225. return u._free(y2), {
  5226. array: C,
  5227. itemSize: 1
  5228. };
  5229. }
  5230. function a(u, h2, m, g, w, _) {
  5231. const y2 = _.num_components(), I2 = m.num_points() * y2, S = I2 * w.BYTES_PER_ELEMENT, R = c(u, w), j = u._malloc(S);
  5232. h2.GetAttributeDataArrayForAllPoints(m, _, R, S, j);
  5233. const F2 = new w(u.HEAPF32.buffer, j, I2).slice();
  5234. return u._free(j), {
  5235. name: g,
  5236. array: F2,
  5237. itemSize: y2
  5238. };
  5239. }
  5240. function c(u, h2) {
  5241. switch (h2) {
  5242. case Float32Array:
  5243. return u.DT_FLOAT32;
  5244. case Int8Array:
  5245. return u.DT_INT8;
  5246. case Int16Array:
  5247. return u.DT_INT16;
  5248. case Int32Array:
  5249. return u.DT_INT32;
  5250. case Uint8Array:
  5251. return u.DT_UINT8;
  5252. case Uint16Array:
  5253. return u.DT_UINT16;
  5254. case Uint32Array:
  5255. return u.DT_UINT32;
  5256. }
  5257. }
  5258. }
  5259. function Nn() {
  5260. const b2 = inject("extend") || (() => {
  5261. console.warn("No extend function provided");
  5262. }), { state: i, setState: r } = inject("useTres", $());
  5263. return {
  5264. state: i,
  5265. setState: r,
  5266. extend: b2
  5267. };
  5268. }
  5269. var Nh = defineComponent({
  5270. __name: "OrbitControls",
  5271. props: {
  5272. makeDefault: { type: Boolean, default: false },
  5273. camera: null,
  5274. domElement: null,
  5275. target: null,
  5276. enableDamping: { type: Boolean }
  5277. },
  5278. setup(b2) {
  5279. const i = b2, { state: r, setState: s, extend: a } = Nn(), c = ref(null);
  5280. return a({ OrbitControls: ru }), watch(c, (u) => {
  5281. u && i.makeDefault ? s("controls", u) : s("controls", null);
  5282. }), (u, h2) => {
  5283. var g;
  5284. const m = resolveComponent("TresOrbitControls");
  5285. return unref(r).camera && unref(r).renderer ? (openBlock(), createBlock(m, {
  5286. key: 0,
  5287. ref_key: "controls",
  5288. ref: c,
  5289. args: [unref(unref(r).camera), (g = unref(r).renderer) == null ? void 0 : g.domElement],
  5290. "enabling-dampling": b2.enableDamping
  5291. }, null, 8, ["args", "enabling-dampling"])) : createCommentVNode("", true);
  5292. };
  5293. }
  5294. });
  5295. function ch(b2, i) {
  5296. const r = {};
  5297. for (const s of i)
  5298. Object.prototype.hasOwnProperty.call(b2, s) && (r[s] = b2[s]);
  5299. return r;
  5300. }
  5301. function ph(b2, i) {
  5302. const r = `set${i[0].toUpperCase()}${i.slice(1)}`;
  5303. return b2[r] !== void 0;
  5304. }
  5305. var Fh = defineComponent({
  5306. __name: "TransformControls",
  5307. props: {
  5308. object: null,
  5309. mode: null,
  5310. enabled: { type: Boolean, default: true },
  5311. axis: null,
  5312. translationSnap: null,
  5313. rotationSnap: null,
  5314. scaleSnap: null,
  5315. space: null,
  5316. size: null,
  5317. showX: { type: Boolean },
  5318. showY: { type: Boolean },
  5319. showZ: { type: Boolean }
  5320. },
  5321. emits: ["dragging", "change", "mouseDown", "mouseUp", "objectChange"],
  5322. setup(b2, { emit: i }) {
  5323. const r = b2;
  5324. let s = shallowRef();
  5325. const { state: a } = Nn(), c = computed(
  5326. () => ch(r, [
  5327. "enabled",
  5328. "axis",
  5329. "mode",
  5330. "translationSnap",
  5331. "rotationSnap",
  5332. "scaleSnap",
  5333. "space",
  5334. "size",
  5335. "showX",
  5336. "showY",
  5337. "showZ"
  5338. ])
  5339. ), u = () => i("change", s.value), h2 = () => i("mouseDown", s.value), m = () => i("mouseUp", s.value), g = () => i("objectChange", s.value), w = (y2) => {
  5340. a.controls && (a.controls.enabled = !y2.value), i("dragging", y2.value);
  5341. };
  5342. function _(y2) {
  5343. y2.addEventListener("dragging-changed", w), y2.addEventListener("change", u), y2.addEventListener("mouseDown", h2), y2.addEventListener("mouseUp", m), y2.addEventListener("objectChange", g);
  5344. }
  5345. return watch(
  5346. () => r.object,
  5347. () => {
  5348. a.camera && a.renderer && a.scene && r.object && (s.value = new nu(a.camera, unref(a.renderer).domElement), s.value.attach(unref(r.object)), a.scene.add(unref(s)), _(unref(s)));
  5349. },
  5350. {
  5351. deep: true
  5352. }
  5353. ), watch(
  5354. [c, s],
  5355. // TODO: properly type this
  5356. ([y2, C]) => {
  5357. if (y2 && C)
  5358. for (const I2 in y2)
  5359. if (!ph(C, I2))
  5360. C[I2] = y2[I2];
  5361. else {
  5362. const S = `set${I2[0].toUpperCase()}${I2.slice(1)}`;
  5363. typeof C[S] == "function" && y2[I2] !== void 0 && C[S](y2[I2]);
  5364. }
  5365. },
  5366. {
  5367. immediate: true
  5368. }
  5369. ), onUnmounted(() => {
  5370. s.value && (s.value.removeEventListener("dragging-changed", w), s.value.removeEventListener("change", u), s.value.removeEventListener("mouseDown", h2), s.value.removeEventListener("mouseUp", m), s.value.removeEventListener("objectChange", g));
  5371. }), (y2, C) => renderSlot(y2.$slots, "default");
  5372. }
  5373. });
  5374. var wa;
  5375. var nl = typeof window < "u";
  5376. var uh = (b2) => typeof b2 == "string";
  5377. var hh = () => {
  5378. };
  5379. nl && ((wa = window == null ? void 0 : window.navigator) != null && wa.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
  5380. function il(b2) {
  5381. return typeof b2 == "function" ? b2() : unref(b2);
  5382. }
  5383. function dh(b2) {
  5384. return b2;
  5385. }
  5386. function mh(b2) {
  5387. return getCurrentScope() ? (onScopeDispose(b2), true) : false;
  5388. }
  5389. function fh(b2, i = true) {
  5390. getCurrentInstance() ? onMounted(b2) : i ? b2() : nextTick(b2);
  5391. }
  5392. function vh(b2) {
  5393. var i;
  5394. const r = il(b2);
  5395. return (i = r == null ? void 0 : r.$el) != null ? i : r;
  5396. }
  5397. var yo = nl ? window : void 0;
  5398. function Rn(...b2) {
  5399. let i, r, s, a;
  5400. if (uh(b2[0]) || Array.isArray(b2[0]) ? ([r, s, a] = b2, i = yo) : [i, r, s, a] = b2, !i)
  5401. return hh;
  5402. Array.isArray(r) || (r = [r]), Array.isArray(s) || (s = [s]);
  5403. const c = [], u = () => {
  5404. c.forEach((w) => w()), c.length = 0;
  5405. }, h2 = (w, _, y2, C) => (w.addEventListener(_, y2, C), () => w.removeEventListener(_, y2, C)), m = watch(() => [vh(i), il(a)], ([w, _]) => {
  5406. u(), w && c.push(...r.flatMap((y2) => s.map((C) => h2(w, y2, C, _))));
  5407. }, { immediate: true, flush: "post" }), g = () => {
  5408. m(), u();
  5409. };
  5410. return mh(g), g;
  5411. }
  5412. var mo = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
  5413. var fo = "__vueuse_ssr_handlers__";
  5414. mo[fo] = mo[fo] || {};
  5415. mo[fo];
  5416. function bh(b2 = {}) {
  5417. const {
  5418. type: i = "page",
  5419. touch: r = true,
  5420. resetOnTouchEnds: s = false,
  5421. initialValue: a = { x: 0, y: 0 },
  5422. window: c = yo,
  5423. eventFilter: u
  5424. } = b2, h2 = ref(a.x), m = ref(a.y), g = ref(null), w = (S) => {
  5425. i === "page" ? (h2.value = S.pageX, m.value = S.pageY) : i === "client" ? (h2.value = S.clientX, m.value = S.clientY) : i === "movement" && (h2.value = S.movementX, m.value = S.movementY), g.value = "mouse";
  5426. }, _ = () => {
  5427. h2.value = a.x, m.value = a.y;
  5428. }, y2 = (S) => {
  5429. if (S.touches.length > 0) {
  5430. const R = S.touches[0];
  5431. i === "page" ? (h2.value = R.pageX, m.value = R.pageY) : i === "client" && (h2.value = R.clientX, m.value = R.clientY), g.value = "touch";
  5432. }
  5433. }, C = (S) => u === void 0 ? w(S) : u(() => w(S), {}), I2 = (S) => u === void 0 ? y2(S) : u(() => y2(S), {});
  5434. return c && (Rn(c, "mousemove", C, { passive: true }), Rn(c, "dragover", C, { passive: true }), r && i !== "movement" && (Rn(c, "touchstart", I2, { passive: true }), Rn(c, "touchmove", I2, { passive: true }), s && Rn(c, "touchend", _, { passive: true }))), {
  5435. x: h2,
  5436. y: m,
  5437. sourceType: g
  5438. };
  5439. }
  5440. var ya;
  5441. (function(b2) {
  5442. b2.UP = "UP", b2.RIGHT = "RIGHT", b2.DOWN = "DOWN", b2.LEFT = "LEFT", b2.NONE = "NONE";
  5443. })(ya || (ya = {}));
  5444. var gh = Object.defineProperty;
  5445. var xa = Object.getOwnPropertySymbols;
  5446. var _h = Object.prototype.hasOwnProperty;
  5447. var wh = Object.prototype.propertyIsEnumerable;
  5448. var Ea = (b2, i, r) => i in b2 ? gh(b2, i, { enumerable: true, configurable: true, writable: true, value: r }) : b2[i] = r;
  5449. var yh = (b2, i) => {
  5450. for (var r in i || (i = {}))
  5451. _h.call(i, r) && Ea(b2, r, i[r]);
  5452. if (xa)
  5453. for (var r of xa(i))
  5454. wh.call(i, r) && Ea(b2, r, i[r]);
  5455. return b2;
  5456. };
  5457. var xh = {
  5458. easeInSine: [0.12, 0, 0.39, 0],
  5459. easeOutSine: [0.61, 1, 0.88, 1],
  5460. easeInOutSine: [0.37, 0, 0.63, 1],
  5461. easeInQuad: [0.11, 0, 0.5, 0],
  5462. easeOutQuad: [0.5, 1, 0.89, 1],
  5463. easeInOutQuad: [0.45, 0, 0.55, 1],
  5464. easeInCubic: [0.32, 0, 0.67, 0],
  5465. easeOutCubic: [0.33, 1, 0.68, 1],
  5466. easeInOutCubic: [0.65, 0, 0.35, 1],
  5467. easeInQuart: [0.5, 0, 0.75, 0],
  5468. easeOutQuart: [0.25, 1, 0.5, 1],
  5469. easeInOutQuart: [0.76, 0, 0.24, 1],
  5470. easeInQuint: [0.64, 0, 0.78, 0],
  5471. easeOutQuint: [0.22, 1, 0.36, 1],
  5472. easeInOutQuint: [0.83, 0, 0.17, 1],
  5473. easeInExpo: [0.7, 0, 0.84, 0],
  5474. easeOutExpo: [0.16, 1, 0.3, 1],
  5475. easeInOutExpo: [0.87, 0, 0.13, 1],
  5476. easeInCirc: [0.55, 0, 1, 0.45],
  5477. easeOutCirc: [0, 0.55, 0.45, 1],
  5478. easeInOutCirc: [0.85, 0, 0.15, 1],
  5479. easeInBack: [0.36, 0, 0.66, -0.56],
  5480. easeOutBack: [0.34, 1.56, 0.64, 1],
  5481. easeInOutBack: [0.68, -0.6, 0.32, 1.6]
  5482. };
  5483. yh({
  5484. linear: dh
  5485. }, xh);
  5486. function Eh(b2 = {}) {
  5487. const {
  5488. window: i = yo,
  5489. initialWidth: r = 1 / 0,
  5490. initialHeight: s = 1 / 0,
  5491. listenOrientation: a = true,
  5492. includeScrollbar: c = true
  5493. } = b2, u = ref(r), h2 = ref(s), m = () => {
  5494. i && (c ? (u.value = i.innerWidth, h2.value = i.innerHeight) : (u.value = i.document.documentElement.clientWidth, h2.value = i.document.documentElement.clientHeight));
  5495. };
  5496. return m(), fh(m), Rn("resize", m, { passive: true }), a && Rn("orientationchange", m, { passive: true }), { width: u, height: h2 };
  5497. }
  5498. var Ca = "[TresJS - Cientos ▲ ■ ♥] ";
  5499. function Ch() {
  5500. function b2(s, a) {
  5501. console.error(`${Ca} ${s}`, a || "");
  5502. }
  5503. function i(s) {
  5504. console.warn(`${Ca} ${s}`);
  5505. }
  5506. function r(s, a) {
  5507. }
  5508. return {
  5509. logError: b2,
  5510. logWarning: i,
  5511. logMessage: r
  5512. };
  5513. }
  5514. function Ph(b2 = false, i = 5, r) {
  5515. const { x: s, y: a } = bh(), { logWarning: c } = Ch(), { width: u, height: h2 } = Eh(), m = computed(() => (s.value / u.value - 0.5) * i), g = computed(() => -(a.value / h2.value - 0.5) * i);
  5516. if (r) {
  5517. const { x: w, y: _ } = r.position;
  5518. watchEffect(() => {
  5519. b2 || r && (r.position.x = w + m.value, r.position.y = _ + g.value);
  5520. });
  5521. } else
  5522. c("Scene must contain a Camera component to use this composable");
  5523. }
  5524. var Bh = defineComponent({
  5525. name: "PamCameraMouse",
  5526. props: {
  5527. disabled: {
  5528. type: Boolean,
  5529. required: false,
  5530. default: false
  5531. },
  5532. factor: {
  5533. type: Number,
  5534. required: false,
  5535. default: 5
  5536. }
  5537. },
  5538. setup(b2) {
  5539. const { state: i } = Nn(), r = i == null ? void 0 : i.camera;
  5540. return Ph(b2.disabled, b2.factor, r), () => {
  5541. };
  5542. }
  5543. });
  5544. var zs = {};
  5545. var Th = {
  5546. get exports() {
  5547. return zs;
  5548. },
  5549. set exports(b2) {
  5550. zs = b2;
  5551. }
  5552. };
  5553. (function(b2, i) {
  5554. (function(r, s) {
  5555. s(i);
  5556. })(tl, function(r) {
  5557. class s {
  5558. /**
  5559. * @hidden
  5560. */
  5561. constructor(e) {
  5562. const [t, l] = e.split("-"), v = t.split(".");
  5563. this.major = parseInt(v[0], 10), this.minor = parseInt(v[1], 10), this.patch = parseInt(v[2], 10), this.prerelease = l ?? null;
  5564. }
  5565. toString() {
  5566. const e = [this.major, this.minor, this.patch].join(".");
  5567. return this.prerelease !== null ? [e, this.prerelease].join("-") : e;
  5568. }
  5569. }
  5570. class a {
  5571. constructor(e) {
  5572. this.controller_ = e;
  5573. }
  5574. get element() {
  5575. return this.controller_.view.element;
  5576. }
  5577. get disabled() {
  5578. return this.controller_.viewProps.get("disabled");
  5579. }
  5580. set disabled(e) {
  5581. this.controller_.viewProps.set("disabled", e);
  5582. }
  5583. get hidden() {
  5584. return this.controller_.viewProps.get("hidden");
  5585. }
  5586. set hidden(e) {
  5587. this.controller_.viewProps.set("hidden", e);
  5588. }
  5589. dispose() {
  5590. this.controller_.viewProps.set("disposed", true);
  5591. }
  5592. }
  5593. class c {
  5594. constructor(e) {
  5595. this.target = e;
  5596. }
  5597. }
  5598. class u extends c {
  5599. constructor(e, t, l, v) {
  5600. super(e), this.value = t, this.presetKey = l, this.last = v ?? true;
  5601. }
  5602. }
  5603. class h2 extends c {
  5604. constructor(e, t, l) {
  5605. super(e), this.value = t, this.presetKey = l;
  5606. }
  5607. }
  5608. class m extends c {
  5609. constructor(e, t) {
  5610. super(e), this.expanded = t;
  5611. }
  5612. }
  5613. class g extends c {
  5614. constructor(e, t) {
  5615. super(e), this.index = t;
  5616. }
  5617. }
  5618. function w(n) {
  5619. return n;
  5620. }
  5621. function _(n) {
  5622. return n == null;
  5623. }
  5624. function y2(n, e) {
  5625. if (n.length !== e.length)
  5626. return false;
  5627. for (let t = 0; t < n.length; t++)
  5628. if (n[t] !== e[t])
  5629. return false;
  5630. return true;
  5631. }
  5632. function C(n, e) {
  5633. let t = n;
  5634. do {
  5635. const l = Object.getOwnPropertyDescriptor(t, e);
  5636. if (l && (l.set !== void 0 || l.writable === true))
  5637. return true;
  5638. t = Object.getPrototypeOf(t);
  5639. } while (t !== null);
  5640. return false;
  5641. }
  5642. const I2 = {
  5643. alreadydisposed: () => "View has been already disposed",
  5644. invalidparams: (n) => `Invalid parameters for '${n.name}'`,
  5645. nomatchingcontroller: (n) => `No matching controller for '${n.key}'`,
  5646. nomatchingview: (n) => `No matching view for '${JSON.stringify(n.params)}'`,
  5647. notbindable: () => "Value is not bindable",
  5648. propertynotfound: (n) => `Property '${n.name}' not found`,
  5649. shouldneverhappen: () => "This error should never happen"
  5650. };
  5651. class S {
  5652. constructor(e) {
  5653. var t;
  5654. this.message = (t = I2[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;
  5655. }
  5656. static alreadyDisposed() {
  5657. return new S({ type: "alreadydisposed" });
  5658. }
  5659. static notBindable() {
  5660. return new S({
  5661. type: "notbindable"
  5662. });
  5663. }
  5664. static propertyNotFound(e) {
  5665. return new S({
  5666. type: "propertynotfound",
  5667. context: {
  5668. name: e
  5669. }
  5670. });
  5671. }
  5672. static shouldNeverHappen() {
  5673. return new S({ type: "shouldneverhappen" });
  5674. }
  5675. }
  5676. class R {
  5677. constructor(e, t, l) {
  5678. this.obj_ = e, this.key_ = t, this.presetKey_ = l ?? t;
  5679. }
  5680. static isBindable(e) {
  5681. return !(e === null || typeof e != "object");
  5682. }
  5683. get key() {
  5684. return this.key_;
  5685. }
  5686. get presetKey() {
  5687. return this.presetKey_;
  5688. }
  5689. read() {
  5690. return this.obj_[this.key_];
  5691. }
  5692. write(e) {
  5693. this.obj_[this.key_] = e;
  5694. }
  5695. writeProperty(e, t) {
  5696. const l = this.read();
  5697. if (!R.isBindable(l))
  5698. throw S.notBindable();
  5699. if (!(e in l))
  5700. throw S.propertyNotFound(e);
  5701. l[e] = t;
  5702. }
  5703. }
  5704. class j extends a {
  5705. get label() {
  5706. return this.controller_.props.get("label");
  5707. }
  5708. set label(e) {
  5709. this.controller_.props.set("label", e);
  5710. }
  5711. get title() {
  5712. var e;
  5713. return (e = this.controller_.valueController.props.get("title")) !== null && e !== void 0 ? e : "";
  5714. }
  5715. set title(e) {
  5716. this.controller_.valueController.props.set("title", e);
  5717. }
  5718. on(e, t) {
  5719. const l = t.bind(this);
  5720. return this.controller_.valueController.emitter.on(e, () => {
  5721. l(new c(this));
  5722. }), this;
  5723. }
  5724. }
  5725. class F2 {
  5726. constructor() {
  5727. this.observers_ = {};
  5728. }
  5729. on(e, t) {
  5730. let l = this.observers_[e];
  5731. return l || (l = this.observers_[e] = []), l.push({
  5732. handler: t
  5733. }), this;
  5734. }
  5735. off(e, t) {
  5736. const l = this.observers_[e];
  5737. return l && (this.observers_[e] = l.filter((v) => v.handler !== t)), this;
  5738. }
  5739. emit(e, t) {
  5740. const l = this.observers_[e];
  5741. l && l.forEach((v) => {
  5742. v.handler(t);
  5743. });
  5744. }
  5745. }
  5746. const V = "tp";
  5747. function D2(n) {
  5748. return (t, l) => [
  5749. V,
  5750. "-",
  5751. n,
  5752. "v",
  5753. t ? `_${t}` : "",
  5754. l ? `-${l}` : ""
  5755. ].join("");
  5756. }
  5757. function Y2(n, e) {
  5758. return (t) => e(n(t));
  5759. }
  5760. function G(n) {
  5761. return n.rawValue;
  5762. }
  5763. function N2(n, e) {
  5764. n.emitter.on("change", Y2(G, e)), e(n.rawValue);
  5765. }
  5766. function O(n, e, t) {
  5767. N2(n.value(e), t);
  5768. }
  5769. function H(n, e, t) {
  5770. t ? n.classList.add(e) : n.classList.remove(e);
  5771. }
  5772. function K(n, e) {
  5773. return (t) => {
  5774. H(n, e, t);
  5775. };
  5776. }
  5777. function q(n, e) {
  5778. N2(n, (t) => {
  5779. e.textContent = t ?? "";
  5780. });
  5781. }
  5782. const he = D2("btn");
  5783. class _e {
  5784. constructor(e, t) {
  5785. this.element = e.createElement("div"), this.element.classList.add(he()), t.viewProps.bindClassModifiers(this.element);
  5786. const l = e.createElement("button");
  5787. l.classList.add(he("b")), t.viewProps.bindDisabled(l), this.element.appendChild(l), this.buttonElement = l;
  5788. const v = e.createElement("div");
  5789. v.classList.add(he("t")), q(t.props.value("title"), v), this.buttonElement.appendChild(v);
  5790. }
  5791. }
  5792. class pe {
  5793. constructor(e, t) {
  5794. this.emitter = new F2(), this.onClick_ = this.onClick_.bind(this), this.props = t.props, this.viewProps = t.viewProps, this.view = new _e(e, {
  5795. props: this.props,
  5796. viewProps: this.viewProps
  5797. }), this.view.buttonElement.addEventListener("click", this.onClick_);
  5798. }
  5799. onClick_() {
  5800. this.emitter.emit("click", {
  5801. sender: this
  5802. });
  5803. }
  5804. }
  5805. class fe2 {
  5806. constructor(e, t) {
  5807. var l;
  5808. this.constraint_ = t == null ? void 0 : t.constraint, this.equals_ = (l = t == null ? void 0 : t.equals) !== null && l !== void 0 ? l : (v, E) => v === E, this.emitter = new F2(), this.rawValue_ = e;
  5809. }
  5810. get constraint() {
  5811. return this.constraint_;
  5812. }
  5813. get rawValue() {
  5814. return this.rawValue_;
  5815. }
  5816. set rawValue(e) {
  5817. this.setRawValue(e, {
  5818. forceEmit: false,
  5819. last: true
  5820. });
  5821. }
  5822. setRawValue(e, t) {
  5823. const l = t ?? {
  5824. forceEmit: false,
  5825. last: true
  5826. }, v = this.constraint_ ? this.constraint_.constrain(e) : e, E = this.rawValue_;
  5827. this.equals_(E, v) && !l.forceEmit || (this.emitter.emit("beforechange", {
  5828. sender: this
  5829. }), this.rawValue_ = v, this.emitter.emit("change", {
  5830. options: l,
  5831. previousRawValue: E,
  5832. rawValue: v,
  5833. sender: this
  5834. }));
  5835. }
  5836. }
  5837. class de2 {
  5838. constructor(e) {
  5839. this.emitter = new F2(), this.value_ = e;
  5840. }
  5841. get rawValue() {
  5842. return this.value_;
  5843. }
  5844. set rawValue(e) {
  5845. this.setRawValue(e, {
  5846. forceEmit: false,
  5847. last: true
  5848. });
  5849. }
  5850. setRawValue(e, t) {
  5851. const l = t ?? {
  5852. forceEmit: false,
  5853. last: true
  5854. }, v = this.value_;
  5855. v === e && !l.forceEmit || (this.emitter.emit("beforechange", {
  5856. sender: this
  5857. }), this.value_ = e, this.emitter.emit("change", {
  5858. options: l,
  5859. previousRawValue: v,
  5860. rawValue: this.value_,
  5861. sender: this
  5862. }));
  5863. }
  5864. }
  5865. function te2(n, e) {
  5866. const t = e == null ? void 0 : e.constraint, l = e == null ? void 0 : e.equals;
  5867. return !t && !l ? new de2(n) : new fe2(n, e);
  5868. }
  5869. class X2 {
  5870. constructor(e) {
  5871. this.emitter = new F2(), this.valMap_ = e;
  5872. for (const t in this.valMap_)
  5873. this.valMap_[t].emitter.on("change", () => {
  5874. this.emitter.emit("change", {
  5875. key: t,
  5876. sender: this
  5877. });
  5878. });
  5879. }
  5880. static createCore(e) {
  5881. return Object.keys(e).reduce((l, v) => Object.assign(l, {
  5882. [v]: te2(e[v])
  5883. }), {});
  5884. }
  5885. static fromObject(e) {
  5886. const t = this.createCore(e);
  5887. return new X2(t);
  5888. }
  5889. get(e) {
  5890. return this.valMap_[e].rawValue;
  5891. }
  5892. set(e, t) {
  5893. this.valMap_[e].rawValue = t;
  5894. }
  5895. value(e) {
  5896. return this.valMap_[e];
  5897. }
  5898. }
  5899. function ke(n, e) {
  5900. const l = Object.keys(e).reduce((v, E) => {
  5901. if (v === void 0)
  5902. return;
  5903. const k2 = e[E], B2 = k2(n[E]);
  5904. return B2.succeeded ? Object.assign(Object.assign({}, v), { [E]: B2.value }) : void 0;
  5905. }, {});
  5906. return l;
  5907. }
  5908. function ve(n, e) {
  5909. return n.reduce((t, l) => {
  5910. if (t === void 0)
  5911. return;
  5912. const v = e(l);
  5913. if (!(!v.succeeded || v.value === void 0))
  5914. return [...t, v.value];
  5915. }, []);
  5916. }
  5917. function le(n) {
  5918. return n === null ? false : typeof n == "object";
  5919. }
  5920. function ie(n) {
  5921. return (e) => (t) => {
  5922. if (!e && t === void 0)
  5923. return {
  5924. succeeded: false,
  5925. value: void 0
  5926. };
  5927. if (e && t === void 0)
  5928. return {
  5929. succeeded: true,
  5930. value: void 0
  5931. };
  5932. const l = n(t);
  5933. return l !== void 0 ? {
  5934. succeeded: true,
  5935. value: l
  5936. } : {
  5937. succeeded: false,
  5938. value: void 0
  5939. };
  5940. };
  5941. }
  5942. function ge(n) {
  5943. return {
  5944. custom: (e) => ie(e)(n),
  5945. boolean: ie((e) => typeof e == "boolean" ? e : void 0)(n),
  5946. number: ie((e) => typeof e == "number" ? e : void 0)(n),
  5947. string: ie((e) => typeof e == "string" ? e : void 0)(n),
  5948. function: ie((e) => typeof e == "function" ? e : void 0)(n),
  5949. constant: (e) => ie((t) => t === e ? e : void 0)(n),
  5950. raw: ie((e) => e)(n),
  5951. object: (e) => ie((t) => {
  5952. if (le(t))
  5953. return ke(t, e);
  5954. })(n),
  5955. array: (e) => ie((t) => {
  5956. if (Array.isArray(t))
  5957. return ve(t, e);
  5958. })(n)
  5959. };
  5960. }
  5961. const M = {
  5962. optional: ge(true),
  5963. required: ge(false)
  5964. };
  5965. function ce(n, e) {
  5966. const t = M.required.object(e)(n);
  5967. return t.succeeded ? t.value : void 0;
  5968. }
  5969. function Oe(n) {
  5970. console.warn([
  5971. `Missing '${n.key}' of ${n.target} in ${n.place}.`,
  5972. "Please rebuild plugins with the latest core package."
  5973. ].join(" "));
  5974. }
  5975. function je(n) {
  5976. return n && n.parentElement && n.parentElement.removeChild(n), null;
  5977. }
  5978. class ye {
  5979. constructor(e) {
  5980. this.value_ = e;
  5981. }
  5982. static create(e) {
  5983. return [
  5984. new ye(e),
  5985. (t, l) => {
  5986. e.setRawValue(t, l);
  5987. }
  5988. ];
  5989. }
  5990. get emitter() {
  5991. return this.value_.emitter;
  5992. }
  5993. get rawValue() {
  5994. return this.value_.rawValue;
  5995. }
  5996. }
  5997. const st2 = D2("");
  5998. function Fn(n, e) {
  5999. return K(n, st2(void 0, e));
  6000. }
  6001. class Qe2 extends X2 {
  6002. constructor(e) {
  6003. var t;
  6004. super(e), this.onDisabledChange_ = this.onDisabledChange_.bind(this), this.onParentChange_ = this.onParentChange_.bind(this), this.onParentGlobalDisabledChange_ = this.onParentGlobalDisabledChange_.bind(this), [this.globalDisabled_, this.setGlobalDisabled_] = ye.create(te2(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_);
  6005. }
  6006. static create(e) {
  6007. var t, l, v;
  6008. const E = e ?? {};
  6009. return new Qe2(X2.createCore({
  6010. disabled: (t = E.disabled) !== null && t !== void 0 ? t : false,
  6011. disposed: false,
  6012. hidden: (l = E.hidden) !== null && l !== void 0 ? l : false,
  6013. parent: (v = E.parent) !== null && v !== void 0 ? v : null
  6014. }));
  6015. }
  6016. get globalDisabled() {
  6017. return this.globalDisabled_;
  6018. }
  6019. bindClassModifiers(e) {
  6020. N2(this.globalDisabled_, Fn(e, "disabled")), O(this, "hidden", Fn(e, "hidden"));
  6021. }
  6022. bindDisabled(e) {
  6023. N2(this.globalDisabled_, (t) => {
  6024. e.disabled = t;
  6025. });
  6026. }
  6027. bindTabIndex(e) {
  6028. N2(this.globalDisabled_, (t) => {
  6029. e.tabIndex = t ? -1 : 0;
  6030. });
  6031. }
  6032. handleDispose(e) {
  6033. this.value("disposed").emitter.on("change", (t) => {
  6034. t && e();
  6035. });
  6036. }
  6037. getGlobalDisabled_() {
  6038. const e = this.get("parent");
  6039. return (e ? e.globalDisabled.rawValue : false) || this.get("disabled");
  6040. }
  6041. updateGlobalDisabled_() {
  6042. this.setGlobalDisabled_(this.getGlobalDisabled_());
  6043. }
  6044. onDisabledChange_() {
  6045. this.updateGlobalDisabled_();
  6046. }
  6047. onParentGlobalDisabledChange_() {
  6048. this.updateGlobalDisabled_();
  6049. }
  6050. onParentChange_(e) {
  6051. var t;
  6052. const l = e.previousRawValue;
  6053. 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_();
  6054. }
  6055. }
  6056. function Bn() {
  6057. return ["veryfirst", "first", "last", "verylast"];
  6058. }
  6059. const on = D2(""), mt2 = {
  6060. veryfirst: "vfst",
  6061. first: "fst",
  6062. last: "lst",
  6063. verylast: "vlst"
  6064. };
  6065. class At {
  6066. constructor(e) {
  6067. this.parent_ = null, this.blade = e.blade, this.view = e.view, this.viewProps = e.viewProps;
  6068. const t = this.view.element;
  6069. this.blade.value("positions").emitter.on("change", () => {
  6070. Bn().forEach((l) => {
  6071. t.classList.remove(on(void 0, mt2[l]));
  6072. }), this.blade.get("positions").forEach((l) => {
  6073. t.classList.add(on(void 0, mt2[l]));
  6074. });
  6075. }), this.viewProps.handleDispose(() => {
  6076. je(t);
  6077. });
  6078. }
  6079. get parent() {
  6080. return this.parent_;
  6081. }
  6082. set parent(e) {
  6083. if (this.parent_ = e, !("parent" in this.viewProps.valMap_)) {
  6084. Oe({
  6085. key: "parent",
  6086. target: Qe2.name,
  6087. place: "BladeController.parent"
  6088. });
  6089. return;
  6090. }
  6091. this.viewProps.set("parent", this.parent_ ? this.parent_.viewProps : null);
  6092. }
  6093. }
  6094. const He = "http://www.w3.org/2000/svg";
  6095. function rt2(n) {
  6096. n.offsetHeight;
  6097. }
  6098. function an(n, e) {
  6099. const t = n.style.transition;
  6100. n.style.transition = "none", e(), n.style.transition = t;
  6101. }
  6102. function ft2(n) {
  6103. return n.ontouchstart !== void 0;
  6104. }
  6105. function jn() {
  6106. return globalThis;
  6107. }
  6108. function ui() {
  6109. return jn().document;
  6110. }
  6111. function zn(n) {
  6112. const e = n.ownerDocument.defaultView;
  6113. return e && "document" in e ? n.getContext("2d", {
  6114. willReadFrequently: true
  6115. }) : null;
  6116. }
  6117. const Un = {
  6118. check: '<path d="M2 8l4 4l8 -8"/>',
  6119. dropdown: '<path d="M5 7h6l-3 3 z"/>',
  6120. p2dpad: '<path d="M8 4v8"/><path d="M4 8h8"/><circle cx="12" cy="12" r="1.2"/>'
  6121. };
  6122. function xt(n, e) {
  6123. const t = n.createElementNS(He, "svg");
  6124. return t.innerHTML = Un[e], t;
  6125. }
  6126. function Lt(n, e, t) {
  6127. n.insertBefore(e, n.children[t]);
  6128. }
  6129. function Gn(n) {
  6130. n.parentElement && n.parentElement.removeChild(n);
  6131. }
  6132. function ln(n) {
  6133. for (; n.children.length > 0; )
  6134. n.removeChild(n.children[0]);
  6135. }
  6136. function Hn(n) {
  6137. for (; n.childNodes.length > 0; )
  6138. n.removeChild(n.childNodes[0]);
  6139. }
  6140. function Et(n) {
  6141. return n.relatedTarget ? n.relatedTarget : "explicitOriginalTarget" in n ? n.explicitOriginalTarget : null;
  6142. }
  6143. const vt = D2("lbl");
  6144. function Rt2(n, e) {
  6145. const t = n.createDocumentFragment();
  6146. return e.split(`
  6147. `).map((v) => n.createTextNode(v)).forEach((v, E) => {
  6148. E > 0 && t.appendChild(n.createElement("br")), t.appendChild(v);
  6149. }), t;
  6150. }
  6151. class A {
  6152. constructor(e, t) {
  6153. this.element = e.createElement("div"), this.element.classList.add(vt()), t.viewProps.bindClassModifiers(this.element);
  6154. const l = e.createElement("div");
  6155. l.classList.add(vt("l")), O(t.props, "label", (E) => {
  6156. _(E) ? this.element.classList.add(vt(void 0, "nol")) : (this.element.classList.remove(vt(void 0, "nol")), Hn(l), l.appendChild(Rt2(e, E)));
  6157. }), this.element.appendChild(l), this.labelElement = l;
  6158. const v = e.createElement("div");
  6159. v.classList.add(vt("v")), this.element.appendChild(v), this.valueElement = v;
  6160. }
  6161. }
  6162. class U2 extends At {
  6163. constructor(e, t) {
  6164. const l = t.valueController.viewProps;
  6165. super(Object.assign(Object.assign({}, t), { view: new A(e, {
  6166. props: t.props,
  6167. viewProps: l
  6168. }), viewProps: l })), this.props = t.props, this.valueController = t.valueController, this.view.valueElement.appendChild(this.valueController.view.element);
  6169. }
  6170. }
  6171. const J2 = {
  6172. id: "button",
  6173. type: "blade",
  6174. accept(n) {
  6175. const e = M, t = ce(n, {
  6176. title: e.required.string,
  6177. view: e.required.constant("button"),
  6178. label: e.optional.string
  6179. });
  6180. return t ? { params: t } : null;
  6181. },
  6182. controller(n) {
  6183. return new U2(n.document, {
  6184. blade: n.blade,
  6185. props: X2.fromObject({
  6186. label: n.params.label
  6187. }),
  6188. valueController: new pe(n.document, {
  6189. props: X2.fromObject({
  6190. title: n.params.title
  6191. }),
  6192. viewProps: n.viewProps
  6193. })
  6194. });
  6195. },
  6196. api(n) {
  6197. return !(n.controller instanceof U2) || !(n.controller.valueController instanceof pe) ? null : new j(n.controller);
  6198. }
  6199. };
  6200. class se extends At {
  6201. constructor(e) {
  6202. super(e), this.value = e.value;
  6203. }
  6204. }
  6205. function xe() {
  6206. return new X2({
  6207. positions: te2([], {
  6208. equals: y2
  6209. })
  6210. });
  6211. }
  6212. class Ne extends X2 {
  6213. constructor(e) {
  6214. super(e);
  6215. }
  6216. static create(e) {
  6217. const t = {
  6218. completed: true,
  6219. expanded: e,
  6220. expandedHeight: null,
  6221. shouldFixHeight: false,
  6222. temporaryExpanded: null
  6223. }, l = X2.createCore(t);
  6224. return new Ne(l);
  6225. }
  6226. get styleExpanded() {
  6227. var e;
  6228. return (e = this.get("temporaryExpanded")) !== null && e !== void 0 ? e : this.get("expanded");
  6229. }
  6230. get styleHeight() {
  6231. if (!this.styleExpanded)
  6232. return "0";
  6233. const e = this.get("expandedHeight");
  6234. return this.get("shouldFixHeight") && !_(e) ? `${e}px` : "auto";
  6235. }
  6236. bindExpandedClass(e, t) {
  6237. const l = () => {
  6238. this.styleExpanded ? e.classList.add(t) : e.classList.remove(t);
  6239. };
  6240. O(this, "expanded", l), O(this, "temporaryExpanded", l);
  6241. }
  6242. cleanUpTransition() {
  6243. this.set("shouldFixHeight", false), this.set("expandedHeight", null), this.set("completed", true);
  6244. }
  6245. }
  6246. function Ut(n, e) {
  6247. let t = 0;
  6248. return an(e, () => {
  6249. n.set("expandedHeight", null), n.set("temporaryExpanded", true), rt2(e), t = e.clientHeight, n.set("temporaryExpanded", null), rt2(e);
  6250. }), t;
  6251. }
  6252. function cn(n, e) {
  6253. e.style.height = n.styleHeight;
  6254. }
  6255. function Ke(n, e) {
  6256. n.value("expanded").emitter.on("beforechange", () => {
  6257. n.set("completed", false), _(n.get("expandedHeight")) && n.set("expandedHeight", Ut(n, e)), n.set("shouldFixHeight", true), rt2(e);
  6258. }), n.emitter.on("change", () => {
  6259. cn(n, e);
  6260. }), cn(n, e), e.addEventListener("transitionend", (t) => {
  6261. t.propertyName === "height" && n.cleanUpTransition();
  6262. });
  6263. }
  6264. class $e extends a {
  6265. constructor(e, t) {
  6266. super(e), this.rackApi_ = t;
  6267. }
  6268. }
  6269. function Hs(n, e) {
  6270. return n.addBlade(Object.assign(Object.assign({}, e), { view: "button" }));
  6271. }
  6272. function Ks(n, e) {
  6273. return n.addBlade(Object.assign(Object.assign({}, e), { view: "folder" }));
  6274. }
  6275. function $s(n, e) {
  6276. const t = e ?? {};
  6277. return n.addBlade(Object.assign(Object.assign({}, t), { view: "separator" }));
  6278. }
  6279. function hi(n, e) {
  6280. return n.addBlade(Object.assign(Object.assign({}, e), { view: "tab" }));
  6281. }
  6282. class It {
  6283. constructor(e) {
  6284. this.emitter = new F2(), this.items_ = [], this.cache_ = /* @__PURE__ */ new Set(), this.onSubListAdd_ = this.onSubListAdd_.bind(this), this.onSubListRemove_ = this.onSubListRemove_.bind(this), this.extract_ = e;
  6285. }
  6286. get items() {
  6287. return this.items_;
  6288. }
  6289. allItems() {
  6290. return Array.from(this.cache_);
  6291. }
  6292. find(e) {
  6293. for (const t of this.allItems())
  6294. if (e(t))
  6295. return t;
  6296. return null;
  6297. }
  6298. includes(e) {
  6299. return this.cache_.has(e);
  6300. }
  6301. add(e, t) {
  6302. if (this.includes(e))
  6303. throw S.shouldNeverHappen();
  6304. const l = t !== void 0 ? t : this.items_.length;
  6305. this.items_.splice(l, 0, e), this.cache_.add(e);
  6306. const v = this.extract_(e);
  6307. v && (v.emitter.on("add", this.onSubListAdd_), v.emitter.on("remove", this.onSubListRemove_), v.allItems().forEach((E) => {
  6308. this.cache_.add(E);
  6309. })), this.emitter.emit("add", {
  6310. index: l,
  6311. item: e,
  6312. root: this,
  6313. target: this
  6314. });
  6315. }
  6316. remove(e) {
  6317. const t = this.items_.indexOf(e);
  6318. if (t < 0)
  6319. return;
  6320. this.items_.splice(t, 1), this.cache_.delete(e);
  6321. const l = this.extract_(e);
  6322. l && (l.emitter.off("add", this.onSubListAdd_), l.emitter.off("remove", this.onSubListRemove_)), this.emitter.emit("remove", {
  6323. index: t,
  6324. item: e,
  6325. root: this,
  6326. target: this
  6327. });
  6328. }
  6329. onSubListAdd_(e) {
  6330. this.cache_.add(e.item), this.emitter.emit("add", {
  6331. index: e.index,
  6332. item: e.item,
  6333. root: this,
  6334. target: e.target
  6335. });
  6336. }
  6337. onSubListRemove_(e) {
  6338. this.cache_.delete(e.item), this.emitter.emit("remove", {
  6339. index: e.index,
  6340. item: e.item,
  6341. root: this,
  6342. target: e.target
  6343. });
  6344. }
  6345. }
  6346. class di extends a {
  6347. constructor(e) {
  6348. super(e), this.onBindingChange_ = this.onBindingChange_.bind(this), this.emitter_ = new F2(), this.controller_.binding.emitter.on("change", this.onBindingChange_);
  6349. }
  6350. get label() {
  6351. return this.controller_.props.get("label");
  6352. }
  6353. set label(e) {
  6354. this.controller_.props.set("label", e);
  6355. }
  6356. on(e, t) {
  6357. const l = t.bind(this);
  6358. return this.emitter_.on(e, (v) => {
  6359. l(v.event);
  6360. }), this;
  6361. }
  6362. refresh() {
  6363. this.controller_.binding.read();
  6364. }
  6365. onBindingChange_(e) {
  6366. const t = e.sender.target.read();
  6367. this.emitter_.emit("change", {
  6368. event: new u(this, t, this.controller_.binding.target.presetKey, e.options.last)
  6369. });
  6370. }
  6371. }
  6372. class ze extends U2 {
  6373. constructor(e, t) {
  6374. super(e, t), this.binding = t.binding;
  6375. }
  6376. }
  6377. class mi extends a {
  6378. constructor(e) {
  6379. super(e), this.onBindingUpdate_ = this.onBindingUpdate_.bind(this), this.emitter_ = new F2(), this.controller_.binding.emitter.on("update", this.onBindingUpdate_);
  6380. }
  6381. get label() {
  6382. return this.controller_.props.get("label");
  6383. }
  6384. set label(e) {
  6385. this.controller_.props.set("label", e);
  6386. }
  6387. on(e, t) {
  6388. const l = t.bind(this);
  6389. return this.emitter_.on(e, (v) => {
  6390. l(v.event);
  6391. }), this;
  6392. }
  6393. refresh() {
  6394. this.controller_.binding.read();
  6395. }
  6396. onBindingUpdate_(e) {
  6397. const t = e.sender.target.read();
  6398. this.emitter_.emit("update", {
  6399. event: new h2(this, t, this.controller_.binding.target.presetKey)
  6400. });
  6401. }
  6402. }
  6403. class ot extends U2 {
  6404. constructor(e, t) {
  6405. super(e, t), this.binding = t.binding, this.viewProps.bindDisabled(this.binding.ticker), this.viewProps.handleDispose(() => {
  6406. this.binding.dispose();
  6407. });
  6408. }
  6409. }
  6410. function es(n) {
  6411. return n instanceof Kn ? n.apiSet_ : n instanceof $e ? n.rackApi_.apiSet_ : null;
  6412. }
  6413. function pn(n, e) {
  6414. const t = n.find((l) => l.controller_ === e);
  6415. if (!t)
  6416. throw S.shouldNeverHappen();
  6417. return t;
  6418. }
  6419. function ts(n, e, t) {
  6420. if (!R.isBindable(n))
  6421. throw S.notBindable();
  6422. return new R(n, e, t);
  6423. }
  6424. class Kn extends a {
  6425. constructor(e, t) {
  6426. 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 F2(), this.apiSet_ = new It(es), this.pool_ = t;
  6427. const l = this.controller_.rack;
  6428. 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((v) => {
  6429. this.setUpApi_(v);
  6430. });
  6431. }
  6432. get children() {
  6433. return this.controller_.rack.children.map((e) => pn(this.apiSet_, e));
  6434. }
  6435. addInput(e, t, l) {
  6436. const v = l ?? {}, E = this.controller_.view.element.ownerDocument, k2 = this.pool_.createInput(E, ts(e, t, v.presetKey), v), B2 = new di(k2);
  6437. return this.add(B2, v.index);
  6438. }
  6439. addMonitor(e, t, l) {
  6440. const v = l ?? {}, E = this.controller_.view.element.ownerDocument, k2 = this.pool_.createMonitor(E, ts(e, t), v), B2 = new mi(k2);
  6441. return this.add(B2, v.index);
  6442. }
  6443. addFolder(e) {
  6444. return Ks(this, e);
  6445. }
  6446. addButton(e) {
  6447. return Hs(this, e);
  6448. }
  6449. addSeparator(e) {
  6450. return $s(this, e);
  6451. }
  6452. addTab(e) {
  6453. return hi(this, e);
  6454. }
  6455. add(e, t) {
  6456. this.controller_.rack.add(e.controller_, t);
  6457. const l = this.apiSet_.find((v) => v.controller_ === e.controller_);
  6458. return l && this.apiSet_.remove(l), this.apiSet_.add(e), e;
  6459. }
  6460. remove(e) {
  6461. this.controller_.rack.remove(e.controller_);
  6462. }
  6463. addBlade(e) {
  6464. const t = this.controller_.view.element.ownerDocument, l = this.pool_.createBlade(t, e), v = this.pool_.createBladeApi(l);
  6465. return this.add(v, e.index);
  6466. }
  6467. on(e, t) {
  6468. const l = t.bind(this);
  6469. return this.emitter_.on(e, (v) => {
  6470. l(v.event);
  6471. }), this;
  6472. }
  6473. setUpApi_(e) {
  6474. this.apiSet_.find((l) => l.controller_ === e) || this.apiSet_.add(this.pool_.createBladeApi(e));
  6475. }
  6476. onRackAdd_(e) {
  6477. this.setUpApi_(e.bladeController);
  6478. }
  6479. onRackRemove_(e) {
  6480. if (e.isRoot) {
  6481. const t = pn(this.apiSet_, e.bladeController);
  6482. this.apiSet_.remove(t);
  6483. }
  6484. }
  6485. onRackInputChange_(e) {
  6486. const t = e.bladeController;
  6487. if (t instanceof ze) {
  6488. const l = pn(this.apiSet_, t), v = t.binding;
  6489. this.emitter_.emit("change", {
  6490. event: new u(l, v.target.read(), v.target.presetKey, e.options.last)
  6491. });
  6492. } else if (t instanceof se) {
  6493. const l = pn(this.apiSet_, t);
  6494. this.emitter_.emit("change", {
  6495. event: new u(l, t.value.rawValue, void 0, e.options.last)
  6496. });
  6497. }
  6498. }
  6499. onRackMonitorUpdate_(e) {
  6500. if (!(e.bladeController instanceof ot))
  6501. throw S.shouldNeverHappen();
  6502. const t = pn(this.apiSet_, e.bladeController), l = e.bladeController.binding;
  6503. this.emitter_.emit("update", {
  6504. event: new h2(t, l.target.read(), l.target.presetKey)
  6505. });
  6506. }
  6507. }
  6508. class fi extends $e {
  6509. constructor(e, t) {
  6510. super(e, new Kn(e.rackController, t)), this.emitter_ = new F2(), this.controller_.foldable.value("expanded").emitter.on("change", (l) => {
  6511. this.emitter_.emit("fold", {
  6512. event: new m(this, l.sender.rawValue)
  6513. });
  6514. }), this.rackApi_.on("change", (l) => {
  6515. this.emitter_.emit("change", {
  6516. event: l
  6517. });
  6518. }), this.rackApi_.on("update", (l) => {
  6519. this.emitter_.emit("update", {
  6520. event: l
  6521. });
  6522. });
  6523. }
  6524. get expanded() {
  6525. return this.controller_.foldable.get("expanded");
  6526. }
  6527. set expanded(e) {
  6528. this.controller_.foldable.set("expanded", e);
  6529. }
  6530. get title() {
  6531. return this.controller_.props.get("title");
  6532. }
  6533. set title(e) {
  6534. this.controller_.props.set("title", e);
  6535. }
  6536. get children() {
  6537. return this.rackApi_.children;
  6538. }
  6539. addInput(e, t, l) {
  6540. return this.rackApi_.addInput(e, t, l);
  6541. }
  6542. addMonitor(e, t, l) {
  6543. return this.rackApi_.addMonitor(e, t, l);
  6544. }
  6545. addFolder(e) {
  6546. return this.rackApi_.addFolder(e);
  6547. }
  6548. addButton(e) {
  6549. return this.rackApi_.addButton(e);
  6550. }
  6551. addSeparator(e) {
  6552. return this.rackApi_.addSeparator(e);
  6553. }
  6554. addTab(e) {
  6555. return this.rackApi_.addTab(e);
  6556. }
  6557. add(e, t) {
  6558. return this.rackApi_.add(e, t);
  6559. }
  6560. remove(e) {
  6561. this.rackApi_.remove(e);
  6562. }
  6563. addBlade(e) {
  6564. return this.rackApi_.addBlade(e);
  6565. }
  6566. on(e, t) {
  6567. const l = t.bind(this);
  6568. return this.emitter_.on(e, (v) => {
  6569. l(v.event);
  6570. }), this;
  6571. }
  6572. }
  6573. class vi extends At {
  6574. constructor(e) {
  6575. super({
  6576. blade: e.blade,
  6577. view: e.view,
  6578. viewProps: e.rackController.viewProps
  6579. }), this.rackController = e.rackController;
  6580. }
  6581. }
  6582. class Xs {
  6583. constructor(e, t) {
  6584. const l = D2(t.viewName);
  6585. this.element = e.createElement("div"), this.element.classList.add(l()), t.viewProps.bindClassModifiers(this.element);
  6586. }
  6587. }
  6588. function Ys(n, e) {
  6589. for (let t = 0; t < n.length; t++) {
  6590. const l = n[t];
  6591. if (l instanceof ze && l.binding === e)
  6592. return l;
  6593. }
  6594. return null;
  6595. }
  6596. function qs(n, e) {
  6597. for (let t = 0; t < n.length; t++) {
  6598. const l = n[t];
  6599. if (l instanceof ot && l.binding === e)
  6600. return l;
  6601. }
  6602. return null;
  6603. }
  6604. function Qs(n, e) {
  6605. for (let t = 0; t < n.length; t++) {
  6606. const l = n[t];
  6607. if (l instanceof se && l.value === e)
  6608. return l;
  6609. }
  6610. return null;
  6611. }
  6612. function bi(n) {
  6613. return n instanceof un ? n.rack : n instanceof vi ? n.rackController.rack : null;
  6614. }
  6615. function Zs(n) {
  6616. const e = bi(n);
  6617. return e ? e.bcSet_ : null;
  6618. }
  6619. class Ws {
  6620. constructor(e) {
  6621. var t, l;
  6622. 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 F2(), 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 It(Zs), this.bcSet_.emitter.on("add", this.onSetAdd_), this.bcSet_.emitter.on("remove", this.onSetRemove_);
  6623. }
  6624. get children() {
  6625. return this.bcSet_.items;
  6626. }
  6627. add(e, t) {
  6628. var l;
  6629. (l = e.parent) === null || l === void 0 || l.remove(e), C(e, "parent") ? e.parent = this : (e.parent_ = this, Oe({
  6630. key: "parent",
  6631. target: "BladeController",
  6632. place: "BladeRack.add"
  6633. })), this.bcSet_.add(e, t);
  6634. }
  6635. remove(e) {
  6636. C(e, "parent") ? e.parent = null : (e.parent_ = null, Oe({
  6637. key: "parent",
  6638. target: "BladeController",
  6639. place: "BladeRack.remove"
  6640. })), this.bcSet_.remove(e);
  6641. }
  6642. find(e) {
  6643. return this.bcSet_.allItems().filter((t) => t instanceof e);
  6644. }
  6645. onSetAdd_(e) {
  6646. this.updatePositions_();
  6647. const t = e.target === e.root;
  6648. if (this.emitter.emit("add", {
  6649. bladeController: e.item,
  6650. index: e.index,
  6651. isRoot: t,
  6652. sender: this
  6653. }), !t)
  6654. return;
  6655. const l = e.item;
  6656. if (l.viewProps.emitter.on("change", this.onChildViewPropsChange_), l.blade.value("positions").emitter.on("change", this.onChildPositionsChange_), l.viewProps.handleDispose(this.onChildDispose_), l instanceof ze)
  6657. l.binding.emitter.on("change", this.onChildInputChange_);
  6658. else if (l instanceof ot)
  6659. l.binding.emitter.on("update", this.onChildMonitorUpdate_);
  6660. else if (l instanceof se)
  6661. l.value.emitter.on("change", this.onChildValueChange_);
  6662. else {
  6663. const v = bi(l);
  6664. if (v) {
  6665. const E = v.emitter;
  6666. E.on("layout", this.onDescendantLayout_), E.on("inputchange", this.onDescendantInputChange_), E.on("monitorupdate", this.onDescendantMonitorUpdate_);
  6667. }
  6668. }
  6669. }
  6670. onSetRemove_(e) {
  6671. this.updatePositions_();
  6672. const t = e.target === e.root;
  6673. if (this.emitter.emit("remove", {
  6674. bladeController: e.item,
  6675. isRoot: t,
  6676. sender: this
  6677. }), !t)
  6678. return;
  6679. const l = e.item;
  6680. if (l instanceof ze)
  6681. l.binding.emitter.off("change", this.onChildInputChange_);
  6682. else if (l instanceof ot)
  6683. l.binding.emitter.off("update", this.onChildMonitorUpdate_);
  6684. else if (l instanceof se)
  6685. l.value.emitter.off("change", this.onChildValueChange_);
  6686. else {
  6687. const v = bi(l);
  6688. if (v) {
  6689. const E = v.emitter;
  6690. E.off("layout", this.onDescendantLayout_), E.off("inputchange", this.onDescendantInputChange_), E.off("monitorupdate", this.onDescendantMonitorUpdate_);
  6691. }
  6692. }
  6693. }
  6694. updatePositions_() {
  6695. const e = this.bcSet_.items.filter((v) => !v.viewProps.get("hidden")), t = e[0], l = e[e.length - 1];
  6696. this.bcSet_.items.forEach((v) => {
  6697. const E = [];
  6698. v === t && (E.push("first"), (!this.blade_ || this.blade_.get("positions").includes("veryfirst")) && E.push("veryfirst")), v === l && (E.push("last"), (!this.blade_ || this.blade_.get("positions").includes("verylast")) && E.push("verylast")), v.blade.set("positions", E);
  6699. });
  6700. }
  6701. onChildPositionsChange_() {
  6702. this.updatePositions_(), this.emitter.emit("layout", {
  6703. sender: this
  6704. });
  6705. }
  6706. onChildViewPropsChange_(e) {
  6707. this.updatePositions_(), this.emitter.emit("layout", {
  6708. sender: this
  6709. });
  6710. }
  6711. onChildDispose_() {
  6712. this.bcSet_.items.filter((t) => t.viewProps.get("disposed")).forEach((t) => {
  6713. this.bcSet_.remove(t);
  6714. });
  6715. }
  6716. onChildInputChange_(e) {
  6717. const t = Ys(this.find(ze), e.sender);
  6718. if (!t)
  6719. throw S.alreadyDisposed();
  6720. this.emitter.emit("inputchange", {
  6721. bladeController: t,
  6722. options: e.options,
  6723. sender: this
  6724. });
  6725. }
  6726. onChildMonitorUpdate_(e) {
  6727. const t = qs(this.find(ot), e.sender);
  6728. if (!t)
  6729. throw S.alreadyDisposed();
  6730. this.emitter.emit("monitorupdate", {
  6731. bladeController: t,
  6732. sender: this
  6733. });
  6734. }
  6735. onChildValueChange_(e) {
  6736. const t = Qs(this.find(se), e.sender);
  6737. if (!t)
  6738. throw S.alreadyDisposed();
  6739. this.emitter.emit("inputchange", {
  6740. bladeController: t,
  6741. options: e.options,
  6742. sender: this
  6743. });
  6744. }
  6745. onDescendantLayout_(e) {
  6746. this.updatePositions_(), this.emitter.emit("layout", {
  6747. sender: this
  6748. });
  6749. }
  6750. onDescendantInputChange_(e) {
  6751. this.emitter.emit("inputchange", {
  6752. bladeController: e.bladeController,
  6753. options: e.options,
  6754. sender: this
  6755. });
  6756. }
  6757. onDescendantMonitorUpdate_(e) {
  6758. this.emitter.emit("monitorupdate", {
  6759. bladeController: e.bladeController,
  6760. sender: this
  6761. });
  6762. }
  6763. onBladePositionsChange_() {
  6764. this.updatePositions_();
  6765. }
  6766. }
  6767. class un extends At {
  6768. constructor(e, t) {
  6769. super(Object.assign(Object.assign({}, t), { view: new Xs(e, {
  6770. viewName: "brk",
  6771. viewProps: t.viewProps
  6772. }) })), this.onRackAdd_ = this.onRackAdd_.bind(this), this.onRackRemove_ = this.onRackRemove_.bind(this);
  6773. const l = new Ws({
  6774. blade: t.root ? void 0 : t.blade,
  6775. viewProps: t.viewProps
  6776. });
  6777. l.emitter.on("add", this.onRackAdd_), l.emitter.on("remove", this.onRackRemove_), this.rack = l, this.viewProps.handleDispose(() => {
  6778. for (let v = this.rack.children.length - 1; v >= 0; v--)
  6779. this.rack.children[v].viewProps.set("disposed", true);
  6780. });
  6781. }
  6782. onRackAdd_(e) {
  6783. e.isRoot && Lt(this.view.element, e.bladeController.view.element, e.index);
  6784. }
  6785. onRackRemove_(e) {
  6786. e.isRoot && Gn(e.bladeController.view.element);
  6787. }
  6788. }
  6789. const ns = D2("cnt");
  6790. class Js {
  6791. constructor(e, t) {
  6792. var l;
  6793. this.className_ = D2((l = t.viewName) !== null && l !== void 0 ? l : "fld"), this.element = e.createElement("div"), this.element.classList.add(this.className_(), ns()), t.viewProps.bindClassModifiers(this.element), this.foldable_ = t.foldable, this.foldable_.bindExpandedClass(this.element, this.className_(void 0, "expanded")), O(this.foldable_, "completed", K(this.element, this.className_(void 0, "cpl")));
  6794. const v = e.createElement("button");
  6795. v.classList.add(this.className_("b")), O(t.props, "title", (ee) => {
  6796. _(ee) ? this.element.classList.add(this.className_(void 0, "not")) : this.element.classList.remove(this.className_(void 0, "not"));
  6797. }), t.viewProps.bindDisabled(v), this.element.appendChild(v), this.buttonElement = v;
  6798. const E = e.createElement("div");
  6799. E.classList.add(this.className_("i")), this.element.appendChild(E);
  6800. const k2 = e.createElement("div");
  6801. k2.classList.add(this.className_("t")), q(t.props.value("title"), k2), this.buttonElement.appendChild(k2), this.titleElement = k2;
  6802. const B2 = e.createElement("div");
  6803. B2.classList.add(this.className_("m")), this.buttonElement.appendChild(B2);
  6804. const Q = t.containerElement;
  6805. Q.classList.add(this.className_("c")), this.element.appendChild(Q), this.containerElement = Q;
  6806. }
  6807. }
  6808. class $n extends vi {
  6809. constructor(e, t) {
  6810. var l;
  6811. const v = Ne.create((l = t.expanded) !== null && l !== void 0 ? l : true), E = new un(e, {
  6812. blade: t.blade,
  6813. root: t.root,
  6814. viewProps: t.viewProps
  6815. });
  6816. super(Object.assign(Object.assign({}, t), { rackController: E, view: new Js(e, {
  6817. containerElement: E.view.element,
  6818. foldable: v,
  6819. props: t.props,
  6820. viewName: t.root ? "rot" : void 0,
  6821. viewProps: t.viewProps
  6822. }) })), this.onTitleClick_ = this.onTitleClick_.bind(this), this.props = t.props, this.foldable = v, Ke(this.foldable, this.view.containerElement), this.rackController.rack.emitter.on("add", () => {
  6823. this.foldable.cleanUpTransition();
  6824. }), this.rackController.rack.emitter.on("remove", () => {
  6825. this.foldable.cleanUpTransition();
  6826. }), this.view.buttonElement.addEventListener("click", this.onTitleClick_);
  6827. }
  6828. get document() {
  6829. return this.view.element.ownerDocument;
  6830. }
  6831. onTitleClick_() {
  6832. this.foldable.set("expanded", !this.foldable.get("expanded"));
  6833. }
  6834. }
  6835. const er = {
  6836. id: "folder",
  6837. type: "blade",
  6838. accept(n) {
  6839. const e = M, t = ce(n, {
  6840. title: e.required.string,
  6841. view: e.required.constant("folder"),
  6842. expanded: e.optional.boolean
  6843. });
  6844. return t ? { params: t } : null;
  6845. },
  6846. controller(n) {
  6847. return new $n(n.document, {
  6848. blade: n.blade,
  6849. expanded: n.params.expanded,
  6850. props: X2.fromObject({
  6851. title: n.params.title
  6852. }),
  6853. viewProps: n.viewProps
  6854. });
  6855. },
  6856. api(n) {
  6857. return n.controller instanceof $n ? new fi(n.controller, n.pool) : null;
  6858. }
  6859. };
  6860. class Gt extends se {
  6861. constructor(e, t) {
  6862. const l = t.valueController.viewProps;
  6863. super(Object.assign(Object.assign({}, t), { value: t.valueController.value, view: new A(e, {
  6864. props: t.props,
  6865. viewProps: l
  6866. }), viewProps: l })), this.props = t.props, this.valueController = t.valueController, this.view.valueElement.appendChild(this.valueController.view.element);
  6867. }
  6868. }
  6869. class is extends a {
  6870. }
  6871. const gi = D2("spr");
  6872. class tr {
  6873. constructor(e, t) {
  6874. this.element = e.createElement("div"), this.element.classList.add(gi()), t.viewProps.bindClassModifiers(this.element);
  6875. const l = e.createElement("hr");
  6876. l.classList.add(gi("r")), this.element.appendChild(l);
  6877. }
  6878. }
  6879. class hn extends At {
  6880. constructor(e, t) {
  6881. super(Object.assign(Object.assign({}, t), { view: new tr(e, {
  6882. viewProps: t.viewProps
  6883. }) }));
  6884. }
  6885. }
  6886. const nr = {
  6887. id: "separator",
  6888. type: "blade",
  6889. accept(n) {
  6890. const t = ce(n, {
  6891. view: M.required.constant("separator")
  6892. });
  6893. return t ? { params: t } : null;
  6894. },
  6895. controller(n) {
  6896. return new hn(n.document, {
  6897. blade: n.blade,
  6898. viewProps: n.viewProps
  6899. });
  6900. },
  6901. api(n) {
  6902. return n.controller instanceof hn ? new is(n.controller) : null;
  6903. }
  6904. }, Ie = D2("tbi");
  6905. class ir {
  6906. constructor(e, t) {
  6907. this.element = e.createElement("div"), this.element.classList.add(Ie()), t.viewProps.bindClassModifiers(this.element), O(t.props, "selected", (E) => {
  6908. E ? this.element.classList.add(Ie(void 0, "sel")) : this.element.classList.remove(Ie(void 0, "sel"));
  6909. });
  6910. const l = e.createElement("button");
  6911. l.classList.add(Ie("b")), t.viewProps.bindDisabled(l), this.element.appendChild(l), this.buttonElement = l;
  6912. const v = e.createElement("div");
  6913. v.classList.add(Ie("t")), q(t.props.value("title"), v), this.buttonElement.appendChild(v), this.titleElement = v;
  6914. }
  6915. }
  6916. class Xn {
  6917. constructor(e, t) {
  6918. this.emitter = new F2(), this.onClick_ = this.onClick_.bind(this), this.props = t.props, this.viewProps = t.viewProps, this.view = new ir(e, {
  6919. props: t.props,
  6920. viewProps: t.viewProps
  6921. }), this.view.buttonElement.addEventListener("click", this.onClick_);
  6922. }
  6923. onClick_() {
  6924. this.emitter.emit("click", {
  6925. sender: this
  6926. });
  6927. }
  6928. }
  6929. class ss {
  6930. constructor(e, t) {
  6931. this.onItemClick_ = this.onItemClick_.bind(this), this.ic_ = new Xn(e, {
  6932. props: t.itemProps,
  6933. viewProps: Qe2.create()
  6934. }), this.ic_.emitter.on("click", this.onItemClick_), this.cc_ = new un(e, {
  6935. blade: xe(),
  6936. viewProps: Qe2.create()
  6937. }), this.props = t.props, O(this.props, "selected", (l) => {
  6938. this.itemController.props.set("selected", l), this.contentController.viewProps.set("hidden", !l);
  6939. });
  6940. }
  6941. get itemController() {
  6942. return this.ic_;
  6943. }
  6944. get contentController() {
  6945. return this.cc_;
  6946. }
  6947. onItemClick_() {
  6948. this.props.set("selected", true);
  6949. }
  6950. }
  6951. class _i {
  6952. constructor(e, t) {
  6953. this.controller_ = e, this.rackApi_ = t;
  6954. }
  6955. get title() {
  6956. var e;
  6957. return (e = this.controller_.itemController.props.get("title")) !== null && e !== void 0 ? e : "";
  6958. }
  6959. set title(e) {
  6960. this.controller_.itemController.props.set("title", e);
  6961. }
  6962. get selected() {
  6963. return this.controller_.props.get("selected");
  6964. }
  6965. set selected(e) {
  6966. this.controller_.props.set("selected", e);
  6967. }
  6968. get children() {
  6969. return this.rackApi_.children;
  6970. }
  6971. addButton(e) {
  6972. return this.rackApi_.addButton(e);
  6973. }
  6974. addFolder(e) {
  6975. return this.rackApi_.addFolder(e);
  6976. }
  6977. addSeparator(e) {
  6978. return this.rackApi_.addSeparator(e);
  6979. }
  6980. addTab(e) {
  6981. return this.rackApi_.addTab(e);
  6982. }
  6983. add(e, t) {
  6984. this.rackApi_.add(e, t);
  6985. }
  6986. remove(e) {
  6987. this.rackApi_.remove(e);
  6988. }
  6989. addInput(e, t, l) {
  6990. return this.rackApi_.addInput(e, t, l);
  6991. }
  6992. addMonitor(e, t, l) {
  6993. return this.rackApi_.addMonitor(e, t, l);
  6994. }
  6995. addBlade(e) {
  6996. return this.rackApi_.addBlade(e);
  6997. }
  6998. }
  6999. class rs extends $e {
  7000. constructor(e, t) {
  7001. super(e, new Kn(e.rackController, t)), this.onPageAdd_ = this.onPageAdd_.bind(this), this.onPageRemove_ = this.onPageRemove_.bind(this), this.onSelect_ = this.onSelect_.bind(this), this.emitter_ = new F2(), this.pageApiMap_ = /* @__PURE__ */ new Map(), this.rackApi_.on("change", (l) => {
  7002. this.emitter_.emit("change", {
  7003. event: l
  7004. });
  7005. }), this.rackApi_.on("update", (l) => {
  7006. this.emitter_.emit("update", {
  7007. event: l
  7008. });
  7009. }), 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) => {
  7010. this.setUpPageApi_(l);
  7011. });
  7012. }
  7013. get pages() {
  7014. return this.controller_.pageSet.items.map((e) => {
  7015. const t = this.pageApiMap_.get(e);
  7016. if (!t)
  7017. throw S.shouldNeverHappen();
  7018. return t;
  7019. });
  7020. }
  7021. addPage(e) {
  7022. const t = this.controller_.view.element.ownerDocument, l = new ss(t, {
  7023. itemProps: X2.fromObject({
  7024. selected: false,
  7025. title: e.title
  7026. }),
  7027. props: X2.fromObject({
  7028. selected: false
  7029. })
  7030. });
  7031. this.controller_.add(l, e.index);
  7032. const v = this.pageApiMap_.get(l);
  7033. if (!v)
  7034. throw S.shouldNeverHappen();
  7035. return v;
  7036. }
  7037. removePage(e) {
  7038. this.controller_.remove(e);
  7039. }
  7040. on(e, t) {
  7041. const l = t.bind(this);
  7042. return this.emitter_.on(e, (v) => {
  7043. l(v.event);
  7044. }), this;
  7045. }
  7046. setUpPageApi_(e) {
  7047. const t = this.rackApi_.apiSet_.find((v) => v.controller_ === e.contentController);
  7048. if (!t)
  7049. throw S.shouldNeverHappen();
  7050. const l = new _i(e, t);
  7051. this.pageApiMap_.set(e, l);
  7052. }
  7053. onPageAdd_(e) {
  7054. this.setUpPageApi_(e.item);
  7055. }
  7056. onPageRemove_(e) {
  7057. if (!this.pageApiMap_.get(e.item))
  7058. throw S.shouldNeverHappen();
  7059. this.pageApiMap_.delete(e.item);
  7060. }
  7061. onSelect_(e) {
  7062. this.emitter_.emit("select", {
  7063. event: new g(this, e.rawValue)
  7064. });
  7065. }
  7066. }
  7067. const os = -1;
  7068. class sr {
  7069. constructor() {
  7070. this.onItemSelectedChange_ = this.onItemSelectedChange_.bind(this), this.empty = te2(true), this.selectedIndex = te2(os), this.items_ = [];
  7071. }
  7072. add(e, t) {
  7073. const l = t ?? this.items_.length;
  7074. this.items_.splice(l, 0, e), e.emitter.on("change", this.onItemSelectedChange_), this.keepSelection_();
  7075. }
  7076. remove(e) {
  7077. const t = this.items_.indexOf(e);
  7078. t < 0 || (this.items_.splice(t, 1), e.emitter.off("change", this.onItemSelectedChange_), this.keepSelection_());
  7079. }
  7080. keepSelection_() {
  7081. if (this.items_.length === 0) {
  7082. this.selectedIndex.rawValue = os, this.empty.rawValue = true;
  7083. return;
  7084. }
  7085. const e = this.items_.findIndex((t) => t.rawValue);
  7086. e < 0 ? (this.items_.forEach((t, l) => {
  7087. t.rawValue = l === 0;
  7088. }), this.selectedIndex.rawValue = 0) : (this.items_.forEach((t, l) => {
  7089. t.rawValue = l === e;
  7090. }), this.selectedIndex.rawValue = e), this.empty.rawValue = false;
  7091. }
  7092. onItemSelectedChange_(e) {
  7093. if (e.rawValue) {
  7094. const t = this.items_.findIndex((l) => l === e.sender);
  7095. this.items_.forEach((l, v) => {
  7096. l.rawValue = v === t;
  7097. }), this.selectedIndex.rawValue = t;
  7098. } else
  7099. this.keepSelection_();
  7100. }
  7101. }
  7102. const Ht = D2("tab");
  7103. class Kt {
  7104. constructor(e, t) {
  7105. this.element = e.createElement("div"), this.element.classList.add(Ht(), ns()), t.viewProps.bindClassModifiers(this.element), N2(t.empty, K(this.element, Ht(void 0, "nop")));
  7106. const l = e.createElement("div");
  7107. l.classList.add(Ht("t")), this.element.appendChild(l), this.itemsElement = l;
  7108. const v = e.createElement("div");
  7109. v.classList.add(Ht("i")), this.element.appendChild(v);
  7110. const E = t.contentsElement;
  7111. E.classList.add(Ht("c")), this.element.appendChild(E), this.contentsElement = E;
  7112. }
  7113. }
  7114. class dn extends vi {
  7115. constructor(e, t) {
  7116. const l = new un(e, {
  7117. blade: t.blade,
  7118. viewProps: t.viewProps
  7119. }), v = new sr();
  7120. super({
  7121. blade: t.blade,
  7122. rackController: l,
  7123. view: new Kt(e, {
  7124. contentsElement: l.view.element,
  7125. empty: v.empty,
  7126. viewProps: t.viewProps
  7127. })
  7128. }), this.onPageAdd_ = this.onPageAdd_.bind(this), this.onPageRemove_ = this.onPageRemove_.bind(this), this.pageSet_ = new It(() => null), this.pageSet_.emitter.on("add", this.onPageAdd_), this.pageSet_.emitter.on("remove", this.onPageRemove_), this.tab = v;
  7129. }
  7130. get pageSet() {
  7131. return this.pageSet_;
  7132. }
  7133. add(e, t) {
  7134. this.pageSet_.add(e, t);
  7135. }
  7136. remove(e) {
  7137. this.pageSet_.remove(this.pageSet_.items[e]);
  7138. }
  7139. onPageAdd_(e) {
  7140. const t = e.item;
  7141. Lt(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"));
  7142. }
  7143. onPageRemove_(e) {
  7144. const t = e.item;
  7145. Gn(t.itemController.view.element), t.itemController.viewProps.set("parent", null), this.rackController.rack.remove(t.contentController), this.tab.remove(t.props.value("selected"));
  7146. }
  7147. }
  7148. const wi = {
  7149. id: "tab",
  7150. type: "blade",
  7151. accept(n) {
  7152. const e = M, t = ce(n, {
  7153. pages: e.required.array(e.required.object({ title: e.required.string })),
  7154. view: e.required.constant("tab")
  7155. });
  7156. return !t || t.pages.length === 0 ? null : { params: t };
  7157. },
  7158. controller(n) {
  7159. const e = new dn(n.document, {
  7160. blade: n.blade,
  7161. viewProps: n.viewProps
  7162. });
  7163. return n.params.pages.forEach((t) => {
  7164. const l = new ss(n.document, {
  7165. itemProps: X2.fromObject({
  7166. selected: false,
  7167. title: t.title
  7168. }),
  7169. props: X2.fromObject({
  7170. selected: false
  7171. })
  7172. });
  7173. e.add(l);
  7174. }), e;
  7175. },
  7176. api(n) {
  7177. return n.controller instanceof dn ? new rs(n.controller, n.pool) : null;
  7178. }
  7179. };
  7180. function rr(n, e) {
  7181. const t = n.accept(e.params);
  7182. if (!t)
  7183. return null;
  7184. const l = M.optional.boolean(e.params.disabled).value, v = M.optional.boolean(e.params.hidden).value;
  7185. return n.controller({
  7186. blade: xe(),
  7187. document: e.document,
  7188. params: Object.assign(Object.assign({}, t.params), { disabled: l, hidden: v }),
  7189. viewProps: Qe2.create({
  7190. disabled: l,
  7191. hidden: v
  7192. })
  7193. });
  7194. }
  7195. class as {
  7196. constructor() {
  7197. this.disabled = false, this.emitter = new F2();
  7198. }
  7199. dispose() {
  7200. }
  7201. tick() {
  7202. this.disabled || this.emitter.emit("tick", {
  7203. sender: this
  7204. });
  7205. }
  7206. }
  7207. class yi {
  7208. constructor(e, t) {
  7209. this.disabled_ = false, this.timerId_ = null, this.onTick_ = this.onTick_.bind(this), this.doc_ = e, this.emitter = new F2(), this.interval_ = t, this.setTimer_();
  7210. }
  7211. get disabled() {
  7212. return this.disabled_;
  7213. }
  7214. set disabled(e) {
  7215. this.disabled_ = e, this.disabled_ ? this.clearTimer_() : this.setTimer_();
  7216. }
  7217. dispose() {
  7218. this.clearTimer_();
  7219. }
  7220. clearTimer_() {
  7221. if (this.timerId_ === null)
  7222. return;
  7223. const e = this.doc_.defaultView;
  7224. e && e.clearInterval(this.timerId_), this.timerId_ = null;
  7225. }
  7226. setTimer_() {
  7227. if (this.clearTimer_(), this.interval_ <= 0)
  7228. return;
  7229. const e = this.doc_.defaultView;
  7230. e && (this.timerId_ = e.setInterval(this.onTick_, this.interval_));
  7231. }
  7232. onTick_() {
  7233. this.disabled_ || this.emitter.emit("tick", {
  7234. sender: this
  7235. });
  7236. }
  7237. }
  7238. class Ct2 {
  7239. constructor(e) {
  7240. this.constraints = e;
  7241. }
  7242. constrain(e) {
  7243. return this.constraints.reduce((t, l) => l.constrain(t), e);
  7244. }
  7245. }
  7246. function we(n, e) {
  7247. if (n instanceof e)
  7248. return n;
  7249. if (n instanceof Ct2) {
  7250. const t = n.constraints.reduce((l, v) => l || (v instanceof e ? v : null), null);
  7251. if (t)
  7252. return t;
  7253. }
  7254. return null;
  7255. }
  7256. class Vt {
  7257. constructor(e) {
  7258. this.values = X2.fromObject({
  7259. max: e.max,
  7260. min: e.min
  7261. });
  7262. }
  7263. constrain(e) {
  7264. const t = this.values.get("max"), l = this.values.get("min");
  7265. return Math.min(Math.max(e, l), t);
  7266. }
  7267. }
  7268. class at {
  7269. constructor(e) {
  7270. this.values = X2.fromObject({
  7271. options: e
  7272. });
  7273. }
  7274. get options() {
  7275. return this.values.get("options");
  7276. }
  7277. constrain(e) {
  7278. const t = this.values.get("options");
  7279. return t.length === 0 || t.filter((v) => v.value === e).length > 0 ? e : t[0].value;
  7280. }
  7281. }
  7282. class Xe {
  7283. constructor(e) {
  7284. this.values = X2.fromObject({
  7285. max: e.max,
  7286. min: e.min
  7287. });
  7288. }
  7289. get maxValue() {
  7290. return this.values.get("max");
  7291. }
  7292. get minValue() {
  7293. return this.values.get("min");
  7294. }
  7295. constrain(e) {
  7296. const t = this.values.get("max"), l = this.values.get("min");
  7297. let v = e;
  7298. return _(l) || (v = Math.max(v, l)), _(t) || (v = Math.min(v, t)), v;
  7299. }
  7300. }
  7301. class Yn {
  7302. constructor(e, t = 0) {
  7303. this.step = e, this.origin = t;
  7304. }
  7305. constrain(e) {
  7306. const t = this.origin % this.step, l = Math.round((e - t) / this.step);
  7307. return t + l * this.step;
  7308. }
  7309. }
  7310. const xi = D2("lst");
  7311. class Ei {
  7312. constructor(e, t) {
  7313. this.onValueChange_ = this.onValueChange_.bind(this), this.props_ = t.props, this.element = e.createElement("div"), this.element.classList.add(xi()), t.viewProps.bindClassModifiers(this.element);
  7314. const l = e.createElement("select");
  7315. l.classList.add(xi("s")), O(this.props_, "options", (E) => {
  7316. ln(l), E.forEach((k2, B2) => {
  7317. const Q = e.createElement("option");
  7318. Q.dataset.index = String(B2), Q.textContent = k2.text, Q.value = String(k2.value), l.appendChild(Q);
  7319. });
  7320. }), t.viewProps.bindDisabled(l), this.element.appendChild(l), this.selectElement = l;
  7321. const v = e.createElement("div");
  7322. v.classList.add(xi("m")), v.appendChild(xt(e, "dropdown")), this.element.appendChild(v), t.value.emitter.on("change", this.onValueChange_), this.value_ = t.value, this.update_();
  7323. }
  7324. update_() {
  7325. this.selectElement.value = String(this.value_.rawValue);
  7326. }
  7327. onValueChange_() {
  7328. this.update_();
  7329. }
  7330. }
  7331. class mn {
  7332. constructor(e, t) {
  7333. this.onSelectChange_ = this.onSelectChange_.bind(this), this.props = t.props, this.value = t.value, this.viewProps = t.viewProps, this.view = new Ei(e, {
  7334. props: this.props,
  7335. value: this.value,
  7336. viewProps: this.viewProps
  7337. }), this.view.selectElement.addEventListener("change", this.onSelectChange_);
  7338. }
  7339. onSelectChange_(e) {
  7340. const l = e.currentTarget.selectedOptions.item(0);
  7341. if (!l)
  7342. return;
  7343. const v = Number(l.dataset.index);
  7344. this.value.rawValue = this.props.get("options")[v].value;
  7345. }
  7346. }
  7347. const ls = D2("pop");
  7348. class cs {
  7349. constructor(e, t) {
  7350. this.element = e.createElement("div"), this.element.classList.add(ls()), t.viewProps.bindClassModifiers(this.element), N2(t.shows, K(this.element, ls(void 0, "v")));
  7351. }
  7352. }
  7353. class ps {
  7354. constructor(e, t) {
  7355. this.shows = te2(false), this.viewProps = t.viewProps, this.view = new cs(e, {
  7356. shows: this.shows,
  7357. viewProps: this.viewProps
  7358. });
  7359. }
  7360. }
  7361. const fn = D2("txt");
  7362. class us {
  7363. constructor(e, t) {
  7364. this.onChange_ = this.onChange_.bind(this), this.element = e.createElement("div"), this.element.classList.add(fn()), t.viewProps.bindClassModifiers(this.element), this.props_ = t.props, this.props_.emitter.on("change", this.onChange_);
  7365. const l = e.createElement("input");
  7366. l.classList.add(fn("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();
  7367. }
  7368. refresh() {
  7369. const e = this.props_.get("formatter");
  7370. this.inputElement.value = e(this.value_.rawValue);
  7371. }
  7372. onChange_() {
  7373. this.refresh();
  7374. }
  7375. }
  7376. class qn {
  7377. constructor(e, t) {
  7378. 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 us(e, {
  7379. props: t.props,
  7380. value: this.value,
  7381. viewProps: this.viewProps
  7382. }), this.view.inputElement.addEventListener("change", this.onInputChange_);
  7383. }
  7384. onInputChange_(e) {
  7385. const l = e.currentTarget.value, v = this.parser_(l);
  7386. _(v) || (this.value.rawValue = v), this.view.refresh();
  7387. }
  7388. }
  7389. function or(n) {
  7390. return String(n);
  7391. }
  7392. function hs(n) {
  7393. return n === "false" ? false : !!n;
  7394. }
  7395. function ds(n) {
  7396. return or(n);
  7397. }
  7398. class ar {
  7399. constructor(e) {
  7400. this.text = e;
  7401. }
  7402. evaluate() {
  7403. return Number(this.text);
  7404. }
  7405. toString() {
  7406. return this.text;
  7407. }
  7408. }
  7409. const lr = {
  7410. "**": (n, e) => Math.pow(n, e),
  7411. "*": (n, e) => n * e,
  7412. "/": (n, e) => n / e,
  7413. "%": (n, e) => n % e,
  7414. "+": (n, e) => n + e,
  7415. "-": (n, e) => n - e,
  7416. "<<": (n, e) => n << e,
  7417. ">>": (n, e) => n >> e,
  7418. ">>>": (n, e) => n >>> e,
  7419. "&": (n, e) => n & e,
  7420. "^": (n, e) => n ^ e,
  7421. "|": (n, e) => n | e
  7422. };
  7423. class cr {
  7424. constructor(e, t, l) {
  7425. this.left = t, this.operator = e, this.right = l;
  7426. }
  7427. evaluate() {
  7428. const e = lr[this.operator];
  7429. if (!e)
  7430. throw new Error(`unexpected binary operator: '${this.operator}`);
  7431. return e(this.left.evaluate(), this.right.evaluate());
  7432. }
  7433. toString() {
  7434. return [
  7435. "b(",
  7436. this.left.toString(),
  7437. this.operator,
  7438. this.right.toString(),
  7439. ")"
  7440. ].join(" ");
  7441. }
  7442. }
  7443. const pr = {
  7444. "+": (n) => n,
  7445. "-": (n) => -n,
  7446. "~": (n) => ~n
  7447. };
  7448. class ur {
  7449. constructor(e, t) {
  7450. this.operator = e, this.expression = t;
  7451. }
  7452. evaluate() {
  7453. const e = pr[this.operator];
  7454. if (!e)
  7455. throw new Error(`unexpected unary operator: '${this.operator}`);
  7456. return e(this.expression.evaluate());
  7457. }
  7458. toString() {
  7459. return ["u(", this.operator, this.expression.toString(), ")"].join(" ");
  7460. }
  7461. }
  7462. function Ci(n) {
  7463. return (e, t) => {
  7464. for (let l = 0; l < n.length; l++) {
  7465. const v = n[l](e, t);
  7466. if (v !== "")
  7467. return v;
  7468. }
  7469. return "";
  7470. };
  7471. }
  7472. function vn(n, e) {
  7473. var t;
  7474. const l = n.substr(e).match(/^\s+/);
  7475. return (t = l && l[0]) !== null && t !== void 0 ? t : "";
  7476. }
  7477. function hr(n, e) {
  7478. const t = n.substr(e, 1);
  7479. return t.match(/^[1-9]$/) ? t : "";
  7480. }
  7481. function bn(n, e) {
  7482. var t;
  7483. const l = n.substr(e).match(/^[0-9]+/);
  7484. return (t = l && l[0]) !== null && t !== void 0 ? t : "";
  7485. }
  7486. function ms(n, e) {
  7487. const t = bn(n, e);
  7488. if (t !== "")
  7489. return t;
  7490. const l = n.substr(e, 1);
  7491. if (e += 1, l !== "-" && l !== "+")
  7492. return "";
  7493. const v = bn(n, e);
  7494. return v === "" ? "" : l + v;
  7495. }
  7496. function Pi(n, e) {
  7497. const t = n.substr(e, 1);
  7498. if (e += 1, t.toLowerCase() !== "e")
  7499. return "";
  7500. const l = ms(n, e);
  7501. return l === "" ? "" : t + l;
  7502. }
  7503. function fs(n, e) {
  7504. const t = n.substr(e, 1);
  7505. if (t === "0")
  7506. return t;
  7507. const l = hr(n, e);
  7508. return e += l.length, l === "" ? "" : l + bn(n, e);
  7509. }
  7510. function Ti(n, e) {
  7511. const t = fs(n, e);
  7512. if (e += t.length, t === "")
  7513. return "";
  7514. const l = n.substr(e, 1);
  7515. if (e += l.length, l !== ".")
  7516. return "";
  7517. const v = bn(n, e);
  7518. return e += v.length, t + l + v + Pi(n, e);
  7519. }
  7520. function dr(n, e) {
  7521. const t = n.substr(e, 1);
  7522. if (e += t.length, t !== ".")
  7523. return "";
  7524. const l = bn(n, e);
  7525. return e += l.length, l === "" ? "" : t + l + Pi(n, e);
  7526. }
  7527. function mr(n, e) {
  7528. const t = fs(n, e);
  7529. return e += t.length, t === "" ? "" : t + Pi(n, e);
  7530. }
  7531. const fr = Ci([
  7532. Ti,
  7533. dr,
  7534. mr
  7535. ]);
  7536. function Pt(n, e) {
  7537. var t;
  7538. const l = n.substr(e).match(/^[01]+/);
  7539. return (t = l && l[0]) !== null && t !== void 0 ? t : "";
  7540. }
  7541. function vr(n, e) {
  7542. const t = n.substr(e, 2);
  7543. if (e += t.length, t.toLowerCase() !== "0b")
  7544. return "";
  7545. const l = Pt(n, e);
  7546. return l === "" ? "" : t + l;
  7547. }
  7548. function br(n, e) {
  7549. var t;
  7550. const l = n.substr(e).match(/^[0-7]+/);
  7551. return (t = l && l[0]) !== null && t !== void 0 ? t : "";
  7552. }
  7553. function vs(n, e) {
  7554. const t = n.substr(e, 2);
  7555. if (e += t.length, t.toLowerCase() !== "0o")
  7556. return "";
  7557. const l = br(n, e);
  7558. return l === "" ? "" : t + l;
  7559. }
  7560. function gr(n, e) {
  7561. var t;
  7562. const l = n.substr(e).match(/^[0-9a-f]+/i);
  7563. return (t = l && l[0]) !== null && t !== void 0 ? t : "";
  7564. }
  7565. function bs(n, e) {
  7566. const t = n.substr(e, 2);
  7567. if (e += t.length, t.toLowerCase() !== "0x")
  7568. return "";
  7569. const l = gr(n, e);
  7570. return l === "" ? "" : t + l;
  7571. }
  7572. const ki = Ci([
  7573. vr,
  7574. vs,
  7575. bs
  7576. ]), _r = Ci([
  7577. ki,
  7578. fr
  7579. ]);
  7580. function gs(n, e) {
  7581. const t = _r(n, e);
  7582. return e += t.length, t === "" ? null : {
  7583. evaluable: new ar(t),
  7584. cursor: e
  7585. };
  7586. }
  7587. function Ze(n, e) {
  7588. const t = n.substr(e, 1);
  7589. if (e += t.length, t !== "(")
  7590. return null;
  7591. const l = Qn(n, e);
  7592. if (!l)
  7593. return null;
  7594. e = l.cursor, e += vn(n, e).length;
  7595. const v = n.substr(e, 1);
  7596. return e += v.length, v !== ")" ? null : {
  7597. evaluable: l.evaluable,
  7598. cursor: e
  7599. };
  7600. }
  7601. function wr(n, e) {
  7602. var t;
  7603. return (t = gs(n, e)) !== null && t !== void 0 ? t : Ze(n, e);
  7604. }
  7605. function _s(n, e) {
  7606. const t = wr(n, e);
  7607. if (t)
  7608. return t;
  7609. const l = n.substr(e, 1);
  7610. if (e += l.length, l !== "+" && l !== "-" && l !== "~")
  7611. return null;
  7612. const v = _s(n, e);
  7613. return v ? (e = v.cursor, {
  7614. cursor: e,
  7615. evaluable: new ur(l, v.evaluable)
  7616. }) : null;
  7617. }
  7618. function Mi(n, e, t) {
  7619. t += vn(e, t).length;
  7620. const l = n.filter((v) => e.startsWith(v, t))[0];
  7621. return l ? (t += l.length, t += vn(e, t).length, {
  7622. cursor: t,
  7623. operator: l
  7624. }) : null;
  7625. }
  7626. function yr(n, e) {
  7627. return (t, l) => {
  7628. const v = n(t, l);
  7629. if (!v)
  7630. return null;
  7631. l = v.cursor;
  7632. let E = v.evaluable;
  7633. for (; ; ) {
  7634. const k2 = Mi(e, t, l);
  7635. if (!k2)
  7636. break;
  7637. l = k2.cursor;
  7638. const B2 = n(t, l);
  7639. if (!B2)
  7640. return null;
  7641. l = B2.cursor, E = new cr(k2.operator, E, B2.evaluable);
  7642. }
  7643. return E ? {
  7644. cursor: l,
  7645. evaluable: E
  7646. } : null;
  7647. };
  7648. }
  7649. const Tt = [
  7650. ["**"],
  7651. ["*", "/", "%"],
  7652. ["+", "-"],
  7653. ["<<", ">>>", ">>"],
  7654. ["&"],
  7655. ["^"],
  7656. ["|"]
  7657. ].reduce((n, e) => yr(n, e), _s);
  7658. function Qn(n, e) {
  7659. return e += vn(n, e).length, Tt(n, e);
  7660. }
  7661. function xr(n) {
  7662. const e = Qn(n, 0);
  7663. return !e || e.cursor + vn(n, e.cursor).length !== n.length ? null : e.evaluable;
  7664. }
  7665. function lt2(n) {
  7666. var e;
  7667. const t = xr(n);
  7668. return (e = t == null ? void 0 : t.evaluate()) !== null && e !== void 0 ? e : null;
  7669. }
  7670. function ws(n) {
  7671. if (typeof n == "number")
  7672. return n;
  7673. if (typeof n == "string") {
  7674. const e = lt2(n);
  7675. if (!_(e))
  7676. return e;
  7677. }
  7678. return 0;
  7679. }
  7680. function Dt(n) {
  7681. return String(n);
  7682. }
  7683. function Ve(n) {
  7684. return (e) => e.toFixed(Math.max(Math.min(n, 20), 0));
  7685. }
  7686. const Si = Ve(0);
  7687. function gn(n) {
  7688. return Si(n) + "%";
  7689. }
  7690. function Ai(n) {
  7691. return String(n);
  7692. }
  7693. function ct2(n) {
  7694. return n;
  7695. }
  7696. function ys(n, e) {
  7697. for (; n.length < e; )
  7698. n.push(void 0);
  7699. }
  7700. function xs(n) {
  7701. const e = [];
  7702. return ys(e, n), te2(e);
  7703. }
  7704. function Es(n) {
  7705. const e = n.indexOf(void 0);
  7706. return e < 0 ? n : n.slice(0, e);
  7707. }
  7708. function Cs(n, e) {
  7709. const t = [...Es(n), e];
  7710. return t.length > n.length ? t.splice(0, t.length - n.length) : ys(t, n.length), t;
  7711. }
  7712. function $t({ primary: n, secondary: e, forward: t, backward: l }) {
  7713. let v = false;
  7714. function E(k2) {
  7715. v || (v = true, k2(), v = false);
  7716. }
  7717. n.emitter.on("change", (k2) => {
  7718. E(() => {
  7719. e.setRawValue(t(n, e), k2.options);
  7720. });
  7721. }), e.emitter.on("change", (k2) => {
  7722. E(() => {
  7723. n.setRawValue(l(n, e), k2.options);
  7724. }), E(() => {
  7725. e.setRawValue(t(n, e), k2.options);
  7726. });
  7727. }), E(() => {
  7728. e.setRawValue(t(n, e), {
  7729. forceEmit: false,
  7730. last: true
  7731. });
  7732. });
  7733. }
  7734. function Le(n, e) {
  7735. const t = n * (e.altKey ? 0.1 : 1) * (e.shiftKey ? 10 : 1);
  7736. return e.upKey ? +t : e.downKey ? -t : 0;
  7737. }
  7738. function Xt(n) {
  7739. return {
  7740. altKey: n.altKey,
  7741. downKey: n.key === "ArrowDown",
  7742. shiftKey: n.shiftKey,
  7743. upKey: n.key === "ArrowUp"
  7744. };
  7745. }
  7746. function nt(n) {
  7747. return {
  7748. altKey: n.altKey,
  7749. downKey: n.key === "ArrowLeft",
  7750. shiftKey: n.shiftKey,
  7751. upKey: n.key === "ArrowRight"
  7752. };
  7753. }
  7754. function Er(n) {
  7755. return n === "ArrowUp" || n === "ArrowDown";
  7756. }
  7757. function Li(n) {
  7758. return Er(n) || n === "ArrowLeft" || n === "ArrowRight";
  7759. }
  7760. function Zn(n, e) {
  7761. var t, l;
  7762. const v = e.ownerDocument.defaultView, E = e.getBoundingClientRect();
  7763. return {
  7764. x: n.pageX - (((t = v && v.scrollX) !== null && t !== void 0 ? t : 0) + E.left),
  7765. y: n.pageY - (((l = v && v.scrollY) !== null && l !== void 0 ? l : 0) + E.top)
  7766. };
  7767. }
  7768. class bt {
  7769. constructor(e) {
  7770. 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 F2(), e.addEventListener("touchstart", this.onTouchStart_, {
  7771. passive: false
  7772. }), e.addEventListener("touchmove", this.onTouchMove_, {
  7773. passive: true
  7774. }), e.addEventListener("touchend", this.onTouchEnd_), e.addEventListener("mousedown", this.onMouseDown_);
  7775. }
  7776. computePosition_(e) {
  7777. const t = this.elem_.getBoundingClientRect();
  7778. return {
  7779. bounds: {
  7780. width: t.width,
  7781. height: t.height
  7782. },
  7783. point: e ? {
  7784. x: e.x,
  7785. y: e.y
  7786. } : null
  7787. };
  7788. }
  7789. onMouseDown_(e) {
  7790. var t;
  7791. e.preventDefault(), (t = e.currentTarget) === null || t === void 0 || t.focus();
  7792. const l = this.elem_.ownerDocument;
  7793. l.addEventListener("mousemove", this.onDocumentMouseMove_), l.addEventListener("mouseup", this.onDocumentMouseUp_), this.emitter.emit("down", {
  7794. altKey: e.altKey,
  7795. data: this.computePosition_(Zn(e, this.elem_)),
  7796. sender: this,
  7797. shiftKey: e.shiftKey
  7798. });
  7799. }
  7800. onDocumentMouseMove_(e) {
  7801. this.emitter.emit("move", {
  7802. altKey: e.altKey,
  7803. data: this.computePosition_(Zn(e, this.elem_)),
  7804. sender: this,
  7805. shiftKey: e.shiftKey
  7806. });
  7807. }
  7808. onDocumentMouseUp_(e) {
  7809. const t = this.elem_.ownerDocument;
  7810. t.removeEventListener("mousemove", this.onDocumentMouseMove_), t.removeEventListener("mouseup", this.onDocumentMouseUp_), this.emitter.emit("up", {
  7811. altKey: e.altKey,
  7812. data: this.computePosition_(Zn(e, this.elem_)),
  7813. sender: this,
  7814. shiftKey: e.shiftKey
  7815. });
  7816. }
  7817. onTouchStart_(e) {
  7818. e.preventDefault();
  7819. const t = e.targetTouches.item(0), l = this.elem_.getBoundingClientRect();
  7820. this.emitter.emit("down", {
  7821. altKey: e.altKey,
  7822. data: this.computePosition_(t ? {
  7823. x: t.clientX - l.left,
  7824. y: t.clientY - l.top
  7825. } : void 0),
  7826. sender: this,
  7827. shiftKey: e.shiftKey
  7828. }), this.lastTouch_ = t;
  7829. }
  7830. onTouchMove_(e) {
  7831. const t = e.targetTouches.item(0), l = this.elem_.getBoundingClientRect();
  7832. this.emitter.emit("move", {
  7833. altKey: e.altKey,
  7834. data: this.computePosition_(t ? {
  7835. x: t.clientX - l.left,
  7836. y: t.clientY - l.top
  7837. } : void 0),
  7838. sender: this,
  7839. shiftKey: e.shiftKey
  7840. }), this.lastTouch_ = t;
  7841. }
  7842. onTouchEnd_(e) {
  7843. var t;
  7844. const l = (t = e.targetTouches.item(0)) !== null && t !== void 0 ? t : this.lastTouch_, v = this.elem_.getBoundingClientRect();
  7845. this.emitter.emit("up", {
  7846. altKey: e.altKey,
  7847. data: this.computePosition_(l ? {
  7848. x: l.clientX - v.left,
  7849. y: l.clientY - v.top
  7850. } : void 0),
  7851. sender: this,
  7852. shiftKey: e.shiftKey
  7853. });
  7854. }
  7855. }
  7856. function Ee2(n, e, t, l, v) {
  7857. const E = (n - e) / (t - e);
  7858. return l + E * (v - l);
  7859. }
  7860. function Ps(n) {
  7861. return String(n.toFixed(10)).split(".")[1].replace(/0+$/, "").length;
  7862. }
  7863. function Ae(n, e, t) {
  7864. return Math.min(Math.max(n, e), t);
  7865. }
  7866. function Ri(n, e) {
  7867. return (n % e + e) % e;
  7868. }
  7869. const Ye = D2("txt");
  7870. class _n {
  7871. constructor(e, t) {
  7872. 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);
  7873. const l = e.createElement("input");
  7874. 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"));
  7875. const v = e.createElement("div");
  7876. v.classList.add(Ye("k")), this.element.appendChild(v), this.knobElement = v;
  7877. const E = e.createElementNS(He, "svg");
  7878. E.classList.add(Ye("g")), this.knobElement.appendChild(E);
  7879. const k2 = e.createElementNS(He, "path");
  7880. k2.classList.add(Ye("gb")), E.appendChild(k2), this.guideBodyElem_ = k2;
  7881. const B2 = e.createElementNS(He, "path");
  7882. B2.classList.add(Ye("gh")), E.appendChild(B2), this.guideHeadElem_ = B2;
  7883. const Q = e.createElement("div");
  7884. Q.classList.add(D2("tt")()), this.knobElement.appendChild(Q), this.tooltipElem_ = Q, t.value.emitter.on("change", this.onChange_), this.value = t.value, this.refresh();
  7885. }
  7886. onDraggingChange_(e) {
  7887. if (e.rawValue === null) {
  7888. this.element.classList.remove(Ye(void 0, "drg"));
  7889. return;
  7890. }
  7891. this.element.classList.add(Ye(void 0, "drg"));
  7892. const t = e.rawValue / this.props_.get("draggingScale"), l = t + (t > 0 ? -1 : t < 0 ? 1 : 0), v = Ae(-l, -4, 4);
  7893. this.guideHeadElem_.setAttributeNS(null, "d", [`M ${l + v},0 L${l},4 L${l + v},8`, `M ${t},-1 L${t},9`].join(" ")), this.guideBodyElem_.setAttributeNS(null, "d", `M 0,4 L${t},4`);
  7894. const E = this.props_.get("formatter");
  7895. this.tooltipElem_.textContent = E(this.value.rawValue), this.tooltipElem_.style.left = `${t}px`;
  7896. }
  7897. refresh() {
  7898. const e = this.props_.get("formatter");
  7899. this.inputElement.value = e(this.value.rawValue);
  7900. }
  7901. onChange_() {
  7902. this.refresh();
  7903. }
  7904. }
  7905. class Yt {
  7906. constructor(e, t) {
  7907. var l;
  7908. 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_ = te2(null), this.view = new _n(e, {
  7909. arrayPosition: t.arrayPosition,
  7910. dragging: this.dragging_,
  7911. props: this.props,
  7912. value: this.value,
  7913. viewProps: this.viewProps
  7914. }), this.view.inputElement.addEventListener("change", this.onInputChange_), this.view.inputElement.addEventListener("keydown", this.onInputKeyDown_), this.view.inputElement.addEventListener("keyup", this.onInputKeyUp_);
  7915. const v = new bt(this.view.knobElement);
  7916. v.emitter.on("down", this.onPointerDown_), v.emitter.on("move", this.onPointerMove_), v.emitter.on("up", this.onPointerUp_);
  7917. }
  7918. constrainValue_(e) {
  7919. var t, l;
  7920. const v = (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");
  7921. let k2 = e;
  7922. return v !== void 0 && (k2 = Math.max(k2, v)), E !== void 0 && (k2 = Math.min(k2, E)), k2;
  7923. }
  7924. onInputChange_(e) {
  7925. const l = e.currentTarget.value, v = this.parser_(l);
  7926. _(v) || (this.value.rawValue = this.constrainValue_(v)), this.view.refresh();
  7927. }
  7928. onInputKeyDown_(e) {
  7929. const t = Le(this.baseStep_, Xt(e));
  7930. t !== 0 && this.value.setRawValue(this.constrainValue_(this.value.rawValue + t), {
  7931. forceEmit: false,
  7932. last: false
  7933. });
  7934. }
  7935. onInputKeyUp_(e) {
  7936. Le(this.baseStep_, Xt(e)) !== 0 && this.value.setRawValue(this.value.rawValue, {
  7937. forceEmit: true,
  7938. last: true
  7939. });
  7940. }
  7941. onPointerDown_() {
  7942. this.originRawValue_ = this.value.rawValue, this.dragging_.rawValue = 0;
  7943. }
  7944. computeDraggingValue_(e) {
  7945. if (!e.point)
  7946. return null;
  7947. const t = e.point.x - e.bounds.width / 2;
  7948. return this.constrainValue_(this.originRawValue_ + t * this.props.get("draggingScale"));
  7949. }
  7950. onPointerMove_(e) {
  7951. const t = this.computeDraggingValue_(e.data);
  7952. t !== null && (this.value.setRawValue(t, {
  7953. forceEmit: false,
  7954. last: false
  7955. }), this.dragging_.rawValue = this.value.rawValue - this.originRawValue_);
  7956. }
  7957. onPointerUp_(e) {
  7958. const t = this.computeDraggingValue_(e.data);
  7959. t !== null && (this.value.setRawValue(t, {
  7960. forceEmit: true,
  7961. last: true
  7962. }), this.dragging_.rawValue = null);
  7963. }
  7964. }
  7965. const wn = D2("sld");
  7966. class Cr {
  7967. constructor(e, t) {
  7968. 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(wn()), t.viewProps.bindClassModifiers(this.element);
  7969. const l = e.createElement("div");
  7970. l.classList.add(wn("t")), t.viewProps.bindTabIndex(l), this.element.appendChild(l), this.trackElement = l;
  7971. const v = e.createElement("div");
  7972. v.classList.add(wn("k")), this.trackElement.appendChild(v), this.knobElement = v, t.value.emitter.on("change", this.onChange_), this.value = t.value, this.update_();
  7973. }
  7974. update_() {
  7975. const e = Ae(Ee2(this.value.rawValue, this.props_.get("minValue"), this.props_.get("maxValue"), 0, 100), 0, 100);
  7976. this.knobElement.style.width = `${e}%`;
  7977. }
  7978. onChange_() {
  7979. this.update_();
  7980. }
  7981. }
  7982. class Pr {
  7983. constructor(e, t) {
  7984. 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 Cr(e, {
  7985. props: this.props,
  7986. value: this.value,
  7987. viewProps: this.viewProps
  7988. }), this.ptHandler_ = new bt(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_);
  7989. }
  7990. handlePointerEvent_(e, t) {
  7991. e.point && this.value.setRawValue(Ee2(Ae(e.point.x, 0, e.bounds.width), 0, e.bounds.width, this.props.get("minValue"), this.props.get("maxValue")), t);
  7992. }
  7993. onPointerDownOrMove_(e) {
  7994. this.handlePointerEvent_(e.data, {
  7995. forceEmit: false,
  7996. last: false
  7997. });
  7998. }
  7999. onPointerUp_(e) {
  8000. this.handlePointerEvent_(e.data, {
  8001. forceEmit: true,
  8002. last: true
  8003. });
  8004. }
  8005. onKeyDown_(e) {
  8006. const t = Le(this.baseStep_, nt(e));
  8007. t !== 0 && this.value.setRawValue(this.value.rawValue + t, {
  8008. forceEmit: false,
  8009. last: false
  8010. });
  8011. }
  8012. onKeyUp_(e) {
  8013. Le(this.baseStep_, nt(e)) !== 0 && this.value.setRawValue(this.value.rawValue, {
  8014. forceEmit: true,
  8015. last: true
  8016. });
  8017. }
  8018. }
  8019. const Be = D2("sldtxt");
  8020. class Ii {
  8021. constructor(e, t) {
  8022. this.element = e.createElement("div"), this.element.classList.add(Be());
  8023. const l = e.createElement("div");
  8024. l.classList.add(Be("s")), this.sliderView_ = t.sliderView, l.appendChild(this.sliderView_.element), this.element.appendChild(l);
  8025. const v = e.createElement("div");
  8026. v.classList.add(Be("t")), this.textView_ = t.textView, v.appendChild(this.textView_.element), this.element.appendChild(v);
  8027. }
  8028. }
  8029. class yn {
  8030. constructor(e, t) {
  8031. this.value = t.value, this.viewProps = t.viewProps, this.sliderC_ = new Pr(e, {
  8032. baseStep: t.baseStep,
  8033. props: t.sliderProps,
  8034. value: t.value,
  8035. viewProps: this.viewProps
  8036. }), this.textC_ = new Yt(e, {
  8037. baseStep: t.baseStep,
  8038. parser: t.parser,
  8039. props: t.textProps,
  8040. sliderProps: t.sliderProps,
  8041. value: t.value,
  8042. viewProps: t.viewProps
  8043. }), this.view = new Ii(e, {
  8044. sliderView: this.sliderC_.view,
  8045. textView: this.textC_.view
  8046. });
  8047. }
  8048. get sliderController() {
  8049. return this.sliderC_;
  8050. }
  8051. get textController() {
  8052. return this.textC_;
  8053. }
  8054. }
  8055. function Ot(n, e) {
  8056. n.write(e);
  8057. }
  8058. function xn(n) {
  8059. const e = M;
  8060. if (Array.isArray(n))
  8061. return e.required.array(e.required.object({
  8062. text: e.required.string,
  8063. value: e.required.raw
  8064. }))(n).value;
  8065. if (typeof n == "object")
  8066. return e.required.raw(n).value;
  8067. }
  8068. function kt(n) {
  8069. if (n === "inline" || n === "popup")
  8070. return n;
  8071. }
  8072. function gt2(n) {
  8073. const e = M;
  8074. return e.required.object({
  8075. max: e.optional.number,
  8076. min: e.optional.number,
  8077. step: e.optional.number
  8078. })(n).value;
  8079. }
  8080. function Vi(n) {
  8081. if (Array.isArray(n))
  8082. return n;
  8083. const e = [];
  8084. return Object.keys(n).forEach((t) => {
  8085. e.push({ text: t, value: n[t] });
  8086. }), e;
  8087. }
  8088. function Wn(n) {
  8089. return _(n) ? null : new at(Vi(n));
  8090. }
  8091. function Tr(n) {
  8092. const e = n ? we(n, Yn) : null;
  8093. return e ? e.step : null;
  8094. }
  8095. function Jn(n, e) {
  8096. const t = n && we(n, Yn);
  8097. return t ? Ps(t.step) : Math.max(Ps(e), 2);
  8098. }
  8099. function qt(n) {
  8100. const e = Tr(n);
  8101. return e ?? 1;
  8102. }
  8103. function Qt(n, e) {
  8104. var t;
  8105. const l = n && we(n, Yn), v = Math.abs((t = l == null ? void 0 : l.step) !== null && t !== void 0 ? t : e);
  8106. return v === 0 ? 0.1 : Math.pow(10, Math.floor(Math.log10(v)) - 1);
  8107. }
  8108. const En = D2("ckb");
  8109. class Ts {
  8110. constructor(e, t) {
  8111. this.onValueChange_ = this.onValueChange_.bind(this), this.element = e.createElement("div"), this.element.classList.add(En()), t.viewProps.bindClassModifiers(this.element);
  8112. const l = e.createElement("label");
  8113. l.classList.add(En("l")), this.element.appendChild(l);
  8114. const v = e.createElement("input");
  8115. v.classList.add(En("i")), v.type = "checkbox", l.appendChild(v), this.inputElement = v, t.viewProps.bindDisabled(this.inputElement);
  8116. const E = e.createElement("div");
  8117. E.classList.add(En("w")), l.appendChild(E);
  8118. const k2 = xt(e, "check");
  8119. E.appendChild(k2), t.value.emitter.on("change", this.onValueChange_), this.value = t.value, this.update_();
  8120. }
  8121. update_() {
  8122. this.inputElement.checked = this.value.rawValue;
  8123. }
  8124. onValueChange_() {
  8125. this.update_();
  8126. }
  8127. }
  8128. class ks {
  8129. constructor(e, t) {
  8130. this.onInputChange_ = this.onInputChange_.bind(this), this.value = t.value, this.viewProps = t.viewProps, this.view = new Ts(e, {
  8131. value: this.value,
  8132. viewProps: this.viewProps
  8133. }), this.view.inputElement.addEventListener("change", this.onInputChange_);
  8134. }
  8135. onInputChange_(e) {
  8136. const t = e.currentTarget;
  8137. this.value.rawValue = t.checked;
  8138. }
  8139. }
  8140. function Cn(n) {
  8141. const e = [], t = Wn(n.options);
  8142. return t && e.push(t), new Ct2(e);
  8143. }
  8144. const Ms = {
  8145. id: "input-bool",
  8146. type: "input",
  8147. accept: (n, e) => {
  8148. if (typeof n != "boolean")
  8149. return null;
  8150. const l = ce(e, {
  8151. options: M.optional.custom(xn)
  8152. });
  8153. return l ? {
  8154. initialValue: n,
  8155. params: l
  8156. } : null;
  8157. },
  8158. binding: {
  8159. reader: (n) => hs,
  8160. constraint: (n) => Cn(n.params),
  8161. writer: (n) => Ot
  8162. },
  8163. controller: (n) => {
  8164. const e = n.document, t = n.value, l = n.constraint, v = l && we(l, at);
  8165. return v ? new mn(e, {
  8166. props: new X2({
  8167. options: v.values.value("options")
  8168. }),
  8169. value: t,
  8170. viewProps: n.viewProps
  8171. }) : new ks(e, {
  8172. value: t,
  8173. viewProps: n.viewProps
  8174. });
  8175. }
  8176. }, Mt = D2("col");
  8177. class ei {
  8178. constructor(e, t) {
  8179. this.element = e.createElement("div"), this.element.classList.add(Mt()), t.foldable.bindExpandedClass(this.element, Mt(void 0, "expanded")), O(t.foldable, "completed", K(this.element, Mt(void 0, "cpl")));
  8180. const l = e.createElement("div");
  8181. l.classList.add(Mt("h")), this.element.appendChild(l);
  8182. const v = e.createElement("div");
  8183. v.classList.add(Mt("s")), l.appendChild(v), this.swatchElement = v;
  8184. const E = e.createElement("div");
  8185. if (E.classList.add(Mt("t")), l.appendChild(E), this.textElement = E, t.pickerLayout === "inline") {
  8186. const k2 = e.createElement("div");
  8187. k2.classList.add(Mt("p")), this.element.appendChild(k2), this.pickerElement = k2;
  8188. } else
  8189. this.pickerElement = null;
  8190. }
  8191. }
  8192. function kr(n, e, t) {
  8193. const l = Ae(n / 255, 0, 1), v = Ae(e / 255, 0, 1), E = Ae(t / 255, 0, 1), k2 = Math.max(l, v, E), B2 = Math.min(l, v, E), Q = k2 - B2;
  8194. let ee = 0, me2 = 0;
  8195. const be = (B2 + k2) / 2;
  8196. return Q !== 0 && (me2 = Q / (1 - Math.abs(k2 + B2 - 1)), l === k2 ? ee = (v - E) / Q : v === k2 ? ee = 2 + (E - l) / Q : ee = 4 + (l - v) / Q, ee = ee / 6 + (ee < 0 ? 1 : 0)), [ee * 360, me2 * 100, be * 100];
  8197. }
  8198. function Di(n, e, t) {
  8199. const l = (n % 360 + 360) % 360, v = Ae(e / 100, 0, 1), E = Ae(t / 100, 0, 1), k2 = (1 - Math.abs(2 * E - 1)) * v, B2 = k2 * (1 - Math.abs(l / 60 % 2 - 1)), Q = E - k2 / 2;
  8200. let ee, me2, be;
  8201. return l >= 0 && l < 60 ? [ee, me2, be] = [k2, B2, 0] : l >= 60 && l < 120 ? [ee, me2, be] = [B2, k2, 0] : l >= 120 && l < 180 ? [ee, me2, be] = [0, k2, B2] : l >= 180 && l < 240 ? [ee, me2, be] = [0, B2, k2] : l >= 240 && l < 300 ? [ee, me2, be] = [B2, 0, k2] : [ee, me2, be] = [k2, 0, B2], [(ee + Q) * 255, (me2 + Q) * 255, (be + Q) * 255];
  8202. }
  8203. function Mr(n, e, t) {
  8204. const l = Ae(n / 255, 0, 1), v = Ae(e / 255, 0, 1), E = Ae(t / 255, 0, 1), k2 = Math.max(l, v, E), B2 = Math.min(l, v, E), Q = k2 - B2;
  8205. let ee;
  8206. Q === 0 ? ee = 0 : k2 === l ? ee = 60 * (((v - E) / Q % 6 + 6) % 6) : k2 === v ? ee = 60 * ((E - l) / Q + 2) : ee = 60 * ((l - v) / Q + 4);
  8207. const me2 = k2 === 0 ? 0 : Q / k2, be = k2;
  8208. return [ee, me2 * 100, be * 100];
  8209. }
  8210. function Ss(n, e, t) {
  8211. const l = Ri(n, 360), v = Ae(e / 100, 0, 1), E = Ae(t / 100, 0, 1), k2 = E * v, B2 = k2 * (1 - Math.abs(l / 60 % 2 - 1)), Q = E - k2;
  8212. let ee, me2, be;
  8213. return l >= 0 && l < 60 ? [ee, me2, be] = [k2, B2, 0] : l >= 60 && l < 120 ? [ee, me2, be] = [B2, k2, 0] : l >= 120 && l < 180 ? [ee, me2, be] = [0, k2, B2] : l >= 180 && l < 240 ? [ee, me2, be] = [0, B2, k2] : l >= 240 && l < 300 ? [ee, me2, be] = [B2, 0, k2] : [ee, me2, be] = [k2, 0, B2], [(ee + Q) * 255, (me2 + Q) * 255, (be + Q) * 255];
  8214. }
  8215. function Sr(n, e, t) {
  8216. const l = t + e * (100 - Math.abs(2 * t - 100)) / 200;
  8217. return [
  8218. n,
  8219. l !== 0 ? e * (100 - Math.abs(2 * t - 100)) / l : 0,
  8220. t + e * (100 - Math.abs(2 * t - 100)) / (2 * 100)
  8221. ];
  8222. }
  8223. function Ar(n, e, t) {
  8224. const l = 100 - Math.abs(t * (200 - e) / 100 - 100);
  8225. return [n, l !== 0 ? e * t / l : 0, t * (200 - e) / (2 * 100)];
  8226. }
  8227. function d(n) {
  8228. return [n[0], n[1], n[2]];
  8229. }
  8230. function o(n, e) {
  8231. return [n[0], n[1], n[2], e];
  8232. }
  8233. const p = {
  8234. hsl: {
  8235. hsl: (n, e, t) => [n, e, t],
  8236. hsv: Sr,
  8237. rgb: Di
  8238. },
  8239. hsv: {
  8240. hsl: Ar,
  8241. hsv: (n, e, t) => [n, e, t],
  8242. rgb: Ss
  8243. },
  8244. rgb: {
  8245. hsl: kr,
  8246. hsv: Mr,
  8247. rgb: (n, e, t) => [n, e, t]
  8248. }
  8249. };
  8250. function f(n, e) {
  8251. return [
  8252. e === "float" ? 1 : n === "rgb" ? 255 : 360,
  8253. e === "float" ? 1 : n === "rgb" ? 255 : 100,
  8254. e === "float" ? 1 : n === "rgb" ? 255 : 100
  8255. ];
  8256. }
  8257. function x(n, e) {
  8258. return n === e ? e : Ri(n, e);
  8259. }
  8260. function T(n, e, t) {
  8261. var l;
  8262. const v = f(e, t);
  8263. return [
  8264. e === "rgb" ? Ae(n[0], 0, v[0]) : x(n[0], v[0]),
  8265. Ae(n[1], 0, v[1]),
  8266. Ae(n[2], 0, v[2]),
  8267. Ae((l = n[3]) !== null && l !== void 0 ? l : 1, 0, 1)
  8268. ];
  8269. }
  8270. function L(n, e, t, l) {
  8271. const v = f(e, t), E = f(e, l);
  8272. return n.map((k2, B2) => k2 / v[B2] * E[B2]);
  8273. }
  8274. function z(n, e, t) {
  8275. const l = L(n, e.mode, e.type, "int"), v = p[e.mode][t.mode](...l);
  8276. return L(v, t.mode, "int", t.type);
  8277. }
  8278. function re(n, e) {
  8279. return typeof n != "object" || _(n) ? false : e in n && typeof n[e] == "number";
  8280. }
  8281. class W2 {
  8282. constructor(e, t, l = "int") {
  8283. this.mode = t, this.type = l, this.comps_ = T(e, t, l);
  8284. }
  8285. static black(e = "int") {
  8286. return new W2([0, 0, 0], "rgb", e);
  8287. }
  8288. static fromObject(e, t = "int") {
  8289. const l = "a" in e ? [e.r, e.g, e.b, e.a] : [e.r, e.g, e.b];
  8290. return new W2(l, "rgb", t);
  8291. }
  8292. static toRgbaObject(e, t = "int") {
  8293. return e.toRgbaObject(t);
  8294. }
  8295. static isRgbColorObject(e) {
  8296. return re(e, "r") && re(e, "g") && re(e, "b");
  8297. }
  8298. static isRgbaColorObject(e) {
  8299. return this.isRgbColorObject(e) && re(e, "a");
  8300. }
  8301. static isColorObject(e) {
  8302. return this.isRgbColorObject(e);
  8303. }
  8304. static equals(e, t) {
  8305. if (e.mode !== t.mode)
  8306. return false;
  8307. const l = e.comps_, v = t.comps_;
  8308. for (let E = 0; E < l.length; E++)
  8309. if (l[E] !== v[E])
  8310. return false;
  8311. return true;
  8312. }
  8313. getComponents(e, t = "int") {
  8314. return o(z(d(this.comps_), { mode: this.mode, type: this.type }, { mode: e ?? this.mode, type: t }), this.comps_[3]);
  8315. }
  8316. toRgbaObject(e = "int") {
  8317. const t = this.getComponents("rgb", e);
  8318. return {
  8319. r: t[0],
  8320. g: t[1],
  8321. b: t[2],
  8322. a: t[3]
  8323. };
  8324. }
  8325. }
  8326. const Fe = D2("colp");
  8327. class Oi {
  8328. constructor(e, t) {
  8329. this.alphaViews_ = null, this.element = e.createElement("div"), this.element.classList.add(Fe()), t.viewProps.bindClassModifiers(this.element);
  8330. const l = e.createElement("div");
  8331. l.classList.add(Fe("hsv"));
  8332. const v = e.createElement("div");
  8333. v.classList.add(Fe("sv")), this.svPaletteView_ = t.svPaletteView, v.appendChild(this.svPaletteView_.element), l.appendChild(v);
  8334. const E = e.createElement("div");
  8335. E.classList.add(Fe("h")), this.hPaletteView_ = t.hPaletteView, E.appendChild(this.hPaletteView_.element), l.appendChild(E), this.element.appendChild(l);
  8336. const k2 = e.createElement("div");
  8337. if (k2.classList.add(Fe("rgb")), this.textView_ = t.textView, k2.appendChild(this.textView_.element), this.element.appendChild(k2), t.alphaViews) {
  8338. this.alphaViews_ = {
  8339. palette: t.alphaViews.palette,
  8340. text: t.alphaViews.text
  8341. };
  8342. const B2 = e.createElement("div");
  8343. B2.classList.add(Fe("a"));
  8344. const Q = e.createElement("div");
  8345. Q.classList.add(Fe("ap")), Q.appendChild(this.alphaViews_.palette.element), B2.appendChild(Q);
  8346. const ee = e.createElement("div");
  8347. ee.classList.add(Fe("at")), ee.appendChild(this.alphaViews_.text.element), B2.appendChild(ee), this.element.appendChild(B2);
  8348. }
  8349. }
  8350. get allFocusableElements() {
  8351. const e = [
  8352. this.svPaletteView_.element,
  8353. this.hPaletteView_.element,
  8354. this.textView_.modeSelectElement,
  8355. ...this.textView_.textViews.map((t) => t.inputElement)
  8356. ];
  8357. return this.alphaViews_ && e.push(this.alphaViews_.palette.element, this.alphaViews_.text.inputElement), e;
  8358. }
  8359. }
  8360. function Lr(n) {
  8361. return n === "int" ? "int" : n === "float" ? "float" : void 0;
  8362. }
  8363. function Ni(n) {
  8364. const e = M;
  8365. return ce(n, {
  8366. alpha: e.optional.boolean,
  8367. color: e.optional.object({
  8368. alpha: e.optional.boolean,
  8369. type: e.optional.custom(Lr)
  8370. }),
  8371. expanded: e.optional.boolean,
  8372. picker: e.optional.custom(kt)
  8373. });
  8374. }
  8375. function Pn(n) {
  8376. return n ? 0.1 : 1;
  8377. }
  8378. function Tn(n) {
  8379. var e;
  8380. return (e = n.color) === null || e === void 0 ? void 0 : e.type;
  8381. }
  8382. function sl(n, e) {
  8383. return n.alpha === e.alpha && n.mode === e.mode && n.notation === e.notation && n.type === e.type;
  8384. }
  8385. function pt2(n, e) {
  8386. const t = n.match(/^(.+)%$/);
  8387. return Math.min(t ? parseFloat(t[1]) * 0.01 * e : parseFloat(n), e);
  8388. }
  8389. const rl = {
  8390. deg: (n) => n,
  8391. grad: (n) => n * 360 / 400,
  8392. rad: (n) => n * 360 / (2 * Math.PI),
  8393. turn: (n) => n * 360
  8394. };
  8395. function xo(n) {
  8396. const e = n.match(/^([0-9.]+?)(deg|grad|rad|turn)$/);
  8397. if (!e)
  8398. return parseFloat(n);
  8399. const t = parseFloat(e[1]), l = e[2];
  8400. return rl[l](t);
  8401. }
  8402. function Eo(n) {
  8403. const e = n.match(/^rgb\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);
  8404. if (!e)
  8405. return null;
  8406. const t = [
  8407. pt2(e[1], 255),
  8408. pt2(e[2], 255),
  8409. pt2(e[3], 255)
  8410. ];
  8411. return isNaN(t[0]) || isNaN(t[1]) || isNaN(t[2]) ? null : t;
  8412. }
  8413. function Co(n) {
  8414. return (e) => {
  8415. const t = Eo(e);
  8416. return t ? new W2(t, "rgb", n) : null;
  8417. };
  8418. }
  8419. function Po(n) {
  8420. 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*\)$/);
  8421. if (!e)
  8422. return null;
  8423. const t = [
  8424. pt2(e[1], 255),
  8425. pt2(e[2], 255),
  8426. pt2(e[3], 255),
  8427. pt2(e[4], 1)
  8428. ];
  8429. return isNaN(t[0]) || isNaN(t[1]) || isNaN(t[2]) || isNaN(t[3]) ? null : t;
  8430. }
  8431. function To(n) {
  8432. return (e) => {
  8433. const t = Po(e);
  8434. return t ? new W2(t, "rgb", n) : null;
  8435. };
  8436. }
  8437. function ko(n) {
  8438. 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*\)$/);
  8439. if (!e)
  8440. return null;
  8441. const t = [
  8442. xo(e[1]),
  8443. pt2(e[2], 100),
  8444. pt2(e[3], 100)
  8445. ];
  8446. return isNaN(t[0]) || isNaN(t[1]) || isNaN(t[2]) ? null : t;
  8447. }
  8448. function Mo(n) {
  8449. return (e) => {
  8450. const t = ko(e);
  8451. return t ? new W2(t, "hsl", n) : null;
  8452. };
  8453. }
  8454. function So(n) {
  8455. 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*\)$/);
  8456. if (!e)
  8457. return null;
  8458. const t = [
  8459. xo(e[1]),
  8460. pt2(e[2], 100),
  8461. pt2(e[3], 100),
  8462. pt2(e[4], 1)
  8463. ];
  8464. return isNaN(t[0]) || isNaN(t[1]) || isNaN(t[2]) || isNaN(t[3]) ? null : t;
  8465. }
  8466. function Ao(n) {
  8467. return (e) => {
  8468. const t = So(e);
  8469. return t ? new W2(t, "hsl", n) : null;
  8470. };
  8471. }
  8472. function Lo(n) {
  8473. const e = n.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);
  8474. if (e)
  8475. return [
  8476. parseInt(e[1] + e[1], 16),
  8477. parseInt(e[2] + e[2], 16),
  8478. parseInt(e[3] + e[3], 16)
  8479. ];
  8480. const t = n.match(/^(?:#|0x)([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);
  8481. return t ? [
  8482. parseInt(t[1], 16),
  8483. parseInt(t[2], 16),
  8484. parseInt(t[3], 16)
  8485. ] : null;
  8486. }
  8487. function ol(n) {
  8488. const e = Lo(n);
  8489. return e ? new W2(e, "rgb", "int") : null;
  8490. }
  8491. function Ro(n) {
  8492. const e = n.match(/^#?([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);
  8493. if (e)
  8494. return [
  8495. parseInt(e[1] + e[1], 16),
  8496. parseInt(e[2] + e[2], 16),
  8497. parseInt(e[3] + e[3], 16),
  8498. Ee2(parseInt(e[4] + e[4], 16), 0, 255, 0, 1)
  8499. ];
  8500. 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})$/);
  8501. return t ? [
  8502. parseInt(t[1], 16),
  8503. parseInt(t[2], 16),
  8504. parseInt(t[3], 16),
  8505. Ee2(parseInt(t[4], 16), 0, 255, 0, 1)
  8506. ] : null;
  8507. }
  8508. function al(n) {
  8509. const e = Ro(n);
  8510. return e ? new W2(e, "rgb", "int") : null;
  8511. }
  8512. function Io(n) {
  8513. 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*\}$/);
  8514. if (!e)
  8515. return null;
  8516. const t = [
  8517. parseFloat(e[1]),
  8518. parseFloat(e[2]),
  8519. parseFloat(e[3])
  8520. ];
  8521. return isNaN(t[0]) || isNaN(t[1]) || isNaN(t[2]) ? null : t;
  8522. }
  8523. function Vo(n) {
  8524. return (e) => {
  8525. const t = Io(e);
  8526. return t ? new W2(t, "rgb", n) : null;
  8527. };
  8528. }
  8529. function Do(n) {
  8530. 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*\}$/);
  8531. if (!e)
  8532. return null;
  8533. const t = [
  8534. parseFloat(e[1]),
  8535. parseFloat(e[2]),
  8536. parseFloat(e[3]),
  8537. parseFloat(e[4])
  8538. ];
  8539. return isNaN(t[0]) || isNaN(t[1]) || isNaN(t[2]) || isNaN(t[3]) ? null : t;
  8540. }
  8541. function Oo(n) {
  8542. return (e) => {
  8543. const t = Do(e);
  8544. return t ? new W2(t, "rgb", n) : null;
  8545. };
  8546. }
  8547. const ll = [
  8548. {
  8549. parser: Lo,
  8550. result: {
  8551. alpha: false,
  8552. mode: "rgb",
  8553. notation: "hex"
  8554. }
  8555. },
  8556. {
  8557. parser: Ro,
  8558. result: {
  8559. alpha: true,
  8560. mode: "rgb",
  8561. notation: "hex"
  8562. }
  8563. },
  8564. {
  8565. parser: Eo,
  8566. result: {
  8567. alpha: false,
  8568. mode: "rgb",
  8569. notation: "func"
  8570. }
  8571. },
  8572. {
  8573. parser: Po,
  8574. result: {
  8575. alpha: true,
  8576. mode: "rgb",
  8577. notation: "func"
  8578. }
  8579. },
  8580. {
  8581. parser: ko,
  8582. result: {
  8583. alpha: false,
  8584. mode: "hsl",
  8585. notation: "func"
  8586. }
  8587. },
  8588. {
  8589. parser: So,
  8590. result: {
  8591. alpha: true,
  8592. mode: "hsl",
  8593. notation: "func"
  8594. }
  8595. },
  8596. {
  8597. parser: Io,
  8598. result: {
  8599. alpha: false,
  8600. mode: "rgb",
  8601. notation: "object"
  8602. }
  8603. },
  8604. {
  8605. parser: Do,
  8606. result: {
  8607. alpha: true,
  8608. mode: "rgb",
  8609. notation: "object"
  8610. }
  8611. }
  8612. ];
  8613. function cl(n) {
  8614. return ll.reduce((e, { parser: t, result: l }) => e || (t(n) ? l : null), null);
  8615. }
  8616. function Rr(n, e = "int") {
  8617. const t = cl(n);
  8618. 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;
  8619. }
  8620. const No = {
  8621. int: [
  8622. ol,
  8623. al,
  8624. Co("int"),
  8625. To("int"),
  8626. Mo("int"),
  8627. Ao("int"),
  8628. Vo("int"),
  8629. Oo("int")
  8630. ],
  8631. float: [
  8632. Co("float"),
  8633. To("float"),
  8634. Mo("float"),
  8635. Ao("float"),
  8636. Vo("float"),
  8637. Oo("float")
  8638. ]
  8639. };
  8640. function pl(n) {
  8641. const e = No[n];
  8642. return (t) => {
  8643. if (typeof t != "string")
  8644. return W2.black(n);
  8645. const l = e.reduce((v, E) => v || E(t), null);
  8646. return l ?? W2.black(n);
  8647. };
  8648. }
  8649. function Ir(n) {
  8650. const e = No[n];
  8651. return (t) => e.reduce((l, v) => l || v(t), null);
  8652. }
  8653. function Fo(n) {
  8654. const e = Ae(Math.floor(n), 0, 255).toString(16);
  8655. return e.length === 1 ? `0${e}` : e;
  8656. }
  8657. function Bo(n, e = "#") {
  8658. const t = d(n.getComponents("rgb")).map(Fo).join("");
  8659. return `${e}${t}`;
  8660. }
  8661. function Vr(n, e = "#") {
  8662. const t = n.getComponents("rgb"), l = [t[0], t[1], t[2], t[3] * 255].map(Fo).join("");
  8663. return `${e}${l}`;
  8664. }
  8665. function jo(n, e) {
  8666. const t = Ve(e === "float" ? 2 : 0);
  8667. return `rgb(${d(n.getComponents("rgb", e)).map((v) => t(v)).join(", ")})`;
  8668. }
  8669. function ul(n) {
  8670. return (e) => jo(e, n);
  8671. }
  8672. function As(n, e) {
  8673. const t = Ve(2), l = Ve(e === "float" ? 2 : 0);
  8674. return `rgba(${n.getComponents("rgb", e).map((E, k2) => (k2 === 3 ? t : l)(E)).join(", ")})`;
  8675. }
  8676. function hl(n) {
  8677. return (e) => As(e, n);
  8678. }
  8679. function dl(n) {
  8680. const e = [
  8681. Ve(0),
  8682. gn,
  8683. gn
  8684. ];
  8685. return `hsl(${d(n.getComponents("hsl")).map((l, v) => e[v](l)).join(", ")})`;
  8686. }
  8687. function ml(n) {
  8688. const e = [
  8689. Ve(0),
  8690. gn,
  8691. gn,
  8692. Ve(2)
  8693. ];
  8694. return `hsla(${n.getComponents("hsl").map((l, v) => e[v](l)).join(", ")})`;
  8695. }
  8696. function zo(n, e) {
  8697. const t = Ve(e === "float" ? 2 : 0), l = ["r", "g", "b"];
  8698. return `{${d(n.getComponents("rgb", e)).map((E, k2) => `${l[k2]}: ${t(E)}`).join(", ")}}`;
  8699. }
  8700. function fl(n) {
  8701. return (e) => zo(e, n);
  8702. }
  8703. function Uo(n, e) {
  8704. const t = Ve(2), l = Ve(e === "float" ? 2 : 0), v = ["r", "g", "b", "a"];
  8705. return `{${n.getComponents("rgb", e).map((k2, B2) => {
  8706. const Q = B2 === 3 ? t : l;
  8707. return `${v[B2]}: ${Q(k2)}`;
  8708. }).join(", ")}}`;
  8709. }
  8710. function vl(n) {
  8711. return (e) => Uo(e, n);
  8712. }
  8713. const bl = [
  8714. {
  8715. format: {
  8716. alpha: false,
  8717. mode: "rgb",
  8718. notation: "hex",
  8719. type: "int"
  8720. },
  8721. stringifier: Bo
  8722. },
  8723. {
  8724. format: {
  8725. alpha: true,
  8726. mode: "rgb",
  8727. notation: "hex",
  8728. type: "int"
  8729. },
  8730. stringifier: Vr
  8731. },
  8732. {
  8733. format: {
  8734. alpha: false,
  8735. mode: "hsl",
  8736. notation: "func",
  8737. type: "int"
  8738. },
  8739. stringifier: dl
  8740. },
  8741. {
  8742. format: {
  8743. alpha: true,
  8744. mode: "hsl",
  8745. notation: "func",
  8746. type: "int"
  8747. },
  8748. stringifier: ml
  8749. },
  8750. ...["int", "float"].reduce((n, e) => [
  8751. ...n,
  8752. {
  8753. format: {
  8754. alpha: false,
  8755. mode: "rgb",
  8756. notation: "func",
  8757. type: e
  8758. },
  8759. stringifier: ul(e)
  8760. },
  8761. {
  8762. format: {
  8763. alpha: true,
  8764. mode: "rgb",
  8765. notation: "func",
  8766. type: e
  8767. },
  8768. stringifier: hl(e)
  8769. },
  8770. {
  8771. format: {
  8772. alpha: false,
  8773. mode: "rgb",
  8774. notation: "object",
  8775. type: e
  8776. },
  8777. stringifier: fl(e)
  8778. },
  8779. {
  8780. format: {
  8781. alpha: true,
  8782. mode: "rgb",
  8783. notation: "object",
  8784. type: e
  8785. },
  8786. stringifier: vl(e)
  8787. }
  8788. ], [])
  8789. ];
  8790. function Dr(n) {
  8791. return bl.reduce((e, t) => e || (sl(t.format, n) ? t.stringifier : null), null);
  8792. }
  8793. const Fi = D2("apl");
  8794. class gl {
  8795. constructor(e, t) {
  8796. 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(Fi()), t.viewProps.bindClassModifiers(this.element), t.viewProps.bindTabIndex(this.element);
  8797. const l = e.createElement("div");
  8798. l.classList.add(Fi("b")), this.element.appendChild(l);
  8799. const v = e.createElement("div");
  8800. v.classList.add(Fi("c")), l.appendChild(v), this.colorElem_ = v;
  8801. const E = e.createElement("div");
  8802. E.classList.add(Fi("m")), this.element.appendChild(E), this.markerElem_ = E;
  8803. const k2 = e.createElement("div");
  8804. k2.classList.add(Fi("p")), this.markerElem_.appendChild(k2), this.previewElem_ = k2, this.update_();
  8805. }
  8806. update_() {
  8807. const e = this.value.rawValue, t = e.getComponents("rgb"), l = new W2([t[0], t[1], t[2], 0], "rgb"), v = new W2([t[0], t[1], t[2], 255], "rgb"), E = [
  8808. "to right",
  8809. As(l),
  8810. As(v)
  8811. ];
  8812. this.colorElem_.style.background = `linear-gradient(${E.join(",")})`, this.previewElem_.style.backgroundColor = As(e);
  8813. const k2 = Ee2(t[3], 0, 1, 0, 100);
  8814. this.markerElem_.style.left = `${k2}%`;
  8815. }
  8816. onValueChange_() {
  8817. this.update_();
  8818. }
  8819. }
  8820. class _l {
  8821. constructor(e, t) {
  8822. 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 gl(e, {
  8823. value: this.value,
  8824. viewProps: this.viewProps
  8825. }), this.ptHandler_ = new bt(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_);
  8826. }
  8827. handlePointerEvent_(e, t) {
  8828. if (!e.point)
  8829. return;
  8830. const l = e.point.x / e.bounds.width, v = this.value.rawValue, [E, k2, B2] = v.getComponents("hsv");
  8831. this.value.setRawValue(new W2([E, k2, B2, l], "hsv"), t);
  8832. }
  8833. onPointerDown_(e) {
  8834. this.handlePointerEvent_(e.data, {
  8835. forceEmit: false,
  8836. last: false
  8837. });
  8838. }
  8839. onPointerMove_(e) {
  8840. this.handlePointerEvent_(e.data, {
  8841. forceEmit: false,
  8842. last: false
  8843. });
  8844. }
  8845. onPointerUp_(e) {
  8846. this.handlePointerEvent_(e.data, {
  8847. forceEmit: true,
  8848. last: true
  8849. });
  8850. }
  8851. onKeyDown_(e) {
  8852. const t = Le(Pn(true), nt(e));
  8853. if (t === 0)
  8854. return;
  8855. const l = this.value.rawValue, [v, E, k2, B2] = l.getComponents("hsv");
  8856. this.value.setRawValue(new W2([v, E, k2, B2 + t], "hsv"), {
  8857. forceEmit: false,
  8858. last: false
  8859. });
  8860. }
  8861. onKeyUp_(e) {
  8862. Le(Pn(true), nt(e)) !== 0 && this.value.setRawValue(this.value.rawValue, {
  8863. forceEmit: true,
  8864. last: true
  8865. });
  8866. }
  8867. }
  8868. const ti = D2("coltxt");
  8869. function wl(n) {
  8870. const e = n.createElement("select"), t = [
  8871. { text: "RGB", value: "rgb" },
  8872. { text: "HSL", value: "hsl" },
  8873. { text: "HSV", value: "hsv" }
  8874. ];
  8875. return e.appendChild(t.reduce((l, v) => {
  8876. const E = n.createElement("option");
  8877. return E.textContent = v.text, E.value = v.value, l.appendChild(E), l;
  8878. }, n.createDocumentFragment())), e;
  8879. }
  8880. class yl {
  8881. constructor(e, t) {
  8882. this.element = e.createElement("div"), this.element.classList.add(ti()), t.viewProps.bindClassModifiers(this.element);
  8883. const l = e.createElement("div");
  8884. l.classList.add(ti("m")), this.modeElem_ = wl(e), this.modeElem_.classList.add(ti("ms")), l.appendChild(this.modeSelectElement), t.viewProps.bindDisabled(this.modeElem_);
  8885. const v = e.createElement("div");
  8886. v.classList.add(ti("mm")), v.appendChild(xt(e, "dropdown")), l.appendChild(v), this.element.appendChild(l);
  8887. const E = e.createElement("div");
  8888. E.classList.add(ti("w")), this.element.appendChild(E), this.textsElem_ = E, this.textViews_ = t.textViews, this.applyTextViews_(), N2(t.colorMode, (k2) => {
  8889. this.modeElem_.value = k2;
  8890. });
  8891. }
  8892. get modeSelectElement() {
  8893. return this.modeElem_;
  8894. }
  8895. get textViews() {
  8896. return this.textViews_;
  8897. }
  8898. set textViews(e) {
  8899. this.textViews_ = e, this.applyTextViews_();
  8900. }
  8901. applyTextViews_() {
  8902. ln(this.textsElem_);
  8903. const e = this.element.ownerDocument;
  8904. this.textViews_.forEach((t) => {
  8905. const l = e.createElement("div");
  8906. l.classList.add(ti("c")), l.appendChild(t.element), this.textsElem_.appendChild(l);
  8907. });
  8908. }
  8909. }
  8910. function xl(n) {
  8911. return Ve(n === "float" ? 2 : 0);
  8912. }
  8913. function El(n, e, t) {
  8914. const l = f(n, e)[t];
  8915. return new Vt({
  8916. min: 0,
  8917. max: l
  8918. });
  8919. }
  8920. function Or(n, e, t) {
  8921. return new Yt(n, {
  8922. arrayPosition: t === 0 ? "fst" : t === 3 - 1 ? "lst" : "mid",
  8923. baseStep: Pn(false),
  8924. parser: e.parser,
  8925. props: X2.fromObject({
  8926. draggingScale: e.colorType === "float" ? 0.01 : 1,
  8927. formatter: xl(e.colorType)
  8928. }),
  8929. value: te2(0, {
  8930. constraint: El(e.colorMode, e.colorType, t)
  8931. }),
  8932. viewProps: e.viewProps
  8933. });
  8934. }
  8935. class Cl {
  8936. constructor(e, t) {
  8937. this.onModeSelectChange_ = this.onModeSelectChange_.bind(this), this.colorType_ = t.colorType, this.parser_ = t.parser, this.value = t.value, this.viewProps = t.viewProps, this.colorMode = te2(this.value.rawValue.mode), this.ccs_ = this.createComponentControllers_(e), this.view = new yl(e, {
  8938. colorMode: this.colorMode,
  8939. textViews: [this.ccs_[0].view, this.ccs_[1].view, this.ccs_[2].view],
  8940. viewProps: this.viewProps
  8941. }), this.view.modeSelectElement.addEventListener("change", this.onModeSelectChange_);
  8942. }
  8943. createComponentControllers_(e) {
  8944. const t = {
  8945. colorMode: this.colorMode.rawValue,
  8946. colorType: this.colorType_,
  8947. parser: this.parser_,
  8948. viewProps: this.viewProps
  8949. }, l = [
  8950. Or(e, t, 0),
  8951. Or(e, t, 1),
  8952. Or(e, t, 2)
  8953. ];
  8954. return l.forEach((v, E) => {
  8955. $t({
  8956. primary: this.value,
  8957. secondary: v.value,
  8958. forward: (k2) => k2.rawValue.getComponents(this.colorMode.rawValue, this.colorType_)[E],
  8959. backward: (k2, B2) => {
  8960. const Q = this.colorMode.rawValue, ee = k2.rawValue.getComponents(Q, this.colorType_);
  8961. return ee[E] = B2.rawValue, new W2(o(d(ee), ee[3]), Q, this.colorType_);
  8962. }
  8963. });
  8964. }), l;
  8965. }
  8966. onModeSelectChange_(e) {
  8967. const t = e.currentTarget;
  8968. this.colorMode.rawValue = t.value, this.ccs_ = this.createComponentControllers_(this.view.element.ownerDocument), this.view.textViews = [
  8969. this.ccs_[0].view,
  8970. this.ccs_[1].view,
  8971. this.ccs_[2].view
  8972. ];
  8973. }
  8974. }
  8975. const Nr = D2("hpl");
  8976. class Pl {
  8977. constructor(e, t) {
  8978. 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(Nr()), t.viewProps.bindClassModifiers(this.element), t.viewProps.bindTabIndex(this.element);
  8979. const l = e.createElement("div");
  8980. l.classList.add(Nr("c")), this.element.appendChild(l);
  8981. const v = e.createElement("div");
  8982. v.classList.add(Nr("m")), this.element.appendChild(v), this.markerElem_ = v, this.update_();
  8983. }
  8984. update_() {
  8985. const e = this.value.rawValue, [t] = e.getComponents("hsv");
  8986. this.markerElem_.style.backgroundColor = jo(new W2([t, 100, 100], "hsv"));
  8987. const l = Ee2(t, 0, 360, 0, 100);
  8988. this.markerElem_.style.left = `${l}%`;
  8989. }
  8990. onValueChange_() {
  8991. this.update_();
  8992. }
  8993. }
  8994. class Tl {
  8995. constructor(e, t) {
  8996. 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 Pl(e, {
  8997. value: this.value,
  8998. viewProps: this.viewProps
  8999. }), this.ptHandler_ = new bt(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_);
  9000. }
  9001. handlePointerEvent_(e, t) {
  9002. if (!e.point)
  9003. return;
  9004. const l = Ee2(Ae(e.point.x, 0, e.bounds.width), 0, e.bounds.width, 0, 360), v = this.value.rawValue, [, E, k2, B2] = v.getComponents("hsv");
  9005. this.value.setRawValue(new W2([l, E, k2, B2], "hsv"), t);
  9006. }
  9007. onPointerDown_(e) {
  9008. this.handlePointerEvent_(e.data, {
  9009. forceEmit: false,
  9010. last: false
  9011. });
  9012. }
  9013. onPointerMove_(e) {
  9014. this.handlePointerEvent_(e.data, {
  9015. forceEmit: false,
  9016. last: false
  9017. });
  9018. }
  9019. onPointerUp_(e) {
  9020. this.handlePointerEvent_(e.data, {
  9021. forceEmit: true,
  9022. last: true
  9023. });
  9024. }
  9025. onKeyDown_(e) {
  9026. const t = Le(Pn(false), nt(e));
  9027. if (t === 0)
  9028. return;
  9029. const l = this.value.rawValue, [v, E, k2, B2] = l.getComponents("hsv");
  9030. this.value.setRawValue(new W2([v + t, E, k2, B2], "hsv"), {
  9031. forceEmit: false,
  9032. last: false
  9033. });
  9034. }
  9035. onKeyUp_(e) {
  9036. Le(Pn(false), nt(e)) !== 0 && this.value.setRawValue(this.value.rawValue, {
  9037. forceEmit: true,
  9038. last: true
  9039. });
  9040. }
  9041. }
  9042. const Fr = D2("svp"), Go = 64;
  9043. class kl {
  9044. constructor(e, t) {
  9045. 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(Fr()), t.viewProps.bindClassModifiers(this.element), t.viewProps.bindTabIndex(this.element);
  9046. const l = e.createElement("canvas");
  9047. l.height = Go, l.width = Go, l.classList.add(Fr("c")), this.element.appendChild(l), this.canvasElement = l;
  9048. const v = e.createElement("div");
  9049. v.classList.add(Fr("m")), this.element.appendChild(v), this.markerElem_ = v, this.update_();
  9050. }
  9051. update_() {
  9052. const e = zn(this.canvasElement);
  9053. if (!e)
  9054. return;
  9055. const l = this.value.rawValue.getComponents("hsv"), v = this.canvasElement.width, E = this.canvasElement.height, k2 = e.getImageData(0, 0, v, E), B2 = k2.data;
  9056. for (let me2 = 0; me2 < E; me2++)
  9057. for (let be = 0; be < v; be++) {
  9058. const Ft = Ee2(be, 0, v, 0, 100), ji = Ee2(me2, 0, E, 100, 0), zi = Ss(l[0], Ft, ji), ri = (me2 * v + be) * 4;
  9059. B2[ri] = zi[0], B2[ri + 1] = zi[1], B2[ri + 2] = zi[2], B2[ri + 3] = 255;
  9060. }
  9061. e.putImageData(k2, 0, 0);
  9062. const Q = Ee2(l[1], 0, 100, 0, 100);
  9063. this.markerElem_.style.left = `${Q}%`;
  9064. const ee = Ee2(l[2], 0, 100, 100, 0);
  9065. this.markerElem_.style.top = `${ee}%`;
  9066. }
  9067. onValueChange_() {
  9068. this.update_();
  9069. }
  9070. }
  9071. class Ml {
  9072. constructor(e, t) {
  9073. 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 kl(e, {
  9074. value: this.value,
  9075. viewProps: this.viewProps
  9076. }), this.ptHandler_ = new bt(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_);
  9077. }
  9078. handlePointerEvent_(e, t) {
  9079. if (!e.point)
  9080. return;
  9081. const l = Ee2(e.point.x, 0, e.bounds.width, 0, 100), v = Ee2(e.point.y, 0, e.bounds.height, 100, 0), [E, , , k2] = this.value.rawValue.getComponents("hsv");
  9082. this.value.setRawValue(new W2([E, l, v, k2], "hsv"), t);
  9083. }
  9084. onPointerDown_(e) {
  9085. this.handlePointerEvent_(e.data, {
  9086. forceEmit: false,
  9087. last: false
  9088. });
  9089. }
  9090. onPointerMove_(e) {
  9091. this.handlePointerEvent_(e.data, {
  9092. forceEmit: false,
  9093. last: false
  9094. });
  9095. }
  9096. onPointerUp_(e) {
  9097. this.handlePointerEvent_(e.data, {
  9098. forceEmit: true,
  9099. last: true
  9100. });
  9101. }
  9102. onKeyDown_(e) {
  9103. Li(e.key) && e.preventDefault();
  9104. const [t, l, v, E] = this.value.rawValue.getComponents("hsv"), k2 = Pn(false), B2 = Le(k2, nt(e)), Q = Le(k2, Xt(e));
  9105. B2 === 0 && Q === 0 || this.value.setRawValue(new W2([t, l + B2, v + Q, E], "hsv"), {
  9106. forceEmit: false,
  9107. last: false
  9108. });
  9109. }
  9110. onKeyUp_(e) {
  9111. const t = Pn(false), l = Le(t, nt(e)), v = Le(t, Xt(e));
  9112. l === 0 && v === 0 || this.value.setRawValue(this.value.rawValue, {
  9113. forceEmit: true,
  9114. last: true
  9115. });
  9116. }
  9117. }
  9118. class Sl {
  9119. constructor(e, t) {
  9120. this.value = t.value, this.viewProps = t.viewProps, this.hPaletteC_ = new Tl(e, {
  9121. value: this.value,
  9122. viewProps: this.viewProps
  9123. }), this.svPaletteC_ = new Ml(e, {
  9124. value: this.value,
  9125. viewProps: this.viewProps
  9126. }), this.alphaIcs_ = t.supportsAlpha ? {
  9127. palette: new _l(e, {
  9128. value: this.value,
  9129. viewProps: this.viewProps
  9130. }),
  9131. text: new Yt(e, {
  9132. parser: lt2,
  9133. baseStep: 0.1,
  9134. props: X2.fromObject({
  9135. draggingScale: 0.01,
  9136. formatter: Ve(2)
  9137. }),
  9138. value: te2(0, {
  9139. constraint: new Vt({ min: 0, max: 1 })
  9140. }),
  9141. viewProps: this.viewProps
  9142. })
  9143. } : null, this.alphaIcs_ && $t({
  9144. primary: this.value,
  9145. secondary: this.alphaIcs_.text.value,
  9146. forward: (l) => l.rawValue.getComponents()[3],
  9147. backward: (l, v) => {
  9148. const E = l.rawValue.getComponents();
  9149. return E[3] = v.rawValue, new W2(E, l.rawValue.mode);
  9150. }
  9151. }), this.textC_ = new Cl(e, {
  9152. colorType: t.colorType,
  9153. parser: lt2,
  9154. value: this.value,
  9155. viewProps: this.viewProps
  9156. }), this.view = new Oi(e, {
  9157. alphaViews: this.alphaIcs_ ? {
  9158. palette: this.alphaIcs_.palette.view,
  9159. text: this.alphaIcs_.text.view
  9160. } : null,
  9161. hPaletteView: this.hPaletteC_.view,
  9162. supportsAlpha: t.supportsAlpha,
  9163. svPaletteView: this.svPaletteC_.view,
  9164. textView: this.textC_.view,
  9165. viewProps: this.viewProps
  9166. });
  9167. }
  9168. get textController() {
  9169. return this.textC_;
  9170. }
  9171. }
  9172. const Br = D2("colsw");
  9173. class Al {
  9174. constructor(e, t) {
  9175. 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(Br()), t.viewProps.bindClassModifiers(this.element);
  9176. const l = e.createElement("div");
  9177. l.classList.add(Br("sw")), this.element.appendChild(l), this.swatchElem_ = l;
  9178. const v = e.createElement("button");
  9179. v.classList.add(Br("b")), t.viewProps.bindDisabled(v), this.element.appendChild(v), this.buttonElement = v, this.update_();
  9180. }
  9181. update_() {
  9182. const e = this.value.rawValue;
  9183. this.swatchElem_.style.backgroundColor = Vr(e);
  9184. }
  9185. onValueChange_() {
  9186. this.update_();
  9187. }
  9188. }
  9189. class Ll {
  9190. constructor(e, t) {
  9191. this.value = t.value, this.viewProps = t.viewProps, this.view = new Al(e, {
  9192. value: this.value,
  9193. viewProps: this.viewProps
  9194. });
  9195. }
  9196. }
  9197. class jr {
  9198. constructor(e, t) {
  9199. 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_ = Ne.create(t.expanded), this.swatchC_ = new Ll(e, {
  9200. value: this.value,
  9201. viewProps: this.viewProps
  9202. });
  9203. const l = this.swatchC_.view.buttonElement;
  9204. l.addEventListener("blur", this.onButtonBlur_), l.addEventListener("click", this.onButtonClick_), this.textC_ = new qn(e, {
  9205. parser: t.parser,
  9206. props: X2.fromObject({
  9207. formatter: t.formatter
  9208. }),
  9209. value: this.value,
  9210. viewProps: this.viewProps
  9211. }), this.view = new ei(e, {
  9212. foldable: this.foldable_,
  9213. pickerLayout: t.pickerLayout
  9214. }), this.view.swatchElement.appendChild(this.swatchC_.view.element), this.view.textElement.appendChild(this.textC_.view.element), this.popC_ = t.pickerLayout === "popup" ? new ps(e, {
  9215. viewProps: this.viewProps
  9216. }) : null;
  9217. const v = new Sl(e, {
  9218. colorType: t.colorType,
  9219. supportsAlpha: t.supportsAlpha,
  9220. value: this.value,
  9221. viewProps: this.viewProps
  9222. });
  9223. v.view.allFocusableElements.forEach((E) => {
  9224. E.addEventListener("blur", this.onPopupChildBlur_), E.addEventListener("keydown", this.onPopupChildKeydown_);
  9225. }), this.pickerC_ = v, this.popC_ ? (this.view.element.appendChild(this.popC_.view.element), this.popC_.view.element.appendChild(v.view.element), $t({
  9226. primary: this.foldable_.value("expanded"),
  9227. secondary: this.popC_.shows,
  9228. forward: (E) => E.rawValue,
  9229. backward: (E, k2) => k2.rawValue
  9230. })) : this.view.pickerElement && (this.view.pickerElement.appendChild(this.pickerC_.view.element), Ke(this.foldable_, this.view.pickerElement));
  9231. }
  9232. get textController() {
  9233. return this.textC_;
  9234. }
  9235. onButtonBlur_(e) {
  9236. if (!this.popC_)
  9237. return;
  9238. const t = this.view.element, l = e.relatedTarget;
  9239. (!l || !t.contains(l)) && (this.popC_.shows.rawValue = false);
  9240. }
  9241. onButtonClick_() {
  9242. this.foldable_.set("expanded", !this.foldable_.get("expanded")), this.foldable_.get("expanded") && this.pickerC_.view.allFocusableElements[0].focus();
  9243. }
  9244. onPopupChildBlur_(e) {
  9245. if (!this.popC_)
  9246. return;
  9247. const t = this.popC_.view.element, l = Et(e);
  9248. l && t.contains(l) || l && l === this.swatchC_.view.buttonElement && !ft2(t.ownerDocument) || (this.popC_.shows.rawValue = false);
  9249. }
  9250. onPopupChildKeydown_(e) {
  9251. this.popC_ ? e.key === "Escape" && (this.popC_.shows.rawValue = false) : this.view.pickerElement && e.key === "Escape" && this.swatchC_.view.buttonElement.focus();
  9252. }
  9253. }
  9254. function Rl(n, e) {
  9255. return W2.isColorObject(n) ? W2.fromObject(n, e) : W2.black(e);
  9256. }
  9257. function Il(n) {
  9258. return d(n.getComponents("rgb")).reduce((e, t) => e << 8 | Math.floor(t) & 255, 0);
  9259. }
  9260. function Vl(n) {
  9261. return n.getComponents("rgb").reduce((e, t, l) => {
  9262. const v = Math.floor(l === 3 ? t * 255 : t) & 255;
  9263. return e << 8 | v;
  9264. }, 0) >>> 0;
  9265. }
  9266. function Dl(n) {
  9267. return new W2([n >> 16 & 255, n >> 8 & 255, n & 255], "rgb");
  9268. }
  9269. function Ol(n) {
  9270. return new W2([
  9271. n >> 24 & 255,
  9272. n >> 16 & 255,
  9273. n >> 8 & 255,
  9274. Ee2(n & 255, 0, 255, 0, 1)
  9275. ], "rgb");
  9276. }
  9277. function Nl(n) {
  9278. return typeof n != "number" ? W2.black() : Dl(n);
  9279. }
  9280. function Fl(n) {
  9281. return typeof n != "number" ? W2.black() : Ol(n);
  9282. }
  9283. function Bl(n) {
  9284. const e = Dr(n);
  9285. return e ? (t, l) => {
  9286. Ot(t, e(l));
  9287. } : null;
  9288. }
  9289. function jl(n) {
  9290. const e = n ? Vl : Il;
  9291. return (t, l) => {
  9292. Ot(t, e(l));
  9293. };
  9294. }
  9295. function zl(n, e, t) {
  9296. const l = e.toRgbaObject(t);
  9297. n.writeProperty("r", l.r), n.writeProperty("g", l.g), n.writeProperty("b", l.b), n.writeProperty("a", l.a);
  9298. }
  9299. function Ul(n, e, t) {
  9300. const l = e.toRgbaObject(t);
  9301. n.writeProperty("r", l.r), n.writeProperty("g", l.g), n.writeProperty("b", l.b);
  9302. }
  9303. function Gl(n, e) {
  9304. return (t, l) => {
  9305. n ? zl(t, l, e) : Ul(t, l, e);
  9306. };
  9307. }
  9308. function zr(n) {
  9309. var e;
  9310. return !!(n != null && n.alpha || !((e = n == null ? void 0 : n.color) === null || e === void 0) && e.alpha);
  9311. }
  9312. function Hl(n) {
  9313. return n ? (e) => Vr(e, "0x") : (e) => Bo(e, "0x");
  9314. }
  9315. function Kl(n) {
  9316. return "color" in n || "view" in n && n.view === "color";
  9317. }
  9318. const $l = {
  9319. id: "input-color-number",
  9320. type: "input",
  9321. accept: (n, e) => {
  9322. if (typeof n != "number" || !Kl(e))
  9323. return null;
  9324. const t = Ni(e);
  9325. return t ? {
  9326. initialValue: n,
  9327. params: t
  9328. } : null;
  9329. },
  9330. binding: {
  9331. reader: (n) => zr(n.params) ? Fl : Nl,
  9332. equals: W2.equals,
  9333. writer: (n) => jl(zr(n.params))
  9334. },
  9335. controller: (n) => {
  9336. const e = zr(n.params), t = "expanded" in n.params ? n.params.expanded : void 0, l = "picker" in n.params ? n.params.picker : void 0;
  9337. return new jr(n.document, {
  9338. colorType: "int",
  9339. expanded: t ?? false,
  9340. formatter: Hl(e),
  9341. parser: Ir("int"),
  9342. pickerLayout: l ?? "popup",
  9343. supportsAlpha: e,
  9344. value: n.value,
  9345. viewProps: n.viewProps
  9346. });
  9347. }
  9348. };
  9349. function Xl(n) {
  9350. return W2.isRgbaColorObject(n);
  9351. }
  9352. function Yl(n) {
  9353. return (e) => Rl(e, n);
  9354. }
  9355. function ql(n, e) {
  9356. return (t) => n ? Uo(t, e) : zo(t, e);
  9357. }
  9358. const Ql = {
  9359. id: "input-color-object",
  9360. type: "input",
  9361. accept: (n, e) => {
  9362. if (!W2.isColorObject(n))
  9363. return null;
  9364. const t = Ni(e);
  9365. return t ? {
  9366. initialValue: n,
  9367. params: t
  9368. } : null;
  9369. },
  9370. binding: {
  9371. reader: (n) => Yl(Tn(n.params)),
  9372. equals: W2.equals,
  9373. writer: (n) => Gl(Xl(n.initialValue), Tn(n.params))
  9374. },
  9375. controller: (n) => {
  9376. var e;
  9377. const t = W2.isRgbaColorObject(n.initialValue), l = "expanded" in n.params ? n.params.expanded : void 0, v = "picker" in n.params ? n.params.picker : void 0, E = (e = Tn(n.params)) !== null && e !== void 0 ? e : "int";
  9378. return new jr(n.document, {
  9379. colorType: E,
  9380. expanded: l ?? false,
  9381. formatter: ql(t, E),
  9382. parser: Ir(E),
  9383. pickerLayout: v ?? "popup",
  9384. supportsAlpha: t,
  9385. value: n.value,
  9386. viewProps: n.viewProps
  9387. });
  9388. }
  9389. }, Zl = {
  9390. id: "input-color-string",
  9391. type: "input",
  9392. accept: (n, e) => {
  9393. if (typeof n != "string" || "view" in e && e.view === "text")
  9394. return null;
  9395. const t = Rr(n, Tn(e));
  9396. if (!t || !Dr(t))
  9397. return null;
  9398. const v = Ni(e);
  9399. return v ? {
  9400. initialValue: n,
  9401. params: v
  9402. } : null;
  9403. },
  9404. binding: {
  9405. reader: (n) => {
  9406. var e;
  9407. return pl((e = Tn(n.params)) !== null && e !== void 0 ? e : "int");
  9408. },
  9409. equals: W2.equals,
  9410. writer: (n) => {
  9411. const e = Rr(n.initialValue, Tn(n.params));
  9412. if (!e)
  9413. throw S.shouldNeverHappen();
  9414. const t = Bl(e);
  9415. if (!t)
  9416. throw S.notBindable();
  9417. return t;
  9418. }
  9419. },
  9420. controller: (n) => {
  9421. const e = Rr(n.initialValue, Tn(n.params));
  9422. if (!e)
  9423. throw S.shouldNeverHappen();
  9424. const t = Dr(e);
  9425. if (!t)
  9426. throw S.shouldNeverHappen();
  9427. const l = "expanded" in n.params ? n.params.expanded : void 0, v = "picker" in n.params ? n.params.picker : void 0;
  9428. return new jr(n.document, {
  9429. colorType: e.type,
  9430. expanded: l ?? false,
  9431. formatter: t,
  9432. parser: Ir(e.type),
  9433. pickerLayout: v ?? "popup",
  9434. supportsAlpha: e.alpha,
  9435. value: n.value,
  9436. viewProps: n.viewProps
  9437. });
  9438. }
  9439. };
  9440. class Zt {
  9441. constructor(e) {
  9442. this.components = e.components, this.asm_ = e.assembly;
  9443. }
  9444. constrain(e) {
  9445. const t = this.asm_.toComponents(e).map((l, v) => {
  9446. var E, k2;
  9447. return (k2 = (E = this.components[v]) === null || E === void 0 ? void 0 : E.constrain(l)) !== null && k2 !== void 0 ? k2 : l;
  9448. });
  9449. return this.asm_.fromComponents(t);
  9450. }
  9451. }
  9452. const Ho = D2("pndtxt");
  9453. class Wl {
  9454. constructor(e, t) {
  9455. this.textViews = t.textViews, this.element = e.createElement("div"), this.element.classList.add(Ho()), this.textViews.forEach((l) => {
  9456. const v = e.createElement("div");
  9457. v.classList.add(Ho("a")), v.appendChild(l.element), this.element.appendChild(v);
  9458. });
  9459. }
  9460. }
  9461. function Jl(n, e, t) {
  9462. return new Yt(n, {
  9463. arrayPosition: t === 0 ? "fst" : t === e.axes.length - 1 ? "lst" : "mid",
  9464. baseStep: e.axes[t].baseStep,
  9465. parser: e.parser,
  9466. props: e.axes[t].textProps,
  9467. value: te2(0, {
  9468. constraint: e.axes[t].constraint
  9469. }),
  9470. viewProps: e.viewProps
  9471. });
  9472. }
  9473. class Ur {
  9474. constructor(e, t) {
  9475. this.value = t.value, this.viewProps = t.viewProps, this.acs_ = t.axes.map((l, v) => Jl(e, t, v)), this.acs_.forEach((l, v) => {
  9476. $t({
  9477. primary: this.value,
  9478. secondary: l.value,
  9479. forward: (E) => t.assembly.toComponents(E.rawValue)[v],
  9480. backward: (E, k2) => {
  9481. const B2 = t.assembly.toComponents(E.rawValue);
  9482. return B2[v] = k2.rawValue, t.assembly.fromComponents(B2);
  9483. }
  9484. });
  9485. }), this.view = new Wl(e, {
  9486. textViews: this.acs_.map((l) => l.view)
  9487. });
  9488. }
  9489. }
  9490. function Ko(n, e) {
  9491. return "step" in n && !_(n.step) ? new Yn(n.step, e) : null;
  9492. }
  9493. function $o(n) {
  9494. return !_(n.max) && !_(n.min) ? new Vt({
  9495. max: n.max,
  9496. min: n.min
  9497. }) : !_(n.max) || !_(n.min) ? new Xe({
  9498. max: n.max,
  9499. min: n.min
  9500. }) : null;
  9501. }
  9502. function ec(n) {
  9503. const e = we(n, Vt);
  9504. if (e)
  9505. return [e.values.get("min"), e.values.get("max")];
  9506. const t = we(n, Xe);
  9507. return t ? [t.minValue, t.maxValue] : [void 0, void 0];
  9508. }
  9509. function tc(n, e) {
  9510. const t = [], l = Ko(n, e);
  9511. l && t.push(l);
  9512. const v = $o(n);
  9513. v && t.push(v);
  9514. const E = Wn(n.options);
  9515. return E && t.push(E), new Ct2(t);
  9516. }
  9517. const nc = {
  9518. id: "input-number",
  9519. type: "input",
  9520. accept: (n, e) => {
  9521. if (typeof n != "number")
  9522. return null;
  9523. const t = M, l = ce(e, {
  9524. format: t.optional.function,
  9525. max: t.optional.number,
  9526. min: t.optional.number,
  9527. options: t.optional.custom(xn),
  9528. step: t.optional.number
  9529. });
  9530. return l ? {
  9531. initialValue: n,
  9532. params: l
  9533. } : null;
  9534. },
  9535. binding: {
  9536. reader: (n) => ws,
  9537. constraint: (n) => tc(n.params, n.initialValue),
  9538. writer: (n) => Ot
  9539. },
  9540. controller: (n) => {
  9541. var e;
  9542. const t = n.value, l = n.constraint, v = l && we(l, at);
  9543. if (v)
  9544. return new mn(n.document, {
  9545. props: new X2({
  9546. options: v.values.value("options")
  9547. }),
  9548. value: t,
  9549. viewProps: n.viewProps
  9550. });
  9551. const E = (e = "format" in n.params ? n.params.format : void 0) !== null && e !== void 0 ? e : Ve(Jn(l, t.rawValue)), k2 = l && we(l, Vt);
  9552. return k2 ? new yn(n.document, {
  9553. baseStep: qt(l),
  9554. parser: lt2,
  9555. sliderProps: new X2({
  9556. maxValue: k2.values.value("max"),
  9557. minValue: k2.values.value("min")
  9558. }),
  9559. textProps: X2.fromObject({
  9560. draggingScale: Qt(l, t.rawValue),
  9561. formatter: E
  9562. }),
  9563. value: t,
  9564. viewProps: n.viewProps
  9565. }) : new Yt(n.document, {
  9566. baseStep: qt(l),
  9567. parser: lt2,
  9568. props: X2.fromObject({
  9569. draggingScale: Qt(l, t.rawValue),
  9570. formatter: E
  9571. }),
  9572. value: t,
  9573. viewProps: n.viewProps
  9574. });
  9575. }
  9576. };
  9577. class Wt {
  9578. constructor(e = 0, t = 0) {
  9579. this.x = e, this.y = t;
  9580. }
  9581. getComponents() {
  9582. return [this.x, this.y];
  9583. }
  9584. static isObject(e) {
  9585. if (_(e))
  9586. return false;
  9587. const t = e.x, l = e.y;
  9588. return !(typeof t != "number" || typeof l != "number");
  9589. }
  9590. static equals(e, t) {
  9591. return e.x === t.x && e.y === t.y;
  9592. }
  9593. toObject() {
  9594. return {
  9595. x: this.x,
  9596. y: this.y
  9597. };
  9598. }
  9599. }
  9600. const Xo = {
  9601. toComponents: (n) => n.getComponents(),
  9602. fromComponents: (n) => new Wt(...n)
  9603. }, ni = D2("p2d");
  9604. class ic {
  9605. constructor(e, t) {
  9606. this.element = e.createElement("div"), this.element.classList.add(ni()), t.viewProps.bindClassModifiers(this.element), N2(t.expanded, K(this.element, ni(void 0, "expanded")));
  9607. const l = e.createElement("div");
  9608. l.classList.add(ni("h")), this.element.appendChild(l);
  9609. const v = e.createElement("button");
  9610. v.classList.add(ni("b")), v.appendChild(xt(e, "p2dpad")), t.viewProps.bindDisabled(v), l.appendChild(v), this.buttonElement = v;
  9611. const E = e.createElement("div");
  9612. if (E.classList.add(ni("t")), l.appendChild(E), this.textElement = E, t.pickerLayout === "inline") {
  9613. const k2 = e.createElement("div");
  9614. k2.classList.add(ni("p")), this.element.appendChild(k2), this.pickerElement = k2;
  9615. } else
  9616. this.pickerElement = null;
  9617. }
  9618. }
  9619. const Jt = D2("p2dp");
  9620. class sc {
  9621. constructor(e, t) {
  9622. 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(Jt()), t.layout === "popup" && this.element.classList.add(Jt(void 0, "p")), t.viewProps.bindClassModifiers(this.element);
  9623. const l = e.createElement("div");
  9624. l.classList.add(Jt("p")), t.viewProps.bindTabIndex(l), this.element.appendChild(l), this.padElement = l;
  9625. const v = e.createElementNS(He, "svg");
  9626. v.classList.add(Jt("g")), this.padElement.appendChild(v), this.svgElem_ = v;
  9627. const E = e.createElementNS(He, "line");
  9628. E.classList.add(Jt("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);
  9629. const k2 = e.createElementNS(He, "line");
  9630. k2.classList.add(Jt("ax")), k2.setAttributeNS(null, "x1", "50%"), k2.setAttributeNS(null, "y1", "0"), k2.setAttributeNS(null, "x2", "50%"), k2.setAttributeNS(null, "y2", "100%"), this.svgElem_.appendChild(k2);
  9631. const B2 = e.createElementNS(He, "line");
  9632. B2.classList.add(Jt("l")), B2.setAttributeNS(null, "x1", "50%"), B2.setAttributeNS(null, "y1", "50%"), this.svgElem_.appendChild(B2), this.lineElem_ = B2;
  9633. const Q = e.createElement("div");
  9634. Q.classList.add(Jt("m")), this.padElement.appendChild(Q), this.markerElem_ = Q, t.value.emitter.on("change", this.onValueChange_), this.value = t.value, this.update_();
  9635. }
  9636. get allFocusableElements() {
  9637. return [this.padElement];
  9638. }
  9639. update_() {
  9640. const [e, t] = this.value.rawValue.getComponents(), l = this.maxValue_, v = Ee2(e, -l, +l, 0, 100), E = Ee2(t, -l, +l, 0, 100), k2 = this.invertsY_ ? 100 - E : E;
  9641. this.lineElem_.setAttributeNS(null, "x2", `${v}%`), this.lineElem_.setAttributeNS(null, "y2", `${k2}%`), this.markerElem_.style.left = `${v}%`, this.markerElem_.style.top = `${k2}%`;
  9642. }
  9643. onValueChange_() {
  9644. this.update_();
  9645. }
  9646. onFoldableChange_() {
  9647. this.update_();
  9648. }
  9649. }
  9650. function Yo(n, e, t) {
  9651. return [
  9652. Le(e[0], nt(n)),
  9653. Le(e[1], Xt(n)) * (t ? 1 : -1)
  9654. ];
  9655. }
  9656. class rc {
  9657. constructor(e, t) {
  9658. 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 sc(e, {
  9659. invertsY: this.invertsY_,
  9660. layout: t.layout,
  9661. maxValue: this.maxValue_,
  9662. value: this.value,
  9663. viewProps: this.viewProps
  9664. }), this.ptHandler_ = new bt(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_);
  9665. }
  9666. handlePointerEvent_(e, t) {
  9667. if (!e.point)
  9668. return;
  9669. const l = this.maxValue_, v = Ee2(e.point.x, 0, e.bounds.width, -l, +l), E = Ee2(this.invertsY_ ? e.bounds.height - e.point.y : e.point.y, 0, e.bounds.height, -l, +l);
  9670. this.value.setRawValue(new Wt(v, E), t);
  9671. }
  9672. onPointerDown_(e) {
  9673. this.handlePointerEvent_(e.data, {
  9674. forceEmit: false,
  9675. last: false
  9676. });
  9677. }
  9678. onPointerMove_(e) {
  9679. this.handlePointerEvent_(e.data, {
  9680. forceEmit: false,
  9681. last: false
  9682. });
  9683. }
  9684. onPointerUp_(e) {
  9685. this.handlePointerEvent_(e.data, {
  9686. forceEmit: true,
  9687. last: true
  9688. });
  9689. }
  9690. onPadKeyDown_(e) {
  9691. Li(e.key) && e.preventDefault();
  9692. const [t, l] = Yo(e, this.baseSteps_, this.invertsY_);
  9693. t === 0 && l === 0 || this.value.setRawValue(new Wt(this.value.rawValue.x + t, this.value.rawValue.y + l), {
  9694. forceEmit: false,
  9695. last: false
  9696. });
  9697. }
  9698. onPadKeyUp_(e) {
  9699. const [t, l] = Yo(e, this.baseSteps_, this.invertsY_);
  9700. t === 0 && l === 0 || this.value.setRawValue(this.value.rawValue, {
  9701. forceEmit: true,
  9702. last: true
  9703. });
  9704. }
  9705. }
  9706. class oc {
  9707. constructor(e, t) {
  9708. var l, v;
  9709. 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_ = Ne.create(t.expanded), this.popC_ = t.pickerLayout === "popup" ? new ps(e, {
  9710. viewProps: this.viewProps
  9711. }) : null;
  9712. const E = new rc(e, {
  9713. baseSteps: [t.axes[0].baseStep, t.axes[1].baseStep],
  9714. invertsY: t.invertsY,
  9715. layout: t.pickerLayout,
  9716. maxValue: t.maxValue,
  9717. value: this.value,
  9718. viewProps: this.viewProps
  9719. });
  9720. E.view.allFocusableElements.forEach((k2) => {
  9721. k2.addEventListener("blur", this.onPopupChildBlur_), k2.addEventListener("keydown", this.onPopupChildKeydown_);
  9722. }), this.pickerC_ = E, this.textC_ = new Ur(e, {
  9723. assembly: Xo,
  9724. axes: t.axes,
  9725. parser: t.parser,
  9726. value: this.value,
  9727. viewProps: this.viewProps
  9728. }), this.view = new ic(e, {
  9729. expanded: this.foldable_.value("expanded"),
  9730. pickerLayout: t.pickerLayout,
  9731. viewProps: this.viewProps
  9732. }), this.view.textElement.appendChild(this.textC_.view.element), (l = this.view.buttonElement) === null || l === void 0 || l.addEventListener("blur", this.onPadButtonBlur_), (v = this.view.buttonElement) === null || v === void 0 || v.addEventListener("click", this.onPadButtonClick_), this.popC_ ? (this.view.element.appendChild(this.popC_.view.element), this.popC_.view.element.appendChild(this.pickerC_.view.element), $t({
  9733. primary: this.foldable_.value("expanded"),
  9734. secondary: this.popC_.shows,
  9735. forward: (k2) => k2.rawValue,
  9736. backward: (k2, B2) => B2.rawValue
  9737. })) : this.view.pickerElement && (this.view.pickerElement.appendChild(this.pickerC_.view.element), Ke(this.foldable_, this.view.pickerElement));
  9738. }
  9739. onPadButtonBlur_(e) {
  9740. if (!this.popC_)
  9741. return;
  9742. const t = this.view.element, l = e.relatedTarget;
  9743. (!l || !t.contains(l)) && (this.popC_.shows.rawValue = false);
  9744. }
  9745. onPadButtonClick_() {
  9746. this.foldable_.set("expanded", !this.foldable_.get("expanded")), this.foldable_.get("expanded") && this.pickerC_.view.allFocusableElements[0].focus();
  9747. }
  9748. onPopupChildBlur_(e) {
  9749. if (!this.popC_)
  9750. return;
  9751. const t = this.popC_.view.element, l = Et(e);
  9752. l && t.contains(l) || l && l === this.view.buttonElement && !ft2(t.ownerDocument) || (this.popC_.shows.rawValue = false);
  9753. }
  9754. onPopupChildKeydown_(e) {
  9755. this.popC_ ? e.key === "Escape" && (this.popC_.shows.rawValue = false) : this.view.pickerElement && e.key === "Escape" && this.view.buttonElement.focus();
  9756. }
  9757. }
  9758. class ii {
  9759. constructor(e = 0, t = 0, l = 0) {
  9760. this.x = e, this.y = t, this.z = l;
  9761. }
  9762. getComponents() {
  9763. return [this.x, this.y, this.z];
  9764. }
  9765. static isObject(e) {
  9766. if (_(e))
  9767. return false;
  9768. const t = e.x, l = e.y, v = e.z;
  9769. return !(typeof t != "number" || typeof l != "number" || typeof v != "number");
  9770. }
  9771. static equals(e, t) {
  9772. return e.x === t.x && e.y === t.y && e.z === t.z;
  9773. }
  9774. toObject() {
  9775. return {
  9776. x: this.x,
  9777. y: this.y,
  9778. z: this.z
  9779. };
  9780. }
  9781. }
  9782. const qo = {
  9783. toComponents: (n) => n.getComponents(),
  9784. fromComponents: (n) => new ii(...n)
  9785. };
  9786. function ac(n) {
  9787. return ii.isObject(n) ? new ii(n.x, n.y, n.z) : new ii();
  9788. }
  9789. function lc(n, e) {
  9790. n.writeProperty("x", e.x), n.writeProperty("y", e.y), n.writeProperty("z", e.z);
  9791. }
  9792. function cc(n, e) {
  9793. return new Zt({
  9794. assembly: qo,
  9795. components: [
  9796. Nt("x" in n ? n.x : void 0, e.x),
  9797. Nt("y" in n ? n.y : void 0, e.y),
  9798. Nt("z" in n ? n.z : void 0, e.z)
  9799. ]
  9800. });
  9801. }
  9802. function Gr(n, e) {
  9803. return {
  9804. baseStep: qt(e),
  9805. constraint: e,
  9806. textProps: X2.fromObject({
  9807. draggingScale: Qt(e, n),
  9808. formatter: Ve(Jn(e, n))
  9809. })
  9810. };
  9811. }
  9812. const pc = {
  9813. id: "input-point3d",
  9814. type: "input",
  9815. accept: (n, e) => {
  9816. if (!ii.isObject(n))
  9817. return null;
  9818. const t = M, l = ce(e, {
  9819. x: t.optional.custom(gt2),
  9820. y: t.optional.custom(gt2),
  9821. z: t.optional.custom(gt2)
  9822. });
  9823. return l ? {
  9824. initialValue: n,
  9825. params: l
  9826. } : null;
  9827. },
  9828. binding: {
  9829. reader: (n) => ac,
  9830. constraint: (n) => cc(n.params, n.initialValue),
  9831. equals: ii.equals,
  9832. writer: (n) => lc
  9833. },
  9834. controller: (n) => {
  9835. const e = n.value, t = n.constraint;
  9836. if (!(t instanceof Zt))
  9837. throw S.shouldNeverHappen();
  9838. return new Ur(n.document, {
  9839. assembly: qo,
  9840. axes: [
  9841. Gr(e.rawValue.x, t.components[0]),
  9842. Gr(e.rawValue.y, t.components[1]),
  9843. Gr(e.rawValue.z, t.components[2])
  9844. ],
  9845. parser: lt2,
  9846. value: e,
  9847. viewProps: n.viewProps
  9848. });
  9849. }
  9850. };
  9851. class si {
  9852. constructor(e = 0, t = 0, l = 0, v = 0) {
  9853. this.x = e, this.y = t, this.z = l, this.w = v;
  9854. }
  9855. getComponents() {
  9856. return [this.x, this.y, this.z, this.w];
  9857. }
  9858. static isObject(e) {
  9859. if (_(e))
  9860. return false;
  9861. const t = e.x, l = e.y, v = e.z, E = e.w;
  9862. return !(typeof t != "number" || typeof l != "number" || typeof v != "number" || typeof E != "number");
  9863. }
  9864. static equals(e, t) {
  9865. return e.x === t.x && e.y === t.y && e.z === t.z && e.w === t.w;
  9866. }
  9867. toObject() {
  9868. return {
  9869. x: this.x,
  9870. y: this.y,
  9871. z: this.z,
  9872. w: this.w
  9873. };
  9874. }
  9875. }
  9876. const Qo = {
  9877. toComponents: (n) => n.getComponents(),
  9878. fromComponents: (n) => new si(...n)
  9879. };
  9880. function uc(n) {
  9881. return si.isObject(n) ? new si(n.x, n.y, n.z, n.w) : new si();
  9882. }
  9883. function hc(n, e) {
  9884. n.writeProperty("x", e.x), n.writeProperty("y", e.y), n.writeProperty("z", e.z), n.writeProperty("w", e.w);
  9885. }
  9886. function dc(n, e) {
  9887. return new Zt({
  9888. assembly: Qo,
  9889. components: [
  9890. Nt("x" in n ? n.x : void 0, e.x),
  9891. Nt("y" in n ? n.y : void 0, e.y),
  9892. Nt("z" in n ? n.z : void 0, e.z),
  9893. Nt("w" in n ? n.w : void 0, e.w)
  9894. ]
  9895. });
  9896. }
  9897. function mc(n, e) {
  9898. return {
  9899. baseStep: qt(e),
  9900. constraint: e,
  9901. textProps: X2.fromObject({
  9902. draggingScale: Qt(e, n),
  9903. formatter: Ve(Jn(e, n))
  9904. })
  9905. };
  9906. }
  9907. const fc = {
  9908. id: "input-point4d",
  9909. type: "input",
  9910. accept: (n, e) => {
  9911. if (!si.isObject(n))
  9912. return null;
  9913. const t = M, l = ce(e, {
  9914. x: t.optional.custom(gt2),
  9915. y: t.optional.custom(gt2),
  9916. z: t.optional.custom(gt2),
  9917. w: t.optional.custom(gt2)
  9918. });
  9919. return l ? {
  9920. initialValue: n,
  9921. params: l
  9922. } : null;
  9923. },
  9924. binding: {
  9925. reader: (n) => uc,
  9926. constraint: (n) => dc(n.params, n.initialValue),
  9927. equals: si.equals,
  9928. writer: (n) => hc
  9929. },
  9930. controller: (n) => {
  9931. const e = n.value, t = n.constraint;
  9932. if (!(t instanceof Zt))
  9933. throw S.shouldNeverHappen();
  9934. return new Ur(n.document, {
  9935. assembly: Qo,
  9936. axes: e.rawValue.getComponents().map((l, v) => mc(l, t.components[v])),
  9937. parser: lt2,
  9938. value: e,
  9939. viewProps: n.viewProps
  9940. });
  9941. }
  9942. };
  9943. function vc(n) {
  9944. const e = [], t = Wn(n.options);
  9945. return t && e.push(t), new Ct2(e);
  9946. }
  9947. const bc = {
  9948. id: "input-string",
  9949. type: "input",
  9950. accept: (n, e) => {
  9951. if (typeof n != "string")
  9952. return null;
  9953. const l = ce(e, {
  9954. options: M.optional.custom(xn)
  9955. });
  9956. return l ? {
  9957. initialValue: n,
  9958. params: l
  9959. } : null;
  9960. },
  9961. binding: {
  9962. reader: (n) => Ai,
  9963. constraint: (n) => vc(n.params),
  9964. writer: (n) => Ot
  9965. },
  9966. controller: (n) => {
  9967. const e = n.document, t = n.value, l = n.constraint, v = l && we(l, at);
  9968. return v ? new mn(e, {
  9969. props: new X2({
  9970. options: v.values.value("options")
  9971. }),
  9972. value: t,
  9973. viewProps: n.viewProps
  9974. }) : new qn(e, {
  9975. parser: (E) => E,
  9976. props: X2.fromObject({
  9977. formatter: ct2
  9978. }),
  9979. value: t,
  9980. viewProps: n.viewProps
  9981. });
  9982. }
  9983. }, Bi = {
  9984. monitor: {
  9985. defaultInterval: 200,
  9986. defaultLineCount: 3
  9987. }
  9988. }, Zo = D2("mll");
  9989. class gc {
  9990. constructor(e, t) {
  9991. this.onValueUpdate_ = this.onValueUpdate_.bind(this), this.formatter_ = t.formatter, this.element = e.createElement("div"), this.element.classList.add(Zo()), t.viewProps.bindClassModifiers(this.element);
  9992. const l = e.createElement("textarea");
  9993. l.classList.add(Zo("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_();
  9994. }
  9995. update_() {
  9996. const e = this.textareaElem_, t = e.scrollTop === e.scrollHeight - e.clientHeight, l = [];
  9997. this.value.rawValue.forEach((v) => {
  9998. v !== void 0 && l.push(this.formatter_(v));
  9999. }), e.textContent = l.join(`
  10000. `), t && (e.scrollTop = e.scrollHeight);
  10001. }
  10002. onValueUpdate_() {
  10003. this.update_();
  10004. }
  10005. }
  10006. class Hr {
  10007. constructor(e, t) {
  10008. this.value = t.value, this.viewProps = t.viewProps, this.view = new gc(e, {
  10009. formatter: t.formatter,
  10010. lineCount: t.lineCount,
  10011. value: this.value,
  10012. viewProps: this.viewProps
  10013. });
  10014. }
  10015. }
  10016. const Wo = D2("sgl");
  10017. class _c {
  10018. constructor(e, t) {
  10019. this.onValueUpdate_ = this.onValueUpdate_.bind(this), this.formatter_ = t.formatter, this.element = e.createElement("div"), this.element.classList.add(Wo()), t.viewProps.bindClassModifiers(this.element);
  10020. const l = e.createElement("input");
  10021. l.classList.add(Wo("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_();
  10022. }
  10023. update_() {
  10024. const e = this.value.rawValue, t = e[e.length - 1];
  10025. this.inputElement.value = t !== void 0 ? this.formatter_(t) : "";
  10026. }
  10027. onValueUpdate_() {
  10028. this.update_();
  10029. }
  10030. }
  10031. class Kr {
  10032. constructor(e, t) {
  10033. this.value = t.value, this.viewProps = t.viewProps, this.view = new _c(e, {
  10034. formatter: t.formatter,
  10035. value: this.value,
  10036. viewProps: this.viewProps
  10037. });
  10038. }
  10039. }
  10040. const wc = {
  10041. id: "monitor-bool",
  10042. type: "monitor",
  10043. accept: (n, e) => {
  10044. if (typeof n != "boolean")
  10045. return null;
  10046. const l = ce(e, {
  10047. lineCount: M.optional.number
  10048. });
  10049. return l ? {
  10050. initialValue: n,
  10051. params: l
  10052. } : null;
  10053. },
  10054. binding: {
  10055. reader: (n) => hs
  10056. },
  10057. controller: (n) => {
  10058. var e;
  10059. return n.value.rawValue.length === 1 ? new Kr(n.document, {
  10060. formatter: ds,
  10061. value: n.value,
  10062. viewProps: n.viewProps
  10063. }) : new Hr(n.document, {
  10064. formatter: ds,
  10065. lineCount: (e = n.params.lineCount) !== null && e !== void 0 ? e : Bi.monitor.defaultLineCount,
  10066. value: n.value,
  10067. viewProps: n.viewProps
  10068. });
  10069. }
  10070. }, en = D2("grl");
  10071. class yc {
  10072. constructor(e, t) {
  10073. this.onCursorChange_ = this.onCursorChange_.bind(this), this.onValueUpdate_ = this.onValueUpdate_.bind(this), this.element = e.createElement("div"), this.element.classList.add(en()), t.viewProps.bindClassModifiers(this.element), this.formatter_ = t.formatter, this.props_ = t.props, this.cursor_ = t.cursor, this.cursor_.emitter.on("change", this.onCursorChange_);
  10074. const l = e.createElementNS(He, "svg");
  10075. l.classList.add(en("g")), l.style.height = `calc(var(--bld-us) * ${t.lineCount})`, this.element.appendChild(l), this.svgElem_ = l;
  10076. const v = e.createElementNS(He, "polyline");
  10077. this.svgElem_.appendChild(v), this.lineElem_ = v;
  10078. const E = e.createElement("div");
  10079. E.classList.add(en("t"), D2("tt")()), this.element.appendChild(E), this.tooltipElem_ = E, t.value.emitter.on("change", this.onValueUpdate_), this.value = t.value, this.update_();
  10080. }
  10081. get graphElement() {
  10082. return this.svgElem_;
  10083. }
  10084. update_() {
  10085. const e = this.svgElem_.getBoundingClientRect(), t = this.value.rawValue.length - 1, l = this.props_.get("minValue"), v = this.props_.get("maxValue"), E = [];
  10086. this.value.rawValue.forEach((me2, be) => {
  10087. if (me2 === void 0)
  10088. return;
  10089. const Ft = Ee2(be, 0, t, 0, e.width), ji = Ee2(me2, l, v, e.height, 0);
  10090. E.push([Ft, ji].join(","));
  10091. }), this.lineElem_.setAttributeNS(null, "points", E.join(" "));
  10092. const k2 = this.tooltipElem_, B2 = this.value.rawValue[this.cursor_.rawValue];
  10093. if (B2 === void 0) {
  10094. k2.classList.remove(en("t", "a"));
  10095. return;
  10096. }
  10097. const Q = Ee2(this.cursor_.rawValue, 0, t, 0, e.width), ee = Ee2(B2, l, v, e.height, 0);
  10098. k2.style.left = `${Q}px`, k2.style.top = `${ee}px`, k2.textContent = `${this.formatter_(B2)}`, k2.classList.contains(en("t", "a")) || (k2.classList.add(en("t", "a"), en("t", "in")), rt2(k2), k2.classList.remove(en("t", "in")));
  10099. }
  10100. onValueUpdate_() {
  10101. this.update_();
  10102. }
  10103. onCursorChange_() {
  10104. this.update_();
  10105. }
  10106. }
  10107. class xc {
  10108. constructor(e, t) {
  10109. 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_ = te2(-1), this.view = new yc(e, {
  10110. cursor: this.cursor_,
  10111. formatter: t.formatter,
  10112. lineCount: t.lineCount,
  10113. props: this.props_,
  10114. value: this.value,
  10115. viewProps: this.viewProps
  10116. }), !ft2(e))
  10117. this.view.element.addEventListener("mousemove", this.onGraphMouseMove_), this.view.element.addEventListener("mouseleave", this.onGraphMouseLeave_);
  10118. else {
  10119. const l = new bt(this.view.element);
  10120. l.emitter.on("down", this.onGraphPointerDown_), l.emitter.on("move", this.onGraphPointerMove_), l.emitter.on("up", this.onGraphPointerUp_);
  10121. }
  10122. }
  10123. onGraphMouseLeave_() {
  10124. this.cursor_.rawValue = -1;
  10125. }
  10126. onGraphMouseMove_(e) {
  10127. const t = this.view.element.getBoundingClientRect();
  10128. this.cursor_.rawValue = Math.floor(Ee2(e.offsetX, 0, t.width, 0, this.value.rawValue.length));
  10129. }
  10130. onGraphPointerDown_(e) {
  10131. this.onGraphPointerMove_(e);
  10132. }
  10133. onGraphPointerMove_(e) {
  10134. if (!e.data.point) {
  10135. this.cursor_.rawValue = -1;
  10136. return;
  10137. }
  10138. this.cursor_.rawValue = Math.floor(Ee2(e.data.point.x, 0, e.data.bounds.width, 0, this.value.rawValue.length));
  10139. }
  10140. onGraphPointerUp_() {
  10141. this.cursor_.rawValue = -1;
  10142. }
  10143. }
  10144. function $r(n) {
  10145. return "format" in n && !_(n.format) ? n.format : Ve(2);
  10146. }
  10147. function Ec(n) {
  10148. var e;
  10149. return n.value.rawValue.length === 1 ? new Kr(n.document, {
  10150. formatter: $r(n.params),
  10151. value: n.value,
  10152. viewProps: n.viewProps
  10153. }) : new Hr(n.document, {
  10154. formatter: $r(n.params),
  10155. lineCount: (e = n.params.lineCount) !== null && e !== void 0 ? e : Bi.monitor.defaultLineCount,
  10156. value: n.value,
  10157. viewProps: n.viewProps
  10158. });
  10159. }
  10160. function Cc(n) {
  10161. var e, t, l;
  10162. return new xc(n.document, {
  10163. formatter: $r(n.params),
  10164. lineCount: (e = n.params.lineCount) !== null && e !== void 0 ? e : Bi.monitor.defaultLineCount,
  10165. props: X2.fromObject({
  10166. maxValue: (t = "max" in n.params ? n.params.max : null) !== null && t !== void 0 ? t : 100,
  10167. minValue: (l = "min" in n.params ? n.params.min : null) !== null && l !== void 0 ? l : 0
  10168. }),
  10169. value: n.value,
  10170. viewProps: n.viewProps
  10171. });
  10172. }
  10173. function Jo(n) {
  10174. return "view" in n && n.view === "graph";
  10175. }
  10176. const Pc = {
  10177. id: "monitor-number",
  10178. type: "monitor",
  10179. accept: (n, e) => {
  10180. if (typeof n != "number")
  10181. return null;
  10182. const t = M, l = ce(e, {
  10183. format: t.optional.function,
  10184. lineCount: t.optional.number,
  10185. max: t.optional.number,
  10186. min: t.optional.number,
  10187. view: t.optional.string
  10188. });
  10189. return l ? {
  10190. initialValue: n,
  10191. params: l
  10192. } : null;
  10193. },
  10194. binding: {
  10195. defaultBufferSize: (n) => Jo(n) ? 64 : 1,
  10196. reader: (n) => ws
  10197. },
  10198. controller: (n) => Jo(n.params) ? Cc(n) : Ec(n)
  10199. }, Tc = {
  10200. id: "monitor-string",
  10201. type: "monitor",
  10202. accept: (n, e) => {
  10203. if (typeof n != "string")
  10204. return null;
  10205. const t = M, l = ce(e, {
  10206. lineCount: t.optional.number,
  10207. multiline: t.optional.boolean
  10208. });
  10209. return l ? {
  10210. initialValue: n,
  10211. params: l
  10212. } : null;
  10213. },
  10214. binding: {
  10215. reader: (n) => Ai
  10216. },
  10217. controller: (n) => {
  10218. var e;
  10219. const t = n.value;
  10220. return t.rawValue.length > 1 || "multiline" in n.params && n.params.multiline ? new Hr(n.document, {
  10221. formatter: ct2,
  10222. lineCount: (e = n.params.lineCount) !== null && e !== void 0 ? e : Bi.monitor.defaultLineCount,
  10223. value: t,
  10224. viewProps: n.viewProps
  10225. }) : new Kr(n.document, {
  10226. formatter: ct2,
  10227. value: t,
  10228. viewProps: n.viewProps
  10229. });
  10230. }
  10231. };
  10232. class kc {
  10233. constructor(e) {
  10234. this.onValueChange_ = this.onValueChange_.bind(this), this.reader = e.reader, this.writer = e.writer, this.emitter = new F2(), this.value = e.value, this.value.emitter.on("change", this.onValueChange_), this.target = e.target, this.read();
  10235. }
  10236. read() {
  10237. const e = this.target.read();
  10238. e !== void 0 && (this.value.rawValue = this.reader(e));
  10239. }
  10240. write_(e) {
  10241. this.writer(this.target, e);
  10242. }
  10243. onValueChange_(e) {
  10244. this.write_(e.rawValue), this.emitter.emit("change", {
  10245. options: e.options,
  10246. rawValue: e.rawValue,
  10247. sender: this
  10248. });
  10249. }
  10250. }
  10251. function Mc(n, e) {
  10252. const t = n.accept(e.target.read(), e.params);
  10253. if (_(t))
  10254. return null;
  10255. const l = M, v = {
  10256. target: e.target,
  10257. initialValue: t.initialValue,
  10258. params: t.params
  10259. }, E = n.binding.reader(v), k2 = n.binding.constraint ? n.binding.constraint(v) : void 0, B2 = te2(E(t.initialValue), {
  10260. constraint: k2,
  10261. equals: n.binding.equals
  10262. }), Q = new kc({
  10263. reader: E,
  10264. target: e.target,
  10265. value: B2,
  10266. writer: n.binding.writer(v)
  10267. }), ee = l.optional.boolean(e.params.disabled).value, me2 = l.optional.boolean(e.params.hidden).value, be = n.controller({
  10268. constraint: k2,
  10269. document: e.document,
  10270. initialValue: t.initialValue,
  10271. params: t.params,
  10272. value: Q.value,
  10273. viewProps: Qe2.create({
  10274. disabled: ee,
  10275. hidden: me2
  10276. })
  10277. }), Ft = l.optional.string(e.params.label).value;
  10278. return new ze(e.document, {
  10279. binding: Q,
  10280. blade: xe(),
  10281. props: X2.fromObject({
  10282. label: Ft ?? e.target.key
  10283. }),
  10284. valueController: be
  10285. });
  10286. }
  10287. class Sc {
  10288. constructor(e) {
  10289. this.onTick_ = this.onTick_.bind(this), this.reader_ = e.reader, this.target = e.target, this.emitter = new F2(), this.value = e.value, this.ticker = e.ticker, this.ticker.emitter.on("tick", this.onTick_), this.read();
  10290. }
  10291. dispose() {
  10292. this.ticker.dispose();
  10293. }
  10294. read() {
  10295. const e = this.target.read();
  10296. if (e === void 0)
  10297. return;
  10298. const t = this.value.rawValue, l = this.reader_(e);
  10299. this.value.rawValue = Cs(t, l), this.emitter.emit("update", {
  10300. rawValue: l,
  10301. sender: this
  10302. });
  10303. }
  10304. onTick_(e) {
  10305. this.read();
  10306. }
  10307. }
  10308. function Ac(n, e) {
  10309. return e === 0 ? new as() : new yi(n, e ?? Bi.monitor.defaultInterval);
  10310. }
  10311. function Lc(n, e) {
  10312. var t, l, v;
  10313. const E = M, k2 = n.accept(e.target.read(), e.params);
  10314. if (_(k2))
  10315. return null;
  10316. const B2 = {
  10317. target: e.target,
  10318. initialValue: k2.initialValue,
  10319. params: k2.params
  10320. }, Q = n.binding.reader(B2), ee = (l = (t = E.optional.number(e.params.bufferSize).value) !== null && t !== void 0 ? t : n.binding.defaultBufferSize && n.binding.defaultBufferSize(k2.params)) !== null && l !== void 0 ? l : 1, me2 = E.optional.number(e.params.interval).value, be = new Sc({
  10321. reader: Q,
  10322. target: e.target,
  10323. ticker: Ac(e.document, me2),
  10324. value: xs(ee)
  10325. }), Ft = E.optional.boolean(e.params.disabled).value, ji = E.optional.boolean(e.params.hidden).value, zi = n.controller({
  10326. document: e.document,
  10327. params: k2.params,
  10328. value: be.value,
  10329. viewProps: Qe2.create({
  10330. disabled: Ft,
  10331. hidden: ji
  10332. })
  10333. }), ri = (v = E.optional.string(e.params.label).value) !== null && v !== void 0 ? v : e.target.key;
  10334. return new ot(e.document, {
  10335. binding: be,
  10336. blade: xe(),
  10337. props: X2.fromObject({
  10338. label: ri
  10339. }),
  10340. valueController: zi
  10341. });
  10342. }
  10343. class Rc {
  10344. constructor() {
  10345. this.pluginsMap_ = {
  10346. blades: [],
  10347. inputs: [],
  10348. monitors: []
  10349. };
  10350. }
  10351. getAll() {
  10352. return [
  10353. ...this.pluginsMap_.blades,
  10354. ...this.pluginsMap_.inputs,
  10355. ...this.pluginsMap_.monitors
  10356. ];
  10357. }
  10358. register(e) {
  10359. e.type === "blade" ? this.pluginsMap_.blades.unshift(e) : e.type === "input" ? this.pluginsMap_.inputs.unshift(e) : e.type === "monitor" && this.pluginsMap_.monitors.unshift(e);
  10360. }
  10361. createInput(e, t, l) {
  10362. const v = t.read();
  10363. if (_(v))
  10364. throw new S({
  10365. context: {
  10366. key: t.key
  10367. },
  10368. type: "nomatchingcontroller"
  10369. });
  10370. const E = this.pluginsMap_.inputs.reduce((k2, B2) => k2 ?? Mc(B2, {
  10371. document: e,
  10372. target: t,
  10373. params: l
  10374. }), null);
  10375. if (E)
  10376. return E;
  10377. throw new S({
  10378. context: {
  10379. key: t.key
  10380. },
  10381. type: "nomatchingcontroller"
  10382. });
  10383. }
  10384. createMonitor(e, t, l) {
  10385. const v = this.pluginsMap_.monitors.reduce((E, k2) => E ?? Lc(k2, {
  10386. document: e,
  10387. params: l,
  10388. target: t
  10389. }), null);
  10390. if (v)
  10391. return v;
  10392. throw new S({
  10393. context: {
  10394. key: t.key
  10395. },
  10396. type: "nomatchingcontroller"
  10397. });
  10398. }
  10399. createBlade(e, t) {
  10400. const l = this.pluginsMap_.blades.reduce((v, E) => v ?? rr(E, {
  10401. document: e,
  10402. params: t
  10403. }), null);
  10404. if (!l)
  10405. throw new S({
  10406. type: "nomatchingview",
  10407. context: {
  10408. params: t
  10409. }
  10410. });
  10411. return l;
  10412. }
  10413. createBladeApi(e) {
  10414. if (e instanceof ze)
  10415. return new di(e);
  10416. if (e instanceof ot)
  10417. return new mi(e);
  10418. if (e instanceof un)
  10419. return new Kn(e, this);
  10420. const t = this.pluginsMap_.blades.reduce((l, v) => l ?? v.api({
  10421. controller: e,
  10422. pool: this
  10423. }), null);
  10424. if (!t)
  10425. throw S.shouldNeverHappen();
  10426. return t;
  10427. }
  10428. }
  10429. function Ic() {
  10430. const n = new Rc();
  10431. return [
  10432. Bc,
  10433. pc,
  10434. fc,
  10435. bc,
  10436. nc,
  10437. Zl,
  10438. Ql,
  10439. $l,
  10440. Ms,
  10441. wc,
  10442. Tc,
  10443. Pc,
  10444. J2,
  10445. er,
  10446. nr,
  10447. wi
  10448. ].forEach((e) => {
  10449. n.register(e);
  10450. }), n;
  10451. }
  10452. function Vc(n) {
  10453. return Wt.isObject(n) ? new Wt(n.x, n.y) : new Wt();
  10454. }
  10455. function Dc(n, e) {
  10456. n.writeProperty("x", e.x), n.writeProperty("y", e.y);
  10457. }
  10458. function Nt(n, e) {
  10459. if (!n)
  10460. return;
  10461. const t = [], l = Ko(n, e);
  10462. l && t.push(l);
  10463. const v = $o(n);
  10464. return v && t.push(v), new Ct2(t);
  10465. }
  10466. function Oc(n, e) {
  10467. return new Zt({
  10468. assembly: Xo,
  10469. components: [
  10470. Nt("x" in n ? n.x : void 0, e.x),
  10471. Nt("y" in n ? n.y : void 0, e.y)
  10472. ]
  10473. });
  10474. }
  10475. function ea(n, e) {
  10476. const [t, l] = n ? ec(n) : [];
  10477. if (!_(t) || !_(l))
  10478. return Math.max(Math.abs(t ?? 0), Math.abs(l ?? 0));
  10479. const v = qt(n);
  10480. return Math.max(Math.abs(v) * 10, Math.abs(e) * 10);
  10481. }
  10482. function Nc(n, e) {
  10483. const t = e instanceof Zt ? e.components[0] : void 0, l = e instanceof Zt ? e.components[1] : void 0, v = ea(t, n.x), E = ea(l, n.y);
  10484. return Math.max(v, E);
  10485. }
  10486. function ta(n, e) {
  10487. return {
  10488. baseStep: qt(e),
  10489. constraint: e,
  10490. textProps: X2.fromObject({
  10491. draggingScale: Qt(e, n),
  10492. formatter: Ve(Jn(e, n))
  10493. })
  10494. };
  10495. }
  10496. function Fc(n) {
  10497. if (!("y" in n))
  10498. return false;
  10499. const e = n.y;
  10500. return e && "inverted" in e ? !!e.inverted : false;
  10501. }
  10502. const Bc = {
  10503. id: "input-point2d",
  10504. type: "input",
  10505. accept: (n, e) => {
  10506. if (!Wt.isObject(n))
  10507. return null;
  10508. const t = M, l = ce(e, {
  10509. expanded: t.optional.boolean,
  10510. picker: t.optional.custom(kt),
  10511. x: t.optional.custom(gt2),
  10512. y: t.optional.object({
  10513. inverted: t.optional.boolean,
  10514. max: t.optional.number,
  10515. min: t.optional.number,
  10516. step: t.optional.number
  10517. })
  10518. });
  10519. return l ? {
  10520. initialValue: n,
  10521. params: l
  10522. } : null;
  10523. },
  10524. binding: {
  10525. reader: (n) => Vc,
  10526. constraint: (n) => Oc(n.params, n.initialValue),
  10527. equals: Wt.equals,
  10528. writer: (n) => Dc
  10529. },
  10530. controller: (n) => {
  10531. const e = n.document, t = n.value, l = n.constraint;
  10532. if (!(l instanceof Zt))
  10533. throw S.shouldNeverHappen();
  10534. const v = "expanded" in n.params ? n.params.expanded : void 0, E = "picker" in n.params ? n.params.picker : void 0;
  10535. return new oc(e, {
  10536. axes: [
  10537. ta(t.rawValue.x, l.components[0]),
  10538. ta(t.rawValue.y, l.components[1])
  10539. ],
  10540. expanded: v ?? false,
  10541. invertsY: Fc(n.params),
  10542. maxValue: Nc(t.rawValue, l),
  10543. parser: lt2,
  10544. pickerLayout: E ?? "popup",
  10545. value: t,
  10546. viewProps: n.viewProps
  10547. });
  10548. }
  10549. };
  10550. class na extends a {
  10551. constructor(e) {
  10552. super(e), this.emitter_ = new F2(), this.controller_.valueController.value.emitter.on("change", (t) => {
  10553. this.emitter_.emit("change", {
  10554. event: new u(this, t.rawValue)
  10555. });
  10556. });
  10557. }
  10558. get label() {
  10559. return this.controller_.props.get("label");
  10560. }
  10561. set label(e) {
  10562. this.controller_.props.set("label", e);
  10563. }
  10564. get options() {
  10565. return this.controller_.valueController.props.get("options");
  10566. }
  10567. set options(e) {
  10568. this.controller_.valueController.props.set("options", e);
  10569. }
  10570. get value() {
  10571. return this.controller_.valueController.value.rawValue;
  10572. }
  10573. set value(e) {
  10574. this.controller_.valueController.value.rawValue = e;
  10575. }
  10576. on(e, t) {
  10577. const l = t.bind(this);
  10578. return this.emitter_.on(e, (v) => {
  10579. l(v.event);
  10580. }), this;
  10581. }
  10582. }
  10583. class ia extends a {
  10584. constructor(e) {
  10585. super(e), this.emitter_ = new F2(), this.controller_.valueController.value.emitter.on("change", (t) => {
  10586. this.emitter_.emit("change", {
  10587. event: new u(this, t.rawValue)
  10588. });
  10589. });
  10590. }
  10591. get label() {
  10592. return this.controller_.props.get("label");
  10593. }
  10594. set label(e) {
  10595. this.controller_.props.set("label", e);
  10596. }
  10597. get maxValue() {
  10598. return this.controller_.valueController.sliderController.props.get("maxValue");
  10599. }
  10600. set maxValue(e) {
  10601. this.controller_.valueController.sliderController.props.set("maxValue", e);
  10602. }
  10603. get minValue() {
  10604. return this.controller_.valueController.sliderController.props.get("minValue");
  10605. }
  10606. set minValue(e) {
  10607. this.controller_.valueController.sliderController.props.set("minValue", e);
  10608. }
  10609. get value() {
  10610. return this.controller_.valueController.value.rawValue;
  10611. }
  10612. set value(e) {
  10613. this.controller_.valueController.value.rawValue = e;
  10614. }
  10615. on(e, t) {
  10616. const l = t.bind(this);
  10617. return this.emitter_.on(e, (v) => {
  10618. l(v.event);
  10619. }), this;
  10620. }
  10621. }
  10622. class sa extends a {
  10623. constructor(e) {
  10624. super(e), this.emitter_ = new F2(), this.controller_.valueController.value.emitter.on("change", (t) => {
  10625. this.emitter_.emit("change", {
  10626. event: new u(this, t.rawValue)
  10627. });
  10628. });
  10629. }
  10630. get label() {
  10631. return this.controller_.props.get("label");
  10632. }
  10633. set label(e) {
  10634. this.controller_.props.set("label", e);
  10635. }
  10636. get formatter() {
  10637. return this.controller_.valueController.props.get("formatter");
  10638. }
  10639. set formatter(e) {
  10640. this.controller_.valueController.props.set("formatter", e);
  10641. }
  10642. get value() {
  10643. return this.controller_.valueController.value.rawValue;
  10644. }
  10645. set value(e) {
  10646. this.controller_.valueController.value.rawValue = e;
  10647. }
  10648. on(e, t) {
  10649. const l = t.bind(this);
  10650. return this.emitter_.on(e, (v) => {
  10651. l(v.event);
  10652. }), this;
  10653. }
  10654. }
  10655. const jc = function() {
  10656. return {
  10657. id: "list",
  10658. type: "blade",
  10659. accept(n) {
  10660. const e = M, t = ce(n, {
  10661. options: e.required.custom(xn),
  10662. value: e.required.raw,
  10663. view: e.required.constant("list"),
  10664. label: e.optional.string
  10665. });
  10666. return t ? { params: t } : null;
  10667. },
  10668. controller(n) {
  10669. const e = new at(Vi(n.params.options)), t = te2(n.params.value, {
  10670. constraint: e
  10671. }), l = new mn(n.document, {
  10672. props: new X2({
  10673. options: e.values.value("options")
  10674. }),
  10675. value: t,
  10676. viewProps: n.viewProps
  10677. });
  10678. return new Gt(n.document, {
  10679. blade: n.blade,
  10680. props: X2.fromObject({
  10681. label: n.params.label
  10682. }),
  10683. valueController: l
  10684. });
  10685. },
  10686. api(n) {
  10687. return !(n.controller instanceof Gt) || !(n.controller.valueController instanceof mn) ? null : new na(n.controller);
  10688. }
  10689. };
  10690. }();
  10691. function zc(n) {
  10692. return n.reduce((e, t) => Object.assign(e, {
  10693. [t.presetKey]: t.read()
  10694. }), {});
  10695. }
  10696. function Uc(n, e) {
  10697. n.forEach((t) => {
  10698. const l = e[t.presetKey];
  10699. l !== void 0 && t.write(l);
  10700. });
  10701. }
  10702. class Gc extends fi {
  10703. /**
  10704. * @hidden
  10705. */
  10706. constructor(e, t) {
  10707. super(e, t);
  10708. }
  10709. get element() {
  10710. return this.controller_.view.element;
  10711. }
  10712. /**
  10713. * Imports a preset of all inputs.
  10714. * @param preset The preset object to import.
  10715. */
  10716. importPreset(e) {
  10717. const t = this.controller_.rackController.rack.find(ze).map((l) => l.binding.target);
  10718. Uc(t, e), this.refresh();
  10719. }
  10720. /**
  10721. * Exports a preset of all inputs.
  10722. * @return An exported preset object.
  10723. */
  10724. exportPreset() {
  10725. const e = this.controller_.rackController.rack.find(ze).map((t) => t.binding.target);
  10726. return zc(e);
  10727. }
  10728. /**
  10729. * Refreshes all bindings of the pane.
  10730. */
  10731. refresh() {
  10732. this.controller_.rackController.rack.find(ze).forEach((e) => {
  10733. e.binding.read();
  10734. }), this.controller_.rackController.rack.find(ot).forEach((e) => {
  10735. e.binding.read();
  10736. });
  10737. }
  10738. }
  10739. class Hc extends $n {
  10740. constructor(e, t) {
  10741. super(e, {
  10742. expanded: t.expanded,
  10743. blade: t.blade,
  10744. props: t.props,
  10745. root: true,
  10746. viewProps: t.viewProps
  10747. });
  10748. }
  10749. }
  10750. const Kc = {
  10751. id: "slider",
  10752. type: "blade",
  10753. accept(n) {
  10754. const e = M, t = ce(n, {
  10755. max: e.required.number,
  10756. min: e.required.number,
  10757. view: e.required.constant("slider"),
  10758. format: e.optional.function,
  10759. label: e.optional.string,
  10760. value: e.optional.number
  10761. });
  10762. return t ? { params: t } : null;
  10763. },
  10764. controller(n) {
  10765. var e, t;
  10766. const l = (e = n.params.value) !== null && e !== void 0 ? e : 0, v = new Vt({
  10767. max: n.params.max,
  10768. min: n.params.min
  10769. }), E = new yn(n.document, {
  10770. baseStep: 1,
  10771. parser: lt2,
  10772. sliderProps: new X2({
  10773. maxValue: v.values.value("max"),
  10774. minValue: v.values.value("min")
  10775. }),
  10776. textProps: X2.fromObject({
  10777. draggingScale: Qt(void 0, l),
  10778. formatter: (t = n.params.format) !== null && t !== void 0 ? t : Dt
  10779. }),
  10780. value: te2(l, {
  10781. constraint: v
  10782. }),
  10783. viewProps: n.viewProps
  10784. });
  10785. return new Gt(n.document, {
  10786. blade: n.blade,
  10787. props: X2.fromObject({
  10788. label: n.params.label
  10789. }),
  10790. valueController: E
  10791. });
  10792. },
  10793. api(n) {
  10794. return !(n.controller instanceof Gt) || !(n.controller.valueController instanceof yn) ? null : new ia(n.controller);
  10795. }
  10796. }, $c = function() {
  10797. return {
  10798. id: "text",
  10799. type: "blade",
  10800. accept(n) {
  10801. const e = M, t = ce(n, {
  10802. parse: e.required.function,
  10803. value: e.required.raw,
  10804. view: e.required.constant("text"),
  10805. format: e.optional.function,
  10806. label: e.optional.string
  10807. });
  10808. return t ? { params: t } : null;
  10809. },
  10810. controller(n) {
  10811. var e;
  10812. const t = new qn(n.document, {
  10813. parser: n.params.parse,
  10814. props: X2.fromObject({
  10815. formatter: (e = n.params.format) !== null && e !== void 0 ? e : (l) => String(l)
  10816. }),
  10817. value: te2(n.params.value),
  10818. viewProps: n.viewProps
  10819. });
  10820. return new Gt(n.document, {
  10821. blade: n.blade,
  10822. props: X2.fromObject({
  10823. label: n.params.label
  10824. }),
  10825. valueController: t
  10826. });
  10827. },
  10828. api(n) {
  10829. return !(n.controller instanceof Gt) || !(n.controller.valueController instanceof qn) ? null : new sa(n.controller);
  10830. }
  10831. };
  10832. }();
  10833. function Xc(n) {
  10834. const e = n.createElement("div");
  10835. return e.classList.add(D2("dfw")()), n.body && n.body.appendChild(e), e;
  10836. }
  10837. function ra(n, e, t) {
  10838. if (n.querySelector(`style[data-tp-style=${e}]`))
  10839. return;
  10840. const l = n.createElement("style");
  10841. l.dataset.tpStyle = e, l.textContent = t, n.head.appendChild(l);
  10842. }
  10843. class Yc extends Gc {
  10844. constructor(e) {
  10845. var t, l;
  10846. const v = e ?? {}, E = (t = v.document) !== null && t !== void 0 ? t : ui(), k2 = Ic(), B2 = new Hc(E, {
  10847. expanded: v.expanded,
  10848. blade: xe(),
  10849. props: X2.fromObject({
  10850. title: v.title
  10851. }),
  10852. viewProps: Qe2.create()
  10853. });
  10854. super(B2, k2), this.pool_ = k2, this.containerElem_ = (l = v.container) !== null && l !== void 0 ? l : Xc(E), this.containerElem_.appendChild(this.element), this.doc_ = E, this.usesDefaultWrapper_ = !v.container, this.setUpDefaultPlugins_();
  10855. }
  10856. get document() {
  10857. if (!this.doc_)
  10858. throw S.alreadyDisposed();
  10859. return this.doc_;
  10860. }
  10861. dispose() {
  10862. const e = this.containerElem_;
  10863. if (!e)
  10864. throw S.alreadyDisposed();
  10865. if (this.usesDefaultWrapper_) {
  10866. const t = e.parentElement;
  10867. t && t.removeChild(e);
  10868. }
  10869. this.containerElem_ = null, this.doc_ = null, super.dispose();
  10870. }
  10871. registerPlugin(e) {
  10872. ("plugin" in e ? [e.plugin] : "plugins" in e ? e.plugins : []).forEach((l) => {
  10873. this.pool_.register(l), this.embedPluginStyle_(l);
  10874. });
  10875. }
  10876. embedPluginStyle_(e) {
  10877. e.css && ra(this.document, `plugin-${e.id}`, e.css);
  10878. }
  10879. setUpDefaultPlugins_() {
  10880. ra(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(230deg, 7%, 17%));--bs-sh: var(--tp-base-shadow-color, rgba(0, 0, 0, 0.2));--btn-bg: var(--tp-button-background-color, hsl(230deg, 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(230deg, 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(230deg, 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(230deg, 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-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) => {
  10881. this.embedPluginStyle_(e);
  10882. }), this.registerPlugin({
  10883. plugins: [
  10884. Kc,
  10885. jc,
  10886. wi,
  10887. $c
  10888. ]
  10889. });
  10890. }
  10891. }
  10892. const qc = new s("3.1.4");
  10893. r.BladeApi = a, r.ButtonApi = j, r.FolderApi = fi, r.InputBindingApi = di, r.ListApi = na, r.MonitorBindingApi = mi, r.Pane = Yc, r.SeparatorApi = is, r.SliderApi = ia, r.TabApi = rs, r.TabPageApi = _i, r.TextApi = sa, r.TpChangeEvent = u, r.VERSION = qc, Object.defineProperty(r, "__esModule", { value: true });
  10894. });
  10895. })(Th, zs);
  10896. var Wi = {};
  10897. var kh = {
  10898. get exports() {
  10899. return Wi;
  10900. },
  10901. set exports(b2) {
  10902. Wi = b2;
  10903. }
  10904. };
  10905. (function(b2, i) {
  10906. (function(r, s) {
  10907. s(i);
  10908. })(tl, function(r) {
  10909. class s {
  10910. constructor(o) {
  10911. this.controller_ = o;
  10912. }
  10913. get element() {
  10914. return this.controller_.view.element;
  10915. }
  10916. get disabled() {
  10917. return this.controller_.viewProps.get("disabled");
  10918. }
  10919. set disabled(o) {
  10920. this.controller_.viewProps.set("disabled", o);
  10921. }
  10922. get hidden() {
  10923. return this.controller_.viewProps.get("hidden");
  10924. }
  10925. set hidden(o) {
  10926. this.controller_.viewProps.set("hidden", o);
  10927. }
  10928. dispose() {
  10929. this.controller_.viewProps.set("disposed", true);
  10930. }
  10931. }
  10932. class a {
  10933. constructor(o) {
  10934. this.target = o;
  10935. }
  10936. }
  10937. class c extends a {
  10938. constructor(o, p, f, x) {
  10939. super(o), this.value = p, this.presetKey = f, this.last = x ?? true;
  10940. }
  10941. }
  10942. function u(d) {
  10943. return d;
  10944. }
  10945. function h2(d) {
  10946. return d == null;
  10947. }
  10948. const m = {
  10949. alreadydisposed: () => "View has been already disposed",
  10950. invalidparams: (d) => `Invalid parameters for '${d.name}'`,
  10951. nomatchingcontroller: (d) => `No matching controller for '${d.key}'`,
  10952. nomatchingview: (d) => `No matching view for '${JSON.stringify(d.params)}'`,
  10953. notbindable: () => "Value is not bindable",
  10954. propertynotfound: (d) => `Property '${d.name}' not found`,
  10955. shouldneverhappen: () => "This error should never happen"
  10956. };
  10957. class g {
  10958. constructor(o) {
  10959. var p;
  10960. this.message = (p = m[o.type](o.context)) !== null && p !== void 0 ? p : "Unexpected error", this.name = this.constructor.name, this.stack = new Error(this.message).stack, this.type = o.type;
  10961. }
  10962. static alreadyDisposed() {
  10963. return new g({ type: "alreadydisposed" });
  10964. }
  10965. static notBindable() {
  10966. return new g({
  10967. type: "notbindable"
  10968. });
  10969. }
  10970. static propertyNotFound(o) {
  10971. return new g({
  10972. type: "propertynotfound",
  10973. context: {
  10974. name: o
  10975. }
  10976. });
  10977. }
  10978. static shouldNeverHappen() {
  10979. return new g({ type: "shouldneverhappen" });
  10980. }
  10981. }
  10982. class w {
  10983. constructor() {
  10984. this.observers_ = {};
  10985. }
  10986. on(o, p) {
  10987. let f = this.observers_[o];
  10988. return f || (f = this.observers_[o] = []), f.push({
  10989. handler: p
  10990. }), this;
  10991. }
  10992. off(o, p) {
  10993. const f = this.observers_[o];
  10994. return f && (this.observers_[o] = f.filter((x) => x.handler !== p)), this;
  10995. }
  10996. emit(o, p) {
  10997. const f = this.observers_[o];
  10998. f && f.forEach((x) => {
  10999. x.handler(p);
  11000. });
  11001. }
  11002. }
  11003. const _ = "tp";
  11004. function y2(d) {
  11005. return (p, f) => [
  11006. _,
  11007. "-",
  11008. d,
  11009. "v",
  11010. p ? `_${p}` : "",
  11011. f ? `-${f}` : ""
  11012. ].join("");
  11013. }
  11014. function C(d, o) {
  11015. return (p) => o(d(p));
  11016. }
  11017. function I2(d) {
  11018. return d.rawValue;
  11019. }
  11020. function S(d, o) {
  11021. d.emitter.on("change", C(I2, o)), o(d.rawValue);
  11022. }
  11023. function R(d, o, p) {
  11024. S(d.value(o), p);
  11025. }
  11026. function j(d, o, p) {
  11027. p ? d.classList.add(o) : d.classList.remove(o);
  11028. }
  11029. function F2(d, o) {
  11030. return (p) => {
  11031. j(d, o, p);
  11032. };
  11033. }
  11034. function V(d, o) {
  11035. S(d, (p) => {
  11036. o.textContent = p ?? "";
  11037. });
  11038. }
  11039. const D2 = y2("btn");
  11040. class Y2 {
  11041. constructor(o, p) {
  11042. this.element = o.createElement("div"), this.element.classList.add(D2()), p.viewProps.bindClassModifiers(this.element);
  11043. const f = o.createElement("button");
  11044. f.classList.add(D2("b")), p.viewProps.bindDisabled(f), this.element.appendChild(f), this.buttonElement = f;
  11045. const x = o.createElement("div");
  11046. x.classList.add(D2("t")), V(p.props.value("title"), x), this.buttonElement.appendChild(x);
  11047. }
  11048. }
  11049. class G {
  11050. constructor(o, p) {
  11051. this.emitter = new w(), this.onClick_ = this.onClick_.bind(this), this.props = p.props, this.viewProps = p.viewProps, this.view = new Y2(o, {
  11052. props: this.props,
  11053. viewProps: this.viewProps
  11054. }), this.view.buttonElement.addEventListener("click", this.onClick_);
  11055. }
  11056. onClick_() {
  11057. this.emitter.emit("click", {
  11058. sender: this
  11059. });
  11060. }
  11061. }
  11062. class N2 {
  11063. constructor(o, p) {
  11064. var f;
  11065. this.constraint_ = p == null ? void 0 : p.constraint, this.equals_ = (f = p == null ? void 0 : p.equals) !== null && f !== void 0 ? f : (x, T) => x === T, this.emitter = new w(), this.rawValue_ = o;
  11066. }
  11067. get constraint() {
  11068. return this.constraint_;
  11069. }
  11070. get rawValue() {
  11071. return this.rawValue_;
  11072. }
  11073. set rawValue(o) {
  11074. this.setRawValue(o, {
  11075. forceEmit: false,
  11076. last: true
  11077. });
  11078. }
  11079. setRawValue(o, p) {
  11080. const f = p ?? {
  11081. forceEmit: false,
  11082. last: true
  11083. }, x = this.constraint_ ? this.constraint_.constrain(o) : o, T = this.rawValue_;
  11084. this.equals_(T, x) && !f.forceEmit || (this.emitter.emit("beforechange", {
  11085. sender: this
  11086. }), this.rawValue_ = x, this.emitter.emit("change", {
  11087. options: f,
  11088. previousRawValue: T,
  11089. rawValue: x,
  11090. sender: this
  11091. }));
  11092. }
  11093. }
  11094. class O {
  11095. constructor(o) {
  11096. this.emitter = new w(), this.value_ = o;
  11097. }
  11098. get rawValue() {
  11099. return this.value_;
  11100. }
  11101. set rawValue(o) {
  11102. this.setRawValue(o, {
  11103. forceEmit: false,
  11104. last: true
  11105. });
  11106. }
  11107. setRawValue(o, p) {
  11108. const f = p ?? {
  11109. forceEmit: false,
  11110. last: true
  11111. }, x = this.value_;
  11112. x === o && !f.forceEmit || (this.emitter.emit("beforechange", {
  11113. sender: this
  11114. }), this.value_ = o, this.emitter.emit("change", {
  11115. options: f,
  11116. previousRawValue: x,
  11117. rawValue: this.value_,
  11118. sender: this
  11119. }));
  11120. }
  11121. }
  11122. function H(d, o) {
  11123. const p = o == null ? void 0 : o.constraint, f = o == null ? void 0 : o.equals;
  11124. return !p && !f ? new O(d) : new N2(d, o);
  11125. }
  11126. class K {
  11127. constructor(o) {
  11128. this.emitter = new w(), this.valMap_ = o;
  11129. for (const p in this.valMap_)
  11130. this.valMap_[p].emitter.on("change", () => {
  11131. this.emitter.emit("change", {
  11132. key: p,
  11133. sender: this
  11134. });
  11135. });
  11136. }
  11137. static createCore(o) {
  11138. return Object.keys(o).reduce((f, x) => Object.assign(f, {
  11139. [x]: H(o[x])
  11140. }), {});
  11141. }
  11142. static fromObject(o) {
  11143. const p = this.createCore(o);
  11144. return new K(p);
  11145. }
  11146. get(o) {
  11147. return this.valMap_[o].rawValue;
  11148. }
  11149. set(o, p) {
  11150. this.valMap_[o].rawValue = p;
  11151. }
  11152. value(o) {
  11153. return this.valMap_[o];
  11154. }
  11155. }
  11156. function q(d, o) {
  11157. const f = Object.keys(o).reduce((x, T) => {
  11158. if (x === void 0)
  11159. return;
  11160. const L = o[T], z = L(d[T]);
  11161. return z.succeeded ? Object.assign(Object.assign({}, x), { [T]: z.value }) : void 0;
  11162. }, {});
  11163. return f;
  11164. }
  11165. function he(d, o) {
  11166. return d.reduce((p, f) => {
  11167. if (p === void 0)
  11168. return;
  11169. const x = o(f);
  11170. if (!(!x.succeeded || x.value === void 0))
  11171. return [...p, x.value];
  11172. }, []);
  11173. }
  11174. function _e(d) {
  11175. return d === null ? false : typeof d == "object";
  11176. }
  11177. function pe(d) {
  11178. return (o) => (p) => {
  11179. if (!o && p === void 0)
  11180. return {
  11181. succeeded: false,
  11182. value: void 0
  11183. };
  11184. if (o && p === void 0)
  11185. return {
  11186. succeeded: true,
  11187. value: void 0
  11188. };
  11189. const f = d(p);
  11190. return f !== void 0 ? {
  11191. succeeded: true,
  11192. value: f
  11193. } : {
  11194. succeeded: false,
  11195. value: void 0
  11196. };
  11197. };
  11198. }
  11199. function fe2(d) {
  11200. return {
  11201. custom: (o) => pe(o)(d),
  11202. boolean: pe((o) => typeof o == "boolean" ? o : void 0)(d),
  11203. number: pe((o) => typeof o == "number" ? o : void 0)(d),
  11204. string: pe((o) => typeof o == "string" ? o : void 0)(d),
  11205. function: pe((o) => typeof o == "function" ? o : void 0)(d),
  11206. constant: (o) => pe((p) => p === o ? o : void 0)(d),
  11207. raw: pe((o) => o)(d),
  11208. object: (o) => pe((p) => {
  11209. if (_e(p))
  11210. return q(p, o);
  11211. })(d),
  11212. array: (o) => pe((p) => {
  11213. if (Array.isArray(p))
  11214. return he(p, o);
  11215. })(d)
  11216. };
  11217. }
  11218. const de2 = {
  11219. optional: fe2(true),
  11220. required: fe2(false)
  11221. };
  11222. function te2(d, o) {
  11223. const p = de2.required.object(o)(d);
  11224. return p.succeeded ? p.value : void 0;
  11225. }
  11226. function X2(d) {
  11227. console.warn([
  11228. `Missing '${d.key}' of ${d.target} in ${d.place}.`,
  11229. "Please rebuild plugins with the latest core package."
  11230. ].join(" "));
  11231. }
  11232. function ke(d) {
  11233. return d && d.parentElement && d.parentElement.removeChild(d), null;
  11234. }
  11235. class ve {
  11236. constructor(o) {
  11237. this.value_ = o;
  11238. }
  11239. static create(o) {
  11240. return [
  11241. new ve(o),
  11242. (p, f) => {
  11243. o.setRawValue(p, f);
  11244. }
  11245. ];
  11246. }
  11247. get emitter() {
  11248. return this.value_.emitter;
  11249. }
  11250. get rawValue() {
  11251. return this.value_.rawValue;
  11252. }
  11253. }
  11254. const le = y2("");
  11255. function ie(d, o) {
  11256. return F2(d, le(void 0, o));
  11257. }
  11258. class ge extends K {
  11259. constructor(o) {
  11260. var p;
  11261. super(o), this.onDisabledChange_ = this.onDisabledChange_.bind(this), this.onParentChange_ = this.onParentChange_.bind(this), this.onParentGlobalDisabledChange_ = this.onParentGlobalDisabledChange_.bind(this), [this.globalDisabled_, this.setGlobalDisabled_] = ve.create(H(this.getGlobalDisabled_())), this.value("disabled").emitter.on("change", this.onDisabledChange_), this.value("parent").emitter.on("change", this.onParentChange_), (p = this.get("parent")) === null || p === void 0 || p.globalDisabled.emitter.on("change", this.onParentGlobalDisabledChange_);
  11262. }
  11263. static create(o) {
  11264. var p, f, x;
  11265. const T = o ?? {};
  11266. return new ge(K.createCore({
  11267. disabled: (p = T.disabled) !== null && p !== void 0 ? p : false,
  11268. disposed: false,
  11269. hidden: (f = T.hidden) !== null && f !== void 0 ? f : false,
  11270. parent: (x = T.parent) !== null && x !== void 0 ? x : null
  11271. }));
  11272. }
  11273. get globalDisabled() {
  11274. return this.globalDisabled_;
  11275. }
  11276. bindClassModifiers(o) {
  11277. S(this.globalDisabled_, ie(o, "disabled")), R(this, "hidden", ie(o, "hidden"));
  11278. }
  11279. bindDisabled(o) {
  11280. S(this.globalDisabled_, (p) => {
  11281. o.disabled = p;
  11282. });
  11283. }
  11284. bindTabIndex(o) {
  11285. S(this.globalDisabled_, (p) => {
  11286. o.tabIndex = p ? -1 : 0;
  11287. });
  11288. }
  11289. handleDispose(o) {
  11290. this.value("disposed").emitter.on("change", (p) => {
  11291. p && o();
  11292. });
  11293. }
  11294. getGlobalDisabled_() {
  11295. const o = this.get("parent");
  11296. return (o ? o.globalDisabled.rawValue : false) || this.get("disabled");
  11297. }
  11298. updateGlobalDisabled_() {
  11299. this.setGlobalDisabled_(this.getGlobalDisabled_());
  11300. }
  11301. onDisabledChange_() {
  11302. this.updateGlobalDisabled_();
  11303. }
  11304. onParentGlobalDisabledChange_() {
  11305. this.updateGlobalDisabled_();
  11306. }
  11307. onParentChange_(o) {
  11308. var p;
  11309. const f = o.previousRawValue;
  11310. f == null || f.globalDisabled.emitter.off("change", this.onParentGlobalDisabledChange_), (p = this.get("parent")) === null || p === void 0 || p.globalDisabled.emitter.on("change", this.onParentGlobalDisabledChange_), this.updateGlobalDisabled_();
  11311. }
  11312. }
  11313. function M() {
  11314. return ["veryfirst", "first", "last", "verylast"];
  11315. }
  11316. const ce = y2(""), Oe = {
  11317. veryfirst: "vfst",
  11318. first: "fst",
  11319. last: "lst",
  11320. verylast: "vlst"
  11321. };
  11322. class je {
  11323. constructor(o) {
  11324. this.parent_ = null, this.blade = o.blade, this.view = o.view, this.viewProps = o.viewProps;
  11325. const p = this.view.element;
  11326. this.blade.value("positions").emitter.on("change", () => {
  11327. M().forEach((f) => {
  11328. p.classList.remove(ce(void 0, Oe[f]));
  11329. }), this.blade.get("positions").forEach((f) => {
  11330. p.classList.add(ce(void 0, Oe[f]));
  11331. });
  11332. }), this.viewProps.handleDispose(() => {
  11333. ke(p);
  11334. });
  11335. }
  11336. get parent() {
  11337. return this.parent_;
  11338. }
  11339. set parent(o) {
  11340. if (this.parent_ = o, !("parent" in this.viewProps.valMap_)) {
  11341. X2({
  11342. key: "parent",
  11343. target: ge.name,
  11344. place: "BladeController.parent"
  11345. });
  11346. return;
  11347. }
  11348. this.viewProps.set("parent", this.parent_ ? this.parent_.viewProps : null);
  11349. }
  11350. }
  11351. const ye = "http://www.w3.org/2000/svg";
  11352. function st2(d) {
  11353. d.offsetHeight;
  11354. }
  11355. function Fn(d, o) {
  11356. const p = d.style.transition;
  11357. d.style.transition = "none", o(), d.style.transition = p;
  11358. }
  11359. function Qe2(d) {
  11360. return d.ontouchstart !== void 0;
  11361. }
  11362. function Bn(d) {
  11363. for (; d.childNodes.length > 0; )
  11364. d.removeChild(d.childNodes[0]);
  11365. }
  11366. function on(d) {
  11367. return d.relatedTarget ? d.relatedTarget : "explicitOriginalTarget" in d ? d.explicitOriginalTarget : null;
  11368. }
  11369. const mt2 = y2("lbl");
  11370. function At(d, o) {
  11371. const p = d.createDocumentFragment();
  11372. return o.split(`
  11373. `).map((x) => d.createTextNode(x)).forEach((x, T) => {
  11374. T > 0 && p.appendChild(d.createElement("br")), p.appendChild(x);
  11375. }), p;
  11376. }
  11377. class He {
  11378. constructor(o, p) {
  11379. this.element = o.createElement("div"), this.element.classList.add(mt2()), p.viewProps.bindClassModifiers(this.element);
  11380. const f = o.createElement("div");
  11381. f.classList.add(mt2("l")), R(p.props, "label", (T) => {
  11382. h2(T) ? this.element.classList.add(mt2(void 0, "nol")) : (this.element.classList.remove(mt2(void 0, "nol")), Bn(f), f.appendChild(At(o, T)));
  11383. }), this.element.appendChild(f), this.labelElement = f;
  11384. const x = o.createElement("div");
  11385. x.classList.add(mt2("v")), this.element.appendChild(x), this.valueElement = x;
  11386. }
  11387. }
  11388. class rt2 extends je {
  11389. constructor(o, p) {
  11390. const f = p.valueController.viewProps;
  11391. super(Object.assign(Object.assign({}, p), { view: new He(o, {
  11392. props: p.props,
  11393. viewProps: f
  11394. }), viewProps: f })), this.props = p.props, this.valueController = p.valueController, this.view.valueElement.appendChild(this.valueController.view.element);
  11395. }
  11396. }
  11397. class an extends je {
  11398. constructor(o) {
  11399. super(o), this.value = o.value;
  11400. }
  11401. }
  11402. class ft2 extends K {
  11403. constructor(o) {
  11404. super(o);
  11405. }
  11406. static create(o) {
  11407. const p = {
  11408. completed: true,
  11409. expanded: o,
  11410. expandedHeight: null,
  11411. shouldFixHeight: false,
  11412. temporaryExpanded: null
  11413. }, f = K.createCore(p);
  11414. return new ft2(f);
  11415. }
  11416. get styleExpanded() {
  11417. var o;
  11418. return (o = this.get("temporaryExpanded")) !== null && o !== void 0 ? o : this.get("expanded");
  11419. }
  11420. get styleHeight() {
  11421. if (!this.styleExpanded)
  11422. return "0";
  11423. const o = this.get("expandedHeight");
  11424. return this.get("shouldFixHeight") && !h2(o) ? `${o}px` : "auto";
  11425. }
  11426. bindExpandedClass(o, p) {
  11427. const f = () => {
  11428. this.styleExpanded ? o.classList.add(p) : o.classList.remove(p);
  11429. };
  11430. R(this, "expanded", f), R(this, "temporaryExpanded", f);
  11431. }
  11432. cleanUpTransition() {
  11433. this.set("shouldFixHeight", false), this.set("expandedHeight", null), this.set("completed", true);
  11434. }
  11435. }
  11436. function jn(d) {
  11437. return ft2.create(d);
  11438. }
  11439. function ui(d, o) {
  11440. let p = 0;
  11441. return Fn(o, () => {
  11442. d.set("expandedHeight", null), d.set("temporaryExpanded", true), st2(o), p = o.clientHeight, d.set("temporaryExpanded", null), st2(o);
  11443. }), p;
  11444. }
  11445. function zn(d, o) {
  11446. o.style.height = d.styleHeight;
  11447. }
  11448. function Un(d, o) {
  11449. d.value("expanded").emitter.on("beforechange", () => {
  11450. d.set("completed", false), h2(d.get("expandedHeight")) && d.set("expandedHeight", ui(d, o)), d.set("shouldFixHeight", true), st2(o);
  11451. }), d.emitter.on("change", () => {
  11452. zn(d, o);
  11453. }), zn(d, o), o.addEventListener("transitionend", (p) => {
  11454. p.propertyName === "height" && d.cleanUpTransition();
  11455. });
  11456. }
  11457. class xt {
  11458. constructor(o, p) {
  11459. const f = y2(p.viewName);
  11460. this.element = o.createElement("div"), this.element.classList.add(f()), p.viewProps.bindClassModifiers(this.element);
  11461. }
  11462. }
  11463. class Lt extends an {
  11464. constructor(o, p) {
  11465. const f = p.valueController.viewProps;
  11466. super(Object.assign(Object.assign({}, p), { value: p.valueController.value, view: new He(o, {
  11467. props: p.props,
  11468. viewProps: f
  11469. }), viewProps: f })), this.props = p.props, this.valueController = p.valueController, this.view.valueElement.appendChild(this.valueController.view.element);
  11470. }
  11471. }
  11472. class Gn {
  11473. constructor() {
  11474. this.disabled = false, this.emitter = new w();
  11475. }
  11476. dispose() {
  11477. }
  11478. tick() {
  11479. this.disabled || this.emitter.emit("tick", {
  11480. sender: this
  11481. });
  11482. }
  11483. }
  11484. class ln {
  11485. constructor(o, p) {
  11486. this.disabled_ = false, this.timerId_ = null, this.onTick_ = this.onTick_.bind(this), this.doc_ = o, this.emitter = new w(), this.interval_ = p, this.setTimer_();
  11487. }
  11488. get disabled() {
  11489. return this.disabled_;
  11490. }
  11491. set disabled(o) {
  11492. this.disabled_ = o, this.disabled_ ? this.clearTimer_() : this.setTimer_();
  11493. }
  11494. dispose() {
  11495. this.clearTimer_();
  11496. }
  11497. clearTimer_() {
  11498. if (this.timerId_ === null)
  11499. return;
  11500. const o = this.doc_.defaultView;
  11501. o && o.clearInterval(this.timerId_), this.timerId_ = null;
  11502. }
  11503. setTimer_() {
  11504. if (this.clearTimer_(), this.interval_ <= 0)
  11505. return;
  11506. const o = this.doc_.defaultView;
  11507. o && (this.timerId_ = o.setInterval(this.onTick_, this.interval_));
  11508. }
  11509. onTick_() {
  11510. this.disabled_ || this.emitter.emit("tick", {
  11511. sender: this
  11512. });
  11513. }
  11514. }
  11515. class Hn {
  11516. constructor(o) {
  11517. this.constraints = o;
  11518. }
  11519. constrain(o) {
  11520. return this.constraints.reduce((p, f) => f.constrain(p), o);
  11521. }
  11522. }
  11523. function Et(d, o) {
  11524. if (d instanceof o)
  11525. return d;
  11526. if (d instanceof Hn) {
  11527. const p = d.constraints.reduce((f, x) => f || (x instanceof o ? x : null), null);
  11528. if (p)
  11529. return p;
  11530. }
  11531. return null;
  11532. }
  11533. class vt {
  11534. constructor(o) {
  11535. this.values = K.fromObject({
  11536. max: o.max,
  11537. min: o.min
  11538. });
  11539. }
  11540. constrain(o) {
  11541. const p = this.values.get("max"), f = this.values.get("min");
  11542. return Math.min(Math.max(o, f), p);
  11543. }
  11544. }
  11545. class Rt2 {
  11546. constructor(o) {
  11547. this.values = K.fromObject({
  11548. max: o.max,
  11549. min: o.min
  11550. });
  11551. }
  11552. get maxValue() {
  11553. return this.values.get("max");
  11554. }
  11555. get minValue() {
  11556. return this.values.get("min");
  11557. }
  11558. constrain(o) {
  11559. const p = this.values.get("max"), f = this.values.get("min");
  11560. let x = o;
  11561. return h2(f) || (x = Math.max(x, f)), h2(p) || (x = Math.min(x, p)), x;
  11562. }
  11563. }
  11564. class A {
  11565. constructor(o, p = 0) {
  11566. this.step = o, this.origin = p;
  11567. }
  11568. constrain(o) {
  11569. const p = this.origin % this.step, f = Math.round((o - p) / this.step);
  11570. return p + f * this.step;
  11571. }
  11572. }
  11573. const U2 = y2("pop");
  11574. class J2 {
  11575. constructor(o, p) {
  11576. this.element = o.createElement("div"), this.element.classList.add(U2()), p.viewProps.bindClassModifiers(this.element), S(p.shows, F2(this.element, U2(void 0, "v")));
  11577. }
  11578. }
  11579. class se {
  11580. constructor(o, p) {
  11581. this.shows = H(false), this.viewProps = p.viewProps, this.view = new J2(o, {
  11582. shows: this.shows,
  11583. viewProps: this.viewProps
  11584. });
  11585. }
  11586. }
  11587. const xe = y2("txt");
  11588. class Ne {
  11589. constructor(o, p) {
  11590. this.onChange_ = this.onChange_.bind(this), this.element = o.createElement("div"), this.element.classList.add(xe()), p.viewProps.bindClassModifiers(this.element), this.props_ = p.props, this.props_.emitter.on("change", this.onChange_);
  11591. const f = o.createElement("input");
  11592. f.classList.add(xe("i")), f.type = "text", p.viewProps.bindDisabled(f), this.element.appendChild(f), this.inputElement = f, p.value.emitter.on("change", this.onChange_), this.value_ = p.value, this.refresh();
  11593. }
  11594. refresh() {
  11595. const o = this.props_.get("formatter");
  11596. this.inputElement.value = o(this.value_.rawValue);
  11597. }
  11598. onChange_() {
  11599. this.refresh();
  11600. }
  11601. }
  11602. class Ut {
  11603. constructor(o, p) {
  11604. this.onInputChange_ = this.onInputChange_.bind(this), this.parser_ = p.parser, this.props = p.props, this.value = p.value, this.viewProps = p.viewProps, this.view = new Ne(o, {
  11605. props: p.props,
  11606. value: this.value,
  11607. viewProps: this.viewProps
  11608. }), this.view.inputElement.addEventListener("change", this.onInputChange_);
  11609. }
  11610. onInputChange_(o) {
  11611. const f = o.currentTarget.value, x = this.parser_(f);
  11612. h2(x) || (this.value.rawValue = x), this.view.refresh();
  11613. }
  11614. }
  11615. function cn(d) {
  11616. return d === "false" ? false : !!d;
  11617. }
  11618. class Ke {
  11619. constructor(o) {
  11620. this.text = o;
  11621. }
  11622. evaluate() {
  11623. return Number(this.text);
  11624. }
  11625. toString() {
  11626. return this.text;
  11627. }
  11628. }
  11629. const $e = {
  11630. "**": (d, o) => Math.pow(d, o),
  11631. "*": (d, o) => d * o,
  11632. "/": (d, o) => d / o,
  11633. "%": (d, o) => d % o,
  11634. "+": (d, o) => d + o,
  11635. "-": (d, o) => d - o,
  11636. "<<": (d, o) => d << o,
  11637. ">>": (d, o) => d >> o,
  11638. ">>>": (d, o) => d >>> o,
  11639. "&": (d, o) => d & o,
  11640. "^": (d, o) => d ^ o,
  11641. "|": (d, o) => d | o
  11642. };
  11643. class Hs {
  11644. constructor(o, p, f) {
  11645. this.left = p, this.operator = o, this.right = f;
  11646. }
  11647. evaluate() {
  11648. const o = $e[this.operator];
  11649. if (!o)
  11650. throw new Error(`unexpected binary operator: '${this.operator}`);
  11651. return o(this.left.evaluate(), this.right.evaluate());
  11652. }
  11653. toString() {
  11654. return [
  11655. "b(",
  11656. this.left.toString(),
  11657. this.operator,
  11658. this.right.toString(),
  11659. ")"
  11660. ].join(" ");
  11661. }
  11662. }
  11663. const Ks = {
  11664. "+": (d) => d,
  11665. "-": (d) => -d,
  11666. "~": (d) => ~d
  11667. };
  11668. class $s {
  11669. constructor(o, p) {
  11670. this.operator = o, this.expression = p;
  11671. }
  11672. evaluate() {
  11673. const o = Ks[this.operator];
  11674. if (!o)
  11675. throw new Error(`unexpected unary operator: '${this.operator}`);
  11676. return o(this.expression.evaluate());
  11677. }
  11678. toString() {
  11679. return ["u(", this.operator, this.expression.toString(), ")"].join(" ");
  11680. }
  11681. }
  11682. function hi(d) {
  11683. return (o, p) => {
  11684. for (let f = 0; f < d.length; f++) {
  11685. const x = d[f](o, p);
  11686. if (x !== "")
  11687. return x;
  11688. }
  11689. return "";
  11690. };
  11691. }
  11692. function It(d, o) {
  11693. var p;
  11694. const f = d.substr(o).match(/^\s+/);
  11695. return (p = f && f[0]) !== null && p !== void 0 ? p : "";
  11696. }
  11697. function di(d, o) {
  11698. const p = d.substr(o, 1);
  11699. return p.match(/^[1-9]$/) ? p : "";
  11700. }
  11701. function ze(d, o) {
  11702. var p;
  11703. const f = d.substr(o).match(/^[0-9]+/);
  11704. return (p = f && f[0]) !== null && p !== void 0 ? p : "";
  11705. }
  11706. function mi(d, o) {
  11707. const p = ze(d, o);
  11708. if (p !== "")
  11709. return p;
  11710. const f = d.substr(o, 1);
  11711. if (o += 1, f !== "-" && f !== "+")
  11712. return "";
  11713. const x = ze(d, o);
  11714. return x === "" ? "" : f + x;
  11715. }
  11716. function ot(d, o) {
  11717. const p = d.substr(o, 1);
  11718. if (o += 1, p.toLowerCase() !== "e")
  11719. return "";
  11720. const f = mi(d, o);
  11721. return f === "" ? "" : p + f;
  11722. }
  11723. function es(d, o) {
  11724. const p = d.substr(o, 1);
  11725. if (p === "0")
  11726. return p;
  11727. const f = di(d, o);
  11728. return o += f.length, f === "" ? "" : f + ze(d, o);
  11729. }
  11730. function pn(d, o) {
  11731. const p = es(d, o);
  11732. if (o += p.length, p === "")
  11733. return "";
  11734. const f = d.substr(o, 1);
  11735. if (o += f.length, f !== ".")
  11736. return "";
  11737. const x = ze(d, o);
  11738. return o += x.length, p + f + x + ot(d, o);
  11739. }
  11740. function ts(d, o) {
  11741. const p = d.substr(o, 1);
  11742. if (o += p.length, p !== ".")
  11743. return "";
  11744. const f = ze(d, o);
  11745. return o += f.length, f === "" ? "" : p + f + ot(d, o);
  11746. }
  11747. function Kn(d, o) {
  11748. const p = es(d, o);
  11749. return o += p.length, p === "" ? "" : p + ot(d, o);
  11750. }
  11751. const fi = hi([
  11752. pn,
  11753. ts,
  11754. Kn
  11755. ]);
  11756. function vi(d, o) {
  11757. var p;
  11758. const f = d.substr(o).match(/^[01]+/);
  11759. return (p = f && f[0]) !== null && p !== void 0 ? p : "";
  11760. }
  11761. function Xs(d, o) {
  11762. const p = d.substr(o, 2);
  11763. if (o += p.length, p.toLowerCase() !== "0b")
  11764. return "";
  11765. const f = vi(d, o);
  11766. return f === "" ? "" : p + f;
  11767. }
  11768. function Ys(d, o) {
  11769. var p;
  11770. const f = d.substr(o).match(/^[0-7]+/);
  11771. return (p = f && f[0]) !== null && p !== void 0 ? p : "";
  11772. }
  11773. function qs(d, o) {
  11774. const p = d.substr(o, 2);
  11775. if (o += p.length, p.toLowerCase() !== "0o")
  11776. return "";
  11777. const f = Ys(d, o);
  11778. return f === "" ? "" : p + f;
  11779. }
  11780. function Qs(d, o) {
  11781. var p;
  11782. const f = d.substr(o).match(/^[0-9a-f]+/i);
  11783. return (p = f && f[0]) !== null && p !== void 0 ? p : "";
  11784. }
  11785. function bi(d, o) {
  11786. const p = d.substr(o, 2);
  11787. if (o += p.length, p.toLowerCase() !== "0x")
  11788. return "";
  11789. const f = Qs(d, o);
  11790. return f === "" ? "" : p + f;
  11791. }
  11792. const Zs = hi([
  11793. Xs,
  11794. qs,
  11795. bi
  11796. ]), Ws = hi([
  11797. Zs,
  11798. fi
  11799. ]);
  11800. function un(d, o) {
  11801. const p = Ws(d, o);
  11802. return o += p.length, p === "" ? null : {
  11803. evaluable: new Ke(p),
  11804. cursor: o
  11805. };
  11806. }
  11807. function ns(d, o) {
  11808. const p = d.substr(o, 1);
  11809. if (o += p.length, p !== "(")
  11810. return null;
  11811. const f = gi(d, o);
  11812. if (!f)
  11813. return null;
  11814. o = f.cursor, o += It(d, o).length;
  11815. const x = d.substr(o, 1);
  11816. return o += x.length, x !== ")" ? null : {
  11817. evaluable: f.evaluable,
  11818. cursor: o
  11819. };
  11820. }
  11821. function Js(d, o) {
  11822. var p;
  11823. return (p = un(d, o)) !== null && p !== void 0 ? p : ns(d, o);
  11824. }
  11825. function $n(d, o) {
  11826. const p = Js(d, o);
  11827. if (p)
  11828. return p;
  11829. const f = d.substr(o, 1);
  11830. if (o += f.length, f !== "+" && f !== "-" && f !== "~")
  11831. return null;
  11832. const x = $n(d, o);
  11833. return x ? (o = x.cursor, {
  11834. cursor: o,
  11835. evaluable: new $s(f, x.evaluable)
  11836. }) : null;
  11837. }
  11838. function er(d, o, p) {
  11839. p += It(o, p).length;
  11840. const f = d.filter((x) => o.startsWith(x, p))[0];
  11841. return f ? (p += f.length, p += It(o, p).length, {
  11842. cursor: p,
  11843. operator: f
  11844. }) : null;
  11845. }
  11846. function Gt(d, o) {
  11847. return (p, f) => {
  11848. const x = d(p, f);
  11849. if (!x)
  11850. return null;
  11851. f = x.cursor;
  11852. let T = x.evaluable;
  11853. for (; ; ) {
  11854. const L = er(o, p, f);
  11855. if (!L)
  11856. break;
  11857. f = L.cursor;
  11858. const z = d(p, f);
  11859. if (!z)
  11860. return null;
  11861. f = z.cursor, T = new Hs(L.operator, T, z.evaluable);
  11862. }
  11863. return T ? {
  11864. cursor: f,
  11865. evaluable: T
  11866. } : null;
  11867. };
  11868. }
  11869. const is = [
  11870. ["**"],
  11871. ["*", "/", "%"],
  11872. ["+", "-"],
  11873. ["<<", ">>>", ">>"],
  11874. ["&"],
  11875. ["^"],
  11876. ["|"]
  11877. ].reduce((d, o) => Gt(d, o), $n);
  11878. function gi(d, o) {
  11879. return o += It(d, o).length, is(d, o);
  11880. }
  11881. function tr(d) {
  11882. const o = gi(d, 0);
  11883. return !o || o.cursor + It(d, o.cursor).length !== d.length ? null : o.evaluable;
  11884. }
  11885. function hn(d) {
  11886. var o;
  11887. const p = tr(d);
  11888. return (o = p == null ? void 0 : p.evaluate()) !== null && o !== void 0 ? o : null;
  11889. }
  11890. function nr(d) {
  11891. if (typeof d == "number")
  11892. return d;
  11893. if (typeof d == "string") {
  11894. const o = hn(d);
  11895. if (!h2(o))
  11896. return o;
  11897. }
  11898. return 0;
  11899. }
  11900. function Ie(d) {
  11901. return (o) => o.toFixed(Math.max(Math.min(d, 20), 0));
  11902. }
  11903. const ir = Ie(0);
  11904. function Xn(d) {
  11905. return ir(d) + "%";
  11906. }
  11907. function ss(d) {
  11908. return String(d);
  11909. }
  11910. function _i(d, o) {
  11911. for (; d.length < o; )
  11912. d.push(void 0);
  11913. }
  11914. function rs(d) {
  11915. const o = [];
  11916. return _i(o, d), H(o);
  11917. }
  11918. function os(d) {
  11919. const o = d.indexOf(void 0);
  11920. return o < 0 ? d : d.slice(0, o);
  11921. }
  11922. function sr(d, o) {
  11923. const p = [...os(d), o];
  11924. return p.length > d.length ? p.splice(0, p.length - d.length) : _i(p, d.length), p;
  11925. }
  11926. function Ht({ primary: d, secondary: o, forward: p, backward: f }) {
  11927. let x = false;
  11928. function T(L) {
  11929. x || (x = true, L(), x = false);
  11930. }
  11931. d.emitter.on("change", (L) => {
  11932. T(() => {
  11933. o.setRawValue(p(d, o), L.options);
  11934. });
  11935. }), o.emitter.on("change", (L) => {
  11936. T(() => {
  11937. d.setRawValue(f(d, o), L.options);
  11938. }), T(() => {
  11939. o.setRawValue(p(d, o), L.options);
  11940. });
  11941. }), T(() => {
  11942. o.setRawValue(p(d, o), {
  11943. forceEmit: false,
  11944. last: true
  11945. });
  11946. });
  11947. }
  11948. function Kt(d, o) {
  11949. const p = d * (o.altKey ? 0.1 : 1) * (o.shiftKey ? 10 : 1);
  11950. return o.upKey ? +p : o.downKey ? -p : 0;
  11951. }
  11952. function dn(d) {
  11953. return {
  11954. altKey: d.altKey,
  11955. downKey: d.key === "ArrowDown",
  11956. shiftKey: d.shiftKey,
  11957. upKey: d.key === "ArrowUp"
  11958. };
  11959. }
  11960. function wi(d) {
  11961. return {
  11962. altKey: d.altKey,
  11963. downKey: d.key === "ArrowLeft",
  11964. shiftKey: d.shiftKey,
  11965. upKey: d.key === "ArrowRight"
  11966. };
  11967. }
  11968. function rr(d) {
  11969. return d === "ArrowUp" || d === "ArrowDown";
  11970. }
  11971. function as(d) {
  11972. return rr(d) || d === "ArrowLeft" || d === "ArrowRight";
  11973. }
  11974. function yi(d, o) {
  11975. var p, f;
  11976. const x = o.ownerDocument.defaultView, T = o.getBoundingClientRect();
  11977. return {
  11978. x: d.pageX - (((p = x && x.scrollX) !== null && p !== void 0 ? p : 0) + T.left),
  11979. y: d.pageY - (((f = x && x.scrollY) !== null && f !== void 0 ? f : 0) + T.top)
  11980. };
  11981. }
  11982. class Ct2 {
  11983. constructor(o) {
  11984. 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_ = o, this.emitter = new w(), o.addEventListener("touchstart", this.onTouchStart_, {
  11985. passive: false
  11986. }), o.addEventListener("touchmove", this.onTouchMove_, {
  11987. passive: true
  11988. }), o.addEventListener("touchend", this.onTouchEnd_), o.addEventListener("mousedown", this.onMouseDown_);
  11989. }
  11990. computePosition_(o) {
  11991. const p = this.elem_.getBoundingClientRect();
  11992. return {
  11993. bounds: {
  11994. width: p.width,
  11995. height: p.height
  11996. },
  11997. point: o ? {
  11998. x: o.x,
  11999. y: o.y
  12000. } : null
  12001. };
  12002. }
  12003. onMouseDown_(o) {
  12004. var p;
  12005. o.preventDefault(), (p = o.currentTarget) === null || p === void 0 || p.focus();
  12006. const f = this.elem_.ownerDocument;
  12007. f.addEventListener("mousemove", this.onDocumentMouseMove_), f.addEventListener("mouseup", this.onDocumentMouseUp_), this.emitter.emit("down", {
  12008. altKey: o.altKey,
  12009. data: this.computePosition_(yi(o, this.elem_)),
  12010. sender: this,
  12011. shiftKey: o.shiftKey
  12012. });
  12013. }
  12014. onDocumentMouseMove_(o) {
  12015. this.emitter.emit("move", {
  12016. altKey: o.altKey,
  12017. data: this.computePosition_(yi(o, this.elem_)),
  12018. sender: this,
  12019. shiftKey: o.shiftKey
  12020. });
  12021. }
  12022. onDocumentMouseUp_(o) {
  12023. const p = this.elem_.ownerDocument;
  12024. p.removeEventListener("mousemove", this.onDocumentMouseMove_), p.removeEventListener("mouseup", this.onDocumentMouseUp_), this.emitter.emit("up", {
  12025. altKey: o.altKey,
  12026. data: this.computePosition_(yi(o, this.elem_)),
  12027. sender: this,
  12028. shiftKey: o.shiftKey
  12029. });
  12030. }
  12031. onTouchStart_(o) {
  12032. o.preventDefault();
  12033. const p = o.targetTouches.item(0), f = this.elem_.getBoundingClientRect();
  12034. this.emitter.emit("down", {
  12035. altKey: o.altKey,
  12036. data: this.computePosition_(p ? {
  12037. x: p.clientX - f.left,
  12038. y: p.clientY - f.top
  12039. } : void 0),
  12040. sender: this,
  12041. shiftKey: o.shiftKey
  12042. }), this.lastTouch_ = p;
  12043. }
  12044. onTouchMove_(o) {
  12045. const p = o.targetTouches.item(0), f = this.elem_.getBoundingClientRect();
  12046. this.emitter.emit("move", {
  12047. altKey: o.altKey,
  12048. data: this.computePosition_(p ? {
  12049. x: p.clientX - f.left,
  12050. y: p.clientY - f.top
  12051. } : void 0),
  12052. sender: this,
  12053. shiftKey: o.shiftKey
  12054. }), this.lastTouch_ = p;
  12055. }
  12056. onTouchEnd_(o) {
  12057. var p;
  12058. const f = (p = o.targetTouches.item(0)) !== null && p !== void 0 ? p : this.lastTouch_, x = this.elem_.getBoundingClientRect();
  12059. this.emitter.emit("up", {
  12060. altKey: o.altKey,
  12061. data: this.computePosition_(f ? {
  12062. x: f.clientX - x.left,
  12063. y: f.clientY - x.top
  12064. } : void 0),
  12065. sender: this,
  12066. shiftKey: o.shiftKey
  12067. });
  12068. }
  12069. }
  12070. function we(d, o, p, f, x) {
  12071. const T = (d - o) / (p - o);
  12072. return f + T * (x - f);
  12073. }
  12074. function Vt(d) {
  12075. return String(d.toFixed(10)).split(".")[1].replace(/0+$/, "").length;
  12076. }
  12077. function at(d, o, p) {
  12078. return Math.min(Math.max(d, o), p);
  12079. }
  12080. const Xe = y2("txt");
  12081. class Yn {
  12082. constructor(o, p) {
  12083. this.onChange_ = this.onChange_.bind(this), this.props_ = p.props, this.props_.emitter.on("change", this.onChange_), this.element = o.createElement("div"), this.element.classList.add(Xe(), Xe(void 0, "num")), p.arrayPosition && this.element.classList.add(Xe(void 0, p.arrayPosition)), p.viewProps.bindClassModifiers(this.element);
  12084. const f = o.createElement("input");
  12085. f.classList.add(Xe("i")), f.type = "text", p.viewProps.bindDisabled(f), this.element.appendChild(f), this.inputElement = f, this.onDraggingChange_ = this.onDraggingChange_.bind(this), this.dragging_ = p.dragging, this.dragging_.emitter.on("change", this.onDraggingChange_), this.element.classList.add(Xe()), this.inputElement.classList.add(Xe("i"));
  12086. const x = o.createElement("div");
  12087. x.classList.add(Xe("k")), this.element.appendChild(x), this.knobElement = x;
  12088. const T = o.createElementNS(ye, "svg");
  12089. T.classList.add(Xe("g")), this.knobElement.appendChild(T);
  12090. const L = o.createElementNS(ye, "path");
  12091. L.classList.add(Xe("gb")), T.appendChild(L), this.guideBodyElem_ = L;
  12092. const z = o.createElementNS(ye, "path");
  12093. z.classList.add(Xe("gh")), T.appendChild(z), this.guideHeadElem_ = z;
  12094. const re = o.createElement("div");
  12095. re.classList.add(y2("tt")()), this.knobElement.appendChild(re), this.tooltipElem_ = re, p.value.emitter.on("change", this.onChange_), this.value = p.value, this.refresh();
  12096. }
  12097. onDraggingChange_(o) {
  12098. if (o.rawValue === null) {
  12099. this.element.classList.remove(Xe(void 0, "drg"));
  12100. return;
  12101. }
  12102. this.element.classList.add(Xe(void 0, "drg"));
  12103. const p = o.rawValue / this.props_.get("draggingScale"), f = p + (p > 0 ? -1 : p < 0 ? 1 : 0), x = at(-f, -4, 4);
  12104. this.guideHeadElem_.setAttributeNS(null, "d", [`M ${f + x},0 L${f},4 L${f + x},8`, `M ${p},-1 L${p},9`].join(" ")), this.guideBodyElem_.setAttributeNS(null, "d", `M 0,4 L${p},4`);
  12105. const T = this.props_.get("formatter");
  12106. this.tooltipElem_.textContent = T(this.value.rawValue), this.tooltipElem_.style.left = `${p}px`;
  12107. }
  12108. refresh() {
  12109. const o = this.props_.get("formatter");
  12110. this.inputElement.value = o(this.value.rawValue);
  12111. }
  12112. onChange_() {
  12113. this.refresh();
  12114. }
  12115. }
  12116. class xi {
  12117. constructor(o, p) {
  12118. var f;
  12119. 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_ = p.baseStep, this.parser_ = p.parser, this.props = p.props, this.sliderProps_ = (f = p.sliderProps) !== null && f !== void 0 ? f : null, this.value = p.value, this.viewProps = p.viewProps, this.dragging_ = H(null), this.view = new Yn(o, {
  12120. arrayPosition: p.arrayPosition,
  12121. dragging: this.dragging_,
  12122. props: this.props,
  12123. value: this.value,
  12124. viewProps: this.viewProps
  12125. }), this.view.inputElement.addEventListener("change", this.onInputChange_), this.view.inputElement.addEventListener("keydown", this.onInputKeyDown_), this.view.inputElement.addEventListener("keyup", this.onInputKeyUp_);
  12126. const x = new Ct2(this.view.knobElement);
  12127. x.emitter.on("down", this.onPointerDown_), x.emitter.on("move", this.onPointerMove_), x.emitter.on("up", this.onPointerUp_);
  12128. }
  12129. constrainValue_(o) {
  12130. var p, f;
  12131. const x = (p = this.sliderProps_) === null || p === void 0 ? void 0 : p.get("minValue"), T = (f = this.sliderProps_) === null || f === void 0 ? void 0 : f.get("maxValue");
  12132. let L = o;
  12133. return x !== void 0 && (L = Math.max(L, x)), T !== void 0 && (L = Math.min(L, T)), L;
  12134. }
  12135. onInputChange_(o) {
  12136. const f = o.currentTarget.value, x = this.parser_(f);
  12137. h2(x) || (this.value.rawValue = this.constrainValue_(x)), this.view.refresh();
  12138. }
  12139. onInputKeyDown_(o) {
  12140. const p = Kt(this.baseStep_, dn(o));
  12141. p !== 0 && this.value.setRawValue(this.constrainValue_(this.value.rawValue + p), {
  12142. forceEmit: false,
  12143. last: false
  12144. });
  12145. }
  12146. onInputKeyUp_(o) {
  12147. Kt(this.baseStep_, dn(o)) !== 0 && this.value.setRawValue(this.value.rawValue, {
  12148. forceEmit: true,
  12149. last: true
  12150. });
  12151. }
  12152. onPointerDown_() {
  12153. this.originRawValue_ = this.value.rawValue, this.dragging_.rawValue = 0;
  12154. }
  12155. computeDraggingValue_(o) {
  12156. if (!o.point)
  12157. return null;
  12158. const p = o.point.x - o.bounds.width / 2;
  12159. return this.constrainValue_(this.originRawValue_ + p * this.props.get("draggingScale"));
  12160. }
  12161. onPointerMove_(o) {
  12162. const p = this.computeDraggingValue_(o.data);
  12163. p !== null && (this.value.setRawValue(p, {
  12164. forceEmit: false,
  12165. last: false
  12166. }), this.dragging_.rawValue = this.value.rawValue - this.originRawValue_);
  12167. }
  12168. onPointerUp_(o) {
  12169. const p = this.computeDraggingValue_(o.data);
  12170. p !== null && (this.value.setRawValue(p, {
  12171. forceEmit: true,
  12172. last: true
  12173. }), this.dragging_.rawValue = null);
  12174. }
  12175. }
  12176. function Ei(d, o) {
  12177. d.write(o);
  12178. }
  12179. function mn(d) {
  12180. const o = d ? Et(d, A) : null;
  12181. return o ? o.step : null;
  12182. }
  12183. function ls(d, o) {
  12184. const p = d && Et(d, A);
  12185. return p ? Vt(p.step) : Math.max(Vt(o), 2);
  12186. }
  12187. function cs(d) {
  12188. const o = mn(d);
  12189. return o ?? 1;
  12190. }
  12191. function ps(d, o) {
  12192. var p;
  12193. const f = d && Et(d, A), x = Math.abs((p = f == null ? void 0 : f.step) !== null && p !== void 0 ? p : o);
  12194. return x === 0 ? 0.1 : Math.pow(10, Math.floor(Math.log10(x)) - 1);
  12195. }
  12196. function fn(d) {
  12197. return [d[0], d[1], d[2]];
  12198. }
  12199. function us(d) {
  12200. const o = at(Math.floor(d), 0, 255).toString(16);
  12201. return o.length === 1 ? `0${o}` : o;
  12202. }
  12203. function qn(d, o = "#") {
  12204. const p = fn(d.getComponents("rgb")).map(us).join("");
  12205. return `${o}${p}`;
  12206. }
  12207. function or(d, o = "#") {
  12208. const p = d.getComponents("rgb"), f = [p[0], p[1], p[2], p[3] * 255].map(us).join("");
  12209. return `${o}${f}`;
  12210. }
  12211. function hs(d, o) {
  12212. const p = Ie(o === "float" ? 2 : 0);
  12213. return `rgb(${fn(d.getComponents("rgb", o)).map((x) => p(x)).join(", ")})`;
  12214. }
  12215. function ds(d) {
  12216. return (o) => hs(o, d);
  12217. }
  12218. function ar(d, o) {
  12219. const p = Ie(2), f = Ie(o === "float" ? 2 : 0);
  12220. return `rgba(${d.getComponents("rgb", o).map((T, L) => (L === 3 ? p : f)(T)).join(", ")})`;
  12221. }
  12222. function lr(d) {
  12223. return (o) => ar(o, d);
  12224. }
  12225. function cr(d) {
  12226. const o = [
  12227. Ie(0),
  12228. Xn,
  12229. Xn
  12230. ];
  12231. return `hsl(${fn(d.getComponents("hsl")).map((f, x) => o[x](f)).join(", ")})`;
  12232. }
  12233. function pr(d) {
  12234. const o = [
  12235. Ie(0),
  12236. Xn,
  12237. Xn,
  12238. Ie(2)
  12239. ];
  12240. return `hsla(${d.getComponents("hsl").map((f, x) => o[x](f)).join(", ")})`;
  12241. }
  12242. function ur(d, o) {
  12243. const p = Ie(o === "float" ? 2 : 0), f = ["r", "g", "b"];
  12244. return `{${fn(d.getComponents("rgb", o)).map((T, L) => `${f[L]}: ${p(T)}`).join(", ")}}`;
  12245. }
  12246. function Ci(d) {
  12247. return (o) => ur(o, d);
  12248. }
  12249. function vn(d, o) {
  12250. const p = Ie(2), f = Ie(o === "float" ? 2 : 0), x = ["r", "g", "b", "a"];
  12251. return `{${d.getComponents("rgb", o).map((L, z) => {
  12252. const re = z === 3 ? p : f;
  12253. return `${x[z]}: ${re(L)}`;
  12254. }).join(", ")}}`;
  12255. }
  12256. function hr(d) {
  12257. return (o) => vn(o, d);
  12258. }
  12259. [
  12260. ...["int", "float"].reduce((d, o) => [
  12261. ...d,
  12262. {
  12263. format: {
  12264. alpha: false,
  12265. mode: "rgb",
  12266. notation: "func",
  12267. type: o
  12268. },
  12269. stringifier: ds(o)
  12270. },
  12271. {
  12272. format: {
  12273. alpha: true,
  12274. mode: "rgb",
  12275. notation: "func",
  12276. type: o
  12277. },
  12278. stringifier: lr(o)
  12279. },
  12280. {
  12281. format: {
  12282. alpha: false,
  12283. mode: "rgb",
  12284. notation: "object",
  12285. type: o
  12286. },
  12287. stringifier: Ci(o)
  12288. },
  12289. {
  12290. format: {
  12291. alpha: true,
  12292. mode: "rgb",
  12293. notation: "object",
  12294. type: o
  12295. },
  12296. stringifier: hr(o)
  12297. }
  12298. ], [])
  12299. ];
  12300. class bn {
  12301. constructor(o) {
  12302. this.components = o.components, this.asm_ = o.assembly;
  12303. }
  12304. constrain(o) {
  12305. const p = this.asm_.toComponents(o).map((f, x) => {
  12306. var T, L;
  12307. return (L = (T = this.components[x]) === null || T === void 0 ? void 0 : T.constrain(f)) !== null && L !== void 0 ? L : f;
  12308. });
  12309. return this.asm_.fromComponents(p);
  12310. }
  12311. }
  12312. const ms = y2("pndtxt");
  12313. class Pi {
  12314. constructor(o, p) {
  12315. this.textViews = p.textViews, this.element = o.createElement("div"), this.element.classList.add(ms()), this.textViews.forEach((f) => {
  12316. const x = o.createElement("div");
  12317. x.classList.add(ms("a")), x.appendChild(f.element), this.element.appendChild(x);
  12318. });
  12319. }
  12320. }
  12321. function fs(d, o, p) {
  12322. return new xi(d, {
  12323. arrayPosition: p === 0 ? "fst" : p === o.axes.length - 1 ? "lst" : "mid",
  12324. baseStep: o.axes[p].baseStep,
  12325. parser: o.parser,
  12326. props: o.axes[p].textProps,
  12327. value: H(0, {
  12328. constraint: o.axes[p].constraint
  12329. }),
  12330. viewProps: o.viewProps
  12331. });
  12332. }
  12333. class Ti {
  12334. constructor(o, p) {
  12335. this.value = p.value, this.viewProps = p.viewProps, this.acs_ = p.axes.map((f, x) => fs(o, p, x)), this.acs_.forEach((f, x) => {
  12336. Ht({
  12337. primary: this.value,
  12338. secondary: f.value,
  12339. forward: (T) => p.assembly.toComponents(T.rawValue)[x],
  12340. backward: (T, L) => {
  12341. const z = p.assembly.toComponents(T.rawValue);
  12342. return z[x] = L.rawValue, p.assembly.fromComponents(z);
  12343. }
  12344. });
  12345. }), this.view = new Pi(o, {
  12346. textViews: this.acs_.map((f) => f.view)
  12347. });
  12348. }
  12349. }
  12350. function dr(d, o) {
  12351. return "step" in d && !h2(d.step) ? new A(d.step, o) : null;
  12352. }
  12353. function mr(d) {
  12354. return !h2(d.max) && !h2(d.min) ? new vt({
  12355. max: d.max,
  12356. min: d.min
  12357. }) : !h2(d.max) || !h2(d.min) ? new Rt2({
  12358. max: d.max,
  12359. min: d.min
  12360. }) : null;
  12361. }
  12362. const fr = {
  12363. monitor: {
  12364. defaultInterval: 200,
  12365. defaultLineCount: 3
  12366. }
  12367. }, Pt = y2("grl");
  12368. class vr {
  12369. constructor(o, p) {
  12370. this.onCursorChange_ = this.onCursorChange_.bind(this), this.onValueUpdate_ = this.onValueUpdate_.bind(this), this.element = o.createElement("div"), this.element.classList.add(Pt()), p.viewProps.bindClassModifiers(this.element), this.formatter_ = p.formatter, this.props_ = p.props, this.cursor_ = p.cursor, this.cursor_.emitter.on("change", this.onCursorChange_);
  12371. const f = o.createElementNS(ye, "svg");
  12372. f.classList.add(Pt("g")), f.style.height = `calc(var(--bld-us) * ${p.lineCount})`, this.element.appendChild(f), this.svgElem_ = f;
  12373. const x = o.createElementNS(ye, "polyline");
  12374. this.svgElem_.appendChild(x), this.lineElem_ = x;
  12375. const T = o.createElement("div");
  12376. T.classList.add(Pt("t"), y2("tt")()), this.element.appendChild(T), this.tooltipElem_ = T, p.value.emitter.on("change", this.onValueUpdate_), this.value = p.value, this.update_();
  12377. }
  12378. get graphElement() {
  12379. return this.svgElem_;
  12380. }
  12381. update_() {
  12382. const o = this.svgElem_.getBoundingClientRect(), p = this.value.rawValue.length - 1, f = this.props_.get("minValue"), x = this.props_.get("maxValue"), T = [];
  12383. this.value.rawValue.forEach((Fe, Oi) => {
  12384. if (Fe === void 0)
  12385. return;
  12386. const Lr = we(Oi, 0, p, 0, o.width), Ni = we(Fe, f, x, o.height, 0);
  12387. T.push([Lr, Ni].join(","));
  12388. }), this.lineElem_.setAttributeNS(null, "points", T.join(" "));
  12389. const L = this.tooltipElem_, z = this.value.rawValue[this.cursor_.rawValue];
  12390. if (z === void 0) {
  12391. L.classList.remove(Pt("t", "a"));
  12392. return;
  12393. }
  12394. const re = we(this.cursor_.rawValue, 0, p, 0, o.width), W2 = we(z, f, x, o.height, 0);
  12395. L.style.left = `${re}px`, L.style.top = `${W2}px`, L.textContent = `${this.formatter_(z)}`, L.classList.contains(Pt("t", "a")) || (L.classList.add(Pt("t", "a"), Pt("t", "in")), st2(L), L.classList.remove(Pt("t", "in")));
  12396. }
  12397. onValueUpdate_() {
  12398. this.update_();
  12399. }
  12400. onCursorChange_() {
  12401. this.update_();
  12402. }
  12403. }
  12404. class br {
  12405. constructor(o, p) {
  12406. 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_ = p.props, this.value = p.value, this.viewProps = p.viewProps, this.cursor_ = H(-1), this.view = new vr(o, {
  12407. cursor: this.cursor_,
  12408. formatter: p.formatter,
  12409. lineCount: p.lineCount,
  12410. props: this.props_,
  12411. value: this.value,
  12412. viewProps: this.viewProps
  12413. }), !Qe2(o))
  12414. this.view.element.addEventListener("mousemove", this.onGraphMouseMove_), this.view.element.addEventListener("mouseleave", this.onGraphMouseLeave_);
  12415. else {
  12416. const f = new Ct2(this.view.element);
  12417. f.emitter.on("down", this.onGraphPointerDown_), f.emitter.on("move", this.onGraphPointerMove_), f.emitter.on("up", this.onGraphPointerUp_);
  12418. }
  12419. }
  12420. onGraphMouseLeave_() {
  12421. this.cursor_.rawValue = -1;
  12422. }
  12423. onGraphMouseMove_(o) {
  12424. const p = this.view.element.getBoundingClientRect();
  12425. this.cursor_.rawValue = Math.floor(we(o.offsetX, 0, p.width, 0, this.value.rawValue.length));
  12426. }
  12427. onGraphPointerDown_(o) {
  12428. this.onGraphPointerMove_(o);
  12429. }
  12430. onGraphPointerMove_(o) {
  12431. if (!o.data.point) {
  12432. this.cursor_.rawValue = -1;
  12433. return;
  12434. }
  12435. this.cursor_.rawValue = Math.floor(we(o.data.point.x, 0, o.data.bounds.width, 0, this.value.rawValue.length));
  12436. }
  12437. onGraphPointerUp_() {
  12438. this.cursor_.rawValue = -1;
  12439. }
  12440. }
  12441. class vs {
  12442. constructor(o) {
  12443. this.controller_ = o;
  12444. }
  12445. get disabled() {
  12446. return this.controller_.viewProps.get("disabled");
  12447. }
  12448. set disabled(o) {
  12449. this.controller_.viewProps.set("disabled", o);
  12450. }
  12451. get title() {
  12452. var o;
  12453. return (o = this.controller_.props.get("title")) !== null && o !== void 0 ? o : "";
  12454. }
  12455. set title(o) {
  12456. this.controller_.props.set("title", o);
  12457. }
  12458. on(o, p) {
  12459. const f = p.bind(this);
  12460. return this.controller_.emitter.on(o, () => {
  12461. f(new a(this));
  12462. }), this;
  12463. }
  12464. }
  12465. class gr extends a {
  12466. constructor(o, p, f) {
  12467. super(o), this.cell = p, this.index = f;
  12468. }
  12469. }
  12470. class bs extends s {
  12471. constructor(o) {
  12472. super(o), this.cellToApiMap_ = /* @__PURE__ */ new Map(), this.emitter_ = new w();
  12473. const p = this.controller_.valueController;
  12474. p.cellControllers.forEach((f, x) => {
  12475. const T = new vs(f);
  12476. this.cellToApiMap_.set(f, T), f.emitter.on("click", () => {
  12477. const L = x % p.size[0], z = Math.floor(x / p.size[0]);
  12478. this.emitter_.emit("click", {
  12479. event: new gr(this, T, [L, z])
  12480. });
  12481. });
  12482. });
  12483. }
  12484. cell(o, p) {
  12485. const f = this.controller_.valueController, x = f.cellControllers[p * f.size[0] + o];
  12486. return this.cellToApiMap_.get(x);
  12487. }
  12488. on(o, p) {
  12489. const f = p.bind(this);
  12490. return this.emitter_.on(o, (x) => {
  12491. f(x.event);
  12492. }), this;
  12493. }
  12494. }
  12495. class ki {
  12496. constructor(o, p) {
  12497. this.size = p.size;
  12498. const [f, x] = this.size, T = [];
  12499. for (let L = 0; L < x; L++)
  12500. for (let z = 0; z < f; z++) {
  12501. const re = new G(o, {
  12502. props: K.fromObject(Object.assign({}, p.cellConfig(z, L))),
  12503. viewProps: ge.create()
  12504. });
  12505. T.push(re);
  12506. }
  12507. this.cellCs_ = T, this.viewProps = ge.create(), this.viewProps.handleDispose(() => {
  12508. this.cellCs_.forEach((L) => {
  12509. L.viewProps.set("disposed", true);
  12510. });
  12511. }), this.view = new xt(o, {
  12512. viewProps: this.viewProps,
  12513. viewName: "btngrid"
  12514. }), this.view.element.style.gridTemplateColumns = `repeat(${f}, 1fr)`, this.cellCs_.forEach((L) => {
  12515. this.view.element.appendChild(L.view.element);
  12516. });
  12517. }
  12518. get cellControllers() {
  12519. return this.cellCs_;
  12520. }
  12521. }
  12522. const _r = {
  12523. id: "buttongrid",
  12524. type: "blade",
  12525. // TODO:
  12526. 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}',
  12527. accept(d) {
  12528. const o = de2, p = te2(d, {
  12529. cells: o.required.function,
  12530. size: o.required.array(o.required.number),
  12531. view: o.required.constant("buttongrid"),
  12532. label: o.optional.string
  12533. });
  12534. return p ? { params: p } : null;
  12535. },
  12536. controller(d) {
  12537. return new rt2(d.document, {
  12538. blade: d.blade,
  12539. props: K.fromObject({
  12540. label: d.params.label
  12541. }),
  12542. valueController: new ki(d.document, {
  12543. cellConfig: d.params.cells,
  12544. size: d.params.size
  12545. })
  12546. });
  12547. },
  12548. api(d) {
  12549. return !(d.controller instanceof rt2) || !(d.controller.valueController instanceof ki) ? null : new bs(d.controller);
  12550. }
  12551. };
  12552. class gs extends s {
  12553. get label() {
  12554. return this.controller_.props.get("label");
  12555. }
  12556. set label(o) {
  12557. this.controller_.props.set("label", o);
  12558. }
  12559. get value() {
  12560. return this.controller_.valueController.value.rawValue;
  12561. }
  12562. set value(o) {
  12563. this.controller_.valueController.value.rawValue = o;
  12564. }
  12565. on(o, p) {
  12566. const f = p.bind(this);
  12567. return this.controller_.valueController.value.emitter.on(o, (x) => {
  12568. f(new c(this, x.rawValue, void 0, x.options.last));
  12569. }), this;
  12570. }
  12571. }
  12572. function Ze(d, o, p) {
  12573. return d * (1 - p) + o * p;
  12574. }
  12575. const wr = 20, _s = 1e-3, Mi = 100;
  12576. function yr(d, o) {
  12577. let p = 0.25, f = 0.5, x = -1;
  12578. for (let T = 0; T < wr; T++) {
  12579. const [L, z] = d.curve(f);
  12580. if (f += p * (L < o ? 1 : -1), x = z, p *= 0.5, Math.abs(o - L) < _s)
  12581. break;
  12582. }
  12583. return x;
  12584. }
  12585. class Tt {
  12586. constructor(o = 0, p = 0, f = 1, x = 1) {
  12587. this.cache_ = [], this.comps_ = [o, p, f, x];
  12588. }
  12589. get x1() {
  12590. return this.comps_[0];
  12591. }
  12592. get y1() {
  12593. return this.comps_[1];
  12594. }
  12595. get x2() {
  12596. return this.comps_[2];
  12597. }
  12598. get y2() {
  12599. return this.comps_[3];
  12600. }
  12601. static isObject(o) {
  12602. return h2(o) || !Array.isArray(o) ? false : typeof o[0] == "number" && typeof o[1] == "number" && typeof o[2] == "number" && typeof o[3] == "number";
  12603. }
  12604. static equals(o, p) {
  12605. return o.x1 === p.x1 && o.y1 === p.y1 && o.x2 === p.x2 && o.y2 === p.y2;
  12606. }
  12607. curve(o) {
  12608. const p = Ze(0, this.x1, o), f = Ze(0, this.y1, o), x = Ze(this.x1, this.x2, o), T = Ze(this.y1, this.y2, o), L = Ze(this.x2, 1, o), z = Ze(this.y2, 1, o), re = Ze(p, x, o), W2 = Ze(f, T, o), Fe = Ze(x, L, o), Oi = Ze(T, z, o);
  12609. return [Ze(re, Fe, o), Ze(W2, Oi, o)];
  12610. }
  12611. y(o) {
  12612. if (this.cache_.length === 0) {
  12613. const p = [];
  12614. for (let f = 0; f < Mi; f++)
  12615. p.push(yr(this, we(f, 0, Mi - 1, 0, 1)));
  12616. this.cache_ = p;
  12617. }
  12618. return this.cache_[Math.round(we(at(o, 0, 1), 0, 1, 0, Mi - 1))];
  12619. }
  12620. toObject() {
  12621. return [this.comps_[0], this.comps_[1], this.comps_[2], this.comps_[3]];
  12622. }
  12623. }
  12624. const Qn = {
  12625. toComponents: (d) => d.toObject(),
  12626. fromComponents: (d) => new Tt(...d)
  12627. };
  12628. function xr(d) {
  12629. const o = Ie(2);
  12630. return `cubic-bezier(${d.toObject().map((f) => o(f)).join(", ")})`;
  12631. }
  12632. const lt2 = [0, 0.5, 0.5, 1];
  12633. function ws(d) {
  12634. const o = d.match(/^cubic-bezier\s*\(\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)\s*\)$/);
  12635. if (!o)
  12636. return new Tt(...lt2);
  12637. const p = [o[1], o[2], o[3], o[4]].reduce((f, x) => {
  12638. if (!f)
  12639. return null;
  12640. const T = Number(x);
  12641. return isNaN(T) ? null : [...f, T];
  12642. }, []);
  12643. return new Tt(...p ?? lt2);
  12644. }
  12645. const Dt = y2("cbz");
  12646. class Ve {
  12647. constructor(o, p) {
  12648. this.element = o.createElement("div"), this.element.classList.add(Dt()), p.viewProps.bindClassModifiers(this.element), p.foldable.bindExpandedClass(this.element, Dt(void 0, "expanded")), R(p.foldable, "completed", F2(this.element, Dt(void 0, "cpl")));
  12649. const f = o.createElement("div");
  12650. f.classList.add(Dt("h")), this.element.appendChild(f);
  12651. const x = o.createElement("button");
  12652. x.classList.add(Dt("b")), p.viewProps.bindDisabled(x);
  12653. const T = o.createElementNS(ye, "svg");
  12654. T.innerHTML = '<path d="M2 13C8 13 8 3 14 3"/>', x.appendChild(T), f.appendChild(x), this.buttonElement = x;
  12655. const L = o.createElement("div");
  12656. if (L.classList.add(Dt("t")), f.appendChild(L), this.textElement = L, p.pickerLayout === "inline") {
  12657. const z = o.createElement("div");
  12658. z.classList.add(Dt("p")), this.element.appendChild(z), this.pickerElement = z;
  12659. } else
  12660. this.pickerElement = null;
  12661. }
  12662. }
  12663. const Si = y2("cbzp");
  12664. class gn {
  12665. constructor(o, p) {
  12666. this.element = o.createElement("div"), this.element.classList.add(Si()), p.viewProps.bindClassModifiers(this.element);
  12667. const f = o.createElement("div");
  12668. f.classList.add(Si("g")), this.element.appendChild(f), this.graphElement = f;
  12669. const x = o.createElement("div");
  12670. x.classList.add(Si("t")), this.element.appendChild(x), this.textElement = x;
  12671. }
  12672. }
  12673. function Ai(d, o) {
  12674. const p = new MutationObserver((x) => {
  12675. for (const T of x)
  12676. T.type === "childList" && T.addedNodes.forEach((L) => {
  12677. L.contains(L) && (o(), p.disconnect());
  12678. });
  12679. }), f = d.ownerDocument;
  12680. p.observe(f.body, {
  12681. attributes: true,
  12682. childList: true,
  12683. subtree: true
  12684. });
  12685. }
  12686. const ct2 = y2("cbzg");
  12687. function ys(d, o) {
  12688. return (p) => o(d(p));
  12689. }
  12690. class xs {
  12691. constructor(o, p) {
  12692. this.element = o.createElement("div"), this.element.classList.add(ct2()), p.viewProps.bindClassModifiers(this.element), p.viewProps.bindTabIndex(this.element);
  12693. const f = o.createElement("div");
  12694. f.classList.add(ct2("p")), this.element.appendChild(f), this.previewElement = f;
  12695. const x = o.createElementNS(ye, "svg");
  12696. x.classList.add(ct2("g")), this.element.appendChild(x), this.svgElem_ = x;
  12697. const T = o.createElementNS(ye, "path");
  12698. T.classList.add(ct2("u")), this.svgElem_.appendChild(T), this.guideElem_ = T;
  12699. const L = o.createElementNS(ye, "polyline");
  12700. L.classList.add(ct2("l")), this.svgElem_.appendChild(L), this.lineElem_ = L, this.handleElems_ = [o.createElement("div"), o.createElement("div")], this.handleElems_.forEach((z) => {
  12701. z.classList.add(ct2("h")), this.element.appendChild(z);
  12702. }), this.vectorElems_ = [
  12703. o.createElementNS(ye, "line"),
  12704. o.createElementNS(ye, "line")
  12705. ], this.vectorElems_.forEach((z) => {
  12706. z.classList.add(ct2("v")), this.svgElem_.appendChild(z);
  12707. }), this.value_ = p.value, this.value_.emitter.on("change", this.onValueChange_.bind(this)), this.sel_ = p.selection, this.handleElems_.forEach((z, re) => {
  12708. S(this.sel_, ys((W2) => W2 === re, F2(z, ct2("h", "sel"))));
  12709. }), Ai(this.element, () => {
  12710. this.refresh();
  12711. });
  12712. }
  12713. getVertMargin_(o) {
  12714. return o * 0.25;
  12715. }
  12716. valueToPosition(o, p) {
  12717. const f = this.element.getBoundingClientRect(), x = f.width, T = f.height, L = this.getVertMargin_(T);
  12718. return {
  12719. x: we(o, 0, 1, 0, x),
  12720. y: we(p, 0, 1, T - L, L)
  12721. };
  12722. }
  12723. positionToValue(o, p) {
  12724. const f = this.element.getBoundingClientRect(), x = f.width, T = f.height, L = this.getVertMargin_(T);
  12725. return {
  12726. x: at(we(o, 0, x, 0, 1), 0, 1),
  12727. y: we(p, T - L, L, 0, 1)
  12728. };
  12729. }
  12730. refresh() {
  12731. this.guideElem_.setAttributeNS(null, "d", [0, 1].map((T) => {
  12732. const L = this.valueToPosition(0, T), z = this.valueToPosition(1, T);
  12733. return [`M ${L.x},${L.y}`, `L ${z.x},${z.y}`].join(" ");
  12734. }).join(" "));
  12735. const o = this.value_.rawValue, p = [];
  12736. let f = 0;
  12737. for (; ; ) {
  12738. const T = this.valueToPosition(...o.curve(f));
  12739. if (p.push([T.x, T.y].join(",")), f >= 1)
  12740. break;
  12741. f = Math.min(f + 0.05, 1);
  12742. }
  12743. this.lineElem_.setAttributeNS(null, "points", p.join(" "));
  12744. const x = o.toObject();
  12745. [0, 1].forEach((T) => {
  12746. const L = this.valueToPosition(T, T), z = this.valueToPosition(x[T * 2], x[T * 2 + 1]), re = this.vectorElems_[T];
  12747. re.setAttributeNS(null, "x1", String(L.x)), re.setAttributeNS(null, "y1", String(L.y)), re.setAttributeNS(null, "x2", String(z.x)), re.setAttributeNS(null, "y2", String(z.y));
  12748. const W2 = this.handleElems_[T];
  12749. W2.style.left = `${z.x}px`, W2.style.top = `${z.y}px`;
  12750. });
  12751. }
  12752. onValueChange_() {
  12753. this.refresh();
  12754. }
  12755. }
  12756. const Es = 24, Cs = 400, $t = 1e3, Le = y2("cbzprv");
  12757. class Xt {
  12758. constructor(o, p) {
  12759. 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 = o.createElement("div"), this.element.classList.add(Le()), p.viewProps.bindClassModifiers(this.element);
  12760. const f = o.createElementNS(ye, "svg");
  12761. f.classList.add(Le("g")), this.element.appendChild(f), this.svgElem_ = f;
  12762. const x = o.createElementNS(ye, "path");
  12763. x.classList.add(Le("t")), this.svgElem_.appendChild(x), this.ticksElem_ = x;
  12764. const T = o.createElement("div");
  12765. T.classList.add(Le("m")), this.element.appendChild(T), this.markerElem_ = T, this.value_ = p.value, this.value_.emitter.on("change", this.onValueChange_), p.viewProps.handleDispose(this.onDispose_), Ai(this.element, () => {
  12766. this.refresh();
  12767. });
  12768. }
  12769. play() {
  12770. this.stop(), this.updateMarker_(0), this.markerElem_.classList.add(Le("m", "a")), this.startTime_ = new Date().getTime() + Cs, this.stopped_ = false, requestAnimationFrame(this.onTimer_);
  12771. }
  12772. stop() {
  12773. this.stopped_ = true, this.markerElem_.classList.remove(Le("m", "a"));
  12774. }
  12775. onDispose_() {
  12776. this.stop();
  12777. }
  12778. updateMarker_(o) {
  12779. const p = this.value_.rawValue.y(at(o, 0, 1));
  12780. this.markerElem_.style.left = `${p * 100}%`;
  12781. }
  12782. refresh() {
  12783. const o = this.svgElem_.getBoundingClientRect(), p = o.width, f = o.height, x = [], T = this.value_.rawValue;
  12784. for (let L = 0; L < Es; L++) {
  12785. const z = we(L, 0, Es - 1, 0, 1), re = we(T.y(z), 0, 1, 0, p);
  12786. x.push(`M ${re},0 v${f}`);
  12787. }
  12788. this.ticksElem_.setAttributeNS(null, "d", x.join(" "));
  12789. }
  12790. onTimer_() {
  12791. if (this.startTime_ === null)
  12792. return;
  12793. const o = new Date().getTime() - this.startTime_, p = o / $t;
  12794. this.updateMarker_(p), o > $t + Cs && this.stop(), this.stopped_ || requestAnimationFrame(this.onTimer_);
  12795. }
  12796. onValueChange_() {
  12797. this.refresh(), this.play();
  12798. }
  12799. }
  12800. function nt(d, o, p, f) {
  12801. const x = p - d, T = f - o;
  12802. return Math.sqrt(x * x + T * T);
  12803. }
  12804. function Er(d, o, p, f) {
  12805. const x = nt(d, o, p, f), T = Math.atan2(f - o, p - d), L = Math.round(T / (Math.PI / 4)) * Math.PI / 4;
  12806. return {
  12807. x: d + Math.cos(L) * x,
  12808. y: o + Math.sin(L) * x
  12809. };
  12810. }
  12811. class Li {
  12812. constructor(o, p) {
  12813. 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_ = p.baseStep, this.value = p.value, this.sel_ = H(0), this.viewProps = p.viewProps, this.view = new xs(o, {
  12814. selection: this.sel_,
  12815. value: this.value,
  12816. viewProps: this.viewProps
  12817. }), this.view.element.addEventListener("keydown", this.onKeyDown_), this.view.element.addEventListener("keyup", this.onKeyUp_), this.prevView_ = new Xt(o, {
  12818. value: this.value,
  12819. viewProps: this.viewProps
  12820. }), this.prevView_.element.addEventListener("mousedown", (x) => {
  12821. x.stopImmediatePropagation(), x.preventDefault(), this.prevView_.play();
  12822. }), this.view.previewElement.appendChild(this.prevView_.element);
  12823. const f = new Ct2(this.view.element);
  12824. f.emitter.on("down", this.onPointerDown_), f.emitter.on("move", this.onPointerMove_), f.emitter.on("up", this.onPointerUp_);
  12825. }
  12826. refresh() {
  12827. this.view.refresh(), this.prevView_.refresh(), this.prevView_.play();
  12828. }
  12829. updateValue_(o, p, f) {
  12830. const x = this.sel_.rawValue, T = this.value.rawValue.toObject(), L = this.view.positionToValue(o.x, o.y), z = p ? Er(x, x, L.x, L.y) : L;
  12831. T[x * 2] = z.x, T[x * 2 + 1] = z.y, this.value.setRawValue(new Tt(...T), f);
  12832. }
  12833. onPointerDown_(o) {
  12834. const p = o.data;
  12835. if (!p.point)
  12836. return;
  12837. const f = this.value.rawValue, x = this.view.valueToPosition(f.x1, f.y1), T = nt(p.point.x, p.point.y, x.x, x.y), L = this.view.valueToPosition(f.x2, f.y2), z = nt(p.point.x, p.point.y, L.x, L.y);
  12838. this.sel_.rawValue = T <= z ? 0 : 1, this.updateValue_(p.point, o.shiftKey, {
  12839. forceEmit: false,
  12840. last: false
  12841. });
  12842. }
  12843. onPointerMove_(o) {
  12844. const p = o.data;
  12845. p.point && this.updateValue_(p.point, o.shiftKey, {
  12846. forceEmit: false,
  12847. last: false
  12848. });
  12849. }
  12850. onPointerUp_(o) {
  12851. const p = o.data;
  12852. p.point && this.updateValue_(p.point, o.shiftKey, {
  12853. forceEmit: true,
  12854. last: true
  12855. });
  12856. }
  12857. onKeyDown_(o) {
  12858. as(o.key) && o.preventDefault();
  12859. const p = this.sel_.rawValue, f = this.value.rawValue.toObject();
  12860. f[p * 2] += Kt(this.baseStep_, wi(o)), f[p * 2 + 1] += Kt(this.baseStep_, dn(o)), this.value.setRawValue(new Tt(...f), {
  12861. forceEmit: false,
  12862. last: false
  12863. });
  12864. }
  12865. onKeyUp_(o) {
  12866. as(o.key) && o.preventDefault();
  12867. const p = Kt(this.baseStep_, wi(o)), f = Kt(this.baseStep_, dn(o));
  12868. p === 0 && f === 0 || this.value.setRawValue(this.value.rawValue, {
  12869. forceEmit: true,
  12870. last: true
  12871. });
  12872. }
  12873. }
  12874. class Zn {
  12875. constructor(o, p) {
  12876. this.value = p.value, this.viewProps = p.viewProps, this.view = new gn(o, {
  12877. viewProps: this.viewProps
  12878. }), this.gc_ = new Li(o, {
  12879. baseStep: p.axis.baseStep,
  12880. value: this.value,
  12881. viewProps: this.viewProps
  12882. }), this.view.graphElement.appendChild(this.gc_.view.element);
  12883. const f = Object.assign(Object.assign({}, p.axis), { constraint: new Rt2({ max: 1, min: 0 }) }), x = Object.assign(Object.assign({}, p.axis), { constraint: void 0 });
  12884. this.tc_ = new Ti(o, {
  12885. assembly: Qn,
  12886. axes: [f, x, f, x],
  12887. parser: hn,
  12888. value: this.value,
  12889. viewProps: this.viewProps
  12890. }), this.view.textElement.appendChild(this.tc_.view.element);
  12891. }
  12892. get allFocusableElements() {
  12893. return [
  12894. this.gc_.view.element,
  12895. ...this.tc_.view.textViews.map((o) => o.inputElement)
  12896. ];
  12897. }
  12898. refresh() {
  12899. this.gc_.refresh();
  12900. }
  12901. }
  12902. class bt {
  12903. constructor(o, p) {
  12904. 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 = p.value, this.viewProps = p.viewProps, this.foldable_ = jn(p.expanded), this.view = new Ve(o, {
  12905. foldable: this.foldable_,
  12906. pickerLayout: p.pickerLayout,
  12907. viewProps: this.viewProps
  12908. }), this.view.buttonElement.addEventListener("blur", this.onButtonBlur_), this.view.buttonElement.addEventListener("click", this.onButtonClick_), this.tc_ = new Ut(o, {
  12909. parser: ws,
  12910. props: K.fromObject({
  12911. formatter: xr
  12912. }),
  12913. value: this.value,
  12914. viewProps: this.viewProps
  12915. }), this.view.textElement.appendChild(this.tc_.view.element), this.popC_ = p.pickerLayout === "popup" ? new se(o, {
  12916. viewProps: this.viewProps
  12917. }) : null;
  12918. const f = new Zn(o, {
  12919. axis: p.axis,
  12920. value: this.value,
  12921. viewProps: this.viewProps
  12922. });
  12923. f.allFocusableElements.forEach((x) => {
  12924. x.addEventListener("blur", this.onPopupChildBlur_), x.addEventListener("keydown", this.onPopupChildKeydown_);
  12925. }), this.pickerC_ = f, this.popC_ ? (this.view.element.appendChild(this.popC_.view.element), this.popC_.view.element.appendChild(this.pickerC_.view.element), S(this.popC_.shows, (x) => {
  12926. x && f.refresh();
  12927. }), Ht({
  12928. primary: this.foldable_.value("expanded"),
  12929. secondary: this.popC_.shows,
  12930. forward: (x) => x.rawValue,
  12931. backward: (x, T) => T.rawValue
  12932. })) : this.view.pickerElement && (this.view.pickerElement.appendChild(this.pickerC_.view.element), Un(this.foldable_, this.view.pickerElement));
  12933. }
  12934. onButtonBlur_(o) {
  12935. if (!this.popC_)
  12936. return;
  12937. const p = o.relatedTarget;
  12938. (!p || !this.popC_.view.element.contains(p)) && (this.popC_.shows.rawValue = false);
  12939. }
  12940. onButtonClick_() {
  12941. this.foldable_.set("expanded", !this.foldable_.get("expanded")), this.foldable_.get("expanded") && this.pickerC_.allFocusableElements[0].focus();
  12942. }
  12943. onPopupChildBlur_(o) {
  12944. if (!this.popC_)
  12945. return;
  12946. const p = this.popC_.view.element, f = on(o);
  12947. f && p.contains(f) || f && f === this.view.buttonElement && !Qe2(p.ownerDocument) || (this.popC_.shows.rawValue = false);
  12948. }
  12949. onPopupChildKeydown_(o) {
  12950. this.popC_ && o.key === "Escape" && (this.popC_.shows.rawValue = false);
  12951. }
  12952. }
  12953. function Ee2() {
  12954. return new bn({
  12955. assembly: Qn,
  12956. components: [0, 1, 2, 3].map((d) => d % 2 === 0 ? new Rt2({
  12957. min: 0,
  12958. max: 1
  12959. }) : void 0)
  12960. });
  12961. }
  12962. const Ps = {
  12963. id: "cubic-bezier",
  12964. type: "blade",
  12965. 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}',
  12966. accept(d) {
  12967. const o = de2, p = te2(d, {
  12968. value: o.required.array(o.required.number),
  12969. view: o.required.constant("cubicbezier"),
  12970. expanded: o.optional.boolean,
  12971. label: o.optional.string,
  12972. picker: o.optional.custom((f) => f === "inline" || f === "popup" ? f : void 0)
  12973. });
  12974. return p ? { params: p } : null;
  12975. },
  12976. controller(d) {
  12977. var o, p;
  12978. const f = new Tt(...d.params.value), x = H(f, {
  12979. constraint: Ee2(),
  12980. equals: Tt.equals
  12981. }), T = new bt(d.document, {
  12982. axis: {
  12983. baseStep: 0.1,
  12984. textProps: K.fromObject({
  12985. draggingScale: 0.01,
  12986. formatter: Ie(2)
  12987. })
  12988. },
  12989. expanded: (o = d.params.expanded) !== null && o !== void 0 ? o : false,
  12990. pickerLayout: (p = d.params.picker) !== null && p !== void 0 ? p : "popup",
  12991. value: x,
  12992. viewProps: d.viewProps
  12993. });
  12994. return new Lt(d.document, {
  12995. blade: d.blade,
  12996. props: K.fromObject({
  12997. label: d.params.label
  12998. }),
  12999. valueController: T
  13000. });
  13001. },
  13002. api(d) {
  13003. return !(d.controller instanceof Lt) || !(d.controller.valueController instanceof bt) ? null : new gs(d.controller);
  13004. }
  13005. };
  13006. class Ae extends s {
  13007. begin() {
  13008. this.controller_.valueController.begin();
  13009. }
  13010. end() {
  13011. this.controller_.valueController.end();
  13012. }
  13013. }
  13014. const Ri = 20;
  13015. class Ye {
  13016. constructor() {
  13017. this.start_ = null, this.duration_ = 0, this.fps_ = null, this.frameCount_ = 0, this.timestamps_ = [];
  13018. }
  13019. get duration() {
  13020. return this.duration_;
  13021. }
  13022. get fps() {
  13023. return this.fps_;
  13024. }
  13025. begin(o) {
  13026. this.start_ = o.getTime();
  13027. }
  13028. calculateFps_(o) {
  13029. if (this.timestamps_.length === 0)
  13030. return null;
  13031. const p = this.timestamps_[0];
  13032. return 1e3 * (this.frameCount_ - p.frameCount) / (o - p.time);
  13033. }
  13034. compactTimestamps_() {
  13035. if (this.timestamps_.length <= Ri)
  13036. return;
  13037. const o = this.timestamps_.length - Ri;
  13038. this.timestamps_.splice(0, o);
  13039. const p = this.timestamps_[0].frameCount;
  13040. this.timestamps_.forEach((f) => {
  13041. f.frameCount -= p;
  13042. }), this.frameCount_ -= p;
  13043. }
  13044. end(o) {
  13045. if (this.start_ === null)
  13046. return;
  13047. const p = o.getTime();
  13048. this.duration_ = p - this.start_, this.start_ = null, this.fps_ = this.calculateFps_(p), this.timestamps_.push({
  13049. frameCount: this.frameCount_,
  13050. time: p
  13051. }), ++this.frameCount_, this.compactTimestamps_();
  13052. }
  13053. }
  13054. const _n = y2("fps");
  13055. class Yt {
  13056. constructor(o, p) {
  13057. this.element = o.createElement("div"), this.element.classList.add(_n()), p.viewProps.bindClassModifiers(this.element), this.graphElement = o.createElement("div"), this.graphElement.classList.add(_n("g")), this.element.appendChild(this.graphElement);
  13058. const f = o.createElement("div");
  13059. f.classList.add(_n("l")), this.element.appendChild(f);
  13060. const x = o.createElement("span");
  13061. x.classList.add(_n("v")), x.textContent = "--", f.appendChild(x), this.valueElement = x;
  13062. const T = o.createElement("span");
  13063. T.classList.add(_n("u")), T.textContent = "FPS", f.appendChild(T);
  13064. }
  13065. }
  13066. class wn {
  13067. constructor(o, p) {
  13068. this.stopwatch_ = new Ye(), this.onTick_ = this.onTick_.bind(this), this.ticker_ = p.ticker, this.ticker_.emitter.on("tick", this.onTick_), this.value_ = p.value, this.viewProps = p.viewProps, this.view = new Yt(o, {
  13069. viewProps: this.viewProps
  13070. }), this.graphC_ = new br(o, {
  13071. formatter: Ie(0),
  13072. lineCount: p.lineCount,
  13073. props: K.fromObject({
  13074. maxValue: p.maxValue,
  13075. minValue: p.minValue
  13076. }),
  13077. value: this.value_,
  13078. viewProps: this.viewProps
  13079. }), this.view.graphElement.appendChild(this.graphC_.view.element), this.viewProps.handleDispose(() => {
  13080. this.graphC_.viewProps.set("disposed", true), this.ticker_.dispose();
  13081. });
  13082. }
  13083. begin() {
  13084. this.stopwatch_.begin(new Date());
  13085. }
  13086. end() {
  13087. this.stopwatch_.end(new Date());
  13088. }
  13089. onTick_() {
  13090. const o = this.stopwatch_.fps;
  13091. if (o !== null) {
  13092. const p = this.value_.rawValue;
  13093. this.value_.rawValue = sr(p, o), this.view.valueElement.textContent = o.toFixed(0);
  13094. }
  13095. }
  13096. }
  13097. function Cr(d, o) {
  13098. return o === 0 ? new Gn() : new ln(d, o ?? fr.monitor.defaultInterval);
  13099. }
  13100. const Pr = {
  13101. id: "fpsgraph",
  13102. type: "blade",
  13103. accept(d) {
  13104. const o = de2, p = te2(d, {
  13105. view: o.required.constant("fpsgraph"),
  13106. interval: o.optional.number,
  13107. label: o.optional.string,
  13108. lineCount: o.optional.number,
  13109. max: o.optional.number,
  13110. min: o.optional.number
  13111. });
  13112. return p ? { params: p } : null;
  13113. },
  13114. controller(d) {
  13115. var o, p, f, x;
  13116. const T = (o = d.params.interval) !== null && o !== void 0 ? o : 500;
  13117. return new rt2(d.document, {
  13118. blade: d.blade,
  13119. props: K.fromObject({
  13120. label: d.params.label
  13121. }),
  13122. valueController: new wn(d.document, {
  13123. lineCount: (p = d.params.lineCount) !== null && p !== void 0 ? p : 2,
  13124. maxValue: (f = d.params.max) !== null && f !== void 0 ? f : 90,
  13125. minValue: (x = d.params.min) !== null && x !== void 0 ? x : 0,
  13126. ticker: Cr(d.document, T),
  13127. value: rs(80),
  13128. viewProps: d.viewProps
  13129. })
  13130. });
  13131. },
  13132. api(d) {
  13133. return !(d.controller instanceof rt2) || !(d.controller.valueController instanceof wn) ? null : new Ae(d.controller);
  13134. }
  13135. };
  13136. class Be {
  13137. constructor(o, p) {
  13138. this.min = o, this.max = p;
  13139. }
  13140. static isObject(o) {
  13141. if (typeof o != "object" || o === null)
  13142. return false;
  13143. const p = o.min, f = o.max;
  13144. return !(typeof p != "number" || typeof f != "number");
  13145. }
  13146. static equals(o, p) {
  13147. return o.min === p.min && o.max === p.max;
  13148. }
  13149. get length() {
  13150. return this.max - this.min;
  13151. }
  13152. toObject() {
  13153. return {
  13154. min: this.min,
  13155. max: this.max
  13156. };
  13157. }
  13158. }
  13159. const Ii = {
  13160. fromComponents: (d) => new Be(d[0], d[1]),
  13161. toComponents: (d) => [d.min, d.max]
  13162. };
  13163. class yn {
  13164. constructor(o) {
  13165. this.edge = o;
  13166. }
  13167. constrain(o) {
  13168. var p, f, x, T, L, z, re, W2;
  13169. if (o.min <= o.max)
  13170. return new Be((f = (p = this.edge) === null || p === void 0 ? void 0 : p.constrain(o.min)) !== null && f !== void 0 ? f : o.min, (T = (x = this.edge) === null || x === void 0 ? void 0 : x.constrain(o.max)) !== null && T !== void 0 ? T : o.max);
  13171. const Fe = (o.min + o.max) / 2;
  13172. return new Be((z = (L = this.edge) === null || L === void 0 ? void 0 : L.constrain(Fe)) !== null && z !== void 0 ? z : Fe, (W2 = (re = this.edge) === null || re === void 0 ? void 0 : re.constrain(Fe)) !== null && W2 !== void 0 ? W2 : Fe);
  13173. }
  13174. }
  13175. const Ot = y2("rsltxt");
  13176. class xn {
  13177. constructor(o, p) {
  13178. this.sliderView_ = p.sliderView, this.textView_ = p.textView, this.element = o.createElement("div"), this.element.classList.add(Ot());
  13179. const f = o.createElement("div");
  13180. f.classList.add(Ot("s")), f.appendChild(this.sliderView_.element), this.element.appendChild(f);
  13181. const x = o.createElement("div");
  13182. x.classList.add(Ot("t")), x.appendChild(this.textView_.element), this.element.appendChild(x);
  13183. }
  13184. }
  13185. const kt = y2("rsl");
  13186. class gt2 {
  13187. constructor(o, p) {
  13188. this.onSliderPropsChange_ = this.onSliderPropsChange_.bind(this), this.onValueChange_ = this.onValueChange_.bind(this), this.sliderProps_ = p.sliderProps, this.sliderProps_.emitter.on("change", this.onSliderPropsChange_), this.element = o.createElement("div"), this.element.classList.add(kt()), p.viewProps.bindClassModifiers(this.element), this.value_ = p.value, this.value_.emitter.on("change", this.onValueChange_);
  13189. const f = o.createElement("div");
  13190. f.classList.add(kt("t")), this.element.appendChild(f), this.trackElement = f;
  13191. const x = o.createElement("div");
  13192. x.classList.add(kt("b")), f.appendChild(x), this.barElement = x;
  13193. const T = ["min", "max"].map((L) => {
  13194. const z = o.createElement("div");
  13195. return z.classList.add(kt("k"), kt("k", L)), f.appendChild(z), z;
  13196. });
  13197. this.knobElements = [T[0], T[1]], this.update_();
  13198. }
  13199. valueToX_(o) {
  13200. const p = this.sliderProps_.get("minValue"), f = this.sliderProps_.get("maxValue");
  13201. return at(we(o, p, f, 0, 1), 0, 1) * 100;
  13202. }
  13203. update_() {
  13204. const o = this.value_.rawValue;
  13205. o.length === 0 ? this.element.classList.add(kt(void 0, "zero")) : this.element.classList.remove(kt(void 0, "zero"));
  13206. const p = [this.valueToX_(o.min), this.valueToX_(o.max)];
  13207. this.barElement.style.left = `${p[0]}%`, this.barElement.style.right = `${100 - p[1]}%`, this.knobElements.forEach((f, x) => {
  13208. f.style.left = `${p[x]}%`;
  13209. });
  13210. }
  13211. onSliderPropsChange_() {
  13212. this.update_();
  13213. }
  13214. onValueChange_() {
  13215. this.update_();
  13216. }
  13217. }
  13218. class Vi {
  13219. constructor(o, p) {
  13220. 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 = p.sliderProps, this.viewProps = p.viewProps, this.value = p.value, this.view = new gt2(o, {
  13221. sliderProps: this.sliderProps,
  13222. value: this.value,
  13223. viewProps: p.viewProps
  13224. });
  13225. const f = new Ct2(this.view.trackElement);
  13226. f.emitter.on("down", this.onPointerDown_), f.emitter.on("move", this.onPointerMove_), f.emitter.on("up", this.onPointerUp_);
  13227. }
  13228. ofs_() {
  13229. return this.grabbing_ === "min" ? this.view.knobElements[0].getBoundingClientRect().width / 2 : this.grabbing_ === "max" ? -this.view.knobElements[1].getBoundingClientRect().width / 2 : 0;
  13230. }
  13231. valueFromData_(o) {
  13232. if (!o.point)
  13233. return null;
  13234. const p = (o.point.x + this.ofs_()) / o.bounds.width, f = this.sliderProps.get("minValue"), x = this.sliderProps.get("maxValue");
  13235. return we(p, 0, 1, f, x);
  13236. }
  13237. onPointerDown_(o) {
  13238. if (!o.data.point)
  13239. return;
  13240. const p = o.data.point.x / o.data.bounds.width, f = this.value.rawValue, x = this.sliderProps.get("minValue"), T = this.sliderProps.get("maxValue"), L = we(f.min, x, T, 0, 1), z = we(f.max, x, T, 0, 1);
  13241. Math.abs(z - p) <= 0.025 ? this.grabbing_ = "max" : Math.abs(L - p) <= 0.025 ? this.grabbing_ = "min" : p >= L && p <= z ? (this.grabbing_ = "length", this.grabOffset_ = we(p - L, 0, 1, 0, T - x)) : p < L ? (this.grabbing_ = "min", this.onPointerMove_(o)) : p > z && (this.grabbing_ = "max", this.onPointerMove_(o));
  13242. }
  13243. applyPointToValue_(o, p) {
  13244. const f = this.valueFromData_(o);
  13245. if (f === null)
  13246. return;
  13247. const x = this.sliderProps.get("minValue"), T = this.sliderProps.get("maxValue");
  13248. if (this.grabbing_ === "min")
  13249. this.value.setRawValue(new Be(f, this.value.rawValue.max), p);
  13250. else if (this.grabbing_ === "max")
  13251. this.value.setRawValue(new Be(this.value.rawValue.min, f), p);
  13252. else if (this.grabbing_ === "length") {
  13253. const L = this.value.rawValue.length;
  13254. let z = f - this.grabOffset_, re = z + L;
  13255. z < x ? (z = x, re = x + L) : re > T && (z = T - L, re = T), this.value.setRawValue(new Be(z, re), p);
  13256. }
  13257. }
  13258. onPointerMove_(o) {
  13259. this.applyPointToValue_(o.data, {
  13260. forceEmit: false,
  13261. last: false
  13262. });
  13263. }
  13264. onPointerUp_(o) {
  13265. this.applyPointToValue_(o.data, {
  13266. forceEmit: true,
  13267. last: true
  13268. }), this.grabbing_ = null;
  13269. }
  13270. }
  13271. class Wn {
  13272. constructor(o, p) {
  13273. this.value = p.value, this.viewProps = p.viewProps, this.sc_ = new Vi(o, p);
  13274. const f = {
  13275. baseStep: p.baseStep,
  13276. constraint: p.constraint,
  13277. textProps: K.fromObject({
  13278. draggingScale: p.draggingScale,
  13279. formatter: p.formatter
  13280. })
  13281. };
  13282. this.tc_ = new Ti(o, {
  13283. assembly: Ii,
  13284. axes: [f, f],
  13285. parser: p.parser,
  13286. value: this.value,
  13287. viewProps: p.viewProps
  13288. }), this.view = new xn(o, {
  13289. sliderView: this.sc_.view,
  13290. textView: this.tc_.view
  13291. });
  13292. }
  13293. get textController() {
  13294. return this.tc_;
  13295. }
  13296. }
  13297. function Tr(d) {
  13298. return Be.isObject(d) ? new Be(d.min, d.max) : new Be(0, 0);
  13299. }
  13300. function Jn(d, o) {
  13301. d.writeProperty("max", o.max), d.writeProperty("min", o.min);
  13302. }
  13303. function qt(d) {
  13304. const o = [], p = mr(d);
  13305. p && o.push(p);
  13306. const f = dr(d);
  13307. return f && o.push(f), new yn(new Hn(o));
  13308. }
  13309. const Qt = {
  13310. id: "input-interval",
  13311. type: "input",
  13312. 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}',
  13313. accept: (d, o) => {
  13314. if (!Be.isObject(d))
  13315. return null;
  13316. const p = de2, f = te2(o, {
  13317. format: p.optional.function,
  13318. max: p.optional.number,
  13319. min: p.optional.number,
  13320. step: p.optional.number
  13321. });
  13322. return f ? {
  13323. initialValue: new Be(d.min, d.max),
  13324. params: f
  13325. } : null;
  13326. },
  13327. binding: {
  13328. reader: (d) => Tr,
  13329. constraint: (d) => qt(d.params),
  13330. equals: Be.equals,
  13331. writer: (d) => Jn
  13332. },
  13333. controller(d) {
  13334. var o;
  13335. const p = d.value, f = d.constraint;
  13336. if (!(f instanceof yn))
  13337. throw g.shouldNeverHappen();
  13338. const x = (p.rawValue.min + p.rawValue.max) / 2, T = (o = d.params.format) !== null && o !== void 0 ? o : Ie(ls(f.edge, x)), L = f.edge && Et(f.edge, vt);
  13339. if (L)
  13340. return new Wn(d.document, {
  13341. baseStep: cs(f.edge),
  13342. constraint: f.edge,
  13343. draggingScale: ps(f.edge, x),
  13344. formatter: T,
  13345. parser: hn,
  13346. sliderProps: new K({
  13347. maxValue: L.values.value("max"),
  13348. minValue: L.values.value("min")
  13349. }),
  13350. value: p,
  13351. viewProps: d.viewProps
  13352. });
  13353. const z = {
  13354. baseStep: cs(f.edge),
  13355. constraint: f.edge,
  13356. textProps: K.fromObject({
  13357. draggingScale: x,
  13358. formatter: T
  13359. })
  13360. };
  13361. return new Ti(d.document, {
  13362. assembly: Ii,
  13363. axes: [z, z],
  13364. parser: hn,
  13365. value: p,
  13366. viewProps: d.viewProps
  13367. });
  13368. }
  13369. };
  13370. class En {
  13371. constructor(o) {
  13372. this.controller_ = o;
  13373. }
  13374. get disabled() {
  13375. return this.controller_.viewProps.get("disabled");
  13376. }
  13377. set disabled(o) {
  13378. this.controller_.viewProps.set("disabled", o);
  13379. }
  13380. get title() {
  13381. var o;
  13382. return (o = this.controller_.props.get("title")) !== null && o !== void 0 ? o : "";
  13383. }
  13384. set title(o) {
  13385. this.controller_.props.set("title", o);
  13386. }
  13387. }
  13388. class Ts extends c {
  13389. constructor(o, p, f, x, T) {
  13390. super(o, x, T), this.cell = p, this.index = f;
  13391. }
  13392. }
  13393. class ks extends s {
  13394. constructor(o) {
  13395. super(o), this.cellToApiMap_ = /* @__PURE__ */ new Map(), this.controller_.valueController.cellControllers.forEach((f) => {
  13396. const x = new En(f);
  13397. this.cellToApiMap_.set(f, x);
  13398. });
  13399. }
  13400. get value() {
  13401. return this.controller_.value;
  13402. }
  13403. cell(o, p) {
  13404. const f = this.controller_.valueController, x = f.cellControllers[p * f.size[0] + o];
  13405. return this.cellToApiMap_.get(x);
  13406. }
  13407. on(o, p) {
  13408. const f = p.bind(this);
  13409. this.controller_.value.emitter.on(o, (x) => {
  13410. const T = this.controller_.valueController, L = T.findCellByValue(x.rawValue);
  13411. if (!L)
  13412. return;
  13413. const z = this.cellToApiMap_.get(L);
  13414. if (!z)
  13415. return;
  13416. const re = T.cellControllers.indexOf(L);
  13417. f(new Ts(this, z, [re % T.size[0], Math.floor(re / T.size[0])], x.rawValue, void 0));
  13418. });
  13419. }
  13420. }
  13421. const Cn = y2("rad");
  13422. class Ms {
  13423. constructor(o, p) {
  13424. this.element = o.createElement("div"), this.element.classList.add(Cn()), p.viewProps.bindClassModifiers(this.element);
  13425. const f = o.createElement("label");
  13426. f.classList.add(Cn("l")), this.element.appendChild(f);
  13427. const x = o.createElement("input");
  13428. x.classList.add(Cn("i")), x.name = p.name, x.type = "radio", p.viewProps.bindDisabled(x), f.appendChild(x), this.inputElement = x;
  13429. const T = o.createElement("div");
  13430. T.classList.add(Cn("b")), f.appendChild(T);
  13431. const L = o.createElement("div");
  13432. L.classList.add(Cn("t")), T.appendChild(L), R(p.props, "title", (z) => {
  13433. L.textContent = z;
  13434. });
  13435. }
  13436. }
  13437. class Mt {
  13438. constructor(o, p) {
  13439. this.props = p.props, this.viewProps = p.viewProps, this.view = new Ms(o, {
  13440. name: p.name,
  13441. props: this.props,
  13442. viewProps: this.viewProps
  13443. });
  13444. }
  13445. }
  13446. class ei {
  13447. constructor(o, p) {
  13448. this.cellCs_ = [], this.cellValues_ = [], this.onCellInputChange_ = this.onCellInputChange_.bind(this), this.size = p.size;
  13449. const [f, x] = this.size;
  13450. for (let T = 0; T < x; T++)
  13451. for (let L = 0; L < f; L++) {
  13452. const z = new Mt(o, {
  13453. name: p.groupName,
  13454. props: K.fromObject(Object.assign({}, p.cellConfig(L, T))),
  13455. viewProps: ge.create()
  13456. });
  13457. this.cellCs_.push(z), this.cellValues_.push(p.cellConfig(L, T).value);
  13458. }
  13459. this.value = p.value, S(this.value, (T) => {
  13460. const L = this.findCellByValue(T);
  13461. L && (L.view.inputElement.checked = true);
  13462. }), this.viewProps = ge.create(), this.view = new xt(o, {
  13463. viewProps: this.viewProps,
  13464. viewName: "radgrid"
  13465. }), this.view.element.style.gridTemplateColumns = `repeat(${f}, 1fr)`, this.cellCs_.forEach((T) => {
  13466. T.view.inputElement.addEventListener("change", this.onCellInputChange_), this.view.element.appendChild(T.view.element);
  13467. });
  13468. }
  13469. get cellControllers() {
  13470. return this.cellCs_;
  13471. }
  13472. findCellByValue(o) {
  13473. const p = this.cellValues_.findIndex((f) => f === o);
  13474. return p < 0 ? null : this.cellCs_[p];
  13475. }
  13476. onCellInputChange_(o) {
  13477. const p = o.currentTarget, f = this.cellCs_.findIndex((x) => x.view.inputElement === p);
  13478. f < 0 || (this.value.rawValue = this.cellValues_[f]);
  13479. }
  13480. }
  13481. const kr = function() {
  13482. return {
  13483. id: "radiogrid",
  13484. type: "blade",
  13485. accept(d) {
  13486. const o = de2, p = te2(d, {
  13487. cells: o.required.function,
  13488. groupName: o.required.string,
  13489. size: o.required.array(o.required.number),
  13490. value: o.required.raw,
  13491. view: o.required.constant("radiogrid"),
  13492. label: o.optional.string
  13493. });
  13494. return p ? { params: p } : null;
  13495. },
  13496. controller(d) {
  13497. return new Lt(d.document, {
  13498. blade: d.blade,
  13499. props: K.fromObject({
  13500. label: d.params.label
  13501. }),
  13502. valueController: new ei(d.document, {
  13503. groupName: d.params.groupName,
  13504. cellConfig: d.params.cells,
  13505. size: d.params.size,
  13506. value: H(d.params.value)
  13507. })
  13508. });
  13509. },
  13510. api(d) {
  13511. return !(d.controller instanceof Lt) || !(d.controller.valueController instanceof ei) ? null : new ks(d.controller);
  13512. }
  13513. };
  13514. }();
  13515. function Di(d) {
  13516. return {
  13517. id: "input-radiogrid",
  13518. type: "input",
  13519. accept(o, p) {
  13520. if (!d.isType(o))
  13521. return null;
  13522. const f = de2, x = te2(p, {
  13523. cells: f.required.function,
  13524. groupName: f.required.string,
  13525. size: f.required.array(f.required.number),
  13526. view: f.required.constant("radiogrid")
  13527. });
  13528. return x ? {
  13529. initialValue: o,
  13530. params: x
  13531. } : null;
  13532. },
  13533. binding: d.binding,
  13534. controller: (o) => new ei(o.document, {
  13535. cellConfig: o.params.cells,
  13536. groupName: o.params.groupName,
  13537. size: o.params.size,
  13538. value: o.value
  13539. })
  13540. };
  13541. }
  13542. const Mr = Di({
  13543. isType: (d) => typeof d == "number",
  13544. binding: {
  13545. reader: (d) => nr,
  13546. writer: (d) => Ei
  13547. }
  13548. }), Ss = Di({
  13549. isType: (d) => typeof d == "string",
  13550. binding: {
  13551. reader: (d) => ss,
  13552. writer: (d) => Ei
  13553. }
  13554. }), Sr = Di({
  13555. isType: (d) => typeof d == "boolean",
  13556. binding: {
  13557. reader: (d) => cn,
  13558. writer: (d) => Ei
  13559. }
  13560. }), Ar = [
  13561. _r,
  13562. Ps,
  13563. Pr,
  13564. Qt,
  13565. kr,
  13566. Sr,
  13567. Mr,
  13568. Ss
  13569. ];
  13570. r.ButtonCellApi = vs, r.ButtonGridApi = bs, r.ButtonGridController = ki, r.CubicBezier = Tt, r.CubicBezierApi = gs, r.CubicBezierAssembly = Qn, r.CubicBezierController = bt, r.CubicBezierGraphController = Li, r.CubicBezierGraphView = xs, r.CubicBezierPickerController = Zn, r.CubicBezierPickerView = gn, r.CubicBezierPreviewView = Xt, r.CubicBezierView = Ve, r.FpsGraphBladeApi = Ae, r.FpsGraphController = wn, r.FpsView = Yt, r.Fpswatch = Ye, r.Interval = Be, r.IntervalAssembly = Ii, r.IntervalConstraint = yn, r.RadioCellApi = En, r.RadioController = Mt, r.RadioGridApi = ks, r.RadioGridController = ei, r.RadioView = Ms, r.RangeSliderController = Vi, r.RangeSliderTextController = Wn, r.RangeSliderTextView = xn, r.RangeSliderView = gt2, r.TpRadioGridChangeEvent = Ts, r.plugins = Ar, Object.defineProperty(r, "__esModule", { value: true });
  13571. });
  13572. })(kh, Wi);
  13573. var Mh = rh(Wi);
  13574. var Sh = Bp({
  13575. __proto__: null,
  13576. default: Mh
  13577. }, [Wi]);
  13578. var Sn;
  13579. var Ds;
  13580. var jh = (b2 = "tres-container") => {
  13581. Sn || (Sn = new zs.Pane({
  13582. container: document.querySelector(b2) || void 0
  13583. }), Sn.registerPlugin(Sh), Ds = Sn.addBlade({
  13584. view: "fpsgraph",
  13585. label: "fpsgraph"
  13586. }));
  13587. function i() {
  13588. Sn && Sn.dispose();
  13589. }
  13590. return onMounted(() => {
  13591. const { onBeforeLoop: r, onAfterLoop: s, resume: a } = ne();
  13592. a(), r(() => Ds.begin()), s(() => Ds.end());
  13593. }), onUnmounted(() => {
  13594. i();
  13595. }), { pane: Sn, fpsGraph: Ds, disposeTweakPane: i };
  13596. };
  13597. function zh(b2, i) {
  13598. const r = ref(i), s = new AnimationMixer(r.value), a = shallowReactive({});
  13599. b2.forEach((u) => {
  13600. const h2 = s.clipAction(u, r.value);
  13601. a[u.name] = h2;
  13602. });
  13603. const { onLoop: c } = ne();
  13604. return c(({ delta: u }) => {
  13605. s.update(u);
  13606. }), {
  13607. actions: a,
  13608. mixer: s
  13609. };
  13610. }
  13611. var Os = null;
  13612. function Ah(b2, i) {
  13613. return (r) => {
  13614. i && i(r), b2.draco && (Os || (Os = new ah()), Os.setDecoderPath(b2.decoderPath || "https://www.gstatic.com/draco/versioned/decoders/1.4.3/"), r.setDRACOLoader(Os));
  13615. };
  13616. }
  13617. async function Lh(b2, i = {
  13618. draco: false
  13619. }, r) {
  13620. return await Ct(ou, b2, Ah(i, r));
  13621. }
  13622. var Uh = defineComponent({
  13623. name: "GLTFModel",
  13624. props: {
  13625. /**
  13626. * The path to the GLTF file.
  13627. *
  13628. */
  13629. path: String,
  13630. /**
  13631. * Whether to use Draco compression.
  13632. *
  13633. */
  13634. draco: Boolean,
  13635. /**
  13636. * The path to the Draco decoder.
  13637. *
  13638. */
  13639. decoderPath: String
  13640. },
  13641. async setup(b2, { expose: i }) {
  13642. const { state: r } = Nn();
  13643. function s() {
  13644. return a;
  13645. }
  13646. i({ getModel: s });
  13647. const { scene: a } = await Lh(b2.path, { draco: b2.draco, decoderPath: b2.decoderPath });
  13648. return r.scene && r.scene.add(a), () => {
  13649. };
  13650. }
  13651. });
  13652. async function Rh(b2) {
  13653. return await Ct(Hu, b2);
  13654. }
  13655. var Gh = defineComponent({
  13656. name: "FBXModel",
  13657. props: {
  13658. /*
  13659. * The path to the FBX file.
  13660. */
  13661. path: {
  13662. type: String,
  13663. required: true
  13664. }
  13665. },
  13666. async setup(b2, { expose: i }) {
  13667. const { state: r } = Nn();
  13668. let s = null;
  13669. function a() {
  13670. return s;
  13671. }
  13672. return i({ getModel: a }), s = await Rh(b2.path), r.scene && s.isObject3D && r.scene.add(s), () => {
  13673. };
  13674. }
  13675. });
  13676. var Hh = defineComponent({
  13677. __name: "Text3D",
  13678. props: {
  13679. font: null,
  13680. text: null,
  13681. size: { default: 0.5 },
  13682. height: { default: 0.2 },
  13683. curveSegments: { default: 5 },
  13684. bevelEnabled: { type: Boolean, default: true },
  13685. bevelThickness: { default: 0.05 },
  13686. bevelSize: { default: 0.02 },
  13687. bevelOffset: { default: 0 },
  13688. bevelSegments: { default: 4 },
  13689. center: { type: Boolean, default: false }
  13690. },
  13691. async setup(b2) {
  13692. let i, r;
  13693. const s = b2, { extend: a } = Nn();
  13694. a({ TextGeometry: Ou });
  13695. const c = new nh(), u = useSlots(), h2 = computed(() => {
  13696. var w;
  13697. return s.text ? s.text : u.default ? (w = u.default()[0].children) == null ? void 0 : w.trim() : "TresJS";
  13698. }), m = ([i, r] = withAsyncContext(() => new Promise((w, _) => {
  13699. try {
  13700. typeof s.font == "string" ? c.load(s.font, (y2) => {
  13701. w(y2);
  13702. }) : w(s.font);
  13703. } catch (y2) {
  13704. _(console.error("cientos", y2));
  13705. }
  13706. })), i = await i, r(), i), g = computed(() => ({
  13707. font: m,
  13708. size: s.size,
  13709. height: s.height,
  13710. curveSegments: s.curveSegments,
  13711. bevelEnabled: s.bevelEnabled,
  13712. bevelThickness: s.bevelThickness,
  13713. bevelSize: s.bevelSize,
  13714. bevelOffset: s.bevelOffset,
  13715. bevelSegments: s.bevelSegments
  13716. }));
  13717. return (w, _) => {
  13718. const y2 = resolveComponent("TresTextGeometry"), C = resolveComponent("TresMesh");
  13719. return unref(m) ? (openBlock(), createBlock(C, { key: 0 }, {
  13720. default: withCtx(() => [
  13721. unref(h2) ? (openBlock(), createBlock(y2, {
  13722. key: 0,
  13723. args: [unref(h2), unref(g)],
  13724. center: b2.center
  13725. }, null, 8, ["args", "center"])) : createCommentVNode("", true),
  13726. renderSlot(w.$slots, "default")
  13727. ]),
  13728. _: 3
  13729. })) : createCommentVNode("", true);
  13730. };
  13731. }
  13732. });
  13733. var Kh = defineComponent({
  13734. __name: "Plane",
  13735. props: {
  13736. args: { default: () => [1, 1] },
  13737. color: { default: "0xffffff" }
  13738. },
  13739. setup(b2, { expose: i }) {
  13740. const r = shallowRef();
  13741. return i({
  13742. value: r
  13743. }), (s, a) => {
  13744. const c = resolveComponent("TresPlaneGeometry"), u = resolveComponent("TresMeshBasicMaterial"), h2 = resolveComponent("TresMesh");
  13745. return openBlock(), createBlock(h2, mergeProps({
  13746. ref_key: "planeRef",
  13747. ref: r,
  13748. rotation: [-Math.PI / 2, 0, 0]
  13749. }, s.$attrs), {
  13750. default: withCtx(() => [
  13751. createVNode(c, { args: b2.args }, null, 8, ["args"]),
  13752. renderSlot(s.$slots, "default", {}, () => [
  13753. createVNode(u, { color: b2.color }, null, 8, ["color"])
  13754. ])
  13755. ]),
  13756. _: 3
  13757. }, 16, ["rotation"]);
  13758. };
  13759. }
  13760. });
  13761. var $h = defineComponent({
  13762. __name: "Box",
  13763. props: {
  13764. args: { default: () => [1, 1, 1] },
  13765. color: { default: "0xffffff" }
  13766. },
  13767. setup(b2, { expose: i }) {
  13768. const r = shallowRef();
  13769. return i({
  13770. value: r
  13771. }), (s, a) => {
  13772. const c = resolveComponent("TresBoxGeometry"), u = resolveComponent("TresMeshBasicMaterial"), h2 = resolveComponent("TresMesh");
  13773. return openBlock(), createBlock(h2, mergeProps({
  13774. ref_key: "boxRef",
  13775. ref: r
  13776. }, s.$attrs), {
  13777. default: withCtx(() => [
  13778. createVNode(c, { args: b2.args }, null, 8, ["args"]),
  13779. renderSlot(s.$slots, "default", {}, () => [
  13780. createVNode(u, { color: b2.color }, null, 8, ["color"])
  13781. ])
  13782. ]),
  13783. _: 3
  13784. }, 16);
  13785. };
  13786. }
  13787. });
  13788. var Xh = defineComponent({
  13789. __name: "Sphere",
  13790. props: {
  13791. args: { default: () => [2, 32, 16] },
  13792. color: { default: "0xffffff" }
  13793. },
  13794. setup(b2, { expose: i }) {
  13795. const r = shallowRef();
  13796. return i({
  13797. value: r
  13798. }), (s, a) => {
  13799. const c = resolveComponent("TresSphereGeometry"), u = resolveComponent("TresMeshBasicMaterial"), h2 = resolveComponent("TresMesh");
  13800. return openBlock(), createBlock(h2, mergeProps({
  13801. ref_key: "sphereRef",
  13802. ref: r
  13803. }, s.$attrs), {
  13804. default: withCtx(() => [
  13805. createVNode(c, { args: b2.args }, null, 8, ["args"]),
  13806. renderSlot(s.$slots, "default", {}, () => [
  13807. createVNode(u, { color: b2.color }, null, 8, ["color"])
  13808. ])
  13809. ]),
  13810. _: 3
  13811. }, 16);
  13812. };
  13813. }
  13814. });
  13815. var Yh = defineComponent({
  13816. __name: "Torus",
  13817. props: {
  13818. args: { default: () => [1, 1, 16, 80] },
  13819. color: { default: "0xffffff" }
  13820. },
  13821. setup(b2, { expose: i }) {
  13822. const r = shallowRef();
  13823. return i({
  13824. value: r
  13825. }), (s, a) => {
  13826. const c = resolveComponent("TresTorusGeometry"), u = resolveComponent("TresMeshBasicMaterial"), h2 = resolveComponent("TresMesh");
  13827. return openBlock(), createBlock(h2, mergeProps({
  13828. ref_key: "torusRef",
  13829. ref: r
  13830. }, s.$attrs), {
  13831. default: withCtx(() => [
  13832. createVNode(c, { args: b2.args }, null, 8, ["args"]),
  13833. renderSlot(s.$slots, "default", {}, () => [
  13834. createVNode(u, { color: b2.color }, null, 8, ["color"])
  13835. ])
  13836. ]),
  13837. _: 3
  13838. }, 16);
  13839. };
  13840. }
  13841. });
  13842. var qh = defineComponent({
  13843. __name: "TorusKnot",
  13844. props: {
  13845. args: { default: () => [1, 0.4, 64, 8] },
  13846. color: { default: "0xffffff" }
  13847. },
  13848. setup(b2, { expose: i }) {
  13849. const r = shallowRef();
  13850. return i({
  13851. value: r
  13852. }), (s, a) => {
  13853. const c = resolveComponent("TresTorusKnotGeometry"), u = resolveComponent("TresMeshBasicMaterial"), h2 = resolveComponent("TresMesh");
  13854. return openBlock(), createBlock(h2, mergeProps({
  13855. ref_key: "torusKnotRef",
  13856. ref: r
  13857. }, s.$attrs), {
  13858. default: withCtx(() => [
  13859. createVNode(c, { args: b2.args }, null, 8, ["args"]),
  13860. renderSlot(s.$slots, "default", {}, () => [
  13861. createVNode(u, { color: b2.color }, null, 8, ["color"])
  13862. ])
  13863. ]),
  13864. _: 3
  13865. }, 16);
  13866. };
  13867. }
  13868. });
  13869. var Qh = defineComponent({
  13870. __name: "Circle",
  13871. props: {
  13872. args: { default: () => [1, 32] },
  13873. color: { default: "0xffffff" }
  13874. },
  13875. setup(b2, { expose: i }) {
  13876. const r = shallowRef();
  13877. return i({
  13878. value: r
  13879. }), (s, a) => {
  13880. const c = resolveComponent("TresCircleGeometry"), u = resolveComponent("TresMeshBasicMaterial"), h2 = resolveComponent("TresMesh");
  13881. return openBlock(), createBlock(h2, mergeProps({
  13882. ref_key: "circleRef",
  13883. ref: r
  13884. }, s.$attrs), {
  13885. default: withCtx(() => [
  13886. createVNode(c, { args: b2.args }, null, 8, ["args"]),
  13887. renderSlot(s.$slots, "default", {}, () => [
  13888. createVNode(u, { color: b2.color }, null, 8, ["color"])
  13889. ])
  13890. ]),
  13891. _: 3
  13892. }, 16);
  13893. };
  13894. }
  13895. });
  13896. var Zh = defineComponent({
  13897. __name: "Cone",
  13898. props: {
  13899. args: { default: () => [1, 1, 12] },
  13900. color: { default: "0xffffff" }
  13901. },
  13902. setup(b2, { expose: i }) {
  13903. const r = shallowRef();
  13904. return i({
  13905. value: r
  13906. }), (s, a) => {
  13907. const c = resolveComponent("TresConeGeometry"), u = resolveComponent("TresMeshBasicMaterial"), h2 = resolveComponent("TresMesh");
  13908. return openBlock(), createBlock(h2, mergeProps({
  13909. ref_key: "coneRef",
  13910. ref: r
  13911. }, s.$attrs), {
  13912. default: withCtx(() => [
  13913. createVNode(c, { args: b2.args }, null, 8, ["args"]),
  13914. renderSlot(s.$slots, "default", {}, () => [
  13915. createVNode(u, { color: b2.color }, null, 8, ["color"])
  13916. ])
  13917. ]),
  13918. _: 3
  13919. }, 16);
  13920. };
  13921. }
  13922. });
  13923. var Wh = defineComponent({
  13924. __name: "Tube",
  13925. props: {
  13926. args: { default: () => [
  13927. new QuadraticBezierCurve3(new Vector3(-1, 0, 0), new Vector3(0, 1, 0), new Vector3(1, 0, 0)),
  13928. 20,
  13929. 0.2,
  13930. 8,
  13931. false
  13932. ] },
  13933. color: { default: "0xffffff" }
  13934. },
  13935. setup(b2, { expose: i }) {
  13936. const r = shallowRef();
  13937. return i({
  13938. value: r
  13939. }), (s, a) => {
  13940. const c = resolveComponent("TresTubeGeometry"), u = resolveComponent("TresMeshBasicMaterial"), h2 = resolveComponent("TresMesh");
  13941. return openBlock(), createBlock(h2, mergeProps({
  13942. ref_key: "tubeRef",
  13943. ref: r
  13944. }, s.$attrs), {
  13945. default: withCtx(() => [
  13946. createVNode(c, { args: b2.args }, null, 8, ["args"]),
  13947. renderSlot(s.$slots, "default", {}, () => [
  13948. createVNode(u, { color: b2.color }, null, 8, ["color"])
  13949. ])
  13950. ]),
  13951. _: 3
  13952. }, 16);
  13953. };
  13954. }
  13955. });
  13956. var Jh = defineComponent({
  13957. __name: "Ring",
  13958. props: {
  13959. args: { default: () => [0.5, 1, 32] },
  13960. color: { default: "0xffffff" }
  13961. },
  13962. setup(b2, { expose: i }) {
  13963. const r = shallowRef();
  13964. return i({
  13965. value: r
  13966. }), (s, a) => {
  13967. const c = resolveComponent("TresRingGeometry"), u = resolveComponent("TresMeshBasicMaterial"), h2 = resolveComponent("TresMesh");
  13968. return openBlock(), createBlock(h2, mergeProps({
  13969. ref_key: "ringRef",
  13970. ref: r
  13971. }, s.$attrs), {
  13972. default: withCtx(() => [
  13973. createVNode(c, { args: b2.args }, null, 8, ["args"]),
  13974. renderSlot(s.$slots, "default", {}, () => [
  13975. createVNode(u, { color: b2.color }, null, 8, ["color"])
  13976. ])
  13977. ]),
  13978. _: 3
  13979. }, 16);
  13980. };
  13981. }
  13982. });
  13983. var ed = defineComponent({
  13984. __name: "Tetrahedron",
  13985. props: {
  13986. args: { default: () => [1, 0] },
  13987. color: { default: "0xffffff" }
  13988. },
  13989. setup(b2, { expose: i }) {
  13990. const r = shallowRef();
  13991. return i({
  13992. value: r
  13993. }), (s, a) => {
  13994. const c = resolveComponent("TresTetrahedronGeometry"), u = resolveComponent("TresMeshBasicMaterial"), h2 = resolveComponent("TresMesh");
  13995. return openBlock(), createBlock(h2, mergeProps({
  13996. ref_key: "tetrahedronRef",
  13997. ref: r,
  13998. rotation: [-Math.PI / 2, 0, 0]
  13999. }, s.$attrs), {
  14000. default: withCtx(() => [
  14001. createVNode(c, { args: b2.args }, null, 8, ["args"]),
  14002. renderSlot(s.$slots, "default", {}, () => [
  14003. createVNode(u, { color: b2.color }, null, 8, ["color"])
  14004. ])
  14005. ]),
  14006. _: 3
  14007. }, 16, ["rotation"]);
  14008. };
  14009. }
  14010. });
  14011. var td = defineComponent({
  14012. __name: "Icosahedron",
  14013. props: {
  14014. args: { default: () => [1, 0] },
  14015. color: { default: "0xffffff" }
  14016. },
  14017. setup(b2, { expose: i }) {
  14018. const r = shallowRef();
  14019. return i({
  14020. value: r
  14021. }), (s, a) => {
  14022. const c = resolveComponent("TresIcosahedronGeometry"), u = resolveComponent("TresMeshBasicMaterial"), h2 = resolveComponent("TresMesh");
  14023. return openBlock(), createBlock(h2, mergeProps({
  14024. ref_key: "icosahedronRef",
  14025. ref: r
  14026. }, s.$attrs), {
  14027. default: withCtx(() => [
  14028. createVNode(c, { args: b2.args }, null, 8, ["args"]),
  14029. renderSlot(s.$slots, "default", {}, () => [
  14030. createVNode(u, { color: b2.color }, null, 8, ["color"])
  14031. ])
  14032. ]),
  14033. _: 3
  14034. }, 16);
  14035. };
  14036. }
  14037. });
  14038. var nd = defineComponent({
  14039. __name: "Octahedron",
  14040. props: {
  14041. args: { default: () => [1, 0] },
  14042. color: { default: "0xffffff" }
  14043. },
  14044. setup(b2, { expose: i }) {
  14045. const r = shallowRef();
  14046. return i({
  14047. value: r
  14048. }), (s, a) => {
  14049. const c = resolveComponent("TresOctahedronGeometry"), u = resolveComponent("TresMeshBasicMaterial"), h2 = resolveComponent("TresMesh");
  14050. return openBlock(), createBlock(h2, mergeProps({
  14051. ref_key: "octahedronRef",
  14052. ref: r
  14053. }, s.$attrs), {
  14054. default: withCtx(() => [
  14055. createVNode(c, { args: b2.args }, null, 8, ["args"]),
  14056. renderSlot(s.$slots, "default", {}, () => [
  14057. createVNode(u, { color: b2.color }, null, 8, ["color"])
  14058. ])
  14059. ]),
  14060. _: 3
  14061. }, 16);
  14062. };
  14063. }
  14064. });
  14065. var id = defineComponent({
  14066. __name: "Dodecahedron",
  14067. props: {
  14068. args: { default: () => [1, 0] },
  14069. color: { default: "0xffffff" }
  14070. },
  14071. setup(b2, { expose: i }) {
  14072. const r = shallowRef();
  14073. return i({
  14074. value: r
  14075. }), (s, a) => {
  14076. const c = resolveComponent("TresDodecahedronGeometry"), u = resolveComponent("TresMeshBasicMaterial"), h2 = resolveComponent("TresMesh");
  14077. return openBlock(), createBlock(h2, mergeProps({
  14078. ref_key: "dodecahedronRef",
  14079. ref: r
  14080. }, s.$attrs), {
  14081. default: withCtx(() => [
  14082. createVNode(c, { args: b2.args }, null, 8, ["args"]),
  14083. renderSlot(s.$slots, "default", {}, () => [
  14084. createVNode(u, { color: b2.color }, null, 8, ["color"])
  14085. ])
  14086. ]),
  14087. _: 3
  14088. }, 16);
  14089. };
  14090. }
  14091. });
  14092. var no = {
  14093. sunset: "venice/venice_sunset_4k.hdr"
  14094. };
  14095. async function Ih({
  14096. files: b2 = ["/px.png", "/nx.png", "/py.png", "/ny.png", "/pz.png", "/nz.png"],
  14097. blur: i = 0,
  14098. background: r = false,
  14099. path: s = void 0,
  14100. preset: a = void 0,
  14101. encoding: c = void 0
  14102. }) {
  14103. const { state: u } = Nn();
  14104. if (a) {
  14105. if (!(a in no))
  14106. throw new Error("Preset must be one of: " + Object.keys(no).join(", "));
  14107. b2 = no[a], s = "https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/";
  14108. }
  14109. const h2 = Array.isArray(b2), g = await Ct(
  14110. h2 ? CubeTextureLoader : oh,
  14111. h2 ? [b2] : b2,
  14112. (_) => {
  14113. s && _.setPath(s), c && (_.encoding = c);
  14114. }
  14115. ), w = h2 ? g[0] : g;
  14116. return w && (w.mapping = h2 ? CubeReflectionMapping : EquirectangularReflectionMapping, w.encoding = c ?? h2 ? sRGBEncoding : LinearEncoding), r && u.scene && (u.scene.environment = w, u.scene.background = w, i && (u.scene.backgroundBlurriness = i | 0)), w;
  14117. }
  14118. var sd = defineComponent({
  14119. name: "Environment",
  14120. props: {
  14121. background: {
  14122. type: Boolean,
  14123. default: false
  14124. },
  14125. blur: {
  14126. type: Number,
  14127. default: 0
  14128. },
  14129. files: {
  14130. type: [String, Array]
  14131. },
  14132. encoding: Object,
  14133. path: String,
  14134. preset: Object
  14135. },
  14136. async setup(b2, { expose: i }) {
  14137. let r = null;
  14138. return i({ getTexture: () => r }), r = await Ih(b2), () => {
  14139. };
  14140. }
  14141. });
  14142. export {
  14143. $h as Box,
  14144. Qh as Circle,
  14145. Zh as Cone,
  14146. id as Dodecahedron,
  14147. sd as Environment,
  14148. Gh as FBXModel,
  14149. Uh as GLTFModel,
  14150. td as Icosahedron,
  14151. nd as Octahedron,
  14152. Nh as OrbitControls,
  14153. Bh as PamCameraMouse,
  14154. Kh as Plane,
  14155. Jh as Ring,
  14156. Xh as Sphere,
  14157. ed as Tetrahedron,
  14158. Hh as Text3D,
  14159. Yh as Torus,
  14160. qh as TorusKnot,
  14161. Fh as TransformControls,
  14162. Wh as Tube,
  14163. zh as useAnimations,
  14164. Ih as useEnvironment,
  14165. Rh as useFBX,
  14166. Lh as useGLTF,
  14167. Ph as usePamCameraMouse,
  14168. jh as useTweakPane
  14169. };
  14170. /*! Bundled license information:
  14171. @tresjs/cientos/dist/trescientos.js:
  14172. (*! Tweakpane 3.1.4 (c) 2016 cocopon, licensed under the MIT license. *)
  14173. */
  14174. //# sourceMappingURL=@tresjs_cientos.js.map