| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664 |
- function eie(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(t,i,a.get?a:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const s of a.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Ev=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var OA={exports:{}},px={};var EF;function tie(){if(EF)return px;EF=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,a){var s=null;if(a!==void 0&&(s=""+a),i.key!==void 0&&(s=""+i.key),"key"in i){a={};for(var l in i)l!=="key"&&(a[l]=i[l])}else a=i;return i=a.ref,{$$typeof:t,type:r,key:s,ref:i!==void 0?i:null,props:a}}return px.Fragment=e,px.jsx=n,px.jsxs=n,px}var AF;function nie(){return AF||(AF=1,OA.exports=tie()),OA.exports}var o=nie(),LA={exports:{}},rn={};var TF;function rie(){if(TF)return rn;TF=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),s=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),g=Symbol.iterator;function p(z){return z===null||typeof z!="object"?null:(z=g&&z[g]||z["@@iterator"],typeof z=="function"?z:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,y={};function b(z,V,X){this.props=z,this.context=V,this.refs=y,this.updater=X||x}b.prototype.isReactComponent={},b.prototype.setState=function(z,V){if(typeof z!="object"&&typeof z!="function"&&z!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,z,V,"setState")},b.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function E(){}E.prototype=b.prototype;function w(z,V,X){this.props=z,this.context=V,this.refs=y,this.updater=X||x}var A=w.prototype=new E;A.constructor=w,v(A,b.prototype),A.isPureReactComponent=!0;var T=Array.isArray;function C(){}var N={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function k(z,V,X){var te=X.ref;return{$$typeof:t,type:z,key:V,ref:te!==void 0?te:null,props:X}}function j(z,V){return k(z.type,V,z.props)}function B(z){return typeof z=="object"&&z!==null&&z.$$typeof===t}function L(z){var V={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(X){return V[X]})}var K=/\/+/g;function R(z,V){return typeof z=="object"&&z!==null&&z.key!=null?L(""+z.key):V.toString(36)}function q(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(C,C):(z.status="pending",z.then(function(V){z.status==="pending"&&(z.status="fulfilled",z.value=V)},function(V){z.status==="pending"&&(z.status="rejected",z.reason=V)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function W(z,V,X,te,ie){var le=typeof z;(le==="undefined"||le==="boolean")&&(z=null);var ge=!1;if(z===null)ge=!0;else switch(le){case"bigint":case"string":case"number":ge=!0;break;case"object":switch(z.$$typeof){case t:case e:ge=!0;break;case d:return ge=z._init,W(ge(z._payload),V,X,te,ie)}}if(ge)return ie=ie(z),ge=te===""?"."+R(z,0):te,T(ie)?(X="",ge!=null&&(X=ge.replace(K,"$&/")+"/"),W(ie,V,X,"",function(de){return de})):ie!=null&&(B(ie)&&(ie=j(ie,X+(ie.key==null||z&&z.key===ie.key?"":(""+ie.key).replace(K,"$&/")+"/")+ge)),V.push(ie)),1;ge=0;var Ee=te===""?".":te+":";if(T(z))for(var pe=0;pe<z.length;pe++)te=z[pe],le=Ee+R(te,pe),ge+=W(te,V,X,le,ie);else if(pe=p(z),typeof pe=="function")for(z=pe.call(z),pe=0;!(te=z.next()).done;)te=te.value,le=Ee+R(te,pe++),ge+=W(te,V,X,le,ie);else if(le==="object"){if(typeof z.then=="function")return W(q(z),V,X,te,ie);throw V=String(z),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return ge}function $(z,V,X){if(z==null)return z;var te=[],ie=0;return W(z,te,"","",function(le){return V.call(X,le,ie++)}),te}function J(z){if(z._status===-1){var V=z._result;V=V(),V.then(function(X){(z._status===0||z._status===-1)&&(z._status=1,z._result=X)},function(X){(z._status===0||z._status===-1)&&(z._status=2,z._result=X)}),z._status===-1&&(z._status=0,z._result=V)}if(z._status===1)return z._result.default;throw z._result}var ee=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},Q={map:$,forEach:function(z,V,X){$(z,function(){V.apply(this,arguments)},X)},count:function(z){var V=0;return $(z,function(){V++}),V},toArray:function(z){return $(z,function(V){return V})||[]},only:function(z){if(!B(z))throw Error("React.Children.only expected to receive a single React element child.");return z}};return rn.Activity=f,rn.Children=Q,rn.Component=b,rn.Fragment=n,rn.Profiler=i,rn.PureComponent=w,rn.StrictMode=r,rn.Suspense=c,rn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,rn.__COMPILER_RUNTIME={__proto__:null,c:function(z){return N.H.useMemoCache(z)}},rn.cache=function(z){return function(){return z.apply(null,arguments)}},rn.cacheSignal=function(){return null},rn.cloneElement=function(z,V,X){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var te=v({},z.props),ie=z.key;if(V!=null)for(le in V.key!==void 0&&(ie=""+V.key),V)!O.call(V,le)||le==="key"||le==="__self"||le==="__source"||le==="ref"&&V.ref===void 0||(te[le]=V[le]);var le=arguments.length-2;if(le===1)te.children=X;else if(1<le){for(var ge=Array(le),Ee=0;Ee<le;Ee++)ge[Ee]=arguments[Ee+2];te.children=ge}return k(z.type,ie,te)},rn.createContext=function(z){return z={$$typeof:s,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null},z.Provider=z,z.Consumer={$$typeof:a,_context:z},z},rn.createElement=function(z,V,X){var te,ie={},le=null;if(V!=null)for(te in V.key!==void 0&&(le=""+V.key),V)O.call(V,te)&&te!=="key"&&te!=="__self"&&te!=="__source"&&(ie[te]=V[te]);var ge=arguments.length-2;if(ge===1)ie.children=X;else if(1<ge){for(var Ee=Array(ge),pe=0;pe<ge;pe++)Ee[pe]=arguments[pe+2];ie.children=Ee}if(z&&z.defaultProps)for(te in ge=z.defaultProps,ge)ie[te]===void 0&&(ie[te]=ge[te]);return k(z,le,ie)},rn.createRef=function(){return{current:null}},rn.forwardRef=function(z){return{$$typeof:l,render:z}},rn.isValidElement=B,rn.lazy=function(z){return{$$typeof:d,_payload:{_status:-1,_result:z},_init:J}},rn.memo=function(z,V){return{$$typeof:u,type:z,compare:V===void 0?null:V}},rn.startTransition=function(z){var V=N.T,X={};N.T=X;try{var te=z(),ie=N.S;ie!==null&&ie(X,te),typeof te=="object"&&te!==null&&typeof te.then=="function"&&te.then(C,ee)}catch(le){ee(le)}finally{V!==null&&X.types!==null&&(V.types=X.types),N.T=V}},rn.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},rn.use=function(z){return N.H.use(z)},rn.useActionState=function(z,V,X){return N.H.useActionState(z,V,X)},rn.useCallback=function(z,V){return N.H.useCallback(z,V)},rn.useContext=function(z){return N.H.useContext(z)},rn.useDebugValue=function(){},rn.useDeferredValue=function(z,V){return N.H.useDeferredValue(z,V)},rn.useEffect=function(z,V){return N.H.useEffect(z,V)},rn.useEffectEvent=function(z){return N.H.useEffectEvent(z)},rn.useId=function(){return N.H.useId()},rn.useImperativeHandle=function(z,V,X){return N.H.useImperativeHandle(z,V,X)},rn.useInsertionEffect=function(z,V){return N.H.useInsertionEffect(z,V)},rn.useLayoutEffect=function(z,V){return N.H.useLayoutEffect(z,V)},rn.useMemo=function(z,V){return N.H.useMemo(z,V)},rn.useOptimistic=function(z,V){return N.H.useOptimistic(z,V)},rn.useReducer=function(z,V,X){return N.H.useReducer(z,V,X)},rn.useRef=function(z){return N.H.useRef(z)},rn.useState=function(z){return N.H.useState(z)},rn.useSyncExternalStore=function(z,V,X){return N.H.useSyncExternalStore(z,V,X)},rn.useTransition=function(){return N.H.useTransition()},rn.version="19.2.0",rn}var NF;function tg(){return NF||(NF=1,LA.exports=rie()),LA.exports}var S=tg();const Cr=yo(S),iie=eie({__proto__:null,default:Cr},[S]);var IA={exports:{}},gx={},FA={exports:{}},UA={};var CF;function aie(){return CF||(CF=1,(function(t){function e(W,$){var J=W.length;W.push($);e:for(;0<J;){var ee=J-1>>>1,Q=W[ee];if(0<i(Q,$))W[ee]=$,W[J]=Q,J=ee;else break e}}function n(W){return W.length===0?null:W[0]}function r(W){if(W.length===0)return null;var $=W[0],J=W.pop();if(J!==$){W[0]=J;e:for(var ee=0,Q=W.length,z=Q>>>1;ee<z;){var V=2*(ee+1)-1,X=W[V],te=V+1,ie=W[te];if(0>i(X,J))te<Q&&0>i(ie,X)?(W[ee]=ie,W[te]=J,ee=te):(W[ee]=X,W[V]=J,ee=V);else if(te<Q&&0>i(ie,J))W[ee]=ie,W[te]=J,ee=te;else break e}}return $}function i(W,$){var J=W.sortIndex-$.sortIndex;return J!==0?J:W.id-$.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var s=Date,l=s.now();t.unstable_now=function(){return s.now()-l}}var c=[],u=[],d=1,f=null,g=3,p=!1,x=!1,v=!1,y=!1,b=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function A(W){for(var $=n(u);$!==null;){if($.callback===null)r(u);else if($.startTime<=W)r(u),$.sortIndex=$.expirationTime,e(c,$);else break;$=n(u)}}function T(W){if(v=!1,A(W),!x)if(n(c)!==null)x=!0,C||(C=!0,L());else{var $=n(u);$!==null&&q(T,$.startTime-W)}}var C=!1,N=-1,O=5,k=-1;function j(){return y?!0:!(t.unstable_now()-k<O)}function B(){if(y=!1,C){var W=t.unstable_now();k=W;var $=!0;try{e:{x=!1,v&&(v=!1,E(N),N=-1),p=!0;var J=g;try{t:{for(A(W),f=n(c);f!==null&&!(f.expirationTime>W&&j());){var ee=f.callback;if(typeof ee=="function"){f.callback=null,g=f.priorityLevel;var Q=ee(f.expirationTime<=W);if(W=t.unstable_now(),typeof Q=="function"){f.callback=Q,A(W),$=!0;break t}f===n(c)&&r(c),A(W)}else r(c);f=n(c)}if(f!==null)$=!0;else{var z=n(u);z!==null&&q(T,z.startTime-W),$=!1}}break e}finally{f=null,g=J,p=!1}$=void 0}}finally{$?L():C=!1}}}var L;if(typeof w=="function")L=function(){w(B)};else if(typeof MessageChannel<"u"){var K=new MessageChannel,R=K.port2;K.port1.onmessage=B,L=function(){R.postMessage(null)}}else L=function(){b(B,0)};function q(W,$){N=b(function(){W(t.unstable_now())},$)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(W){W.callback=null},t.unstable_forceFrameRate=function(W){0>W||125<W?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<W?Math.floor(1e3/W):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_next=function(W){switch(g){case 1:case 2:case 3:var $=3;break;default:$=g}var J=g;g=$;try{return W()}finally{g=J}},t.unstable_requestPaint=function(){y=!0},t.unstable_runWithPriority=function(W,$){switch(W){case 1:case 2:case 3:case 4:case 5:break;default:W=3}var J=g;g=W;try{return $()}finally{g=J}},t.unstable_scheduleCallback=function(W,$,J){var ee=t.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?ee+J:ee):J=ee,W){case 1:var Q=-1;break;case 2:Q=250;break;case 5:Q=1073741823;break;case 4:Q=1e4;break;default:Q=5e3}return Q=J+Q,W={id:d++,callback:$,priorityLevel:W,startTime:J,expirationTime:Q,sortIndex:-1},J>ee?(W.sortIndex=J,e(u,W),n(c)===null&&W===n(u)&&(v?(E(N),N=-1):v=!0,q(T,J-ee))):(W.sortIndex=Q,e(c,W),x||p||(x=!0,C||(C=!0,L()))),W},t.unstable_shouldYield=j,t.unstable_wrapCallback=function(W){var $=g;return function(){var J=g;g=$;try{return W.apply(this,arguments)}finally{g=J}}}})(UA)),UA}var kF;function sie(){return kF||(kF=1,FA.exports=aie()),FA.exports}var zA={exports:{}},da={};var PF;function oie(){if(PF)return da;PF=1;var t=tg();function e(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function a(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return da.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,da.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return a(c,u,null,d)},da.flushSync=function(c){var u=s.T,d=r.p;try{if(s.T=null,r.p=2,c)return c()}finally{s.T=u,r.p=d,r.d.f()}},da.preconnect=function(c,u){typeof c=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,r.d.C(c,u))},da.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},da.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin),g=typeof u.integrity=="string"?u.integrity:void 0,p=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:g,fetchPriority:p}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:g,fetchPriority:p,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},da.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=l(u.as,u.crossOrigin);r.d.M(c,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&r.d.M(c)},da.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},da.preloadModule=function(c,u){if(typeof c=="string")if(u){var d=l(u.as,u.crossOrigin);r.d.m(c,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else r.d.m(c)},da.requestFormReset=function(c){r.d.r(c)},da.unstable_batchedUpdates=function(c,u){return c(u)},da.useFormState=function(c,u,d){return s.H.useFormState(c,u,d)},da.useFormStatus=function(){return s.H.useHostTransitionStatus()},da.version="19.2.0",da}var jF;function JG(){if(jF)return zA.exports;jF=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),zA.exports=oie(),zA.exports}var RF;function lie(){if(RF)return gx;RF=1;var t=sie(),e=tg(),n=JG();function r(h){var m="https://react.dev/errors/"+h;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)m+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+h+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(h){return!(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)}function a(h){var m=h,_=h;if(h.alternate)for(;m.return;)m=m.return;else{h=m;do m=h,(m.flags&4098)!==0&&(_=m.return),h=m.return;while(h)}return m.tag===3?_:null}function s(h){if(h.tag===13){var m=h.memoizedState;if(m===null&&(h=h.alternate,h!==null&&(m=h.memoizedState)),m!==null)return m.dehydrated}return null}function l(h){if(h.tag===31){var m=h.memoizedState;if(m===null&&(h=h.alternate,h!==null&&(m=h.memoizedState)),m!==null)return m.dehydrated}return null}function c(h){if(a(h)!==h)throw Error(r(188))}function u(h){var m=h.alternate;if(!m){if(m=a(h),m===null)throw Error(r(188));return m!==h?null:h}for(var _=h,M=m;;){var P=_.return;if(P===null)break;var D=P.alternate;if(D===null){if(M=P.return,M!==null){_=M;continue}break}if(P.child===D.child){for(D=P.child;D;){if(D===_)return c(P),h;if(D===M)return c(P),m;D=D.sibling}throw Error(r(188))}if(_.return!==M.return)_=P,M=D;else{for(var Y=!1,ce=P.child;ce;){if(ce===_){Y=!0,_=P,M=D;break}if(ce===M){Y=!0,M=P,_=D;break}ce=ce.sibling}if(!Y){for(ce=D.child;ce;){if(ce===_){Y=!0,_=D,M=P;break}if(ce===M){Y=!0,M=D,_=P;break}ce=ce.sibling}if(!Y)throw Error(r(189))}}if(_.alternate!==M)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:m}function d(h){var m=h.tag;if(m===5||m===26||m===27||m===6)return h;for(h=h.child;h!==null;){if(m=d(h),m!==null)return m;h=h.sibling}return null}var f=Object.assign,g=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),w=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),j=Symbol.for("react.memo_cache_sentinel"),B=Symbol.iterator;function L(h){return h===null||typeof h!="object"?null:(h=B&&h[B]||h["@@iterator"],typeof h=="function"?h:null)}var K=Symbol.for("react.client.reference");function R(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===K?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case v:return"Fragment";case b:return"Profiler";case y:return"StrictMode";case T:return"Suspense";case C:return"SuspenseList";case k:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case w:return h.displayName||"Context";case E:return(h._context.displayName||"Context")+".Consumer";case A:var m=h.render;return h=h.displayName,h||(h=m.displayName||m.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case N:return m=h.displayName||null,m!==null?m:R(h.type)||"Memo";case O:m=h._payload,h=h._init;try{return R(h(m))}catch{}}return null}var q=Array.isArray,W=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},ee=[],Q=-1;function z(h){return{current:h}}function V(h){0>Q||(h.current=ee[Q],ee[Q]=null,Q--)}function X(h,m){Q++,ee[Q]=h.current,h.current=m}var te=z(null),ie=z(null),le=z(null),ge=z(null);function Ee(h,m){switch(X(le,m),X(ie,h),X(te,null),m.nodeType){case 9:case 11:h=(h=m.documentElement)&&(h=h.namespaceURI)?K5(h):0;break;default:if(h=m.tagName,m=m.namespaceURI)m=K5(m),h=X5(m,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}V(te),X(te,h)}function pe(){V(te),V(ie),V(le)}function de(h){h.memoizedState!==null&&X(ge,h);var m=te.current,_=X5(m,h.type);m!==_&&(X(ie,h),X(te,_))}function Re(h){ie.current===h&&(V(te),V(ie)),ge.current===h&&(V(ge),dx._currentValue=J)}var fe,Fe;function U(h){if(fe===void 0)try{throw Error()}catch(_){var m=_.stack.trim().match(/\n( *(at )?)/);fe=m&&m[1]||"",Fe=-1<_.stack.indexOf(`
- at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+fe+h+Fe}var H=!1;function re(h,m){if(!h||H)return"";H=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var M={DetermineComponentFrameRoot:function(){try{if(m){var mt=function(){throw Error()};if(Object.defineProperty(mt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(mt,[])}catch(ot){var it=ot}Reflect.construct(h,[],mt)}else{try{mt.call()}catch(ot){it=ot}h.call(mt.prototype)}}else{try{throw Error()}catch(ot){it=ot}(mt=h())&&typeof mt.catch=="function"&&mt.catch(function(){})}}catch(ot){if(ot&&it&&typeof ot.stack=="string")return[ot.stack,it.stack]}return[null,null]}};M.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(M.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(M.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var D=M.DetermineComponentFrameRoot(),Y=D[0],ce=D[1];if(Y&&ce){var Ce=Y.split(`
- `),tt=ce.split(`
- `);for(P=M=0;M<Ce.length&&!Ce[M].includes("DetermineComponentFrameRoot");)M++;for(;P<tt.length&&!tt[P].includes("DetermineComponentFrameRoot");)P++;if(M===Ce.length||P===tt.length)for(M=Ce.length-1,P=tt.length-1;1<=M&&0<=P&&Ce[M]!==tt[P];)P--;for(;1<=M&&0<=P;M--,P--)if(Ce[M]!==tt[P]){if(M!==1||P!==1)do if(M--,P--,0>P||Ce[M]!==tt[P]){var dt=`
- `+Ce[M].replace(" at new "," at ");return h.displayName&&dt.includes("<anonymous>")&&(dt=dt.replace("<anonymous>",h.displayName)),dt}while(1<=M&&0<=P);break}}}finally{H=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?U(_):""}function G(h,m){switch(h.tag){case 26:case 27:case 5:return U(h.type);case 16:return U("Lazy");case 13:return h.child!==m&&m!==null?U("Suspense Fallback"):U("Suspense");case 19:return U("SuspenseList");case 0:case 15:return re(h.type,!1);case 11:return re(h.type.render,!1);case 1:return re(h.type,!0);case 31:return U("Activity");default:return""}}function Z(h){try{var m="",_=null;do m+=G(h,_),_=h,h=h.return;while(h);return m}catch(M){return`
- Error generating stack: `+M.message+`
- `+M.stack}}var oe=Object.prototype.hasOwnProperty,be=t.unstable_scheduleCallback,Te=t.unstable_cancelCallback,Me=t.unstable_shouldYield,F=t.unstable_requestPaint,I=t.unstable_now,ne=t.unstable_getCurrentPriorityLevel,ve=t.unstable_ImmediatePriority,Se=t.unstable_UserBlockingPriority,ye=t.unstable_NormalPriority,Ke=t.unstable_LowPriority,We=t.unstable_IdlePriority,qe=t.log,ut=t.unstable_setDisableYieldValue,ue=null,se=null;function Ve(h){if(typeof qe=="function"&&ut(h),se&&typeof se.setStrictMode=="function")try{se.setStrictMode(ue,h)}catch{}}var Be=Math.clz32?Math.clz32:me,Ze=Math.log,ht=Math.LN2;function me(h){return h>>>=0,h===0?32:31-(Ze(h)/ht|0)|0}var nt=256,xe=262144,He=4194304;function Pe(h){var m=h&42;if(m!==0)return m;switch(h&-h){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return h&261888;case 262144:case 524288:case 1048576:case 2097152:return h&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return h&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return h}}function we(h,m,_){var M=h.pendingLanes;if(M===0)return 0;var P=0,D=h.suspendedLanes,Y=h.pingedLanes;h=h.warmLanes;var ce=M&134217727;return ce!==0?(M=ce&~D,M!==0?P=Pe(M):(Y&=ce,Y!==0?P=Pe(Y):_||(_=ce&~h,_!==0&&(P=Pe(_))))):(ce=M&~D,ce!==0?P=Pe(ce):Y!==0?P=Pe(Y):_||(_=M&~h,_!==0&&(P=Pe(_)))),P===0?0:m!==0&&m!==P&&(m&D)===0&&(D=P&-P,_=m&-m,D>=_||D===32&&(_&4194048)!==0)?m:P}function Ae(h,m){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&m)===0}function lt(h,m){switch(h){case 1:case 2:case 4:case 8:case 64:return m+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return m+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function _t(){var h=He;return He<<=1,(He&62914560)===0&&(He=4194304),h}function Xe(h){for(var m=[],_=0;31>_;_++)m.push(h);return m}function Ut(h,m){h.pendingLanes|=m,m!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Ct(h,m,_,M,P,D){var Y=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var ce=h.entanglements,Ce=h.expirationTimes,tt=h.hiddenUpdates;for(_=Y&~_;0<_;){var dt=31-Be(_),mt=1<<dt;ce[dt]=0,Ce[dt]=-1;var it=tt[dt];if(it!==null)for(tt[dt]=null,dt=0;dt<it.length;dt++){var ot=it[dt];ot!==null&&(ot.lane&=-536870913)}_&=~mt}M!==0&&$t(h,M,0),D!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=D&~(Y&~m))}function $t(h,m,_){h.pendingLanes|=m,h.suspendedLanes&=~m;var M=31-Be(m);h.entangledLanes|=m,h.entanglements[M]=h.entanglements[M]|1073741824|_&261930}function gn(h,m){var _=h.entangledLanes|=m;for(h=h.entanglements;_;){var M=31-Be(_),P=1<<M;P&m|h[M]&m&&(h[M]|=m),_&=~P}}function Fn(h,m){var _=m&-m;return _=(_&42)!==0?1:It(_),(_&(h.suspendedLanes|m))!==0?0:_}function It(h){switch(h){case 2:h=1;break;case 8:h=4;break;case 32:h=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:h=128;break;case 268435456:h=134217728;break;default:h=0}return h}function Yt(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function Jn(){var h=$.p;return h!==0?h:(h=window.event,h===void 0?32:bF(h.type))}function er(h,m){var _=$.p;try{return $.p=h,m()}finally{$.p=_}}var Hn=Math.random().toString(36).slice(2),Un="__reactFiber$"+Hn,jn="__reactProps$"+Hn,sn="__reactContainer$"+Hn,Le="__reactEvents$"+Hn,he="__reactListeners$"+Hn,ze="__reactHandles$"+Hn,et="__reactResources$"+Hn,st="__reactMarker$"+Hn;function rt(h){delete h[Un],delete h[jn],delete h[Le],delete h[he],delete h[ze]}function yt(h){var m=h[Un];if(m)return m;for(var _=h.parentNode;_;){if(m=_[sn]||_[Un]){if(_=m.alternate,m.child!==null||_!==null&&_.child!==null)for(h=nF(h);h!==null;){if(_=h[Un])return _;h=nF(h)}return m}h=_,_=h.parentNode}return null}function ae(h){if(h=h[Un]||h[sn]){var m=h.tag;if(m===5||m===6||m===13||m===31||m===26||m===27||m===3)return h}return null}function Ne(h){var m=h.tag;if(m===5||m===26||m===27||m===6)return h.stateNode;throw Error(r(33))}function Ue(h){var m=h[et];return m||(m=h[et]={hoistableStyles:new Map,hoistableScripts:new Map}),m}function Ie(h){h[st]=!0}var je=new Set,ct={};function xt(h,m){Tt(h,m),Tt(h+"Capture",m)}function Tt(h,m){for(ct[h]=m,h=0;h<m.length;h++)je.add(m[h])}var Et=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Ft={},Pt={};function wt(h){return oe.call(Pt,h)?!0:oe.call(Ft,h)?!1:Et.test(h)?Pt[h]=!0:(Ft[h]=!0,!1)}function Jt(h,m,_){if(wt(m))if(_===null)h.removeAttribute(m);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(m);return;case"boolean":var M=m.toLowerCase().slice(0,5);if(M!=="data-"&&M!=="aria-"){h.removeAttribute(m);return}}h.setAttribute(m,""+_)}}function Ht(h,m,_){if(_===null)h.removeAttribute(m);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(m);return}h.setAttribute(m,""+_)}}function cn(h,m,_,M){if(M===null)h.removeAttribute(_);else{switch(typeof M){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(m,_,""+M)}}function bn(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function Mn(h){var m=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(m==="checkbox"||m==="radio")}function Bt(h,m,_){var M=Object.getOwnPropertyDescriptor(h.constructor.prototype,m);if(!h.hasOwnProperty(m)&&typeof M<"u"&&typeof M.get=="function"&&typeof M.set=="function"){var P=M.get,D=M.set;return Object.defineProperty(h,m,{configurable:!0,get:function(){return P.call(this)},set:function(Y){_=""+Y,D.call(this,Y)}}),Object.defineProperty(h,m,{enumerable:M.enumerable}),{getValue:function(){return _},setValue:function(Y){_=""+Y},stopTracking:function(){h._valueTracker=null,delete h[m]}}}}function nn(h){if(!h._valueTracker){var m=Mn(h)?"checked":"value";h._valueTracker=Bt(h,m,""+h[m])}}function an(h){if(!h)return!1;var m=h._valueTracker;if(!m)return!0;var _=m.getValue(),M="";return h&&(M=Mn(h)?h.checked?"true":"false":h.value),h=M,h!==_?(m.setValue(h),!0):!1}function Ur(h){if(h=h||(typeof document<"u"?document:void 0),typeof h>"u")return null;try{return h.activeElement||h.body}catch{return h.body}}var qr=/[\n"\\]/g;function $n(h){return h.replace(qr,function(m){return"\\"+m.charCodeAt(0).toString(16)+" "})}function wo(h,m,_,M,P,D,Y,ce){h.name="",Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"?h.type=Y:h.removeAttribute("type"),m!=null?Y==="number"?(m===0&&h.value===""||h.value!=m)&&(h.value=""+bn(m)):h.value!==""+bn(m)&&(h.value=""+bn(m)):Y!=="submit"&&Y!=="reset"||h.removeAttribute("value"),m!=null?Pi(h,Y,bn(m)):_!=null?Pi(h,Y,bn(_)):M!=null&&h.removeAttribute("value"),P==null&&D!=null&&(h.defaultChecked=!!D),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),ce!=null&&typeof ce!="function"&&typeof ce!="symbol"&&typeof ce!="boolean"?h.name=""+bn(ce):h.removeAttribute("name")}function Wn(h,m,_,M,P,D,Y,ce){if(D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"&&(h.type=D),m!=null||_!=null){if(!(D!=="submit"&&D!=="reset"||m!=null)){nn(h);return}_=_!=null?""+bn(_):"",m=m!=null?""+bn(m):_,ce||m===h.value||(h.value=m),h.defaultValue=m}M=M??P,M=typeof M!="function"&&typeof M!="symbol"&&!!M,h.checked=ce?h.checked:!!M,h.defaultChecked=!!M,Y!=null&&typeof Y!="function"&&typeof Y!="symbol"&&typeof Y!="boolean"&&(h.name=Y),nn(h)}function Pi(h,m,_){m==="number"&&Ur(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function pi(h,m,_,M){if(h=h.options,m){m={};for(var P=0;P<_.length;P++)m["$"+_[P]]=!0;for(_=0;_<h.length;_++)P=m.hasOwnProperty("$"+h[_].value),h[_].selected!==P&&(h[_].selected=P),P&&M&&(h[_].defaultSelected=!0)}else{for(_=""+bn(_),m=null,P=0;P<h.length;P++){if(h[P].value===_){h[P].selected=!0,M&&(h[P].defaultSelected=!0);return}m!==null||h[P].disabled||(m=h[P])}m!==null&&(m.selected=!0)}}function ji(h,m,_){if(m!=null&&(m=""+bn(m),m!==h.value&&(h.value=m),_==null)){h.defaultValue!==m&&(h.defaultValue=m);return}h.defaultValue=_!=null?""+bn(_):""}function qi(h,m,_,M){if(m==null){if(M!=null){if(_!=null)throw Error(r(92));if(q(M)){if(1<M.length)throw Error(r(93));M=M[0]}_=M}_==null&&(_=""),m=_}_=bn(m),h.defaultValue=_,M=h.textContent,M===_&&M!==""&&M!==null&&(h.value=M),nn(h)}function Zo(h,m){if(m){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=m;return}}h.textContent=m}var Il=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function GL(h,m,_){var M=m.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?M?h.setProperty(m,""):m==="float"?h.cssFloat="":h[m]="":M?h.setProperty(m,_):typeof _!="number"||_===0||Il.has(m)?m==="float"?h.cssFloat=_:h[m]=(""+_).trim():h[m]=_+"px"}function WL(h,m,_){if(m!=null&&typeof m!="object")throw Error(r(62));if(h=h.style,_!=null){for(var M in _)!_.hasOwnProperty(M)||m!=null&&m.hasOwnProperty(M)||(M.indexOf("--")===0?h.setProperty(M,""):M==="float"?h.cssFloat="":h[M]="");for(var P in m)M=m[P],m.hasOwnProperty(P)&&_[P]!==M&&GL(h,P,M)}else for(var D in m)m.hasOwnProperty(D)&&GL(h,D,m[D])}function PE(h){if(h.indexOf("-")===-1)return!1;switch(h){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Yte=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Zte=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function gy(h){return Zte.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function Fl(){}var jE=null;function RE(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var Pf=null,jf=null;function qL(h){var m=ae(h);if(m&&(h=m.stateNode)){var _=h[jn]||null;e:switch(h=m.stateNode,m.type){case"input":if(wo(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),m=_.name,_.type==="radio"&&m!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+$n(""+m)+'"][type="radio"]'),m=0;m<_.length;m++){var M=_[m];if(M!==h&&M.form===h.form){var P=M[jn]||null;if(!P)throw Error(r(90));wo(M,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(m=0;m<_.length;m++)M=_[m],M.form===h.form&&an(M)}break e;case"textarea":ji(h,_.value,_.defaultValue);break e;case"select":m=_.value,m!=null&&pi(h,!!_.multiple,m,!1)}}}var DE=!1;function KL(h,m,_){if(DE)return h(m,_);DE=!0;try{var M=h(m);return M}finally{if(DE=!1,(Pf!==null||jf!==null)&&(rv(),Pf&&(m=Pf,h=jf,jf=Pf=null,qL(m),h)))for(m=0;m<h.length;m++)qL(h[m])}}function Ng(h,m){var _=h.stateNode;if(_===null)return null;var M=_[jn]||null;if(M===null)return null;_=M[m];e:switch(m){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(M=!M.disabled)||(h=h.type,M=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!M;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,m,typeof _));return _}var Ul=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),OE=!1;if(Ul)try{var Cg={};Object.defineProperty(Cg,"passive",{get:function(){OE=!0}}),window.addEventListener("test",Cg,Cg),window.removeEventListener("test",Cg,Cg)}catch{OE=!1}var nu=null,LE=null,xy=null;function XL(){if(xy)return xy;var h,m=LE,_=m.length,M,P="value"in nu?nu.value:nu.textContent,D=P.length;for(h=0;h<_&&m[h]===P[h];h++);var Y=_-h;for(M=1;M<=Y&&m[_-M]===P[D-M];M++);return xy=P.slice(h,1<M?1-M:void 0)}function by(h){var m=h.keyCode;return"charCode"in h?(h=h.charCode,h===0&&m===13&&(h=13)):h=m,h===10&&(h=13),32<=h||h===13?h:0}function yy(){return!0}function YL(){return!1}function Ha(h){function m(_,M,P,D,Y){this._reactName=_,this._targetInst=P,this.type=M,this.nativeEvent=D,this.target=Y,this.currentTarget=null;for(var ce in h)h.hasOwnProperty(ce)&&(_=h[ce],this[ce]=_?_(D):D[ce]);return this.isDefaultPrevented=(D.defaultPrevented!=null?D.defaultPrevented:D.returnValue===!1)?yy:YL,this.isPropagationStopped=YL,this}return f(m.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=yy)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=yy)},persist:function(){},isPersistent:yy}),m}var Fd={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},vy=Ha(Fd),kg=f({},Fd,{view:0,detail:0}),Qte=Ha(kg),IE,FE,Pg,_y=f({},kg,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:zE,button:0,buttons:0,relatedTarget:function(h){return h.relatedTarget===void 0?h.fromElement===h.srcElement?h.toElement:h.fromElement:h.relatedTarget},movementX:function(h){return"movementX"in h?h.movementX:(h!==Pg&&(Pg&&h.type==="mousemove"?(IE=h.screenX-Pg.screenX,FE=h.screenY-Pg.screenY):FE=IE=0,Pg=h),IE)},movementY:function(h){return"movementY"in h?h.movementY:FE}}),ZL=Ha(_y),Jte=f({},_y,{dataTransfer:0}),ene=Ha(Jte),tne=f({},kg,{relatedTarget:0}),UE=Ha(tne),nne=f({},Fd,{animationName:0,elapsedTime:0,pseudoElement:0}),rne=Ha(nne),ine=f({},Fd,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),ane=Ha(ine),sne=f({},Fd,{data:0}),QL=Ha(sne),one={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},lne={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},cne={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function une(h){var m=this.nativeEvent;return m.getModifierState?m.getModifierState(h):(h=cne[h])?!!m[h]:!1}function zE(){return une}var dne=f({},kg,{key:function(h){if(h.key){var m=one[h.key]||h.key;if(m!=="Unidentified")return m}return h.type==="keypress"?(h=by(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?lne[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:zE,charCode:function(h){return h.type==="keypress"?by(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?by(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),hne=Ha(dne),fne=f({},_y,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),JL=Ha(fne),mne=f({},kg,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:zE}),pne=Ha(mne),gne=f({},Fd,{propertyName:0,elapsedTime:0,pseudoElement:0}),xne=Ha(gne),bne=f({},_y,{deltaX:function(h){return"deltaX"in h?h.deltaX:"wheelDeltaX"in h?-h.wheelDeltaX:0},deltaY:function(h){return"deltaY"in h?h.deltaY:"wheelDeltaY"in h?-h.wheelDeltaY:"wheelDelta"in h?-h.wheelDelta:0},deltaZ:0,deltaMode:0}),yne=Ha(bne),vne=f({},Fd,{newState:0,oldState:0}),_ne=Ha(vne),wne=[9,13,27,32],BE=Ul&&"CompositionEvent"in window,jg=null;Ul&&"documentMode"in document&&(jg=document.documentMode);var Sne=Ul&&"TextEvent"in window&&!jg,e4=Ul&&(!BE||jg&&8<jg&&11>=jg),t4=" ",n4=!1;function r4(h,m){switch(h){case"keyup":return wne.indexOf(m.keyCode)!==-1;case"keydown":return m.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function i4(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var Rf=!1;function Mne(h,m){switch(h){case"compositionend":return i4(m);case"keypress":return m.which!==32?null:(n4=!0,t4);case"textInput":return h=m.data,h===t4&&n4?null:h;default:return null}}function Ene(h,m){if(Rf)return h==="compositionend"||!BE&&r4(h,m)?(h=XL(),xy=LE=nu=null,Rf=!1,h):null;switch(h){case"paste":return null;case"keypress":if(!(m.ctrlKey||m.altKey||m.metaKey)||m.ctrlKey&&m.altKey){if(m.char&&1<m.char.length)return m.char;if(m.which)return String.fromCharCode(m.which)}return null;case"compositionend":return e4&&m.locale!=="ko"?null:m.data;default:return null}}var Ane={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function a4(h){var m=h&&h.nodeName&&h.nodeName.toLowerCase();return m==="input"?!!Ane[h.type]:m==="textarea"}function s4(h,m,_,M){Pf?jf?jf.push(M):jf=[M]:Pf=M,m=uv(m,"onChange"),0<m.length&&(_=new vy("onChange","change",null,_,M),h.push({event:_,listeners:m}))}var Rg=null,Dg=null;function Tne(h){H5(h,0)}function wy(h){var m=Ne(h);if(an(m))return h}function o4(h,m){if(h==="change")return m}var l4=!1;if(Ul){var HE;if(Ul){var $E="oninput"in document;if(!$E){var c4=document.createElement("div");c4.setAttribute("oninput","return;"),$E=typeof c4.oninput=="function"}HE=$E}else HE=!1;l4=HE&&(!document.documentMode||9<document.documentMode)}function u4(){Rg&&(Rg.detachEvent("onpropertychange",d4),Dg=Rg=null)}function d4(h){if(h.propertyName==="value"&&wy(Dg)){var m=[];s4(m,Dg,h,RE(h)),KL(Tne,m)}}function Nne(h,m,_){h==="focusin"?(u4(),Rg=m,Dg=_,Rg.attachEvent("onpropertychange",d4)):h==="focusout"&&u4()}function Cne(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return wy(Dg)}function kne(h,m){if(h==="click")return wy(m)}function Pne(h,m){if(h==="input"||h==="change")return wy(m)}function jne(h,m){return h===m&&(h!==0||1/h===1/m)||h!==h&&m!==m}var ds=typeof Object.is=="function"?Object.is:jne;function Og(h,m){if(ds(h,m))return!0;if(typeof h!="object"||h===null||typeof m!="object"||m===null)return!1;var _=Object.keys(h),M=Object.keys(m);if(_.length!==M.length)return!1;for(M=0;M<_.length;M++){var P=_[M];if(!oe.call(m,P)||!ds(h[P],m[P]))return!1}return!0}function h4(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function f4(h,m){var _=h4(h);h=0;for(var M;_;){if(_.nodeType===3){if(M=h+_.textContent.length,h<=m&&M>=m)return{node:_,offset:m-h};h=M}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=h4(_)}}function m4(h,m){return h&&m?h===m?!0:h&&h.nodeType===3?!1:m&&m.nodeType===3?m4(h,m.parentNode):"contains"in h?h.contains(m):h.compareDocumentPosition?!!(h.compareDocumentPosition(m)&16):!1:!1}function p4(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var m=Ur(h.document);m instanceof h.HTMLIFrameElement;){try{var _=typeof m.contentWindow.location.href=="string"}catch{_=!1}if(_)h=m.contentWindow;else break;m=Ur(h.document)}return m}function VE(h){var m=h&&h.nodeName&&h.nodeName.toLowerCase();return m&&(m==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||m==="textarea"||h.contentEditable==="true")}var Rne=Ul&&"documentMode"in document&&11>=document.documentMode,Df=null,GE=null,Lg=null,WE=!1;function g4(h,m,_){var M=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;WE||Df==null||Df!==Ur(M)||(M=Df,"selectionStart"in M&&VE(M)?M={start:M.selectionStart,end:M.selectionEnd}:(M=(M.ownerDocument&&M.ownerDocument.defaultView||window).getSelection(),M={anchorNode:M.anchorNode,anchorOffset:M.anchorOffset,focusNode:M.focusNode,focusOffset:M.focusOffset}),Lg&&Og(Lg,M)||(Lg=M,M=uv(GE,"onSelect"),0<M.length&&(m=new vy("onSelect","select",null,m,_),h.push({event:m,listeners:M}),m.target=Df)))}function Ud(h,m){var _={};return _[h.toLowerCase()]=m.toLowerCase(),_["Webkit"+h]="webkit"+m,_["Moz"+h]="moz"+m,_}var Of={animationend:Ud("Animation","AnimationEnd"),animationiteration:Ud("Animation","AnimationIteration"),animationstart:Ud("Animation","AnimationStart"),transitionrun:Ud("Transition","TransitionRun"),transitionstart:Ud("Transition","TransitionStart"),transitioncancel:Ud("Transition","TransitionCancel"),transitionend:Ud("Transition","TransitionEnd")},qE={},x4={};Ul&&(x4=document.createElement("div").style,"AnimationEvent"in window||(delete Of.animationend.animation,delete Of.animationiteration.animation,delete Of.animationstart.animation),"TransitionEvent"in window||delete Of.transitionend.transition);function zd(h){if(qE[h])return qE[h];if(!Of[h])return h;var m=Of[h],_;for(_ in m)if(m.hasOwnProperty(_)&&_ in x4)return qE[h]=m[_];return h}var b4=zd("animationend"),y4=zd("animationiteration"),v4=zd("animationstart"),Dne=zd("transitionrun"),One=zd("transitionstart"),Lne=zd("transitioncancel"),_4=zd("transitionend"),w4=new Map,KE="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");KE.push("scrollEnd");function So(h,m){w4.set(h,m),xt(m,[h])}var Sy=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var m=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof h=="object"&&h!==null&&typeof h.message=="string"?String(h.message):String(h),error:h});if(!window.dispatchEvent(m))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},Os=[],Lf=0,XE=0;function My(){for(var h=Lf,m=XE=Lf=0;m<h;){var _=Os[m];Os[m++]=null;var M=Os[m];Os[m++]=null;var P=Os[m];Os[m++]=null;var D=Os[m];if(Os[m++]=null,M!==null&&P!==null){var Y=M.pending;Y===null?P.next=P:(P.next=Y.next,Y.next=P),M.pending=P}D!==0&&S4(_,P,D)}}function Ey(h,m,_,M){Os[Lf++]=h,Os[Lf++]=m,Os[Lf++]=_,Os[Lf++]=M,XE|=M,h.lanes|=M,h=h.alternate,h!==null&&(h.lanes|=M)}function YE(h,m,_,M){return Ey(h,m,_,M),Ay(h)}function Bd(h,m){return Ey(h,null,null,m),Ay(h)}function S4(h,m,_){h.lanes|=_;var M=h.alternate;M!==null&&(M.lanes|=_);for(var P=!1,D=h.return;D!==null;)D.childLanes|=_,M=D.alternate,M!==null&&(M.childLanes|=_),D.tag===22&&(h=D.stateNode,h===null||h._visibility&1||(P=!0)),h=D,D=D.return;return h.tag===3?(D=h.stateNode,P&&m!==null&&(P=31-Be(_),h=D.hiddenUpdates,M=h[P],M===null?h[P]=[m]:M.push(m),m.lane=_|536870912),D):null}function Ay(h){if(50<ix)throw ix=0,aA=null,Error(r(185));for(var m=h.return;m!==null;)h=m,m=h.return;return h.tag===3?h.stateNode:null}var If={};function Ine(h,m,_,M){this.tag=h,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=m,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=M,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function hs(h,m,_,M){return new Ine(h,m,_,M)}function ZE(h){return h=h.prototype,!(!h||!h.isReactComponent)}function zl(h,m){var _=h.alternate;return _===null?(_=hs(h.tag,m,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=m,_.type=h.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=h.flags&65011712,_.childLanes=h.childLanes,_.lanes=h.lanes,_.child=h.child,_.memoizedProps=h.memoizedProps,_.memoizedState=h.memoizedState,_.updateQueue=h.updateQueue,m=h.dependencies,_.dependencies=m===null?null:{lanes:m.lanes,firstContext:m.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_.refCleanup=h.refCleanup,_}function M4(h,m){h.flags&=65011714;var _=h.alternate;return _===null?(h.childLanes=0,h.lanes=m,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=_.childLanes,h.lanes=_.lanes,h.child=_.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=_.memoizedProps,h.memoizedState=_.memoizedState,h.updateQueue=_.updateQueue,h.type=_.type,m=_.dependencies,h.dependencies=m===null?null:{lanes:m.lanes,firstContext:m.firstContext}),h}function Ty(h,m,_,M,P,D){var Y=0;if(M=h,typeof h=="function")ZE(h)&&(Y=1);else if(typeof h=="string")Y=Hre(h,_,te.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case k:return h=hs(31,_,m,P),h.elementType=k,h.lanes=D,h;case v:return Hd(_.children,P,D,m);case y:Y=8,P|=24;break;case b:return h=hs(12,_,m,P|2),h.elementType=b,h.lanes=D,h;case T:return h=hs(13,_,m,P),h.elementType=T,h.lanes=D,h;case C:return h=hs(19,_,m,P),h.elementType=C,h.lanes=D,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case w:Y=10;break e;case E:Y=9;break e;case A:Y=11;break e;case N:Y=14;break e;case O:Y=16,M=null;break e}Y=29,_=Error(r(130,h===null?"null":typeof h,"")),M=null}return m=hs(Y,_,m,P),m.elementType=h,m.type=M,m.lanes=D,m}function Hd(h,m,_,M){return h=hs(7,h,M,m),h.lanes=_,h}function QE(h,m,_){return h=hs(6,h,null,m),h.lanes=_,h}function E4(h){var m=hs(18,null,null,0);return m.stateNode=h,m}function JE(h,m,_){return m=hs(4,h.children!==null?h.children:[],h.key,m),m.lanes=_,m.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},m}var A4=new WeakMap;function Ls(h,m){if(typeof h=="object"&&h!==null){var _=A4.get(h);return _!==void 0?_:(m={value:h,source:m,stack:Z(m)},A4.set(h,m),m)}return{value:h,source:m,stack:Z(m)}}var Ff=[],Uf=0,Ny=null,Ig=0,Is=[],Fs=0,ru=null,Qo=1,Jo="";function Bl(h,m){Ff[Uf++]=Ig,Ff[Uf++]=Ny,Ny=h,Ig=m}function T4(h,m,_){Is[Fs++]=Qo,Is[Fs++]=Jo,Is[Fs++]=ru,ru=h;var M=Qo;h=Jo;var P=32-Be(M)-1;M&=~(1<<P),_+=1;var D=32-Be(m)+P;if(30<D){var Y=P-P%5;D=(M&(1<<Y)-1).toString(32),M>>=Y,P-=Y,Qo=1<<32-Be(m)+P|_<<P|M,Jo=D+h}else Qo=1<<D|_<<P|M,Jo=h}function e2(h){h.return!==null&&(Bl(h,1),T4(h,1,0))}function t2(h){for(;h===Ny;)Ny=Ff[--Uf],Ff[Uf]=null,Ig=Ff[--Uf],Ff[Uf]=null;for(;h===ru;)ru=Is[--Fs],Is[Fs]=null,Jo=Is[--Fs],Is[Fs]=null,Qo=Is[--Fs],Is[Fs]=null}function N4(h,m){Is[Fs++]=Qo,Is[Fs++]=Jo,Is[Fs++]=ru,Qo=m.id,Jo=m.overflow,ru=h}var Ki=null,vr=null,Cn=!1,iu=null,Us=!1,n2=Error(r(519));function au(h){var m=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Fg(Ls(m,h)),n2}function C4(h){var m=h.stateNode,_=h.type,M=h.memoizedProps;switch(m[Un]=h,m[jn]=M,_){case"dialog":_n("cancel",m),_n("close",m);break;case"iframe":case"object":case"embed":_n("load",m);break;case"video":case"audio":for(_=0;_<sx.length;_++)_n(sx[_],m);break;case"source":_n("error",m);break;case"img":case"image":case"link":_n("error",m),_n("load",m);break;case"details":_n("toggle",m);break;case"input":_n("invalid",m),Wn(m,M.value,M.defaultValue,M.checked,M.defaultChecked,M.type,M.name,!0);break;case"select":_n("invalid",m);break;case"textarea":_n("invalid",m),qi(m,M.value,M.defaultValue,M.children)}_=M.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||m.textContent===""+_||M.suppressHydrationWarning===!0||W5(m.textContent,_)?(M.popover!=null&&(_n("beforetoggle",m),_n("toggle",m)),M.onScroll!=null&&_n("scroll",m),M.onScrollEnd!=null&&_n("scrollend",m),M.onClick!=null&&(m.onclick=Fl),m=!0):m=!1,m||au(h,!0)}function k4(h){for(Ki=h.return;Ki;)switch(Ki.tag){case 5:case 31:case 13:Us=!1;return;case 27:case 3:Us=!0;return;default:Ki=Ki.return}}function zf(h){if(h!==Ki)return!1;if(!Cn)return k4(h),Cn=!0,!1;var m=h.tag,_;if((_=m!==3&&m!==27)&&((_=m===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||vA(h.type,h.memoizedProps)),_=!_),_&&vr&&au(h),k4(h),m===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));vr=tF(h)}else if(m===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));vr=tF(h)}else m===27?(m=vr,yu(h.type)?(h=EA,EA=null,vr=h):vr=m):vr=Ki?Bs(h.stateNode.nextSibling):null;return!0}function $d(){vr=Ki=null,Cn=!1}function r2(){var h=iu;return h!==null&&(Wa===null?Wa=h:Wa.push.apply(Wa,h),iu=null),h}function Fg(h){iu===null?iu=[h]:iu.push(h)}var i2=z(null),Vd=null,Hl=null;function su(h,m,_){X(i2,m._currentValue),m._currentValue=_}function $l(h){h._currentValue=i2.current,V(i2)}function a2(h,m,_){for(;h!==null;){var M=h.alternate;if((h.childLanes&m)!==m?(h.childLanes|=m,M!==null&&(M.childLanes|=m)):M!==null&&(M.childLanes&m)!==m&&(M.childLanes|=m),h===_)break;h=h.return}}function s2(h,m,_,M){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var D=P.dependencies;if(D!==null){var Y=P.child;D=D.firstContext;e:for(;D!==null;){var ce=D;D=P;for(var Ce=0;Ce<m.length;Ce++)if(ce.context===m[Ce]){D.lanes|=_,ce=D.alternate,ce!==null&&(ce.lanes|=_),a2(D.return,_,h),M||(Y=null);break e}D=ce.next}}else if(P.tag===18){if(Y=P.return,Y===null)throw Error(r(341));Y.lanes|=_,D=Y.alternate,D!==null&&(D.lanes|=_),a2(Y,_,h),Y=null}else Y=P.child;if(Y!==null)Y.return=P;else for(Y=P;Y!==null;){if(Y===h){Y=null;break}if(P=Y.sibling,P!==null){P.return=Y.return,Y=P;break}Y=Y.return}P=Y}}function Bf(h,m,_,M){h=null;for(var P=m,D=!1;P!==null;){if(!D){if((P.flags&524288)!==0)D=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var Y=P.alternate;if(Y===null)throw Error(r(387));if(Y=Y.memoizedProps,Y!==null){var ce=P.type;ds(P.pendingProps.value,Y.value)||(h!==null?h.push(ce):h=[ce])}}else if(P===ge.current){if(Y=P.alternate,Y===null)throw Error(r(387));Y.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(dx):h=[dx])}P=P.return}h!==null&&s2(m,h,_,M),m.flags|=262144}function Cy(h){for(h=h.firstContext;h!==null;){if(!ds(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Gd(h){Vd=h,Hl=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function Xi(h){return P4(Vd,h)}function ky(h,m){return Vd===null&&Gd(h),P4(h,m)}function P4(h,m){var _=m._currentValue;if(m={context:m,memoizedValue:_,next:null},Hl===null){if(h===null)throw Error(r(308));Hl=m,h.dependencies={lanes:0,firstContext:m},h.flags|=524288}else Hl=Hl.next=m;return _}var Fne=typeof AbortController<"u"?AbortController:function(){var h=[],m=this.signal={aborted:!1,addEventListener:function(_,M){h.push(M)}};this.abort=function(){m.aborted=!0,h.forEach(function(_){return _()})}},Une=t.unstable_scheduleCallback,zne=t.unstable_NormalPriority,ti={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function o2(){return{controller:new Fne,data:new Map,refCount:0}}function Ug(h){h.refCount--,h.refCount===0&&Une(zne,function(){h.controller.abort()})}var zg=null,l2=0,Hf=0,$f=null;function Bne(h,m){if(zg===null){var _=zg=[];l2=0,Hf=dA(),$f={status:"pending",value:void 0,then:function(M){_.push(M)}}}return l2++,m.then(j4,j4),m}function j4(){if(--l2===0&&zg!==null){$f!==null&&($f.status="fulfilled");var h=zg;zg=null,Hf=0,$f=null;for(var m=0;m<h.length;m++)(0,h[m])()}}function Hne(h,m){var _=[],M={status:"pending",value:null,reason:null,then:function(P){_.push(P)}};return h.then(function(){M.status="fulfilled",M.value=m;for(var P=0;P<_.length;P++)(0,_[P])(m)},function(P){for(M.status="rejected",M.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),M}var R4=W.S;W.S=function(h,m){g5=I(),typeof m=="object"&&m!==null&&typeof m.then=="function"&&Bne(h,m),R4!==null&&R4(h,m)};var Wd=z(null);function c2(){var h=Wd.current;return h!==null?h:hr.pooledCache}function Py(h,m){m===null?X(Wd,Wd.current):X(Wd,m.pool)}function D4(){var h=c2();return h===null?null:{parent:ti._currentValue,pool:h}}var Vf=Error(r(460)),u2=Error(r(474)),jy=Error(r(542)),Ry={then:function(){}};function O4(h){return h=h.status,h==="fulfilled"||h==="rejected"}function L4(h,m,_){switch(_=h[_],_===void 0?h.push(m):_!==m&&(m.then(Fl,Fl),m=_),m.status){case"fulfilled":return m.value;case"rejected":throw h=m.reason,F4(h),h;default:if(typeof m.status=="string")m.then(Fl,Fl);else{if(h=hr,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=m,h.status="pending",h.then(function(M){if(m.status==="pending"){var P=m;P.status="fulfilled",P.value=M}},function(M){if(m.status==="pending"){var P=m;P.status="rejected",P.reason=M}})}switch(m.status){case"fulfilled":return m.value;case"rejected":throw h=m.reason,F4(h),h}throw Kd=m,Vf}}function qd(h){try{var m=h._init;return m(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Kd=_,Vf):_}}var Kd=null;function I4(){if(Kd===null)throw Error(r(459));var h=Kd;return Kd=null,h}function F4(h){if(h===Vf||h===jy)throw Error(r(483))}var Gf=null,Bg=0;function Dy(h){var m=Bg;return Bg+=1,Gf===null&&(Gf=[]),L4(Gf,h,m)}function Hg(h,m){m=m.props.ref,h.ref=m!==void 0?m:null}function Oy(h,m){throw m.$$typeof===g?Error(r(525)):(h=Object.prototype.toString.call(m),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(m).join(", ")+"}":h)))}function U4(h){function m(Ge,De){if(h){var Je=Ge.deletions;Je===null?(Ge.deletions=[De],Ge.flags|=16):Je.push(De)}}function _(Ge,De){if(!h)return null;for(;De!==null;)m(Ge,De),De=De.sibling;return null}function M(Ge){for(var De=new Map;Ge!==null;)Ge.key!==null?De.set(Ge.key,Ge):De.set(Ge.index,Ge),Ge=Ge.sibling;return De}function P(Ge,De){return Ge=zl(Ge,De),Ge.index=0,Ge.sibling=null,Ge}function D(Ge,De,Je){return Ge.index=Je,h?(Je=Ge.alternate,Je!==null?(Je=Je.index,Je<De?(Ge.flags|=67108866,De):Je):(Ge.flags|=67108866,De)):(Ge.flags|=1048576,De)}function Y(Ge){return h&&Ge.alternate===null&&(Ge.flags|=67108866),Ge}function ce(Ge,De,Je,ft){return De===null||De.tag!==6?(De=QE(Je,Ge.mode,ft),De.return=Ge,De):(De=P(De,Je),De.return=Ge,De)}function Ce(Ge,De,Je,ft){var Vt=Je.type;return Vt===v?dt(Ge,De,Je.props.children,ft,Je.key):De!==null&&(De.elementType===Vt||typeof Vt=="object"&&Vt!==null&&Vt.$$typeof===O&&qd(Vt)===De.type)?(De=P(De,Je.props),Hg(De,Je),De.return=Ge,De):(De=Ty(Je.type,Je.key,Je.props,null,Ge.mode,ft),Hg(De,Je),De.return=Ge,De)}function tt(Ge,De,Je,ft){return De===null||De.tag!==4||De.stateNode.containerInfo!==Je.containerInfo||De.stateNode.implementation!==Je.implementation?(De=JE(Je,Ge.mode,ft),De.return=Ge,De):(De=P(De,Je.children||[]),De.return=Ge,De)}function dt(Ge,De,Je,ft,Vt){return De===null||De.tag!==7?(De=Hd(Je,Ge.mode,ft,Vt),De.return=Ge,De):(De=P(De,Je),De.return=Ge,De)}function mt(Ge,De,Je){if(typeof De=="string"&&De!==""||typeof De=="number"||typeof De=="bigint")return De=QE(""+De,Ge.mode,Je),De.return=Ge,De;if(typeof De=="object"&&De!==null){switch(De.$$typeof){case p:return Je=Ty(De.type,De.key,De.props,null,Ge.mode,Je),Hg(Je,De),Je.return=Ge,Je;case x:return De=JE(De,Ge.mode,Je),De.return=Ge,De;case O:return De=qd(De),mt(Ge,De,Je)}if(q(De)||L(De))return De=Hd(De,Ge.mode,Je,null),De.return=Ge,De;if(typeof De.then=="function")return mt(Ge,Dy(De),Je);if(De.$$typeof===w)return mt(Ge,ky(Ge,De),Je);Oy(Ge,De)}return null}function it(Ge,De,Je,ft){var Vt=De!==null?De.key:null;if(typeof Je=="string"&&Je!==""||typeof Je=="number"||typeof Je=="bigint")return Vt!==null?null:ce(Ge,De,""+Je,ft);if(typeof Je=="object"&&Je!==null){switch(Je.$$typeof){case p:return Je.key===Vt?Ce(Ge,De,Je,ft):null;case x:return Je.key===Vt?tt(Ge,De,Je,ft):null;case O:return Je=qd(Je),it(Ge,De,Je,ft)}if(q(Je)||L(Je))return Vt!==null?null:dt(Ge,De,Je,ft,null);if(typeof Je.then=="function")return it(Ge,De,Dy(Je),ft);if(Je.$$typeof===w)return it(Ge,De,ky(Ge,Je),ft);Oy(Ge,Je)}return null}function ot(Ge,De,Je,ft,Vt){if(typeof ft=="string"&&ft!==""||typeof ft=="number"||typeof ft=="bigint")return Ge=Ge.get(Je)||null,ce(De,Ge,""+ft,Vt);if(typeof ft=="object"&&ft!==null){switch(ft.$$typeof){case p:return Ge=Ge.get(ft.key===null?Je:ft.key)||null,Ce(De,Ge,ft,Vt);case x:return Ge=Ge.get(ft.key===null?Je:ft.key)||null,tt(De,Ge,ft,Vt);case O:return ft=qd(ft),ot(Ge,De,Je,ft,Vt)}if(q(ft)||L(ft))return Ge=Ge.get(Je)||null,dt(De,Ge,ft,Vt,null);if(typeof ft.then=="function")return ot(Ge,De,Je,Dy(ft),Vt);if(ft.$$typeof===w)return ot(Ge,De,Je,ky(De,ft),Vt);Oy(De,ft)}return null}function Lt(Ge,De,Je,ft){for(var Vt=null,Rn=null,zt=De,ln=De=0,An=null;zt!==null&&ln<Je.length;ln++){zt.index>ln?(An=zt,zt=null):An=zt.sibling;var Dn=it(Ge,zt,Je[ln],ft);if(Dn===null){zt===null&&(zt=An);break}h&&zt&&Dn.alternate===null&&m(Ge,zt),De=D(Dn,De,ln),Rn===null?Vt=Dn:Rn.sibling=Dn,Rn=Dn,zt=An}if(ln===Je.length)return _(Ge,zt),Cn&&Bl(Ge,ln),Vt;if(zt===null){for(;ln<Je.length;ln++)zt=mt(Ge,Je[ln],ft),zt!==null&&(De=D(zt,De,ln),Rn===null?Vt=zt:Rn.sibling=zt,Rn=zt);return Cn&&Bl(Ge,ln),Vt}for(zt=M(zt);ln<Je.length;ln++)An=ot(zt,Ge,ln,Je[ln],ft),An!==null&&(h&&An.alternate!==null&&zt.delete(An.key===null?ln:An.key),De=D(An,De,ln),Rn===null?Vt=An:Rn.sibling=An,Rn=An);return h&&zt.forEach(function(Mu){return m(Ge,Mu)}),Cn&&Bl(Ge,ln),Vt}function Xt(Ge,De,Je,ft){if(Je==null)throw Error(r(151));for(var Vt=null,Rn=null,zt=De,ln=De=0,An=null,Dn=Je.next();zt!==null&&!Dn.done;ln++,Dn=Je.next()){zt.index>ln?(An=zt,zt=null):An=zt.sibling;var Mu=it(Ge,zt,Dn.value,ft);if(Mu===null){zt===null&&(zt=An);break}h&&zt&&Mu.alternate===null&&m(Ge,zt),De=D(Mu,De,ln),Rn===null?Vt=Mu:Rn.sibling=Mu,Rn=Mu,zt=An}if(Dn.done)return _(Ge,zt),Cn&&Bl(Ge,ln),Vt;if(zt===null){for(;!Dn.done;ln++,Dn=Je.next())Dn=mt(Ge,Dn.value,ft),Dn!==null&&(De=D(Dn,De,ln),Rn===null?Vt=Dn:Rn.sibling=Dn,Rn=Dn);return Cn&&Bl(Ge,ln),Vt}for(zt=M(zt);!Dn.done;ln++,Dn=Je.next())Dn=ot(zt,Ge,ln,Dn.value,ft),Dn!==null&&(h&&Dn.alternate!==null&&zt.delete(Dn.key===null?ln:Dn.key),De=D(Dn,De,ln),Rn===null?Vt=Dn:Rn.sibling=Dn,Rn=Dn);return h&&zt.forEach(function(Jre){return m(Ge,Jre)}),Cn&&Bl(Ge,ln),Vt}function rr(Ge,De,Je,ft){if(typeof Je=="object"&&Je!==null&&Je.type===v&&Je.key===null&&(Je=Je.props.children),typeof Je=="object"&&Je!==null){switch(Je.$$typeof){case p:e:{for(var Vt=Je.key;De!==null;){if(De.key===Vt){if(Vt=Je.type,Vt===v){if(De.tag===7){_(Ge,De.sibling),ft=P(De,Je.props.children),ft.return=Ge,Ge=ft;break e}}else if(De.elementType===Vt||typeof Vt=="object"&&Vt!==null&&Vt.$$typeof===O&&qd(Vt)===De.type){_(Ge,De.sibling),ft=P(De,Je.props),Hg(ft,Je),ft.return=Ge,Ge=ft;break e}_(Ge,De);break}else m(Ge,De);De=De.sibling}Je.type===v?(ft=Hd(Je.props.children,Ge.mode,ft,Je.key),ft.return=Ge,Ge=ft):(ft=Ty(Je.type,Je.key,Je.props,null,Ge.mode,ft),Hg(ft,Je),ft.return=Ge,Ge=ft)}return Y(Ge);case x:e:{for(Vt=Je.key;De!==null;){if(De.key===Vt)if(De.tag===4&&De.stateNode.containerInfo===Je.containerInfo&&De.stateNode.implementation===Je.implementation){_(Ge,De.sibling),ft=P(De,Je.children||[]),ft.return=Ge,Ge=ft;break e}else{_(Ge,De);break}else m(Ge,De);De=De.sibling}ft=JE(Je,Ge.mode,ft),ft.return=Ge,Ge=ft}return Y(Ge);case O:return Je=qd(Je),rr(Ge,De,Je,ft)}if(q(Je))return Lt(Ge,De,Je,ft);if(L(Je)){if(Vt=L(Je),typeof Vt!="function")throw Error(r(150));return Je=Vt.call(Je),Xt(Ge,De,Je,ft)}if(typeof Je.then=="function")return rr(Ge,De,Dy(Je),ft);if(Je.$$typeof===w)return rr(Ge,De,ky(Ge,Je),ft);Oy(Ge,Je)}return typeof Je=="string"&&Je!==""||typeof Je=="number"||typeof Je=="bigint"?(Je=""+Je,De!==null&&De.tag===6?(_(Ge,De.sibling),ft=P(De,Je),ft.return=Ge,Ge=ft):(_(Ge,De),ft=QE(Je,Ge.mode,ft),ft.return=Ge,Ge=ft),Y(Ge)):_(Ge,De)}return function(Ge,De,Je,ft){try{Bg=0;var Vt=rr(Ge,De,Je,ft);return Gf=null,Vt}catch(zt){if(zt===Vf||zt===jy)throw zt;var Rn=hs(29,zt,null,Ge.mode);return Rn.lanes=ft,Rn.return=Ge,Rn}finally{}}}var Xd=U4(!0),z4=U4(!1),ou=!1;function d2(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function h2(h,m){h=h.updateQueue,m.updateQueue===h&&(m.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function lu(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function cu(h,m,_){var M=h.updateQueue;if(M===null)return null;if(M=M.shared,(zn&2)!==0){var P=M.pending;return P===null?m.next=m:(m.next=P.next,P.next=m),M.pending=m,m=Ay(h),S4(h,null,_),m}return Ey(h,M,m,_),Ay(h)}function $g(h,m,_){if(m=m.updateQueue,m!==null&&(m=m.shared,(_&4194048)!==0)){var M=m.lanes;M&=h.pendingLanes,_|=M,m.lanes=_,gn(h,_)}}function f2(h,m){var _=h.updateQueue,M=h.alternate;if(M!==null&&(M=M.updateQueue,_===M)){var P=null,D=null;if(_=_.firstBaseUpdate,_!==null){do{var Y={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};D===null?P=D=Y:D=D.next=Y,_=_.next}while(_!==null);D===null?P=D=m:D=D.next=m}else P=D=m;_={baseState:M.baseState,firstBaseUpdate:P,lastBaseUpdate:D,shared:M.shared,callbacks:M.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=m:h.next=m,_.lastBaseUpdate=m}var m2=!1;function Vg(){if(m2){var h=$f;if(h!==null)throw h}}function Gg(h,m,_,M){m2=!1;var P=h.updateQueue;ou=!1;var D=P.firstBaseUpdate,Y=P.lastBaseUpdate,ce=P.shared.pending;if(ce!==null){P.shared.pending=null;var Ce=ce,tt=Ce.next;Ce.next=null,Y===null?D=tt:Y.next=tt,Y=Ce;var dt=h.alternate;dt!==null&&(dt=dt.updateQueue,ce=dt.lastBaseUpdate,ce!==Y&&(ce===null?dt.firstBaseUpdate=tt:ce.next=tt,dt.lastBaseUpdate=Ce))}if(D!==null){var mt=P.baseState;Y=0,dt=tt=Ce=null,ce=D;do{var it=ce.lane&-536870913,ot=it!==ce.lane;if(ot?(En&it)===it:(M&it)===it){it!==0&&it===Hf&&(m2=!0),dt!==null&&(dt=dt.next={lane:0,tag:ce.tag,payload:ce.payload,callback:null,next:null});e:{var Lt=h,Xt=ce;it=m;var rr=_;switch(Xt.tag){case 1:if(Lt=Xt.payload,typeof Lt=="function"){mt=Lt.call(rr,mt,it);break e}mt=Lt;break e;case 3:Lt.flags=Lt.flags&-65537|128;case 0:if(Lt=Xt.payload,it=typeof Lt=="function"?Lt.call(rr,mt,it):Lt,it==null)break e;mt=f({},mt,it);break e;case 2:ou=!0}}it=ce.callback,it!==null&&(h.flags|=64,ot&&(h.flags|=8192),ot=P.callbacks,ot===null?P.callbacks=[it]:ot.push(it))}else ot={lane:it,tag:ce.tag,payload:ce.payload,callback:ce.callback,next:null},dt===null?(tt=dt=ot,Ce=mt):dt=dt.next=ot,Y|=it;if(ce=ce.next,ce===null){if(ce=P.shared.pending,ce===null)break;ot=ce,ce=ot.next,ot.next=null,P.lastBaseUpdate=ot,P.shared.pending=null}}while(!0);dt===null&&(Ce=mt),P.baseState=Ce,P.firstBaseUpdate=tt,P.lastBaseUpdate=dt,D===null&&(P.shared.lanes=0),mu|=Y,h.lanes=Y,h.memoizedState=mt}}function B4(h,m){if(typeof h!="function")throw Error(r(191,h));h.call(m)}function H4(h,m){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)B4(_[h],m)}var Wf=z(null),Ly=z(0);function $4(h,m){h=Ql,X(Ly,h),X(Wf,m),Ql=h|m.baseLanes}function p2(){X(Ly,Ql),X(Wf,Wf.current)}function g2(){Ql=Ly.current,V(Wf),V(Ly)}var fs=z(null),zs=null;function uu(h){var m=h.alternate;X(Kr,Kr.current&1),X(fs,h),zs===null&&(m===null||Wf.current!==null||m.memoizedState!==null)&&(zs=h)}function x2(h){X(Kr,Kr.current),X(fs,h),zs===null&&(zs=h)}function V4(h){h.tag===22?(X(Kr,Kr.current),X(fs,h),zs===null&&(zs=h)):du()}function du(){X(Kr,Kr.current),X(fs,fs.current)}function ms(h){V(fs),zs===h&&(zs=null),V(Kr)}var Kr=z(0);function Iy(h){for(var m=h;m!==null;){if(m.tag===13){var _=m.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||SA(_)||MA(_)))return m}else if(m.tag===19&&(m.memoizedProps.revealOrder==="forwards"||m.memoizedProps.revealOrder==="backwards"||m.memoizedProps.revealOrder==="unstable_legacy-backwards"||m.memoizedProps.revealOrder==="together")){if((m.flags&128)!==0)return m}else if(m.child!==null){m.child.return=m,m=m.child;continue}if(m===h)break;for(;m.sibling===null;){if(m.return===null||m.return===h)return null;m=m.return}m.sibling.return=m.return,m=m.sibling}return null}var Vl=0,on=null,tr=null,ni=null,Fy=!1,qf=!1,Yd=!1,Uy=0,Wg=0,Kf=null,$ne=0;function zr(){throw Error(r(321))}function b2(h,m){if(m===null)return!1;for(var _=0;_<m.length&&_<h.length;_++)if(!ds(h[_],m[_]))return!1;return!0}function y2(h,m,_,M,P,D){return Vl=D,on=m,m.memoizedState=null,m.updateQueue=null,m.lanes=0,W.H=h===null||h.memoizedState===null?TI:D2,Yd=!1,D=_(M,P),Yd=!1,qf&&(D=W4(m,_,M,P)),G4(h),D}function G4(h){W.H=Xg;var m=tr!==null&&tr.next!==null;if(Vl=0,ni=tr=on=null,Fy=!1,Wg=0,Kf=null,m)throw Error(r(300));h===null||ri||(h=h.dependencies,h!==null&&Cy(h)&&(ri=!0))}function W4(h,m,_,M){on=h;var P=0;do{if(qf&&(Kf=null),Wg=0,qf=!1,25<=P)throw Error(r(301));if(P+=1,ni=tr=null,h.updateQueue!=null){var D=h.updateQueue;D.lastEffect=null,D.events=null,D.stores=null,D.memoCache!=null&&(D.memoCache.index=0)}W.H=NI,D=m(_,M)}while(qf);return D}function Vne(){var h=W.H,m=h.useState()[0];return m=typeof m.then=="function"?qg(m):m,h=h.useState()[0],(tr!==null?tr.memoizedState:null)!==h&&(on.flags|=1024),m}function v2(){var h=Uy!==0;return Uy=0,h}function _2(h,m,_){m.updateQueue=h.updateQueue,m.flags&=-2053,h.lanes&=~_}function w2(h){if(Fy){for(h=h.memoizedState;h!==null;){var m=h.queue;m!==null&&(m.pending=null),h=h.next}Fy=!1}Vl=0,ni=tr=on=null,qf=!1,Wg=Uy=0,Kf=null}function Ea(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ni===null?on.memoizedState=ni=h:ni=ni.next=h,ni}function Xr(){if(tr===null){var h=on.alternate;h=h!==null?h.memoizedState:null}else h=tr.next;var m=ni===null?on.memoizedState:ni.next;if(m!==null)ni=m,tr=h;else{if(h===null)throw on.alternate===null?Error(r(467)):Error(r(310));tr=h,h={memoizedState:tr.memoizedState,baseState:tr.baseState,baseQueue:tr.baseQueue,queue:tr.queue,next:null},ni===null?on.memoizedState=ni=h:ni=ni.next=h}return ni}function zy(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function qg(h){var m=Wg;return Wg+=1,Kf===null&&(Kf=[]),h=L4(Kf,h,m),m=on,(ni===null?m.memoizedState:ni.next)===null&&(m=m.alternate,W.H=m===null||m.memoizedState===null?TI:D2),h}function By(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return qg(h);if(h.$$typeof===w)return Xi(h)}throw Error(r(438,String(h)))}function S2(h){var m=null,_=on.updateQueue;if(_!==null&&(m=_.memoCache),m==null){var M=on.alternate;M!==null&&(M=M.updateQueue,M!==null&&(M=M.memoCache,M!=null&&(m={data:M.data.map(function(P){return P.slice()}),index:0})))}if(m==null&&(m={data:[],index:0}),_===null&&(_=zy(),on.updateQueue=_),_.memoCache=m,_=m.data[m.index],_===void 0)for(_=m.data[m.index]=Array(h),M=0;M<h;M++)_[M]=j;return m.index++,_}function Gl(h,m){return typeof m=="function"?m(h):m}function Hy(h){var m=Xr();return M2(m,tr,h)}function M2(h,m,_){var M=h.queue;if(M===null)throw Error(r(311));M.lastRenderedReducer=_;var P=h.baseQueue,D=M.pending;if(D!==null){if(P!==null){var Y=P.next;P.next=D.next,D.next=Y}m.baseQueue=P=D,M.pending=null}if(D=h.baseState,P===null)h.memoizedState=D;else{m=P.next;var ce=Y=null,Ce=null,tt=m,dt=!1;do{var mt=tt.lane&-536870913;if(mt!==tt.lane?(En&mt)===mt:(Vl&mt)===mt){var it=tt.revertLane;if(it===0)Ce!==null&&(Ce=Ce.next={lane:0,revertLane:0,gesture:null,action:tt.action,hasEagerState:tt.hasEagerState,eagerState:tt.eagerState,next:null}),mt===Hf&&(dt=!0);else if((Vl&it)===it){tt=tt.next,it===Hf&&(dt=!0);continue}else mt={lane:0,revertLane:tt.revertLane,gesture:null,action:tt.action,hasEagerState:tt.hasEagerState,eagerState:tt.eagerState,next:null},Ce===null?(ce=Ce=mt,Y=D):Ce=Ce.next=mt,on.lanes|=it,mu|=it;mt=tt.action,Yd&&_(D,mt),D=tt.hasEagerState?tt.eagerState:_(D,mt)}else it={lane:mt,revertLane:tt.revertLane,gesture:tt.gesture,action:tt.action,hasEagerState:tt.hasEagerState,eagerState:tt.eagerState,next:null},Ce===null?(ce=Ce=it,Y=D):Ce=Ce.next=it,on.lanes|=mt,mu|=mt;tt=tt.next}while(tt!==null&&tt!==m);if(Ce===null?Y=D:Ce.next=ce,!ds(D,h.memoizedState)&&(ri=!0,dt&&(_=$f,_!==null)))throw _;h.memoizedState=D,h.baseState=Y,h.baseQueue=Ce,M.lastRenderedState=D}return P===null&&(M.lanes=0),[h.memoizedState,M.dispatch]}function E2(h){var m=Xr(),_=m.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var M=_.dispatch,P=_.pending,D=m.memoizedState;if(P!==null){_.pending=null;var Y=P=P.next;do D=h(D,Y.action),Y=Y.next;while(Y!==P);ds(D,m.memoizedState)||(ri=!0),m.memoizedState=D,m.baseQueue===null&&(m.baseState=D),_.lastRenderedState=D}return[D,M]}function q4(h,m,_){var M=on,P=Xr(),D=Cn;if(D){if(_===void 0)throw Error(r(407));_=_()}else _=m();var Y=!ds((tr||P).memoizedState,_);if(Y&&(P.memoizedState=_,ri=!0),P=P.queue,N2(Y4.bind(null,M,P,h),[h]),P.getSnapshot!==m||Y||ni!==null&&ni.memoizedState.tag&1){if(M.flags|=2048,Xf(9,{destroy:void 0},X4.bind(null,M,P,_,m),null),hr===null)throw Error(r(349));D||(Vl&127)!==0||K4(M,m,_)}return _}function K4(h,m,_){h.flags|=16384,h={getSnapshot:m,value:_},m=on.updateQueue,m===null?(m=zy(),on.updateQueue=m,m.stores=[h]):(_=m.stores,_===null?m.stores=[h]:_.push(h))}function X4(h,m,_,M){m.value=_,m.getSnapshot=M,Z4(m)&&Q4(h)}function Y4(h,m,_){return _(function(){Z4(m)&&Q4(h)})}function Z4(h){var m=h.getSnapshot;h=h.value;try{var _=m();return!ds(h,_)}catch{return!0}}function Q4(h){var m=Bd(h,2);m!==null&&qa(m,h,2)}function A2(h){var m=Ea();if(typeof h=="function"){var _=h;if(h=_(),Yd){Ve(!0);try{_()}finally{Ve(!1)}}}return m.memoizedState=m.baseState=h,m.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gl,lastRenderedState:h},m}function J4(h,m,_,M){return h.baseState=_,M2(h,tr,typeof M=="function"?M:Gl)}function Gne(h,m,_,M,P){if(Gy(h))throw Error(r(485));if(h=m.action,h!==null){var D={payload:P,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(Y){D.listeners.push(Y)}};W.T!==null?_(!0):D.isTransition=!1,M(D),_=m.pending,_===null?(D.next=m.pending=D,eI(m,D)):(D.next=_.next,m.pending=_.next=D)}}function eI(h,m){var _=m.action,M=m.payload,P=h.state;if(m.isTransition){var D=W.T,Y={};W.T=Y;try{var ce=_(P,M),Ce=W.S;Ce!==null&&Ce(Y,ce),tI(h,m,ce)}catch(tt){T2(h,m,tt)}finally{D!==null&&Y.types!==null&&(D.types=Y.types),W.T=D}}else try{D=_(P,M),tI(h,m,D)}catch(tt){T2(h,m,tt)}}function tI(h,m,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(M){nI(h,m,M)},function(M){return T2(h,m,M)}):nI(h,m,_)}function nI(h,m,_){m.status="fulfilled",m.value=_,rI(m),h.state=_,m=h.pending,m!==null&&(_=m.next,_===m?h.pending=null:(_=_.next,m.next=_,eI(h,_)))}function T2(h,m,_){var M=h.pending;if(h.pending=null,M!==null){M=M.next;do m.status="rejected",m.reason=_,rI(m),m=m.next;while(m!==M)}h.action=null}function rI(h){h=h.listeners;for(var m=0;m<h.length;m++)(0,h[m])()}function iI(h,m){return m}function aI(h,m){if(Cn){var _=hr.formState;if(_!==null){e:{var M=on;if(Cn){if(vr){t:{for(var P=vr,D=Us;P.nodeType!==8;){if(!D){P=null;break t}if(P=Bs(P.nextSibling),P===null){P=null;break t}}D=P.data,P=D==="F!"||D==="F"?P:null}if(P){vr=Bs(P.nextSibling),M=P.data==="F!";break e}}au(M)}M=!1}M&&(m=_[0])}}return _=Ea(),_.memoizedState=_.baseState=m,M={pending:null,lanes:0,dispatch:null,lastRenderedReducer:iI,lastRenderedState:m},_.queue=M,_=MI.bind(null,on,M),M.dispatch=_,M=A2(!1),D=R2.bind(null,on,!1,M.queue),M=Ea(),P={state:m,dispatch:null,action:h,pending:null},M.queue=P,_=Gne.bind(null,on,P,D,_),P.dispatch=_,M.memoizedState=h,[m,_,!1]}function sI(h){var m=Xr();return oI(m,tr,h)}function oI(h,m,_){if(m=M2(h,m,iI)[0],h=Hy(Gl)[0],typeof m=="object"&&m!==null&&typeof m.then=="function")try{var M=qg(m)}catch(Y){throw Y===Vf?jy:Y}else M=m;m=Xr();var P=m.queue,D=P.dispatch;return _!==m.memoizedState&&(on.flags|=2048,Xf(9,{destroy:void 0},Wne.bind(null,P,_),null)),[M,D,h]}function Wne(h,m){h.action=m}function lI(h){var m=Xr(),_=tr;if(_!==null)return oI(m,_,h);Xr(),m=m.memoizedState,_=Xr();var M=_.queue.dispatch;return _.memoizedState=h,[m,M,!1]}function Xf(h,m,_,M){return h={tag:h,create:_,deps:M,inst:m,next:null},m=on.updateQueue,m===null&&(m=zy(),on.updateQueue=m),_=m.lastEffect,_===null?m.lastEffect=h.next=h:(M=_.next,_.next=h,h.next=M,m.lastEffect=h),h}function cI(){return Xr().memoizedState}function $y(h,m,_,M){var P=Ea();on.flags|=h,P.memoizedState=Xf(1|m,{destroy:void 0},_,M===void 0?null:M)}function Vy(h,m,_,M){var P=Xr();M=M===void 0?null:M;var D=P.memoizedState.inst;tr!==null&&M!==null&&b2(M,tr.memoizedState.deps)?P.memoizedState=Xf(m,D,_,M):(on.flags|=h,P.memoizedState=Xf(1|m,D,_,M))}function uI(h,m){$y(8390656,8,h,m)}function N2(h,m){Vy(2048,8,h,m)}function qne(h){on.flags|=4;var m=on.updateQueue;if(m===null)m=zy(),on.updateQueue=m,m.events=[h];else{var _=m.events;_===null?m.events=[h]:_.push(h)}}function dI(h){var m=Xr().memoizedState;return qne({ref:m,nextImpl:h}),function(){if((zn&2)!==0)throw Error(r(440));return m.impl.apply(void 0,arguments)}}function hI(h,m){return Vy(4,2,h,m)}function fI(h,m){return Vy(4,4,h,m)}function mI(h,m){if(typeof m=="function"){h=h();var _=m(h);return function(){typeof _=="function"?_():m(null)}}if(m!=null)return h=h(),m.current=h,function(){m.current=null}}function pI(h,m,_){_=_!=null?_.concat([h]):null,Vy(4,4,mI.bind(null,m,h),_)}function C2(){}function gI(h,m){var _=Xr();m=m===void 0?null:m;var M=_.memoizedState;return m!==null&&b2(m,M[1])?M[0]:(_.memoizedState=[h,m],h)}function xI(h,m){var _=Xr();m=m===void 0?null:m;var M=_.memoizedState;if(m!==null&&b2(m,M[1]))return M[0];if(M=h(),Yd){Ve(!0);try{h()}finally{Ve(!1)}}return _.memoizedState=[M,m],M}function k2(h,m,_){return _===void 0||(Vl&1073741824)!==0&&(En&261930)===0?h.memoizedState=m:(h.memoizedState=_,h=b5(),on.lanes|=h,mu|=h,_)}function bI(h,m,_,M){return ds(_,m)?_:Wf.current!==null?(h=k2(h,_,M),ds(h,m)||(ri=!0),h):(Vl&42)===0||(Vl&1073741824)!==0&&(En&261930)===0?(ri=!0,h.memoizedState=_):(h=b5(),on.lanes|=h,mu|=h,m)}function yI(h,m,_,M,P){var D=$.p;$.p=D!==0&&8>D?D:8;var Y=W.T,ce={};W.T=ce,R2(h,!1,m,_);try{var Ce=P(),tt=W.S;if(tt!==null&&tt(ce,Ce),Ce!==null&&typeof Ce=="object"&&typeof Ce.then=="function"){var dt=Hne(Ce,M);Kg(h,m,dt,xs(h))}else Kg(h,m,M,xs(h))}catch(mt){Kg(h,m,{then:function(){},status:"rejected",reason:mt},xs())}finally{$.p=D,Y!==null&&ce.types!==null&&(Y.types=ce.types),W.T=Y}}function Kne(){}function P2(h,m,_,M){if(h.tag!==5)throw Error(r(476));var P=vI(h).queue;yI(h,P,m,J,_===null?Kne:function(){return _I(h),_(M)})}function vI(h){var m=h.memoizedState;if(m!==null)return m;m={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gl,lastRenderedState:J},next:null};var _={};return m.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gl,lastRenderedState:_},next:null},h.memoizedState=m,h=h.alternate,h!==null&&(h.memoizedState=m),m}function _I(h){var m=vI(h);m.next===null&&(m=h.alternate.memoizedState),Kg(h,m.next.queue,{},xs())}function j2(){return Xi(dx)}function wI(){return Xr().memoizedState}function SI(){return Xr().memoizedState}function Xne(h){for(var m=h.return;m!==null;){switch(m.tag){case 24:case 3:var _=xs();h=lu(_);var M=cu(m,h,_);M!==null&&(qa(M,m,_),$g(M,m,_)),m={cache:o2()},h.payload=m;return}m=m.return}}function Yne(h,m,_){var M=xs();_={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Gy(h)?EI(m,_):(_=YE(h,m,_,M),_!==null&&(qa(_,h,M),AI(_,m,M)))}function MI(h,m,_){var M=xs();Kg(h,m,_,M)}function Kg(h,m,_,M){var P={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Gy(h))EI(m,P);else{var D=h.alternate;if(h.lanes===0&&(D===null||D.lanes===0)&&(D=m.lastRenderedReducer,D!==null))try{var Y=m.lastRenderedState,ce=D(Y,_);if(P.hasEagerState=!0,P.eagerState=ce,ds(ce,Y))return Ey(h,m,P,0),hr===null&&My(),!1}catch{}finally{}if(_=YE(h,m,P,M),_!==null)return qa(_,h,M),AI(_,m,M),!0}return!1}function R2(h,m,_,M){if(M={lane:2,revertLane:dA(),gesture:null,action:M,hasEagerState:!1,eagerState:null,next:null},Gy(h)){if(m)throw Error(r(479))}else m=YE(h,_,M,2),m!==null&&qa(m,h,2)}function Gy(h){var m=h.alternate;return h===on||m!==null&&m===on}function EI(h,m){qf=Fy=!0;var _=h.pending;_===null?m.next=m:(m.next=_.next,_.next=m),h.pending=m}function AI(h,m,_){if((_&4194048)!==0){var M=m.lanes;M&=h.pendingLanes,_|=M,m.lanes=_,gn(h,_)}}var Xg={readContext:Xi,use:By,useCallback:zr,useContext:zr,useEffect:zr,useImperativeHandle:zr,useLayoutEffect:zr,useInsertionEffect:zr,useMemo:zr,useReducer:zr,useRef:zr,useState:zr,useDebugValue:zr,useDeferredValue:zr,useTransition:zr,useSyncExternalStore:zr,useId:zr,useHostTransitionStatus:zr,useFormState:zr,useActionState:zr,useOptimistic:zr,useMemoCache:zr,useCacheRefresh:zr};Xg.useEffectEvent=zr;var TI={readContext:Xi,use:By,useCallback:function(h,m){return Ea().memoizedState=[h,m===void 0?null:m],h},useContext:Xi,useEffect:uI,useImperativeHandle:function(h,m,_){_=_!=null?_.concat([h]):null,$y(4194308,4,mI.bind(null,m,h),_)},useLayoutEffect:function(h,m){return $y(4194308,4,h,m)},useInsertionEffect:function(h,m){$y(4,2,h,m)},useMemo:function(h,m){var _=Ea();m=m===void 0?null:m;var M=h();if(Yd){Ve(!0);try{h()}finally{Ve(!1)}}return _.memoizedState=[M,m],M},useReducer:function(h,m,_){var M=Ea();if(_!==void 0){var P=_(m);if(Yd){Ve(!0);try{_(m)}finally{Ve(!1)}}}else P=m;return M.memoizedState=M.baseState=P,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:P},M.queue=h,h=h.dispatch=Yne.bind(null,on,h),[M.memoizedState,h]},useRef:function(h){var m=Ea();return h={current:h},m.memoizedState=h},useState:function(h){h=A2(h);var m=h.queue,_=MI.bind(null,on,m);return m.dispatch=_,[h.memoizedState,_]},useDebugValue:C2,useDeferredValue:function(h,m){var _=Ea();return k2(_,h,m)},useTransition:function(){var h=A2(!1);return h=yI.bind(null,on,h.queue,!0,!1),Ea().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,m,_){var M=on,P=Ea();if(Cn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=m(),hr===null)throw Error(r(349));(En&127)!==0||K4(M,m,_)}P.memoizedState=_;var D={value:_,getSnapshot:m};return P.queue=D,uI(Y4.bind(null,M,D,h),[h]),M.flags|=2048,Xf(9,{destroy:void 0},X4.bind(null,M,D,_,m),null),_},useId:function(){var h=Ea(),m=hr.identifierPrefix;if(Cn){var _=Jo,M=Qo;_=(M&~(1<<32-Be(M)-1)).toString(32)+_,m="_"+m+"R_"+_,_=Uy++,0<_&&(m+="H"+_.toString(32)),m+="_"}else _=$ne++,m="_"+m+"r_"+_.toString(32)+"_";return h.memoizedState=m},useHostTransitionStatus:j2,useFormState:aI,useActionState:aI,useOptimistic:function(h){var m=Ea();m.memoizedState=m.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return m.queue=_,m=R2.bind(null,on,!0,_),_.dispatch=m,[h,m]},useMemoCache:S2,useCacheRefresh:function(){return Ea().memoizedState=Xne.bind(null,on)},useEffectEvent:function(h){var m=Ea(),_={impl:h};return m.memoizedState=_,function(){if((zn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},D2={readContext:Xi,use:By,useCallback:gI,useContext:Xi,useEffect:N2,useImperativeHandle:pI,useInsertionEffect:hI,useLayoutEffect:fI,useMemo:xI,useReducer:Hy,useRef:cI,useState:function(){return Hy(Gl)},useDebugValue:C2,useDeferredValue:function(h,m){var _=Xr();return bI(_,tr.memoizedState,h,m)},useTransition:function(){var h=Hy(Gl)[0],m=Xr().memoizedState;return[typeof h=="boolean"?h:qg(h),m]},useSyncExternalStore:q4,useId:wI,useHostTransitionStatus:j2,useFormState:sI,useActionState:sI,useOptimistic:function(h,m){var _=Xr();return J4(_,tr,h,m)},useMemoCache:S2,useCacheRefresh:SI};D2.useEffectEvent=dI;var NI={readContext:Xi,use:By,useCallback:gI,useContext:Xi,useEffect:N2,useImperativeHandle:pI,useInsertionEffect:hI,useLayoutEffect:fI,useMemo:xI,useReducer:E2,useRef:cI,useState:function(){return E2(Gl)},useDebugValue:C2,useDeferredValue:function(h,m){var _=Xr();return tr===null?k2(_,h,m):bI(_,tr.memoizedState,h,m)},useTransition:function(){var h=E2(Gl)[0],m=Xr().memoizedState;return[typeof h=="boolean"?h:qg(h),m]},useSyncExternalStore:q4,useId:wI,useHostTransitionStatus:j2,useFormState:lI,useActionState:lI,useOptimistic:function(h,m){var _=Xr();return tr!==null?J4(_,tr,h,m):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:S2,useCacheRefresh:SI};NI.useEffectEvent=dI;function O2(h,m,_,M){m=h.memoizedState,_=_(M,m),_=_==null?m:f({},m,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var L2={enqueueSetState:function(h,m,_){h=h._reactInternals;var M=xs(),P=lu(M);P.payload=m,_!=null&&(P.callback=_),m=cu(h,P,M),m!==null&&(qa(m,h,M),$g(m,h,M))},enqueueReplaceState:function(h,m,_){h=h._reactInternals;var M=xs(),P=lu(M);P.tag=1,P.payload=m,_!=null&&(P.callback=_),m=cu(h,P,M),m!==null&&(qa(m,h,M),$g(m,h,M))},enqueueForceUpdate:function(h,m){h=h._reactInternals;var _=xs(),M=lu(_);M.tag=2,m!=null&&(M.callback=m),m=cu(h,M,_),m!==null&&(qa(m,h,_),$g(m,h,_))}};function CI(h,m,_,M,P,D,Y){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(M,D,Y):m.prototype&&m.prototype.isPureReactComponent?!Og(_,M)||!Og(P,D):!0}function kI(h,m,_,M){h=m.state,typeof m.componentWillReceiveProps=="function"&&m.componentWillReceiveProps(_,M),typeof m.UNSAFE_componentWillReceiveProps=="function"&&m.UNSAFE_componentWillReceiveProps(_,M),m.state!==h&&L2.enqueueReplaceState(m,m.state,null)}function Zd(h,m){var _=m;if("ref"in m){_={};for(var M in m)M!=="ref"&&(_[M]=m[M])}if(h=h.defaultProps){_===m&&(_=f({},_));for(var P in h)_[P]===void 0&&(_[P]=h[P])}return _}function PI(h){Sy(h)}function jI(h){console.error(h)}function RI(h){Sy(h)}function Wy(h,m){try{var _=h.onUncaughtError;_(m.value,{componentStack:m.stack})}catch(M){setTimeout(function(){throw M})}}function DI(h,m,_){try{var M=h.onCaughtError;M(_.value,{componentStack:_.stack,errorBoundary:m.tag===1?m.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function I2(h,m,_){return _=lu(_),_.tag=3,_.payload={element:null},_.callback=function(){Wy(h,m)},_}function OI(h){return h=lu(h),h.tag=3,h}function LI(h,m,_,M){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var D=M.value;h.payload=function(){return P(D)},h.callback=function(){DI(m,_,M)}}var Y=_.stateNode;Y!==null&&typeof Y.componentDidCatch=="function"&&(h.callback=function(){DI(m,_,M),typeof P!="function"&&(pu===null?pu=new Set([this]):pu.add(this));var ce=M.stack;this.componentDidCatch(M.value,{componentStack:ce!==null?ce:""})})}function Zne(h,m,_,M,P){if(_.flags|=32768,M!==null&&typeof M=="object"&&typeof M.then=="function"){if(m=_.alternate,m!==null&&Bf(m,_,P,!0),_=fs.current,_!==null){switch(_.tag){case 31:case 13:return zs===null?iv():_.alternate===null&&Br===0&&(Br=3),_.flags&=-257,_.flags|=65536,_.lanes=P,M===Ry?_.flags|=16384:(m=_.updateQueue,m===null?_.updateQueue=new Set([M]):m.add(M),lA(h,M,P)),!1;case 22:return _.flags|=65536,M===Ry?_.flags|=16384:(m=_.updateQueue,m===null?(m={transitions:null,markerInstances:null,retryQueue:new Set([M])},_.updateQueue=m):(_=m.retryQueue,_===null?m.retryQueue=new Set([M]):_.add(M)),lA(h,M,P)),!1}throw Error(r(435,_.tag))}return lA(h,M,P),iv(),!1}if(Cn)return m=fs.current,m!==null?((m.flags&65536)===0&&(m.flags|=256),m.flags|=65536,m.lanes=P,M!==n2&&(h=Error(r(422),{cause:M}),Fg(Ls(h,_)))):(M!==n2&&(m=Error(r(423),{cause:M}),Fg(Ls(m,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,M=Ls(M,_),P=I2(h.stateNode,M,P),f2(h,P),Br!==4&&(Br=2)),!1;var D=Error(r(520),{cause:M});if(D=Ls(D,_),rx===null?rx=[D]:rx.push(D),Br!==4&&(Br=2),m===null)return!0;M=Ls(M,_),_=m;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=I2(_.stateNode,M,h),f2(_,h),!1;case 1:if(m=_.type,D=_.stateNode,(_.flags&128)===0&&(typeof m.getDerivedStateFromError=="function"||D!==null&&typeof D.componentDidCatch=="function"&&(pu===null||!pu.has(D))))return _.flags|=65536,P&=-P,_.lanes|=P,P=OI(P),LI(P,h,_,M),f2(_,P),!1}_=_.return}while(_!==null);return!1}var F2=Error(r(461)),ri=!1;function Yi(h,m,_,M){m.child=h===null?z4(m,null,_,M):Xd(m,h.child,_,M)}function II(h,m,_,M,P){_=_.render;var D=m.ref;if("ref"in M){var Y={};for(var ce in M)ce!=="ref"&&(Y[ce]=M[ce])}else Y=M;return Gd(m),M=y2(h,m,_,Y,D,P),ce=v2(),h!==null&&!ri?(_2(h,m,P),Wl(h,m,P)):(Cn&&ce&&e2(m),m.flags|=1,Yi(h,m,M,P),m.child)}function FI(h,m,_,M,P){if(h===null){var D=_.type;return typeof D=="function"&&!ZE(D)&&D.defaultProps===void 0&&_.compare===null?(m.tag=15,m.type=D,UI(h,m,D,M,P)):(h=Ty(_.type,null,M,m,m.mode,P),h.ref=m.ref,h.return=m,m.child=h)}if(D=h.child,!W2(h,P)){var Y=D.memoizedProps;if(_=_.compare,_=_!==null?_:Og,_(Y,M)&&h.ref===m.ref)return Wl(h,m,P)}return m.flags|=1,h=zl(D,M),h.ref=m.ref,h.return=m,m.child=h}function UI(h,m,_,M,P){if(h!==null){var D=h.memoizedProps;if(Og(D,M)&&h.ref===m.ref)if(ri=!1,m.pendingProps=M=D,W2(h,P))(h.flags&131072)!==0&&(ri=!0);else return m.lanes=h.lanes,Wl(h,m,P)}return U2(h,m,_,M,P)}function zI(h,m,_,M){var P=M.children,D=h!==null?h.memoizedState:null;if(h===null&&m.stateNode===null&&(m.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),M.mode==="hidden"){if((m.flags&128)!==0){if(D=D!==null?D.baseLanes|_:_,h!==null){for(M=m.child=h.child,P=0;M!==null;)P=P|M.lanes|M.childLanes,M=M.sibling;M=P&~D}else M=0,m.child=null;return BI(h,m,D,_,M)}if((_&536870912)!==0)m.memoizedState={baseLanes:0,cachePool:null},h!==null&&Py(m,D!==null?D.cachePool:null),D!==null?$4(m,D):p2(),V4(m);else return M=m.lanes=536870912,BI(h,m,D!==null?D.baseLanes|_:_,_,M)}else D!==null?(Py(m,D.cachePool),$4(m,D),du(),m.memoizedState=null):(h!==null&&Py(m,null),p2(),du());return Yi(h,m,P,_),m.child}function Yg(h,m){return h!==null&&h.tag===22||m.stateNode!==null||(m.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),m.sibling}function BI(h,m,_,M,P){var D=c2();return D=D===null?null:{parent:ti._currentValue,pool:D},m.memoizedState={baseLanes:_,cachePool:D},h!==null&&Py(m,null),p2(),V4(m),h!==null&&Bf(h,m,M,!0),m.childLanes=P,null}function qy(h,m){return m=Xy({mode:m.mode,children:m.children},h.mode),m.ref=h.ref,h.child=m,m.return=h,m}function HI(h,m,_){return Xd(m,h.child,null,_),h=qy(m,m.pendingProps),h.flags|=2,ms(m),m.memoizedState=null,h}function Qne(h,m,_){var M=m.pendingProps,P=(m.flags&128)!==0;if(m.flags&=-129,h===null){if(Cn){if(M.mode==="hidden")return h=qy(m,M),m.lanes=536870912,Yg(null,h);if(x2(m),(h=vr)?(h=eF(h,Us),h=h!==null&&h.data==="&"?h:null,h!==null&&(m.memoizedState={dehydrated:h,treeContext:ru!==null?{id:Qo,overflow:Jo}:null,retryLane:536870912,hydrationErrors:null},_=E4(h),_.return=m,m.child=_,Ki=m,vr=null)):h=null,h===null)throw au(m);return m.lanes=536870912,null}return qy(m,M)}var D=h.memoizedState;if(D!==null){var Y=D.dehydrated;if(x2(m),P)if(m.flags&256)m.flags&=-257,m=HI(h,m,_);else if(m.memoizedState!==null)m.child=h.child,m.flags|=128,m=null;else throw Error(r(558));else if(ri||Bf(h,m,_,!1),P=(_&h.childLanes)!==0,ri||P){if(M=hr,M!==null&&(Y=Fn(M,_),Y!==0&&Y!==D.retryLane))throw D.retryLane=Y,Bd(h,Y),qa(M,h,Y),F2;iv(),m=HI(h,m,_)}else h=D.treeContext,vr=Bs(Y.nextSibling),Ki=m,Cn=!0,iu=null,Us=!1,h!==null&&N4(m,h),m=qy(m,M),m.flags|=4096;return m}return h=zl(h.child,{mode:M.mode,children:M.children}),h.ref=m.ref,m.child=h,h.return=m,h}function Ky(h,m){var _=m.ref;if(_===null)h!==null&&h.ref!==null&&(m.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(m.flags|=4194816)}}function U2(h,m,_,M,P){return Gd(m),_=y2(h,m,_,M,void 0,P),M=v2(),h!==null&&!ri?(_2(h,m,P),Wl(h,m,P)):(Cn&&M&&e2(m),m.flags|=1,Yi(h,m,_,P),m.child)}function $I(h,m,_,M,P,D){return Gd(m),m.updateQueue=null,_=W4(m,M,_,P),G4(h),M=v2(),h!==null&&!ri?(_2(h,m,D),Wl(h,m,D)):(Cn&&M&&e2(m),m.flags|=1,Yi(h,m,_,D),m.child)}function VI(h,m,_,M,P){if(Gd(m),m.stateNode===null){var D=If,Y=_.contextType;typeof Y=="object"&&Y!==null&&(D=Xi(Y)),D=new _(M,D),m.memoizedState=D.state!==null&&D.state!==void 0?D.state:null,D.updater=L2,m.stateNode=D,D._reactInternals=m,D=m.stateNode,D.props=M,D.state=m.memoizedState,D.refs={},d2(m),Y=_.contextType,D.context=typeof Y=="object"&&Y!==null?Xi(Y):If,D.state=m.memoizedState,Y=_.getDerivedStateFromProps,typeof Y=="function"&&(O2(m,_,Y,M),D.state=m.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof D.getSnapshotBeforeUpdate=="function"||typeof D.UNSAFE_componentWillMount!="function"&&typeof D.componentWillMount!="function"||(Y=D.state,typeof D.componentWillMount=="function"&&D.componentWillMount(),typeof D.UNSAFE_componentWillMount=="function"&&D.UNSAFE_componentWillMount(),Y!==D.state&&L2.enqueueReplaceState(D,D.state,null),Gg(m,M,D,P),Vg(),D.state=m.memoizedState),typeof D.componentDidMount=="function"&&(m.flags|=4194308),M=!0}else if(h===null){D=m.stateNode;var ce=m.memoizedProps,Ce=Zd(_,ce);D.props=Ce;var tt=D.context,dt=_.contextType;Y=If,typeof dt=="object"&&dt!==null&&(Y=Xi(dt));var mt=_.getDerivedStateFromProps;dt=typeof mt=="function"||typeof D.getSnapshotBeforeUpdate=="function",ce=m.pendingProps!==ce,dt||typeof D.UNSAFE_componentWillReceiveProps!="function"&&typeof D.componentWillReceiveProps!="function"||(ce||tt!==Y)&&kI(m,D,M,Y),ou=!1;var it=m.memoizedState;D.state=it,Gg(m,M,D,P),Vg(),tt=m.memoizedState,ce||it!==tt||ou?(typeof mt=="function"&&(O2(m,_,mt,M),tt=m.memoizedState),(Ce=ou||CI(m,_,Ce,M,it,tt,Y))?(dt||typeof D.UNSAFE_componentWillMount!="function"&&typeof D.componentWillMount!="function"||(typeof D.componentWillMount=="function"&&D.componentWillMount(),typeof D.UNSAFE_componentWillMount=="function"&&D.UNSAFE_componentWillMount()),typeof D.componentDidMount=="function"&&(m.flags|=4194308)):(typeof D.componentDidMount=="function"&&(m.flags|=4194308),m.memoizedProps=M,m.memoizedState=tt),D.props=M,D.state=tt,D.context=Y,M=Ce):(typeof D.componentDidMount=="function"&&(m.flags|=4194308),M=!1)}else{D=m.stateNode,h2(h,m),Y=m.memoizedProps,dt=Zd(_,Y),D.props=dt,mt=m.pendingProps,it=D.context,tt=_.contextType,Ce=If,typeof tt=="object"&&tt!==null&&(Ce=Xi(tt)),ce=_.getDerivedStateFromProps,(tt=typeof ce=="function"||typeof D.getSnapshotBeforeUpdate=="function")||typeof D.UNSAFE_componentWillReceiveProps!="function"&&typeof D.componentWillReceiveProps!="function"||(Y!==mt||it!==Ce)&&kI(m,D,M,Ce),ou=!1,it=m.memoizedState,D.state=it,Gg(m,M,D,P),Vg();var ot=m.memoizedState;Y!==mt||it!==ot||ou||h!==null&&h.dependencies!==null&&Cy(h.dependencies)?(typeof ce=="function"&&(O2(m,_,ce,M),ot=m.memoizedState),(dt=ou||CI(m,_,dt,M,it,ot,Ce)||h!==null&&h.dependencies!==null&&Cy(h.dependencies))?(tt||typeof D.UNSAFE_componentWillUpdate!="function"&&typeof D.componentWillUpdate!="function"||(typeof D.componentWillUpdate=="function"&&D.componentWillUpdate(M,ot,Ce),typeof D.UNSAFE_componentWillUpdate=="function"&&D.UNSAFE_componentWillUpdate(M,ot,Ce)),typeof D.componentDidUpdate=="function"&&(m.flags|=4),typeof D.getSnapshotBeforeUpdate=="function"&&(m.flags|=1024)):(typeof D.componentDidUpdate!="function"||Y===h.memoizedProps&&it===h.memoizedState||(m.flags|=4),typeof D.getSnapshotBeforeUpdate!="function"||Y===h.memoizedProps&&it===h.memoizedState||(m.flags|=1024),m.memoizedProps=M,m.memoizedState=ot),D.props=M,D.state=ot,D.context=Ce,M=dt):(typeof D.componentDidUpdate!="function"||Y===h.memoizedProps&&it===h.memoizedState||(m.flags|=4),typeof D.getSnapshotBeforeUpdate!="function"||Y===h.memoizedProps&&it===h.memoizedState||(m.flags|=1024),M=!1)}return D=M,Ky(h,m),M=(m.flags&128)!==0,D||M?(D=m.stateNode,_=M&&typeof _.getDerivedStateFromError!="function"?null:D.render(),m.flags|=1,h!==null&&M?(m.child=Xd(m,h.child,null,P),m.child=Xd(m,null,_,P)):Yi(h,m,_,P),m.memoizedState=D.state,h=m.child):h=Wl(h,m,P),h}function GI(h,m,_,M){return $d(),m.flags|=256,Yi(h,m,_,M),m.child}var z2={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function B2(h){return{baseLanes:h,cachePool:D4()}}function H2(h,m,_){return h=h!==null?h.childLanes&~_:0,m&&(h|=gs),h}function WI(h,m,_){var M=m.pendingProps,P=!1,D=(m.flags&128)!==0,Y;if((Y=D)||(Y=h!==null&&h.memoizedState===null?!1:(Kr.current&2)!==0),Y&&(P=!0,m.flags&=-129),Y=(m.flags&32)!==0,m.flags&=-33,h===null){if(Cn){if(P?uu(m):du(),(h=vr)?(h=eF(h,Us),h=h!==null&&h.data!=="&"?h:null,h!==null&&(m.memoizedState={dehydrated:h,treeContext:ru!==null?{id:Qo,overflow:Jo}:null,retryLane:536870912,hydrationErrors:null},_=E4(h),_.return=m,m.child=_,Ki=m,vr=null)):h=null,h===null)throw au(m);return MA(h)?m.lanes=32:m.lanes=536870912,null}var ce=M.children;return M=M.fallback,P?(du(),P=m.mode,ce=Xy({mode:"hidden",children:ce},P),M=Hd(M,P,_,null),ce.return=m,M.return=m,ce.sibling=M,m.child=ce,M=m.child,M.memoizedState=B2(_),M.childLanes=H2(h,Y,_),m.memoizedState=z2,Yg(null,M)):(uu(m),$2(m,ce))}var Ce=h.memoizedState;if(Ce!==null&&(ce=Ce.dehydrated,ce!==null)){if(D)m.flags&256?(uu(m),m.flags&=-257,m=V2(h,m,_)):m.memoizedState!==null?(du(),m.child=h.child,m.flags|=128,m=null):(du(),ce=M.fallback,P=m.mode,M=Xy({mode:"visible",children:M.children},P),ce=Hd(ce,P,_,null),ce.flags|=2,M.return=m,ce.return=m,M.sibling=ce,m.child=M,Xd(m,h.child,null,_),M=m.child,M.memoizedState=B2(_),M.childLanes=H2(h,Y,_),m.memoizedState=z2,m=Yg(null,M));else if(uu(m),MA(ce)){if(Y=ce.nextSibling&&ce.nextSibling.dataset,Y)var tt=Y.dgst;Y=tt,M=Error(r(419)),M.stack="",M.digest=Y,Fg({value:M,source:null,stack:null}),m=V2(h,m,_)}else if(ri||Bf(h,m,_,!1),Y=(_&h.childLanes)!==0,ri||Y){if(Y=hr,Y!==null&&(M=Fn(Y,_),M!==0&&M!==Ce.retryLane))throw Ce.retryLane=M,Bd(h,M),qa(Y,h,M),F2;SA(ce)||iv(),m=V2(h,m,_)}else SA(ce)?(m.flags|=192,m.child=h.child,m=null):(h=Ce.treeContext,vr=Bs(ce.nextSibling),Ki=m,Cn=!0,iu=null,Us=!1,h!==null&&N4(m,h),m=$2(m,M.children),m.flags|=4096);return m}return P?(du(),ce=M.fallback,P=m.mode,Ce=h.child,tt=Ce.sibling,M=zl(Ce,{mode:"hidden",children:M.children}),M.subtreeFlags=Ce.subtreeFlags&65011712,tt!==null?ce=zl(tt,ce):(ce=Hd(ce,P,_,null),ce.flags|=2),ce.return=m,M.return=m,M.sibling=ce,m.child=M,Yg(null,M),M=m.child,ce=h.child.memoizedState,ce===null?ce=B2(_):(P=ce.cachePool,P!==null?(Ce=ti._currentValue,P=P.parent!==Ce?{parent:Ce,pool:Ce}:P):P=D4(),ce={baseLanes:ce.baseLanes|_,cachePool:P}),M.memoizedState=ce,M.childLanes=H2(h,Y,_),m.memoizedState=z2,Yg(h.child,M)):(uu(m),_=h.child,h=_.sibling,_=zl(_,{mode:"visible",children:M.children}),_.return=m,_.sibling=null,h!==null&&(Y=m.deletions,Y===null?(m.deletions=[h],m.flags|=16):Y.push(h)),m.child=_,m.memoizedState=null,_)}function $2(h,m){return m=Xy({mode:"visible",children:m},h.mode),m.return=h,h.child=m}function Xy(h,m){return h=hs(22,h,null,m),h.lanes=0,h}function V2(h,m,_){return Xd(m,h.child,null,_),h=$2(m,m.pendingProps.children),h.flags|=2,m.memoizedState=null,h}function qI(h,m,_){h.lanes|=m;var M=h.alternate;M!==null&&(M.lanes|=m),a2(h.return,m,_)}function G2(h,m,_,M,P,D){var Y=h.memoizedState;Y===null?h.memoizedState={isBackwards:m,rendering:null,renderingStartTime:0,last:M,tail:_,tailMode:P,treeForkCount:D}:(Y.isBackwards=m,Y.rendering=null,Y.renderingStartTime=0,Y.last=M,Y.tail=_,Y.tailMode=P,Y.treeForkCount=D)}function KI(h,m,_){var M=m.pendingProps,P=M.revealOrder,D=M.tail;M=M.children;var Y=Kr.current,ce=(Y&2)!==0;if(ce?(Y=Y&1|2,m.flags|=128):Y&=1,X(Kr,Y),Yi(h,m,M,_),M=Cn?Ig:0,!ce&&h!==null&&(h.flags&128)!==0)e:for(h=m.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&qI(h,_,m);else if(h.tag===19)qI(h,_,m);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===m)break e;for(;h.sibling===null;){if(h.return===null||h.return===m)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(P){case"forwards":for(_=m.child,P=null;_!==null;)h=_.alternate,h!==null&&Iy(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=m.child,m.child=null):(P=_.sibling,_.sibling=null),G2(m,!1,P,_,D,M);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=m.child,m.child=null;P!==null;){if(h=P.alternate,h!==null&&Iy(h)===null){m.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}G2(m,!0,_,null,D,M);break;case"together":G2(m,!1,null,null,void 0,M);break;default:m.memoizedState=null}return m.child}function Wl(h,m,_){if(h!==null&&(m.dependencies=h.dependencies),mu|=m.lanes,(_&m.childLanes)===0)if(h!==null){if(Bf(h,m,_,!1),(_&m.childLanes)===0)return null}else return null;if(h!==null&&m.child!==h.child)throw Error(r(153));if(m.child!==null){for(h=m.child,_=zl(h,h.pendingProps),m.child=_,_.return=m;h.sibling!==null;)h=h.sibling,_=_.sibling=zl(h,h.pendingProps),_.return=m;_.sibling=null}return m.child}function W2(h,m){return(h.lanes&m)!==0?!0:(h=h.dependencies,!!(h!==null&&Cy(h)))}function Jne(h,m,_){switch(m.tag){case 3:Ee(m,m.stateNode.containerInfo),su(m,ti,h.memoizedState.cache),$d();break;case 27:case 5:de(m);break;case 4:Ee(m,m.stateNode.containerInfo);break;case 10:su(m,m.type,m.memoizedProps.value);break;case 31:if(m.memoizedState!==null)return m.flags|=128,x2(m),null;break;case 13:var M=m.memoizedState;if(M!==null)return M.dehydrated!==null?(uu(m),m.flags|=128,null):(_&m.child.childLanes)!==0?WI(h,m,_):(uu(m),h=Wl(h,m,_),h!==null?h.sibling:null);uu(m);break;case 19:var P=(h.flags&128)!==0;if(M=(_&m.childLanes)!==0,M||(Bf(h,m,_,!1),M=(_&m.childLanes)!==0),P){if(M)return KI(h,m,_);m.flags|=128}if(P=m.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),X(Kr,Kr.current),M)break;return null;case 22:return m.lanes=0,zI(h,m,_,m.pendingProps);case 24:su(m,ti,h.memoizedState.cache)}return Wl(h,m,_)}function XI(h,m,_){if(h!==null)if(h.memoizedProps!==m.pendingProps)ri=!0;else{if(!W2(h,_)&&(m.flags&128)===0)return ri=!1,Jne(h,m,_);ri=(h.flags&131072)!==0}else ri=!1,Cn&&(m.flags&1048576)!==0&&T4(m,Ig,m.index);switch(m.lanes=0,m.tag){case 16:e:{var M=m.pendingProps;if(h=qd(m.elementType),m.type=h,typeof h=="function")ZE(h)?(M=Zd(h,M),m.tag=1,m=VI(null,m,h,M,_)):(m.tag=0,m=U2(null,m,h,M,_));else{if(h!=null){var P=h.$$typeof;if(P===A){m.tag=11,m=II(null,m,h,M,_);break e}else if(P===N){m.tag=14,m=FI(null,m,h,M,_);break e}}throw m=R(h)||h,Error(r(306,m,""))}}return m;case 0:return U2(h,m,m.type,m.pendingProps,_);case 1:return M=m.type,P=Zd(M,m.pendingProps),VI(h,m,M,P,_);case 3:e:{if(Ee(m,m.stateNode.containerInfo),h===null)throw Error(r(387));M=m.pendingProps;var D=m.memoizedState;P=D.element,h2(h,m),Gg(m,M,null,_);var Y=m.memoizedState;if(M=Y.cache,su(m,ti,M),M!==D.cache&&s2(m,[ti],_,!0),Vg(),M=Y.element,D.isDehydrated)if(D={element:M,isDehydrated:!1,cache:Y.cache},m.updateQueue.baseState=D,m.memoizedState=D,m.flags&256){m=GI(h,m,M,_);break e}else if(M!==P){P=Ls(Error(r(424)),m),Fg(P),m=GI(h,m,M,_);break e}else{switch(h=m.stateNode.containerInfo,h.nodeType){case 9:h=h.body;break;default:h=h.nodeName==="HTML"?h.ownerDocument.body:h}for(vr=Bs(h.firstChild),Ki=m,Cn=!0,iu=null,Us=!0,_=z4(m,null,M,_),m.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if($d(),M===P){m=Wl(h,m,_);break e}Yi(h,m,M,_)}m=m.child}return m;case 26:return Ky(h,m),h===null?(_=sF(m.type,null,m.pendingProps,null))?m.memoizedState=_:Cn||(_=m.type,h=m.pendingProps,M=dv(le.current).createElement(_),M[Un]=m,M[jn]=h,Zi(M,_,h),Ie(M),m.stateNode=M):m.memoizedState=sF(m.type,h.memoizedProps,m.pendingProps,h.memoizedState),null;case 27:return de(m),h===null&&Cn&&(M=m.stateNode=rF(m.type,m.pendingProps,le.current),Ki=m,Us=!0,P=vr,yu(m.type)?(EA=P,vr=Bs(M.firstChild)):vr=P),Yi(h,m,m.pendingProps.children,_),Ky(h,m),h===null&&(m.flags|=4194304),m.child;case 5:return h===null&&Cn&&((P=M=vr)&&(M=Cre(M,m.type,m.pendingProps,Us),M!==null?(m.stateNode=M,Ki=m,vr=Bs(M.firstChild),Us=!1,P=!0):P=!1),P||au(m)),de(m),P=m.type,D=m.pendingProps,Y=h!==null?h.memoizedProps:null,M=D.children,vA(P,D)?M=null:Y!==null&&vA(P,Y)&&(m.flags|=32),m.memoizedState!==null&&(P=y2(h,m,Vne,null,null,_),dx._currentValue=P),Ky(h,m),Yi(h,m,M,_),m.child;case 6:return h===null&&Cn&&((h=_=vr)&&(_=kre(_,m.pendingProps,Us),_!==null?(m.stateNode=_,Ki=m,vr=null,h=!0):h=!1),h||au(m)),null;case 13:return WI(h,m,_);case 4:return Ee(m,m.stateNode.containerInfo),M=m.pendingProps,h===null?m.child=Xd(m,null,M,_):Yi(h,m,M,_),m.child;case 11:return II(h,m,m.type,m.pendingProps,_);case 7:return Yi(h,m,m.pendingProps,_),m.child;case 8:return Yi(h,m,m.pendingProps.children,_),m.child;case 12:return Yi(h,m,m.pendingProps.children,_),m.child;case 10:return M=m.pendingProps,su(m,m.type,M.value),Yi(h,m,M.children,_),m.child;case 9:return P=m.type._context,M=m.pendingProps.children,Gd(m),P=Xi(P),M=M(P),m.flags|=1,Yi(h,m,M,_),m.child;case 14:return FI(h,m,m.type,m.pendingProps,_);case 15:return UI(h,m,m.type,m.pendingProps,_);case 19:return KI(h,m,_);case 31:return Qne(h,m,_);case 22:return zI(h,m,_,m.pendingProps);case 24:return Gd(m),M=Xi(ti),h===null?(P=c2(),P===null&&(P=hr,D=o2(),P.pooledCache=D,D.refCount++,D!==null&&(P.pooledCacheLanes|=_),P=D),m.memoizedState={parent:M,cache:P},d2(m),su(m,ti,P)):((h.lanes&_)!==0&&(h2(h,m),Gg(m,null,null,_),Vg()),P=h.memoizedState,D=m.memoizedState,P.parent!==M?(P={parent:M,cache:M},m.memoizedState=P,m.lanes===0&&(m.memoizedState=m.updateQueue.baseState=P),su(m,ti,M)):(M=D.cache,su(m,ti,M),M!==P.cache&&s2(m,[ti],_,!0))),Yi(h,m,m.pendingProps.children,_),m.child;case 29:throw m.pendingProps}throw Error(r(156,m.tag))}function ql(h){h.flags|=4}function q2(h,m,_,M,P){if((m=(h.mode&32)!==0)&&(m=!1),m){if(h.flags|=16777216,(P&335544128)===P)if(h.stateNode.complete)h.flags|=8192;else if(w5())h.flags|=8192;else throw Kd=Ry,u2}else h.flags&=-16777217}function YI(h,m){if(m.type!=="stylesheet"||(m.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!dF(m))if(w5())h.flags|=8192;else throw Kd=Ry,u2}function Yy(h,m){m!==null&&(h.flags|=4),h.flags&16384&&(m=h.tag!==22?_t():536870912,h.lanes|=m,Jf|=m)}function Zg(h,m){if(!Cn)switch(h.tailMode){case"hidden":m=h.tail;for(var _=null;m!==null;)m.alternate!==null&&(_=m),m=m.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var M=null;_!==null;)_.alternate!==null&&(M=_),_=_.sibling;M===null?m||h.tail===null?h.tail=null:h.tail.sibling=null:M.sibling=null}}function _r(h){var m=h.alternate!==null&&h.alternate.child===h.child,_=0,M=0;if(m)for(var P=h.child;P!==null;)_|=P.lanes|P.childLanes,M|=P.subtreeFlags&65011712,M|=P.flags&65011712,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)_|=P.lanes|P.childLanes,M|=P.subtreeFlags,M|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=M,h.childLanes=_,m}function ere(h,m,_){var M=m.pendingProps;switch(t2(m),m.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return _r(m),null;case 1:return _r(m),null;case 3:return _=m.stateNode,M=null,h!==null&&(M=h.memoizedState.cache),m.memoizedState.cache!==M&&(m.flags|=2048),$l(ti),pe(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(zf(m)?ql(m):h===null||h.memoizedState.isDehydrated&&(m.flags&256)===0||(m.flags|=1024,r2())),_r(m),null;case 26:var P=m.type,D=m.memoizedState;return h===null?(ql(m),D!==null?(_r(m),YI(m,D)):(_r(m),q2(m,P,null,M,_))):D?D!==h.memoizedState?(ql(m),_r(m),YI(m,D)):(_r(m),m.flags&=-16777217):(h=h.memoizedProps,h!==M&&ql(m),_r(m),q2(m,P,h,M,_)),null;case 27:if(Re(m),_=le.current,P=m.type,h!==null&&m.stateNode!=null)h.memoizedProps!==M&&ql(m);else{if(!M){if(m.stateNode===null)throw Error(r(166));return _r(m),null}h=te.current,zf(m)?C4(m):(h=rF(P,M,_),m.stateNode=h,ql(m))}return _r(m),null;case 5:if(Re(m),P=m.type,h!==null&&m.stateNode!=null)h.memoizedProps!==M&&ql(m);else{if(!M){if(m.stateNode===null)throw Error(r(166));return _r(m),null}if(D=te.current,zf(m))C4(m);else{var Y=dv(le.current);switch(D){case 1:D=Y.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:D=Y.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":D=Y.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":D=Y.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":D=Y.createElement("div"),D.innerHTML="<script><\/script>",D=D.removeChild(D.firstChild);break;case"select":D=typeof M.is=="string"?Y.createElement("select",{is:M.is}):Y.createElement("select"),M.multiple?D.multiple=!0:M.size&&(D.size=M.size);break;default:D=typeof M.is=="string"?Y.createElement(P,{is:M.is}):Y.createElement(P)}}D[Un]=m,D[jn]=M;e:for(Y=m.child;Y!==null;){if(Y.tag===5||Y.tag===6)D.appendChild(Y.stateNode);else if(Y.tag!==4&&Y.tag!==27&&Y.child!==null){Y.child.return=Y,Y=Y.child;continue}if(Y===m)break e;for(;Y.sibling===null;){if(Y.return===null||Y.return===m)break e;Y=Y.return}Y.sibling.return=Y.return,Y=Y.sibling}m.stateNode=D;e:switch(Zi(D,P,M),P){case"button":case"input":case"select":case"textarea":M=!!M.autoFocus;break e;case"img":M=!0;break e;default:M=!1}M&&ql(m)}}return _r(m),q2(m,m.type,h===null?null:h.memoizedProps,m.pendingProps,_),null;case 6:if(h&&m.stateNode!=null)h.memoizedProps!==M&&ql(m);else{if(typeof M!="string"&&m.stateNode===null)throw Error(r(166));if(h=le.current,zf(m)){if(h=m.stateNode,_=m.memoizedProps,M=null,P=Ki,P!==null)switch(P.tag){case 27:case 5:M=P.memoizedProps}h[Un]=m,h=!!(h.nodeValue===_||M!==null&&M.suppressHydrationWarning===!0||W5(h.nodeValue,_)),h||au(m,!0)}else h=dv(h).createTextNode(M),h[Un]=m,m.stateNode=h}return _r(m),null;case 31:if(_=m.memoizedState,h===null||h.memoizedState!==null){if(M=zf(m),_!==null){if(h===null){if(!M)throw Error(r(318));if(h=m.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[Un]=m}else $d(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;_r(m),h=!1}else _=r2(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return m.flags&256?(ms(m),m):(ms(m),null);if((m.flags&128)!==0)throw Error(r(558))}return _r(m),null;case 13:if(M=m.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=zf(m),M!==null&&M.dehydrated!==null){if(h===null){if(!P)throw Error(r(318));if(P=m.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(r(317));P[Un]=m}else $d(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;_r(m),P=!1}else P=r2(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=P),P=!0;if(!P)return m.flags&256?(ms(m),m):(ms(m),null)}return ms(m),(m.flags&128)!==0?(m.lanes=_,m):(_=M!==null,h=h!==null&&h.memoizedState!==null,_&&(M=m.child,P=null,M.alternate!==null&&M.alternate.memoizedState!==null&&M.alternate.memoizedState.cachePool!==null&&(P=M.alternate.memoizedState.cachePool.pool),D=null,M.memoizedState!==null&&M.memoizedState.cachePool!==null&&(D=M.memoizedState.cachePool.pool),D!==P&&(M.flags|=2048)),_!==h&&_&&(m.child.flags|=8192),Yy(m,m.updateQueue),_r(m),null);case 4:return pe(),h===null&&pA(m.stateNode.containerInfo),_r(m),null;case 10:return $l(m.type),_r(m),null;case 19:if(V(Kr),M=m.memoizedState,M===null)return _r(m),null;if(P=(m.flags&128)!==0,D=M.rendering,D===null)if(P)Zg(M,!1);else{if(Br!==0||h!==null&&(h.flags&128)!==0)for(h=m.child;h!==null;){if(D=Iy(h),D!==null){for(m.flags|=128,Zg(M,!1),h=D.updateQueue,m.updateQueue=h,Yy(m,h),m.subtreeFlags=0,h=_,_=m.child;_!==null;)M4(_,h),_=_.sibling;return X(Kr,Kr.current&1|2),Cn&&Bl(m,M.treeForkCount),m.child}h=h.sibling}M.tail!==null&&I()>tv&&(m.flags|=128,P=!0,Zg(M,!1),m.lanes=4194304)}else{if(!P)if(h=Iy(D),h!==null){if(m.flags|=128,P=!0,h=h.updateQueue,m.updateQueue=h,Yy(m,h),Zg(M,!0),M.tail===null&&M.tailMode==="hidden"&&!D.alternate&&!Cn)return _r(m),null}else 2*I()-M.renderingStartTime>tv&&_!==536870912&&(m.flags|=128,P=!0,Zg(M,!1),m.lanes=4194304);M.isBackwards?(D.sibling=m.child,m.child=D):(h=M.last,h!==null?h.sibling=D:m.child=D,M.last=D)}return M.tail!==null?(h=M.tail,M.rendering=h,M.tail=h.sibling,M.renderingStartTime=I(),h.sibling=null,_=Kr.current,X(Kr,P?_&1|2:_&1),Cn&&Bl(m,M.treeForkCount),h):(_r(m),null);case 22:case 23:return ms(m),g2(),M=m.memoizedState!==null,h!==null?h.memoizedState!==null!==M&&(m.flags|=8192):M&&(m.flags|=8192),M?(_&536870912)!==0&&(m.flags&128)===0&&(_r(m),m.subtreeFlags&6&&(m.flags|=8192)):_r(m),_=m.updateQueue,_!==null&&Yy(m,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),M=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(M=m.memoizedState.cachePool.pool),M!==_&&(m.flags|=2048),h!==null&&V(Wd),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),m.memoizedState.cache!==_&&(m.flags|=2048),$l(ti),_r(m),null;case 25:return null;case 30:return null}throw Error(r(156,m.tag))}function tre(h,m){switch(t2(m),m.tag){case 1:return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 3:return $l(ti),pe(),h=m.flags,(h&65536)!==0&&(h&128)===0?(m.flags=h&-65537|128,m):null;case 26:case 27:case 5:return Re(m),null;case 31:if(m.memoizedState!==null){if(ms(m),m.alternate===null)throw Error(r(340));$d()}return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 13:if(ms(m),h=m.memoizedState,h!==null&&h.dehydrated!==null){if(m.alternate===null)throw Error(r(340));$d()}return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 19:return V(Kr),null;case 4:return pe(),null;case 10:return $l(m.type),null;case 22:case 23:return ms(m),g2(),h!==null&&V(Wd),h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 24:return $l(ti),null;case 25:return null;default:return null}}function ZI(h,m){switch(t2(m),m.tag){case 3:$l(ti),pe();break;case 26:case 27:case 5:Re(m);break;case 4:pe();break;case 31:m.memoizedState!==null&&ms(m);break;case 13:ms(m);break;case 19:V(Kr);break;case 10:$l(m.type);break;case 22:case 23:ms(m),g2(),h!==null&&V(Wd);break;case 24:$l(ti)}}function Qg(h,m){try{var _=m.updateQueue,M=_!==null?_.lastEffect:null;if(M!==null){var P=M.next;_=P;do{if((_.tag&h)===h){M=void 0;var D=_.create,Y=_.inst;M=D(),Y.destroy=M}_=_.next}while(_!==P)}}catch(ce){Kn(m,m.return,ce)}}function hu(h,m,_){try{var M=m.updateQueue,P=M!==null?M.lastEffect:null;if(P!==null){var D=P.next;M=D;do{if((M.tag&h)===h){var Y=M.inst,ce=Y.destroy;if(ce!==void 0){Y.destroy=void 0,P=m;var Ce=_,tt=ce;try{tt()}catch(dt){Kn(P,Ce,dt)}}}M=M.next}while(M!==D)}}catch(dt){Kn(m,m.return,dt)}}function QI(h){var m=h.updateQueue;if(m!==null){var _=h.stateNode;try{H4(m,_)}catch(M){Kn(h,h.return,M)}}}function JI(h,m,_){_.props=Zd(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(M){Kn(h,m,M)}}function Jg(h,m){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var M=h.stateNode;break;case 30:M=h.stateNode;break;default:M=h.stateNode}typeof _=="function"?h.refCleanup=_(M):_.current=M}}catch(P){Kn(h,m,P)}}function el(h,m){var _=h.ref,M=h.refCleanup;if(_!==null)if(typeof M=="function")try{M()}catch(P){Kn(h,m,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){Kn(h,m,P)}else _.current=null}function e5(h){var m=h.type,_=h.memoizedProps,M=h.stateNode;try{e:switch(m){case"button":case"input":case"select":case"textarea":_.autoFocus&&M.focus();break e;case"img":_.src?M.src=_.src:_.srcSet&&(M.srcset=_.srcSet)}}catch(P){Kn(h,h.return,P)}}function K2(h,m,_){try{var M=h.stateNode;Sre(M,h.type,_,m),M[jn]=m}catch(P){Kn(h,h.return,P)}}function t5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&yu(h.type)||h.tag===4}function X2(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||t5(h.return))return null;h=h.return}for(h.sibling.return=h.return,h=h.sibling;h.tag!==5&&h.tag!==6&&h.tag!==18;){if(h.tag===27&&yu(h.type)||h.flags&2||h.child===null||h.tag===4)continue e;h.child.return=h,h=h.child}if(!(h.flags&2))return h.stateNode}}function Y2(h,m,_){var M=h.tag;if(M===5||M===6)h=h.stateNode,m?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,m):(m=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,m.appendChild(h),_=_._reactRootContainer,_!=null||m.onclick!==null||(m.onclick=Fl));else if(M!==4&&(M===27&&yu(h.type)&&(_=h.stateNode,m=null),h=h.child,h!==null))for(Y2(h,m,_),h=h.sibling;h!==null;)Y2(h,m,_),h=h.sibling}function Zy(h,m,_){var M=h.tag;if(M===5||M===6)h=h.stateNode,m?_.insertBefore(h,m):_.appendChild(h);else if(M!==4&&(M===27&&yu(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(Zy(h,m,_),h=h.sibling;h!==null;)Zy(h,m,_),h=h.sibling}function n5(h){var m=h.stateNode,_=h.memoizedProps;try{for(var M=h.type,P=m.attributes;P.length;)m.removeAttributeNode(P[0]);Zi(m,M,_),m[Un]=h,m[jn]=_}catch(D){Kn(h,h.return,D)}}var Kl=!1,ii=!1,Z2=!1,r5=typeof WeakSet=="function"?WeakSet:Set,Ri=null;function nre(h,m){if(h=h.containerInfo,bA=bv,h=p4(h),VE(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var M=_.getSelection&&_.getSelection();if(M&&M.rangeCount!==0){_=M.anchorNode;var P=M.anchorOffset,D=M.focusNode;M=M.focusOffset;try{_.nodeType,D.nodeType}catch{_=null;break e}var Y=0,ce=-1,Ce=-1,tt=0,dt=0,mt=h,it=null;t:for(;;){for(var ot;mt!==_||P!==0&&mt.nodeType!==3||(ce=Y+P),mt!==D||M!==0&&mt.nodeType!==3||(Ce=Y+M),mt.nodeType===3&&(Y+=mt.nodeValue.length),(ot=mt.firstChild)!==null;)it=mt,mt=ot;for(;;){if(mt===h)break t;if(it===_&&++tt===P&&(ce=Y),it===D&&++dt===M&&(Ce=Y),(ot=mt.nextSibling)!==null)break;mt=it,it=mt.parentNode}mt=ot}_=ce===-1||Ce===-1?null:{start:ce,end:Ce}}else _=null}_=_||{start:0,end:0}}else _=null;for(yA={focusedElem:h,selectionRange:_},bv=!1,Ri=m;Ri!==null;)if(m=Ri,h=m.child,(m.subtreeFlags&1028)!==0&&h!==null)h.return=m,Ri=h;else for(;Ri!==null;){switch(m=Ri,D=m.alternate,h=m.flags,m.tag){case 0:if((h&4)!==0&&(h=m.updateQueue,h=h!==null?h.events:null,h!==null))for(_=0;_<h.length;_++)P=h[_],P.ref.impl=P.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&D!==null){h=void 0,_=m,P=D.memoizedProps,D=D.memoizedState,M=_.stateNode;try{var Lt=Zd(_.type,P);h=M.getSnapshotBeforeUpdate(Lt,D),M.__reactInternalSnapshotBeforeUpdate=h}catch(Xt){Kn(_,_.return,Xt)}}break;case 3:if((h&1024)!==0){if(h=m.stateNode.containerInfo,_=h.nodeType,_===9)wA(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":wA(h);break;default:h.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((h&1024)!==0)throw Error(r(163))}if(h=m.sibling,h!==null){h.return=m.return,Ri=h;break}Ri=m.return}}function i5(h,m,_){var M=_.flags;switch(_.tag){case 0:case 11:case 15:Yl(h,_),M&4&&Qg(5,_);break;case 1:if(Yl(h,_),M&4)if(h=_.stateNode,m===null)try{h.componentDidMount()}catch(Y){Kn(_,_.return,Y)}else{var P=Zd(_.type,m.memoizedProps);m=m.memoizedState;try{h.componentDidUpdate(P,m,h.__reactInternalSnapshotBeforeUpdate)}catch(Y){Kn(_,_.return,Y)}}M&64&&QI(_),M&512&&Jg(_,_.return);break;case 3:if(Yl(h,_),M&64&&(h=_.updateQueue,h!==null)){if(m=null,_.child!==null)switch(_.child.tag){case 27:case 5:m=_.child.stateNode;break;case 1:m=_.child.stateNode}try{H4(h,m)}catch(Y){Kn(_,_.return,Y)}}break;case 27:m===null&&M&4&&n5(_);case 26:case 5:Yl(h,_),m===null&&M&4&&e5(_),M&512&&Jg(_,_.return);break;case 12:Yl(h,_);break;case 31:Yl(h,_),M&4&&o5(h,_);break;case 13:Yl(h,_),M&4&&l5(h,_),M&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=dre.bind(null,_),Pre(h,_))));break;case 22:if(M=_.memoizedState!==null||Kl,!M){m=m!==null&&m.memoizedState!==null||ii,P=Kl;var D=ii;Kl=M,(ii=m)&&!D?Zl(h,_,(_.subtreeFlags&8772)!==0):Yl(h,_),Kl=P,ii=D}break;case 30:break;default:Yl(h,_)}}function a5(h){var m=h.alternate;m!==null&&(h.alternate=null,a5(m)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(m=h.stateNode,m!==null&&rt(m)),h.stateNode=null,h.return=null,h.dependencies=null,h.memoizedProps=null,h.memoizedState=null,h.pendingProps=null,h.stateNode=null,h.updateQueue=null}var Tr=null,$a=!1;function Xl(h,m,_){for(_=_.child;_!==null;)s5(h,m,_),_=_.sibling}function s5(h,m,_){if(se&&typeof se.onCommitFiberUnmount=="function")try{se.onCommitFiberUnmount(ue,_)}catch{}switch(_.tag){case 26:ii||el(_,m),Xl(h,m,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:ii||el(_,m);var M=Tr,P=$a;yu(_.type)&&(Tr=_.stateNode,$a=!1),Xl(h,m,_),lx(_.stateNode),Tr=M,$a=P;break;case 5:ii||el(_,m);case 6:if(M=Tr,P=$a,Tr=null,Xl(h,m,_),Tr=M,$a=P,Tr!==null)if($a)try{(Tr.nodeType===9?Tr.body:Tr.nodeName==="HTML"?Tr.ownerDocument.body:Tr).removeChild(_.stateNode)}catch(D){Kn(_,m,D)}else try{Tr.removeChild(_.stateNode)}catch(D){Kn(_,m,D)}break;case 18:Tr!==null&&($a?(h=Tr,Q5(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),om(h)):Q5(Tr,_.stateNode));break;case 4:M=Tr,P=$a,Tr=_.stateNode.containerInfo,$a=!0,Xl(h,m,_),Tr=M,$a=P;break;case 0:case 11:case 14:case 15:hu(2,_,m),ii||hu(4,_,m),Xl(h,m,_);break;case 1:ii||(el(_,m),M=_.stateNode,typeof M.componentWillUnmount=="function"&&JI(_,m,M)),Xl(h,m,_);break;case 21:Xl(h,m,_);break;case 22:ii=(M=ii)||_.memoizedState!==null,Xl(h,m,_),ii=M;break;default:Xl(h,m,_)}}function o5(h,m){if(m.memoizedState===null&&(h=m.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{om(h)}catch(_){Kn(m,m.return,_)}}}function l5(h,m){if(m.memoizedState===null&&(h=m.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{om(h)}catch(_){Kn(m,m.return,_)}}function rre(h){switch(h.tag){case 31:case 13:case 19:var m=h.stateNode;return m===null&&(m=h.stateNode=new r5),m;case 22:return h=h.stateNode,m=h._retryCache,m===null&&(m=h._retryCache=new r5),m;default:throw Error(r(435,h.tag))}}function Qy(h,m){var _=rre(h);m.forEach(function(M){if(!_.has(M)){_.add(M);var P=hre.bind(null,h,M);M.then(P,P)}})}function Va(h,m){var _=m.deletions;if(_!==null)for(var M=0;M<_.length;M++){var P=_[M],D=h,Y=m,ce=Y;e:for(;ce!==null;){switch(ce.tag){case 27:if(yu(ce.type)){Tr=ce.stateNode,$a=!1;break e}break;case 5:Tr=ce.stateNode,$a=!1;break e;case 3:case 4:Tr=ce.stateNode.containerInfo,$a=!0;break e}ce=ce.return}if(Tr===null)throw Error(r(160));s5(D,Y,P),Tr=null,$a=!1,D=P.alternate,D!==null&&(D.return=null),P.return=null}if(m.subtreeFlags&13886)for(m=m.child;m!==null;)c5(m,h),m=m.sibling}var Mo=null;function c5(h,m){var _=h.alternate,M=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:Va(m,h),Ga(h),M&4&&(hu(3,h,h.return),Qg(3,h),hu(5,h,h.return));break;case 1:Va(m,h),Ga(h),M&512&&(ii||_===null||el(_,_.return)),M&64&&Kl&&(h=h.updateQueue,h!==null&&(M=h.callbacks,M!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?M:_.concat(M))));break;case 26:var P=Mo;if(Va(m,h),Ga(h),M&512&&(ii||_===null||el(_,_.return)),M&4){var D=_!==null?_.memoizedState:null;if(M=h.memoizedState,_===null)if(M===null)if(h.stateNode===null){e:{M=h.type,_=h.memoizedProps,P=P.ownerDocument||P;t:switch(M){case"title":D=P.getElementsByTagName("title")[0],(!D||D[st]||D[Un]||D.namespaceURI==="http://www.w3.org/2000/svg"||D.hasAttribute("itemprop"))&&(D=P.createElement(M),P.head.insertBefore(D,P.querySelector("head > title"))),Zi(D,M,_),D[Un]=h,Ie(D),M=D;break e;case"link":var Y=cF("link","href",P).get(M+(_.href||""));if(Y){for(var ce=0;ce<Y.length;ce++)if(D=Y[ce],D.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&D.getAttribute("rel")===(_.rel==null?null:_.rel)&&D.getAttribute("title")===(_.title==null?null:_.title)&&D.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){Y.splice(ce,1);break t}}D=P.createElement(M),Zi(D,M,_),P.head.appendChild(D);break;case"meta":if(Y=cF("meta","content",P).get(M+(_.content||""))){for(ce=0;ce<Y.length;ce++)if(D=Y[ce],D.getAttribute("content")===(_.content==null?null:""+_.content)&&D.getAttribute("name")===(_.name==null?null:_.name)&&D.getAttribute("property")===(_.property==null?null:_.property)&&D.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&D.getAttribute("charset")===(_.charSet==null?null:_.charSet)){Y.splice(ce,1);break t}}D=P.createElement(M),Zi(D,M,_),P.head.appendChild(D);break;default:throw Error(r(468,M))}D[Un]=h,Ie(D),M=D}h.stateNode=M}else uF(P,h.type,h.stateNode);else h.stateNode=lF(P,M,h.memoizedProps);else D!==M?(D===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):D.count--,M===null?uF(P,h.type,h.stateNode):lF(P,M,h.memoizedProps)):M===null&&h.stateNode!==null&&K2(h,h.memoizedProps,_.memoizedProps)}break;case 27:Va(m,h),Ga(h),M&512&&(ii||_===null||el(_,_.return)),_!==null&&M&4&&K2(h,h.memoizedProps,_.memoizedProps);break;case 5:if(Va(m,h),Ga(h),M&512&&(ii||_===null||el(_,_.return)),h.flags&32){P=h.stateNode;try{Zo(P,"")}catch(Lt){Kn(h,h.return,Lt)}}M&4&&h.stateNode!=null&&(P=h.memoizedProps,K2(h,P,_!==null?_.memoizedProps:P)),M&1024&&(Z2=!0);break;case 6:if(Va(m,h),Ga(h),M&4){if(h.stateNode===null)throw Error(r(162));M=h.memoizedProps,_=h.stateNode;try{_.nodeValue=M}catch(Lt){Kn(h,h.return,Lt)}}break;case 3:if(mv=null,P=Mo,Mo=hv(m.containerInfo),Va(m,h),Mo=P,Ga(h),M&4&&_!==null&&_.memoizedState.isDehydrated)try{om(m.containerInfo)}catch(Lt){Kn(h,h.return,Lt)}Z2&&(Z2=!1,u5(h));break;case 4:M=Mo,Mo=hv(h.stateNode.containerInfo),Va(m,h),Ga(h),Mo=M;break;case 12:Va(m,h),Ga(h);break;case 31:Va(m,h),Ga(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,Qy(h,M)));break;case 13:Va(m,h),Ga(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(ev=I()),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,Qy(h,M)));break;case 22:P=h.memoizedState!==null;var Ce=_!==null&&_.memoizedState!==null,tt=Kl,dt=ii;if(Kl=tt||P,ii=dt||Ce,Va(m,h),ii=dt,Kl=tt,Ga(h),M&8192)e:for(m=h.stateNode,m._visibility=P?m._visibility&-2:m._visibility|1,P&&(_===null||Ce||Kl||ii||Qd(h)),_=null,m=h;;){if(m.tag===5||m.tag===26){if(_===null){Ce=_=m;try{if(D=Ce.stateNode,P)Y=D.style,typeof Y.setProperty=="function"?Y.setProperty("display","none","important"):Y.display="none";else{ce=Ce.stateNode;var mt=Ce.memoizedProps.style,it=mt!=null&&mt.hasOwnProperty("display")?mt.display:null;ce.style.display=it==null||typeof it=="boolean"?"":(""+it).trim()}}catch(Lt){Kn(Ce,Ce.return,Lt)}}}else if(m.tag===6){if(_===null){Ce=m;try{Ce.stateNode.nodeValue=P?"":Ce.memoizedProps}catch(Lt){Kn(Ce,Ce.return,Lt)}}}else if(m.tag===18){if(_===null){Ce=m;try{var ot=Ce.stateNode;P?J5(ot,!0):J5(Ce.stateNode,!1)}catch(Lt){Kn(Ce,Ce.return,Lt)}}}else if((m.tag!==22&&m.tag!==23||m.memoizedState===null||m===h)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===h)break e;for(;m.sibling===null;){if(m.return===null||m.return===h)break e;_===m&&(_=null),m=m.return}_===m&&(_=null),m.sibling.return=m.return,m=m.sibling}M&4&&(M=h.updateQueue,M!==null&&(_=M.retryQueue,_!==null&&(M.retryQueue=null,Qy(h,_))));break;case 19:Va(m,h),Ga(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,Qy(h,M)));break;case 30:break;case 21:break;default:Va(m,h),Ga(h)}}function Ga(h){var m=h.flags;if(m&2){try{for(var _,M=h.return;M!==null;){if(t5(M)){_=M;break}M=M.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,D=X2(h);Zy(h,D,P);break;case 5:var Y=_.stateNode;_.flags&32&&(Zo(Y,""),_.flags&=-33);var ce=X2(h);Zy(h,ce,Y);break;case 3:case 4:var Ce=_.stateNode.containerInfo,tt=X2(h);Y2(h,tt,Ce);break;default:throw Error(r(161))}}catch(dt){Kn(h,h.return,dt)}h.flags&=-3}m&4096&&(h.flags&=-4097)}function u5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var m=h;u5(m),m.tag===5&&m.flags&1024&&m.stateNode.reset(),h=h.sibling}}function Yl(h,m){if(m.subtreeFlags&8772)for(m=m.child;m!==null;)i5(h,m.alternate,m),m=m.sibling}function Qd(h){for(h=h.child;h!==null;){var m=h;switch(m.tag){case 0:case 11:case 14:case 15:hu(4,m,m.return),Qd(m);break;case 1:el(m,m.return);var _=m.stateNode;typeof _.componentWillUnmount=="function"&&JI(m,m.return,_),Qd(m);break;case 27:lx(m.stateNode);case 26:case 5:el(m,m.return),Qd(m);break;case 22:m.memoizedState===null&&Qd(m);break;case 30:Qd(m);break;default:Qd(m)}h=h.sibling}}function Zl(h,m,_){for(_=_&&(m.subtreeFlags&8772)!==0,m=m.child;m!==null;){var M=m.alternate,P=h,D=m,Y=D.flags;switch(D.tag){case 0:case 11:case 15:Zl(P,D,_),Qg(4,D);break;case 1:if(Zl(P,D,_),M=D,P=M.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(tt){Kn(M,M.return,tt)}if(M=D,P=M.updateQueue,P!==null){var ce=M.stateNode;try{var Ce=P.shared.hiddenCallbacks;if(Ce!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Ce.length;P++)B4(Ce[P],ce)}catch(tt){Kn(M,M.return,tt)}}_&&Y&64&&QI(D),Jg(D,D.return);break;case 27:n5(D);case 26:case 5:Zl(P,D,_),_&&M===null&&Y&4&&e5(D),Jg(D,D.return);break;case 12:Zl(P,D,_);break;case 31:Zl(P,D,_),_&&Y&4&&o5(P,D);break;case 13:Zl(P,D,_),_&&Y&4&&l5(P,D);break;case 22:D.memoizedState===null&&Zl(P,D,_),Jg(D,D.return);break;case 30:break;default:Zl(P,D,_)}m=m.sibling}}function Q2(h,m){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(h=m.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&Ug(_))}function J2(h,m){h=null,m.alternate!==null&&(h=m.alternate.memoizedState.cache),m=m.memoizedState.cache,m!==h&&(m.refCount++,h!=null&&Ug(h))}function Eo(h,m,_,M){if(m.subtreeFlags&10256)for(m=m.child;m!==null;)d5(h,m,_,M),m=m.sibling}function d5(h,m,_,M){var P=m.flags;switch(m.tag){case 0:case 11:case 15:Eo(h,m,_,M),P&2048&&Qg(9,m);break;case 1:Eo(h,m,_,M);break;case 3:Eo(h,m,_,M),P&2048&&(h=null,m.alternate!==null&&(h=m.alternate.memoizedState.cache),m=m.memoizedState.cache,m!==h&&(m.refCount++,h!=null&&Ug(h)));break;case 12:if(P&2048){Eo(h,m,_,M),h=m.stateNode;try{var D=m.memoizedProps,Y=D.id,ce=D.onPostCommit;typeof ce=="function"&&ce(Y,m.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Ce){Kn(m,m.return,Ce)}}else Eo(h,m,_,M);break;case 31:Eo(h,m,_,M);break;case 13:Eo(h,m,_,M);break;case 23:break;case 22:D=m.stateNode,Y=m.alternate,m.memoizedState!==null?D._visibility&2?Eo(h,m,_,M):ex(h,m):D._visibility&2?Eo(h,m,_,M):(D._visibility|=2,Yf(h,m,_,M,(m.subtreeFlags&10256)!==0||!1)),P&2048&&Q2(Y,m);break;case 24:Eo(h,m,_,M),P&2048&&J2(m.alternate,m);break;default:Eo(h,m,_,M)}}function Yf(h,m,_,M,P){for(P=P&&((m.subtreeFlags&10256)!==0||!1),m=m.child;m!==null;){var D=h,Y=m,ce=_,Ce=M,tt=Y.flags;switch(Y.tag){case 0:case 11:case 15:Yf(D,Y,ce,Ce,P),Qg(8,Y);break;case 23:break;case 22:var dt=Y.stateNode;Y.memoizedState!==null?dt._visibility&2?Yf(D,Y,ce,Ce,P):ex(D,Y):(dt._visibility|=2,Yf(D,Y,ce,Ce,P)),P&&tt&2048&&Q2(Y.alternate,Y);break;case 24:Yf(D,Y,ce,Ce,P),P&&tt&2048&&J2(Y.alternate,Y);break;default:Yf(D,Y,ce,Ce,P)}m=m.sibling}}function ex(h,m){if(m.subtreeFlags&10256)for(m=m.child;m!==null;){var _=h,M=m,P=M.flags;switch(M.tag){case 22:ex(_,M),P&2048&&Q2(M.alternate,M);break;case 24:ex(_,M),P&2048&&J2(M.alternate,M);break;default:ex(_,M)}m=m.sibling}}var tx=8192;function Zf(h,m,_){if(h.subtreeFlags&tx)for(h=h.child;h!==null;)h5(h,m,_),h=h.sibling}function h5(h,m,_){switch(h.tag){case 26:Zf(h,m,_),h.flags&tx&&h.memoizedState!==null&&$re(_,Mo,h.memoizedState,h.memoizedProps);break;case 5:Zf(h,m,_);break;case 3:case 4:var M=Mo;Mo=hv(h.stateNode.containerInfo),Zf(h,m,_),Mo=M;break;case 22:h.memoizedState===null&&(M=h.alternate,M!==null&&M.memoizedState!==null?(M=tx,tx=16777216,Zf(h,m,_),tx=M):Zf(h,m,_));break;default:Zf(h,m,_)}}function f5(h){var m=h.alternate;if(m!==null&&(h=m.child,h!==null)){m.child=null;do m=h.sibling,h.sibling=null,h=m;while(h!==null)}}function nx(h){var m=h.deletions;if((h.flags&16)!==0){if(m!==null)for(var _=0;_<m.length;_++){var M=m[_];Ri=M,p5(M,h)}f5(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)m5(h),h=h.sibling}function m5(h){switch(h.tag){case 0:case 11:case 15:nx(h),h.flags&2048&&hu(9,h,h.return);break;case 3:nx(h);break;case 12:nx(h);break;case 22:var m=h.stateNode;h.memoizedState!==null&&m._visibility&2&&(h.return===null||h.return.tag!==13)?(m._visibility&=-3,Jy(h)):nx(h);break;default:nx(h)}}function Jy(h){var m=h.deletions;if((h.flags&16)!==0){if(m!==null)for(var _=0;_<m.length;_++){var M=m[_];Ri=M,p5(M,h)}f5(h)}for(h=h.child;h!==null;){switch(m=h,m.tag){case 0:case 11:case 15:hu(8,m,m.return),Jy(m);break;case 22:_=m.stateNode,_._visibility&2&&(_._visibility&=-3,Jy(m));break;default:Jy(m)}h=h.sibling}}function p5(h,m){for(;Ri!==null;){var _=Ri;switch(_.tag){case 0:case 11:case 15:hu(8,_,m);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var M=_.memoizedState.cachePool.pool;M!=null&&M.refCount++}break;case 24:Ug(_.memoizedState.cache)}if(M=_.child,M!==null)M.return=_,Ri=M;else e:for(_=h;Ri!==null;){M=Ri;var P=M.sibling,D=M.return;if(a5(M),M===_){Ri=null;break e}if(P!==null){P.return=D,Ri=P;break e}Ri=D}}}var ire={getCacheForType:function(h){var m=Xi(ti),_=m.data.get(h);return _===void 0&&(_=h(),m.data.set(h,_)),_},cacheSignal:function(){return Xi(ti).controller.signal}},are=typeof WeakMap=="function"?WeakMap:Map,zn=0,hr=null,vn=null,En=0,qn=0,ps=null,fu=!1,Qf=!1,eA=!1,Ql=0,Br=0,mu=0,Jd=0,tA=0,gs=0,Jf=0,rx=null,Wa=null,nA=!1,ev=0,g5=0,tv=1/0,nv=null,pu=null,gi=0,gu=null,em=null,Jl=0,rA=0,iA=null,x5=null,ix=0,aA=null;function xs(){return(zn&2)!==0&&En!==0?En&-En:W.T!==null?dA():Jn()}function b5(){if(gs===0)if((En&536870912)===0||Cn){var h=xe;xe<<=1,(xe&3932160)===0&&(xe=262144),gs=h}else gs=536870912;return h=fs.current,h!==null&&(h.flags|=32),gs}function qa(h,m,_){(h===hr&&(qn===2||qn===9)||h.cancelPendingCommit!==null)&&(tm(h,0),xu(h,En,gs,!1)),Ut(h,_),((zn&2)===0||h!==hr)&&(h===hr&&((zn&2)===0&&(Jd|=_),Br===4&&xu(h,En,gs,!1)),tl(h))}function y5(h,m,_){if((zn&6)!==0)throw Error(r(327));var M=!_&&(m&127)===0&&(m&h.expiredLanes)===0||Ae(h,m),P=M?lre(h,m):oA(h,m,!0),D=M;do{if(P===0){Qf&&!M&&xu(h,m,0,!1);break}else{if(_=h.current.alternate,D&&!sre(_)){P=oA(h,m,!1),D=!1;continue}if(P===2){if(D=m,h.errorRecoveryDisabledLanes&D)var Y=0;else Y=h.pendingLanes&-536870913,Y=Y!==0?Y:Y&536870912?536870912:0;if(Y!==0){m=Y;e:{var ce=h;P=rx;var Ce=ce.current.memoizedState.isDehydrated;if(Ce&&(tm(ce,Y).flags|=256),Y=oA(ce,Y,!1),Y!==2){if(eA&&!Ce){ce.errorRecoveryDisabledLanes|=D,Jd|=D,P=4;break e}D=Wa,Wa=P,D!==null&&(Wa===null?Wa=D:Wa.push.apply(Wa,D))}P=Y}if(D=!1,P!==2)continue}}if(P===1){tm(h,0),xu(h,m,0,!0);break}e:{switch(M=h,D=P,D){case 0:case 1:throw Error(r(345));case 4:if((m&4194048)!==m)break;case 6:xu(M,m,gs,!fu);break e;case 2:Wa=null;break;case 3:case 5:break;default:throw Error(r(329))}if((m&62914560)===m&&(P=ev+300-I(),10<P)){if(xu(M,m,gs,!fu),we(M,0,!0)!==0)break e;Jl=m,M.timeoutHandle=Y5(v5.bind(null,M,_,Wa,nv,nA,m,gs,Jd,Jf,fu,D,"Throttled",-0,0),P);break e}v5(M,_,Wa,nv,nA,m,gs,Jd,Jf,fu,D,null,-0,0)}}break}while(!0);tl(h)}function v5(h,m,_,M,P,D,Y,ce,Ce,tt,dt,mt,it,ot){if(h.timeoutHandle=-1,mt=m.subtreeFlags,mt&8192||(mt&16785408)===16785408){mt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Fl},h5(m,D,mt);var Lt=(D&62914560)===D?ev-I():(D&4194048)===D?g5-I():0;if(Lt=Vre(mt,Lt),Lt!==null){Jl=D,h.cancelPendingCommit=Lt(N5.bind(null,h,m,D,_,M,P,Y,ce,Ce,dt,mt,null,it,ot)),xu(h,D,Y,!tt);return}}N5(h,m,D,_,M,P,Y,ce,Ce)}function sre(h){for(var m=h;;){var _=m.tag;if((_===0||_===11||_===15)&&m.flags&16384&&(_=m.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var M=0;M<_.length;M++){var P=_[M],D=P.getSnapshot;P=P.value;try{if(!ds(D(),P))return!1}catch{return!1}}if(_=m.child,m.subtreeFlags&16384&&_!==null)_.return=m,m=_;else{if(m===h)break;for(;m.sibling===null;){if(m.return===null||m.return===h)return!0;m=m.return}m.sibling.return=m.return,m=m.sibling}}return!0}function xu(h,m,_,M){m&=~tA,m&=~Jd,h.suspendedLanes|=m,h.pingedLanes&=~m,M&&(h.warmLanes|=m),M=h.expirationTimes;for(var P=m;0<P;){var D=31-Be(P),Y=1<<D;M[D]=-1,P&=~Y}_!==0&&$t(h,_,m)}function rv(){return(zn&6)===0?(ax(0),!1):!0}function sA(){if(vn!==null){if(qn===0)var h=vn.return;else h=vn,Hl=Vd=null,w2(h),Gf=null,Bg=0,h=vn;for(;h!==null;)ZI(h.alternate,h),h=h.return;vn=null}}function tm(h,m){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,Are(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),Jl=0,sA(),hr=h,vn=_=zl(h.current,null),En=m,qn=0,ps=null,fu=!1,Qf=Ae(h,m),eA=!1,Jf=gs=tA=Jd=mu=Br=0,Wa=rx=null,nA=!1,(m&8)!==0&&(m|=m&32);var M=h.entangledLanes;if(M!==0)for(h=h.entanglements,M&=m;0<M;){var P=31-Be(M),D=1<<P;m|=h[P],M&=~D}return Ql=m,My(),_}function _5(h,m){on=null,W.H=Xg,m===Vf||m===jy?(m=I4(),qn=3):m===u2?(m=I4(),qn=4):qn=m===F2?8:m!==null&&typeof m=="object"&&typeof m.then=="function"?6:1,ps=m,vn===null&&(Br=1,Wy(h,Ls(m,h.current)))}function w5(){var h=fs.current;return h===null?!0:(En&4194048)===En?zs===null:(En&62914560)===En||(En&536870912)!==0?h===zs:!1}function S5(){var h=W.H;return W.H=Xg,h===null?Xg:h}function M5(){var h=W.A;return W.A=ire,h}function iv(){Br=4,fu||(En&4194048)!==En&&fs.current!==null||(Qf=!0),(mu&134217727)===0&&(Jd&134217727)===0||hr===null||xu(hr,En,gs,!1)}function oA(h,m,_){var M=zn;zn|=2;var P=S5(),D=M5();(hr!==h||En!==m)&&(nv=null,tm(h,m)),m=!1;var Y=Br;e:do try{if(qn!==0&&vn!==null){var ce=vn,Ce=ps;switch(qn){case 8:sA(),Y=6;break e;case 3:case 2:case 9:case 6:fs.current===null&&(m=!0);var tt=qn;if(qn=0,ps=null,nm(h,ce,Ce,tt),_&&Qf){Y=0;break e}break;default:tt=qn,qn=0,ps=null,nm(h,ce,Ce,tt)}}ore(),Y=Br;break}catch(dt){_5(h,dt)}while(!0);return m&&h.shellSuspendCounter++,Hl=Vd=null,zn=M,W.H=P,W.A=D,vn===null&&(hr=null,En=0,My()),Y}function ore(){for(;vn!==null;)E5(vn)}function lre(h,m){var _=zn;zn|=2;var M=S5(),P=M5();hr!==h||En!==m?(nv=null,tv=I()+500,tm(h,m)):Qf=Ae(h,m);e:do try{if(qn!==0&&vn!==null){m=vn;var D=ps;t:switch(qn){case 1:qn=0,ps=null,nm(h,m,D,1);break;case 2:case 9:if(O4(D)){qn=0,ps=null,A5(m);break}m=function(){qn!==2&&qn!==9||hr!==h||(qn=7),tl(h)},D.then(m,m);break e;case 3:qn=7;break e;case 4:qn=5;break e;case 7:O4(D)?(qn=0,ps=null,A5(m)):(qn=0,ps=null,nm(h,m,D,7));break;case 5:var Y=null;switch(vn.tag){case 26:Y=vn.memoizedState;case 5:case 27:var ce=vn;if(Y?dF(Y):ce.stateNode.complete){qn=0,ps=null;var Ce=ce.sibling;if(Ce!==null)vn=Ce;else{var tt=ce.return;tt!==null?(vn=tt,av(tt)):vn=null}break t}}qn=0,ps=null,nm(h,m,D,5);break;case 6:qn=0,ps=null,nm(h,m,D,6);break;case 8:sA(),Br=6;break e;default:throw Error(r(462))}}cre();break}catch(dt){_5(h,dt)}while(!0);return Hl=Vd=null,W.H=M,W.A=P,zn=_,vn!==null?0:(hr=null,En=0,My(),Br)}function cre(){for(;vn!==null&&!Me();)E5(vn)}function E5(h){var m=XI(h.alternate,h,Ql);h.memoizedProps=h.pendingProps,m===null?av(h):vn=m}function A5(h){var m=h,_=m.alternate;switch(m.tag){case 15:case 0:m=$I(_,m,m.pendingProps,m.type,void 0,En);break;case 11:m=$I(_,m,m.pendingProps,m.type.render,m.ref,En);break;case 5:w2(m);default:ZI(_,m),m=vn=M4(m,Ql),m=XI(_,m,Ql)}h.memoizedProps=h.pendingProps,m===null?av(h):vn=m}function nm(h,m,_,M){Hl=Vd=null,w2(m),Gf=null,Bg=0;var P=m.return;try{if(Zne(h,P,m,_,En)){Br=1,Wy(h,Ls(_,h.current)),vn=null;return}}catch(D){if(P!==null)throw vn=P,D;Br=1,Wy(h,Ls(_,h.current)),vn=null;return}m.flags&32768?(Cn||M===1?h=!0:Qf||(En&536870912)!==0?h=!1:(fu=h=!0,(M===2||M===9||M===3||M===6)&&(M=fs.current,M!==null&&M.tag===13&&(M.flags|=16384))),T5(m,h)):av(m)}function av(h){var m=h;do{if((m.flags&32768)!==0){T5(m,fu);return}h=m.return;var _=ere(m.alternate,m,Ql);if(_!==null){vn=_;return}if(m=m.sibling,m!==null){vn=m;return}vn=m=h}while(m!==null);Br===0&&(Br=5)}function T5(h,m){do{var _=tre(h.alternate,h);if(_!==null){_.flags&=32767,vn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!m&&(h=h.sibling,h!==null)){vn=h;return}vn=h=_}while(h!==null);Br=6,vn=null}function N5(h,m,_,M,P,D,Y,ce,Ce){h.cancelPendingCommit=null;do sv();while(gi!==0);if((zn&6)!==0)throw Error(r(327));if(m!==null){if(m===h.current)throw Error(r(177));if(D=m.lanes|m.childLanes,D|=XE,Ct(h,_,D,Y,ce,Ce),h===hr&&(vn=hr=null,En=0),em=m,gu=h,Jl=_,rA=D,iA=P,x5=M,(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,fre(ye,function(){return R5(),null})):(h.callbackNode=null,h.callbackPriority=0),M=(m.flags&13878)!==0,(m.subtreeFlags&13878)!==0||M){M=W.T,W.T=null,P=$.p,$.p=2,Y=zn,zn|=4;try{nre(h,m,_)}finally{zn=Y,$.p=P,W.T=M}}gi=1,C5(),k5(),P5()}}function C5(){if(gi===1){gi=0;var h=gu,m=em,_=(m.flags&13878)!==0;if((m.subtreeFlags&13878)!==0||_){_=W.T,W.T=null;var M=$.p;$.p=2;var P=zn;zn|=4;try{c5(m,h);var D=yA,Y=p4(h.containerInfo),ce=D.focusedElem,Ce=D.selectionRange;if(Y!==ce&&ce&&ce.ownerDocument&&m4(ce.ownerDocument.documentElement,ce)){if(Ce!==null&&VE(ce)){var tt=Ce.start,dt=Ce.end;if(dt===void 0&&(dt=tt),"selectionStart"in ce)ce.selectionStart=tt,ce.selectionEnd=Math.min(dt,ce.value.length);else{var mt=ce.ownerDocument||document,it=mt&&mt.defaultView||window;if(it.getSelection){var ot=it.getSelection(),Lt=ce.textContent.length,Xt=Math.min(Ce.start,Lt),rr=Ce.end===void 0?Xt:Math.min(Ce.end,Lt);!ot.extend&&Xt>rr&&(Y=rr,rr=Xt,Xt=Y);var Ge=f4(ce,Xt),De=f4(ce,rr);if(Ge&&De&&(ot.rangeCount!==1||ot.anchorNode!==Ge.node||ot.anchorOffset!==Ge.offset||ot.focusNode!==De.node||ot.focusOffset!==De.offset)){var Je=mt.createRange();Je.setStart(Ge.node,Ge.offset),ot.removeAllRanges(),Xt>rr?(ot.addRange(Je),ot.extend(De.node,De.offset)):(Je.setEnd(De.node,De.offset),ot.addRange(Je))}}}}for(mt=[],ot=ce;ot=ot.parentNode;)ot.nodeType===1&&mt.push({element:ot,left:ot.scrollLeft,top:ot.scrollTop});for(typeof ce.focus=="function"&&ce.focus(),ce=0;ce<mt.length;ce++){var ft=mt[ce];ft.element.scrollLeft=ft.left,ft.element.scrollTop=ft.top}}bv=!!bA,yA=bA=null}finally{zn=P,$.p=M,W.T=_}}h.current=m,gi=2}}function k5(){if(gi===2){gi=0;var h=gu,m=em,_=(m.flags&8772)!==0;if((m.subtreeFlags&8772)!==0||_){_=W.T,W.T=null;var M=$.p;$.p=2;var P=zn;zn|=4;try{i5(h,m.alternate,m)}finally{zn=P,$.p=M,W.T=_}}gi=3}}function P5(){if(gi===4||gi===3){gi=0,F();var h=gu,m=em,_=Jl,M=x5;(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?gi=5:(gi=0,em=gu=null,j5(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(pu=null),Yt(_),m=m.stateNode,se&&typeof se.onCommitFiberRoot=="function")try{se.onCommitFiberRoot(ue,m,void 0,(m.current.flags&128)===128)}catch{}if(M!==null){m=W.T,P=$.p,$.p=2,W.T=null;try{for(var D=h.onRecoverableError,Y=0;Y<M.length;Y++){var ce=M[Y];D(ce.value,{componentStack:ce.stack})}}finally{W.T=m,$.p=P}}(Jl&3)!==0&&sv(),tl(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===aA?ix++:(ix=0,aA=h):ix=0,ax(0)}}function j5(h,m){(h.pooledCacheLanes&=m)===0&&(m=h.pooledCache,m!=null&&(h.pooledCache=null,Ug(m)))}function sv(){return C5(),k5(),P5(),R5()}function R5(){if(gi!==5)return!1;var h=gu,m=rA;rA=0;var _=Yt(Jl),M=W.T,P=$.p;try{$.p=32>_?32:_,W.T=null,_=iA,iA=null;var D=gu,Y=Jl;if(gi=0,em=gu=null,Jl=0,(zn&6)!==0)throw Error(r(331));var ce=zn;if(zn|=4,m5(D.current),d5(D,D.current,Y,_),zn=ce,ax(0,!1),se&&typeof se.onPostCommitFiberRoot=="function")try{se.onPostCommitFiberRoot(ue,D)}catch{}return!0}finally{$.p=P,W.T=M,j5(h,m)}}function D5(h,m,_){m=Ls(_,m),m=I2(h.stateNode,m,2),h=cu(h,m,2),h!==null&&(Ut(h,2),tl(h))}function Kn(h,m,_){if(h.tag===3)D5(h,h,_);else for(;m!==null;){if(m.tag===3){D5(m,h,_);break}else if(m.tag===1){var M=m.stateNode;if(typeof m.type.getDerivedStateFromError=="function"||typeof M.componentDidCatch=="function"&&(pu===null||!pu.has(M))){h=Ls(_,h),_=OI(2),M=cu(m,_,2),M!==null&&(LI(_,M,m,h),Ut(M,2),tl(M));break}}m=m.return}}function lA(h,m,_){var M=h.pingCache;if(M===null){M=h.pingCache=new are;var P=new Set;M.set(m,P)}else P=M.get(m),P===void 0&&(P=new Set,M.set(m,P));P.has(_)||(eA=!0,P.add(_),h=ure.bind(null,h,m,_),m.then(h,h))}function ure(h,m,_){var M=h.pingCache;M!==null&&M.delete(m),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,hr===h&&(En&_)===_&&(Br===4||Br===3&&(En&62914560)===En&&300>I()-ev?(zn&2)===0&&tm(h,0):tA|=_,Jf===En&&(Jf=0)),tl(h)}function O5(h,m){m===0&&(m=_t()),h=Bd(h,m),h!==null&&(Ut(h,m),tl(h))}function dre(h){var m=h.memoizedState,_=0;m!==null&&(_=m.retryLane),O5(h,_)}function hre(h,m){var _=0;switch(h.tag){case 31:case 13:var M=h.stateNode,P=h.memoizedState;P!==null&&(_=P.retryLane);break;case 19:M=h.stateNode;break;case 22:M=h.stateNode._retryCache;break;default:throw Error(r(314))}M!==null&&M.delete(m),O5(h,_)}function fre(h,m){return be(h,m)}var ov=null,rm=null,cA=!1,lv=!1,uA=!1,bu=0;function tl(h){h!==rm&&h.next===null&&(rm===null?ov=rm=h:rm=rm.next=h),lv=!0,cA||(cA=!0,pre())}function ax(h,m){if(!uA&&lv){uA=!0;do for(var _=!1,M=ov;M!==null;){if(h!==0){var P=M.pendingLanes;if(P===0)var D=0;else{var Y=M.suspendedLanes,ce=M.pingedLanes;D=(1<<31-Be(42|h)+1)-1,D&=P&~(Y&~ce),D=D&201326741?D&201326741|1:D?D|2:0}D!==0&&(_=!0,U5(M,D))}else D=En,D=we(M,M===hr?D:0,M.cancelPendingCommit!==null||M.timeoutHandle!==-1),(D&3)===0||Ae(M,D)||(_=!0,U5(M,D));M=M.next}while(_);uA=!1}}function mre(){L5()}function L5(){lv=cA=!1;var h=0;bu!==0&&Ere()&&(h=bu);for(var m=I(),_=null,M=ov;M!==null;){var P=M.next,D=I5(M,m);D===0?(M.next=null,_===null?ov=P:_.next=P,P===null&&(rm=_)):(_=M,(h!==0||(D&3)!==0)&&(lv=!0)),M=P}gi!==0&&gi!==5||ax(h),bu!==0&&(bu=0)}function I5(h,m){for(var _=h.suspendedLanes,M=h.pingedLanes,P=h.expirationTimes,D=h.pendingLanes&-62914561;0<D;){var Y=31-Be(D),ce=1<<Y,Ce=P[Y];Ce===-1?((ce&_)===0||(ce&M)!==0)&&(P[Y]=lt(ce,m)):Ce<=m&&(h.expiredLanes|=ce),D&=~ce}if(m=hr,_=En,_=we(h,h===m?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M=h.callbackNode,_===0||h===m&&(qn===2||qn===9)||h.cancelPendingCommit!==null)return M!==null&&M!==null&&Te(M),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||Ae(h,_)){if(m=_&-_,m===h.callbackPriority)return m;switch(M!==null&&Te(M),Yt(_)){case 2:case 8:_=Se;break;case 32:_=ye;break;case 268435456:_=We;break;default:_=ye}return M=F5.bind(null,h),_=be(_,M),h.callbackPriority=m,h.callbackNode=_,m}return M!==null&&M!==null&&Te(M),h.callbackPriority=2,h.callbackNode=null,2}function F5(h,m){if(gi!==0&&gi!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(sv()&&h.callbackNode!==_)return null;var M=En;return M=we(h,h===hr?M:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M===0?null:(y5(h,M,m),I5(h,I()),h.callbackNode!=null&&h.callbackNode===_?F5.bind(null,h):null)}function U5(h,m){if(sv())return null;y5(h,m,!0)}function pre(){Tre(function(){(zn&6)!==0?be(ve,mre):L5()})}function dA(){if(bu===0){var h=Hf;h===0&&(h=nt,nt<<=1,(nt&261888)===0&&(nt=256)),bu=h}return bu}function z5(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:gy(""+h)}function B5(h,m){var _=m.ownerDocument.createElement("input");return _.name=m.name,_.value=m.value,h.id&&_.setAttribute("form",h.id),m.parentNode.insertBefore(_,m),h=new FormData(h),_.parentNode.removeChild(_),h}function gre(h,m,_,M,P){if(m==="submit"&&_&&_.stateNode===P){var D=z5((P[jn]||null).action),Y=M.submitter;Y&&(m=(m=Y[jn]||null)?z5(m.formAction):Y.getAttribute("formAction"),m!==null&&(D=m,Y=null));var ce=new vy("action","action",null,M,P);h.push({event:ce,listeners:[{instance:null,listener:function(){if(M.defaultPrevented){if(bu!==0){var Ce=Y?B5(P,Y):new FormData(P);P2(_,{pending:!0,data:Ce,method:P.method,action:D},null,Ce)}}else typeof D=="function"&&(ce.preventDefault(),Ce=Y?B5(P,Y):new FormData(P),P2(_,{pending:!0,data:Ce,method:P.method,action:D},D,Ce))},currentTarget:P}]})}}for(var hA=0;hA<KE.length;hA++){var fA=KE[hA],xre=fA.toLowerCase(),bre=fA[0].toUpperCase()+fA.slice(1);So(xre,"on"+bre)}So(b4,"onAnimationEnd"),So(y4,"onAnimationIteration"),So(v4,"onAnimationStart"),So("dblclick","onDoubleClick"),So("focusin","onFocus"),So("focusout","onBlur"),So(Dne,"onTransitionRun"),So(One,"onTransitionStart"),So(Lne,"onTransitionCancel"),So(_4,"onTransitionEnd"),Tt("onMouseEnter",["mouseout","mouseover"]),Tt("onMouseLeave",["mouseout","mouseover"]),Tt("onPointerEnter",["pointerout","pointerover"]),Tt("onPointerLeave",["pointerout","pointerover"]),xt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),xt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),xt("onBeforeInput",["compositionend","keypress","textInput","paste"]),xt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),xt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),xt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var sx="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),yre=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(sx));function H5(h,m){m=(m&4)!==0;for(var _=0;_<h.length;_++){var M=h[_],P=M.event;M=M.listeners;e:{var D=void 0;if(m)for(var Y=M.length-1;0<=Y;Y--){var ce=M[Y],Ce=ce.instance,tt=ce.currentTarget;if(ce=ce.listener,Ce!==D&&P.isPropagationStopped())break e;D=ce,P.currentTarget=tt;try{D(P)}catch(dt){Sy(dt)}P.currentTarget=null,D=Ce}else for(Y=0;Y<M.length;Y++){if(ce=M[Y],Ce=ce.instance,tt=ce.currentTarget,ce=ce.listener,Ce!==D&&P.isPropagationStopped())break e;D=ce,P.currentTarget=tt;try{D(P)}catch(dt){Sy(dt)}P.currentTarget=null,D=Ce}}}}function _n(h,m){var _=m[Le];_===void 0&&(_=m[Le]=new Set);var M=h+"__bubble";_.has(M)||($5(m,h,2,!1),_.add(M))}function mA(h,m,_){var M=0;m&&(M|=4),$5(_,h,M,m)}var cv="_reactListening"+Math.random().toString(36).slice(2);function pA(h){if(!h[cv]){h[cv]=!0,je.forEach(function(_){_!=="selectionchange"&&(yre.has(_)||mA(_,!1,h),mA(_,!0,h))});var m=h.nodeType===9?h:h.ownerDocument;m===null||m[cv]||(m[cv]=!0,mA("selectionchange",!1,m))}}function $5(h,m,_,M){switch(bF(m)){case 2:var P=qre;break;case 8:P=Kre;break;default:P=kA}_=P.bind(null,m,_,h),P=void 0,!OE||m!=="touchstart"&&m!=="touchmove"&&m!=="wheel"||(P=!0),M?P!==void 0?h.addEventListener(m,_,{capture:!0,passive:P}):h.addEventListener(m,_,!0):P!==void 0?h.addEventListener(m,_,{passive:P}):h.addEventListener(m,_,!1)}function gA(h,m,_,M,P){var D=M;if((m&1)===0&&(m&2)===0&&M!==null)e:for(;;){if(M===null)return;var Y=M.tag;if(Y===3||Y===4){var ce=M.stateNode.containerInfo;if(ce===P)break;if(Y===4)for(Y=M.return;Y!==null;){var Ce=Y.tag;if((Ce===3||Ce===4)&&Y.stateNode.containerInfo===P)return;Y=Y.return}for(;ce!==null;){if(Y=yt(ce),Y===null)return;if(Ce=Y.tag,Ce===5||Ce===6||Ce===26||Ce===27){M=D=Y;continue e}ce=ce.parentNode}}M=M.return}KL(function(){var tt=D,dt=RE(_),mt=[];e:{var it=w4.get(h);if(it!==void 0){var ot=vy,Lt=h;switch(h){case"keypress":if(by(_)===0)break e;case"keydown":case"keyup":ot=hne;break;case"focusin":Lt="focus",ot=UE;break;case"focusout":Lt="blur",ot=UE;break;case"beforeblur":case"afterblur":ot=UE;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ot=ZL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ot=ene;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ot=pne;break;case b4:case y4:case v4:ot=rne;break;case _4:ot=xne;break;case"scroll":case"scrollend":ot=Qte;break;case"wheel":ot=yne;break;case"copy":case"cut":case"paste":ot=ane;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ot=JL;break;case"toggle":case"beforetoggle":ot=_ne}var Xt=(m&4)!==0,rr=!Xt&&(h==="scroll"||h==="scrollend"),Ge=Xt?it!==null?it+"Capture":null:it;Xt=[];for(var De=tt,Je;De!==null;){var ft=De;if(Je=ft.stateNode,ft=ft.tag,ft!==5&&ft!==26&&ft!==27||Je===null||Ge===null||(ft=Ng(De,Ge),ft!=null&&Xt.push(ox(De,ft,Je))),rr)break;De=De.return}0<Xt.length&&(it=new ot(it,Lt,null,_,dt),mt.push({event:it,listeners:Xt}))}}if((m&7)===0){e:{if(it=h==="mouseover"||h==="pointerover",ot=h==="mouseout"||h==="pointerout",it&&_!==jE&&(Lt=_.relatedTarget||_.fromElement)&&(yt(Lt)||Lt[sn]))break e;if((ot||it)&&(it=dt.window===dt?dt:(it=dt.ownerDocument)?it.defaultView||it.parentWindow:window,ot?(Lt=_.relatedTarget||_.toElement,ot=tt,Lt=Lt?yt(Lt):null,Lt!==null&&(rr=a(Lt),Xt=Lt.tag,Lt!==rr||Xt!==5&&Xt!==27&&Xt!==6)&&(Lt=null)):(ot=null,Lt=tt),ot!==Lt)){if(Xt=ZL,ft="onMouseLeave",Ge="onMouseEnter",De="mouse",(h==="pointerout"||h==="pointerover")&&(Xt=JL,ft="onPointerLeave",Ge="onPointerEnter",De="pointer"),rr=ot==null?it:Ne(ot),Je=Lt==null?it:Ne(Lt),it=new Xt(ft,De+"leave",ot,_,dt),it.target=rr,it.relatedTarget=Je,ft=null,yt(dt)===tt&&(Xt=new Xt(Ge,De+"enter",Lt,_,dt),Xt.target=Je,Xt.relatedTarget=rr,ft=Xt),rr=ft,ot&&Lt)t:{for(Xt=vre,Ge=ot,De=Lt,Je=0,ft=Ge;ft;ft=Xt(ft))Je++;ft=0;for(var Vt=De;Vt;Vt=Xt(Vt))ft++;for(;0<Je-ft;)Ge=Xt(Ge),Je--;for(;0<ft-Je;)De=Xt(De),ft--;for(;Je--;){if(Ge===De||De!==null&&Ge===De.alternate){Xt=Ge;break t}Ge=Xt(Ge),De=Xt(De)}Xt=null}else Xt=null;ot!==null&&V5(mt,it,ot,Xt,!1),Lt!==null&&rr!==null&&V5(mt,rr,Lt,Xt,!0)}}e:{if(it=tt?Ne(tt):window,ot=it.nodeName&&it.nodeName.toLowerCase(),ot==="select"||ot==="input"&&it.type==="file")var Rn=o4;else if(a4(it))if(l4)Rn=Pne;else{Rn=Cne;var zt=Nne}else ot=it.nodeName,!ot||ot.toLowerCase()!=="input"||it.type!=="checkbox"&&it.type!=="radio"?tt&&PE(tt.elementType)&&(Rn=o4):Rn=kne;if(Rn&&(Rn=Rn(h,tt))){s4(mt,Rn,_,dt);break e}zt&&zt(h,it,tt),h==="focusout"&&tt&&it.type==="number"&&tt.memoizedProps.value!=null&&Pi(it,"number",it.value)}switch(zt=tt?Ne(tt):window,h){case"focusin":(a4(zt)||zt.contentEditable==="true")&&(Df=zt,GE=tt,Lg=null);break;case"focusout":Lg=GE=Df=null;break;case"mousedown":WE=!0;break;case"contextmenu":case"mouseup":case"dragend":WE=!1,g4(mt,_,dt);break;case"selectionchange":if(Rne)break;case"keydown":case"keyup":g4(mt,_,dt)}var ln;if(BE)e:{switch(h){case"compositionstart":var An="onCompositionStart";break e;case"compositionend":An="onCompositionEnd";break e;case"compositionupdate":An="onCompositionUpdate";break e}An=void 0}else Rf?r4(h,_)&&(An="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(An="onCompositionStart");An&&(e4&&_.locale!=="ko"&&(Rf||An!=="onCompositionStart"?An==="onCompositionEnd"&&Rf&&(ln=XL()):(nu=dt,LE="value"in nu?nu.value:nu.textContent,Rf=!0)),zt=uv(tt,An),0<zt.length&&(An=new QL(An,h,null,_,dt),mt.push({event:An,listeners:zt}),ln?An.data=ln:(ln=i4(_),ln!==null&&(An.data=ln)))),(ln=Sne?Mne(h,_):Ene(h,_))&&(An=uv(tt,"onBeforeInput"),0<An.length&&(zt=new QL("onBeforeInput","beforeinput",null,_,dt),mt.push({event:zt,listeners:An}),zt.data=ln)),gre(mt,h,tt,_,dt)}H5(mt,m)})}function ox(h,m,_){return{instance:h,listener:m,currentTarget:_}}function uv(h,m){for(var _=m+"Capture",M=[];h!==null;){var P=h,D=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||D===null||(P=Ng(h,_),P!=null&&M.unshift(ox(h,P,D)),P=Ng(h,m),P!=null&&M.push(ox(h,P,D))),h.tag===3)return M;h=h.return}return[]}function vre(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function V5(h,m,_,M,P){for(var D=m._reactName,Y=[];_!==null&&_!==M;){var ce=_,Ce=ce.alternate,tt=ce.stateNode;if(ce=ce.tag,Ce!==null&&Ce===M)break;ce!==5&&ce!==26&&ce!==27||tt===null||(Ce=tt,P?(tt=Ng(_,D),tt!=null&&Y.unshift(ox(_,tt,Ce))):P||(tt=Ng(_,D),tt!=null&&Y.push(ox(_,tt,Ce)))),_=_.return}Y.length!==0&&h.push({event:m,listeners:Y})}var _re=/\r\n?/g,wre=/\u0000|\uFFFD/g;function G5(h){return(typeof h=="string"?h:""+h).replace(_re,`
- `).replace(wre,"")}function W5(h,m){return m=G5(m),G5(h)===m}function nr(h,m,_,M,P,D){switch(_){case"children":typeof M=="string"?m==="body"||m==="textarea"&&M===""||Zo(h,M):(typeof M=="number"||typeof M=="bigint")&&m!=="body"&&Zo(h,""+M);break;case"className":Ht(h,"class",M);break;case"tabIndex":Ht(h,"tabindex",M);break;case"dir":case"role":case"viewBox":case"width":case"height":Ht(h,_,M);break;case"style":WL(h,M,D);break;case"data":if(m!=="object"){Ht(h,"data",M);break}case"src":case"href":if(M===""&&(m!=="a"||_!=="href")){h.removeAttribute(_);break}if(M==null||typeof M=="function"||typeof M=="symbol"||typeof M=="boolean"){h.removeAttribute(_);break}M=gy(""+M),h.setAttribute(_,M);break;case"action":case"formAction":if(typeof M=="function"){h.setAttribute(_,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof D=="function"&&(_==="formAction"?(m!=="input"&&nr(h,m,"name",P.name,P,null),nr(h,m,"formEncType",P.formEncType,P,null),nr(h,m,"formMethod",P.formMethod,P,null),nr(h,m,"formTarget",P.formTarget,P,null)):(nr(h,m,"encType",P.encType,P,null),nr(h,m,"method",P.method,P,null),nr(h,m,"target",P.target,P,null)));if(M==null||typeof M=="symbol"||typeof M=="boolean"){h.removeAttribute(_);break}M=gy(""+M),h.setAttribute(_,M);break;case"onClick":M!=null&&(h.onclick=Fl);break;case"onScroll":M!=null&&_n("scroll",h);break;case"onScrollEnd":M!=null&&_n("scrollend",h);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(_=M.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=M&&typeof M!="function"&&typeof M!="symbol";break;case"muted":h.muted=M&&typeof M!="function"&&typeof M!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(M==null||typeof M=="function"||typeof M=="boolean"||typeof M=="symbol"){h.removeAttribute("xlink:href");break}_=gy(""+M),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",_);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":M!=null&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,""+M):h.removeAttribute(_);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":M&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":M===!0?h.setAttribute(_,""):M!==!1&&M!=null&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,M):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":M!=null&&typeof M!="function"&&typeof M!="symbol"&&!isNaN(M)&&1<=M?h.setAttribute(_,M):h.removeAttribute(_);break;case"rowSpan":case"start":M==null||typeof M=="function"||typeof M=="symbol"||isNaN(M)?h.removeAttribute(_):h.setAttribute(_,M);break;case"popover":_n("beforetoggle",h),_n("toggle",h),Jt(h,"popover",M);break;case"xlinkActuate":cn(h,"http://www.w3.org/1999/xlink","xlink:actuate",M);break;case"xlinkArcrole":cn(h,"http://www.w3.org/1999/xlink","xlink:arcrole",M);break;case"xlinkRole":cn(h,"http://www.w3.org/1999/xlink","xlink:role",M);break;case"xlinkShow":cn(h,"http://www.w3.org/1999/xlink","xlink:show",M);break;case"xlinkTitle":cn(h,"http://www.w3.org/1999/xlink","xlink:title",M);break;case"xlinkType":cn(h,"http://www.w3.org/1999/xlink","xlink:type",M);break;case"xmlBase":cn(h,"http://www.w3.org/XML/1998/namespace","xml:base",M);break;case"xmlLang":cn(h,"http://www.w3.org/XML/1998/namespace","xml:lang",M);break;case"xmlSpace":cn(h,"http://www.w3.org/XML/1998/namespace","xml:space",M);break;case"is":Jt(h,"is",M);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=Yte.get(_)||_,Jt(h,_,M))}}function xA(h,m,_,M,P,D){switch(_){case"style":WL(h,M,D);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(_=M.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof M=="string"?Zo(h,M):(typeof M=="number"||typeof M=="bigint")&&Zo(h,""+M);break;case"onScroll":M!=null&&_n("scroll",h);break;case"onScrollEnd":M!=null&&_n("scrollend",h);break;case"onClick":M!=null&&(h.onclick=Fl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ct.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(P=_.endsWith("Capture"),m=_.slice(2,P?_.length-7:void 0),D=h[jn]||null,D=D!=null?D[_]:null,typeof D=="function"&&h.removeEventListener(m,D,P),typeof M=="function")){typeof D!="function"&&D!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(m,M,P);break e}_ in h?h[_]=M:M===!0?h.setAttribute(_,""):Jt(h,_,M)}}}function Zi(h,m,_){switch(m){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":_n("error",h),_n("load",h);var M=!1,P=!1,D;for(D in _)if(_.hasOwnProperty(D)){var Y=_[D];if(Y!=null)switch(D){case"src":M=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,m));default:nr(h,m,D,Y,_,null)}}P&&nr(h,m,"srcSet",_.srcSet,_,null),M&&nr(h,m,"src",_.src,_,null);return;case"input":_n("invalid",h);var ce=D=Y=P=null,Ce=null,tt=null;for(M in _)if(_.hasOwnProperty(M)){var dt=_[M];if(dt!=null)switch(M){case"name":P=dt;break;case"type":Y=dt;break;case"checked":Ce=dt;break;case"defaultChecked":tt=dt;break;case"value":D=dt;break;case"defaultValue":ce=dt;break;case"children":case"dangerouslySetInnerHTML":if(dt!=null)throw Error(r(137,m));break;default:nr(h,m,M,dt,_,null)}}Wn(h,D,ce,Ce,tt,Y,P,!1);return;case"select":_n("invalid",h),M=Y=D=null;for(P in _)if(_.hasOwnProperty(P)&&(ce=_[P],ce!=null))switch(P){case"value":D=ce;break;case"defaultValue":Y=ce;break;case"multiple":M=ce;default:nr(h,m,P,ce,_,null)}m=D,_=Y,h.multiple=!!M,m!=null?pi(h,!!M,m,!1):_!=null&&pi(h,!!M,_,!0);return;case"textarea":_n("invalid",h),D=P=M=null;for(Y in _)if(_.hasOwnProperty(Y)&&(ce=_[Y],ce!=null))switch(Y){case"value":M=ce;break;case"defaultValue":P=ce;break;case"children":D=ce;break;case"dangerouslySetInnerHTML":if(ce!=null)throw Error(r(91));break;default:nr(h,m,Y,ce,_,null)}qi(h,M,P,D);return;case"option":for(Ce in _)if(_.hasOwnProperty(Ce)&&(M=_[Ce],M!=null))switch(Ce){case"selected":h.selected=M&&typeof M!="function"&&typeof M!="symbol";break;default:nr(h,m,Ce,M,_,null)}return;case"dialog":_n("beforetoggle",h),_n("toggle",h),_n("cancel",h),_n("close",h);break;case"iframe":case"object":_n("load",h);break;case"video":case"audio":for(M=0;M<sx.length;M++)_n(sx[M],h);break;case"image":_n("error",h),_n("load",h);break;case"details":_n("toggle",h);break;case"embed":case"source":case"link":_n("error",h),_n("load",h);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(tt in _)if(_.hasOwnProperty(tt)&&(M=_[tt],M!=null))switch(tt){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,m));default:nr(h,m,tt,M,_,null)}return;default:if(PE(m)){for(dt in _)_.hasOwnProperty(dt)&&(M=_[dt],M!==void 0&&xA(h,m,dt,M,_,void 0));return}}for(ce in _)_.hasOwnProperty(ce)&&(M=_[ce],M!=null&&nr(h,m,ce,M,_,null))}function Sre(h,m,_,M){switch(m){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var P=null,D=null,Y=null,ce=null,Ce=null,tt=null,dt=null;for(ot in _){var mt=_[ot];if(_.hasOwnProperty(ot)&&mt!=null)switch(ot){case"checked":break;case"value":break;case"defaultValue":Ce=mt;default:M.hasOwnProperty(ot)||nr(h,m,ot,null,M,mt)}}for(var it in M){var ot=M[it];if(mt=_[it],M.hasOwnProperty(it)&&(ot!=null||mt!=null))switch(it){case"type":D=ot;break;case"name":P=ot;break;case"checked":tt=ot;break;case"defaultChecked":dt=ot;break;case"value":Y=ot;break;case"defaultValue":ce=ot;break;case"children":case"dangerouslySetInnerHTML":if(ot!=null)throw Error(r(137,m));break;default:ot!==mt&&nr(h,m,it,ot,M,mt)}}wo(h,Y,ce,Ce,tt,dt,D,P);return;case"select":ot=Y=ce=it=null;for(D in _)if(Ce=_[D],_.hasOwnProperty(D)&&Ce!=null)switch(D){case"value":break;case"multiple":ot=Ce;default:M.hasOwnProperty(D)||nr(h,m,D,null,M,Ce)}for(P in M)if(D=M[P],Ce=_[P],M.hasOwnProperty(P)&&(D!=null||Ce!=null))switch(P){case"value":it=D;break;case"defaultValue":ce=D;break;case"multiple":Y=D;default:D!==Ce&&nr(h,m,P,D,M,Ce)}m=ce,_=Y,M=ot,it!=null?pi(h,!!_,it,!1):!!M!=!!_&&(m!=null?pi(h,!!_,m,!0):pi(h,!!_,_?[]:"",!1));return;case"textarea":ot=it=null;for(ce in _)if(P=_[ce],_.hasOwnProperty(ce)&&P!=null&&!M.hasOwnProperty(ce))switch(ce){case"value":break;case"children":break;default:nr(h,m,ce,null,M,P)}for(Y in M)if(P=M[Y],D=_[Y],M.hasOwnProperty(Y)&&(P!=null||D!=null))switch(Y){case"value":it=P;break;case"defaultValue":ot=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==D&&nr(h,m,Y,P,M,D)}ji(h,it,ot);return;case"option":for(var Lt in _)if(it=_[Lt],_.hasOwnProperty(Lt)&&it!=null&&!M.hasOwnProperty(Lt))switch(Lt){case"selected":h.selected=!1;break;default:nr(h,m,Lt,null,M,it)}for(Ce in M)if(it=M[Ce],ot=_[Ce],M.hasOwnProperty(Ce)&&it!==ot&&(it!=null||ot!=null))switch(Ce){case"selected":h.selected=it&&typeof it!="function"&&typeof it!="symbol";break;default:nr(h,m,Ce,it,M,ot)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Xt in _)it=_[Xt],_.hasOwnProperty(Xt)&&it!=null&&!M.hasOwnProperty(Xt)&&nr(h,m,Xt,null,M,it);for(tt in M)if(it=M[tt],ot=_[tt],M.hasOwnProperty(tt)&&it!==ot&&(it!=null||ot!=null))switch(tt){case"children":case"dangerouslySetInnerHTML":if(it!=null)throw Error(r(137,m));break;default:nr(h,m,tt,it,M,ot)}return;default:if(PE(m)){for(var rr in _)it=_[rr],_.hasOwnProperty(rr)&&it!==void 0&&!M.hasOwnProperty(rr)&&xA(h,m,rr,void 0,M,it);for(dt in M)it=M[dt],ot=_[dt],!M.hasOwnProperty(dt)||it===ot||it===void 0&&ot===void 0||xA(h,m,dt,it,M,ot);return}}for(var Ge in _)it=_[Ge],_.hasOwnProperty(Ge)&&it!=null&&!M.hasOwnProperty(Ge)&&nr(h,m,Ge,null,M,it);for(mt in M)it=M[mt],ot=_[mt],!M.hasOwnProperty(mt)||it===ot||it==null&&ot==null||nr(h,m,mt,it,M,ot)}function q5(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Mre(){if(typeof performance.getEntriesByType=="function"){for(var h=0,m=0,_=performance.getEntriesByType("resource"),M=0;M<_.length;M++){var P=_[M],D=P.transferSize,Y=P.initiatorType,ce=P.duration;if(D&&ce&&q5(Y)){for(Y=0,ce=P.responseEnd,M+=1;M<_.length;M++){var Ce=_[M],tt=Ce.startTime;if(tt>ce)break;var dt=Ce.transferSize,mt=Ce.initiatorType;dt&&q5(mt)&&(Ce=Ce.responseEnd,Y+=dt*(Ce<ce?1:(ce-tt)/(Ce-tt)))}if(--M,m+=8*(D+Y)/(P.duration/1e3),h++,10<h)break}}if(0<h)return m/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var bA=null,yA=null;function dv(h){return h.nodeType===9?h:h.ownerDocument}function K5(h){switch(h){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function X5(h,m){if(h===0)switch(m){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&m==="foreignObject"?0:h}function vA(h,m){return h==="textarea"||h==="noscript"||typeof m.children=="string"||typeof m.children=="number"||typeof m.children=="bigint"||typeof m.dangerouslySetInnerHTML=="object"&&m.dangerouslySetInnerHTML!==null&&m.dangerouslySetInnerHTML.__html!=null}var _A=null;function Ere(){var h=window.event;return h&&h.type==="popstate"?h===_A?!1:(_A=h,!0):(_A=null,!1)}var Y5=typeof setTimeout=="function"?setTimeout:void 0,Are=typeof clearTimeout=="function"?clearTimeout:void 0,Z5=typeof Promise=="function"?Promise:void 0,Tre=typeof queueMicrotask=="function"?queueMicrotask:typeof Z5<"u"?function(h){return Z5.resolve(null).then(h).catch(Nre)}:Y5;function Nre(h){setTimeout(function(){throw h})}function yu(h){return h==="head"}function Q5(h,m){var _=m,M=0;do{var P=_.nextSibling;if(h.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(M===0){h.removeChild(P),om(m);return}M--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")M++;else if(_==="html")lx(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,lx(_);for(var D=_.firstChild;D;){var Y=D.nextSibling,ce=D.nodeName;D[st]||ce==="SCRIPT"||ce==="STYLE"||ce==="LINK"&&D.rel.toLowerCase()==="stylesheet"||_.removeChild(D),D=Y}}else _==="body"&&lx(h.ownerDocument.body);_=P}while(_);om(m)}function J5(h,m){var _=h;h=0;do{var M=_.nextSibling;if(_.nodeType===1?m?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(m?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),M&&M.nodeType===8)if(_=M.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=M}while(_)}function wA(h){var m=h.firstChild;for(m&&m.nodeType===10&&(m=m.nextSibling);m;){var _=m;switch(m=m.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":wA(_),rt(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function Cre(h,m,_,M){for(;h.nodeType===1;){var P=_;if(h.nodeName.toLowerCase()!==m.toLowerCase()){if(!M&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(M){if(!h[st])switch(m){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(D=h.getAttribute("rel"),D==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(D!==P.rel||h.getAttribute("href")!==(P.href==null||P.href===""?null:P.href)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin)||h.getAttribute("title")!==(P.title==null?null:P.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(D=h.getAttribute("src"),(D!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&D&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(m==="input"&&h.type==="hidden"){var D=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===D)return h}else return h;if(h=Bs(h.nextSibling),h===null)break}return null}function kre(h,m,_){if(m==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=Bs(h.nextSibling),h===null))return null;return h}function eF(h,m){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!m||(h=Bs(h.nextSibling),h===null))return null;return h}function SA(h){return h.data==="$?"||h.data==="$~"}function MA(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function Pre(h,m){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=m;else if(h.data!=="$?"||_.readyState!=="loading")m();else{var M=function(){m(),_.removeEventListener("DOMContentLoaded",M)};_.addEventListener("DOMContentLoaded",M),h._reactRetry=M}}function Bs(h){for(;h!=null;h=h.nextSibling){var m=h.nodeType;if(m===1||m===3)break;if(m===8){if(m=h.data,m==="$"||m==="$!"||m==="$?"||m==="$~"||m==="&"||m==="F!"||m==="F")break;if(m==="/$"||m==="/&")return null}}return h}var EA=null;function tF(h){h=h.nextSibling;for(var m=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(m===0)return Bs(h.nextSibling);m--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||m++}h=h.nextSibling}return null}function nF(h){h=h.previousSibling;for(var m=0;h;){if(h.nodeType===8){var _=h.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(m===0)return h;m--}else _!=="/$"&&_!=="/&"||m++}h=h.previousSibling}return null}function rF(h,m,_){switch(m=dv(_),h){case"html":if(h=m.documentElement,!h)throw Error(r(452));return h;case"head":if(h=m.head,!h)throw Error(r(453));return h;case"body":if(h=m.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function lx(h){for(var m=h.attributes;m.length;)h.removeAttributeNode(m[0]);rt(h)}var Hs=new Map,iF=new Set;function hv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var ec=$.d;$.d={f:jre,r:Rre,D:Dre,C:Ore,L:Lre,m:Ire,X:Ure,S:Fre,M:zre};function jre(){var h=ec.f(),m=rv();return h||m}function Rre(h){var m=ae(h);m!==null&&m.tag===5&&m.type==="form"?_I(m):ec.r(h)}var im=typeof document>"u"?null:document;function aF(h,m,_){var M=im;if(M&&typeof m=="string"&&m){var P=$n(m);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),iF.has(P)||(iF.add(P),h={rel:h,crossOrigin:_,href:m},M.querySelector(P)===null&&(m=M.createElement("link"),Zi(m,"link",h),Ie(m),M.head.appendChild(m)))}}function Dre(h){ec.D(h),aF("dns-prefetch",h,null)}function Ore(h,m){ec.C(h,m),aF("preconnect",h,m)}function Lre(h,m,_){ec.L(h,m,_);var M=im;if(M&&h&&m){var P='link[rel="preload"][as="'+$n(m)+'"]';m==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+$n(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+$n(_.imageSizes)+'"]')):P+='[href="'+$n(h)+'"]';var D=P;switch(m){case"style":D=am(h);break;case"script":D=sm(h)}Hs.has(D)||(h=f({rel:"preload",href:m==="image"&&_&&_.imageSrcSet?void 0:h,as:m},_),Hs.set(D,h),M.querySelector(P)!==null||m==="style"&&M.querySelector(cx(D))||m==="script"&&M.querySelector(ux(D))||(m=M.createElement("link"),Zi(m,"link",h),Ie(m),M.head.appendChild(m)))}}function Ire(h,m){ec.m(h,m);var _=im;if(_&&h){var M=m&&typeof m.as=="string"?m.as:"script",P='link[rel="modulepreload"][as="'+$n(M)+'"][href="'+$n(h)+'"]',D=P;switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":D=sm(h)}if(!Hs.has(D)&&(h=f({rel:"modulepreload",href:h},m),Hs.set(D,h),_.querySelector(P)===null)){switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(ux(D)))return}M=_.createElement("link"),Zi(M,"link",h),Ie(M),_.head.appendChild(M)}}}function Fre(h,m,_){ec.S(h,m,_);var M=im;if(M&&h){var P=Ue(M).hoistableStyles,D=am(h);m=m||"default";var Y=P.get(D);if(!Y){var ce={loading:0,preload:null};if(Y=M.querySelector(cx(D)))ce.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":m},_),(_=Hs.get(D))&&AA(h,_);var Ce=Y=M.createElement("link");Ie(Ce),Zi(Ce,"link",h),Ce._p=new Promise(function(tt,dt){Ce.onload=tt,Ce.onerror=dt}),Ce.addEventListener("load",function(){ce.loading|=1}),Ce.addEventListener("error",function(){ce.loading|=2}),ce.loading|=4,fv(Y,m,M)}Y={type:"stylesheet",instance:Y,count:1,state:ce},P.set(D,Y)}}}function Ure(h,m){ec.X(h,m);var _=im;if(_&&h){var M=Ue(_).hoistableScripts,P=sm(h),D=M.get(P);D||(D=_.querySelector(ux(P)),D||(h=f({src:h,async:!0},m),(m=Hs.get(P))&&TA(h,m),D=_.createElement("script"),Ie(D),Zi(D,"link",h),_.head.appendChild(D)),D={type:"script",instance:D,count:1,state:null},M.set(P,D))}}function zre(h,m){ec.M(h,m);var _=im;if(_&&h){var M=Ue(_).hoistableScripts,P=sm(h),D=M.get(P);D||(D=_.querySelector(ux(P)),D||(h=f({src:h,async:!0,type:"module"},m),(m=Hs.get(P))&&TA(h,m),D=_.createElement("script"),Ie(D),Zi(D,"link",h),_.head.appendChild(D)),D={type:"script",instance:D,count:1,state:null},M.set(P,D))}}function sF(h,m,_,M){var P=(P=le.current)?hv(P):null;if(!P)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(m=am(_.href),_=Ue(P).hoistableStyles,M=_.get(m),M||(M={type:"style",instance:null,count:0,state:null},_.set(m,M)),M):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=am(_.href);var D=Ue(P).hoistableStyles,Y=D.get(h);if(Y||(P=P.ownerDocument||P,Y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},D.set(h,Y),(D=P.querySelector(cx(h)))&&!D._p&&(Y.instance=D,Y.state.loading=5),Hs.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Hs.set(h,_),D||Bre(P,h,_,Y.state))),m&&M===null)throw Error(r(528,""));return Y}if(m&&M!==null)throw Error(r(529,""));return null;case"script":return m=_.async,_=_.src,typeof _=="string"&&m&&typeof m!="function"&&typeof m!="symbol"?(m=sm(_),_=Ue(P).hoistableScripts,M=_.get(m),M||(M={type:"script",instance:null,count:0,state:null},_.set(m,M)),M):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function am(h){return'href="'+$n(h)+'"'}function cx(h){return'link[rel="stylesheet"]['+h+"]"}function oF(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function Bre(h,m,_,M){h.querySelector('link[rel="preload"][as="style"]['+m+"]")?M.loading=1:(m=h.createElement("link"),M.preload=m,m.addEventListener("load",function(){return M.loading|=1}),m.addEventListener("error",function(){return M.loading|=2}),Zi(m,"link",_),Ie(m),h.head.appendChild(m))}function sm(h){return'[src="'+$n(h)+'"]'}function ux(h){return"script[async]"+h}function lF(h,m,_){if(m.count++,m.instance===null)switch(m.type){case"style":var M=h.querySelector('style[data-href~="'+$n(_.href)+'"]');if(M)return m.instance=M,Ie(M),M;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return M=(h.ownerDocument||h).createElement("style"),Ie(M),Zi(M,"style",P),fv(M,_.precedence,h),m.instance=M;case"stylesheet":P=am(_.href);var D=h.querySelector(cx(P));if(D)return m.state.loading|=4,m.instance=D,Ie(D),D;M=oF(_),(P=Hs.get(P))&&AA(M,P),D=(h.ownerDocument||h).createElement("link"),Ie(D);var Y=D;return Y._p=new Promise(function(ce,Ce){Y.onload=ce,Y.onerror=Ce}),Zi(D,"link",M),m.state.loading|=4,fv(D,_.precedence,h),m.instance=D;case"script":return D=sm(_.src),(P=h.querySelector(ux(D)))?(m.instance=P,Ie(P),P):(M=_,(P=Hs.get(D))&&(M=f({},_),TA(M,P)),h=h.ownerDocument||h,P=h.createElement("script"),Ie(P),Zi(P,"link",M),h.head.appendChild(P),m.instance=P);case"void":return null;default:throw Error(r(443,m.type))}else m.type==="stylesheet"&&(m.state.loading&4)===0&&(M=m.instance,m.state.loading|=4,fv(M,_.precedence,h));return m.instance}function fv(h,m,_){for(var M=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=M.length?M[M.length-1]:null,D=P,Y=0;Y<M.length;Y++){var ce=M[Y];if(ce.dataset.precedence===m)D=ce;else if(D!==P)break}D?D.parentNode.insertBefore(h,D.nextSibling):(m=_.nodeType===9?_.head:_,m.insertBefore(h,m.firstChild))}function AA(h,m){h.crossOrigin==null&&(h.crossOrigin=m.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=m.referrerPolicy),h.title==null&&(h.title=m.title)}function TA(h,m){h.crossOrigin==null&&(h.crossOrigin=m.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=m.referrerPolicy),h.integrity==null&&(h.integrity=m.integrity)}var mv=null;function cF(h,m,_){if(mv===null){var M=new Map,P=mv=new Map;P.set(_,M)}else P=mv,M=P.get(_),M||(M=new Map,P.set(_,M));if(M.has(h))return M;for(M.set(h,null),_=_.getElementsByTagName(h),P=0;P<_.length;P++){var D=_[P];if(!(D[st]||D[Un]||h==="link"&&D.getAttribute("rel")==="stylesheet")&&D.namespaceURI!=="http://www.w3.org/2000/svg"){var Y=D.getAttribute(m)||"";Y=h+Y;var ce=M.get(Y);ce?ce.push(D):M.set(Y,[D])}}return M}function uF(h,m,_){h=h.ownerDocument||h,h.head.insertBefore(_,m==="title"?h.querySelector("head > title"):null)}function Hre(h,m,_){if(_===1||m.itemProp!=null)return!1;switch(h){case"meta":case"title":return!0;case"style":if(typeof m.precedence!="string"||typeof m.href!="string"||m.href==="")break;return!0;case"link":if(typeof m.rel!="string"||typeof m.href!="string"||m.href===""||m.onLoad||m.onError)break;switch(m.rel){case"stylesheet":return h=m.disabled,typeof m.precedence=="string"&&h==null;default:return!0}case"script":if(m.async&&typeof m.async!="function"&&typeof m.async!="symbol"&&!m.onLoad&&!m.onError&&m.src&&typeof m.src=="string")return!0}return!1}function dF(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function $re(h,m,_,M){if(_.type==="stylesheet"&&(typeof M.media!="string"||matchMedia(M.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=am(M.href),D=m.querySelector(cx(P));if(D){m=D._p,m!==null&&typeof m=="object"&&typeof m.then=="function"&&(h.count++,h=pv.bind(h),m.then(h,h)),_.state.loading|=4,_.instance=D,Ie(D);return}D=m.ownerDocument||m,M=oF(M),(P=Hs.get(P))&&AA(M,P),D=D.createElement("link"),Ie(D);var Y=D;Y._p=new Promise(function(ce,Ce){Y.onload=ce,Y.onerror=Ce}),Zi(D,"link",M),_.instance=D}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,m),(m=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=pv.bind(h),m.addEventListener("load",_),m.addEventListener("error",_))}}var NA=0;function Vre(h,m){return h.stylesheets&&h.count===0&&xv(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var M=setTimeout(function(){if(h.stylesheets&&xv(h,h.stylesheets),h.unsuspend){var D=h.unsuspend;h.unsuspend=null,D()}},6e4+m);0<h.imgBytes&&NA===0&&(NA=62500*Mre());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&xv(h,h.stylesheets),h.unsuspend)){var D=h.unsuspend;h.unsuspend=null,D()}},(h.imgBytes>NA?50:800)+m);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(M),clearTimeout(P)}}:null}function pv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)xv(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var gv=null;function xv(h,m){h.stylesheets=null,h.unsuspend!==null&&(h.count++,gv=new Map,m.forEach(Gre,h),gv=null,pv.call(h))}function Gre(h,m){if(!(m.state.loading&4)){var _=gv.get(h);if(_)var M=_.get(null);else{_=new Map,gv.set(h,_);for(var P=h.querySelectorAll("link[data-precedence],style[data-precedence]"),D=0;D<P.length;D++){var Y=P[D];(Y.nodeName==="LINK"||Y.getAttribute("media")!=="not all")&&(_.set(Y.dataset.precedence,Y),M=Y)}M&&_.set(null,M)}P=m.instance,Y=P.getAttribute("data-precedence"),D=_.get(Y)||M,D===M&&_.set(null,P),_.set(Y,P),this.count++,M=pv.bind(this),P.addEventListener("load",M),P.addEventListener("error",M),D?D.parentNode.insertBefore(P,D.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),m.state.loading|=4}}var dx={$$typeof:w,Provider:null,Consumer:null,_currentValue:J,_currentValue2:J,_threadCount:0};function Wre(h,m,_,M,P,D,Y,ce,Ce){this.tag=1,this.containerInfo=h,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Xe(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xe(0),this.hiddenUpdates=Xe(null),this.identifierPrefix=M,this.onUncaughtError=P,this.onCaughtError=D,this.onRecoverableError=Y,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ce,this.incompleteTransitions=new Map}function hF(h,m,_,M,P,D,Y,ce,Ce,tt,dt,mt){return h=new Wre(h,m,_,Y,Ce,tt,dt,mt,ce),m=1,D===!0&&(m|=24),D=hs(3,null,null,m),h.current=D,D.stateNode=h,m=o2(),m.refCount++,h.pooledCache=m,m.refCount++,D.memoizedState={element:M,isDehydrated:_,cache:m},d2(D),h}function fF(h){return h?(h=If,h):If}function mF(h,m,_,M,P,D){P=fF(P),M.context===null?M.context=P:M.pendingContext=P,M=lu(m),M.payload={element:_},D=D===void 0?null:D,D!==null&&(M.callback=D),_=cu(h,M,m),_!==null&&(qa(_,h,m),$g(_,h,m))}function pF(h,m){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<m?_:m}}function CA(h,m){pF(h,m),(h=h.alternate)&&pF(h,m)}function gF(h){if(h.tag===13||h.tag===31){var m=Bd(h,67108864);m!==null&&qa(m,h,67108864),CA(h,67108864)}}function xF(h){if(h.tag===13||h.tag===31){var m=xs();m=It(m);var _=Bd(h,m);_!==null&&qa(_,h,m),CA(h,m)}}var bv=!0;function qre(h,m,_,M){var P=W.T;W.T=null;var D=$.p;try{$.p=2,kA(h,m,_,M)}finally{$.p=D,W.T=P}}function Kre(h,m,_,M){var P=W.T;W.T=null;var D=$.p;try{$.p=8,kA(h,m,_,M)}finally{$.p=D,W.T=P}}function kA(h,m,_,M){if(bv){var P=PA(M);if(P===null)gA(h,m,M,yv,_),yF(h,M);else if(Yre(P,h,m,_,M))M.stopPropagation();else if(yF(h,M),m&4&&-1<Xre.indexOf(h)){for(;P!==null;){var D=ae(P);if(D!==null)switch(D.tag){case 3:if(D=D.stateNode,D.current.memoizedState.isDehydrated){var Y=Pe(D.pendingLanes);if(Y!==0){var ce=D;for(ce.pendingLanes|=2,ce.entangledLanes|=2;Y;){var Ce=1<<31-Be(Y);ce.entanglements[1]|=Ce,Y&=~Ce}tl(D),(zn&6)===0&&(tv=I()+500,ax(0))}}break;case 31:case 13:ce=Bd(D,2),ce!==null&&qa(ce,D,2),rv(),CA(D,2)}if(D=PA(M),D===null&&gA(h,m,M,yv,_),D===P)break;P=D}P!==null&&M.stopPropagation()}else gA(h,m,M,null,_)}}function PA(h){return h=RE(h),jA(h)}var yv=null;function jA(h){if(yv=null,h=yt(h),h!==null){var m=a(h);if(m===null)h=null;else{var _=m.tag;if(_===13){if(h=s(m),h!==null)return h;h=null}else if(_===31){if(h=l(m),h!==null)return h;h=null}else if(_===3){if(m.stateNode.current.memoizedState.isDehydrated)return m.tag===3?m.stateNode.containerInfo:null;h=null}else m!==h&&(h=null)}}return yv=h,null}function bF(h){switch(h){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ne()){case ve:return 2;case Se:return 8;case ye:case Ke:return 32;case We:return 268435456;default:return 32}default:return 32}}var RA=!1,vu=null,_u=null,wu=null,hx=new Map,fx=new Map,Su=[],Xre="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function yF(h,m){switch(h){case"focusin":case"focusout":vu=null;break;case"dragenter":case"dragleave":_u=null;break;case"mouseover":case"mouseout":wu=null;break;case"pointerover":case"pointerout":hx.delete(m.pointerId);break;case"gotpointercapture":case"lostpointercapture":fx.delete(m.pointerId)}}function mx(h,m,_,M,P,D){return h===null||h.nativeEvent!==D?(h={blockedOn:m,domEventName:_,eventSystemFlags:M,nativeEvent:D,targetContainers:[P]},m!==null&&(m=ae(m),m!==null&&gF(m)),h):(h.eventSystemFlags|=M,m=h.targetContainers,P!==null&&m.indexOf(P)===-1&&m.push(P),h)}function Yre(h,m,_,M,P){switch(m){case"focusin":return vu=mx(vu,h,m,_,M,P),!0;case"dragenter":return _u=mx(_u,h,m,_,M,P),!0;case"mouseover":return wu=mx(wu,h,m,_,M,P),!0;case"pointerover":var D=P.pointerId;return hx.set(D,mx(hx.get(D)||null,h,m,_,M,P)),!0;case"gotpointercapture":return D=P.pointerId,fx.set(D,mx(fx.get(D)||null,h,m,_,M,P)),!0}return!1}function vF(h){var m=yt(h.target);if(m!==null){var _=a(m);if(_!==null){if(m=_.tag,m===13){if(m=s(_),m!==null){h.blockedOn=m,er(h.priority,function(){xF(_)});return}}else if(m===31){if(m=l(_),m!==null){h.blockedOn=m,er(h.priority,function(){xF(_)});return}}else if(m===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function vv(h){if(h.blockedOn!==null)return!1;for(var m=h.targetContainers;0<m.length;){var _=PA(h.nativeEvent);if(_===null){_=h.nativeEvent;var M=new _.constructor(_.type,_);jE=M,_.target.dispatchEvent(M),jE=null}else return m=ae(_),m!==null&&gF(m),h.blockedOn=_,!1;m.shift()}return!0}function _F(h,m,_){vv(h)&&_.delete(m)}function Zre(){RA=!1,vu!==null&&vv(vu)&&(vu=null),_u!==null&&vv(_u)&&(_u=null),wu!==null&&vv(wu)&&(wu=null),hx.forEach(_F),fx.forEach(_F)}function _v(h,m){h.blockedOn===m&&(h.blockedOn=null,RA||(RA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Zre)))}var wv=null;function wF(h){wv!==h&&(wv=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){wv===h&&(wv=null);for(var m=0;m<h.length;m+=3){var _=h[m],M=h[m+1],P=h[m+2];if(typeof M!="function"){if(jA(M||_)===null)continue;break}var D=ae(_);D!==null&&(h.splice(m,3),m-=3,P2(D,{pending:!0,data:P,method:_.method,action:M},M,P))}}))}function om(h){function m(Ce){return _v(Ce,h)}vu!==null&&_v(vu,h),_u!==null&&_v(_u,h),wu!==null&&_v(wu,h),hx.forEach(m),fx.forEach(m);for(var _=0;_<Su.length;_++){var M=Su[_];M.blockedOn===h&&(M.blockedOn=null)}for(;0<Su.length&&(_=Su[0],_.blockedOn===null);)vF(_),_.blockedOn===null&&Su.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(M=0;M<_.length;M+=3){var P=_[M],D=_[M+1],Y=P[jn]||null;if(typeof D=="function")Y||wF(_);else if(Y){var ce=null;if(D&&D.hasAttribute("formAction")){if(P=D,Y=D[jn]||null)ce=Y.formAction;else if(jA(P)!==null)continue}else ce=Y.action;typeof ce=="function"?_[M+1]=ce:(_.splice(M,3),M-=3),wF(_)}}}function SF(){function h(D){D.canIntercept&&D.info==="react-transition"&&D.intercept({handler:function(){return new Promise(function(Y){return P=Y})},focusReset:"manual",scroll:"manual"})}function m(){P!==null&&(P(),P=null),M||setTimeout(_,20)}function _(){if(!M&&!navigation.transition){var D=navigation.currentEntry;D&&D.url!=null&&navigation.navigate(D.url,{state:D.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var M=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",m),navigation.addEventListener("navigateerror",m),setTimeout(_,100),function(){M=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",m),navigation.removeEventListener("navigateerror",m),P!==null&&(P(),P=null)}}}function DA(h){this._internalRoot=h}Sv.prototype.render=DA.prototype.render=function(h){var m=this._internalRoot;if(m===null)throw Error(r(409));var _=m.current,M=xs();mF(_,M,h,m,null,null)},Sv.prototype.unmount=DA.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var m=h.containerInfo;mF(h.current,2,null,h,null,null),rv(),m[sn]=null}};function Sv(h){this._internalRoot=h}Sv.prototype.unstable_scheduleHydration=function(h){if(h){var m=Jn();h={blockedOn:null,target:h,priority:m};for(var _=0;_<Su.length&&m!==0&&m<Su[_].priority;_++);Su.splice(_,0,h),_===0&&vF(h)}};var MF=e.version;if(MF!=="19.2.0")throw Error(r(527,MF,"19.2.0"));$.findDOMNode=function(h){var m=h._reactInternals;if(m===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(m),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var Qre={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:W,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Mv=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Mv.isDisabled&&Mv.supportsFiber)try{ue=Mv.inject(Qre),se=Mv}catch{}}return gx.createRoot=function(h,m){if(!i(h))throw Error(r(299));var _=!1,M="",P=PI,D=jI,Y=RI;return m!=null&&(m.unstable_strictMode===!0&&(_=!0),m.identifierPrefix!==void 0&&(M=m.identifierPrefix),m.onUncaughtError!==void 0&&(P=m.onUncaughtError),m.onCaughtError!==void 0&&(D=m.onCaughtError),m.onRecoverableError!==void 0&&(Y=m.onRecoverableError)),m=hF(h,1,!1,null,null,_,M,null,P,D,Y,SF),h[sn]=m.current,pA(h),new DA(m)},gx.hydrateRoot=function(h,m,_){if(!i(h))throw Error(r(299));var M=!1,P="",D=PI,Y=jI,ce=RI,Ce=null;return _!=null&&(_.unstable_strictMode===!0&&(M=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(D=_.onUncaughtError),_.onCaughtError!==void 0&&(Y=_.onCaughtError),_.onRecoverableError!==void 0&&(ce=_.onRecoverableError),_.formState!==void 0&&(Ce=_.formState)),m=hF(h,1,!0,m,_??null,M,P,Ce,D,Y,ce,SF),m.context=fF(null),_=m.current,M=xs(),M=It(M),P=lu(M),P.callback=null,cu(_,P,M),_=M,m.current.lanes=_,Ut(m,_),tl(m),h[sn]=m.current,pA(h),new Sv(m)},gx.version="19.2.0",gx}var DF;function cie(){if(DF)return IA.exports;DF=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),IA.exports=lie(),IA.exports}var uie=cie();const Zt=t=>typeof t=="string",xx=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},OF=t=>t==null?"":""+t,die=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},hie=/###/g,LF=t=>t&&t.indexOf("###")>-1?t.replace(hie,"."):t,IF=t=>!t||Zt(t),a0=(t,e,n)=>{const r=Zt(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(IF(t))return{};const a=LF(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return IF(t)?{}:{obj:t,k:LF(r[i])}},FF=(t,e,n)=>{const{obj:r,k:i}=a0(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let a=e[e.length-1],s=e.slice(0,e.length-1),l=a0(t,s,Object);for(;l.obj===void 0&&s.length;)a=`${s[s.length-1]}.${a}`,s=s.slice(0,s.length-1),l=a0(t,s,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},fie=(t,e,n,r)=>{const{obj:i,k:a}=a0(t,e,Object);i[a]=i[a]||[],i[a].push(n)},O1=(t,e)=>{const{obj:n,k:r}=a0(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},mie=(t,e,n)=>{const r=O1(t,n);return r!==void 0?r:O1(e,n)},e9=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?Zt(t[r])||t[r]instanceof String||Zt(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):e9(t[r],e[r],n):t[r]=e[r]);return t},lm=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var pie={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const gie=t=>Zt(t)?t.replace(/[&<>"'\/]/g,e=>pie[e]):t;class xie{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;const r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}const bie=[" ",",","?","!",";"],yie=new xie(20),vie=(t,e,n)=>{e=e||"",n=n||"";const r=bie.filter(s=>e.indexOf(s)<0&&n.indexOf(s)<0);if(r.length===0)return!0;const i=yie.getRegExp(`(${r.map(s=>s==="?"?"\\?":s).join("|")})`);let a=!i.test(t);if(!a){const s=t.indexOf(n);s>0&&!i.test(t.substring(0,s))&&(a=!0)}return a},Ik=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let a=0;a<r.length;){if(!i||typeof i!="object")return;let s,l="";for(let c=a;c<r.length;++c)if(c!==a&&(l+=n),l+=r[c],s=i[l],s!==void 0){if(["string","number","boolean"].indexOf(typeof s)>-1&&c<r.length-1)continue;a+=c-a+1;break}i=s}return i},C0=t=>t?.replace("_","-"),_ie={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}};class L1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||_ie,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:(Zt(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new L1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new L1(this.logger,e)}}var fl=new L1;let XS=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,a])=>{for(let s=0;s<a;s++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,a])=>{for(let s=0;s<a;s++)i.apply(i,[e,...n])})}};class UF extends XS{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,s=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;e.indexOf(".")>-1?l=e.split("."):(l=[e,n],r&&(Array.isArray(r)?l.push(...r):Zt(r)&&a?l.push(...r.split(a)):l.push(r)));const c=O1(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!s||!Zt(r)?c:Ik(this.data?.[e]?.[n],r,a)}addResource(e,n,r,i,a={silent:!1}){const s=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let l=[e,n];r&&(l=l.concat(s?r.split(s):r)),e.indexOf(".")>-1&&(l=e.split("."),i=n,n=l[1]),this.addNamespaces(n),FF(this.data,l,i),a.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const a in r)(Zt(r[a])||Array.isArray(r[a]))&&this.addResource(e,n,a,r[a],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,a,s={silent:!1,skipCopy:!1}){let l=[e,n];e.indexOf(".")>-1&&(l=e.split("."),i=r,r=n,n=l[1]),this.addNamespaces(n);let c=O1(this.data,l)||{};s.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?e9(c,r,a):c={...c,...r},FF(this.data,l,c),s.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var t9={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(a=>{e=this.processors[a]?.process(e,n,r,i)??e}),e}};const n9=Symbol("i18next/PATH_KEY");function wie(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===n9?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Fk(t,e){const{[n9]:n}=t(wie());return n.join(e?.keySeparator??".")}const zF={},BA=t=>!Zt(t)&&typeof t!="boolean"&&typeof t!="number";class I1 extends XS{constructor(e,n={}){super(),die(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=fl.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const a=BA(i.res);return!(r.returnObjects===!1&&a)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const s=r&&e.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!vie(e,r,i);if(s&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:Zt(a)?[a]:a};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(a=u.shift()),e=u.join(i)}return{key:e,namespaces:Zt(a)?[a]:a}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=Fk(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const a=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return g?a?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const p=this.resolve(e,i);let x=p?.res;const v=p?.usedKey||l,y=p?.exactUsedKey||l,b=["[object Number]","[object Function]","[object RegExp]"],E=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,A=i.count!==void 0&&!Zt(i.count),T=I1.hasDefaultValue(i),C=A?this.pluralResolver.getSuffix(f,i.count,i):"",N=i.ordinal&&A?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",O=A&&!i.ordinal&&i.count===0,k=O&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${C}`]||i[`defaultValue${N}`]||i.defaultValue;let j=x;w&&!x&&T&&(j=k);const B=BA(j),L=Object.prototype.toString.apply(j);if(w&&j&&B&&b.indexOf(L)<0&&!(Zt(E)&&Array.isArray(j))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const K=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,j,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(p.res=K,p.usedParams=this.getUsedParamsDetails(i),p):K}if(s){const K=Array.isArray(j),R=K?[]:{},q=K?y:v;for(const W in j)if(Object.prototype.hasOwnProperty.call(j,W)){const $=`${q}${s}${W}`;T&&!x?R[W]=this.translate($,{...i,defaultValue:BA(k)?k[W]:void 0,joinArrays:!1,ns:c}):R[W]=this.translate($,{...i,joinArrays:!1,ns:c}),R[W]===$&&(R[W]=j[W])}x=R}}else if(w&&Zt(E)&&Array.isArray(x))x=x.join(E),x&&(x=this.extendTranslation(x,e,i,r));else{let K=!1,R=!1;!this.isValidLookup(x)&&T&&(K=!0,x=k),this.isValidLookup(x)||(R=!0,x=l);const W=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&R?void 0:x,$=T&&k!==x&&this.options.updateMissing;if(R||K||$){if(this.logger.log($?"updateKey":"missingKey",f,u,l,$?k:x),s){const z=this.resolve(l,{...i,keySeparator:!1});z&&z.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let J=[];const ee=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ee&&ee[0])for(let z=0;z<ee.length;z++)J.push(ee[z]);else this.options.saveMissingTo==="all"?J=this.languageUtils.toResolveHierarchy(i.lng||this.language):J.push(i.lng||this.language);const Q=(z,V,X)=>{const te=T&&X!==x?X:W;this.options.missingKeyHandler?this.options.missingKeyHandler(z,u,V,te,$,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(z,u,V,te,$,i),this.emit("missingKey",z,u,V,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?J.forEach(z=>{const V=this.pluralResolver.getSuffixes(z,i);O&&i[`defaultValue${this.options.pluralSeparator}zero`]&&V.indexOf(`${this.options.pluralSeparator}zero`)<0&&V.push(`${this.options.pluralSeparator}zero`),V.forEach(X=>{Q([z],l+X,i[`defaultValue${X}`]||k)})}):Q(J,l,k))}x=this.extendTranslation(x,e,i,p,r),R&&x===l&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${l}`),(R||K)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,K?x:void 0,i))}return a?(p.res=x,p.usedParams=this.getUsedParamsDetails(i),p):x}extendTranslation(e,n,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=Zt(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const f=e.match(this.interpolator.nestingRegexp);u=f&&f.length}let d=r.replace&&!Zt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),c){const f=e.match(this.interpolator.nestingRegexp),g=f&&f.length;u<g&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>a?.[0]===f[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),r)),r.interpolation&&this.interpolator.reset()}const s=r.postProcess||this.options.postProcess,l=Zt(s)?[s]:s;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=t9.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,a,s,l;return Zt(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;i=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const g=n.count!==void 0&&!Zt(n.count),p=g&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(Zt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(y=>{this.isValidLookup(r)||(l=y,!zF[`${v[0]}-${y}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(zF[`${v[0]}-${y}`]=!0,this.logger.warn(`key "${i}" for languages "${v.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(b=>{if(this.isValidLookup(r))return;s=b;const E=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(E,d,b,y,n);else{let A;g&&(A=this.pluralResolver.getSuffix(b,n.count,n));const T=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(g&&(n.ordinal&&A.indexOf(C)===0&&E.push(d+A.replace(C,this.options.pluralSeparator)),E.push(d+A),p&&E.push(d+T)),x){const N=`${d}${this.options.contextSeparator||"_"}${n.context}`;E.push(N),g&&(n.ordinal&&A.indexOf(C)===0&&E.push(N+A.replace(C,this.options.pluralSeparator)),E.push(N+A),p&&E.push(N+T))}}let w;for(;w=E.pop();)this.isValidLookup(r)||(a=w,r=this.getResource(b,y,w,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,usedLng:s,usedNS:l}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!Zt(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const a of n)delete i[a]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class BF{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=fl.create("languageUtils")}getScriptPartFromCode(e){if(e=C0(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=C0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(Zt(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const a=this.getLanguagePartFromCode(r);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(s=>{if(s===a)return s;if(!(s.indexOf("-")<0&&a.indexOf("-")<0)&&(s.indexOf("-")>0&&a.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===a||s.indexOf(a)===0&&a.length>1))return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),Zt(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),i=[],a=s=>{s&&(this.isSupportedCode(s)?i.push(s):this.logger.warn(`rejecting language code not found in supportedLngs: ${s}`))};return Zt(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(e))):Zt(e)&&a(this.formatLanguageCode(e)),r.forEach(s=>{i.indexOf(s)<0&&a(this.formatLanguageCode(s))}),i}}const HF={zero:0,one:1,two:2,few:3,many:4,other:5},$F={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Sie{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=fl.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=C0(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:r,type:i});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let s;try{s=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),$F;if(!e.match(/-|_/))return $F;const c=this.languageUtils.getLanguagePartFromCode(e);s=this.getRule(c,n)}return this.pluralRulesCache[a]=s,s}needsPlural(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,r={}){return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,a)=>HF[i]-HF[a]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const VF=(t,e,n,r=".",i=!0)=>{let a=mie(t,e,n);return!a&&i&&Zt(n)&&(a=Ik(t,n,r),a===void 0&&(a=Ik(e,n,r))),a},HA=t=>t.replace(/\$/g,"$$$$");class Mie{constructor(e={}){this.logger=fl.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:a,prefixEscaped:s,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:g,nestingPrefixEscaped:p,nestingSuffix:x,nestingSuffixEscaped:v,nestingOptionsSeparator:y,maxReplaces:b,alwaysFormat:E}=e.interpolation;this.escape=n!==void 0?n:gie,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?lm(a):s||"{{",this.suffix=l?lm(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=g?lm(g):p||lm("$t("),this.nestingSuffix=x?lm(x):v||lm(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=b||1e3,this.alwaysFormat=E!==void 0?E:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let a,s,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=p=>{if(p.indexOf(this.formatSeparator)<0){const b=VF(n,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(b,void 0,r,{...i,...n,interpolationkey:p}):b}const x=p.split(this.formatSeparator),v=x.shift().trim(),y=x.join(this.formatSeparator).trim();return this.format(VF(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),y,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:p=>HA(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?HA(this.escape(p)):HA(p)}].forEach(p=>{for(l=0;a=p.regex.exec(e);){const x=a[1].trim();if(s=u(x),s===void 0)if(typeof d=="function"){const y=d(e,a,i);s=Zt(y)?y:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))s="";else if(f){s=a[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),s="";else!Zt(s)&&!this.useRawValueToEscape&&(s=OF(s));const v=p.safeValue(s);if(e=e.replace(a[0],v),f?(p.regex.lastIndex+=s.length,p.regex.lastIndex-=a[0].length):p.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,s;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let g=`{${f[1]}`;c=f[0],g=this.interpolate(g,s);const p=g.match(/'/g),x=g.match(/"/g);((p?.length??0)%2===0&&!x||x.length%2!==0)&&(g=g.replace(/'/g,'"'));try{s=JSON.parse(g),u&&(s={...u,...s})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${d}${g}`}return s.defaultValue&&s.defaultValue.indexOf(this.prefix)>-1&&delete s.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];s={...r},s=s.replace&&!Zt(s.replace)?s.replace:s,s.applyPostProcessor=!1,delete s.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(c=i[1].slice(u).split(this.formatSeparator).map(d=>d.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),a=n(l.call(this,i[1].trim(),s),s),a&&i[0]===e&&!Zt(a))return a;Zt(a)||(a=OF(a)),a||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),a=""),c.length&&(a=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:i[1].trim()}),a.trim())),e=e.replace(i[0],a),this.regexp.lastIndex=0}return e}}const Eie=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(s=>{if(s){const[l,...c]=s.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),d=l.trim();n[d]||(n[d]=u),u==="false"&&(n[d]=!1),u==="true"&&(n[d]=!0),isNaN(u)||(n[d]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},GF=t=>{const e={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});const s=r+JSON.stringify(a);let l=e[s];return l||(l=t(C0(r),i),e[s]=l),l(n)}},Aie=t=>(e,n,r)=>t(C0(n),r)(e);class Tie{constructor(e={}){this.logger=fl.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?GF:Aie;this.formats={number:r((i,a)=>{const s=new Intl.NumberFormat(i,{...a});return l=>s.format(l)}),currency:r((i,a)=>{const s=new Intl.NumberFormat(i,{...a,style:"currency"});return l=>s.format(l)}),datetime:r((i,a)=>{const s=new Intl.DateTimeFormat(i,{...a});return l=>s.format(l)}),relativetime:r((i,a)=>{const s=new Intl.RelativeTimeFormat(i,{...a});return l=>s.format(l,a.range||"day")}),list:r((i,a)=>{const s=new Intl.ListFormat(i,{...a});return l=>s.format(l)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=GF(n)}format(e,n,r,i={}){const a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(l=>l.indexOf(")")>-1)){const l=a.findIndex(c=>c.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,l)].join(this.formatSeparator)}return a.reduce((l,c)=>{const{formatName:u,formatOptions:d}=Eie(c);if(this.formats[u]){let f=l;try{const g=i?.formatParams?.[i.interpolationkey]||{},p=g.locale||g.lng||i.locale||i.lng||r;f=this.formats[u](l,p,{...d,...i,...g})}catch(g){this.logger.warn(g)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const Nie=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Cie extends XS{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=fl.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const a={},s={},l={},c={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const g=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?s[g]===void 0&&(s[g]=!0):(this.state[g]=1,d=!1,s[g]===void 0&&(s[g]=!0),a[g]===void 0&&(a[g]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(l[u]=!0)}),(Object.keys(a).length||Object.keys(s).length)&&this.queue.push({pending:s,pendingCount:Object.keys(s).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(s),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),a=i[0],s=i[1];n&&this.emit("failedLoading",a,s,n),!n&&r&&this.store.addResourceBundle(a,s,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const l={};this.queue.forEach(c=>{fie(c.loaded,[a],s),Nie(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{l[u][f]===void 0&&(l[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,a=this.retryTimeout,s){if(!e.length)return s(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:a,callback:s});return}this.readingCalls++;const l=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&d&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,a*2,s)},a);return}s(u,d)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(e,n);u&&typeof u.then=="function"?u.then(d=>l(null,d)).catch(l):l(null,u)}catch(u){l(u)}return}return c(e,n,l)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();Zt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Zt(n)&&(n=[n]);const a=this.queueLoad(e,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(s=>{this.loadOne(s)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],a=r[1];this.read(i,a,"read",void 0,void 0,(s,l)=>{s&&this.logger.warn(`${n}loading namespace ${a} for language ${i} failed`,s),!s&&l&&this.logger.log(`${n}loaded namespace ${a} for language ${i}`,l),this.loaded(e,s,l)})}saveMissing(e,n,r,i,a,s={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...s,isUpdate:a},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(e,n,r,i,c):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}else u(e,n,r,i,l,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const WF=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),Zt(t[1])&&(e.defaultValue=t[1]),Zt(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),qF=t=>(Zt(t.ns)&&(t.ns=[t.ns]),Zt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),Zt(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t),Av=()=>{},kie=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class s0 extends XS{constructor(e={},n){if(super(),this.options=qF(e),this.services={},this.logger=fl,this.modules={external:[]},kie(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,typeof e=="function"&&(n=e,e={}),e.defaultNS==null&&e.ns&&(Zt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=WF();this.options={...r,...this.options,...qF(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?fl.init(i(this.modules.logger),this.options):fl.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Tie;const d=new BF(this.options);this.store=new UF(this.options.resources,this.options);const f=this.services;f.logger=fl,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new Sie(d,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(f.formatter=i(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Mie(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Cie(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(p,...x)=>{this.emit(p,...x)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new I1(this.services,this.options),this.translator.on("*",(p,...x)=>{this.emit(p,...x)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Av),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(u=>{this[u]=(...d)=>this.store[u](...d)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...d)=>(this.store[u](...d),this)});const l=xx(),c=()=>{const u=(d,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(f),n(d,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(e,n=Av){let r=n;const i=Zt(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const a=[],s=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&a.indexOf(u)<0&&a.push(u)})};i?s(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>s(c)),this.options.preload?.forEach?.(l=>s(l)),this.services.backendConnector.load(a,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(e,n,r){const i=xx();return typeof e=="function"&&(r=e,e=void 0),typeof n=="function"&&(r=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),r||(r=Av),this.services.backendConnector.reload(e,n,a=>{i.resolve(),r(a)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&t9.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;const r=xx();this.emit("languageChanging",e);const i=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(l,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...u)=>this.t(...u)),n&&n(l,(...u)=>this.t(...u))},s=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);const c=Zt(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(Zt(l)?[l]:l);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,d=>{a(d,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?s(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(s):this.services.languageDetector.detect(s):s(e),r}getFixedT(e,n,r){const i=(a,s,...l)=>{let c;typeof s!="object"?c=this.options.overloadTranslationOptionHandler([a,s].concat(l)):c={...s},c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||i.keyPrefix);const u=this.options.keySeparator||".";let d;return c.keyPrefix&&Array.isArray(a)?d=a.map(f=>(typeof f=="function"&&(f=Fk(f,{...this.options,...s})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=Fk(a,{...this.options,...s})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return Zt(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=r,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const s=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,s);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||s(r,e)&&(!i||s(a,e)))}loadNamespaces(e,n){const r=xx();return this.options.ns?(Zt(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=xx();Zt(e)&&(e=[e]);const i=this.options.preload||[],a=e.filter(s=>i.indexOf(s)<0&&this.services.languageUtils.isSupportedCode(s));return a.length?(this.options.preload=i.concat(a),this.loadResources(s=>{r.resolve(),n&&n(s)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const a=i.getTextInfo();if(a&&a.direction)return a.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new BF(WF());return e.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){const r=new s0(e,n);return r.createInstance=s0.createInstance,r}cloneInstance(e={},n=Av){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new s0(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(l=>{a[l]=this[l]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r){const l=Object.keys(this.store.data).reduce((c,u)=>(c[u]={...this.store.data[u]},c[u]=Object.keys(c[u]).reduce((d,f)=>(d[f]={...c[u][f]},d),c[u]),c),{});a.store=new UF(l,i),a.services.resourceStore=a.store}return a.translator=new I1(a.services,i),a.translator.on("*",(l,...c)=>{a.emit(l,...c)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Ba=s0.createInstance();Ba.createInstance;Ba.dir;Ba.init;Ba.loadResources;Ba.reloadResources;Ba.use;Ba.changeLanguage;Ba.getFixedT;Ba.t;Ba.exists;Ba.setDefaultNamespace;Ba.hasLoadedNamespace;Ba.loadNamespaces;Ba.loadLanguages;const Pie=(t,e,n,r)=>{const i=[n,{code:e,...r||{}}];if(t?.services?.logger?.forward)return t.services.logger.forward(i,"warn","react-i18next::",!0);Xh(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},KF={},r9=(t,e,n,r)=>{Xh(n)&&KF[n]||(Xh(n)&&(KF[n]=new Date),Pie(t,e,n,r))},i9=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},Uk=(t,e,n)=>{t.loadNamespaces(e,i9(t,n))},XF=(t,e,n,r)=>{if(Xh(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return Uk(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,i9(t,r))},jie=(t,e,n={})=>!e.languages||!e.languages.length?(r9(e,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:e.languages}),!0):e.hasLoadedNamespace(t,{lng:n.lng,precheck:(r,i)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&r.services.backendConnector.backend&&r.isLanguageChangingTo&&!i(r.isLanguageChangingTo,t))return!1}}),Xh=t=>typeof t=="string",Rie=t=>typeof t=="object"&&t!==null,Die=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Oie={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},Lie=t=>Oie[t],Iie=t=>t.replace(Die,Lie);let zk={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Iie};const Fie=(t={})=>{zk={...zk,...t}},Uie=()=>zk;let a9;const zie=t=>{a9=t},Bie=()=>a9,Hie={type:"3rdParty",init(t){Fie(t.options.react),zie(t)}},$ie=S.createContext();class Vie{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var $A={exports:{}},VA={};var YF;function Gie(){if(YF)return VA;YF=1;var t=tg();function e(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,s=t.useDebugValue;function l(f,g){var p=g(),x=r({inst:{value:p,getSnapshot:g}}),v=x[0].inst,y=x[1];return a(function(){v.value=p,v.getSnapshot=g,c(v)&&y({inst:v})},[f,p,g]),i(function(){return c(v)&&y({inst:v}),f(function(){c(v)&&y({inst:v})})},[f]),s(p),p}function c(f){var g=f.getSnapshot;f=f.value;try{var p=g();return!n(f,p)}catch{return!0}}function u(f,g){return g()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return VA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,VA}var ZF;function s9(){return ZF||(ZF=1,$A.exports=Gie()),$A.exports}var Zj=s9();const Wie=(t,e)=>Xh(e)?e:Rie(e)&&Xh(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,qie={t:Wie,ready:!1},Kie=()=>()=>{},ng=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=S.useContext($ie)||{},a=n||r||Bie();a&&!a.reportNamespaces&&(a.reportNamespaces=new Vie),a||r9(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const s=S.useMemo(()=>({...Uie(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=s,u=i||a?.options?.defaultNS,d=Xh(u)?[u]:u||["translation"],f=S.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const g=S.useRef(0),p=S.useCallback(k=>{if(!a)return Kie;const{bindI18n:j,bindI18nStore:B}=s,L=()=>{g.current+=1,k()};return j&&a.on(j,L),B&&a.store.on(B,L),()=>{j&&j.split(" ").forEach(K=>a.off(K,L)),B&&B.split(" ").forEach(K=>a.store.off(K,L))}},[a,s]),x=S.useRef(),v=S.useCallback(()=>{if(!a)return qie;const k=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(q=>jie(q,a,s)),j=e.lng||a.language,B=g.current,L=x.current;if(L&&L.ready===k&&L.lng===j&&L.keyPrefix===c&&L.revision===B)return L;const R={t:a.getFixedT(j,s.nsMode==="fallback"?f:f[0],c),ready:k,lng:j,keyPrefix:c,revision:B};return x.current=R,R},[a,f,c,s,e.lng]),[y,b]=S.useState(0),{t:E,ready:w}=Zj.useSyncExternalStore(p,v,v);S.useEffect(()=>{if(a&&!w&&!l){const k=()=>b(j=>j+1);e.lng?XF(a,e.lng,f,k):Uk(a,f,k)}},[a,e.lng,f,w,l,y]);const A=a||{},T=S.useRef(null),C=S.useRef(),N=k=>{const j=Object.getOwnPropertyDescriptors(k);j.__original&&delete j.__original;const B=Object.create(Object.getPrototypeOf(k),j);if(!Object.prototype.hasOwnProperty.call(B,"__original"))try{Object.defineProperty(B,"__original",{value:k,writable:!1,enumerable:!1,configurable:!1})}catch{}return B},O=S.useMemo(()=>{const k=A,j=k?.language;let B=k;k&&(T.current&&T.current.__original===k?C.current!==j?(B=N(k),T.current=B,C.current=j):B=T.current:(B=N(k),T.current=B,C.current=j));const L=[E,B,w];return L.t=E,L.i18n=B,L.ready=w,L},[E,A,w,A.resolvedLanguage,A.language,A.languages]);if(a&&l&&!w)throw new Promise(k=>{const j=()=>k();e.lng?XF(a,e.lng,f,j):Uk(a,f,j)});return O},{slice:Xie,forEach:Yie}=[];function Zie(t){return Yie.call(Xie.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Qie(t){return typeof t!="string"?!1:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(n=>n.test(t))}const QF=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Jie=function(t,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let a=`${t}=${i}`;if(r.maxAge>0){const s=r.maxAge-0;if(Number.isNaN(s))throw new Error("maxAge should be a Number");a+=`; Max-Age=${Math.floor(s)}`}if(r.domain){if(!QF.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!QF.test(r.path))throw new TypeError("option path is invalid");a+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(a+="; HttpOnly"),r.secure&&(a+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(a+="; Partitioned"),a},JF={create(t,e,n,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};n&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+n*60*1e3)),r&&(i.domain=r),document.cookie=Jie(t,e,i)},read(t){const e=`${t}=`,n=document.cookie.split(";");for(let r=0;r<n.length;r++){let i=n[r];for(;i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return i.substring(e.length,i.length)}return null},remove(t,e){this.create(t,"",-1,e)}};var eae={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return JF.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&JF.create(n,t,r,i,a)}},tae={name:"querystring",lookup(t){let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const a=r.substring(1).split("&");for(let s=0;s<a.length;s++){const l=a[s].indexOf("=");l>0&&a[s].substring(0,l)===e&&(n=a[s].substring(l+1))}}return n}},nae={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,r;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const a=i.substring(1);if(e){const s=a.split("&");for(let l=0;l<s.length;l++){const c=s[l].indexOf("=");c>0&&s[l].substring(0,c)===e&&(r=s[l].substring(c+1))}}if(r)return r;if(!r&&n>-1){const s=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(s)?s[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return r}};let cm=null;const eU=()=>{if(cm!==null)return cm;try{if(cm=typeof window<"u"&&window.localStorage!==null,!cm)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{cm=!1}return cm};var rae={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&eU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&eU()&&window.localStorage.setItem(n,t)}};let um=null;const tU=()=>{if(um!==null)return um;try{if(um=typeof window<"u"&&window.sessionStorage!==null,!um)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{um=!1}return um};var iae={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&tU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&tU()&&window.sessionStorage.setItem(n,t)}},aae={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:r,language:i}=navigator;if(n)for(let a=0;a<n.length;a++)e.push(n[a]);r&&e.push(r),i&&e.push(i)}return e.length>0?e:void 0}},sae={name:"htmlTag",lookup(t){let{htmlTag:e}=t,n;const r=e||(typeof document<"u"?document.documentElement:null);return r&&typeof r.getAttribute=="function"&&(n=r.getAttribute("lang")),n}},oae={name:"path",lookup(t){let{lookupFromPathIndex:e}=t;if(typeof window>"u")return;const n=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(n)?n[typeof e=="number"?e:0]?.replace("/",""):void 0}},lae={name:"subdomain",lookup(t){let{lookupFromSubdomainIndex:e}=t;const n=typeof e=="number"?e+1:1,r=typeof window<"u"&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[n]}};let o9=!1;try{document.cookie,o9=!0}catch{}const l9=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];o9||l9.splice(1,1);const cae=()=>({order:l9,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class c9{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(e,n)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=Zie(n,this.options||{},cae()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=i=>i.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=r,this.addDetector(eae),this.addDetector(tae),this.addDetector(rae),this.addDetector(iae),this.addDetector(aae),this.addDetector(sae),this.addDetector(oae),this.addDetector(lae),this.addDetector(nae)}addDetector(e){return this.detectors[e.name]=e,this}detect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,n=[];return e.forEach(r=>{if(this.detectors[r]){let i=this.detectors[r].lookup(this.options);i&&typeof i=="string"&&(i=[i]),i&&(n=n.concat(i))}}),n=n.filter(r=>r!=null&&!Qie(r)).map(r=>this.options.convertDetectedLanguage(r)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?n:n.length>0?n[0]:null}cacheUserLanguage(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;n&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||n.forEach(r=>{this.detectors[r]&&this.detectors[r].cacheUserLanguage(e,this.options)}))}}c9.type="languageDetector";const uae={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",settings:"Settings",system:"System",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode"},common:{save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",close:"Close",confirm:"Confirm",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",enabled:"Enabled",disabled:"Disabled",yes:"Yes",no:"No",on:"On",off:"Off",all:"All",none:"None",search:"Search",filter:"Filter",sort:"Sort",refresh:"Refresh",download:"Download",upload:"Upload",actions:"Actions",status:"Status",name:"Name",description:"Description",date:"Date",time:"Time",hours:"hours",minutes:"minutes",seconds:"seconds",noPrinters:"No printers configured",noData:"No data available",required:"Required",optional:"Optional"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address",accessCode:"Access Code",model:"Model",nozzleCount:"Nozzle Count",autoArchive:"Auto Archive",status:{idle:"Idle",printing:"Printing",paused:"Paused",offline:"Offline",error:"Error",finished:"Finished",unknown:"Unknown"},temperatures:{nozzle:"Nozzle",bed:"Bed",chamber:"Chamber"},progress:"{{percent}}% complete",timeRemaining:"{{time}} remaining",deleteConfirm:'Are you sure you want to delete "{{name}}"?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} warning",maintenanceWarning_plural:"{{count}} warnings",maintenanceDue:"{{count}} due",maintenanceDue_plural:"{{count}} due"},archives:{title:"Print Archives",searchPlaceholder:"Search archives...",filterByPrinter:"Filter by printer",filterByStatus:"Filter by status",sortBy:"Sort by",sortNewest:"Newest first",sortOldest:"Oldest first",sortName:"Name",sortDuration:"Duration",noArchives:"No archives found",printTime:"Print Time",filamentUsed:"Filament Used",cost:"Cost",reprint:"Reprint",preview:"Preview",deleteArchive:"Delete Archive",deleteConfirm:"Are you sure you want to delete this archive?",favorite:"Favorite",unfavorite:"Remove from favorites",viewDetails:"View Details",status:{completed:"Completed",failed:"Failed",stopped:"Stopped"}},queue:{title:"Print Queue",addToQueue:"Add to Queue",clearQueue:"Clear Queue",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",remove:"Remove",startNow:"Start Now",status:{pending:"Pending",printing:"Printing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"}},stats:{title:"Statistics",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",totalFilament:"Total Filament Used",totalCost:"Total Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time"},profiles:{title:"Filament Profiles",addProfile:"Add Profile",editProfile:"Edit Profile",deleteProfile:"Delete Profile",material:"Material",brand:"Brand",color:"Color",diameter:"Diameter",density:"Density",costPerKg:"Cost per kg",spoolWeight:"Spool Weight",noProfiles:"No profiles configured",deleteConfirm:"Are you sure you want to delete this profile?"},maintenance:{title:"Maintenance",overview:"Overview",allOk:"All maintenance up to date",dueCount:"{{count}} item due",dueCount_plural:"{{count}} items due",warningCount:"{{count}} warning",warningCount_plural:"{{count}} warnings",totalPrintTime:"Total Print Time",nextMaintenance:"Next Maintenance",nothingDue:"Nothing due",tasks:"Tasks",lastPerformed:"Last performed",interval:"Interval",hoursRemaining:"{{hours}}h remaining",hoursOverdue:"{{hours}}h overdue",markDone:"Mark as Done",performMaintenance:"Perform Maintenance",history:"History",noHistory:"No maintenance history",editPrintHours:"Edit Print Hours",currentHours:"Current Hours",types:{lubricateRails:"Lubricate Linear Rails",cleanNozzle:"Clean Nozzle/Hotend",checkBelts:"Check Belt Tension",cleanBuildPlate:"Clean Build Plate",checkExtruder:"Check Extruder Gears",checkCooling:"Check Cooling Fans",generalInspection:"General Inspection"}},settings:{title:"Settings",general:"General",appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",telemetry:"Anonymous telemetry",telemetryDescription:"Help improve BamBuddy by sending anonymous usage data",telemetryLearnMore:"Learn more",telemetryInfoTitle:"What data is collected?",telemetryInfoIntro:"BamBuddy collects minimal anonymous data to help understand how many people use the app and which versions are in use. This helps prioritize bug fixes and new features.",telemetryInfoCollected:"What we collect:",telemetryInfoItem1:"A random installation ID (not linked to you or your hardware)",telemetryInfoItem2:"The app version you're running",telemetryInfoItem3:"A timestamp (to count daily/weekly active users)",telemetryInfoNotCollected:"What we do NOT collect:",telemetryInfoNotItem1:"IP addresses or location data",telemetryInfoNotItem2:"Printer names, serial numbers, or any printer data",telemetryInfoNotItem3:"Print history, filenames, or any personal content",telemetryInfoNotItem4:"Any information that could identify you",telemetryInfoFooter:"You can disable telemetry at any time. The installation ID is randomly generated and cannot be traced back to you.",notificationLanguage:"Notification Language",notificationLanguageDescription:"Language for push notifications",notificationProviders:"Notification Providers",addProvider:"Add Provider",editProvider:"Edit Provider",providerType:"Provider Type",testNotification:"Test Notification",testSuccess:"Test notification sent successfully",testFailed:"Failed to send test notification",quietHours:"Quiet Hours",quietHoursDescription:"Do not disturb during these hours",quietHoursStart:"Start",quietHoursEnd:"End",events:{title:"Notification Events",printStart:"Print Started",printComplete:"Print Completed",printFailed:"Print Failed",printStopped:"Print Stopped",printProgress:"Progress Milestones",printProgressDescription:"Notify at 25%, 50%, 75%",printerOffline:"Printer Offline",printerError:"Printer Error",filamentLow:"Low Filament",maintenanceDue:"Maintenance Due",maintenanceDueDescription:"Notify when maintenance is needed"},smartPlug:{title:"Smart Plugs",add:"Add Smart Plug",edit:"Edit Smart Plug",name:"Name",ipAddress:"IP Address",linkedPrinter:"Linked Printer",autoOn:"Auto Power On",autoOnDescription:"Turn on when print starts",autoOff:"Auto Power Off",autoOffDescription:"Turn off after print completes",offDelay:"Off Delay",offDelayMinutes:"Minutes after print",offDelayTemp:"When nozzle below temperature",currentState:"Current State",turnOn:"Turn On",turnOff:"Turn Off"},spoolmanEnabled:"Enable Spoolman Integration",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Connected",spoolmanDisconnected:"Disconnected"},notification:{printStarted:{title:"Print Started",body:"{{printer}}: {{filename}} has started printing"},printCompleted:{title:"Print Completed",body:"{{printer}}: {{filename}} completed successfully"},printFailed:{title:"Print Failed",body:"{{printer}}: {{filename}} has failed"},printStopped:{title:"Print Stopped",body:"{{printer}}: {{filename}} was stopped"},printProgress:{title:"Print Progress",body:"{{printer}}: {{filename}} is {{percent}}% complete"},printerOffline:{title:"Printer Offline",body:"{{printer}} is offline"},printerError:{title:"Printer Error",body:"{{printer}}: {{error}}"},filamentLow:{title:"Low Filament",body:"{{printer}}: Filament is running low"},maintenanceDue:{title:"Maintenance Due",body:"{{printer}}: {{items}} need attention"}},errors:{generic:"Something went wrong",networkError:"Network error. Please check your connection.",notFound:"Not found",unauthorized:"Unauthorized",serverError:"Server error",validationError:"Please check your input",printerConnectionFailed:"Failed to connect to printer",saveFailed:"Failed to save changes",deleteFailed:"Failed to delete",loadFailed:"Failed to load data"},confirm:{delete:"Are you sure you want to delete this?",unsavedChanges:"You have unsaved changes. Are you sure you want to leave?",clearQueue:"Are you sure you want to clear the queue?"}},dae={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",settings:"Einstellungen",system:"System",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln"},common:{save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",close:"Schließen",confirm:"Bestätigen",loading:"Lädt...",error:"Fehler",success:"Erfolg",warning:"Warnung",enabled:"Aktiviert",disabled:"Deaktiviert",yes:"Ja",no:"Nein",on:"An",off:"Aus",all:"Alle",none:"Keine",search:"Suchen",filter:"Filtern",sort:"Sortieren",refresh:"Aktualisieren",download:"Herunterladen",upload:"Hochladen",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",date:"Datum",time:"Zeit",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",required:"Erforderlich",optional:"Optional"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse",accessCode:"Zugangscode",model:"Modell",nozzleCount:"Düsenanzahl",autoArchive:"Automatische Archivierung",status:{idle:"Bereit",printing:"Druckt",paused:"Pausiert",offline:"Offline",error:"Fehler",finished:"Fertig",unknown:"Unbekannt"},temperatures:{nozzle:"Düse",bed:"Druckbett",chamber:"Kammer"},progress:"{{percent}}% abgeschlossen",timeRemaining:"Noch {{time}}",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',maintenanceOk:"Wartung OK",maintenanceWarning:"{{count}} Warnung",maintenanceWarning_plural:"{{count}} Warnungen",maintenanceDue:"{{count}} fällig",maintenanceDue_plural:"{{count}} fällig"},archives:{title:"Druckarchiv",searchPlaceholder:"Archiv durchsuchen...",filterByPrinter:"Nach Drucker filtern",filterByStatus:"Nach Status filtern",sortBy:"Sortieren nach",sortNewest:"Neueste zuerst",sortOldest:"Älteste zuerst",sortName:"Name",sortDuration:"Dauer",noArchives:"Keine Archive gefunden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Erneut drucken",preview:"Vorschau",deleteArchive:"Archiv löschen",deleteConfirm:"Möchten Sie dieses Archiv wirklich löschen?",favorite:"Favorit",unfavorite:"Aus Favoriten entfernen",viewDetails:"Details anzeigen",status:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",stopped:"Gestoppt"}},queue:{title:"Druckwarteschlange",addToQueue:"Zur Warteschlange hinzufügen",clearQueue:"Warteschlange leeren",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",remove:"Entfernen",startNow:"Jetzt starten",status:{pending:"Ausstehend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"}},stats:{title:"Statistiken",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",totalFilament:"Gesamtverbrauch Filament",totalCost:"Gesamtkosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt"},profiles:{title:"Filament-Profile",addProfile:"Profil hinzufügen",editProfile:"Profil bearbeiten",deleteProfile:"Profil löschen",material:"Material",brand:"Marke",color:"Farbe",diameter:"Durchmesser",density:"Dichte",costPerKg:"Kosten pro kg",spoolWeight:"Spulengewicht",noProfiles:"Keine Profile konfiguriert",deleteConfirm:"Möchten Sie dieses Profil wirklich löschen?"},maintenance:{title:"Wartung",overview:"Übersicht",allOk:"Alle Wartungen aktuell",dueCount:"{{count}} Aufgabe fällig",dueCount_plural:"{{count}} Aufgaben fällig",warningCount:"{{count}} Warnung",warningCount_plural:"{{count}} Warnungen",totalPrintTime:"Gesamtdruckzeit",nextMaintenance:"Nächste Wartung",nothingDue:"Nichts fällig",tasks:"Aufgaben",lastPerformed:"Zuletzt durchgeführt",interval:"Intervall",hoursRemaining:"{{hours}}h verbleibend",hoursOverdue:"{{hours}}h überfällig",markDone:"Als erledigt markieren",performMaintenance:"Wartung durchführen",history:"Verlauf",noHistory:"Kein Wartungsverlauf",editPrintHours:"Druckstunden bearbeiten",currentHours:"Aktuelle Stunden",types:{lubricateRails:"Linearschienen schmieren",cleanNozzle:"Düse/Hotend reinigen",checkBelts:"Riemenspannung prüfen",cleanBuildPlate:"Druckbett reinigen",checkExtruder:"Extruderzahnräder prüfen",checkCooling:"Kühlungslüfter prüfen",generalInspection:"Allgemeine Inspektion"}},settings:{title:"Einstellungen",general:"Allgemein",appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",telemetry:"Anonyme Telemetrie",telemetryDescription:"Helfen Sie BamBuddy zu verbessern, indem Sie anonyme Nutzungsdaten senden",telemetryLearnMore:"Mehr erfahren",telemetryInfoTitle:"Welche Daten werden gesammelt?",telemetryInfoIntro:"BamBuddy sammelt minimale anonyme Daten, um zu verstehen, wie viele Personen die App nutzen und welche Versionen verwendet werden. Dies hilft bei der Priorisierung von Fehlerbehebungen und neuen Funktionen.",telemetryInfoCollected:"Was wir sammeln:",telemetryInfoItem1:"Eine zufällige Installations-ID (nicht mit Ihnen oder Ihrer Hardware verknüpft)",telemetryInfoItem2:"Die App-Version, die Sie verwenden",telemetryInfoItem3:"Ein Zeitstempel (um tägliche/wöchentliche aktive Nutzer zu zählen)",telemetryInfoNotCollected:"Was wir NICHT sammeln:",telemetryInfoNotItem1:"IP-Adressen oder Standortdaten",telemetryInfoNotItem2:"Druckernamen, Seriennummern oder Druckerdaten",telemetryInfoNotItem3:"Druckverlauf, Dateinamen oder persönliche Inhalte",telemetryInfoNotItem4:"Informationen, die Sie identifizieren könnten",telemetryInfoFooter:"Sie können die Telemetrie jederzeit deaktivieren. Die Installations-ID wird zufällig generiert und kann nicht zu Ihnen zurückverfolgt werden.",notificationLanguage:"Benachrichtigungssprache",notificationLanguageDescription:"Sprache für Push-Benachrichtigungen",notificationProviders:"Benachrichtigungsanbieter",addProvider:"Anbieter hinzufügen",editProvider:"Anbieter bearbeiten",providerType:"Anbietertyp",testNotification:"Testbenachrichtigung",testSuccess:"Testbenachrichtigung erfolgreich gesendet",testFailed:"Testbenachrichtigung konnte nicht gesendet werden",quietHours:"Ruhezeiten",quietHoursDescription:"Keine Störungen während dieser Zeiten",quietHoursStart:"Beginn",quietHoursEnd:"Ende",events:{title:"Benachrichtigungsereignisse",printStart:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",printProgress:"Fortschrittsmeldungen",printProgressDescription:"Bei 25%, 50%, 75% benachrichtigen",printerOffline:"Drucker offline",printerError:"Druckerfehler",filamentLow:"Filament niedrig",maintenanceDue:"Wartung fällig",maintenanceDueDescription:"Benachrichtigen, wenn Wartung erforderlich"},smartPlug:{title:"Smart Plugs",add:"Smart Plug hinzufügen",edit:"Smart Plug bearbeiten",name:"Name",ipAddress:"IP-Adresse",linkedPrinter:"Verknüpfter Drucker",autoOn:"Automatisch einschalten",autoOnDescription:"Einschalten beim Druckstart",autoOff:"Automatisch ausschalten",autoOffDescription:"Ausschalten nach Druckende",offDelay:"Ausschaltverzögerung",offDelayMinutes:"Minuten nach Druck",offDelayTemp:"Wenn Düse unter Temperatur",currentState:"Aktueller Status",turnOn:"Einschalten",turnOff:"Ausschalten"},spoolmanEnabled:"Spoolman-Integration aktivieren",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden"},notification:{printStarted:{title:"Druck gestartet",body:"{{printer}}: {{filename}} wird gedruckt"},printCompleted:{title:"Druck abgeschlossen",body:"{{printer}}: {{filename}} erfolgreich abgeschlossen"},printFailed:{title:"Druck fehlgeschlagen",body:"{{printer}}: {{filename}} ist fehlgeschlagen"},printStopped:{title:"Druck gestoppt",body:"{{printer}}: {{filename}} wurde gestoppt"},printProgress:{title:"Druckfortschritt",body:"{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen"},printerOffline:{title:"Drucker offline",body:"{{printer}} ist offline"},printerError:{title:"Druckerfehler",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filament niedrig",body:"{{printer}}: Filament geht zur Neige"},maintenanceDue:{title:"Wartung fällig",body:"{{printer}}: {{items}} benötigen Aufmerksamkeit"}},errors:{generic:"Etwas ist schiefgelaufen",networkError:"Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.",notFound:"Nicht gefunden",unauthorized:"Nicht autorisiert",serverError:"Serverfehler",validationError:"Bitte überprüfen Sie Ihre Eingabe",printerConnectionFailed:"Verbindung zum Drucker fehlgeschlagen",saveFailed:"Speichern fehlgeschlagen",deleteFailed:"Löschen fehlgeschlagen",loadFailed:"Laden der Daten fehlgeschlagen"},confirm:{delete:"Möchten Sie dies wirklich löschen?",unsavedChanges:"Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?",clearQueue:"Möchten Sie die Warteschlange wirklich leeren?"}},hae={en:{translation:uae},de:{translation:dae}};Ba.use(c9).use(Hie).init({resources:hae,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const nU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var rU="popstate";function fae(t={}){function e(r,i){let{pathname:a,search:s,hash:l}=r.location;return Bk("",{pathname:a,search:s,hash:l},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:k0(i)}return pae(e,n,null,t)}function Dr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Vo(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function mae(){return Math.random().toString(36).substring(2,10)}function iU(t,e){return{usr:t.state,key:t.key,idx:e}}function Bk(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?rg(e):e,state:n,key:e&&e.key||r||mae()}}function k0({pathname:t="/",search:e="",hash:n=""}){return e&&e!=="?"&&(t+=e.charAt(0)==="?"?e:"?"+e),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function rg(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substring(n),t=t.substring(0,n));let r=t.indexOf("?");r>=0&&(e.search=t.substring(r),t=t.substring(0,r)),t&&(e.pathname=t)}return e}function pae(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,s=i.history,l="POP",c=null,u=d();u==null&&(u=0,s.replaceState({...s.state,idx:u},""));function d(){return(s.state||{idx:null}).idx}function f(){l="POP";let y=d(),b=y==null?null:y-u;u=y,c&&c({action:l,location:v.location,delta:b})}function g(y,b){l="PUSH";let E=Bk(v.location,y,b);u=d()+1;let w=iU(E,u),A=v.createHref(E);try{s.pushState(w,"",A)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;i.location.assign(A)}a&&c&&c({action:l,location:v.location,delta:1})}function p(y,b){l="REPLACE";let E=Bk(v.location,y,b);u=d();let w=iU(E,u),A=v.createHref(E);s.replaceState(w,"",A),a&&c&&c({action:l,location:v.location,delta:0})}function x(y){return gae(y)}let v={get action(){return l},get location(){return t(i,s)},listen(y){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(rU,f),c=y,()=>{i.removeEventListener(rU,f),c=null}},createHref(y){return e(i,y)},createURL:x,encodeLocation(y){let b=x(y);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:g,replace:p,go(y){return s.go(y)}};return v}function gae(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Dr(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:k0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function u9(t,e,n="/"){return xae(t,e,n,!1)}function xae(t,e,n,r){let i=typeof e=="string"?rg(e):e,a=Uc(i.pathname||"/",n);if(a==null)return null;let s=d9(t);bae(s);let l=null;for(let c=0;l==null&&c<s.length;++c){let u=Cae(a);l=Tae(s[c],u,r)}return l}function d9(t,e=[],n=[],r="",i=!1){let a=(s,l,c=i,u)=>{let d={relativePath:u===void 0?s.path||"":u,caseSensitive:s.caseSensitive===!0,childrenIndex:l,route:s};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&c)return;Dr(d.relativePath.startsWith(r),`Absolute route path "${d.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(r.length)}let f=Pc([r,d.relativePath]),g=n.concat(d);s.children&&s.children.length>0&&(Dr(s.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),d9(s.children,e,g,f,c)),!(s.path==null&&!s.index)&&e.push({path:f,score:Eae(f,s.index),routesMeta:g})};return t.forEach((s,l)=>{if(s.path===""||!s.path?.includes("?"))a(s,l);else for(let c of h9(s.path))a(s,l,!0,c)}),e}function h9(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return i?[a,""]:[a];let s=h9(r.join("/")),l=[];return l.push(...s.map(c=>c===""?a:[a,c].join("/"))),i&&l.push(...s),l.map(c=>t.startsWith("/")&&c===""?"/":c)}function bae(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Aae(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var yae=/^:[\w-]+$/,vae=3,_ae=2,wae=1,Sae=10,Mae=-2,aU=t=>t==="*";function Eae(t,e){let n=t.split("/"),r=n.length;return n.some(aU)&&(r+=Mae),e&&(r+=_ae),n.filter(i=>!aU(i)).reduce((i,a)=>i+(yae.test(a)?vae:a===""?wae:Sae),r)}function Aae(t,e){return t.length===e.length&&t.slice(0,-1).every((r,i)=>r===e[i])?t[t.length-1]-e[e.length-1]:0}function Tae(t,e,n=!1){let{routesMeta:r}=t,i={},a="/",s=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,d=a==="/"?e:e.slice(a.length)||"/",f=F1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),g=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=F1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),s.push({params:i,pathname:Pc([a,f.pathname]),pathnameBase:Dae(Pc([a,f.pathnameBase])),route:g}),f.pathnameBase!=="/"&&(a=Pc([a,f.pathnameBase]))}return s}function F1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Nae(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let a=i[0],s=a.replace(/(.)\/+$/,"$1"),l=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},g)=>{if(d==="*"){let x=l[g]||"";s=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const p=l[g];return f&&!p?u[d]=void 0:u[d]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:s,pattern:t}}function Nae(t,e=!1,n=!0){Vo(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let r=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(s,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function Cae(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Vo(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${e}).`),t}}function Uc(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}var kae=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Pae=t=>kae.test(t);function jae(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?rg(t):t,a;if(n)if(Pae(n))a=n;else{if(n.includes("//")){let s=n;n=n.replace(/\/\/+/g,"/"),Vo(!1,`Pathnames cannot have embedded double slashes - normalizing ${s} -> ${n}`)}n.startsWith("/")?a=sU(n.substring(1),"/"):a=sU(n,e)}else a=e;return{pathname:a,search:Oae(r),hash:Lae(i)}}function sU(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function GA(t,e,n,r){return`Cannot include a '${t}' character in a manually specified \`to.${e}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Rae(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function f9(t){let e=Rae(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function m9(t,e,n,r=!1){let i;typeof t=="string"?i=rg(t):(i={...t},Dr(!i.pathname||!i.pathname.includes("?"),GA("?","pathname","search",i)),Dr(!i.pathname||!i.pathname.includes("#"),GA("#","pathname","hash",i)),Dr(!i.search||!i.search.includes("#"),GA("#","search","hash",i)));let a=t===""||i.pathname==="",s=a?"/":i.pathname,l;if(s==null)l=n;else{let f=e.length-1;if(!r&&s.startsWith("..")){let g=s.split("/");for(;g[0]==="..";)g.shift(),f-=1;i.pathname=g.join("/")}l=f>=0?e[f]:"/"}let c=jae(i,l),u=s&&s!=="/"&&s.endsWith("/"),d=(a||s===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Pc=t=>t.join("/").replace(/\/\/+/g,"/"),Dae=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Oae=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Lae=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function Iae(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var p9=["POST","PUT","PATCH","DELETE"];new Set(p9);var Fae=["GET",...p9];new Set(Fae);var ig=S.createContext(null);ig.displayName="DataRouter";var YS=S.createContext(null);YS.displayName="DataRouterState";S.createContext(!1);var g9=S.createContext({isTransitioning:!1});g9.displayName="ViewTransition";var Uae=S.createContext(new Map);Uae.displayName="Fetchers";var zae=S.createContext(null);zae.displayName="Await";var Pl=S.createContext(null);Pl.displayName="Navigation";var Sb=S.createContext(null);Sb.displayName="Location";var qo=S.createContext({outlet:null,matches:[],isDataRoute:!1});qo.displayName="Route";var Qj=S.createContext(null);Qj.displayName="RouteError";function Bae(t,{relative:e}={}){Dr(Mb(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=S.useContext(Pl),{hash:i,pathname:a,search:s}=Ab(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:Pc([n,a])),r.createHref({pathname:l,search:s,hash:i})}function Mb(){return S.useContext(Sb)!=null}function kd(){return Dr(Mb(),"useLocation() may be used only in the context of a <Router> component."),S.useContext(Sb).location}var x9="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function b9(t){S.useContext(Pl).static||S.useLayoutEffect(t)}function Eb(){let{isDataRoute:t}=S.useContext(qo);return t?nse():Hae()}function Hae(){Dr(Mb(),"useNavigate() may be used only in the context of a <Router> component.");let t=S.useContext(ig),{basename:e,navigator:n}=S.useContext(Pl),{matches:r}=S.useContext(qo),{pathname:i}=kd(),a=JSON.stringify(f9(r)),s=S.useRef(!1);return b9(()=>{s.current=!0}),S.useCallback((c,u={})=>{if(Vo(s.current,x9),!s.current)return;if(typeof c=="number"){n.go(c);return}let d=m9(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Pc([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var $ae=S.createContext(null);function Vae(t){let e=S.useContext(qo).outlet;return S.useMemo(()=>e&&S.createElement($ae.Provider,{value:t},e),[e,t])}function Jj(){let{matches:t}=S.useContext(qo),e=t[t.length-1];return e?e.params:{}}function Ab(t,{relative:e}={}){let{matches:n}=S.useContext(qo),{pathname:r}=kd(),i=JSON.stringify(f9(n));return S.useMemo(()=>m9(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Gae(t,e){return y9(t,e)}function y9(t,e,n,r,i){Dr(Mb(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=S.useContext(Pl),{matches:s}=S.useContext(qo),l=s[s.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",f=l&&l.route;{let E=f&&f.path||"";v9(u,!f||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${E}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
- Please change the parent <Route path="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let g=kd(),p;if(e){let E=typeof e=="string"?rg(e):e;Dr(d==="/"||E.pathname?.startsWith(d),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${E.pathname}" was given in the \`location\` prop.`),p=E}else p=g;let x=p.pathname||"/",v=x;if(d!=="/"){let E=d.replace(/^\//,"").split("/");v="/"+x.replace(/^\//,"").split("/").slice(E.length).join("/")}let y=u9(t,{pathname:v});Vo(f||y!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Vo(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let b=Yae(y&&y.map(E=>Object.assign({},E,{params:Object.assign({},c,E.params),pathname:Pc([d,a.encodeLocation?a.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?d:Pc([d,a.encodeLocation?a.encodeLocation(E.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),s,n,r,i);return e&&b?S.createElement(Sb.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},b):b}function Wae(){let t=tse(),e=Iae(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},s=null;return console.error("Error handled by React Router default ErrorBoundary:",t),s=S.createElement(S.Fragment,null,S.createElement("p",null,"💿 Hey developer 👋"),S.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",S.createElement("code",{style:a},"ErrorBoundary")," or"," ",S.createElement("code",{style:a},"errorElement")," prop on your route.")),S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},e),n?S.createElement("pre",{style:i},n):null,s)}var qae=S.createElement(Wae,null),Kae=class extends S.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){return this.state.error!==void 0?S.createElement(qo.Provider,{value:this.props.routeContext},S.createElement(Qj.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Xae({routeContext:t,match:e,children:n}){let r=S.useContext(ig);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),S.createElement(qo.Provider,{value:t},n)}function Yae(t,e=[],n=null,r=null,i=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let a=t,s=n?.errors;if(s!=null){let d=a.findIndex(f=>f.route.id&&s?.[f.route.id]!==void 0);Dr(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let l=!1,c=-1;if(n)for(let d=0;d<a.length;d++){let f=a[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=d),f.route.id){let{loaderData:g,errors:p}=n,x=f.route.loader&&!g.hasOwnProperty(f.route.id)&&(!p||p[f.route.id]===void 0);if(f.route.lazy||x){l=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:f})}:void 0;return a.reduceRight((d,f,g)=>{let p,x=!1,v=null,y=null;n&&(p=s&&f.route.id?s[f.route.id]:void 0,v=f.route.errorElement||qae,l&&(c<0&&g===0?(v9("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,y=null):c===g&&(x=!0,y=f.route.hydrateFallbackElement||null)));let b=e.concat(a.slice(0,g+1)),E=()=>{let w;return p?w=v:x?w=y:f.route.Component?w=S.createElement(f.route.Component,null):f.route.element?w=f.route.element:w=d,S.createElement(Xae,{match:f,routeContext:{outlet:d,matches:b,isDataRoute:n!=null},children:w})};return n&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?S.createElement(Kae,{location:n.location,revalidation:n.revalidation,component:v,error:p,children:E(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:u}):E()},null)}function eR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Zae(t){let e=S.useContext(ig);return Dr(e,eR(t)),e}function Qae(t){let e=S.useContext(YS);return Dr(e,eR(t)),e}function Jae(t){let e=S.useContext(qo);return Dr(e,eR(t)),e}function tR(t){let e=Jae(t),n=e.matches[e.matches.length-1];return Dr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function ese(){return tR("useRouteId")}function tse(){let t=S.useContext(Qj),e=Qae("useRouteError"),n=tR("useRouteError");return t!==void 0?t:e.errors?.[n]}function nse(){let{router:t}=Zae("useNavigate"),e=tR("useNavigate"),n=S.useRef(!1);return b9(()=>{n.current=!0}),S.useCallback(async(i,a={})=>{Vo(n.current,x9),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var oU={};function v9(t,e,n){!e&&!oU[t]&&(oU[t]=!0,Vo(!1,n))}S.memo(rse);function rse({routes:t,future:e,state:n,unstable_onError:r}){return y9(t,void 0,n,r,e)}function ise(t){return Vae(t.context)}function Ya(t){Dr(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function ase({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1}){Dr(!Mb(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let s=t.replace(/^\/*/,"/"),l=S.useMemo(()=>({basename:s,navigator:i,static:a,future:{}}),[s,i,a]);typeof n=="string"&&(n=rg(n));let{pathname:c="/",search:u="",hash:d="",state:f=null,key:g="default"}=n,p=S.useMemo(()=>{let x=Uc(c,s);return x==null?null:{location:{pathname:x,search:u,hash:d,state:f,key:g},navigationType:r}},[s,c,u,d,f,g,r]);return Vo(p!=null,`<Router basename="${s}"> is not able to match the URL "${c}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:S.createElement(Pl.Provider,{value:l},S.createElement(Sb.Provider,{children:e,value:p}))}function sse({children:t,location:e}){return Gae(Hk(t),e)}function Hk(t,e=[]){let n=[];return S.Children.forEach(t,(r,i)=>{if(!S.isValidElement(r))return;let a=[...e,i];if(r.type===S.Fragment){n.push.apply(n,Hk(r.props.children,a));return}Dr(r.type===Ya,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Dr(!r.props.index||!r.props.children,"An index route cannot have child routes.");let s={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(s.children=Hk(r.props.children,a)),n.push(s)}),n}var d1="get",h1="application/x-www-form-urlencoded";function ZS(t){return t!=null&&typeof t.tagName=="string"}function ose(t){return ZS(t)&&t.tagName.toLowerCase()==="button"}function lse(t){return ZS(t)&&t.tagName.toLowerCase()==="form"}function cse(t){return ZS(t)&&t.tagName.toLowerCase()==="input"}function use(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function dse(t,e){return t.button===0&&(!e||e==="_self")&&!use(t)}var Tv=null;function hse(){if(Tv===null)try{new FormData(document.createElement("form"),0),Tv=!1}catch{Tv=!0}return Tv}var fse=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function WA(t){return t!=null&&!fse.has(t)?(Vo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${h1}"`),null):t}function mse(t,e){let n,r,i,a,s;if(lse(t)){let l=t.getAttribute("action");r=l?Uc(l,e):null,n=t.getAttribute("method")||d1,i=WA(t.getAttribute("enctype"))||h1,a=new FormData(t)}else if(ose(t)||cse(t)&&(t.type==="submit"||t.type==="image")){let l=t.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=t.getAttribute("formaction")||l.getAttribute("action");if(r=c?Uc(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||d1,i=WA(t.getAttribute("formenctype"))||WA(l.getAttribute("enctype"))||h1,a=new FormData(l,t),!hse()){let{name:u,type:d,value:f}=t;if(d==="image"){let g=u?`${u}.`:"";a.append(`${g}x`,"0"),a.append(`${g}y`,"0")}else u&&a.append(u,f)}}else{if(ZS(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=d1,r=null,i=h1,s=t}return a&&i==="text/plain"&&(s=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function nR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function pse(t,e,n){let r=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return r.pathname==="/"?r.pathname=`_root.${n}`:e&&Uc(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function gse(t,e){if(t.id in e)return e[t.id];try{let n=await import(t.module);return e[t.id]=n,n}catch(n){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function xse(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function bse(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let s=await gse(a,n);return s.links?s.links():[]}return[]}));return wse(r.flat(1).filter(xse).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function lU(t,e,n,r,i,a){let s=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>n[u].pathname!==c.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==c.params["*"];return a==="assets"?e.filter((c,u)=>s(c,u)||l(c,u)):a==="data"?e.filter((c,u)=>{let d=r.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(s(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let f=c.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function yse(t,e,{includeHydrateFallback:n}={}){return vse(t.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let a=[i.module];return i.clientActionModule&&(a=a.concat(i.clientActionModule)),i.clientLoaderModule&&(a=a.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(a=a.concat(i.hydrateFallbackModule)),i.imports&&(a=a.concat(i.imports)),a}).flat(1))}function vse(t){return[...new Set(t)]}function _se(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function wse(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(_se(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function _9(){let t=S.useContext(ig);return nR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Sse(){let t=S.useContext(YS);return nR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var rR=S.createContext(void 0);rR.displayName="FrameworkContext";function w9(){let t=S.useContext(rR);return nR(t,"You must render this element inside a <HydratedRouter> element"),t}function Mse(t,e){let n=S.useContext(rR),[r,i]=S.useState(!1),[a,s]=S.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,g=S.useRef(null);S.useEffect(()=>{if(t==="render"&&s(!0),t==="viewport"){let v=b=>{b.forEach(E=>{s(E.isIntersecting)})},y=new IntersectionObserver(v,{threshold:.5});return g.current&&y.observe(g.current),()=>{y.disconnect()}}},[t]),S.useEffect(()=>{if(r){let v=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(v)}}},[r]);let p=()=>{i(!0)},x=()=>{i(!1),s(!1)};return n?t!=="intent"?[a,g,{}]:[a,g,{onFocus:bx(l,p),onBlur:bx(c,x),onMouseEnter:bx(u,p),onMouseLeave:bx(d,x),onTouchStart:bx(f,p)}]:[!1,g,{}]}function bx(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Ese({page:t,...e}){let{router:n}=_9(),r=S.useMemo(()=>u9(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?S.createElement(Tse,{page:t,matches:r,...e}):null}function Ase(t){let{manifest:e,routeModules:n}=w9(),[r,i]=S.useState([]);return S.useEffect(()=>{let a=!1;return bse(t,e,n).then(s=>{a||i(s)}),()=>{a=!0}},[t,e,n]),r}function Tse({page:t,matches:e,...n}){let r=kd(),{manifest:i,routeModules:a}=w9(),{basename:s}=_9(),{loaderData:l,matches:c}=Sse(),u=S.useMemo(()=>lU(t,e,c,i,r,"data"),[t,e,c,i,r]),d=S.useMemo(()=>lU(t,e,c,i,r,"assets"),[t,e,c,i,r]),f=S.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let x=new Set,v=!1;if(e.forEach(b=>{let E=i.routes[b.route.id];!E||!E.hasLoader||(!u.some(w=>w.route.id===b.route.id)&&b.route.id in l&&a[b.route.id]?.shouldRevalidate||E.hasClientLoader?v=!0:x.add(b.route.id))}),x.size===0)return[];let y=pse(t,s,"data");return v&&x.size>0&&y.searchParams.set("_routes",e.filter(b=>x.has(b.route.id)).map(b=>b.route.id).join(",")),[y.pathname+y.search]},[s,l,r,i,u,e,t,a]),g=S.useMemo(()=>yse(d,i),[d,i]),p=Ase(d);return S.createElement(S.Fragment,null,f.map(x=>S.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),g.map(x=>S.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),p.map(({key:x,link:v})=>S.createElement("link",{key:x,nonce:n.nonce,...v})))}function Nse(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var S9=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{S9&&(window.__reactRouterVersion="7.9.6")}catch{}function Cse({basename:t,children:e,window:n}){let r=S.useRef();r.current==null&&(r.current=fae({window:n,v5Compat:!0}));let i=r.current,[a,s]=S.useState({action:i.action,location:i.location}),l=S.useCallback(c=>{S.startTransition(()=>s(c))},[s]);return S.useLayoutEffect(()=>i.listen(l),[i,l]),S.createElement(ase,{basename:t,children:e,location:a.location,navigationType:a.action,navigator:i})}var M9=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Sc=S.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:a,replace:s,state:l,target:c,to:u,preventScrollReset:d,viewTransition:f,...g},p){let{basename:x}=S.useContext(Pl),v=typeof u=="string"&&M9.test(u),y,b=!1;if(typeof u=="string"&&v&&(y=u,S9))try{let k=new URL(window.location.href),j=u.startsWith("//")?new URL(k.protocol+u):new URL(u),B=Uc(j.pathname,x);j.origin===k.origin&&B!=null?u=B+j.search+j.hash:b=!0}catch{Vo(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let E=Bae(u,{relative:i}),[w,A,T]=Mse(r,g),C=jse(u,{replace:s,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f});function N(k){e&&e(k),k.defaultPrevented||C(k)}let O=S.createElement("a",{...g,...T,href:y||E,onClick:b||a?e:N,ref:Nse(p,A),target:c,"data-discover":!v&&n==="render"?"true":void 0});return w&&!v?S.createElement(S.Fragment,null,O,S.createElement(Ese,{page:E})):O});Sc.displayName="Link";var Gx=S.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:a,to:s,viewTransition:l,children:c,...u},d){let f=Ab(s,{relative:u.relative}),g=kd(),p=S.useContext(YS),{navigator:x,basename:v}=S.useContext(Pl),y=p!=null&&Ise(f)&&l===!0,b=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,E=g.pathname,w=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(E=E.toLowerCase(),w=w?w.toLowerCase():null,b=b.toLowerCase()),w&&v&&(w=Uc(w,v)||w);const A=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let T=E===b||!i&&E.startsWith(b)&&E.charAt(A)==="/",C=w!=null&&(w===b||!i&&w.startsWith(b)&&w.charAt(b.length)==="/"),N={isActive:T,isPending:C,isTransitioning:y},O=T?e:void 0,k;typeof r=="function"?k=r(N):k=[r,T?"active":null,C?"pending":null,y?"transitioning":null].filter(Boolean).join(" ");let j=typeof a=="function"?a(N):a;return S.createElement(Sc,{...u,"aria-current":O,className:k,ref:d,style:j,to:s,viewTransition:l},typeof c=="function"?c(N):c)});Gx.displayName="NavLink";var kse=S.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:s=d1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,...g},p)=>{let x=Ose(),v=Lse(l,{relative:u}),y=s.toLowerCase()==="get"?"get":"post",b=typeof l=="string"&&M9.test(l),E=w=>{if(c&&c(w),w.defaultPrevented)return;w.preventDefault();let A=w.nativeEvent.submitter,T=A?.getAttribute("formmethod")||s;x(A||w.currentTarget,{fetcherKey:e,method:T,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f})};return S.createElement("form",{ref:p,method:y,action:v,onSubmit:r?c:E,...g,"data-discover":!b&&t==="render"?"true":void 0})});kse.displayName="Form";function Pse(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function E9(t){let e=S.useContext(ig);return Dr(e,Pse(t)),e}function jse(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:s}={}){let l=Eb(),c=kd(),u=Ab(t,{relative:a});return S.useCallback(d=>{if(dse(d,e)){d.preventDefault();let f=n!==void 0?n:k0(c)===k0(u);l(t,{replace:f,state:r,preventScrollReset:i,relative:a,viewTransition:s})}},[c,l,u,n,r,e,t,i,a,s])}var Rse=0,Dse=()=>`__${String(++Rse)}__`;function Ose(){let{router:t}=E9("useSubmit"),{basename:e}=S.useContext(Pl),n=ese();return S.useCallback(async(r,i={})=>{let{action:a,method:s,encType:l,formData:c,body:u}=mse(r,e);if(i.navigate===!1){let d=i.fetcherKey||Dse();await t.fetch(d,n,i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||s,formEncType:i.encType||l,flushSync:i.flushSync})}else await t.navigate(i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||s,formEncType:i.encType||l,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function Lse(t,{relative:e}={}){let{basename:n}=S.useContext(Pl),r=S.useContext(qo);Dr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...Ab(t||".",{relative:e})},s=kd();if(t==null){a.search=s.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(f=>f).forEach(f=>l.append("index",f));let d=l.toString();a.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Pc([n,a.pathname])),k0(a)}function Ise(t,{relative:e}={}){let n=S.useContext(g9);Dr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=E9("useViewTransitionState"),i=Ab(t,{relative:e});if(!n.isTransitioning)return!1;let a=Uc(n.currentLocation.pathname,r)||n.currentLocation.pathname,s=Uc(n.nextLocation.pathname,r)||n.nextLocation.pathname;return F1(i.pathname,s)!=null||F1(i.pathname,a)!=null}var Mc=JG();const Fse=yo(Mc);var ag=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Use={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},zse=class{#e=Use;#t=!1;setTimeoutProvider(t){this.#e=t}setTimeout(t,e){return this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},Eh=new zse;function Bse(t){setTimeout(t,0)}var Yh=typeof window>"u"||"Deno"in globalThis;function Ca(){}function Hse(t,e){return typeof t=="function"?t(e):t}function $k(t){return typeof t=="number"&&t>=0&&t!==1/0}function A9(t,e){return Math.max(t+(e||0)-Date.now(),0)}function sd(t,e){return typeof t=="function"?t(e):t}function Zs(t,e){return typeof t=="function"?t(e):t}function cU(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:s,stale:l}=t;if(s){if(r){if(e.queryHash!==iR(s,e.options))return!1}else if(!P0(e.queryKey,s))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||i&&i!==e.state.fetchStatus||a&&!a(e))}function uU(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(Zh(e.options.mutationKey)!==Zh(a))return!1}else if(!P0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function iR(t,e){return(e?.queryKeyHashFn||Zh)(t)}function Zh(t){return JSON.stringify(t,(e,n)=>Vk(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function P0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>P0(t[n],e[n])):!1}var $se=Object.prototype.hasOwnProperty;function T9(t,e){if(t===e)return t;const n=dU(t)&&dU(e);if(!n&&!(Vk(t)&&Vk(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),s=a.length,l=n?new Array(s):{};let c=0;for(let u=0;u<s;u++){const d=n?u:a[u],f=t[d],g=e[d];if(f===g){l[d]=f,(n?u<i:$se.call(t,d))&&c++;continue}if(f===null||g===null||typeof f!="object"||typeof g!="object"){l[d]=g;continue}const p=T9(f,g);l[d]=p,p===f&&c++}return i===s&&c===i?t:l}function U1(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(t[n]!==e[n])return!1;return!0}function dU(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Vk(t){if(!hU(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!hU(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function hU(t){return Object.prototype.toString.call(t)==="[object Object]"}function Vse(t){return new Promise(e=>{Eh.setTimeout(e,t)})}function Gk(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?T9(t,e):e}function Gse(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function Wse(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var aR=Symbol();function N9(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===aR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function C9(t,e){return typeof t=="function"?t(...e):!!t}var qse=class extends ag{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!Yh&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},sR=new qse;function Wk(){let t,e;const n=new Promise((i,a)=>{t=i,e=a});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var Kse=Bse;function Xse(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=Kse;const a=l=>{e?t.push(l):i(()=>{n(l)})},s=()=>{const l=t;t=[],l.length&&i(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||s()}return c},batchCalls:l=>(...c)=>{a(()=>{l(...c)})},schedule:a,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var vi=Xse(),Yse=class extends ag{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!Yh&&window.addEventListener){const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#e}},z1=new Yse;function Zse(t){return Math.min(1e3*2**t,3e4)}function k9(t){return(t??"online")==="online"?z1.isOnline():!0}var qk=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function P9(t){let e=!1,n=0,r;const i=Wk(),a=()=>i.status!=="pending",s=v=>{if(!a()){const y=new qk(v);g(y),t.onCancel?.(y)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>sR.isFocused()&&(t.networkMode==="always"||z1.isOnline())&&t.canRun(),d=()=>k9(t.networkMode)&&t.canRun(),f=v=>{a()||(r?.(),i.resolve(v))},g=v=>{a()||(r?.(),i.reject(v))},p=()=>new Promise(v=>{r=y=>{(a()||u())&&v(y)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),x=()=>{if(a())return;let v;const y=n===0?t.initialPromise:void 0;try{v=y??t.fn()}catch(b){v=Promise.reject(b)}Promise.resolve(v).then(f).catch(b=>{if(a())return;const E=t.retry??(Yh?0:3),w=t.retryDelay??Zse,A=typeof w=="function"?w(n,b):w,T=E===!0||typeof E=="number"&&n<E||typeof E=="function"&&E(n,b);if(e||!T){g(b);return}n++,t.onFail?.(n,b),Vse(A).then(()=>u()?void 0:p()).then(()=>{e?g(b):x()})})};return{promise:i,status:()=>i.status,cancel:s,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():p().then(x),i)}}var j9=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),$k(this.gcTime)&&(this.#e=Eh.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Yh?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Eh.clearTimeout(this.#e),this.#e=void 0)}},Qse=class extends j9{#e;#t;#n;#i;#r;#s;#o;constructor(t){super(),this.#o=!1,this.#s=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#n=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=mU(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#s,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=mU(this.options);e.data!==void 0&&(this.setState(fU(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=Gk(this.state.data,t,this.options);return this.#a({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#a({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(Ca).catch(Ca):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Zs(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===aR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>sd(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!A9(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#a({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const l=this.observers.find(c=>c.options.queryFn);l&&this.setOptions(l.options)}const n=new AbortController,r=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const l=N9(this.options,e),u=(()=>{const d={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(d),d})();return this.#o=!1,this.options.persister?this.options.persister(l,u,this):l(u)},s=(()=>{const l={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(l),l})();this.options.behavior?.onFetch(s,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#a({type:"fetch",meta:s.fetchOptions?.meta}),this.#r=P9({initialPromise:e?.initialPromise,fn:s.fetchFn,onCancel:l=>{l instanceof qk&&l.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(l,c)=>{this.#a({type:"failed",failureCount:l,error:c})},onPause:()=>{this.#a({type:"pause"})},onContinue:()=>{this.#a({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0});try{const l=await this.#r.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#n.config.onSuccess?.(l,this),this.#n.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof qk){if(l.silent)return this.#r.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#a({type:"error",error:l}),this.#n.config.onError?.(l,this),this.#n.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#a(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...R9(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...fU(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=t.manual?r:void 0,r;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),vi.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function R9(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:k9(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function fU(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function mU(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,n=e!==void 0,r=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Jse=class extends ag{constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=Wk(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#i=void 0;#r;#s;#o;#a;#p;#h;#f;#c;#u;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),pU(this.#t,this.options)?this.#d():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Kk(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Kk(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#_(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Zs(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#t.setOptions(this.options),e._defaulted&&!U1(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&gU(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||Zs(this.options.enabled,this.#t)!==Zs(e.enabled,this.#t)||sd(this.options.staleTime,this.#t)!==sd(e.staleTime,this.#t))&&this.#g();const i=this.#x();r&&(this.#t!==n||Zs(this.options.enabled,this.#t)!==Zs(e.enabled,this.#t)||i!==this.#l)&&this.#b(i)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(e,t);return toe(this,n)&&(this.#i=n,this.#s=this.options,this.#r=this.#t.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#m.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#d({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#d(t){this.#w();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(Ca)),e}#g(){this.#v();const t=sd(this.options.staleTime,this.#t);if(Yh||this.#i.isStale||!$k(t))return;const n=A9(this.#i.dataUpdatedAt,t)+1;this.#c=Eh.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#b(t){this.#_(),this.#l=t,!(Yh||Zs(this.options.enabled,this.#t)===!1||!$k(this.#l)||this.#l===0)&&(this.#u=Eh.setInterval(()=>{(this.options.refetchIntervalInBackground||sR.isFocused())&&this.#d()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(Eh.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(Eh.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#t,r=this.options,i=this.#i,a=this.#r,s=this.#s,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,g;if(e._optimisticResults){const O=this.hasListeners(),k=!O&&pU(t,e),j=O&&gU(t,n,e,r);(k||j)&&(d={...d,...R9(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:x,status:v}=d;g=d.data;let y=!1;if(e.placeholderData!==void 0&&g===void 0&&v==="pending"){let O;i?.isPlaceholderData&&e.placeholderData===s?.placeholderData?(O=i.data,y=!0):O=typeof e.placeholderData=="function"?e.placeholderData(this.#f?.state.data,this.#f):e.placeholderData,O!==void 0&&(v="success",g=Gk(i?.data,O,e),f=!0)}if(e.select&&g!==void 0&&!y)if(i&&g===a?.data&&e.select===this.#p)g=this.#h;else try{this.#p=e.select,g=e.select(g),g=Gk(i?.data,g,e),this.#h=g,this.#a=null}catch(O){this.#a=O}this.#a&&(p=this.#a,g=this.#h,x=Date.now(),v="error");const b=d.fetchStatus==="fetching",E=v==="pending",w=v==="error",A=E&&b,T=g!==void 0,N={status:v,fetchStatus:d.fetchStatus,isPending:E,isSuccess:v==="success",isError:w,isInitialLoading:A,isLoading:A,data:g,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:b,isRefetching:b&&!E,isLoadingError:w&&!T,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&T,isStale:oR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Zs(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=B=>{N.status==="error"?B.reject(N.error):N.data!==void 0&&B.resolve(N.data)},k=()=>{const B=this.#o=N.promise=Wk();O(B)},j=this.#o;switch(j.status){case"pending":t.queryHash===n.queryHash&&O(j);break;case"fulfilled":(N.status==="error"||N.data!==j.value)&&k();break;case"rejected":(N.status!=="error"||N.error!==j.reason)&&k();break}}return N}updateResult(){const t=this.#i,e=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#s=this.options,this.#r.data!==void 0&&(this.#f=this.#t),U1(e,t))return;this.#i=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#m.size)return!0;const a=new Set(i??this.#m);return this.options.throwOnError&&a.add("error"),Object.keys(this.#i).some(s=>{const l=s;return this.#i[l]!==t[l]&&a.has(l)})};this.#S({listeners:n()})}#w(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(t){vi.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function eoe(t,e){return Zs(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function pU(t,e){return eoe(t,e)||t.state.data!==void 0&&Kk(t,e,e.refetchOnMount)}function Kk(t,e,n){if(Zs(e.enabled,t)!==!1&&sd(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&oR(t,e)}return!1}function gU(t,e,n,r){return(t!==e||Zs(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&oR(t,n)}function oR(t,e){return Zs(e.enabled,t)!==!1&&t.isStaleByTime(sd(e.staleTime,t))}function toe(t,e){return!U1(t.getCurrentResult(),e)}function xU(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,a=e.state.data?.pages||[],s=e.state.data?.pageParams||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const f=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},g=N9(e.options,e.fetchOptions),p=async(x,v,y)=>{if(d)return Promise.reject();if(v==null&&x.pages.length)return Promise.resolve(x);const E=(()=>{const C={client:e.client,queryKey:e.queryKey,pageParam:v,direction:y?"backward":"forward",meta:e.options.meta};return f(C),C})(),w=await g(E),{maxPages:A}=e.options,T=y?Wse:Gse;return{pages:T(x.pages,w,A),pageParams:T(x.pageParams,v,A)}};if(i&&a.length){const x=i==="backward",v=x?noe:bU,y={pages:a,pageParams:s},b=v(r,y);l=await p(y,b,x)}else{const x=t??a.length;do{const v=c===0?s[0]??r.initialPageParam:bU(r,l);if(c>0&&v==null)break;l=await p(l,v),c++}while(c<x)}return l};e.options.persister?e.fetchFn=()=>e.options.persister?.(u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=u}}}function bU(t,{pages:e,pageParams:n}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,n[r],n):void 0}function noe(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var roe=class extends j9{#e;#t;#n;#i;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#t=[],this.state=t.state||D9(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#r({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=P9({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(a,s)=>{this.#r({type:"failed",failureCount:a,error:s})},onPause:()=>{this.#r({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",i=!this.#i.canStart();try{if(r)e();else{this.#r({type:"pending",variables:t,isPaused:i}),await this.#n.config.onMutate?.(t,this,n);const s=await this.options.onMutate?.(t,n);s!==this.state.context&&this.#r({type:"pending",context:s,variables:t,isPaused:i})}const a=await this.#i.start();return await this.#n.config.onSuccess?.(a,t,this.state.context,this,n),await this.options.onSuccess?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,t,this.state.context,n),this.#r({type:"success",data:a}),a}catch(a){try{throw await this.#n.config.onError?.(a,t,this.state.context,this,n),await this.options.onError?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,a,t,this.state.context,n),a}finally{this.#r({type:"error",error:a})}}finally{this.#n.runNext(this)}}#r(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),vi.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function D9(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ioe=class extends ag{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(t,e,n){const r=new roe({client:t,mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:n});return this.add(r),r}add(t){this.#e.add(t);const e=Nv(t);if(typeof e=="string"){const n=this.#t.get(e);n?n.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){const e=Nv(t);if(typeof e=="string"){const n=this.#t.get(e);if(n)if(n.length>1){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}else n[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=Nv(t);if(typeof e=="string"){const r=this.#t.get(e)?.find(i=>i.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=Nv(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){vi.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>uU(e,n))}findAll(t={}){return this.getAll().filter(e=>uU(t,e))}notify(t){vi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return vi.batch(()=>Promise.all(t.map(e=>e.continue().catch(Ca))))}};function Nv(t){return t.options.scope?.id}var aoe=class extends ag{#e;#t=void 0;#n;#i;constructor(e,n){super(),this.#e=e,this.setOptions(n),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#e.defaultMutationOptions(e),U1(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Zh(n.mutationKey)!==Zh(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#s(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#s()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??D9();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#s(e){vi.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#i.onSuccess?.(e.data,n,r,i),this.#i.onSettled?.(e.data,null,n,r,i)):e?.type==="error"&&(this.#i.onError?.(e.error,n,r,i),this.#i.onSettled?.(void 0,e.error,n,r,i))}this.listeners.forEach(n=>{n(this.#t)})})}},soe=class extends ag{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??iR(r,e);let a=this.get(i);return a||(a=new Qse({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(a)),a}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){vi.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>cU(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>cU(t,n)):e}notify(t){vi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){vi.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){vi.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},ooe=class{#e;#t;#n;#i;#r;#s;#o;#a;constructor(t={}){this.#e=t.queryCache||new soe,this.#t=t.mutationCache||new ioe,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=sR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=z1.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#e.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(sd(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),a=this.#e.get(r.queryHash)?.state.data,s=Hse(e,a);if(s!==void 0)return this.#e.build(this,r).setData(s,{...n,manual:!0})}setQueriesData(t,e,n){return vi.batch(()=>this.#e.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;vi.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return vi.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=vi.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Ca).catch(Ca)}invalidateQueries(t,e={}){return vi.batch(()=>(this.#e.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=vi.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,n);return n.throwOnError||(a=a.catch(Ca)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ca)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(sd(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ca).catch(Ca)}fetchInfiniteQuery(t){return t.behavior=xU(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ca).catch(Ca)}ensureInfiniteQueryData(t){return t.behavior=xU(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return z1.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#i.set(Zh(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{P0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Zh(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{P0(t,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#n.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=iR(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===aR&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},O9=S.createContext(void 0),pn=t=>{const e=S.useContext(O9);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},loe=({client:t,children:e})=>(S.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),o.jsx(O9.Provider,{value:t,children:e})),L9=S.createContext(!1),coe=()=>S.useContext(L9);L9.Provider;function uoe(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var doe=S.createContext(uoe()),hoe=()=>S.useContext(doe),foe=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},moe=t=>{S.useEffect(()=>{t.clearReset()},[t])},poe=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||C9(n,[t.error,r])),goe=t=>{if(t.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},xoe=(t,e)=>t.isLoading&&t.isFetching&&!e,boe=(t,e)=>t?.suspense&&e.isPending,yU=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function yoe(t,e,n){const r=coe(),i=hoe(),a=pn(),s=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(s),s._optimisticResults=r?"isRestoring":"optimistic",goe(s),foe(s,i),moe(i);const l=!a.getQueryCache().get(s.queryHash),[c]=S.useState(()=>new e(a,s)),u=c.getOptimisticResult(s),d=!r&&t.subscribed!==!1;if(S.useSyncExternalStore(S.useCallback(f=>{const g=d?c.subscribe(vi.batchCalls(f)):Ca;return c.updateResult(),g},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),S.useEffect(()=>{c.setOptions(s)},[s,c]),boe(s,u))throw yU(s,c,i);if(poe({result:u,errorResetBoundary:i,throwOnError:s.throwOnError,query:a.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(s,u),s.experimental_prefetchInRender&&!Yh&&xoe(u,r)&&(l?yU(s,c,i):a.getQueryCache().get(s.queryHash)?.promise)?.catch(Ca).finally(()=>{c.updateResult()}),s.notifyOnChangeProps?u:c.trackResult(u)}function gt(t,e){return yoe(t,Jse)}function vt(t,e){const n=pn(),[r]=S.useState(()=>new aoe(n,t));S.useEffect(()=>{r.setOptions(t)},[r,t]);const i=S.useSyncExternalStore(S.useCallback(s=>r.subscribe(vi.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=S.useCallback((s,l)=>{r.mutate(s,l).catch(Ca)},[r]);if(i.error&&C9(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const voe=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),_oe=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),vU=t=>{const e=_oe(t);return e.charAt(0).toUpperCase()+e.slice(1)},I9=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),woe=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Soe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Moe=S.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:s,...l},c)=>S.createElement("svg",{ref:c,...Soe,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:I9("lucide",i),...!a&&!woe(l)&&{"aria-hidden":"true"},...l},[...s.map(([u,d])=>S.createElement(u,d)),...Array.isArray(a)?a:[a]]));const Ye=(t,e)=>{const n=S.forwardRef(({className:r,...i},a)=>S.createElement(Moe,{ref:a,iconNode:e,className:I9(`lucide-${voe(vU(t))}`,`lucide-${t}`,r),...i}));return n.displayName=vU(t),n};const Eoe=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],lo=Ye("archive",Eoe);const Aoe=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],j0=Ye("arrow-down",Aoe);const Toe=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Noe=Ye("arrow-left",Toe);const Coe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Xk=Ye("arrow-right",Coe);const koe=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Poe=Ye("arrow-up-down",koe);const joe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Mp=Ye("arrow-up",joe);const Roe=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],Dh=Ye("bell",Roe);const Doe=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],Ooe=Ye("bold",Doe);const Loe=[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],Ioe=Ye("book",Loe);const Foe=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],Uoe=Ye("bookmark",Foe);const zoe=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],Qh=Ye("box",zoe);const Boe=[["path",{d:"M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z",key:"trhst0"}],["path",{d:"M17 21v-2",key:"ds4u3f"}],["path",{d:"M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10",key:"1mo9zo"}],["path",{d:"M21 21v-2",key:"eo0ou"}],["path",{d:"M3 5V3",key:"1k5hjh"}],["path",{d:"M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z",key:"1dd30t"}],["path",{d:"M7 5V3",key:"1t1388"}]],Hoe=Ye("cable",Boe);const $oe=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],Voe=Ye("calendar-days",$oe);const Goe=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Jr=Ye("calendar",Goe);const Woe=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],R0=Ye("camera",Woe);const qoe=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],Koe=Ye("chart-column",qoe);const Xoe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],po=Ye("check",Xoe);const Yoe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],vo=Ye("chevron-down",Yoe);const Zoe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ko=Ye("chevron-right",Zoe);const Qoe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Jh=Ye("chevron-left",Qoe);const Joe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Tb=Ye("chevron-up",Joe);const ele=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Oa=Ye("circle-alert",ele);const tle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],qA=Ye("circle-arrow-up",tle);const nle=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],kr=Ye("circle-check-big",nle);const rle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],lR=Ye("circle-check",rle);const ile=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],ale=Ye("circle-dot",ile);const sle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],ole=Ye("circle-stop",sle);const lle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Pa=Ye("circle-x",lle);const cle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],_U=Ye("circle",cle);const ule=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ur=Ye("clock",ule);const dle=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],QS=Ye("cloud",dle);const hle=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],fle=Ye("code-xml",hle);const mle=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],F9=Ye("code",mle);const ple=[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]],gle=Ye("coffee",ple);const xle=[["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}]],ble=Ye("cog",xle);const yle=[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],vle=Ye("compass",yle);const _le=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],vl=Ye("copy",_le);const wle=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Cv=Ye("cpu",wle);const Sle=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],Mle=Ye("cylinder",Sle);const Ele=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Ep=Ye("database",Ele);const Ale=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],Yk=Ye("dollar-sign",Ale);const Tle=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],as=Ye("download",Tle);const Nle=[["path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z",key:"c7niix"}]],cR=Ye("droplet",Nle);const Cle=[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]],uR=Ye("droplets",Cle);const kle=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],o0=Ye("ellipsis-vertical",kle);const Ple=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],KA=Ye("equal",Ple);const jle=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],la=Ye("external-link",jle);const Rle=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],JS=Ye("eye-off",Rle);const Dle=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],ef=Ye("eye",Dle);const Ole=[["path",{d:"M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z",key:"484a7f"}],["path",{d:"M12 12v.01",key:"u5ubse"}]],Lle=Ye("fan",Ole);const Ile=[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v3.8",key:"1kchwa"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}],["path",{d:"M3 13.1a2 2 0 0 0-.999 1.76v3.24a2 2 0 0 0 .969 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01z",key:"19flxy"}],["path",{d:"M7 17v5",key:"1yj1jh"}]],U9=Ye("file-box",Ile);const Fle=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],Zk=Ye("file-code",Fle);const Ule=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],zle=Ye("file-exclamation-point",Ule);const Ble=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],B1=Ye("file-spreadsheet",Ble);const Hle=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],As=Ye("file-text",Hle);const $le=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],dR=Ye("file",$le);const Vle=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],Oh=Ye("film",Vle);const Gle=[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]],Wle=Ye("flame",Gle);const qle=[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]],Bo=Ye("folder-kanban",qle);const Kle=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Xle=Ye("folder-open",Kle);const Yle=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],Zle=Ye("folder-tree",Yle);const Qle=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],z9=Ye("folder",Qle);const Jle=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],hR=Ye("funnel",Jle);const ece=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],eM=Ye("gauge",ece);const tce=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],nce=Ye("gift",tce);const rce=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]],dp=Ye("git-compare",rce);const ice=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],wU=Ye("github",ice);const ace=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Ap=Ye("globe",ace);const sce=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],D0=Ye("grip-vertical",sce);const oce=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],fR=Ye("hard-drive",oce);const lce=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],cce=Ye("hash",lce);const uce=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],dce=Ye("heart",uce);const hce=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],H1=Ye("history",hce);const fce=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],mce=Ye("house",fce);const pce=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Nb=Ye("image",pce);const gce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],tf=Ye("info",gce);const xce=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],bce=Ye("italic",xce);const yce=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],ip=Ye("key",yce);const vce=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],Qk=Ye("keyboard",vce);const _ce=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],gd=Ye("layers",_ce);const wce=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],tM=Ye("layout-grid",wce);const Sce=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]],Mce=Ye("layout-list",Sce);const Ece=[["path",{d:"M9 17H7A5 5 0 0 1 7 7",key:"10o201"}],["path",{d:"M15 7h2a5 5 0 0 1 4 8",key:"1d3206"}],["line",{x1:"8",x2:"12",y1:"12",y2:"12",key:"rvw6j4"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]],Ace=Ye("link-2-off",Ece);const Tce=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Tp=Ye("link-2",Tce);const Nce=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],Cb=Ye("link",Nce);const Cce=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],B9=Ye("list-ordered",Cce);const kce=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],Jk=Ye("list-todo",kce);const Pce=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],mR=Ye("list",Pce);const jce=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],pt=Ye("loader-circle",jce);const Rce=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],SU=Ye("log-in",Rce);const Dce=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Oce=Ye("log-out",Dce);const Lce=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Ice=Ye("mail",Lce);const Fce=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],Uce=Ye("map",Fce);const zce=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Bce=Ye("maximize-2",zce);const Hce=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],$ce=Ye("maximize",Hce);const Vce=[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]],Gce=Ye("memory-stick",Vce);const Wce=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],qce=Ye("menu",Wce);const Kce=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Xce=Ye("minimize-2",Kce);const Yce=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],Zce=Ye("minimize",Yce);const Qce=[["path",{d:"M5 12h14",key:"1ays0h"}]],e3=Ye("minus",Qce);const Jce=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],eue=Ye("monitor",Jce);const tue=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],$1=Ye("moon",tue);const nue=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],t3=Ye("music",nue);const rue=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],zc=Ye("package",rue);const iue=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],pR=Ye("palette",iue);const aue=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],sue=Ye("paperclip",aue);const oue=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],gR=Ye("pause",oue);const lue=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],nf=Ye("pen-line",lue);const cue=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],xR=Ye("pen",cue);const uue=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Bc=Ye("pencil",uue);const due=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],hue=Ye("phone",due);const fue=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],xd=Ye("play",fue);const mue=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],co=Ye("plug",mue);const pue=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],fr=Ye("plus",pue);const gue=[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],nM=Ye("power-off",gue);const xue=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],jl=Ye("power",xue);const bue=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],Gi=Ye("printer",bue);const yue=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],vue=Ye("qr-code",yue);const _ue=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],li=Ye("refresh-cw",_ue);const wue=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],sg=Ye("rotate-ccw",wue);const Sue=[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]],Mue=Ye("ruler",Sue);const Eue=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Ts=Ye("save",Eue);const Aue=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m16 16-1.9-1.9",key:"1dq9hf"}]],Tue=Ye("scan-search",Aue);const Nue=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],Cue=Ye("scissors",Nue);const kue=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],_l=Ye("search",kue);const Pue=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],bR=Ye("send",Pue);const jue=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],fh=Ye("server",jue);const Rue=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],rM=Ye("settings-2",Rue);const Due=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],yR=Ye("settings",Due);const Oue=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Lue=Ye("shield",Oue);const Iue=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],H9=Ye("shopping-cart",Iue);const Fue=[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}],["path",{d:"M22 4v16",key:"sih9yq"}]],Uue=Ye("signal",Fue);const zue=[["path",{d:"M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z",key:"15892j"}],["path",{d:"M3 20V4",key:"1ptbpl"}]],Bue=Ye("skip-back",zue);const Hue=[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]],V1=Ye("skip-forward",Hue);const $ue=[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],MU=Ye("sliders-vertical",$ue);const Vue=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],O0=Ye("sparkles",Vue);const Gue=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],rf=Ye("square-check-big",Gue);const Wue=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],af=Ye("square",Wue);const que=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],Np=Ye("star",que);const Kue=[["path",{d:"M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",key:"1dfntj"}],["path",{d:"M15 3v5a1 1 0 0 0 1 1h5",key:"6s6qgf"}]],$9=Ye("sticky-note",Kue);const Xue=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],EU=Ye("sun",Xue);const Yue=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Cp=Ye("tag",Yue);const Zue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],V9=Ye("target",Zue);const Que=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],G9=Ye("terminal",Que);const Jue=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],ede=Ye("text-align-center",Jue);const tde=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],nde=Ye("text-align-end",tde);const rde=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],ide=Ye("text-align-start",rde);const ade=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],iM=Ye("thermometer",ade);const sde=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],Ju=Ye("timer",sde);const ode=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Nn=Ye("trash-2",ode);const lde=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],W9=Ye("trending-down",lde);const cde=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],q9=Ye("trending-up",cde);const ude=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Gn=Ye("triangle-alert",ude);const dde=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],hde=Ye("underline",dde);const fde=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],K9=Ye("unlink",fde);const mde=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],ca=Ye("upload",mde);const pde=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],n3=Ye("user",pde);const gde=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],xde=Ye("users",gde);const bde=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],X9=Ye("video",bde);const yde=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],vde=Ye("volume-2",yde);const _de=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],wde=Ye("volume-x",_de);const Sde=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],kb=Ye("wifi-off",Sde);const Mde=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],vR=Ye("wifi",Mde);const Ede=[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]],Ade=Ye("wind",Ede);const Tde=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],bd=Ye("wrench",Tde);const Nde=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Wt=Ye("x",Nde);const Cde=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],kde=Ye("zoom-in",Cde);const Pde=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],sf=Ye("zap",Pde);const jde=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Rde=Ye("zoom-out",jde),On="/api/v1";async function $e(t,e={}){const n=await fetch(`${On}${t}`,{...e,headers:{"Content-Type":"application/json",...e.headers}});if(!n.ok){const i=(await n.json().catch(()=>({}))).detail,a=typeof i=="string"?i:i?JSON.stringify(i):`HTTP ${n.status}`;throw new Error(a)}return await n.json()}const _e={getPrinters:()=>$e("/printers/"),getPrinter:t=>$e(`/printers/${t}`),createPrinter:t=>$e("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>$e(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>$e(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>$e(`/printers/${t}/status`),refreshPrinterStatus:t=>$e(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>$e(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>$e(`/printers/${t}/disconnect`,{method:"POST"}),stopPrint:t=>$e(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>$e(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>$e(`/printers/${t}/print/resume`,{method:"POST"}),getPrintableObjects:t=>$e(`/printers/${t}/print/objects`),skipObjects:(t,e)=>$e(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>$e(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>$e(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>$e(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>$e(`/printers/${t}/logging`),clearMQTTLogs:t=>$e(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>$e(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${On}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>$e(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>$e(`/printers/${t}/storage`),getArchives:(t,e,n=50,r=0)=>{const i=new URLSearchParams;return t&&i.set("printer_id",String(t)),e&&i.set("project_id",String(e)),i.set("limit",String(n)),i.set("offset",String(r)),$e(`/archives/?${i}`)},getArchive:t=>$e(`/archives/${t}`),searchArchives:(t,e)=>{const n=new URLSearchParams;return n.set("q",t),e?.printerId&&n.set("printer_id",String(e.printerId)),e?.projectId&&n.set("project_id",String(e.projectId)),e?.status&&n.set("status",e.status),e?.limit&&n.set("limit",String(e.limit)),e?.offset&&n.set("offset",String(e.offset)),$e(`/archives/search?${n}`)},rebuildSearchIndex:()=>$e("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>$e(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>$e(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>$e(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>$e("/archives/stats"),getFailureAnalysis:t=>{const e=new URLSearchParams;return t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),$e(`/archives/analysis/failures?${e}`)},compareArchives:t=>$e(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>$e(`/archives/${t}/similar?limit=${e}`),exportArchives:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.fields&&e.set("fields",t.fields.join(",")),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),t?.status&&e.set("status",t.status),t?.dateFrom&&e.set("date_from",t.dateFrom),t?.dateTo&&e.set("date_to",t.dateTo),t?.search&&e.set("search",t.search);const n=await fetch(`${On}/archives/export?${e}`);if(!n.ok){const s=await n.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(r){const s=r.match(/filename="?([^"]+)"?/);s&&(i=s[1])}return{blob:await n.blob(),filename:i}},exportStats:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId));const n=await fetch(`${On}/archives/stats/export?${e}`);if(!n.ok){const s=await n.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"stats_export.xlsx":"stats_export.csv";if(r){const s=r.match(/filename="?([^"]+)"?/);s&&(i=s[1])}return{blob:await n.blob(),filename:i}},getArchiveDuplicates:t=>$e(`/archives/${t}/duplicates`),backfillContentHashes:()=>$e("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${On}/archives/${t}/thumbnail?v=${Date.now()}`,getArchiveDownload:t=>`${On}/archives/${t}/download`,getArchiveGcode:t=>`${On}/archives/${t}/gcode`,getArchiveTimelapse:t=>`${On}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>$e(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>$e(`/archives/${t}/timelapse/select?filename=${encodeURIComponent(e)}`,{method:"POST"}),uploadArchiveTimelapse:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${On}/archives/${t}/timelapse/upload`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getTimelapseInfo:t=>$e(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>$e(`/archives/${t}/timelapse/thumbnails?count=${e}`),processTimelapse:async(t,e,n)=>{const r=new FormData;r.append("trim_start",String(e.trimStart??0)),e.trimEnd!==void 0&&r.append("trim_end",String(e.trimEnd)),r.append("speed",String(e.speed??1)),r.append("save_mode",e.saveMode),e.outputFilename&&r.append("output_filename",e.outputFilename),n&&r.append("audio",n);const i=await fetch(`${On}/archives/${t}/timelapse/process`,{method:"POST",body:r});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getArchivePhotoUrl:(t,e)=>`${On}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${On}/archives/${t}/photos`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteArchivePhoto:(t,e)=>$e(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${On}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${On}/archives/${t}/source/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,uploadSource3mf:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${On}/archives/${t}/source`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteSource3mf:t=>$e(`/archives/${t}/source`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${On}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>$e(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>$e(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>$e(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${On}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${On}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchiveFilamentRequirements:t=>$e(`/archives/${t}/filament-requirements`),reprintArchive:(t,e)=>$e(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST"}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${On}/archives/upload?printer_id=${e}`:`${On}/archives/upload`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(a=>n.append("files",a));const r=e?`${On}/archives/upload-bulk?printer_id=${e}`:`${On}/archives/upload-bulk`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getSettings:()=>$e("/settings/"),updateSettings:t=>$e("/settings/",{method:"PUT",body:JSON.stringify(t)}),resetSettings:()=>$e("/settings/reset",{method:"POST"}),exportBackup:async t=>{const e=new URLSearchParams;t&&(t.settings!==void 0&&e.set("include_settings",String(t.settings)),t.notifications!==void 0&&e.set("include_notifications",String(t.notifications)),t.templates!==void 0&&e.set("include_templates",String(t.templates)),t.smart_plugs!==void 0&&e.set("include_smart_plugs",String(t.smart_plugs)),t.external_links!==void 0&&e.set("include_external_links",String(t.external_links)),t.printers!==void 0&&e.set("include_printers",String(t.printers)),t.filaments!==void 0&&e.set("include_filaments",String(t.filaments)),t.maintenance!==void 0&&e.set("include_maintenance",String(t.maintenance)),t.archives!==void 0&&e.set("include_archives",String(t.archives)),t.projects!==void 0&&e.set("include_projects",String(t.projects)),t.access_codes!==void 0&&e.set("include_access_codes",String(t.access_codes)));const n=`${On}/settings/backup${e.toString()?"?"+e.toString():""}`,r=await fetch(n),i=r.headers.get("Content-Disposition");let a="bambuddy-backup.json";if(i){const l=i.match(/filename=([^;]+)/);l&&(a=l[1].trim())}return{blob:await r.blob(),filename:a}},importBackup:async(t,e=!1)=>{const n=new FormData;n.append("file",t);const r=`${On}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>$e("/settings/check-ffmpeg"),getCloudStatus:()=>$e("/cloud/status"),cloudLogin:(t,e,n="global")=>$e("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>$e("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>$e("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>$e("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>$e(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>$e(`/cloud/settings/${t}`),createCloudSetting:t=>$e("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>$e(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>$e(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>$e("/cloud/devices"),getCloudFields:t=>$e(`/cloud/fields/${t}`),getAllCloudFields:()=>$e("/cloud/fields"),getFilamentInfo:t=>$e("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>$e("/smart-plugs/"),getSmartPlug:t=>$e(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>$e(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>$e("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>$e(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>$e(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>$e(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>$e(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>$e("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${On}/smart-plugs/discover/scan`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getTasmotaScanStatus:()=>$e("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${On}/smart-plugs/discover/stop`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getDiscoveredTasmotaDevices:()=>$e("/smart-plugs/discover/devices"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),$e(`/queue/?${n}`)},getQueueItem:t=>$e(`/queue/${t}`),addToQueue:t=>$e("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>$e(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>$e(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>$e("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>$e(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>$e(`/queue/${t}/stop`,{method:"POST"}),getKProfiles:(t,e="0.4")=>$e(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>$e(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>$e(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>$e(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>$e(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>$e(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>$e(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>$e(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>$e(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>$e(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>$e(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),listFilaments:()=>$e("/filaments/"),getFilament:t=>$e(`/filaments/${t}`),getFilamentsByType:t=>$e(`/filaments/by-type/${t}`),getNotificationProviders:()=>$e("/notifications/"),getNotificationProvider:t=>$e(`/notifications/${t}`),createNotificationProvider:t=>$e("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>$e(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>$e(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>$e(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>$e("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>$e("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>$e("/notification-templates"),getNotificationTemplate:t=>$e(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>$e(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>$e(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>$e("/notification-templates/variables"),previewTemplate:t=>$e("/notification-templates/preview",{method:"POST",body:JSON.stringify(t)}),getNotificationLogs:t=>{const e=new URLSearchParams;return t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset)),t?.provider_id&&e.set("provider_id",String(t.provider_id)),t?.event_type&&e.set("event_type",t.event_type),t?.success!==void 0&&e.set("success",String(t.success)),t?.days&&e.set("days",String(t.days)),$e(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>$e(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>$e(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>$e("/spoolman/status"),connectSpoolman:()=>$e("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>$e("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>$e(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>$e("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>$e("/spoolman/spools"),getSpoolmanFilaments:()=>$e("/spoolman/filaments"),getUnlinkedSpools:()=>$e("/spoolman/spools/unlinked"),linkSpool:(t,e)=>$e(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>$e("/updates/version"),checkForUpdates:()=>$e("/updates/check"),applyUpdate:()=>$e("/updates/apply",{method:"POST"}),getUpdateStatus:()=>$e("/updates/status"),getMaintenanceTypes:()=>$e("/maintenance/types"),createMaintenanceType:t=>$e("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>$e(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>$e(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>$e("/maintenance/overview"),getPrinterMaintenance:t=>$e(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>$e(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>$e(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>$e(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>$e("/maintenance/summary"),setPrinterHours:(t,e)=>$e(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>$e(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>$e(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${On}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${On}/printers/${t}/camera/snapshot`,testCameraConnection:t=>$e(`/printers/${t}/camera/test`),getExternalLinks:()=>$e("/external-links/"),getExternalLink:t=>$e(`/external-links/${t}`),createExternalLink:t=>$e("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>$e(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>$e(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>$e("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${On}/external-links/${t}/icon`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteExternalLinkIcon:t=>$e(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${On}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),$e(`/projects/?${e}`)},getProject:t=>$e(`/projects/${t}`),createProject:t=>$e("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>$e(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>$e(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>$e(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>$e(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>$e(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>$e(`/projects/${t}/add-queue`,{method:"POST",body:JSON.stringify({queue_item_ids:e})}),uploadProjectAttachment:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${On}/projects/${t}/attachments`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getProjectAttachmentUrl:(t,e)=>`${On}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>$e(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>$e(`/projects/${t}/bom`),createBOMItem:(t,e)=>$e(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>$e(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>$e(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>$e("/projects/templates/"),createTemplateFromProject:t=>$e(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>$e(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>$e(`/projects/${t}/timeline?limit=${e}`),getAPIKeys:()=>$e("/api-keys/"),createAPIKey:t=>$e("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>$e(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>$e(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>$e(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>$e("/system/info")},nl={getInfo:()=>$e("/discovery/info"),getStatus:()=>$e("/discovery/status"),startDiscovery:(t=10)=>$e(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>$e("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>$e("/discovery/printers"),startSubnetScan:(t,e=1)=>$e("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>$e("/discovery/scan/status"),stopSubnetScan:()=>$e("/discovery/scan/stop",{method:"POST"})},r3={getSettings:()=>$e("/settings/virtual-printer"),updateSettings:t=>{const e=new URLSearchParams;return t.enabled!==void 0&&e.set("enabled",String(t.enabled)),t.access_code!==void 0&&e.set("access_code",t.access_code),t.mode!==void 0&&e.set("mode",t.mode),$e(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},yx={list:()=>$e("/pending-uploads/"),getCount:()=>$e("/pending-uploads/count"),get:t=>$e(`/pending-uploads/${t}`),archive:(t,e)=>$e(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>$e(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>$e("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>$e("/pending-uploads/discard-all",{method:"DELETE"})},Y9=S.createContext(void 0);function Dde({children:t}){const[e,n]=S.useState(()=>{const N=localStorage.getItem("theme-mode"),O=localStorage.getItem("theme");return N||O||"dark"}),[r,i]=S.useState(()=>localStorage.getItem("dark-style")||"classic"),[a,s]=S.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=S.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=S.useState(()=>localStorage.getItem("light-style")||"classic"),[f,g]=S.useState(()=>localStorage.getItem("light-background")||"neutral"),[p,x]=S.useState(()=>localStorage.getItem("light-accent")||"green");S.useEffect(()=>{_e.getSettings().then(N=>{N.dark_style&&(i(N.dark_style),localStorage.setItem("dark-style",N.dark_style)),N.dark_background&&(s(N.dark_background),localStorage.setItem("dark-background",N.dark_background)),N.dark_accent&&(c(N.dark_accent),localStorage.setItem("dark-accent",N.dark_accent)),N.light_style&&(d(N.light_style),localStorage.setItem("light-style",N.light_style)),N.light_background&&(g(N.light_background),localStorage.setItem("light-background",N.light_background)),N.light_accent&&(x(N.light_accent),localStorage.setItem("light-accent",N.light_accent))}).catch(()=>{})},[]),S.useEffect(()=>{const N=document.documentElement;N.classList.remove("dark","style-classic","style-glow","style-vibrant","bg-neutral","bg-warm","bg-cool","bg-oled","bg-slate","bg-forest","accent-green","accent-teal","accent-blue","accent-orange","accent-purple","accent-red"),e==="dark"?(N.classList.add("dark"),N.classList.add(`style-${r}`),N.classList.add(`bg-${a}`),N.classList.add(`accent-${l}`)):(N.classList.add(`style-${u}`),N.classList.add(`bg-${f}`),N.classList.add(`accent-${p}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,a,l,u,f,p]);const v=()=>n(N=>N==="dark"?"light":"dark"),y=N=>n(N),b=N=>{i(N),localStorage.setItem("dark-style",N),_e.updateSettings({dark_style:N}).catch(()=>{})},E=N=>{s(N),localStorage.setItem("dark-background",N),_e.updateSettings({dark_background:N}).catch(()=>{})},w=N=>{c(N),localStorage.setItem("dark-accent",N),_e.updateSettings({dark_accent:N}).catch(()=>{})},A=N=>{d(N),localStorage.setItem("light-style",N),_e.updateSettings({light_style:N}).catch(()=>{})},T=N=>{g(N),localStorage.setItem("light-background",N),_e.updateSettings({light_background:N}).catch(()=>{})},C=N=>{x(N),localStorage.setItem("light-accent",N),_e.updateSettings({light_accent:N}).catch(()=>{})};return o.jsx(Y9.Provider,{value:{mode:e,darkStyle:r,darkBackground:a,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:p,toggleMode:v,setMode:y,setDarkStyle:b,setDarkBackground:E,setDarkAccent:w,setLightStyle:A,setLightBackground:T,setLightAccent:C},children:t})}function og(){const t=S.useContext(Y9);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function Mt({children:t,className:e="",onClick:n,onContextMenu:r}){return o.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary card-shadow ${e}`,onClick:n,onContextMenu:r,children:t})}function Fi({children:t,className:e=""}){return o.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function At({children:t,className:e=""}){return o.jsx("div",{className:`p-6 ${e}`,children:t})}function Ode(t,e,n){return[{category:"Navigation",items:t?t.slice(0,9).map((i,a)=>({keys:[String(a+1)],description:i.type==="external"?`Open ${i.label}`:`Go to ${i.labelKey?n(i.labelKey):i.label}`,isExternal:i.type==="external"})):e?e.map((i,a)=>({keys:[String(a+1)],description:`Go to ${n(i.labelKey)}`,isExternal:!1})):[{keys:["1"],description:"Go to Printers",isExternal:!1},{keys:["2"],description:"Go to Archives",isExternal:!1},{keys:["3"],description:"Go to Queue",isExternal:!1},{keys:["4"],description:"Go to Statistics",isExternal:!1},{keys:["5"],description:"Go to Cloud Profiles",isExternal:!1},{keys:["6"],description:"Go to Settings",isExternal:!1}]},{category:"Archives",items:[{keys:["/"],description:"Focus search",isExternal:!1},{keys:["U"],description:"Open upload modal",isExternal:!1},{keys:["Esc"],description:"Clear selection / blur input",isExternal:!1},{keys:["Right-click"],description:"Context menu on cards",isExternal:!1}]},{category:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles",isExternal:!1},{keys:["N"],description:"New profile",isExternal:!1},{keys:["Esc"],description:"Exit selection mode",isExternal:!1}]},{category:"General",items:[{keys:["?"],description:"Show this help",isExternal:!1}]}]}function AU({children:t}){return o.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-bambu-dark border border-bambu-dark-tertiary rounded text-white",children:t})}function Lde({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=ng(),i=Ode(n,e,r);return S.useEffect(()=>{const a=s=>{s.key==="Escape"&&t()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t]),o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:o.jsx(Mt,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:o.jsxs(At,{className:"p-0",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Qk,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),o.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(a=>o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:a.category}),o.jsx("div",{className:"space-y-2",children:a.items.map(s=>o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[s.description,s.isExternal&&o.jsx(la,{className:"w-3 h-3 text-bambu-gray"})]}),o.jsx("div",{className:"flex gap-1",children:s.keys.map(l=>o.jsx(AU,{children:l},l))})]},s.description))})]},a.category))}),o.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:o.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",o.jsx(AU,{children:"Esc"})," or click outside to close"]})})]})})})}function ke({variant:t="primary",size:e="md",className:n="",children:r,...i}){const a="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",s={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},l={sm:"px-3 py-1.5 text-sm gap-1.5 min-h-[44px] md:min-h-0",md:"px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0",lg:"px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0"};return o.jsx("button",{className:`${a} ${s[t]} ${l[e]} ${n}`,...i,children:r})}function br({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",onConfirm:a,onCancel:s}){S.useEffect(()=>{const u=d=>{d.key==="Escape"&&s()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[s]);const c={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600"},warning:{icon:"text-yellow-400",button:"bg-yellow-500 hover:bg-yellow-600"},default:{icon:"text-bambu-green",button:"bg-bambu-green hover:bg-bambu-green-dark"}}[i];return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:s,children:o.jsx(Mt,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:o.jsxs(At,{className:"p-6",children:[o.jsxs("div",{className:"flex items-start gap-4",children:[o.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${c.icon}`,children:o.jsx(Gn,{className:"w-6 h-6"})}),o.jsxs("div",{className:"flex-1",children:[o.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),o.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),o.jsxs("div",{className:"flex gap-3 mt-6",children:[o.jsx(ke,{variant:"secondary",onClick:s,className:"flex-1",children:r}),o.jsx(ke,{onClick:a,className:`flex-1 ${c.button}`,children:n})]})]})})})}function Ide({plug:t}){const e=pn(),[n,r]=S.useState(null),{data:i,isLoading:a}=gt({queryKey:["smart-plug-status",t.id],queryFn:()=>_e.getSmartPlugStatus(t.id),refetchInterval:1e4}),s=vt({mutationFn:f=>_e.controlSmartPlug(t.id,f),onSuccess:()=>{e.invalidateQueries({queryKey:["smart-plug-status",t.id]})}}),l=i?.state==="ON",c=i?.reachable??!1,u=s.isPending,d=()=>{n&&(s.mutate(n),r(null))};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between py-2 px-3 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:`p-1.5 rounded ${c?l?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:o.jsx(co,{className:`w-4 h-4 ${c?l?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white font-medium",children:t.name}),o.jsx("div",{className:"flex items-center gap-1 text-xs",children:a?o.jsx(pt,{className:"w-3 h-3 text-bambu-gray animate-spin"}):c?o.jsxs(o.Fragment,{children:[o.jsx(vR,{className:"w-3 h-3 text-bambu-green"}),o.jsx("span",{className:l?"text-bambu-green":"text-bambu-gray",children:i?.state||"Unknown"}),i?.energy?.power!==null&&i?.energy?.power!==void 0&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),o.jsx(sf,{className:"w-3 h-3 text-yellow-400"}),o.jsxs("span",{className:"text-yellow-400",children:[Math.round(i.energy.power),"W"]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx(kb,{className:"w-3 h-3 text-red-400"}),o.jsx("span",{className:"text-red-400",children:"Offline"})]})})]})]}),o.jsxs("div",{className:"flex gap-1",children:[o.jsx("button",{onClick:()=>r("on"),disabled:!c||u,className:`p-1.5 rounded transition-colors ${l?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn On",children:u?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(jl,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>r("off"),disabled:!c||u,className:`p-1.5 rounded transition-colors ${!l&&c?"bg-bambu-dark-tertiary text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn Off",children:u?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(nM,{className:"w-4 h-4"})})]})]}),n&&o.jsx(br,{title:`Turn ${n==="on"?"On":"Off"} Smart Plug`,message:`Are you sure you want to turn ${n==="on"?"on":"off"} "${t.name}"?`,confirmText:n==="on"?"Turn On":"Turn Off",variant:n==="off"?"warning":"default",onConfirm:d,onCancel:()=>r(null)})]})}function TU({onClose:t}){const{data:e,isLoading:n}=gt({queryKey:["smart-plugs"],queryFn:_e.getSmartPlugs}),r=e?.filter(i=>i.show_in_switchbar)||[];return o.jsxs("div",{className:"absolute bottom-full left-0 mb-2 w-72 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-xl z-50",onMouseLeave:t,children:[o.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary",children:o.jsxs("h3",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[o.jsx(co,{className:"w-4 h-4 text-bambu-green"}),"Smart Switches"]})}),o.jsx("div",{className:"p-2 max-h-80 overflow-y-auto",children:n?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(pt,{className:"w-6 h-6 text-bambu-gray animate-spin"})}):r.length===0?o.jsxs("div",{className:"text-center py-6 px-4",children:[o.jsx(co,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"No switches in switchbar"}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:'Enable "Show in Switchbar" in Settings > Smart Plugs'})]}):o.jsx("div",{className:"space-y-1",children:r.map(i=>o.jsx(Ide,{plug:i},i.id))})})]})}const Z9=[{name:"globe",icon:Ap},{name:"link",icon:Cb},{name:"external-link",icon:la},{name:"book",icon:Ioe},{name:"file-text",icon:As},{name:"home",icon:mce},{name:"star",icon:Np},{name:"heart",icon:dce},{name:"bookmark",icon:Uoe},{name:"shopping-cart",icon:H9},{name:"music",icon:t3},{name:"video",icon:X9},{name:"image",icon:Nb},{name:"camera",icon:R0},{name:"map",icon:Uce},{name:"compass",icon:vle},{name:"coffee",icon:gle},{name:"gift",icon:nce},{name:"wrench",icon:bd},{name:"zap",icon:sf},{name:"cloud",icon:QS},{name:"database",icon:Ep},{name:"folder",icon:z9},{name:"mail",icon:Ice},{name:"phone",icon:hue},{name:"user",icon:n3},{name:"users",icon:xde},{name:"server",icon:fh},{name:"terminal",icon:G9},{name:"code",icon:F9}];function aM(t){return Z9.find(n=>n.name===t)?.icon||Cb}function Fde({value:t,onChange:e}){const[n,r]=S.useState(!1),i=aM(t);return o.jsxs("div",{className:"relative",children:[o.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white hover:border-bambu-gray focus:border-bambu-green focus:outline-none w-full",children:[o.jsx(i,{className:"w-5 h-5"}),o.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),o.jsx("div",{className:"absolute z-50 mt-1 w-full max-h-64 overflow-y-auto bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg",children:o.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:Z9.map(({name:a,icon:s})=>o.jsx("button",{type:"button",onClick:()=>{e(a),r(!1)},className:`p-2 rounded-lg transition-colors flex items-center justify-center ${t===a?"bg-bambu-green text-white":"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:a,children:o.jsx(s,{className:"w-5 h-5"})},a))})})]})]})}const NU=768;function Q9(){const[t,e]=S.useState(()=>typeof window<"u"?window.innerWidth<NU:!1);return S.useEffect(()=>{const n=window.matchMedia(`(max-width: ${NU-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const L0=[{id:"printers",to:"/",icon:Gi,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:lo,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:Jr,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:Koe,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:QS,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:bd,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:Bo,labelKey:"nav.projects"},{id:"settings",to:"/settings",icon:yR,labelKey:"nav.settings"}];function Ude(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return L0.map(e=>e.id)}return L0.map(e=>e.id)}function zde(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function XA(t){return t.startsWith("ext-")}function J9(){return localStorage.getItem("defaultView")||"/"}function Bde(t){localStorage.setItem("defaultView",t)}function Hde(){const t=Eb(),e=kd(),{mode:n,toggleMode:r}=og(),{t:i}=ng(),a=Q9(),[s,l]=S.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[c,u]=S.useState(!1),[d,f]=S.useState(!1),[g,p]=S.useState(!1),[x,v]=S.useState(Ude),[y,b]=S.useState(null),[E,w]=S.useState(null),A=S.useRef(!1),[T,C]=S.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),{data:N}=gt({queryKey:["version"],queryFn:_e.getVersion,staleTime:1/0}),{data:O}=gt({queryKey:["settings"],queryFn:_e.getSettings,staleTime:300*1e3}),{data:k}=gt({queryKey:["updateCheck"],queryFn:_e.checkForUpdates,enabled:O?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:j}=gt({queryKey:["external-links"],queryFn:_e.getExternalLinks}),{data:B}=gt({queryKey:["smart-plugs"],queryFn:_e.getSmartPlugs,staleTime:30*1e3}),L=B?.some(te=>te.show_in_switchbar)??!1,K=new Map(L0.map(te=>[te.id,te])),R=new Map((j||[]).map(te=>[`ext-${te.id}`,te])),q=(()=>{const te=[],ie=new Set;for(const le of x)(K.has(le)||R.has(le))&&(te.push(le),ie.add(le));for(const le of L0)ie.has(le.id)||(te.push(le.id),ie.add(le.id));for(const le of j||[]){const ge=`ext-${le.id}`;ie.has(ge)||(te.push(ge),ie.add(ge))}return te})(),W=(te,ie)=>{b(ie),te.dataTransfer.effectAllowed="move",te.dataTransfer.setData("text/plain",ie)},$=(te,ie)=>{te.preventDefault(),te.dataTransfer.dropEffect="move",w(ie)},J=()=>{w(null)},ee=(te,ie)=>{if(te.preventDefault(),y===null||y===ie){b(null),w(null);return}const le=[...q],ge=le.indexOf(y),Ee=le.indexOf(ie);if(ge===-1||Ee===-1){b(null),w(null);return}le.splice(ge,1),le.splice(Ee,0,y),v(le),zde(le),b(null),w(null)},Q=()=>{b(null),w(null)},z=k?.update_available&&k.latest_version&&k.latest_version!==T,V=()=>{k?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",k.latest_version),C(k.latest_version))};S.useEffect(()=>{if(!A.current&&e.pathname==="/"){const te=J9();te!=="/"&&(A.current=!0,t(te,{replace:!0}))}},[e.pathname,t]),S.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(s))},[s]),S.useEffect(()=>{a&&u(!1)},[e.pathname,a]);const X=S.useCallback(te=>{const ie=te.target;if(!(ie.tagName==="INPUT"||ie.tagName==="TEXTAREA"||ie.isContentEditable)&&!te.metaKey&&!te.ctrlKey&&!te.altKey){const le=parseInt(te.key);if(le>=1&&le<=q.length&&le<=9){const ge=q[le-1];if(te.preventDefault(),XA(ge)){const Ee=ge.replace("ext-","");t(`/external/${Ee}`)}else{const Ee=K.get(ge);Ee&&t(Ee.to)}return}switch(te.key){case"?":te.preventDefault(),f(!0);break;case"Escape":f(!1);break}}},[t,q,K]);return S.useEffect(()=>(document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)),[X]),o.jsxs("div",{className:"flex min-h-screen",children:[a&&o.jsxs("header",{className:"fixed top-0 left-0 right-0 z-40 h-14 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-4",children:[o.jsx("button",{onClick:()=>u(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:o.jsx(qce,{className:"w-6 h-6 text-white"})}),o.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),a&&c&&o.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>u(!1)}),o.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${a?`fixed inset-y-0 left-0 z-50 w-72 transform ${c?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${s?"w-64":"w-16"}`}`,children:[o.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a||s?"p-4":"p-2"}`,children:o.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:a||s?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),o.jsx("nav",{className:"flex-1 p-2",children:o.jsx("ul",{className:"space-y-2",children:q.map(te=>{if(XA(te)){const le=R.get(te);if(!le)return null;const ge=le.custom_icon?null:aM(le.icon);return o.jsx("li",{draggable:!0,onDragStart:Ee=>W(Ee,te),onDragOver:Ee=>$(Ee,te),onDragLeave:J,onDrop:Ee=>ee(Ee,te),onDragEnd:Q,className:`relative ${y===te?"opacity-50":""} ${E===te&&y!==te?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:o.jsxs(Gx,{to:`/external/${le.id}`,className:({isActive:Ee})=>`flex items-center ${a||s?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${Ee?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!s?le.name:void 0,children:[s&&!a&&o.jsx(D0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),le.custom_icon?o.jsx("img",{src:`/api/v1/external-links/${le.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):ge&&o.jsx(ge,{className:"w-5 h-5 flex-shrink-0"}),(a||s)&&o.jsx("span",{children:le.name})]})},te)}else{const le=K.get(te);if(!le)return null;const{to:ge,icon:Ee,labelKey:pe}=le;return o.jsx("li",{draggable:!0,onDragStart:de=>W(de,te),onDragOver:de=>$(de,te),onDragLeave:J,onDrop:de=>ee(de,te),onDragEnd:Q,className:`relative ${y===te?"opacity-50":""} ${E===te&&y!==te?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:o.jsxs(Gx,{to:ge,className:({isActive:de})=>`flex items-center ${a||s?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${de?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!s?i(pe):void 0,children:[s&&!a&&o.jsx(D0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),o.jsx(Ee,{className:"w-5 h-5 flex-shrink-0"}),(a||s)&&o.jsx("span",{children:i(pe)})]})},te)}})})}),!a&&o.jsx("button",{onClick:()=>l(!s),className:"p-2 mx-2 mb-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white flex items-center justify-center",title:i(s?"nav.collapseSidebar":"nav.expandSidebar"),children:s?o.jsx(Jh,{className:"w-5 h-5"}):o.jsx(Ko,{className:"w-5 h-5"})}),o.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||s?o.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[o.jsxs("div",{className:"flex items-center justify-center gap-1",children:[L&&o.jsxs("div",{className:"relative",children:[o.jsx("button",{onMouseEnter:()=>p(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${g?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:o.jsx(co,{className:"w-5 h-5"})}),g&&o.jsx(TU,{onClose:()=>p(!1)})]}),o.jsx(Gx,{to:"/system",className:({isActive:te})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${te?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:o.jsx(tf,{className:"w-5 h-5"})}),o.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:o.jsx(wU,{className:"w-5 h-5"})}),o.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:o.jsx(Qk,{className:"w-5 h-5"})}),o.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?o.jsx(EU,{className:"w-5 h-5"}):o.jsx($1,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"flex items-center justify-center gap-2",children:[o.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",N?.version||"..."]}),k?.update_available&&o.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:k.latest_version}),children:[o.jsx(qA,{className:"w-4 h-4"}),o.jsx("span",{children:i("nav.update")})]})]})]}):o.jsxs("div",{className:"flex flex-col items-center gap-1",children:[k?.update_available&&o.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:i("nav.updateAvailable",{version:k.latest_version}),children:o.jsx(qA,{className:"w-5 h-5"})}),L&&o.jsxs("div",{className:"relative",children:[o.jsx("button",{onMouseEnter:()=>p(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${g?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:o.jsx(co,{className:"w-5 h-5"})}),g&&o.jsx(TU,{onClose:()=>p(!1)})]}),o.jsx(Gx,{to:"/system",className:({isActive:te})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${te?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:o.jsx(tf,{className:"w-5 h-5"})}),o.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:o.jsx(wU,{className:"w-5 h-5"})}),o.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:o.jsx(Qk,{className:"w-5 h-5"})}),o.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?o.jsx(EU,{className:"w-5 h-5"}):o.jsx($1,{className:"w-5 h-5"})})]})})]}),o.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${a?"mt-14":s?"ml-64":"ml-16"}`,children:[z&&o.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx(qA,{className:"w-4 h-4 text-bambu-green"}),o.jsx("span",{children:i("nav.updateAvailableBanner",{version:k?.latest_version,defaultValue:`Version ${k?.latest_version} is available!`})}),o.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),o.jsx("button",{onClick:V,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:o.jsx(Wt,{className:"w-4 h-4"})})]}),o.jsx(ise,{})]}),d&&o.jsx(Lde,{onClose:()=>f(!1),sidebarItems:q.map(te=>{if(XA(te)){const ie=R.get(te);return ie?{type:"external",label:ie.name}:null}else{const ie=K.get(te);return ie?{type:"nav",label:ie.labelKey,labelKey:ie.labelKey}:null}}).filter(Boolean)})]})}const eW=S.createContext(void 0);function Ar(){const t=S.useContext(eW);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const $de={success:o.jsx(kr,{className:"w-5 h-5 text-green-400"}),error:o.jsx(Pa,{className:"w-5 h-5 text-red-400"}),warning:o.jsx(Oa,{className:"w-5 h-5 text-yellow-400"}),info:o.jsx(tf,{className:"w-5 h-5 text-blue-400"}),loading:o.jsx(pt,{className:"w-5 h-5 text-bambu-green animate-spin"})},Vde={success:"bg-green-500/10 border-green-500/30",error:"bg-red-500/10 border-red-500/30",warning:"bg-yellow-500/10 border-yellow-500/30",info:"bg-blue-500/10 border-blue-500/30",loading:"bg-bambu-green/10 border-bambu-green/30"};function Gde({children:t}){const[e,n]=S.useState([]),r=S.useCallback((s,l="success")=>{const c=Math.random().toString(36).substr(2,9);n(u=>[...u,{id:c,message:s,type:l}]),setTimeout(()=>{n(u=>u.filter(d=>d.id!==c))},3e3)},[]),i=S.useCallback((s,l,c="info")=>{n(u=>u.find(f=>f.id===s)?u.map(f=>f.id===s?{...f,message:l,type:c,persistent:!0}:f):[...u,{id:s,message:l,type:c,persistent:!0}])},[]),a=S.useCallback(s=>{n(l=>l.filter(c=>c.id!==s))},[]);return o.jsxs(eW.Provider,{value:{showToast:r,showPersistentToast:i,dismissToast:a},children:[t,o.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(s=>o.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${Vde[s.type]}`,children:[$de[s.type],o.jsx("span",{className:"text-white text-sm",children:s.message}),o.jsx("button",{onClick:()=>a(s.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:o.jsx(Wt,{className:"w-4 h-4"})})]},s.id))})]})}function Wde(t){if(t===0)return"0 B";const e=1024,n=["B","KB","MB","GB"],r=Math.floor(Math.log(t)/Math.log(e));return`${parseFloat((t/Math.pow(e,r)).toFixed(1))} ${n[r]}`}function CU(t){if(t===0)return"0 GB";const e=t/(1024*1024*1024);return e>=1?`${e.toFixed(1)} GB`:`${(t/(1024*1024)).toFixed(0)} MB`}function qde(t,e){if(e)return z9;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return U9;case"gcode":return As;case"mp4":case"avi":return Oh;case"png":case"jpg":case"jpeg":return Nb;default:return dR}}function Kde({printerId:t,printerName:e,onClose:n}){const{showToast:r}=Ar(),i=pn(),[a,s]=S.useState("/"),[l,c]=S.useState(null),[u,d]=S.useState(""),[f,g]=S.useState(null);S.useEffect(()=>{const N=O=>{O.key==="Escape"&&n()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[n]);const{data:p,isLoading:x,refetch:v}=gt({queryKey:["printerFiles",t,a],queryFn:()=>_e.getPrinterFiles(t,a)}),{data:y}=gt({queryKey:["printerStorage",t],queryFn:()=>_e.getPrinterStorage(t),staleTime:3e4}),b=vt({mutationFn:N=>_e.deletePrinterFile(t,N),onSuccess:(N,O)=>{r(`Deleted: ${O.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(null)},onError:N=>{r(`Delete failed: ${N.message}`,"error")}}),E=N=>{s(N),c(null)},w=()=>{if(a==="/")return;const N=a.split("/").filter(Boolean);N.pop(),s(N.length?"/"+N.join("/"):"/"),c(null)},A=N=>{window.open(_e.getPrinterFileDownloadUrl(t,N),"_blank")},T=N=>{g(N)},C=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return o.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[o.jsxs("div",{className:"w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden",onClick:N=>N.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(fR,{className:"w-5 h-5 text-bambu-green"}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),o.jsxs("div",{className:"flex items-center gap-4",children:[y&&(y.used_bytes!=null||y.free_bytes!=null)&&o.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[y.used_bytes!=null&&o.jsxs("span",{children:["Used: ",CU(y.used_bytes)]}),y.used_bytes!=null&&y.free_bytes!=null&&o.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),y.free_bytes!=null&&o.jsxs("span",{children:["Free: ",CU(y.free_bytes)]})]}),o.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]})]}),o.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[C.map(N=>o.jsx("button",{onClick:()=>{E(N.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===N.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:N.label},N.path)),o.jsx("div",{className:"flex-1"}),o.jsxs("div",{className:"relative",children:[o.jsx(_l,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),o.jsx("input",{type:"text",placeholder:"Filter files...",value:u,onChange:N=>d(N.target.value),className:"w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>v(),disabled:x,children:o.jsx(li,{className:`w-4 h-4 ${x?"animate-spin":""}`})})]}),o.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[o.jsx("button",{onClick:w,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:o.jsx(Jh,{className:"w-4 h-4"})}),o.jsx("span",{className:"text-bambu-gray font-mono",children:a})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:x?o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):p?.files?.length?o.jsx("div",{className:"space-y-1",children:[...p.files].filter(N=>!u||N.name.toLowerCase().includes(u.toLowerCase())).sort((N,O)=>N.is_directory&&!O.is_directory?-1:!N.is_directory&&O.is_directory?1:N.name.localeCompare(O.name)).map(N=>{const O=qde(N.name,N.is_directory),k=l===N.path;return o.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${k?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{N.is_directory?E(N.path):c(k?null:N.path)},children:[o.jsx(O,{className:`w-5 h-5 flex-shrink-0 ${N.is_directory?"text-bambu-green":"text-bambu-gray"}`}),o.jsx("span",{className:"flex-1 text-white truncate",children:N.name}),!N.is_directory&&o.jsx("span",{className:"text-sm text-bambu-gray",children:Wde(N.size)}),N.is_directory&&o.jsx(Jh,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},N.path)})}):o.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),o.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[o.jsx("div",{className:"text-sm text-bambu-gray",children:u?`${p?.files?.filter(N=>N.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${p?.files?.length||0} items`:`${p?.files?.length||0} items`}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(ke,{variant:"secondary",disabled:!l,onClick:()=>l&&A(l),children:[o.jsx(as,{className:"w-4 h-4"}),"Download"]}),o.jsxs(ke,{variant:"secondary",disabled:!l||b.isPending,onClick:()=>l&&T(l),className:"text-red-400 hover:text-red-300",children:[b.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(Nn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&o.jsx(br,{title:"Delete File",message:`Delete "${f.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{b.mutate(f),g(null)},onCancel:()=>g(null)})]})}function Xde({printerId:t,printerName:e,onClose:n}){const r=pn(),[i,a]=S.useState(!0),[s,l]=S.useState(new Set),[c,u]=S.useState(""),[d,f]=S.useState("all"),g=S.useRef(null),{data:p,isLoading:x,refetch:v}=gt({queryKey:["mqtt-logs",t],queryFn:()=>_e.getMQTTLogs(t),refetchInterval:1e3}),y=vt({mutationFn:()=>_e.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),b=vt({mutationFn:()=>_e.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),E=vt({mutationFn:()=>_e.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});S.useEffect(()=>{const k=j=>{j.key==="Escape"&&n()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[n]),S.useEffect(()=>{i&&g.current&&(g.current.scrollTop=g.current.scrollHeight)},[p?.logs,i]);const w=k=>{l(j=>{const B=new Set(j);return B.has(k)?B.delete(k):B.add(k),B})},A=k=>new Date(k).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),T=(k,j)=>{if(k==null)return"<empty>";const B=typeof k=="string"?JSON.parse(k):k,L=JSON.stringify(B,null,j?2:0);return!j&&L.length>100?L.substring(0,100)+"...":L},C=p?.logging_enabled??!1,N=p?.logs??[],O=S.useMemo(()=>N.filter(k=>{if(d!=="all"&&k.direction!==d)return!1;if(c.trim()){const j=c.toLowerCase(),B=k.topic.toLowerCase().includes(j),K=JSON.stringify(k.payload).toLowerCase().includes(j);return B||K}return!0}),[N,c,d]);return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),o.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[C?o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,children:[o.jsx(af,{className:"w-4 h-4"}),"Stop"]}):o.jsxs(ke,{size:"sm",onClick:()=>y.mutate(),disabled:y.isPending,children:[o.jsx(xd,{className:"w-4 h-4"}),"Start Logging"]}),o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>E.mutate(),disabled:E.isPending||N.length===0,children:[o.jsx(Nn,{className:"w-4 h-4"}),"Clear"]}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>v(),disabled:x,children:o.jsx(li,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),o.jsx("div",{className:"flex-1"}),o.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:i,onChange:k=>a(k.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),o.jsxs("span",{className:"text-sm text-bambu-gray",children:[O.length,"/",N.length]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"relative flex-1",children:[o.jsx(_l,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),o.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:c,onChange:k=>u(k.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),c&&o.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:o.jsx(Wt,{className:"w-4 h-4"})})]}),o.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[o.jsx("button",{onClick:()=>f("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${d==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),o.jsxs("button",{onClick:()=>f("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${d==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[o.jsx(j0,{className:"w-3 h-3"}),"In"]}),o.jsxs("button",{onClick:()=>f("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${d==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[o.jsx(Mp,{className:"w-3 h-3"}),"Out"]})]})]})]}),o.jsx("div",{ref:g,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:N.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[o.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!C&&o.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):O.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[o.jsx("p",{className:"mb-2",children:"No messages match your filter"}),o.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):o.jsx("div",{className:"space-y-1",children:O.map((k,j)=>{const B=s.has(j),L=k.direction==="in";return o.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${B?"bg-bambu-dark-secondary":""}`,onClick:()=>w(j),children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("span",{className:"text-bambu-gray shrink-0",children:A(k.timestamp)}),o.jsx("span",{className:`shrink-0 ${L?"text-blue-400":"text-green-400"}`,title:L?"Incoming":"Outgoing",children:L?o.jsx(j0,{className:"w-3 h-3"}):o.jsx(Mp,{className:"w-3 h-3"})}),o.jsx("span",{className:"text-purple-400 shrink-0",children:k.topic})]}),B?o.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:T(k.payload,!0)}):o.jsx("pre",{className:"mt-1 text-white/80 truncate",children:T(k.payload,!1)})]},j)})})}),o.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[o.jsx("div",{className:"text-sm text-bambu-gray",children:C?o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):o.jsx("span",{children:"Logging stopped"})}),o.jsx(ke,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const i3={"0300_4000":"Z axis homing failed; the task has been stopped.","0300_4001":"The printer timed out waiting for the nozzle to cool down before homing.","0300_4002":"Auto Bed Leveling failed; the task has been stopped.","0300_4005":"The hotend cooling fan speed is abnormal.","0300_4006":"The nozzle is clogged.","0300_4008":"The AMS failed to change filament.","0300_4009":"Homing XY axis failed.","0300_400A":"Mechanical resonance frequency identification failed.","0300_400B":"Internal communication exception","0300_400C":"The task was canceled.","0300_400D":"Resume failed after power loss.","0300_400E":"The motor self-check failed.","0300_400F":"The power supply voltage does not match the printer.","0300_4010":"Nozzle offset calibration failed.","0300_4011":"Flow Dynamics Calibration failed; please reinitiate printing or calibration.","0300_4013":"Printing cannot be initiated while AMS is drying.","0300_4014":"Homing Z axis failed: temperature control abnormality.","0300_4015":"Nozzle clumping detection calibration failed. Please go to 'Assistant' for troubleshooting.","0300_4016":"Nozzle cleaning failed. Please click the Assistant for troubleshooting.","0300_401F":"The hotend is not installed, and the toolhead cannot perform homing. Please install the hotend and then continue.","0300_4020":"The nozzle presence detection failed. Please check the Assistant for details.","0300_4021":"Nozzle offset calibration sensor signal abnormality detected. Please check the sensor and retry.","0300_4042":"The Laser Safety Window is not properly installed. The task has been stopped.","0300_4044":"The Flame Sensor is abnormal. The sensor may be short-circuited. Please troubleshoot the issue before starting a print job.","0300_404B":"Task aborted because the front door or top cover is open.","0300_404D":"The current temperature of the hotend, heatbed, or chamber is too high. Please wait for it to cool down to room temperature before restarting the task.","0300_4050":"Liveview Camera calibration timeout; please restart the printer.","0300_4052":"Blade Z-axis homing failed","0300_4057":"Z-axis step loss detected. The task has stopped. Please check if there are any obstructions beneath the heatbed.","0300_4066":"Calibration of motion precision failed.","0300_4067":"Calibration result is over the threshold.","0300_4068":"Step loss occurred during the motion accuracy enhancement process. Please try again.","0300_8000":"Printing was paused for unknown reason. You can select 'Resume' to resume the print job.","0300_8001":"Printing was paused by the user. You can select 'Resume' to continue printing.","0300_8002":"First layer defects were detected by the Micro Lidar. Please check the quality of the printed model before continuing your print.","0300_8003":"Spaghetti defects were detected by the AI Print Monitoring. Please check the quality of the printed model before continuing your print.","0300_8004":"Filament ran out. Please load new filament.","0300_8005":"Toolhead front cover fell off. Please remount the front cover and check to make sure your print is going okay.","0300_8006":"The build plate marker was not detected. Please confirm the build plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible.","0300_8007":"There was an unfinished print job when the printer lost power. If the model is still adhered to the build plate, you can try resuming the print job.","0300_8008":"Nozzle temperature malfunction","0300_8009":"Heatbed temperature malfunction","0300_800A":"A Filament pile-up was detected by AI Print Monitoring. Please clean filament from the waste chute.","0300_800B":"The cutter is stuck. Please make sure the cutter handle is out and check the filament sensor cable connection.","0300_800C":"Skipped step detected: auto-recover complete; please resume print and check if there are any layer shift problems.","0300_800D":"Detected that the extruder is not extruding normally. If the defects are acceptable, select 'Resume' to resume the print job.","0300_800E":"The print file is not available. Please check to see if the storage media has been removed.","0300_800F":"The door seems to be open, so printing was paused.","0300_8010":"The hotend cooling fan speed is abnormal.","0300_8011":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0300_8013":"Printing paused due to the pause command added to the printing file.","0300_8014":"The nozzle is covered with filament, or the build plate is installed incorrectly. Please cancel this print and clean the nozzle or adjust the build plate according to the actual status. You can als...","0300_8015":"The filament on external spool has run out; please load new filament. If the filament is loaded, please select 'Resume'.","0300_8016":"The nozzle is clogged with filament. Please cancel this print and clean the nozzle or select 'Resume' to resume the print job.","0300_8017":"Foreign objects detected on heatbed. Please check and clean the heatbed. Then, select 'Resume' to resume the print job.","0300_8018":"Chamber temperature malfunction.","0300_8019":"No build plate is placed.","0300_801A":"Filament extrusion error; please check the assistant for troubleshooting. After resolving the issue, decide whether to cancel or resume the print job based on the actual print status.","0300_801B":"Nozzle temperature problem detected. Refer to Assistant to re-connect the hotend connector. POWER OFF the printer before this operation to avoid short circuits.","0300_801C":"The extrusion resistance is abnormal. The extruder may be clogged; please refer to the assistant. After trouble shooting, you can select 'Resume' to resume the print job.","0300_801D":"The extruder servo motor position sensor is malfunctioning. Please power off the printer first and check if the connection cable is loose.","0300_801E":"The extrusion motor is overloaded, please check the Assistant for details.","0300_8021":"The nozzle may not be installed or not properly installed. Please ensure the nozzle is correctly installed before proceeding.","0300_8022":"The heatbed may be obstructed while moving downward. Please clear any objects beneath the heatbed and check for any resistance or jamming during its movement.","0300_8028":"Nozzle offset calibration sensor error. If using a single hotend or the calibration function is disabled, you may ignore this and continue printing; otherwise, it is recommended to check the sensor...","0300_8041":"Platform detection timeout: please restart the printer.","0300_8042":"Task paused because the door is open.","0300_8043":"The laser module is abnormal.","0300_8044":"Fire was detected inside the chamber.","0300_8045":"Material detection timeout: please restart the printer.","0300_8046":"Foreign object detect timeout: please restart the printer.","0300_8047":"Quick-release lever detection time out: please restart the printer.","0300_8048":"Laser Module unlock has timed out, and the task cannot proceed. Please restart the printer and try again.","0300_8049":"The current plate is invalid.","0300_804A":"Emergency stop button improperly installed. Please reinstall according to the Wiki before proceeding.","0300_804B":"Task paused. The Laser Safety Window is open.","0300_804E":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0300_804F":"The loading/unloading process is currently ongoing. Please stop the process or remove the laser/cutting module.","0300_8050":"This device does not support the 40W Laser Module. Please remove it or replace it with a 10W Laser Module.","0300_8051":"The cutting module has dropped or the cutting module cable is disconnected; please check the module.","0300_8053":"Laser module detected. Please install the right nozzle correctly to ensure proper Laser Module Mounting Calibration.","0300_8054":"Please place the paper required for Print Then Cut.","0300_8055":"The module mounted on the toolhead does not match the task. Please install the correct module.","0300_8057":"The rotary attachment is disconnected. Please ensure it is properly installed and the cable is securely plugged in.","0300_8058":"The rotary attachment is detected. Please remove it before continuing.","0300_8061":"The mode of Airflow System failed to activate; check the air door condition.","0300_8062":"The chamber temperature is too high. It may be due to high environmental temperature.","0300_8063":"The chamber temperature is too high. Please open the top cover and front door to cool down.","0300_8064":"The chamber temperature is too high. Please open the top cover and front door to cool down. (Open door detection for this print job will be set to 'Notification' level)","0300_8065":"The temperature of the MC module is too high. Please check the Wiki for possible explanations.","0300_8071":"The Toolhead Enhanced Cooling Fan module is malfunctioning.","0300_807D":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807E":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807F":"Fire Extinguisher is malfunctioning.","0300_8080":"Fire extinguisher motor reset failed.","0300_8081":"Fire extinguisher cylinder not installed. Please confirm on the extinguisher page.","0300_8082":"The Fire Extinguisher Gas Cylinder is empty.","0300_C012":"Please heat the nozzle to above 170°C.","0300_C056":"A minor fire was detected inside the chamber, and the Auto Fire Extinguishing process has been aborted.","0300_C070":"The fire extinguisher has been detected and is ready for use after the laser module is connected.","0500_4001":"Failed to connect to Bambu Cloud. Please check your network connection.","0500_4002":"Unsupported print file path or name. Please resend the print job.","0500_4003":"Printing stopped because the printer was unable to parse the file. Please resend your print job.","0500_4004":"Device is busy and cannot start new task. Please wait for current task to complete before sending new task.","0500_4005":"Print jobs are not allowed to be sent while updating firmware.","0500_4006":"There is not enough free storage space for the print job. Restoring to factory settings can free up available space.","0500_4007":"The device requires a repair upgrade, and printing is currently unavailable.","0500_4008":"Starting printing failed; please power cycle the printer and resend the print job.","0500_4009":"Print jobs are not allowed to be sent while updating logs.","0500_400A":"The file name is not supported. Please rename and restart the print job.","0500_400B":"There was a problem downloading a file. Please check your network connection and resend the print job.","0500_400C":"Please insert a MicroSD card and restart the print job.","0500_400D":"Please run a self-test and restart the print job.","0500_400E":"Printing was cancelled.","0500_400F":"AMS is initializing and cannot be upgraded at the moment. Please try again later.","0500_4010":"AMS is drying and cannot be upgraded at the moment. Please try again later.","0500_4011":"The printer is loading or unloading filament and cannot be upgraded at the moment. Please try again later.","0500_4012":"The device is printing and cannot be upgraded at the moment. Please try again later.","0500_4013":"AMS is in operation and cannot be upgraded at the moment. Please try again when it is idle.","0500_4014":"Slicing for the print job failed. Please check your settings and restart the print job.","0500_4015":"There is not enough free storage space for the print job. Please format or clear files from the MicroSD card to free up space.","0500_4016":"The MicroSD Card is write-protected. Please replace the MicroSD Card.","0500_4017":"Binding failed. Please retry or restart the printer and retry.","0500_4018":"Binding configuration information parsing failed; please try again.","0500_4019":"The printer has already been bound. Please unbind it and try again.","0500_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0500_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_402A":"Failed to connect to the router, which may be caused by wireless interference or being too far away from the router. Please try again or move the printer closer to the router and try again.","0500_402B":"Router connection failed due to incorrect password. Please check the password and try again.","0500_402C":"Failed to obtain IP address, which may be caused by wireless interference resulting in data transmission failure or the DHCP address pool of the router being full. Please move the printer closer to...","0500_402D":"System exception","0500_402E":"System does not support the file system currently used by the USB flash drive. Please replace or format the USB flash drive to FAT32.","0500_402F":"The MicroSD card sector data is damaged. Please use the SD card repair tool to repair or format it. If it still cannot be identified, please replace the MicroSD card.","0500_4030":"The device is currently upgrading. Please try again when it is idle.","0500_4031":"The accessory firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4033":"The AMS firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4034":"The Laser Module firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4035":"The BirdsEye Camera is malfunctioning. Please try restarting the device. If the issue persists after multiple restarts, check the camera connection status or contact customer support.","0500_4037":"Your sliced file is not compatible with current printer model. This file can't be printed on this printer.","0500_4038":"The nozzle diameter in sliced file is not consistent with the current nozzle setting. This file can't be printed.","0500_4039":"The current task does not allow the installation of the laser/cutting module, and the task has been halted.","0500_403A":"The current temperature is too low. In order to protect you and your printer, printing tasks, moving an axis and other operations are disabled. Please move the printer to an environment above 10 de...","0500_403B":"Laser/cutting tasks cannot be initiated on the machine at the moment. Please use the computer software to start the task.","0500_403C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_403D":"The toolhead module is not set up. Please set it up before initiating the task.","0500_403E":"The current tool head does not support initialization.","0500_403F":"Failed to download print job; please check your network connection.","0500_4040":"The printer has reached its power limit. Please connect a dedicated power adapter to this AMS to enable drying.","0500_4041":"The AMS drying cannot be started during printing.","0500_4042":"Due to power limitations, starting AMS drying will pause current operations such as nozzle heating and fan running. Do you want to proceed with drying?","0500_4043":"Due to power limitations, only one AMS is allowed to use the device's power for drying.","0500_4044":"BirdsEye Camera malfunction: please contact customer support.","0500_4045":"Hotend check in progress. This operation is temporarily unavailable. Please wait.","0500_4050":"Error detected on the print board.","0500_4052":"Error detected on the hot end.","0500_4054":"Error detected on the mat.","0500_405D":"Laser module Serial Number error: unable to calibrate or make project.","0500_4065":"The task requires a Laser Platform, but the current one is a Cutting Platform. Please replace it, measure the material thickness in the software, and then restart the task.","0500_4070":"The laser or cutter module is connected, so the device cannot initiate a 3D printing task.","0500_4075":"No Laser Platform was detected, which may affect thickness measurement accuracy. Please place the laser platform correctly and ensure the rear markers are not blocked, then restart the thickness me...","0500_4076":"Please place the Laser Platform correctly and ensure the rear markers are not blocked, then restart the thickness measurement in the software before initiating the task.","0500_4097":"The device cannot detect the Laser Module. Please reconnect the module cable or restart the printer.","0500_4098":"The device cannot detect AMS A. Please reconnect the AMS cable or restart the printer.","0500_4099":"The firmware of Cutting Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409A":"The firmware of the Air Pump does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409B":"The firmware of the Laser Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409D":"The firmware of AMS A does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0500_409E":"The device cannot detect the Cutting Module. Please reconnect the module cable or restart the printer.","0500_409F":"The device cannot detect the Air Pump. Please reconnect the module cable or restart the printer.","0500_40A0":"The Rotary Attachment module is not detected. Please reconnect the cable or restart the printer.","0500_40A1":"The Auto Fire Extinguishing System is not detected. Please reconnect the module cable or restart the printer.","0500_40A3":"AMS(or AMS lite) A communication is abnormal. Please reconnect the module cable or restart the printer.","0500_40A4":"The current firmware only supports 1 AMS Lite. Please remove all AMS units before reconnecting the supported AMS Lite device.","0500_40A5":"The current firmware only supports AMS/AMS 2 Pro/AMS HT, with a maximum of 4 units. Please remove all AMS units before reconnecting the supported one.","0500_8013":"The print file is not available. Please check to see if the storage media has been removed.","0500_8036":"Your sliced file is not consistent with the current printer model. Continue?","0500_803C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_8040":"Toolhead front cover is detached. Moving the toolhead may damage the printer. Do you want to continue?","0500_8041":"The filament in hotend is too cold. Extrusion may damage the extruder. Still feeding in/out the filament?","0500_8048":"The module on the toolhead is not calibrated. Please cancel the task to perform calibration or switch to a calibrated module.","0500_8051":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0500_8053":"Nozzle mismatch was detected during printing. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","0500_8055":"Laser module is installed, but a Cutting Platform is detected. Please place a Laser Platform and perform laser calibration.","0500_8056":"Cutting module is installed, but the laser platform is detected. Please place the cutting platform for calibration.","0500_8058":"Please place the light grip cutting mat correctly and ensure the marker is exposed.","0500_8059":"Cutting platform base is not correctly aligned. Please ensure that the four corners of the platform are aligned with the heatbed.","0500_805A":"Please place the cutting mat on cutting protection base.","0500_805B":"The cutting mat type is unknown; please replace it with the correct cutting mat.","0500_805C":"The grip cutting mat type does not match; please place a LightGrip cutting mat.","0500_805E":"Cutting module Serial Number error: unable to calibrate or make project.","0500_8060":"The current module on toolhead does not meet requirements. Please replace the module as per the on-screen instructions.","0500_8061":"No print plate detected. Please make sure it is placed correctly.","0500_8062":"The print plate marker was not detected. Please confirm the print plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible. If strong light is shining o...","0500_8063":"The platform is not detected during calibration; please make sure the Laser Platform is properly placed.","0500_8064":"Please place the Laser Platform correctly and ensure the rear markers are not blocked for laser calibration.","0500_8066":"The task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + LightGrip cutting mat).","0500_8067":"Please place a LightGrip cutting mat on the cutting protection base.","0500_8068":"Please place the strong grip cutting mat correctly and ensure the marker is exposed.","0500_8069":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please manually set the hotend types.","0500_806A":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please set hotend types on printer screen before next print.","0500_806B":"Quick-release Lever is not locked. Please press down the external toolhead module to ensure it is properly seated, then push down the level to lock it in place.","0500_806C":"Please place the cutting platform correctly and ensure the marker is exposed.","0500_806D":"Material not detected. Please confirm placement and continue.","0500_806E":"Foreign objects detected on heatbed; please check and clean up the heatbed.","0500_806F":"The grip cutting mat type does not match; please place a StrongGrip cutting mat.","0500_8071":"No cutting platform was detected. Please confirm that it has been correctly placed.","0500_8072":"Live View camera is blocked","0500_8073":"Heatbed limit block is obstructed or contaminated. Please clean and ensure the limit block is visible, otherwise platform position offset detection may be inaccurate.","0500_8074":"The Laser Platform is offset. Please ensure that the four corners of the platform are aligned with the heatbed, and the marker is not obstructed.","0500_8077":"The visual marker was not detected. Please ensure the paper is properly placed.","0500_8078":"Current material does not match the sliced file settings. Please load the correct material and ensure the QR code on the material is not damaged or dirty.","0500_8079":"Please place the Laser Test Material (350g paperboard) and position support strips underneath to prevent material warping.","0500_807A":"The foreign object detection function is not working. You can continue the task or check the assistant for troubleshooting.","0500_807B":"Please place the cutting platform (cutting protection base + LightGrip cutting mat).","0500_807C":"Please place the cutting platform (cutting protection base + StrongGrip cutting mat).","0500_807D":"This task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + StrongGrip Cutting Mat).","0500_807E":"Please place a StrongGrip cutting mat on the cutting protection base.","0500_8080":"The left and right hotends are not installed.","0500_8081":"The left and right hotends are not installed.","0500_8082":"Please remove the protective film on the Opaque Glossy Acrylic before processing","0500_8083":"Material is not allowed in Mounting Calibration. Please remove the material from the platform.","0500_8084":"The Live View Camera is dirty; please clean it and continue.","0500_8085":"Toolhead camera is obstructed","0500_8086":"Toolhead Camera is dirty, which affects the AI function; please clean the lens surface.","0500_8087":"BirdsEye camera is obstructed","0500_8088":"The Birdseye Camera is dirty","0500_8089":"Task paused due to Presence Check failed. Please check the printer to continue.","0500_808A":"The BirdsEye Camera is installed offset. Please refer to the assistant to reinstall it.","0500_808B":"The BirdsEye Camera setup failed. Please remove all objects and the mat on the heatbed to ensure the heatbed markers are visible. Meanwhile, please ensure the BirdsEye Camera is installed correctly...","0500_808C":"Detected build plate offset. Please align the build plate with the heatbed, and then continue.","0500_808D":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the cutting material is properly positioned and check whether the cutting blade tip is worn.","0500_808E":"BirdsEye Camera initialization failed. The toolhead camera did not detect the Heatbed features. Please clean the Heatbed, remove all objects and pads, and ensure the bed markings are visible. Check...","0500_808F":"Nozzle camera lens is dirty, affecting AI monitoring. Clean the lens with a non-woven cloth and a small amount of alcohol. Beware of hotend heat; wait for it to cool before handling.","0500_8090":"Please attach the 80g White Printing Paper to the center area of the platform.","0500_8091":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the 80g white printer paper(letter paper thickness) is properly positioned and check whether the cut...","0500_8092":"Toolhead Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0500_8093":"The nozzle silicone sleeve is not installed; there is a risk of temperature control failure. Please install it correctly and try again.","0500_80A0":"The visual encoder board was not detected. Please check if the board is properly placed and aligned at all four corners, and ensure the positioning markings are clear and free from wear.","0500_C010":"MicroSD Card read/write exception: please reinsert or replace the MicroSD Card.","0500_C032":"Laser/Cutting module connected to the toolhead. The drying process has been automatically stopped.","0500_C036":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0500_C07F":"Device is busy and cannot perform this operation. To proceed, please pause or stop the current task.","0501_4017":"Binding failed. Please retry or restart the printer and retry.","0501_4018":"Binding configuration information parsing failed; please try again.","0501_4019":"The printer has already been bound. Please unbind it and try again.","0501_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0501_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4031":"Device discovery binding is in progress, and the QR code cannot be displayed on the screen. You can wait for the binding to finish or abort the device discovery binding process in the APP/Studio an...","0501_4032":"QR code binding is in progress, so device discovery binding cannot be performed. You can scan the QR code on the screen for binding or exit the QR code display page on screen and try device discove...","0501_4033":"Your APP region does not match with your printer; please download the APP in the corresponding region and register your account again.","0501_4034":"The slicing progress has not been updated for a long time, and the printing task has exited. Please confirm the parameters and reinitiate printing.","0501_4035":"The device is in the process of binding and cannot respond to new binding requests.","0501_4038":"The regional settings do not match the printer; please check the printer's regional settings.","0501_4039":"Device login has expired; please try to bind again.","0501_4098":"The device cannot detect AMS B. Please reconnect the AMS cable or restart the printer.","0501_409D":"The firmware of AMS B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0501_40A3":"AMS(or AMS lite) B communication is abnormal. Please reconnect the module cable or restart the printer.","0502_4001":"Current filament will be used in this print job. Settings cannot be changed.","0502_4002":"Please go to “Settings > Calibration” to run the Motion Accuracy Enhancement Calibration before turning on Motion Accuracy Enhancement mode.","0502_4003":"The printer is currently printing and the motion accuracy enhancement feature cannot be turned on or off.","0502_4004":"Some features are not supported by the current device. Please check the Studio feature settings or update the firmware to the latest version.","0502_4005":"The AMS has not been calibrated yet, so printing cannot be initiated.","0502_4006":"Unknown module detected; please try updating the firmware to the latest version.","0502_400D":"Failed to start a new task: filament loading/unloading not completed.","0502_400E":"Failed to start a new task: The nozzle cold pull was not completed.","0502_4013":"This device is not compatible with the 40W laser module. Please replace it with a 10W laser module or remove it.","0502_4098":"The device cannot detect AMS C. Please reconnect the AMS cable or restart the printer.","0502_409D":"The firmware of AMS C does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0502_40A3":"AMS(or AMS lite) C communication is abnormal. Please reconnect the module cable or restart the printer.","0502_C00F":"The device is busy and cannot perform nozzle identification.","0502_C010":"Due to printer power limitations, printing, calibration, controls and other actions cannot be performed during AMS drying. Please stop the drying process before proceeding with any other operation.","0502_C011":"Currently in 2D production mode. Please continue the operation on the printer","0502_C012":"The task cannot be paused.","0502_C014":"The AMS Remaining Filament Estimation is enabled by default and cannot be disabled.","0502_C024":"The flow dynamic calibration records have exceeded the storage limit. Please delete some historical records in the slicer software before adding new calibration data.","0503_4098":"The device cannot detect AMS D. Please reconnect the AMS cable or restart the printer.","0503_409D":"The firmware of AMS D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0503_40A3":"AMS(or AMS lite) D communication is abnormal. Please reconnect the module cable or restart the printer.","0580_4096":"The device cannot detect AMS-HT A. Please reconnect the AMS-HT cable or restart the printer.","0580_409C":"The firmware of AMS-HT A does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0580_40A2":"AMS-HT A communication is abnormal. Please reconnect the module cable or restart the printer.","0581_4096":"The device cannot detect AMS-HT B. Please reconnect the AMS-HT cable or restart the printer.","0581_409C":"The firmware of AMS-HT B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0581_40A2":"AMS-HT B communication is abnormal. Please reconnect the module cable or restart the printer.","0582_4096":"The device cannot detect AMS-HT C. Please reconnect the AMS-HT cable or restart the printer.","0582_409C":"The firmware of AMS-HT C does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0582_40A2":"AMS-HT C communication is abnormal. Please reconnect the module cable or restart the printer.","0583_4096":"The device cannot detect AMS-HT D. Please reconnect the AMS-HT cable or restart the printer.","0583_409C":"The firmware of AMS-HT D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0583_40A2":"AMS-HT D communication is abnormal. Please reconnect the module cable or restart the printer.","0584_4096":"The device cannot detect AMS-HT F. Please reconnect the AMS-HT cable or restart the printer.","0584_409C":"The firmware of AMS-HT E does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0584_40A2":"AMS-HT E communication is abnormal. Please reconnect the module cable or restart the printer.","0585_4096":"The device cannot detect AMS-HT E. Please reconnect the AMS-HT cable or restart the printer.","0585_409C":"The firmware of AMS-HT F does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0585_40A2":"AMS-HT F communication is abnormal. Please reconnect the module cable or restart the printer.","0586_4096":"The device cannot detect AMS-HT G. Please reconnect the AMS-HT cable or restart the printer.","0586_409C":"The firmware of AMS-HT G does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0586_40A2":"AMS-HT G communication is abnormal. Please reconnect the module cable or restart the printer.","0587_4096":"The device cannot detect AMS-HT H. Please reconnect the AMS-HT cable or restart the printer.","0587_409C":"The firmware of AMS-HT H does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0587_40A2":"AMS-HT H communication is abnormal. Please reconnect the module cable or restart the printer.","05FE_8053":"The left nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FE_8069":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FE_806A":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FE_8080":"The left hotend is not installed.","05FE_8081":"The left hotend is not installed.","05FF_8053":"The right nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FF_8069":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FF_806A":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FF_8080":"The right hotend is not installed.","05FF_8081":"The right hotend is not installed.","0700_4001":"The AMS has been disabled for a print, but it still has filament loaded. Please unload the AMS filament and switch to the spool holder filament for printing.","0700_4025":"Failed to read the filament information.","0700_8001":"Failed to cut the filament. Please check the cutter.","0700_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0700_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0700_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0700_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0700_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0700_8007":"Extruding filament failed. The extruder might be clogged.","0700_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS A to the extruder is properly connected.","0700_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0700_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0700_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0700_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0700_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0700_8017":"AMS A is drying. Please stop drying process before loading/unloading material.","0700_8021":"AMS setup failed; please refer to the assistant.","0700_8023":"AMS A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0700_C069":"An error occurred during AMS A drying. Please go to Assistant for more details.","0700_C06A":"AMS A is reading RFID. Unable to start drying. Please try again later.","0700_C06B":"AMS A is changing filament. Unable to start drying. Please try again later.","0700_C06C":"AMS A is in Feed Assist Mode. Unable to start drying. Please try again later.","0700_C06D":"AMS A is assisting in filament insertion. Unable to start drying. Please try again later.","0700_C06E":"AMS A motor is performing self-test. Unable to start drying. Please try again later.","0701_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0701_4025":"Failed to read the filament information.","0701_8001":"Failed to cut the filament. Please check the cutter.","0701_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0701_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0701_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0701_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0701_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0701_8007":"Extruding filament failed. The extruder might be clogged.","0701_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS B to the extruder is properly connected.","0701_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0701_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0701_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0701_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0701_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0701_8017":"AMS B is drying. Please stop drying process before loading/unloading material.","0701_8021":"AMS setup failed; please refer to the assistant.","0701_8023":"AMS B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0701_C069":"An error occurred during AMS B drying. Please go to Assistant for more details.","0701_C06A":"AMS B is reading RFID. Unable to start drying. Please try again later.","0701_C06B":"AMS B is changing filament. Unable to start drying. Please try again later.","0701_C06C":"AMS B is in Feed Assist Mode. Unable to start drying. Please try again later.","0701_C06D":"AMS B is assisting in filament insertion. Unable to start drying. Please try again later.","0701_C06E":"AMS B motor is performing self-test. Unable to start drying. Please try again later.","0702_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0702_4025":"Failed to read the filament information.","0702_8001":"Failed to cut the filament. Please check the cutter.","0702_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0702_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0702_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0702_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0702_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0702_8007":"Extruding filament failed. The extruder might be clogged.","0702_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS C to the extruder is properly connected.","0702_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0702_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0702_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0702_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0702_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0702_8017":"AMS C is drying. Please stop drying process before loading/unloading material.","0702_8021":"AMS setup failed; please refer to the assistant.","0702_8023":"AMS C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0702_C069":"An error occurred during AMS C drying. Please go to Assistant for more details.","0702_C06A":"AMS C is reading RFID. Unable to start drying. Please try again later.","0702_C06B":"AMS C is changing filament. Unable to start drying. Please try again later.","0702_C06C":"AMS C is in Feed Assist Mode. Unable to start drying. Please try again later.","0702_C06D":"AMS C is assisting in filament insertion. Unable to start drying. Please try again later.","0702_C06E":"AMS C motor is performing self-test. Unable to start drying. Please try again later.","0703_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0703_4025":"Failed to read the filament information.","0703_8001":"Failed to cut the filament. Please check the cutter.","0703_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0703_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0703_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0703_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0703_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0703_8007":"Extruding filament failed. The extruder might be clogged.","0703_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS D to the extruder is properly connected.","0703_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0703_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0703_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0703_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0703_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0703_8017":"AMS D is drying. Please stop drying process before loading/unloading material.","0703_8021":"AMS setup failed; please refer to the assistant.","0703_8023":"AMS D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0703_C069":"An error occurred during AMS D drying. Please go to Assistant for more details.","0703_C06A":"AMS D is reading RFID. Unable to start drying. Please try again later.","0703_C06B":"AMS D is changing filament. Unable to start drying. Please try again later.","0703_C06C":"AMS D is in Feed Assist Mode. Unable to start drying. Please try again later.","0703_C06D":"AMS D is assisting in filament insertion. Unable to start drying. Please try again later.","0703_C06E":"AMS D motor is performing self-test. Unable to start drying. Please try again later.","0704_4025":"Failed to read the filament information.","0704_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0704_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0704_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0704_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0704_8007":"Extruding filament failed. The extruder might be clogged.","0704_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS E to the extruder is properly connected.","0704_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0704_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0704_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0704_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0704_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0704_8021":"AMS setup failed; please refer to the assistant.","0704_8023":"AMS E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0705_4025":"Failed to read the filament information.","0705_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0705_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0705_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0705_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0705_8007":"Extruding filament failed. The extruder might be clogged.","0705_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS F to the extruder is properly connected.","0705_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0705_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0705_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0705_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0705_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0705_8021":"AMS setup failed; please refer to the assistant.","0705_8023":"AMS F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0706_4025":"Failed to read the filament information.","0706_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0706_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0706_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0706_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0706_8007":"Extruding filament failed. The extruder might be clogged.","0706_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS G to the extruder is properly connected.","0706_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0706_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0706_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0706_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0706_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0706_8021":"AMS setup failed; please refer to the assistant.","0706_8023":"AMS G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0707_4025":"Failed to read the filament information.","0707_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0707_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0707_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0707_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0707_8007":"Extruding filament failed. The extruder might be clogged.","0707_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS H to the extruder is properly connected.","0707_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0707_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0707_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0707_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0707_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0707_8021":"AMS setup failed; please refer to the assistant.","0707_8023":"AMS H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","07FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","07FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","07FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","07FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","07FE_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FE_8010":"Check if the left external filament spool or filament is stuck.","07FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","07FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","07FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","07FE_8020":"Extruder change failed; please refer to the assistant.","07FE_8021":"AMS setup failed; please refer to the assistant.","07FE_8024":"Extruder position calibration failed; please refer to the assistant.","07FE_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FE_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FE_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FE_C011":"Please manually and slowly pull out the filament from the extruder. Then click “Continue”.","07FE_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","07FF_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","07FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","07FF_8002":"The cutter is stuck. Please make sure the cutter handle is out.","07FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","07FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","07FF_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FF_8010":"Check if the external filament spool or filament is stuck.","07FF_8011":"External filament has run out; please load a new filament.","07FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","07FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","07FF_8020":"Extruder change failed; please refer to the assistant.","07FF_8021":"AMS setup failed; please refer to the assistant.","07FF_8024":"Extruder position calibration failed; please refer to the assistant.","07FF_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FF_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FF_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FF_C011":"Hold the driven wheel bracket, slowly pull the filament from the extruder, then press 'Continue'.","07FF_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","0C00_4020":"The setup of BirdsEye Camera failed. Please clear all objects and remove the mat. Make sure the marker is not obstructed. Meanwhile, clean both the BirdsEye Camera and Toolhead Camera, and remove a...","0C00_4021":"The setup of BirdsEye Camera failed; please reboot the printer.","0C00_4022":"The setup of BirdsEye Camera failed. Please check if the laser module is working properly.","0C00_4024":"The Birdseye Camera is installed offset. Please refer to the assistant to reinstall it.","0C00_4025":"The Birdseye Camera is dirty. Please clean it and restart the process.","0C00_4026":"The Live View Camera initialization failed; please reboot the printer.","0C00_4027":"The Live View Camera calibration failed. Please refer to the assistant for details and recalibrate the camera after processing.","0C00_4029":"Material not detected. Please confirm placement and continue.","0C00_402A":"The visual marker was not detected. Please re-paste the paper in the correct position.","0C00_402C":"Device data link error. Please reboot the printer","0C00_402D":"The toolhead camera is not working properly; please reboot the device.","0C00_403D":"The vision encoder plate was not detected. Please confirm it is correctly positioned on the heatbed.","0C00_403E":"The high-precision nozzle offset calibration has failed, possibly due to a damaged pattern or the similarity of the colors of the two selected filaments. Please clear the printed pattern and replac...","0C00_4041":"Toolhead camera calibration failed. Please ensure the Calibration Marker on the heatbed or Height Calibration Marker on the homing area is clean and undamaged, then re-run the calibration process.","0C00_8001":"First layer defects were detected. If the defects are acceptable, select 'Resume' to resume the print job.","0C00_8005":"Purged filament has piled up in the waste chute, which may cause a tool head collision.","0C00_8009":"Build plate localization marker was not found.","0C00_800B":"The heatbed marker was not detected. Please clear all objects and remove the mat. Make sure the marker is not obstructed.","0C00_8015":"Objects detected on the platform; please clean them up in a timely manner.","0C00_8016":"The foreign object detection function is not working. You can continue the task or check assistant for solutions.","0C00_8017":"Foreign objects detected on the platform; please clean them up on time.","0C00_8018":"The foreign object detection function is not working. You can continue the task or view the assistant for troubleshooting.","0C00_8033":"Quick-release Lever is not locked. Please push it down to secure.","0C00_8034":"Liveview Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0C00_803F":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_8040":"AI detected air-printing defect. Please check the hotend extrusion status. Refer to assistant for solutions.","0C00_8042":"The AI print monitor has detected a spaghetti defect. Please check the print and take the necessary action.","0C00_8043":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_C003":"Possible defects were detected in the first layer.","0C00_C004":"Possible spaghetti failure was detected.","0C00_C006":"Purged filament may have piled up in the waste chute.","1000_C001":"High bed temperature may lead to filament clogging in the nozzle. You may open the chamber door.","1000_C002":"Printing CF material with stainless steel may cause nozzle damage.","1000_C003":"Enabling Timelapse in traditional mode may cause defects; please activate this feature as needed.","1001_4001":"Timelapse is not supported as Spiral Vase mode is enabled in slicing presets.","1001_4002":"Timelapse is not supported as the Print sequence is set to 'By object'.","1001_8003":"The time-lapse mode is set to Traditional in the slicing file. This may cause surface defects. Would you like to enable it?","1001_8004":"Prime Tower is not enabled and time-lapse mode is set to Smooth in slicing file. This may cause surface defects. Would you like to enable it?","1200_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1200_8001":"Cutting the filament failed. Please check to see if the cutter is stuck. Refer to the Assistant for solutions.","1200_8002":"The cutter is stuck. Please pull out the cutter handle.","1200_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1200_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1200_8005":"The filament is not inserted. Please insert the filament.","1200_8006":"Unable to feed filament into the extruder. This could be due to tangled filament or a stuck spool. If not, please check if the AMS PTFE tube is connected.","1200_8007":"Failed to extrude the filament. This might be caused by clogged extruder or stuck filament. Refer to the Assistant for solutions.","1200_8010":"Filament or spool may be stuck.","1200_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1200_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1200_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1200_8014":"The filament location in the toolhead was not found. Refer to the Assistant for solutions.","1200_8015":"Failed to pull out the filament from the toolhead. Please check if the filament is stuck, or if it is broken inside the extruder or PTFE tube.","1200_8016":"The extruder is not extruding normally. Refer to the Assistant for troubleshooting. There may be defects in this layer, but you may resume if the defects are acceptable.","1201_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1201_8001":"Failed to cut the filament. Please check the cutter.","1201_8002":"The cutter is stuck. Please pull out the cutter handle.","1201_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1201_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1201_8005":"Failed to feed the filament. Please load the filament and then select 'Retry'.","1201_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1201_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1201_8010":"Please check if the spool or filament is stuck.","1201_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1201_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1201_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1201_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1201_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or the filament is broken inside the extruder.","1201_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1202_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1202_8001":"Failed to cut the filament. Please check the cutter.","1202_8002":"The cutter is stuck. Please pull out the cutter handle.","1202_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1202_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1202_8005":"The filament is not inserted. Please insert the filament.","1202_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1202_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1202_8010":"Please check if the spool or filament is stuck.","1202_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1202_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1202_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1202_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1202_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1202_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1203_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1203_8001":"Failed to cut the filament. Please check the cutter.","1203_8002":"The cutter is stuck. Please pull out the cutter handle.","1203_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1203_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1203_8005":"The filament is not inserted. Please insert the filament.","1203_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1203_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1203_8010":"Please check if the spool or filament is stuck.","1203_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1203_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1203_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1203_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1203_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1203_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","12FF_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","12FF_8001":"Failed to cut the filament. Please check the cutter.","12FF_8002":"The cutter is stuck. Please pull out the cutter handle.","12FF_8003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube if you are about to us...","12FF_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","12FF_8005":"The filament is not inserted. Please insert the filament.","12FF_8006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","12FF_8007":"Check nozzle. Select 'Done' if filament was extruded, otherwise push filament forward slightly and select 'Retry.'","12FF_8010":"Please check if the filament or the spool is stuck.","12FF_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","12FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","12FF_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","12FF_C003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE Tube. (Connect a PTFE tube if you are about to us...","12FF_C006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","1800_4025":"Failed to read the filament information.","1800_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1800_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1800_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1800_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1800_8007":"Extruding filament failed. The extruder might be clogged.","1800_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT A to the extruder is properly connected.","1800_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1800_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1800_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1800_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1800_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1800_8017":"AMS-HT A is drying. Please stop drying process before loading/unloading material.","1800_8021":"AMS setup failed; please refer to the assistant.","1800_8023":"AMS-HT A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1800_C069":"An error occurred during AMS-HT A drying. Please go to Assistant for more details.","1800_C06A":"AMS-HT A is reading RFID. Unable to start drying. Please try again later.","1800_C06B":"AMS-HT A is changing filament. Unable to start drying. Please try again later.","1800_C06C":"AMS-HT A is in Feed Assist Mode. Unable to start drying. Please try again later.","1800_C06D":"AMS-HT A is assisting in filament insertion. Unable to start drying. Please try again later.","1800_C06E":"AMS-HT A motor is performing self-test. Unable to start drying. Please try again later.","1801_4025":"Failed to read the filament information.","1801_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1801_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1801_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1801_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1801_8007":"Extruding filament failed. The extruder might be clogged.","1801_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT B to the extruder is properly connected.","1801_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1801_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1801_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1801_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1801_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1801_8017":"AMS-HT B is drying. Please stop drying process before loading/unloading material.","1801_8021":"AMS setup failed; please refer to the assistant.","1801_8023":"AMS-HT B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1801_C069":"An error occurred during AMS-HT B drying. Please go to Assistant for more details.","1801_C06A":"AMS-HT B is reading RFID. Unable to start drying. Please try again later.","1801_C06B":"AMS-HT B is changing filament. Unable to start drying. Please try again later.","1801_C06C":"AMS-HT B is in Feed Assist Mode. Unable to start drying. Please try again later.","1801_C06D":"AMS-HT B is assisting in filament insertion. Unable to start drying. Please try again later.","1801_C06E":"AMS-HT B motor is performing self-test. Unable to start drying. Please try again later.","1802_4025":"Failed to read the filament information.","1802_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1802_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1802_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1802_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1802_8007":"Extruding filament failed. The extruder might be clogged.","1802_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT C to the extruder is properly connected.","1802_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1802_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1802_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1802_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1802_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1802_8017":"AMS-HT C is drying. Please stop drying process before loading/unloading material.","1802_8021":"AMS setup failed; please refer to the assistant.","1802_8023":"AMS-HT C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1802_C069":"An error occurred during AMS-HT C drying. Please go to Assistant for more details.","1802_C06A":"AMS-HT C is reading RFID. Unable to start drying. Please try again later.","1802_C06B":"AMS-HT C is changing filament. Unable to start drying. Please try again later.","1802_C06C":"AMS-HT C is in Feed Assist Mode. Unable to start drying. Please try again later.","1802_C06D":"AMS-HT C is assisting in filament insertion. Unable to start drying. Please try again later.","1802_C06E":"AMS-HT C motor is performing self-test. Unable to start drying. Please try again later.","1803_4025":"Failed to read the filament information.","1803_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1803_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1803_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1803_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1803_8007":"Extruding filament failed. The extruder might be clogged.","1803_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT D to the extruder is properly connected.","1803_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1803_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1803_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1803_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1803_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1803_8017":"AMS-HT D is drying. Please stop drying process before loading/unloading material.","1803_8021":"AMS setup failed; please refer to the assistant.","1803_8023":"AMS-HT D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1803_C069":"An error occurred during AMS-HT D drying. Please go to Assistant for more details.","1803_C06A":"AMS-HT D is reading RFID. Unable to start drying. Please try again later.","1803_C06B":"AMS-HT D is changing filament. Unable to start drying. Please try again later.","1803_C06C":"AMS-HT D is in Feed Assist Mode. Unable to start drying. Please try again later.","1803_C06D":"AMS-HT D is assisting in filament insertion. Unable to start drying. Please try again later.","1803_C06E":"AMS-HT D motor is performing self-test. Unable to start drying. Please try again later.","1804_4025":"Failed to read the filament information.","1804_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1804_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1804_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1804_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1804_8007":"Extruding filament failed. The extruder might be clogged.","1804_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT E to the extruder is properly connected.","1804_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1804_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1804_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1804_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1804_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1804_8021":"AMS setup failed; please refer to the assistant.","1804_8023":"AMS-HT E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1804_C069":"An error occurred during AMS-HT E drying. Please go to Assistant for more details.","1804_C06A":"AMS-HT E is reading RFID. Unable to start drying. Please try again later.","1804_C06B":"AMS-HT E is changing filament. Unable to start drying. Please try again later.","1804_C06C":"AMS-HT E is in Feed Assist Mode. Unable to start drying. Please try again later.","1804_C06D":"AMS-HT E is assisting in filament insertion. Unable to start drying. Please try again later.","1804_C06E":"AMS-HT E motor is performing self-test. Unable to start drying. Please try again later.","1805_4025":"Failed to read the filament information.","1805_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1805_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1805_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1805_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1805_8007":"Extruding filament failed. The extruder might be clogged.","1805_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT F to the extruder is properly connected.","1805_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1805_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1805_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1805_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1805_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1805_8021":"AMS setup failed; please refer to the assistant.","1805_8023":"AMS-HT F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1805_C069":"An error occurred during AMS-HT F drying. Please go to Assistant for more details.","1805_C06A":"AMS-HT F is reading RFID. Unable to start drying. Please try again later.","1805_C06B":"AMS-HT F is changing filament. Unable to start drying. Please try again later.","1805_C06C":"AMS-HT F is in Feed Assist Mode. Unable to start drying. Please try again later.","1805_C06D":"AMS-HT F is assisting in filament insertion. Unable to start drying. Please try again later.","1805_C06E":"AMS-HT F motor is performing self-test. Unable to start drying. Please try again later.","1806_4025":"Failed to read the filament information.","1806_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1806_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1806_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1806_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1806_8007":"Extruding filament failed. The extruder might be clogged.","1806_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT G to the extruder is properly connected.","1806_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1806_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1806_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1806_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1806_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1806_8021":"AMS setup failed; please refer to the assistant.","1806_8023":"AMS-HT G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1806_C069":"An error occurred during AMS-HT G drying. Please go to Assistant for more details.","1806_C06A":"AMS-HT G is reading RFID. Unable to start drying. Please try again later.","1806_C06B":"AMS-HT G is changing filament. Unable to start drying. Please try again later.","1806_C06C":"AMS-HT G is in Feed Assist Mode. Unable to start drying. Please try again later.","1806_C06D":"AMS-HT G is assisting in filament insertion. Unable to start drying. Please try again later.","1806_C06E":"AMS-HT G motor is performing self-test. Unable to start drying. Please try again later.","1807_4025":"Failed to read the filament information.","1807_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1807_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1807_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1807_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1807_8007":"Extruding filament failed. The extruder might be clogged.","1807_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT H to the extruder is properly connected.","1807_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1807_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1807_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1807_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1807_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1807_8021":"AMS setup failed; please refer to the assistant.","1807_8023":"AMS-HT H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1807_C069":"An error occurred during AMS-HT H drying. Please go to Assistant for more details.","1807_C06A":"AMS-HT H is reading RFID. Unable to start drying. Please try again later.","1807_C06B":"AMS-HT H is changing filament. Unable to start drying. Please try again later.","1807_C06C":"AMS-HT H is in Feed Assist Mode. Unable to start drying. Please try again later.","1807_C06D":"AMS-HT H is assisting in filament insertion. Unable to start drying. Please try again later.","1807_C06E":"AMS-HT H motor is performing self-test. Unable to start drying. Please try again later.","18FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","18FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","18FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","18FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","18FE_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","18FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","18FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","18FE_8020":"Extruder change failed; please refer to the assistant.","18FE_8021":"AMS setup failed; please refer to the assistant.","18FE_8024":"Extruder position calibration failed; please refer to the assistant.","18FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","18FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","18FF_8002":"The cutter of the right extruder is stuck. Please pull out the cutter handle.","18FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","18FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","18FF_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FF_8011":"The external filament connected to the right extruder has run out; please load a new filament.","18FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","18FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","18FF_8020":"Extruder change failed; please refer to the assistant.","18FF_8021":"AMS setup failed; please refer to the assistant.","18FF_8024":"Extruder position calibration failed; please refer to the assistant.","18FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'."};function Yde(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Gn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Gn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:Oa};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:tf}}}function a3(t,e){const n=t>>16&65535||(t>>8&255)<<8|t&255,r=e&65535;return`${n.toString(16).padStart(4,"0").toUpperCase()}_${r.toString(16).padStart(4,"0").toUpperCase()}`}function Zde(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=a3(e.attr,n);return i3[r]!==void 0})}function Qde(){return"https://wiki.bambulab.com/en/hms/home"}function Jde({printerName:t,errors:e,onClose:n}){console.log("HMSErrorModal errors:",JSON.stringify(e,null,2));const r=e.filter(i=>{const a=parseInt(i.code.replace("0x",""),16)||0,s=a3(i.attr,a);return i3[s]!==void 0});return S.useEffect(()=>{const i=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]),o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Gn,{className:"w-5 h-5 text-orange-400"}),o.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Errors - ",t]})]}),o.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r.length===0?o.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[o.jsx(Oa,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),o.jsx("p",{children:"No errors"})]}):o.jsx("div",{className:"space-y-3",children:r.map((i,a)=>{const{label:s,color:l,bgColor:c,Icon:u}=Yde(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=a3(i.attr,d),g=i3[f],p=Qde(),x=f.replace("_","-");return o.jsx("div",{className:`p-4 rounded-lg ${c} border border-white/10`,children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(u,{className:`w-5 h-5 ${l} flex-shrink-0 mt-0.5`}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsxs("span",{className:`font-mono text-sm ${l}`,children:["[",x,"]"]}),o.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${c} ${l}`,children:s})]}),o.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:g}),o.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[o.jsx(la,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${i.code}-${a}`)})})}),o.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:o.jsx("p",{className:"text-xs text-bambu-gray",children:"Clear errors on the printer to dismiss them here."})})]})})}function ehe(t){if(!t)return"ASAP";const e=new Date(t),n=new Date,r=e.getTime()-n.getTime();return r<0?"Now":r<6e4?"In <1 min":r<36e5?`In ${Math.round(r/6e4)} min`:r<864e5?`In ${Math.round(r/36e5)}h`:e.toLocaleDateString()}function the({printerId:t}){const{data:e}=gt({queryKey:["queue",t,"pending"],queryFn:()=>_e.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:o.jsx(Sc,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[o.jsx(Jr,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),o.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[o.jsx(ur,{className:"w-3 h-3"}),ehe(n?.scheduled_time||null)]}),r>1&&o.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),o.jsx(Ko,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function tW(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=tW(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Pn(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=tW(t))&&(r&&(r+=" "),r+=e);return r}var nhe=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"];function _R(t){if(typeof t!="string")return!1;var e=nhe;return e.includes(t)}var rhe=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],ihe=new Set(rhe);function nW(t){return typeof t!="string"?!1:ihe.has(t)}function rW(t){return typeof t=="string"&&t.startsWith("data-")}function La(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(nW(n)||rW(n))&&(e[n]=t[n]);return e}function of(t){if(t==null)return null;if(S.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return La(e)}return typeof t=="object"&&!Array.isArray(t)?La(t):null}function ua(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(nW(n)||rW(n)||_R(n))&&(e[n]=t[n]);return e}function ahe(t){return t==null?null:S.isValidElement(t)?ua(t.props):typeof t=="object"&&!Array.isArray(t)?ua(t):null}var she=["children","width","height","viewBox","className","style","title","desc"];function s3(){return s3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},s3.apply(null,arguments)}function ohe(t,e){if(t==null)return{};var n,r,i=lhe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function lhe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var wR=S.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:s,style:l,title:c,desc:u}=t,d=ohe(t,she),f=a||{width:r,height:i,x:0,y:0},g=Pn("recharts-surface",s);return S.createElement("svg",s3({},ua(d),{className:g,width:r,height:i,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),S.createElement("title",null,c),S.createElement("desc",null,u),n)}),che=["children","className"];function o3(){return o3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},o3.apply(null,arguments)}function uhe(t,e){if(t==null)return{};var n,r,i=dhe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function dhe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Or=S.forwardRef((t,e)=>{var{children:n,className:r}=t,i=uhe(t,che),a=Pn("recharts-layer",r);return S.createElement("g",o3({className:a},ua(i),{ref:e}),n)}),iW=S.createContext(null),hhe=()=>S.useContext(iW);function xr(t){return function(){return t}}const aW=Math.cos,G1=Math.sin,Xo=Math.sqrt,W1=Math.PI,sM=2*W1,l3=Math.PI,c3=2*l3,mh=1e-6,fhe=c3-mh;function sW(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function mhe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return sW;const n=10**e;return function(r){this._+=r[0];for(let i=1,a=r.length;i<a;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class phe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?sW:mhe(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,a,s){this._append`C${+e},${+n},${+r},${+i},${this._x1=+a},${this._y1=+s}`}arcTo(e,n,r,i,a){if(e=+e,n=+n,r=+r,i=+i,a=+a,a<0)throw new Error(`negative radius: ${a}`);let s=this._x1,l=this._y1,c=r-e,u=i-n,d=s-e,f=l-n,g=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(g>mh)if(!(Math.abs(f*c-u*d)>mh)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let p=r-s,x=i-l,v=c*c+u*u,y=p*p+x*x,b=Math.sqrt(v),E=Math.sqrt(g),w=a*Math.tan((l3-Math.acos((v+g-y)/(2*b*E)))/2),A=w/E,T=w/b;Math.abs(A-1)>mh&&this._append`L${e+A*d},${n+A*f}`,this._append`A${a},${a},0,0,${+(f*p>d*x)},${this._x1=e+T*c},${this._y1=n+T*u}`}}arc(e,n,r,i,a,s){if(e=+e,n=+n,r=+r,s=!!s,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(i),c=r*Math.sin(i),u=e+l,d=n+c,f=1^s,g=s?i-a:a-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>mh||Math.abs(this._y1-d)>mh)&&this._append`L${u},${d}`,r&&(g<0&&(g=g%c3+c3),g>fhe?this._append`A${r},${r},0,1,${f},${e-l},${n-c}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:g>mh&&this._append`A${r},${r},0,${+(g>=l3)},${f},${this._x1=e+r*Math.cos(a)},${this._y1=n+r*Math.sin(a)}`)}rect(e,n,r,i){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function SR(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(n==null)e=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);e=r}return t},()=>new phe(e)}function MR(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function oW(t){this._context=t}oW.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e);break}}};function oM(t){return new oW(t)}function lW(t){return t[0]}function cW(t){return t[1]}function uW(t,e){var n=xr(!0),r=null,i=oM,a=null,s=SR(l);t=typeof t=="function"?t:t===void 0?lW:xr(t),e=typeof e=="function"?e:e===void 0?cW:xr(e);function l(c){var u,d=(c=MR(c)).length,f,g=!1,p;for(r==null&&(a=i(p=s())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===g&&((g=!g)?a.lineStart():a.lineEnd()),g&&a.point(+t(f,u,c),+e(f,u,c));if(p)return a=null,p+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:xr(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:xr(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:xr(!!c),l):n},l.curve=function(c){return arguments.length?(i=c,r!=null&&(a=i(r)),l):i},l.context=function(c){return arguments.length?(c==null?r=a=null:a=i(r=c),l):r},l}function kv(t,e,n){var r=null,i=xr(!0),a=null,s=oM,l=null,c=SR(u);t=typeof t=="function"?t:t===void 0?lW:xr(+t),e=typeof e=="function"?e:xr(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?cW:xr(+n);function u(f){var g,p,x,v=(f=MR(f)).length,y,b=!1,E,w=new Array(v),A=new Array(v);for(a==null&&(l=s(E=c())),g=0;g<=v;++g){if(!(g<v&&i(y=f[g],g,f))===b)if(b=!b)p=g,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=g-1;x>=p;--x)l.point(w[x],A[x]);l.lineEnd(),l.areaEnd()}b&&(w[g]=+t(y,g,f),A[g]=+e(y,g,f),l.point(r?+r(y,g,f):w[g],n?+n(y,g,f):A[g]))}if(E)return l=null,E+""||null}function d(){return uW().defined(i).curve(s).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:xr(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:xr(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:xr(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:xr(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:xr(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:xr(+f),u):n},u.lineX0=u.lineY0=function(){return d().x(t).y(e)},u.lineY1=function(){return d().x(t).y(n)},u.lineX1=function(){return d().x(r).y(e)},u.defined=function(f){return arguments.length?(i=typeof f=="function"?f:xr(!!f),u):i},u.curve=function(f){return arguments.length?(s=f,a!=null&&(l=s(a)),u):s},u.context=function(f){return arguments.length?(f==null?a=l=null:l=s(a=f),u):a},u}class dW{constructor(e,n){this._context=e,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(e,n){switch(e=+e,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(e,n):this._context.moveTo(e,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,n,e,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,e,this._y0,e,n);break}}this._x0=e,this._y0=n}}function ghe(t){return new dW(t,!0)}function xhe(t){return new dW(t,!1)}const ER={draw(t,e){const n=Xo(e/W1);t.moveTo(n,0),t.arc(0,0,n,0,sM)}},bhe={draw(t,e){const n=Xo(e/5)/2;t.moveTo(-3*n,-n),t.lineTo(-n,-n),t.lineTo(-n,-3*n),t.lineTo(n,-3*n),t.lineTo(n,-n),t.lineTo(3*n,-n),t.lineTo(3*n,n),t.lineTo(n,n),t.lineTo(n,3*n),t.lineTo(-n,3*n),t.lineTo(-n,n),t.lineTo(-3*n,n),t.closePath()}},hW=Xo(1/3),yhe=hW*2,vhe={draw(t,e){const n=Xo(e/yhe),r=n*hW;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},_he={draw(t,e){const n=Xo(e),r=-n/2;t.rect(r,r,n,n)}},whe=.8908130915292852,fW=G1(W1/10)/G1(7*W1/10),She=G1(sM/10)*fW,Mhe=-aW(sM/10)*fW,Ehe={draw(t,e){const n=Xo(e*whe),r=She*n,i=Mhe*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const s=sM*a/5,l=aW(s),c=G1(s);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},YA=Xo(3),Ahe={draw(t,e){const n=-Xo(e/(YA*3));t.moveTo(0,n*2),t.lineTo(-YA*n,-n),t.lineTo(YA*n,-n),t.closePath()}},$s=-.5,Vs=Xo(3)/2,u3=1/Xo(12),The=(u3/2+1)*3,Nhe={draw(t,e){const n=Xo(e/The),r=n/2,i=n*u3,a=r,s=n*u3+n,l=-a,c=s;t.moveTo(r,i),t.lineTo(a,s),t.lineTo(l,c),t.lineTo($s*r-Vs*i,Vs*r+$s*i),t.lineTo($s*a-Vs*s,Vs*a+$s*s),t.lineTo($s*l-Vs*c,Vs*l+$s*c),t.lineTo($s*r+Vs*i,$s*i-Vs*r),t.lineTo($s*a+Vs*s,$s*s-Vs*a),t.lineTo($s*l+Vs*c,$s*c-Vs*l),t.closePath()}};function Che(t,e){let n=null,r=SR(i);t=typeof t=="function"?t:xr(t||ER),e=typeof e=="function"?e:xr(e===void 0?64:+e);function i(){let a;if(n||(n=a=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),a)return n=null,a+""||null}return i.type=function(a){return arguments.length?(t=typeof a=="function"?a:xr(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:xr(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function q1(){}function K1(t,e,n){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+n)/6)}function mW(t){this._context=t}mW.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:K1(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:K1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function khe(t){return new mW(t)}function pW(t){this._context=t}pW.prototype={areaStart:q1,areaEnd:q1,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x2=t,this._y2=e;break;case 1:this._point=2,this._x3=t,this._y3=e;break;case 2:this._point=3,this._x4=t,this._y4=e,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+e)/6);break;default:K1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Phe(t){return new pW(t)}function gW(t){this._context=t}gW.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+t)/6,r=(this._y0+4*this._y1+e)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:K1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function jhe(t){return new gW(t)}function xW(t){this._context=t}xW.prototype={areaStart:q1,areaEnd:q1,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(t,e){t=+t,e=+e,this._point?this._context.lineTo(t,e):(this._point=1,this._context.moveTo(t,e))}};function Rhe(t){return new xW(t)}function kU(t){return t<0?-1:1}function PU(t,e,n){var r=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(r||i<0&&-0),s=(n-t._y1)/(i||r<0&&-0),l=(a*i+s*r)/(r+i);return(kU(a)+kU(s))*Math.min(Math.abs(a),Math.abs(s),.5*Math.abs(l))||0}function jU(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function ZA(t,e,n){var r=t._x0,i=t._y0,a=t._x1,s=t._y1,l=(a-r)/3;t._context.bezierCurveTo(r+l,i+l*e,a-l,s-l*n,a,s)}function X1(t){this._context=t}X1.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:ZA(this,this._t0,jU(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){var n=NaN;if(t=+t,e=+e,!(t===this._x1&&e===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,ZA(this,jU(this,n=PU(this,t,e)),n);break;default:ZA(this,this._t0,n=PU(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function bW(t){this._context=new yW(t)}(bW.prototype=Object.create(X1.prototype)).point=function(t,e){X1.prototype.point.call(this,e,t)};function yW(t){this._context=t}yW.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,r,i,a){this._context.bezierCurveTo(e,t,r,n,a,i)}};function Dhe(t){return new X1(t)}function Ohe(t){return new bW(t)}function vW(t){this._context=t}vW.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,e=this._y,n=t.length;if(n)if(this._line?this._context.lineTo(t[0],e[0]):this._context.moveTo(t[0],e[0]),n===2)this._context.lineTo(t[1],e[1]);else for(var r=RU(t),i=RU(e),a=0,s=1;s<n;++a,++s)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],t[s],e[s]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function RU(t){var e,n=t.length-1,r,i=new Array(n),a=new Array(n),s=new Array(n);for(i[0]=0,a[0]=2,s[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,a[e]=4,s[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,a[n-1]=7,s[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/a[e-1],a[e]-=r,s[e]-=r*s[e-1];for(i[n-1]=s[n-1]/a[n-1],e=n-2;e>=0;--e)i[e]=(s[e]-i[e+1])/a[e];for(a[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)a[e]=2*t[e+1]-i[e+1];return[i,a]}function Lhe(t){return new vW(t)}function lM(t,e){this._context=t,this._t=e}lM.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e)}break}}this._x=t,this._y=e}};function Ihe(t){return new lM(t,.5)}function Fhe(t){return new lM(t,0)}function Uhe(t){return new lM(t,1)}function kp(t,e){if((s=t.length)>1)for(var n=1,r,i,a=t[e[0]],s,l=a.length;n<s;++n)for(i=a,a=t[e[n]],r=0;r<l;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function d3(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function zhe(t,e){return t[e]}function Bhe(t){const e=[];return e.key=t,e}function Hhe(){var t=xr([]),e=d3,n=kp,r=zhe;function i(a){var s=Array.from(t.apply(this,arguments),Bhe),l,c=s.length,u=-1,d;for(const f of a)for(l=0,++u;l<c;++l)(s[l][u]=[0,+r(f,s[l].key,u,a)]).data=f;for(l=0,d=MR(e(s));l<c;++l)s[d[l]].index=l;return n(s,d),s}return i.keys=function(a){return arguments.length?(t=typeof a=="function"?a:xr(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:xr(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?d3:typeof a=="function"?a:xr(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??kp,i):n},i}function $he(t,e){if((r=t.length)>0){for(var n,r,i=0,a=t[0].length,s;i<a;++i){for(s=n=0;n<r;++n)s+=t[n][i][1]||0;if(s)for(n=0;n<r;++n)t[n][i][1]/=s}kp(t,e)}}function Vhe(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,a=r.length;n<a;++n){for(var s=0,l=0;s<i;++s)l+=t[s][n][1]||0;r[n][1]+=r[n][0]=-l/2}kp(t,e)}}function Ghe(t,e){if(!(!((s=t.length)>0)||!((a=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,a,s;r<a;++r){for(var l=0,c=0,u=0;l<s;++l){for(var d=t[e[l]],f=d[r][1]||0,g=d[r-1][1]||0,p=(f-g)/2,x=0;x<l;++x){var v=t[e[x]],y=v[r][1]||0,b=v[r-1][1]||0;p+=y-b}c+=f,u+=p*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,kp(t,e)}}var QA={},JA={},DU;function Whe(){return DU||(DU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(JA)),JA}var eT={},OU;function _W(){return OU||(OU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){switch(typeof n){case"number":case"symbol":return!1;case"string":return n.includes(".")||n.includes("[")||n.includes("]")}}t.isDeepKey=e})(eT)),eT}var tT={},LU;function AR(){return LU||(LU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="string"||typeof n=="symbol"?n:Object.is(n?.valueOf?.(),-0)?"-0":String(n)}t.toKey=e})(tT)),tT}var nT={},rT={},IU;function qhe(){return IU||(IU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){if(n==null)return"";if(typeof n=="string")return n;if(Array.isArray(n))return n.map(e).join(",");const r=String(n);return r==="0"&&Object.is(Number(n),-0)?"-0":r}t.toString=e})(rT)),rT}var FU;function TR(){return FU||(FU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qhe(),n=AR();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const a=[],s=i.length;if(s===0)return a;let l=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(a.push(""),l++);l<s;){const f=i[l];u?f==="\\"&&l+1<s?(l++,c+=i[l]):f===u?u="":c+=f:d?f==='"'||f==="'"?u=f:f==="]"?(d=!1,a.push(c),c=""):c+=f:f==="["?(d=!0,c&&(a.push(c),c="")):f==="."?c&&(a.push(c),c=""):c+=f,l++}return c&&a.push(c),a}t.toPath=r})(nT)),nT}var UU;function NR(){return UU||(UU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Whe(),n=_W(),r=AR(),i=TR();function a(l,c,u){if(l==null)return u;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?n.isDeepKey(c)?a(l,i.toPath(c),u):u:d}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const d=l[c];return d===void 0?u:d}default:{if(Array.isArray(c))return s(l,c,u);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?u:d}}}function s(l,c,u){if(c.length===0)return u;let d=l;for(let f=0;f<c.length;f++){if(d==null||e.isUnsafeProperty(c[f]))return u;d=d[c[f]]}return d===void 0?u:d}t.get=a})(QA)),QA}var iT,zU;function Khe(){return zU||(zU=1,iT=NR().get),iT}var Xhe=Khe();const lf=yo(Xhe);var Hi=t=>t===0?0:t>0?1:-1,ss=t=>typeof t=="number"&&t!=+t,Hc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Dt=t=>(typeof t=="number"||t instanceof Number)&&!ss(t),go=t=>Dt(t)||typeof t=="string",Yhe=0,I0=t=>{var e=++Yhe;return"".concat(t||"").concat(e)},_a=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Dt(e)&&typeof e!="string")return r;var a;if(Hc(e)){if(n==null)return r;var s=e.indexOf("%");a=n*parseFloat(e.slice(0,s))/100}else a=+e;return ss(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},wW=t=>{if(!Array.isArray(t))return!1;for(var e=t.length,n={},r=0;r<e;r++)if(!n[t[r]])n[t[r]]=!0;else return!0;return!1};function Vn(t,e,n){return Dt(t)&&Dt(e)?t+n*(e-t):e}function SW(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):lf(r,e))===n)}var Er=t=>t===null||typeof t>"u",Pb=t=>Er(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function Zhe(t){return t!=null}function jb(){}var Qhe=["type","size","sizeType"];function h3(){return h3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},h3.apply(null,arguments)}function BU(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function HU(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?BU(Object(n),!0).forEach(function(r){Jhe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):BU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Jhe(t,e,n){return(e=efe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function efe(t){var e=tfe(t,"string");return typeof e=="symbol"?e:e+""}function tfe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function nfe(t,e){if(t==null)return{};var n,r,i=rfe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function rfe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var MW={symbolCircle:ER,symbolCross:bhe,symbolDiamond:vhe,symbolSquare:_he,symbolStar:Ehe,symbolTriangle:Ahe,symbolWye:Nhe},ife=Math.PI/180,afe=t=>{var e="symbol".concat(Pb(t));return MW[e]||ER},sfe=(t,e,n)=>{if(e==="area")return t;switch(n){case"cross":return 5*t*t/9;case"diamond":return .5*t*t/Math.sqrt(3);case"square":return t*t;case"star":{var r=18*ife;return 1.25*t*t*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**2)}case"triangle":return Math.sqrt(3)*t*t/4;case"wye":return(21-10*Math.sqrt(3))*t*t/8;default:return Math.PI*t*t/4}},ofe=(t,e)=>{MW["symbol".concat(Pb(t))]=e},CR=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=nfe(t,Qhe),a=HU(HU({},i),{},{type:e,size:n,sizeType:r}),s="circle";typeof e=="string"&&(s=e);var l=()=>{var g=afe(s),p=Che().type(g).size(sfe(n,r,s)),x=p();if(x!==null)return x},{className:c,cx:u,cy:d}=a,f=ua(a);return Dt(u)&&Dt(d)&&Dt(n)?S.createElement("path",h3({},f,{className:Pn("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};CR.registerSymbol=ofe;var EW=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,kR=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(S.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{_R(i)&&(r[i]=(a=>n[i](n,a)))}),r},lfe=(t,e,n)=>r=>(t(e,n,r),null),Rb=(t,e,n)=>{if(t===null||typeof t!="object"&&typeof t!="function")return null;var r=null;return Object.keys(t).forEach(i=>{var a=t[i];_R(i)&&typeof a=="function"&&(r||(r={}),r[i]=lfe(a,e,n))}),r};function $U(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function cfe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$U(Object(n),!0).forEach(function(r){ufe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$U(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ufe(t,e,n){return(e=dfe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dfe(t){var e=hfe(t,"string");return typeof e=="symbol"?e:e+""}function hfe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Lr(t,e){var n=cfe({},t),r=e,i=Object.keys(e),a=i.reduce((s,l)=>(s[l]===void 0&&r[l]!==void 0&&(s[l]=r[l]),s),n);return a}function Y1(){return Y1=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Y1.apply(null,arguments)}function VU(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ffe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?VU(Object(n),!0).forEach(function(r){mfe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):VU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mfe(t,e,n){return(e=pfe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pfe(t){var e=gfe(t,"string");return typeof e=="symbol"?e:e+""}function gfe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Xs=32,xfe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function bfe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Xs/2,a=Xs/6,s=Xs/3,l=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return S.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:Xs,y2:i,className:"recharts-legend-icon"})}if(c==="line")return S.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(s,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(2*s,",").concat(i,`
- H`).concat(Xs,"M").concat(2*s,",").concat(i,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(s,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return S.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(Xs/8,"h").concat(Xs,"v").concat(Xs*3/4,"h").concat(-Xs,"z"),className:"recharts-legend-icon"});if(S.isValidElement(e.legendIcon)){var d=ffe({},e);return delete d.legendIcon,S.cloneElement(e.legendIcon,d)}return S.createElement(CR,{fill:l,cx:i,cy:i,size:Xs,sizeType:"diameter",type:c})}function yfe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:s}=t,l={x:0,y:0,width:Xs,height:Xs},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var g=d.formatter||i,p=Pn({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?a:d.color,v=g?g(d.value,d,f):d.value;return S.createElement("li",Y1({className:p,style:c,key:"legend-item-".concat(f)},Rb(t,d,f)),S.createElement(wR,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(v," legend icon")},S.createElement(bfe,{data:d,iconType:s,inactiveColor:a})),S.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},v))})}var vfe=t=>{var e=Lr(t,xfe),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return S.createElement("ul",{className:"recharts-default-legend",style:a},S.createElement(yfe,Y1({},e,{payload:n})))},aT={},sT={},GU;function _fe(){return GU||(GU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let a=0;a<n.length;a++){const s=n[a],l=r(s);i.has(l)||i.set(l,s)}return Array.from(i.values())}t.uniqBy=e})(sT)),sT}var oT={},WU;function AW(){return WU||(WU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(oT)),oT}var lT={},cT={},uT={},qU;function wfe(){return qU||(qU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(uT)),uT}var KU;function PR(){return KU||(KU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=wfe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(cT)),cT}var dT={},XU;function Sfe(){return XU||(XU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(dT)),dT}var YU;function Mfe(){return YU||(YU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=PR(),n=Sfe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(lT)),lT}var hT={},fT={},ZU;function Efe(){return ZU||(ZU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=NR();function n(r){return function(i){return e.get(i,r)}}t.property=n})(fT)),fT}var mT={},pT={},gT={},xT={},QU;function TW(){return QU||(QU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n!==null&&(typeof n=="object"||typeof n=="function")}t.isObject=e})(xT)),xT}var bT={},JU;function NW(){return JU||(JU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==null||typeof n!="object"&&typeof n!="function"}t.isPrimitive=e})(bT)),bT}var yT={},ez;function CW(){return ez||(ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){return n===r||Number.isNaN(n)&&Number.isNaN(r)}t.eq=e})(yT)),yT}var tz;function Afe(){return tz||(tz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=TW(),n=NW(),r=CW();function i(d,f,g){return typeof g!="function"?i(d,f,()=>{}):a(d,f,function p(x,v,y,b,E,w){const A=g(x,v,y,b,E,w);return A!==void 0?!!A:a(x,v,p,w)},new Map)}function a(d,f,g,p){if(f===d)return!0;switch(typeof f){case"object":return s(d,f,g,p);case"function":return Object.keys(f).length>0?a(d,{...f},g,p):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function s(d,f,g,p){if(f==null)return!0;if(Array.isArray(f))return c(d,f,g,p);if(f instanceof Map)return l(d,f,g,p);if(f instanceof Set)return u(d,f,g,p);const x=Object.keys(f);if(d==null)return x.length===0;if(x.length===0)return!0;if(p?.has(f))return p.get(f)===d;p?.set(f,d);try{for(let v=0;v<x.length;v++){const y=x[v];if(!n.isPrimitive(d)&&!(y in d)||f[y]===void 0&&d[y]!==void 0||f[y]===null&&d[y]!==null||!g(d[y],f[y],y,d,f,p))return!1}return!0}finally{p?.delete(f)}}function l(d,f,g,p){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,v]of f.entries()){const y=d.get(x);if(g(y,v,x,d,f,p)===!1)return!1}return!0}function c(d,f,g,p){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let v=0;v<f.length;v++){const y=f[v];let b=!1;for(let E=0;E<d.length;E++){if(x.has(E))continue;const w=d[E];let A=!1;if(g(w,y,v,d,f,p)&&(A=!0),A){x.add(E),b=!0;break}}if(!b)return!1}return!0}function u(d,f,g,p){return f.size===0?!0:d instanceof Set?c([...d],[...f],g,p):!1}t.isMatchWith=i,t.isSetMatch=u})(gT)),gT}var nz;function kW(){return nz||(nz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Afe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(pT)),pT}var vT={},_T={},wT={},rz;function Tfe(){return rz||(rz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Object.getOwnPropertySymbols(n).filter(r=>Object.prototype.propertyIsEnumerable.call(n,r))}t.getSymbols=e})(wT)),wT}var ST={},iz;function PW(){return iz||(iz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}t.getTag=e})(ST)),ST}var MT={},az;function jW(){return az||(az=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",a="[object Arguments]",s="[object Symbol]",l="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",g="[object ArrayBuffer]",p="[object Object]",x="[object Error]",v="[object DataView]",y="[object Uint8Array]",b="[object Uint8ClampedArray]",E="[object Uint16Array]",w="[object Uint32Array]",A="[object BigUint64Array]",T="[object Int8Array]",C="[object Int16Array]",N="[object Int32Array]",O="[object BigInt64Array]",k="[object Float32Array]",j="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=g,t.arrayTag=d,t.bigInt64ArrayTag=O,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=v,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=k,t.float64ArrayTag=j,t.functionTag=f,t.int16ArrayTag=C,t.int32ArrayTag=N,t.int8ArrayTag=T,t.mapTag=c,t.numberTag=r,t.objectTag=p,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=s,t.uint16ArrayTag=E,t.uint32ArrayTag=w,t.uint8ArrayTag=y,t.uint8ClampedArrayTag=b})(MT)),MT}var ET={},sz;function Nfe(){return sz||(sz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(ET)),ET}var oz;function RW(){return oz||(oz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Tfe(),n=PW(),r=jW(),i=NW(),a=Nfe();function s(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,g,p=new Map,x=void 0){const v=x?.(d,f,g,p);if(v!==void 0)return v;if(i.isPrimitive(d))return d;if(p.has(d))return p.get(d);if(Array.isArray(d)){const y=new Array(d.length);p.set(d,y);for(let b=0;b<d.length;b++)y[b]=l(d[b],b,g,p,x);return Object.hasOwn(d,"index")&&(y.index=d.index),Object.hasOwn(d,"input")&&(y.input=d.input),y}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const y=new RegExp(d.source,d.flags);return y.lastIndex=d.lastIndex,y}if(d instanceof Map){const y=new Map;p.set(d,y);for(const[b,E]of d)y.set(b,l(E,b,g,p,x));return y}if(d instanceof Set){const y=new Set;p.set(d,y);for(const b of d)y.add(l(b,void 0,g,p,x));return y}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const y=new(Object.getPrototypeOf(d)).constructor(d.length);p.set(d,y);for(let b=0;b<d.length;b++)y[b]=l(d[b],b,g,p,x);return y}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const y=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return p.set(d,y),c(y,d,g,p,x),y}if(typeof File<"u"&&d instanceof File){const y=new File([d],d.name,{type:d.type});return p.set(d,y),c(y,d,g,p,x),y}if(typeof Blob<"u"&&d instanceof Blob){const y=new Blob([d],{type:d.type});return p.set(d,y),c(y,d,g,p,x),y}if(d instanceof Error){const y=new d.constructor;return p.set(d,y),y.message=d.message,y.name=d.name,y.stack=d.stack,y.cause=d.cause,c(y,d,g,p,x),y}if(d instanceof Boolean){const y=new Boolean(d.valueOf());return p.set(d,y),c(y,d,g,p,x),y}if(d instanceof Number){const y=new Number(d.valueOf());return p.set(d,y),c(y,d,g,p,x),y}if(d instanceof String){const y=new String(d.valueOf());return p.set(d,y),c(y,d,g,p,x),y}if(typeof d=="object"&&u(d)){const y=Object.create(Object.getPrototypeOf(d));return p.set(d,y),c(y,d,g,p,x),y}return d}function c(d,f,g=d,p,x){const v=[...Object.keys(f),...e.getSymbols(f)];for(let y=0;y<v.length;y++){const b=v[y],E=Object.getOwnPropertyDescriptor(d,b);(E==null||E.writable)&&(d[b]=l(f[b],b,g,p,x))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=s,t.cloneDeepWithImpl=l,t.copyProperties=c})(_T)),_T}var lz;function Cfe(){return lz||(lz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=RW();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(vT)),vT}var cz;function kfe(){return cz||(cz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=kW(),n=Cfe();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(mT)),mT}var AT={},TT={},NT={},uz;function Pfe(){return uz||(uz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=RW(),n=jW();function r(i,a){return e.cloneDeepWith(i,(s,l,c,u)=>{const d=a?.(s,l,c,u);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new i.constructor(i?.valueOf());return e.copyProperties(f,i),f}case n.argumentsTag:{const f={};return e.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}t.cloneDeepWith=r})(NT)),NT}var dz;function jfe(){return dz||(dz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Pfe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(TT)),TT}var CT={},kT={},hz;function DW(){return hz||(hz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=/^(?:0|[1-9]\d*)$/;function n(r,i=Number.MAX_SAFE_INTEGER){switch(typeof r){case"number":return Number.isInteger(r)&&r>=0&&r<i;case"symbol":return!1;case"string":return e.test(r)}}t.isIndex=n})(kT)),kT}var PT={},fz;function Rfe(){return fz||(fz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=PW();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(PT)),PT}var mz;function Dfe(){return mz||(mz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=_W(),n=DW(),r=Rfe(),i=TR();function a(s,l){let c;if(Array.isArray(l)?c=l:typeof l=="string"&&e.isDeepKey(l)&&s?.[l]==null?c=i.toPath(l):c=[l],c.length===0)return!1;let u=s;for(let d=0;d<c.length;d++){const f=c[d];if((u==null||!Object.hasOwn(u,f))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(f)&&f<u.length))return!1;u=u[f]}return!0}t.has=a})(CT)),CT}var pz;function Ofe(){return pz||(pz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=kW(),n=AR(),r=jfe(),i=NR(),a=Dfe();function s(l,c){switch(typeof l){case"object":{Object.is(l?.valueOf(),-0)&&(l="-0");break}case"number":{l=n.toKey(l);break}}return c=r.cloneDeep(c),function(u){const d=i.get(u,l);return d===void 0?a.has(u,l):c===void 0?d===void 0:e.isMatch(d,c)}}t.matchesProperty=s})(AT)),AT}var gz;function Lfe(){return gz||(gz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=AW(),n=Efe(),r=kfe(),i=Ofe();function a(s){if(s==null)return e.identity;switch(typeof s){case"function":return s;case"object":return Array.isArray(s)&&s.length===2?i.matchesProperty(s[0],s[1]):r.matches(s);case"string":case"symbol":case"number":return n.property(s)}}t.iteratee=a})(hT)),hT}var xz;function Ife(){return xz||(xz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=_fe(),n=AW(),r=Mfe(),i=Lfe();function a(s,l=n.identity){return r.isArrayLikeObject(s)?e.uniqBy(Array.from(s),i.iteratee(l)):[]}t.uniqBy=a})(aT)),aT}var jT,bz;function Ffe(){return bz||(bz=1,jT=Ife().uniqBy),jT}var Ufe=Ffe();const yz=yo(Ufe);function OW(t,e,n){return e===!0?yz(t,n):typeof e=="function"?yz(t,e):t}var RT={exports:{}},DT={};var vz;function zfe(){if(vz)return DT;vz=1;var t=tg(),e=s9();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,a=t.useRef,s=t.useEffect,l=t.useMemo,c=t.useDebugValue;return DT.useSyncExternalStoreWithSelector=function(u,d,f,g,p){var x=a(null);if(x.current===null){var v={hasValue:!1,value:null};x.current=v}else v=x.current;x=l(function(){function b(C){if(!E){if(E=!0,w=C,C=g(C),p!==void 0&&v.hasValue){var N=v.value;if(p(N,C))return A=N}return A=C}if(N=A,r(w,C))return N;var O=g(C);return p!==void 0&&p(N,O)?(w=C,N):(w=C,A=O)}var E=!1,w,A,T=f===void 0?null:f;return[function(){return b(d())},T===null?void 0:function(){return b(T())}]},[d,f,g,p]);var y=i(u,x[0],x[1]);return s(function(){v.hasValue=!0,v.value=y},[y]),c(y),y},DT}var _z;function Bfe(){return _z||(_z=1,RT.exports=zfe()),RT.exports}var LW=Bfe(),jR=S.createContext(null),Hfe=t=>t,gr=()=>{var t=S.useContext(jR);return t?t.store.dispatch:Hfe},f1=()=>{},$fe=()=>f1,Vfe=(t,e)=>t===e;function jt(t){var e=S.useContext(jR);return LW.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:$fe,e?e.store.getState:f1,e?e.store.getState:f1,e?t:f1,Vfe)}function Gfe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function Wfe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function qfe(t,e="expected all items to be functions, instead received the following types: "){if(!t.every(n=>typeof n=="function")){const n=t.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${e}[${n}]`)}}var wz=t=>Array.isArray(t)?t:[t];function Kfe(t){const e=Array.isArray(t[0])?t[0]:t;return qfe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function Xfe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var Yfe=class{constructor(t){this.value=t}deref(){return this.value}},Zfe=typeof WeakRef<"u"?WeakRef:Yfe,Qfe=0,Sz=1;function Pv(){return{s:Qfe,v:void 0,o:null,p:null}}function IW(t,e={}){let n=Pv();const{resultEqualityCheck:r}=e;let i,a=0;function s(){let l=n;const{length:c}=arguments;for(let f=0,g=c;f<g;f++){const p=arguments[f];if(typeof p=="function"||typeof p=="object"&&p!==null){let x=l.o;x===null&&(l.o=x=new WeakMap);const v=x.get(p);v===void 0?(l=Pv(),x.set(p,l)):l=v}else{let x=l.p;x===null&&(l.p=x=new Map);const v=x.get(p);v===void 0?(l=Pv(),x.set(p,l)):l=v}}const u=l;let d;if(l.s===Sz)d=l.v;else if(d=t.apply(null,arguments),a++,r){const f=i?.deref?.()??i;f!=null&&r(f,d)&&(d=f,a!==0&&a--),i=typeof d=="object"&&d!==null||typeof d=="function"?new Zfe(d):d}return u.s=Sz,u.v=d,d}return s.clearCache=()=>{n=Pv(),s.resetResultsCount()},s.resultsCount=()=>a,s.resetResultsCount=()=>{a=0},s}function Jfe(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let a=0,s=0,l,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),Gfe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:g=[],argsMemoize:p=IW,argsMemoizeOptions:x=[]}=d,v=wz(g),y=wz(x),b=Kfe(i),E=f(function(){return a++,u.apply(null,arguments)},...v),w=p(function(){s++;const T=Xfe(b,arguments);return l=E.apply(null,T),l},...y);return Object.assign(w,{resultFunc:u,memoizedResultFunc:E,dependencies:b,dependencyRecomputations:()=>s,resetDependencyRecomputations:()=>{s=0},lastResult:()=>l,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var Qe=Jfe(IW),eme=Object.assign((t,e=Qe)=>{Wfe(t,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof t}`);const n=Object.keys(t),r=n.map(a=>t[a]);return e(r,(...a)=>a.reduce((s,l,c)=>(s[n[c]]=l,s),{}))},{withTypes:()=>eme}),OT={},LT={},IT={},Mz;function tme(){return Mz||(Mz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,a)=>{if(r!==i){const s=e(r),l=e(i);if(s===l&&s===0){if(r<i)return a==="desc"?1:-1;if(r>i)return a==="desc"?-1:1}return a==="desc"?l-s:s-l}return 0};t.compareValues=n})(IT)),IT}var FT={},UT={},Ez;function FW(){return Ez||(Ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(UT)),UT}var Az;function nme(){return Az||(Az=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=FW(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,s){return Array.isArray(a)?!1:typeof a=="number"||typeof a=="boolean"||a==null||e.isSymbol(a)?!0:typeof a=="string"&&(r.test(a)||!n.test(a))||s!=null&&Object.hasOwn(s,a)}t.isKey=i})(FT)),FT}var Tz;function rme(){return Tz||(Tz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tme(),n=nme(),r=TR();function i(a,s,l,c){if(a==null)return[];l=c?void 0:l,Array.isArray(a)||(a=Object.values(a)),Array.isArray(s)||(s=s==null?[null]:[s]),s.length===0&&(s=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(p=>String(p));const u=(p,x)=>{let v=p;for(let y=0;y<x.length&&v!=null;++y)v=v[x[y]];return v},d=(p,x)=>x==null||p==null?x:typeof p=="object"&&"key"in p?Object.hasOwn(x,p.key)?x[p.key]:u(x,p.path):typeof p=="function"?p(x):Array.isArray(p)?u(x,p):typeof x=="object"?x[p]:x,f=s.map(p=>(Array.isArray(p)&&p.length===1&&(p=p[0]),p==null||typeof p=="function"||Array.isArray(p)||n.isKey(p)?p:{key:p,path:r.toPath(p)}));return a.map(p=>({original:p,criteria:f.map(x=>d(x,p))})).slice().sort((p,x)=>{for(let v=0;v<f.length;v++){const y=e.compareValues(p.criteria[v],x.criteria[v],l[v]);if(y!==0)return y}return 0}).map(p=>p.original)}t.orderBy=i})(LT)),LT}var zT={},Nz;function ime(){return Nz||(Nz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],a=Math.floor(r),s=(l,c)=>{for(let u=0;u<l.length;u++){const d=l[u];Array.isArray(d)&&c<a?s(d,c+1):i.push(d)}};return s(n,0),i}t.flatten=e})(zT)),zT}var BT={},Cz;function UW(){return Cz||(Cz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=DW(),n=PR(),r=TW(),i=CW();function a(s,l,c){return r.isObject(c)&&(typeof l=="number"&&n.isArrayLike(c)&&e.isIndex(l)&&l<c.length||typeof l=="string"&&l in c)?i.eq(c[l],s):!1}t.isIterateeCall=a})(BT)),BT}var kz;function ame(){return kz||(kz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rme(),n=ime(),r=UW();function i(a,...s){const l=s.length;return l>1&&r.isIterateeCall(a,s[0],s[1])?s=[]:l>2&&r.isIterateeCall(s[0],s[1],s[2])&&(s=[s[0]]),e.orderBy(a,n.flatten(s),["asc"])}t.sortBy=i})(OT)),OT}var HT,Pz;function sme(){return Pz||(Pz=1,HT=ame().sortBy),HT}var ome=sme();const cM=yo(ome);var zW=t=>t.legend.settings,lme=t=>t.legend.size,cme=t=>t.legend.payload,ume=Qe([cme,zW],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?cM(r,n):r});function dme(){return jt(ume)}var jv=1;function BW(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=S.useState({height:0,left:0,top:0,width:0}),r=S.useCallback(i=>{if(i!=null){var a=i.getBoundingClientRect(),s={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(s.height-e.height)>jv||Math.abs(s.left-e.left)>jv||Math.abs(s.top-e.top)>jv||Math.abs(s.width-e.width)>jv)&&n({height:s.height,left:s.left,top:s.top,width:s.width})}},[e.width,e.height,e.top,e.left,...t]);return[e,r]}function ta(t){return`Minified Redux error #${t}; visit https://redux.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var hme=typeof Symbol=="function"&&Symbol.observable||"@@observable",jz=hme,$T=()=>Math.random().toString(36).substring(7).split("").join("."),fme={INIT:`@@redux/INIT${$T()}`,REPLACE:`@@redux/REPLACE${$T()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${$T()}`},Z1=fme;function RR(t){if(typeof t!="object"||t===null)return!1;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e||Object.getPrototypeOf(t)===null}function HW(t,e,n){if(typeof t!="function")throw new Error(ta(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ta(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ta(1));return n(HW)(t,e)}let r=t,i=e,a=new Map,s=a,l=0,c=!1;function u(){s===a&&(s=new Map,a.forEach((y,b)=>{s.set(b,y)}))}function d(){if(c)throw new Error(ta(3));return i}function f(y){if(typeof y!="function")throw new Error(ta(4));if(c)throw new Error(ta(5));let b=!0;u();const E=l++;return s.set(E,y),function(){if(b){if(c)throw new Error(ta(6));b=!1,u(),s.delete(E),a=null}}}function g(y){if(!RR(y))throw new Error(ta(7));if(typeof y.type>"u")throw new Error(ta(8));if(typeof y.type!="string")throw new Error(ta(17));if(c)throw new Error(ta(9));try{c=!0,i=r(i,y)}finally{c=!1}return(a=s).forEach(E=>{E()}),y}function p(y){if(typeof y!="function")throw new Error(ta(10));r=y,g({type:Z1.REPLACE})}function x(){const y=f;return{subscribe(b){if(typeof b!="object"||b===null)throw new Error(ta(11));function E(){const A=b;A.next&&A.next(d())}return E(),{unsubscribe:y(E)}},[jz](){return this}}}return g({type:Z1.INIT}),{dispatch:g,subscribe:f,getState:d,replaceReducer:p,[jz]:x}}function mme(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:Z1.INIT})>"u")throw new Error(ta(12));if(typeof n(void 0,{type:Z1.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ta(13))})}function $W(t){const e=Object.keys(t),n={};for(let a=0;a<e.length;a++){const s=e[a];typeof t[s]=="function"&&(n[s]=t[s])}const r=Object.keys(n);let i;try{mme(n)}catch(a){i=a}return function(s={},l){if(i)throw i;let c=!1;const u={};for(let d=0;d<r.length;d++){const f=r[d],g=n[f],p=s[f],x=g(p,l);if(typeof x>"u")throw l&&l.type,new Error(ta(14));u[f]=x,c=c||x!==p}return c=c||r.length!==Object.keys(s).length,c?u:s}}function Q1(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function pme(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(ta(15))};const s={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(s));return a=Q1(...l)(i.dispatch),{...i,dispatch:a}}}function VW(t){return RR(t)&&"type"in t&&typeof t.type=="string"}var GW=Symbol.for("immer-nothing"),Rz=Symbol.for("immer-draftable"),Ia=Symbol.for("immer-state");function Ro(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Ns=Object,Pp=Ns.getPrototypeOf,J1="constructor",uM="prototype",f3="configurable",ew="enumerable",m1="writable",F0="value",$c=t=>!!t&&!!t[Ia];function Go(t){return t?WW(t)||dM(t)||!!t[Rz]||!!t[J1]?.[Rz]||hM(t)||fM(t):!1}var gme=Ns[uM][J1].toString(),Dz=new WeakMap;function WW(t){if(!t||!DR(t))return!1;const e=Pp(t);if(e===null||e===Ns[uM])return!0;const n=Ns.hasOwnProperty.call(e,J1)&&e[J1];if(n===Object)return!0;if(!Qm(n))return!1;let r=Dz.get(n);return r===void 0&&(r=Function.toString.call(n),Dz.set(n,r)),r===gme}function Db(t,e,n=!0){Ob(t)===0?(n?Reflect.ownKeys(t):Ns.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function Ob(t){const e=t[Ia];return e?e.type_:dM(t)?1:hM(t)?2:fM(t)?3:0}var Oz=(t,e,n=Ob(t))=>n===2?t.has(e):Ns[uM].hasOwnProperty.call(t,e),m3=(t,e,n=Ob(t))=>n===2?t.get(e):t[e],tw=(t,e,n,r=Ob(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function xme(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var dM=Array.isArray,hM=t=>t instanceof Map,fM=t=>t instanceof Set,DR=t=>typeof t=="object",Qm=t=>typeof t=="function",VT=t=>typeof t=="boolean",yc=t=>t.copy_||t.base_,OR=t=>t.modified_?t.copy_:t.base_;function p3(t,e){if(hM(t))return new Map(t);if(fM(t))return new Set(t);if(dM(t))return Array[uM].slice.call(t);const n=WW(t);if(e===!0||e==="class_only"&&!n){const r=Ns.getOwnPropertyDescriptors(t);delete r[Ia];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],l=r[s];l[m1]===!1&&(l[m1]=!0,l[f3]=!0),(l.get||l.set)&&(r[s]={[f3]:!0,[m1]:!0,[ew]:l[ew],[F0]:t[s]})}return Ns.create(Pp(t),r)}else{const r=Pp(t);if(r!==null&&n)return{...t};const i=Ns.create(r);return Ns.assign(i,t)}}function LR(t,e=!1){return mM(t)||$c(t)||!Go(t)||(Ob(t)>1&&Ns.defineProperties(t,{set:Rv,add:Rv,clear:Rv,delete:Rv}),Ns.freeze(t),e&&Db(t,(n,r)=>{LR(r,!0)},!1)),t}function bme(){Ro(2)}var Rv={[F0]:bme};function mM(t){return t===null||!DR(t)?!0:Ns.isFrozen(t)}var nw="MapSet",g3="Patches",qW={};function jp(t){const e=qW[t];return e||Ro(0,t),e}var yme=t=>!!qW[t],U0,KW=()=>U0,vme=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:yme(nw)?jp(nw):void 0});function Lz(t,e){e&&(t.patchPlugin_=jp(g3),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function x3(t){b3(t),t.drafts_.forEach(_me),t.drafts_=null}function b3(t){t===U0&&(U0=t.parent_)}var Iz=t=>U0=vme(U0,t);function _me(t){const e=t[Ia];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Fz(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Ia].modified_&&(x3(e),Ro(4)),Go(t)&&(t=Uz(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Ia].base_,t,e)}else t=Uz(e,n);return wme(e,t,!0),x3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==GW?t:void 0}function Uz(t,e){if(mM(e))return e;const n=e[Ia];if(!n)return IR(e,t.handledSet_,t);if(!pM(n,t))return e;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(t);ZW(n,t)}return n.copy_}function wme(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&LR(e,n)}function XW(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var pM=(t,e)=>t.scope_===e,Sme=[];function YW(t,e,n,r){const i=yc(t),a=t.type_;if(r!==void 0&&m3(i,r,a)===e){tw(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;Db(i,(c,u)=>{if($c(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const s=t.draftLocations_.get(e)??Sme;for(const l of s)tw(i,l,n,a)}function Mme(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!pM(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const s=OR(a);YW(t,a.draft_??a,s,n),ZW(a,i)})}function ZW(t,e){if(t.modified_&&!t.finalized_&&(t.type_===3||(t.assigned_?.size??0)>0)){const{patchPlugin_:r}=e;if(r){const i=r.getPath(t);i&&r.generatePatches_(t,i,e)}XW(t)}}function Eme(t,e,n){const{scope_:r}=t;if($c(n)){const i=n[Ia];pM(i,r)&&i.callbacks_.push(function(){p1(t);const s=OR(i);YW(t,n,s,e)})}else Go(n)&&t.callbacks_.push(function(){const a=yc(t);m3(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&IR(m3(t.copy_,e,t.type_),r.handledSet_,r)})}function IR(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||$c(t)||e.has(t)||!Go(t)||mM(t)||(e.add(t),Db(t,(r,i)=>{if($c(i)){const a=i[Ia];if(pM(a,n)){const s=OR(a);tw(t,r,s,t.type_),XW(a)}}else Go(i)&&IR(i,e,n)})),t}function Ame(t,e){const n=dM(t),r={type_:n?1:0,scope_:e?e.scope_:KW(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=FR;n&&(i=[r],a=z0);const{revoke:s,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=s,[l,r]}var FR={get(t,e){if(e===Ia)return t;const n=yc(t);if(!Oz(n,e,t.type_))return Tme(t,n,e);const r=n[e];if(t.finalized_||!Go(r))return r;if(r===GT(t.base_,e)){p1(t);const i=t.type_===1?+e:e,a=v3(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in yc(t)},ownKeys(t){return Reflect.ownKeys(yc(t))},set(t,e,n){const r=QW(yc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=GT(yc(t),e),a=i?.[Ia];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(xme(n,i)&&(n!==void 0||Oz(t.base_,e,t.type_)))return!0;p1(t),y3(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_.set(e,!0),Eme(t,e,n)),!0},deleteProperty(t,e){return p1(t),GT(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),y3(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=yc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[m1]:!0,[f3]:t.type_!==1||e!=="length",[ew]:r[ew],[F0]:n[e]}},defineProperty(){Ro(11)},getPrototypeOf(t){return Pp(t.base_)},setPrototypeOf(){Ro(12)}},z0={};Db(FR,(t,e)=>{z0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});z0.deleteProperty=function(t,e){return z0.set.call(this,t,e,void 0)};z0.set=function(t,e,n){return FR.set.call(this,t[0],e,n,t[0])};function GT(t,e){const n=t[Ia];return(n?yc(n):t)[e]}function Tme(t,e,n){const r=QW(e,n);return r?F0 in r?r[F0]:r.get?.call(t.draft_):void 0}function QW(t,e){if(!(e in t))return;let n=Pp(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=Pp(n)}}function y3(t){t.modified_||(t.modified_=!0,t.parent_&&y3(t.parent_))}function p1(t){t.copy_||(t.assigned_=new Map,t.copy_=p3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Nme=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(Qm(n)&&!Qm(r)){const s=r;r=n;const l=this;return function(u=s,...d){return l.produce(u,f=>r.call(this,f,...d))}}Qm(r)||Ro(6),i!==void 0&&!Qm(i)&&Ro(7);let a;if(Go(n)){const s=Iz(this),l=v3(s,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?x3(s):b3(s)}return Lz(s,i),Fz(a,s)}else if(!n||!DR(n)){if(a=r(n),a===void 0&&(a=n),a===GW&&(a=void 0),this.autoFreeze_&&LR(a,!0),i){const s=[],l=[];jp(g3).generateReplacementPatches_(n,a,{patches_:s,inversePatches_:l}),i(s,l)}return a}else Ro(1,n)},this.produceWithPatches=(n,r)=>{if(Qm(n))return(l,...c)=>this.produceWithPatches(l,u=>n(u,...c));let i,a;return[this.produce(n,r,(l,c)=>{i=l,a=c}),i,a]},VT(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),VT(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),VT(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Go(e)||Ro(8),$c(e)&&(e=Ho(e));const n=Iz(this),r=v3(n,e,void 0);return r[Ia].isManual_=!0,b3(n),r}finishDraft(e,n){const r=e&&e[Ia];(!r||!r.isManual_)&&Ro(9);const{scope_:i}=r;return Lz(i,n),Fz(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let r;for(r=n.length-1;r>=0;r--){const a=n[r];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}r>-1&&(n=n.slice(r+1));const i=jp(g3).applyPatches_;return $c(e)?i(e,n):this.produce(e,a=>i(a,n))}};function v3(t,e,n,r){const[i,a]=hM(e)?jp(nw).proxyMap_(e,n):fM(e)?jp(nw).proxySet_(e,n):Ame(e,n);return(n?.scope_??KW()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Mme(n,a,r):a.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:u}=c;a.modified_&&u&&u.generatePatches_(a,[],c)}),i}function Ho(t){return $c(t)||Ro(10,t),JW(t)}function JW(t){if(!Go(t)||mM(t))return t;const e=t[Ia];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=p3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=p3(t,!0);return Db(n,(i,a)=>{tw(n,i,JW(a))},r),e&&(e.finalized_=!1),n}var Cme=new Nme,eq=Cme.produce;function tq(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var kme=tq(),Pme=tq,jme=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?Q1:Q1.apply(null,arguments)};function xo(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(Cs(0));return{type:t,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:t,payload:r[0]}}return n.toString=()=>`${t}`,n.type=t,n.match=r=>VW(r)&&r.type===t,n}var nq=class Wx extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Wx.prototype)}static get[Symbol.species](){return Wx}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Wx(...e[0].concat(this)):new Wx(...e.concat(this))}};function zz(t){return Go(t)?eq(t,()=>{}):t}function Dv(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Rme(t){return typeof t=="boolean"}var Dme=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let s=new nq;return n&&(Rme(n)?s.push(kme):s.push(Pme(n.extraArgument))),s},rq="RTK_autoBatch",Nr=()=>t=>({payload:t,meta:{[rq]:!0}}),Bz=t=>e=>{setTimeout(e,t)},iq=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,a=!1,s=!1;const l=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:Bz(10):t.type==="callback"?t.queueNotification:Bz(t.timeout),u=()=>{s=!1,a&&(a=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),g=r.subscribe(f);return l.add(d),()=>{g(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[rq],a=!i,a&&(s||(s=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},Ome=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new nq(t);return r&&i.push(iq(typeof r=="object"?r:void 0)),i};function Lme(t){const e=Dme(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:s=void 0}=t||{};let l;if(typeof n=="function")l=n;else if(RR(n))l=$W(n);else throw new Error(Cs(1));let c;typeof r=="function"?c=r(e):c=e();let u=Q1;i&&(u=jme({trace:!1,...typeof i=="object"&&i}));const d=pme(...c),f=Ome(d);let g=typeof s=="function"?s(f):f();const p=u(...g);return HW(l,a,p)}function aq(t){const e={},n=[];let r;const i={addCase(a,s){const l=typeof a=="string"?a:a.type;if(!l)throw new Error(Cs(28));if(l in e)throw new Error(Cs(29));return e[l]=s,i},addAsyncThunk(a,s){return s.pending&&(e[a.pending.type]=s.pending),s.rejected&&(e[a.rejected.type]=s.rejected),s.fulfilled&&(e[a.fulfilled.type]=s.fulfilled),s.settled&&n.push({matcher:a.settled,reducer:s.settled}),i},addMatcher(a,s){return n.push({matcher:a,reducer:s}),i},addDefaultCase(a){return r=a,i}};return t(i),[e,n,r]}function Ime(t){return typeof t=="function"}function Fme(t,e){let[n,r,i]=aq(e),a;if(Ime(t))a=()=>zz(t());else{const l=zz(t);a=()=>l}function s(l=a(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if($c(d)){const p=f(d,c);return p===void 0?d:p}else{if(Go(d))return eq(d,g=>f(g,c));{const g=f(d,c);if(g===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return g}}return d},l)}return s.getInitialState=a,s}var Ume="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",zme=(t=21)=>{let e="",n=t;for(;n--;)e+=Ume[Math.random()*64|0];return e},Bme=Symbol.for("rtk-slice-createasyncthunk");function Hme(t,e){return`${t}/${e}`}function $me({creators:t}={}){const e=t?.asyncThunk?.[Bme];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(Cs(11));const s=(typeof r.reducers=="function"?r.reducers(Gme()):r.reducers)||{},l=Object.keys(s),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(w,A){const T=typeof w=="string"?w:w.type;if(!T)throw new Error(Cs(12));if(T in c.sliceCaseReducersByType)throw new Error(Cs(13));return c.sliceCaseReducersByType[T]=A,u},addMatcher(w,A){return c.sliceMatchers.push({matcher:w,reducer:A}),u},exposeAction(w,A){return c.actionCreators[w]=A,u},exposeCaseReducer(w,A){return c.sliceCaseReducersByName[w]=A,u}};l.forEach(w=>{const A=s[w],T={reducerName:w,type:Hme(i,w),createNotation:typeof r.reducers=="function"};qme(A)?Xme(T,A,u,e):Wme(T,A,u)});function d(){const[w={},A=[],T=void 0]=typeof r.extraReducers=="function"?aq(r.extraReducers):[r.extraReducers],C={...w,...c.sliceCaseReducersByType};return Fme(r.initialState,N=>{for(let O in C)N.addCase(O,C[O]);for(let O of c.sliceMatchers)N.addMatcher(O.matcher,O.reducer);for(let O of A)N.addMatcher(O.matcher,O.reducer);T&&N.addDefaultCase(T)})}const f=w=>w,g=new Map,p=new WeakMap;let x;function v(w,A){return x||(x=d()),x(w,A)}function y(){return x||(x=d()),x.getInitialState()}function b(w,A=!1){function T(N){let O=N[w];return typeof O>"u"&&A&&(O=Dv(p,T,y)),O}function C(N=f){const O=Dv(g,A,()=>new WeakMap);return Dv(O,N,()=>{const k={};for(const[j,B]of Object.entries(r.selectors??{}))k[j]=Vme(B,N,()=>Dv(p,N,y),A);return k})}return{reducerPath:w,getSelectors:C,get selectors(){return C(T)},selectSlice:T}}const E={name:i,reducer:v,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:y,...b(a),injectInto(w,{reducerPath:A,...T}={}){const C=A??a;return w.inject({reducerPath:C,reducer:v},T),{...E,...b(C,!0)}}};return E}}function Vme(t,e,n,r){function i(a,...s){let l=e(a);return typeof l>"u"&&r&&(l=n()),t(l,...s)}return i.unwrapped=t,i}var ls=$me();function Gme(){function t(e,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...n}}return t.withTypes=()=>t,{reducer(e){return Object.assign({[e.name](...n){return e(...n)}}[e.name],{_reducerDefinitionType:"reducer"})},preparedReducer(e,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:n}},asyncThunk:t}}function Wme({type:t,reducerName:e,createNotation:n},r,i){let a,s;if("reducer"in r){if(n&&!Kme(r))throw new Error(Cs(17));a=r.reducer,s=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,s?xo(t,s):xo(t))}function qme(t){return t._reducerDefinitionType==="asyncThunk"}function Kme(t){return t._reducerDefinitionType==="reducerWithPrepare"}function Xme({type:t,reducerName:e},n,r,i){if(!i)throw new Error(Cs(18));const{payloadCreator:a,fulfilled:s,pending:l,rejected:c,settled:u,options:d}=n,f=i(t,a,d);r.exposeAction(e,f),s&&r.addCase(f.fulfilled,s),l&&r.addCase(f.pending,l),c&&r.addCase(f.rejected,c),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:s||Ov,pending:l||Ov,rejected:c||Ov,settled:u||Ov})}function Ov(){}var Yme="task",sq="listener",oq="completed",UR="cancelled",Zme=`task-${UR}`,Qme=`task-${oq}`,_3=`${sq}-${UR}`,Jme=`${sq}-${oq}`,gM=class{constructor(t){this.code=t,this.message=`${Yme} ${UR} (reason: ${t})`}name="TaskAbortError";message},zR=(t,e)=>{if(typeof t!="function")throw new TypeError(Cs(32))},rw=()=>{},lq=(t,e=rw)=>(t.catch(e),t),cq=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Lh=(t,e)=>{const n=t.signal;n.aborted||("reason"in n||Object.defineProperty(n,"reason",{enumerable:!0,value:e,configurable:!0,writable:!0}),t.abort(e))},Ih=t=>{if(t.aborted){const{reason:e}=t;throw new gM(e)}};function uq(t,e){let n=rw;return new Promise((r,i)=>{const a=()=>i(new gM(t.reason));if(t.aborted){a();return}n=cq(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=rw})}var epe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof gM?"cancelled":"rejected",error:n}}finally{e?.()}},iw=t=>e=>lq(uq(t,e).then(n=>(Ih(t),n))),dq=t=>{const e=iw(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:hp}=Object,Hz={},xM="listenerMiddleware",tpe=(t,e)=>{const n=r=>cq(t,()=>Lh(r,t.reason));return(r,i)=>{zR(r);const a=new AbortController;n(a);const s=epe(async()=>{Ih(t),Ih(a.signal);const l=await r({pause:iw(a.signal),delay:dq(a.signal),signal:a.signal});return Ih(a.signal),l},()=>Lh(a,Qme));return i?.autoJoin&&e.push(s.catch(rw)),{result:iw(t)(s),cancel(){Lh(a,Zme)}}}},npe=(t,e)=>{const n=async(r,i)=>{Ih(e);let a=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,g)=>{g.unsubscribe(),c([f,g.getState(),g.getOriginalState()])}});a=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await uq(e,Promise.race(l));return Ih(e),c}finally{a()}};return(r,i)=>lq(n(r,i))},hq=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=xo(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Cs(21));return zR(a),{predicate:i,type:e,effect:a}},fq=hp(t=>{const{type:e,predicate:n,effect:r}=hq(t);return{id:zme(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Cs(22))}}},{withTypes:()=>fq}),$z=(t,e)=>{const{type:n,effect:r,predicate:i}=hq(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},w3=t=>{t.pending.forEach(e=>{Lh(e,_3)})},rpe=(t,e)=>()=>{for(const n of e.keys())w3(n);t.clear()},Vz=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},mq=hp(xo(`${xM}/add`),{withTypes:()=>mq}),ipe=xo(`${xM}/removeAll`),pq=hp(xo(`${xM}/remove`),{withTypes:()=>pq}),ape=(...t)=>{console.error(`${xM}/error`,...t)},Lb=(t={})=>{const e=new Map,n=new Map,r=p=>{const x=n.get(p)??0;n.set(p,x+1)},i=p=>{const x=n.get(p)??1;x===1?n.delete(p):n.set(p,x-1)},{extra:a,onError:s=ape}=t;zR(s);const l=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),x=>{p.unsubscribe(),x?.cancelActive&&w3(p)}),c=p=>{const x=$z(e,p)??fq(p);return l(x)};hp(c,{withTypes:()=>c});const u=p=>{const x=$z(e,p);return x&&(x.unsubscribe(),p.cancelActive&&w3(x)),!!x};hp(u,{withTypes:()=>u});const d=async(p,x,v,y)=>{const b=new AbortController,E=npe(c,b.signal),w=[];try{p.pending.add(b),r(p),await Promise.resolve(p.effect(x,hp({},v,{getOriginalState:y,condition:(A,T)=>E(A,T).then(Boolean),take:E,delay:dq(b.signal),pause:iw(b.signal),extra:a,signal:b.signal,fork:tpe(b.signal,w),unsubscribe:p.unsubscribe,subscribe:()=>{e.set(p.id,p)},cancelActiveListeners:()=>{p.pending.forEach((A,T,C)=>{A!==b&&(Lh(A,_3),C.delete(A))})},cancel:()=>{Lh(b,_3),p.pending.delete(b)},throwIfCancelled:()=>{Ih(b.signal)}})))}catch(A){A instanceof gM||Vz(s,A,{raisedBy:"effect"})}finally{await Promise.all(w),Lh(b,Jme),i(p),p.pending.delete(b)}},f=rpe(e,n);return{middleware:p=>x=>v=>{if(!VW(v))return x(v);if(mq.match(v))return c(v.payload);if(ipe.match(v)){f();return}if(pq.match(v))return u(v.payload);let y=p.getState();const b=()=>{if(y===Hz)throw new Error(Cs(23));return y};let E;try{if(E=x(v),e.size>0){const w=p.getState(),A=Array.from(e.values());for(const T of A){let C=!1;try{C=T.predicate(v,w,y)}catch(N){C=!1,Vz(s,N,{raisedBy:"predicate"})}C&&d(T,v,p,b)}}}finally{y=Hz}return E},startListening:c,stopListening:u,clearListeners:f}};function Cs(t){return`Minified Redux Toolkit error #${t}; visit https://redux-toolkit.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var spe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},gq=ls({name:"chartLayout",initialState:spe,reducers:{setLayout(t,e){t.layoutType=e.payload},setChartSize(t,e){t.width=e.payload.width,t.height=e.payload.height},setMargin(t,e){var n,r,i,a;t.margin.top=(n=e.payload.top)!==null&&n!==void 0?n:0,t.margin.right=(r=e.payload.right)!==null&&r!==void 0?r:0,t.margin.bottom=(i=e.payload.bottom)!==null&&i!==void 0?i:0,t.margin.left=(a=e.payload.left)!==null&&a!==void 0?a:0},setScale(t,e){t.scale=e.payload}}}),{setMargin:ope,setLayout:lpe,setChartSize:cpe,setScale:upe}=gq.actions,dpe=gq.reducer;function xq(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function Gz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ap(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Gz(Object(n),!0).forEach(function(r){hpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Gz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hpe(t,e,n){return(e=fpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fpe(t){var e=mpe(t,"string");return typeof e=="symbol"?e:e+""}function mpe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Zn(t,e,n){return Er(t)||Er(e)?n:go(e)?lf(t,e,n):typeof e=="function"?e(t):n}var ppe=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:a,verticalAlign:s,layout:l}=e;if((l==="vertical"||l==="horizontal"&&s==="middle")&&a!=="center"&&Dt(t[a]))return ap(ap({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&s!=="middle"&&Dt(t[s]))return ap(ap({},t),{},{[s]:t[s]+(i||0)})}return t},Rl=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",bq=(t,e,n,r)=>{if(r)return t.map(l=>l.coordinate);var i,a,s=t.map(l=>(l.coordinate===e&&(i=!0),l.coordinate===n&&(a=!0),l.coordinate));return i||s.push(e),a||s.push(n),s},yq=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:a,scale:s,realScaleType:l,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:g,axisType:p}=t;if(!s)return null;var x=l==="scaleBand"&&s.bandwidth?s.bandwidth()/2:2,v=i==="category"&&s.bandwidth?s.bandwidth()/x:0;if(v=p==="angleAxis"&&a&&a.length>=2?Hi(a[0]-a[1])*2*v:v,f||g){var y=(f||g||[]).map((b,E)=>{var w=r?r.indexOf(b):b;return{coordinate:s(w)+v,value:b,offset:v,index:E}});return y.filter(b=>!ss(b.coordinate))}return c&&u?u.map((b,E)=>({coordinate:s(b)+v,value:b,index:E,offset:v})):s.ticks&&d!=null?s.ticks(d).map((b,E)=>({coordinate:s(b)+v,value:b,offset:v,index:E})):s.domain().map((b,E)=>({coordinate:s(b)+v,value:r?r[b]:b,index:E,offset:v}))},Wz=1e-4,gpe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-Wz,a=Math.max(r[0],r[1])+Wz,s=t(e[0]),l=t(e[n-1]);(s<i||s>a||l<i||l>a)&&t.domain([e[0],e[n-1]])}},xpe=(t,e)=>{if(!e||e.length!==2||!Dt(e[0])||!Dt(e[1]))return t;var n=Math.min(e[0],e[1]),r=Math.max(e[0],e[1]),i=[t[0],t[1]];return(!Dt(t[0])||t[0]<n)&&(i[0]=n),(!Dt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},bpe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0,s=0;s<e;++s){var l=ss(t[s][n][1])?t[s][n][0]:t[s][n][1];l>=0?(t[s][n][0]=i,t[s][n][1]=i+l,i=t[s][n][1]):(t[s][n][0]=a,t[s][n][1]=a+l,a=t[s][n][1])}},ype=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0;a<e;++a){var s=ss(t[a][n][1])?t[a][n][0]:t[a][n][1];s>=0?(t[a][n][0]=i,t[a][n][1]=i+s,i=t[a][n][1]):(t[a][n][0]=0,t[a][n][1]=0)}},vpe={sign:bpe,expand:$he,none:kp,silhouette:Vhe,wiggle:Ghe,positive:ype},_pe=(t,e,n)=>{var r=vpe[n],i=Hhe().keys(e).value((a,s)=>Number(Zn(a,s,0))).order(d3).offset(r);return i(t)};function vq(t){return t==null?void 0:String(t)}function aw(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:s}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Er(i[e.dataKey])){var l=SW(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var c=Zn(i,Er(s)?e.dataKey:s);return Er(c)?null:e.scale(c)}var qz=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:a,index:s}=t;if(e.type==="category")return n[s]?n[s].coordinate+r:null;var l=Zn(a,e.dataKey,e.scale.domain()[s]);return Er(l)?null:e.scale(l)-i/2+r},wpe=t=>{var{numericAxis:e}=t,n=e.scale.domain();if(e.type==="number"){var r=Math.min(n[0],n[1]),i=Math.max(n[0],n[1]);return r<=0&&i>=0?0:i<0?i:r}return n[0]},Spe=t=>{var e=t.flat(2).filter(Dt);return[Math.min(...e),Math.max(...e)]},Mpe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],Epe=(t,e,n)=>{if(t!=null)return Mpe(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:s}=a,l=s.reduce((c,u)=>{var d=xq(u,e,n),f=Spe(d);return[Math.min(c[0],f[0]),Math.max(c[1],f[1])]},[1/0,-1/0]);return[Math.min(l[0],r[0]),Math.max(l[1],r[1])]},[1/0,-1/0]))},Kz=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Xz=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,yd=(t,e,n)=>{if(t&&t.scale&&t.scale.bandwidth){var r=t.scale.bandwidth();if(!n||r>0)return r}if(t&&e&&e.length>=2){for(var i=cM(e,d=>d.coordinate),a=1/0,s=1,l=i.length;s<l;s++){var c=i[s],u=i[s-1];a=Math.min((c.coordinate||0)-(u.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function Yz(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return ap(ap({},e),{},{dataKey:n,payload:r,value:i,name:a})}function Pd(t,e){if(t)return String(t);if(typeof e=="string")return e}var Ape=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Tpe=(t,e)=>e==="centric"?t.angle:t.radius,Zc=t=>t.layout.width,Qc=t=>t.layout.height,Npe=t=>t.layout.scale,_q=t=>t.layout.margin,bM=Qe(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),yM=Qe(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),wq="data-recharts-item-index",Sq="data-recharts-item-data-key",Ib=60;function Zz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Lv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Zz(Object(n),!0).forEach(function(r){Cpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Zz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Cpe(t,e,n){return(e=kpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kpe(t){var e=Ppe(t,"string");return typeof e=="symbol"?e:e+""}function Ppe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var jpe=t=>t.brush.height;function Rpe(t){var e=yM(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Ib;return n+i}return n},0)}function Dpe(t){var e=yM(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Ib;return n+i}return n},0)}function Ope(t){var e=bM(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Lpe(t){var e=bM(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var Ei=Qe([Zc,Qc,_q,jpe,Rpe,Dpe,Ope,Lpe,zW,lme],(t,e,n,r,i,a,s,l,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+a},f={top:(n.top||0)+s,bottom:(n.bottom||0)+l},g=Lv(Lv({},f),d),p=g.bottom;g.bottom+=r,g=ppe(g,c,u);var x=t-g.left-g.right,v=e-g.top-g.bottom;return Lv(Lv({brushBottom:p},g),{},{width:Math.max(x,0),height:Math.max(v,0)})}),Ipe=Qe(Ei,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),BR=Qe(Zc,Qc,(t,e)=>({x:0,y:0,width:t,height:e})),Fpe=S.createContext(null),Ai=()=>S.useContext(Fpe)!=null,vM=t=>t.brush,_M=Qe([vM,Ei,_q],(t,e,n)=>({height:t.height,x:Dt(t.x)?t.x:e.left,y:Dt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Dt(t.width)?t.width:e.width})),WT={},qT={},KT={},Qz;function Upe(){return Qz||(Qz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let s,l=null;const c=a!=null&&a.includes("leading"),u=a==null||a.includes("trailing"),d=()=>{l!==null&&(n.apply(s,l),s=void 0,l=null)},f=()=>{u&&d(),v()};let g=null;const p=()=>{g!=null&&clearTimeout(g),g=setTimeout(()=>{g=null,f()},r)},x=()=>{g!==null&&(clearTimeout(g),g=null)},v=()=>{x(),s=void 0,l=null},y=()=>{d()},b=function(...E){if(i?.aborted)return;s=this,l=E;const w=g==null;p(),c&&w&&d()};return b.schedule=p,b.cancel=v,b.flush=y,i?.addEventListener("abort",v,{once:!0}),b}t.debounce=e})(KT)),KT}var Jz;function zpe(){return Jz||(Jz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Upe();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:s=!1,trailing:l=!0,maxWait:c}=a,u=Array(2);s&&(u[0]="leading"),l&&(u[1]="trailing");let d,f=null;const g=e.debounce(function(...v){d=r.apply(this,v),f=null},i,{edges:u}),p=function(...v){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,v),f=Date.now(),g.cancel(),g.schedule(),d):(g.apply(this,v),d)},x=()=>(g.flush(),d);return p.cancel=g.cancel,p.flush=x,p}t.debounce=n})(qT)),qT}var eB;function Bpe(){return eB||(eB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=zpe();function n(r,i=0,a={}){const{leading:s=!0,trailing:l=!0}=a;return e.debounce(r,i,{leading:s,maxWait:i,trailing:l})}t.throttle=n})(WT)),WT}var XT,tB;function Hpe(){return tB||(tB=1,XT=Bpe().throttle),XT}var $pe=Hpe();const Vpe=yo($pe);var sw=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];if(typeof console<"u"&&console.warn&&(n===void 0&&console.warn("LogUtils requires an error message argument"),!e))if(n===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=0;console.warn(n.replace(/%s/g,()=>i[s++]))}},Mq=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:s}=n,l=Hc(r)?t:Number(r),c=Hc(i)?e:Number(i);return a&&a>0&&(l?c=l/a:c&&(l=c*a),s&&c!=null&&c>s&&(c=s)),{calculatedWidth:l,calculatedHeight:c}},Gpe={width:0,height:0,overflow:"visible"},Wpe={width:0,overflowX:"visible"},qpe={height:0,overflowY:"visible"},Kpe={},Xpe=t=>{var{width:e,height:n}=t,r=Hc(e),i=Hc(n);return r&&i?Gpe:r?Wpe:i?qpe:Kpe};function Ype(t){var{width:e,height:n,aspect:r}=t,i=e,a=n;return i===void 0&&a===void 0?(i="100%",a="100%"):i===void 0?i=r&&r>0?void 0:"100%":a===void 0&&(a=r&&r>0?void 0:"100%"),{width:i,height:a}}function Qn(t){return Number.isFinite(t)}function wl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function S3(){return S3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},S3.apply(null,arguments)}function nB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function rB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nB(Object(n),!0).forEach(function(r){Zpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Zpe(t,e,n){return(e=Qpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Qpe(t){var e=Jpe(t,"string");return typeof e=="symbol"?e:e+""}function Jpe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Eq=S.createContext({width:-1,height:-1});function ege(t){return wl(t.width)&&wl(t.height)}function Aq(t){var{children:e,width:n,height:r}=t,i=S.useMemo(()=>({width:n,height:r}),[n,r]);return ege(i)?S.createElement(Eq.Provider,{value:i},e):null}var HR=()=>S.useContext(Eq),tge=S.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:a,minWidth:s=0,minHeight:l,maxHeight:c,children:u,debounce:d=0,id:f,className:g,onResize:p,style:x={}}=t,v=S.useRef(null),y=S.useRef();y.current=p,S.useImperativeHandle(e,()=>v.current);var[b,E]=S.useState({containerWidth:r.width,containerHeight:r.height}),w=S.useCallback((O,k)=>{E(j=>{var B=Math.round(O),L=Math.round(k);return j.containerWidth===B&&j.containerHeight===L?j:{containerWidth:B,containerHeight:L}})},[]);S.useEffect(()=>{if(v.current==null||typeof ResizeObserver>"u")return jb;var O=L=>{var K,{width:R,height:q}=L[0].contentRect;w(R,q),(K=y.current)===null||K===void 0||K.call(y,R,q)};d>0&&(O=Vpe(O,d,{trailing:!0,leading:!1}));var k=new ResizeObserver(O),{width:j,height:B}=v.current.getBoundingClientRect();return w(j,B),k.observe(v.current),()=>{k.disconnect()}},[w,d]);var{containerWidth:A,containerHeight:T}=b;sw(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:C,calculatedHeight:N}=Mq(A,T,{width:i,height:a,aspect:n,maxHeight:c});return sw(C!=null&&C>0||N!=null&&N>0,`The width(%s) and height(%s) of chart should be greater than 0,
- please check the style of container, or the props width(%s) and height(%s),
- or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
- height and width.`,C,N,i,a,s,l,n),S.createElement("div",{id:f?"".concat(f):void 0,className:Pn("recharts-responsive-container",g),style:rB(rB({},x),{},{width:i,height:a,minWidth:s,minHeight:l,maxHeight:c}),ref:v},S.createElement("div",{style:Xpe({width:i,height:a})},S.createElement(Aq,{width:C,height:N},u)))}),g1=S.forwardRef((t,e)=>{var n=HR();if(wl(n.width)&&wl(n.height))return t.children;var{width:r,height:i}=Ype({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:s}=Mq(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Dt(a)&&Dt(s)?S.createElement(Aq,{width:a,height:s},t.children):S.createElement(tge,S3({},t,{width:r,height:i,ref:e}))});function Tq(t){if(t)return{x:t.x,y:t.y,upperWidth:"upperWidth"in t?t.upperWidth:t.width,lowerWidth:"lowerWidth"in t?t.lowerWidth:t.width,width:t.width,height:t.height}}var Fb=()=>{var t,e=Ai(),n=jt(Ipe),r=jt(_M),i=(t=jt(vM))===null||t===void 0?void 0:t.padding;return!e||!r||!i?n:{width:r.width-i.left-i.right,height:r.height-i.top-i.bottom,x:i.left,y:i.top}},nge={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},Nq=()=>{var t;return(t=jt(Ei))!==null&&t!==void 0?t:nge},$R=()=>jt(Zc),VR=()=>jt(Qc),rge=()=>jt(t=>t.layout.margin),Sn=t=>t.layout.layoutType,Ef=()=>jt(Sn),ige=()=>{var t=Ef();if(t==="horizontal"||t==="vertical")return t},age=()=>{var t=Ef();return t!==void 0},wM=t=>{var e=gr(),n=Ai(),{width:r,height:i}=t,a=HR(),s=r,l=i;return a&&(s=a.width>0?a.width:r,l=a.height>0?a.height:i),S.useEffect(()=>{!n&&wl(s)&&wl(l)&&e(cpe({width:s,height:l}))},[e,n,s,l]),null},Cq=Symbol.for("immer-nothing"),iB=Symbol.for("immer-draftable"),Rs=Symbol.for("immer-state");function Do(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var B0=Object.getPrototypeOf;function Rp(t){return!!t&&!!t[Rs]}function cf(t){return t?kq(t)||Array.isArray(t)||!!t[iB]||!!t.constructor?.[iB]||Ub(t)||MM(t):!1}var sge=Object.prototype.constructor.toString(),aB=new WeakMap;function kq(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);if(e===null||e===Object.prototype)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=aB.get(n);return r===void 0&&(r=Function.toString.call(n),aB.set(n,r)),r===sge}function ow(t,e,n=!0){SM(t)===0?(n?Reflect.ownKeys(t):Object.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function SM(t){const e=t[Rs];return e?e.type_:Array.isArray(t)?1:Ub(t)?2:MM(t)?3:0}function M3(t,e){return SM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Pq(t,e,n){const r=SM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function oge(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Ub(t){return t instanceof Map}function MM(t){return t instanceof Set}function ph(t){return t.copy_||t.base_}function E3(t,e){if(Ub(t))return new Map(t);if(MM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=kq(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Rs];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],l=r[s];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(r[s]={configurable:!0,writable:!0,enumerable:l.enumerable,value:t[s]})}return Object.create(B0(t),r)}else{const r=B0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function GR(t,e=!1){return EM(t)||Rp(t)||!cf(t)||(SM(t)>1&&Object.defineProperties(t,{set:Iv,add:Iv,clear:Iv,delete:Iv}),Object.freeze(t),e&&Object.values(t).forEach(n=>GR(n,!0))),t}function lge(){Do(2)}var Iv={value:lge};function EM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var cge={};function uf(t){const e=cge[t];return e||Do(0,t),e}var H0;function jq(){return H0}function uge(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function sB(t,e){e&&(uf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function A3(t){T3(t),t.drafts_.forEach(dge),t.drafts_=null}function T3(t){t===H0&&(H0=t.parent_)}function oB(t){return H0=uge(H0,t)}function dge(t){const e=t[Rs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function lB(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Rs].modified_&&(A3(e),Do(4)),cf(t)&&(t=lw(e,t),e.parent_||cw(e,t)),e.patches_&&uf("Patches").generateReplacementPatches_(n[Rs].base_,t,e.patches_,e.inversePatches_)):t=lw(e,n,[]),A3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==Cq?t:void 0}function lw(t,e,n){if(EM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Rs];if(!i)return ow(e,(a,s)=>cB(t,i,e,a,s,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return cw(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const a=i.copy_;let s=a,l=!1;i.type_===3&&(s=new Set(a),a.clear(),l=!0),ow(s,(c,u)=>cB(t,i,a,c,u,n,l),r),cw(t,a,!1),n&&t.patches_&&uf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function cB(t,e,n,r,i,a,s){if(i==null||typeof i!="object"&&!s)return;const l=EM(i);if(!(l&&!s)){if(Rp(i)){const c=a&&e&&e.type_!==3&&!M3(e.assigned_,r)?a.concat(r):void 0,u=lw(t,i,c);if(Pq(n,r,u),Rp(u))t.canAutoFreeze_=!1;else return}else s&&n.add(i);if(cf(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;lw(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Ub(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&cw(t,i)}}}function cw(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&GR(e,n)}function hge(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:jq(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=WR;n&&(i=[r],a=$0);const{revoke:s,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=s,l}var WR={get(t,e){if(e===Rs)return t;const n=ph(t);if(!M3(n,e))return fge(t,n,e);const r=n[e];return t.finalized_||!cf(r)?r:r===YT(t.base_,e)?(ZT(t),t.copy_[e]=C3(r,t)):r},has(t,e){return e in ph(t)},ownKeys(t){return Reflect.ownKeys(ph(t))},set(t,e,n){const r=Rq(ph(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=YT(ph(t),e),a=i?.[Rs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(oge(n,i)&&(n!==void 0||M3(t.base_,e)))return!0;ZT(t),N3(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_[e]=!0),!0},deleteProperty(t,e){return YT(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,ZT(t),N3(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=ph(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Do(11)},getPrototypeOf(t){return B0(t.base_)},setPrototypeOf(){Do(12)}},$0={};ow(WR,(t,e)=>{$0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});$0.deleteProperty=function(t,e){return $0.set.call(this,t,e,void 0)};$0.set=function(t,e,n){return WR.set.call(this,t[0],e,n,t[0])};function YT(t,e){const n=t[Rs];return(n?ph(n):t)[e]}function fge(t,e,n){const r=Rq(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function Rq(t,e){if(!(e in t))return;let n=B0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=B0(n)}}function N3(t){t.modified_||(t.modified_=!0,t.parent_&&N3(t.parent_))}function ZT(t){t.copy_||(t.copy_=E3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var mge=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const a=n;n=e;const s=this;return function(c=a,...u){return s.produce(c,d=>n.call(this,d,...u))}}typeof n!="function"&&Do(6),r!==void 0&&typeof r!="function"&&Do(7);let i;if(cf(e)){const a=oB(this),s=C3(e,void 0);let l=!0;try{i=n(s),l=!1}finally{l?A3(a):T3(a)}return sB(a,r),lB(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===Cq&&(i=void 0),this.autoFreeze_&&GR(i,!0),r){const a=[],s=[];uf("Patches").generateReplacementPatches_(e,i,a,s),r(a,s)}return i}else Do(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(s,...l)=>this.produceWithPatches(s,c=>e(c,...l));let r,i;return[this.produce(e,n,(s,l)=>{r=s,i=l}),r,i]},typeof t?.autoFreeze=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof t?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),typeof t?.useStrictIteration=="boolean"&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){cf(t)||Do(8),Rp(t)&&(t=pge(t));const e=oB(this),n=C3(t,void 0);return n[Rs].isManual_=!0,T3(e),n}finishDraft(t,e){const n=t&&t[Rs];(!n||!n.isManual_)&&Do(9);const{scope_:r}=n;return sB(r,e),lB(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const i=e[n];if(i.path.length===0&&i.op==="replace"){t=i.value;break}}n>-1&&(e=e.slice(n+1));const r=uf("Patches").applyPatches_;return Rp(t)?r(t,e):this.produce(t,i=>r(i,e))}};function C3(t,e){const n=Ub(t)?uf("MapSet").proxyMap_(t,e):MM(t)?uf("MapSet").proxySet_(t,e):hge(t,e);return(e?e.scope_:jq()).drafts_.push(n),n}function pge(t){return Rp(t)||Do(10,t),Dq(t)}function Dq(t){if(!cf(t)||EM(t))return t;const e=t[Rs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=E3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=E3(t,!0);return ow(n,(i,a)=>{Pq(n,i,Dq(a))},r),e&&(e.finalized_=!1),n}var gge=new mge;gge.produce;var xge={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},Oq=ls({name:"legend",initialState:xge,reducers:{setLegendSize(t,e){t.size.width=e.payload.width,t.size.height=e.payload.height},setLegendSettings(t,e){t.settings.align=e.payload.align,t.settings.layout=e.payload.layout,t.settings.verticalAlign=e.payload.verticalAlign,t.settings.itemSorter=e.payload.itemSorter},addLegendPayload:{reducer(t,e){t.payload.push(e.payload)},prepare:Nr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ho(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Nr()},removeLegendPayload:{reducer(t,e){var n=Ho(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Nr()}}}),{setLegendSize:uB,setLegendSettings:bge,addLegendPayload:Lq,replaceLegendPayload:Iq,removeLegendPayload:Fq}=Oq.actions,yge=Oq.reducer,vge=["contextPayload"];function k3(){return k3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},k3.apply(null,arguments)}function dB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Dp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?dB(Object(n),!0).forEach(function(r){_ge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):dB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _ge(t,e,n){return(e=wge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wge(t){var e=Sge(t,"string");return typeof e=="symbol"?e:e+""}function Sge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Mge(t,e){if(t==null)return{};var n,r,i=Ege(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Ege(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Age(t){return t.value}function Tge(t){var{contextPayload:e}=t,n=Mge(t,vge),r=OW(e,t.payloadUniqBy,Age),i=Dp(Dp({},n),{},{payload:r});return S.isValidElement(t.content)?S.cloneElement(t.content,i):typeof t.content=="function"?S.createElement(t.content,i):S.createElement(vfe,i)}function Nge(t,e,n,r,i,a){var{layout:s,align:l,verticalAlign:c}=e,u,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(l==="center"&&s==="vertical"?u={left:((r||0)-a.width)/2}:u=l==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(c==="middle"?d={top:((i||0)-a.height)/2}:d=c==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),Dp(Dp({},u),d)}function Cge(t){var e=gr();return S.useEffect(()=>{e(bge(t))},[e,t]),null}function kge(t){var e=gr();return S.useEffect(()=>(e(uB(t)),()=>{e(uB({width:0,height:0}))}),[e,t]),null}function Pge(t,e,n,r){return t==="vertical"&&Dt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var jge={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function qR(t){var e=Lr(t,jge),n=dme(),r=hhe(),i=rge(),{width:a,height:s,wrapperStyle:l,portal:c}=e,[u,d]=BW([n]),f=$R(),g=VR();if(f==null||g==null)return null;var p=f-(i?.left||0)-(i?.right||0),x=Pge(e.layout,s,a,p),v=c?l:Dp(Dp({position:"absolute",width:x?.width||a||"auto",height:x?.height||s||"auto"},Nge(l,e,i,f,g,u)),l),y=c??r;if(y==null||n==null)return null;var b=S.createElement("div",{className:"recharts-legend-wrapper",style:v,ref:d},S.createElement(Cge,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&S.createElement(kge,{width:u.width,height:u.height}),S.createElement(Tge,k3({},e,x,{margin:i,chartWidth:f,chartHeight:g,contextPayload:n})));return Mc.createPortal(b,y)}qR.displayName="Legend";function P3(){return P3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},P3.apply(null,arguments)}function hB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function QT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?hB(Object(n),!0).forEach(function(r){Rge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):hB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Rge(t,e,n){return(e=Dge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Dge(t){var e=Oge(t,"string");return typeof e=="symbol"?e:e+""}function Oge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Lge(t){return Array.isArray(t)&&go(t[0])&&go(t[1])?t.join(" ~ "):t}var Ige=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:a,formatter:s,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:g=!1}=t,p=()=>{if(a&&a.length){var T={padding:0,margin:0},C=(l?cM(a,l):a).map((N,O)=>{if(N.type==="none")return null;var k=N.formatter||s||Lge,{value:j,name:B}=N,L=j,K=B;if(k){var R=k(j,B,N,O,a);if(Array.isArray(R))[L,K]=R;else if(R!=null)L=R;else return null}var q=QT({display:"block",paddingTop:4,paddingBottom:4,color:N.color||"#000"},r);return S.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(O),style:q},go(K)?S.createElement("span",{className:"recharts-tooltip-item-name"},K):null,go(K)?S.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,S.createElement("span",{className:"recharts-tooltip-item-value"},L),S.createElement("span",{className:"recharts-tooltip-item-unit"},N.unit||""))});return S.createElement("ul",{className:"recharts-tooltip-item-list",style:T},C)}return null},x=QT({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),v=QT({margin:0},i),y=!Er(d),b=y?d:"",E=Pn("recharts-default-tooltip",c),w=Pn("recharts-tooltip-label",u);y&&f&&a!==void 0&&a!==null&&(b=f(d,a));var A=g?{role:"status","aria-live":"assertive"}:{};return S.createElement("div",P3({className:E,style:x},A),S.createElement("p",{className:w,style:v},S.isValidElement(b)?b:"".concat(b)),p())},vx="recharts-tooltip-wrapper",Fge={visibility:"hidden"};function Uge(t){var{coordinate:e,translateX:n,translateY:r}=t;return Pn(vx,{["".concat(vx,"-right")]:Dt(n)&&e&&Dt(e.x)&&n>=e.x,["".concat(vx,"-left")]:Dt(n)&&e&&Dt(e.x)&&n<e.x,["".concat(vx,"-bottom")]:Dt(r)&&e&&Dt(e.y)&&r>=e.y,["".concat(vx,"-top")]:Dt(r)&&e&&Dt(e.y)&&r<e.y})}function fB(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:s,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&Dt(a[r]))return a[r];var d=n[r]-l-(i>0?i:0),f=n[r]+i;if(e[r])return s[r]?d:f;var g=c[r];if(g==null)return 0;if(s[r]){var p=d,x=g;return p<x?Math.max(f,g):Math.max(d,g)}if(u==null)return 0;var v=f+l,y=g+u;return v>y?Math.max(d,g):Math.max(f,g)}function zge(t){var{translateX:e,translateY:n,useTranslate3d:r}=t;return{transform:r?"translate3d(".concat(e,"px, ").concat(n,"px, 0)"):"translate(".concat(e,"px, ").concat(n,"px)")}}function Bge(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:a,tooltipBox:s,useTranslate3d:l,viewBox:c}=t,u,d,f;return s.height>0&&s.width>0&&n?(d=fB({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.width,viewBox:c,viewBoxDimension:c.width}),f=fB({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.height,viewBox:c,viewBoxDimension:c.height}),u=zge({translateX:d,translateY:f,useTranslate3d:l})):u=Fge,{cssProperties:u,cssClasses:Uge({translateX:d,translateY:f,coordinate:n})}}function mB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Fv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mB(Object(n),!0).forEach(function(r){j3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function j3(t,e,n){return(e=Hge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Hge(t){var e=$ge(t,"string");return typeof e=="symbol"?e:e+""}function $ge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class Vge extends S.PureComponent{constructor(){super(...arguments),j3(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),j3(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,a;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var e,n;this.state.dismissed&&(((e=this.props.coordinate)===null||e===void 0?void 0:e.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:a,coordinate:s,hasPayload:l,isAnimationActive:c,offset:u,position:d,reverseDirection:f,useTranslate3d:g,viewBox:p,wrapperStyle:x,lastBoundingBox:v,innerRef:y,hasPortalFromProps:b}=this.props,{cssClasses:E,cssProperties:w}=Bge({allowEscapeViewBox:n,coordinate:s,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:v.height,width:v.width},useTranslate3d:g,viewBox:p}),A=b?{}:Fv(Fv({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},w),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),T=Fv(Fv({},A),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},x);return S.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:E,style:T,ref:y},a)}}var Uq=()=>{var t;return(t=jt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function R3(){return R3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},R3.apply(null,arguments)}function pB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function gB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?pB(Object(n),!0).forEach(function(r){Gge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):pB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Gge(t,e,n){return(e=Wge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Wge(t){var e=qge(t,"string");return typeof e=="symbol"?e:e+""}function qge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var xB={curveBasisClosed:Phe,curveBasisOpen:jhe,curveBasis:khe,curveBumpX:ghe,curveBumpY:xhe,curveLinearClosed:Rhe,curveLinear:oM,curveMonotoneX:Dhe,curveMonotoneY:Ohe,curveNatural:Lhe,curveStep:Ihe,curveStepAfter:Uhe,curveStepBefore:Fhe},uw=t=>Qn(t.x)&&Qn(t.y),bB=t=>t.base!=null&&uw(t.base)&&uw(t),_x=t=>t.x,wx=t=>t.y,Kge=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Pb(t));return(n==="curveMonotone"||n==="curveBump")&&e?xB["".concat(n).concat(e==="vertical"?"Y":"X")]:xB[n]||oM},Xge=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,s=Kge(e,i),l=a?n.filter(uw):n,c;if(Array.isArray(r)){var u=n.map((p,x)=>gB(gB({},p),{},{base:r[x]}));i==="vertical"?c=kv().y(wx).x1(_x).x0(p=>p.base.x):c=kv().x(_x).y1(wx).y0(p=>p.base.y);var d=c.defined(bB).curve(s),f=a?u.filter(bB):u;return d(f)}i==="vertical"&&Dt(r)?c=kv().y(wx).x1(_x).x0(r):Dt(r)?c=kv().x(_x).y1(wx).y0(r):c=uW().x(_x).y(wx);var g=c.defined(uw).curve(s);return g(l)},fp=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?Xge(t):r;return S.createElement("path",R3({},La(t),kR(t),{className:Pn("recharts-curve",e),d:a===null?void 0:a,ref:i}))},Yge=["x","y","top","left","width","height","className"];function D3(){return D3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},D3.apply(null,arguments)}function yB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Zge(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yB(Object(n),!0).forEach(function(r){Qge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Qge(t,e,n){return(e=Jge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Jge(t){var e=exe(t,"string");return typeof e=="symbol"?e:e+""}function exe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function txe(t,e){if(t==null)return{};var n,r,i=nxe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function nxe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var rxe=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),ixe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:s=0,className:l}=t,c=txe(t,Yge),u=Zge({x:e,y:n,top:r,left:i,width:a,height:s},c);return!Dt(e)||!Dt(n)||!Dt(a)||!Dt(s)||!Dt(r)||!Dt(i)?null:S.createElement("path",D3({},ua(u),{className:Pn("recharts-cross",l),d:rxe(e,n,a,s,r,i)}))};function axe(t,e,n,r){var i=r/2;return{stroke:"none",fill:"#ccc",x:t==="horizontal"?e.x-i:n.left+.5,y:t==="horizontal"?n.top+.5:e.y-i,width:t==="horizontal"?r:n.width-1,height:t==="horizontal"?n.height-1:r}}function vB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _B(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vB(Object(n),!0).forEach(function(r){sxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function sxe(t,e,n){return(e=oxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oxe(t){var e=lxe(t,"string");return typeof e=="symbol"?e:e+""}function lxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var cxe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),zq=(t,e,n)=>t.map(r=>"".concat(cxe(r)," ").concat(e,"ms ").concat(n)).join(","),uxe=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),V0=(t,e)=>Object.keys(e).reduce((n,r)=>_B(_B({},n),{},{[r]:t(r,e[r])}),{});function wB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function bi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?wB(Object(n),!0).forEach(function(r){dxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dxe(t,e,n){return(e=hxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hxe(t){var e=fxe(t,"string");return typeof e=="symbol"?e:e+""}function fxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var dw=(t,e,n)=>t+(e-t)*n,O3=t=>{var{from:e,to:n}=t;return e!==n},Bq=(t,e,n)=>{var r=V0((i,a)=>{if(O3(a)){var[s,l]=t(a.from,a.to,a.velocity);return bi(bi({},a),{},{from:s,velocity:l})}return a},e);return n<1?V0((i,a)=>O3(a)?bi(bi({},a),{},{velocity:dw(a.velocity,r[i].velocity,n),from:dw(a.from,r[i].from,n)}):a,e):Bq(t,r,n-1)};function mxe(t,e,n,r,i,a){var s,l=r.reduce((g,p)=>bi(bi({},g),{},{[p]:{from:t[p],velocity:0,to:e[p]}}),{}),c=()=>V0((g,p)=>p.from,l),u=()=>!Object.values(l).filter(O3).length,d=null,f=g=>{s||(s=g);var p=g-s,x=p/n.dt;l=Bq(n,l,x),i(bi(bi(bi({},t),e),c())),s=g,u()||(d=a.setTimeout(f))};return()=>(d=a.setTimeout(f),()=>{var g;(g=d)===null||g===void 0||g()})}function pxe(t,e,n,r,i,a,s){var l=null,c=i.reduce((f,g)=>bi(bi({},f),{},{[g]:[t[g],e[g]]}),{}),u,d=f=>{u||(u=f);var g=(f-u)/r,p=V0((v,y)=>dw(...y,n(g)),c);if(a(bi(bi(bi({},t),e),p)),g<1)l=s.setTimeout(d);else{var x=V0((v,y)=>dw(...y,n(1)),c);a(bi(bi(bi({},t),e),x))}};return()=>(l=s.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const gxe=(t,e,n,r,i,a)=>{var s=uxe(t,e);return n==null?()=>(i(bi(bi({},t),e)),()=>{}):n.isStepper===!0?mxe(t,e,n,s,i,a):pxe(t,e,n,r,s,i,a)};var hw=1e-4,Hq=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],$q=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),SB=(t,e)=>n=>{var r=Hq(t,e);return $q(r,n)},xxe=(t,e)=>n=>{var r=Hq(t,e),i=[...r.map((a,s)=>a*s).slice(1),0];return $q(i,n)},bxe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(n.length===1)switch(n[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var i,a=n[0].split("(");if(a[0]==="cubic-bezier"&&((i=a[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var s=a[1].split(")")[0].split(",").map(l=>parseFloat(l));return[s[0],s[1],s[2],s[3]]}}}return n.length===4?n:[0,0,1,1]},yxe=(t,e,n,r)=>{var i=SB(t,n),a=SB(e,r),s=xxe(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,g=0;g<8;++g){var p=i(f)-d,x=s(f);if(Math.abs(p-d)<hw||x<hw)return a(f);f=l(f-p/x)}return a(f)};return c.isStepper=!1,c},MB=function(){return yxe(...bxe(...arguments))},vxe=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,a=(s,l,c)=>{var u=-(s-l)*n,d=c*r,f=c+(u-d)*i/1e3,g=c*i/1e3+s;return Math.abs(g-l)<hw&&Math.abs(f)<hw?[l,0]:[g,f]};return a.isStepper=!0,a.dt=i,a},_xe=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return MB(t);case"spring":return vxe();default:if(t.split("(")[0]==="cubic-bezier")return MB(t)}return typeof t=="function"?t:null};function wxe(t){var e,n=()=>null,r=!1,i=null,a=s=>{if(!r){if(Array.isArray(s)){if(!s.length)return;var l=s,[c,...u]=l;if(typeof c=="number"){i=t.setTimeout(a.bind(null,u),c);return}a(c),i=t.setTimeout(a.bind(null,u));return}typeof s=="string"&&(e=s,n(e)),typeof s=="object"&&(e=s,n(e)),typeof s=="function"&&s()}};return{stop:()=>{r=!0},start:s=>{r=!1,i&&(i(),i=null),a(s)},subscribe:s=>(n=s,()=>{n=()=>null}),getTimeoutController:()=>t}}class Sxe{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,a=s=>{s-r>=n?e(s):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(a))};return i=requestAnimationFrame(a),()=>{i!=null&&cancelAnimationFrame(i)}}}function Mxe(){return wxe(new Sxe)}var Exe=S.createContext(Mxe);function Axe(t,e){var n=S.useContext(Exe);return S.useMemo(()=>e??n(t),[t,e,n])}var Txe=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),lg={devToolsEnabled:!1,isSsr:Txe()},Nxe={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},EB={t:0},JT={t:1};function cg(t){var e=Lr(t,Nxe),{isActive:n,canBegin:r,duration:i,easing:a,begin:s,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!lg.isSsr:n,f=Axe(e.animationId,e.animationManager),[g,p]=S.useState(d?EB:JT),x=S.useRef(null);return S.useEffect(()=>{d||p(JT)},[d]),S.useEffect(()=>{if(!d||!r)return jb;var v=gxe(EB,JT,_xe(a),i,p,f.getTimeoutController()),y=()=>{x.current=v()};return f.start([c,s,y,i,l]),()=>{f.stop(),x.current&&x.current(),l()}},[d,r,i,a,s,c,l,f]),u(g.t)}function ug(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=S.useRef(I0(e)),r=S.useRef(t);return r.current!==t&&(n.current=I0(e),r.current=t),n.current}var Cxe=["radius"],kxe=["radius"];function AB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function TB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?AB(Object(n),!0).forEach(function(r){Pxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):AB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Pxe(t,e,n){return(e=jxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function jxe(t){var e=Rxe(t,"string");return typeof e=="symbol"?e:e+""}function Rxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function fw(){return fw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},fw.apply(null,arguments)}function NB(t,e){if(t==null)return{};var n,r,i=Dxe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Dxe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var CB=(t,e,n,r,i)=>{var a=Math.min(Math.abs(n)/2,Math.abs(r)/2),s=r>=0?1:-1,l=n>=0?1:-1,c=r>=0&&n>=0||r<0&&n<0?1:0,u;if(a>0&&i instanceof Array){for(var d=[0,0,0,0],f=0,g=4;f<g;f++)d[f]=i[f]>a?a:i[f];u="M".concat(t,",").concat(e+s*d[0]),d[0]>0&&(u+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(c,",").concat(t+l*d[0],",").concat(e)),u+="L ".concat(t+n-l*d[1],",").concat(e),d[1]>0&&(u+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(c,`,
- `).concat(t+n,",").concat(e+s*d[1])),u+="L ".concat(t+n,",").concat(e+r-s*d[2]),d[2]>0&&(u+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(c,`,
- `).concat(t+n-l*d[2],",").concat(e+r)),u+="L ".concat(t+l*d[3],",").concat(e+r),d[3]>0&&(u+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(c,`,
- `).concat(t,",").concat(e+r-s*d[3])),u+="Z"}else if(a>0&&i===+i&&i>0){var p=Math.min(a,i);u="M ".concat(t,",").concat(e+s*p,`
- A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+l*p,",").concat(e,`
- L `).concat(t+n-l*p,",").concat(e,`
- A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n,",").concat(e+s*p,`
- L `).concat(t+n,",").concat(e+r-s*p,`
- A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n-l*p,",").concat(e+r,`
- L `).concat(t+l*p,",").concat(e+r,`
- A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t,",").concat(e+r-s*p," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},kB={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Vq=t=>{var e=Lr(t,kB),n=S.useRef(null),[r,i]=S.useState(-1);S.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var $=n.current.getTotalLength();$&&i($)}catch{}},[]);var{x:a,y:s,width:l,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:g,animationBegin:p,isAnimationActive:x,isUpdateAnimationActive:v}=e,y=S.useRef(l),b=S.useRef(c),E=S.useRef(a),w=S.useRef(s),A=S.useMemo(()=>({x:a,y:s,width:l,height:c,radius:u}),[a,s,l,c,u]),T=ug(A,"rectangle-");if(a!==+a||s!==+s||l!==+l||c!==+c||l===0||c===0)return null;var C=Pn("recharts-rectangle",d);if(!v){var N=ua(e),{radius:O}=N,k=NB(N,Cxe);return S.createElement("path",fw({},k,{radius:typeof u=="number"?u:void 0,className:C,d:CB(a,s,l,c,u)}))}var j=y.current,B=b.current,L=E.current,K=w.current,R="0px ".concat(r===-1?1:r,"px"),q="".concat(r,"px 0px"),W=zq(["strokeDasharray"],g,typeof f=="string"?f:kB.animationEasing);return S.createElement(cg,{animationId:T,key:T,canBegin:r>0,duration:g,easing:f,isActive:v,begin:p},$=>{var J=Vn(j,l,$),ee=Vn(B,c,$),Q=Vn(L,a,$),z=Vn(K,s,$);n.current&&(y.current=J,b.current=ee,E.current=Q,w.current=z);var V;x?$>0?V={transition:W,strokeDasharray:q}:V={strokeDasharray:R}:V={strokeDasharray:q};var X=ua(e),{radius:te}=X,ie=NB(X,kxe);return S.createElement("path",fw({},ie,{radius:typeof u=="number"?u:void 0,className:C,d:CB(Q,z,J,ee,u),ref:n,style:TB(TB({},V),e.style)}))})};function PB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function jB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?PB(Object(n),!0).forEach(function(r){Oxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):PB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Oxe(t,e,n){return(e=Lxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Lxe(t){var e=Ixe(t,"string");return typeof e=="symbol"?e:e+""}function Ixe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var mw=Math.PI/180,Fxe=t=>t*180/Math.PI,ui=(t,e,n,r)=>({x:t+Math.cos(-mw*r)*n,y:e+Math.sin(-mw*r)*n}),Gq=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(e-(r.left||0)-(r.right||0)),Math.abs(n-(r.top||0)-(r.bottom||0)))/2},Uxe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},zxe=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,s=Uxe({x:n,y:r},{x:i,y:a});if(s<=0)return{radius:s,angle:0};var l=(n-i)/s,c=Math.acos(l);return r>a&&(c=2*Math.PI-c),{radius:s,angle:Fxe(c),angleInRadian:c}},Bxe=t=>{var{startAngle:e,endAngle:n}=t,r=Math.floor(e/360),i=Math.floor(n/360),a=Math.min(r,i);return{startAngle:e-a*360,endAngle:n-a*360}},Hxe=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),a=Math.floor(r/360),s=Math.min(i,a);return t+s*360},$xe=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=zxe({x:n,y:r},e),{innerRadius:s,outerRadius:l}=e;if(i<s||i>l||i===0)return null;var{startAngle:c,endAngle:u}=Bxe(e),d=a,f;if(c<=u){for(;d>u;)d-=360;for(;d<c;)d+=360;f=d>=c&&d<=u}else{for(;d>c;)d-=360;for(;d<u;)d+=360;f=d>=u&&d<=c}return f?jB(jB({},e),{},{radius:i,angle:Hxe(d,e)}):null};function Wq(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,s=ui(e,n,r,i),l=ui(e,n,r,a);return{points:[s,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}function L3(){return L3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},L3.apply(null,arguments)}var Vxe=(t,e)=>{var n=Hi(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},Uv=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:a,isExternal:s,cornerRadius:l,cornerIsExternal:c}=t,u=l*(s?1:-1)+r,d=Math.asin(l/u)/mw,f=c?i:i+a*d,g=ui(e,n,u,f),p=ui(e,n,r,f),x=c?i-a*d:i,v=ui(e,n,u*Math.cos(d*mw),x);return{center:g,circleTangency:p,lineTangency:v,theta:d}},qq=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:s}=t,l=Vxe(a,s),c=a+l,u=ui(e,n,i,a),d=ui(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
- A `).concat(i,",").concat(i,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(a>c),`,
- `).concat(d.x,",").concat(d.y,`
- `);if(r>0){var g=ui(e,n,r,a),p=ui(e,n,r,c);f+="L ".concat(p.x,",").concat(p.y,`
- A `).concat(r,",").concat(r,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(a<=c),`,
- `).concat(g.x,",").concat(g.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},Gxe=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:s,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=Hi(u-c),{circleTangency:f,lineTangency:g,theta:p}=Uv({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:x,lineTangency:v,theta:y}=Uv({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:l}),b=l?Math.abs(c-u):Math.abs(c-u)-p-y;if(b<0)return s?"M ".concat(g.x,",").concat(g.y,`
- a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
- a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
- `):qq({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var E="M ".concat(g.x,",").concat(g.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
- A`).concat(i,",").concat(i,",0,").concat(+(b>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(v.x,",").concat(v.y,`
- `);if(r>0){var{circleTangency:w,lineTangency:A,theta:T}=Uv({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:C,lineTangency:N,theta:O}=Uv({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),k=l?Math.abs(c-u):Math.abs(c-u)-T-O;if(k<0&&a===0)return"".concat(E,"L").concat(e,",").concat(n,"Z");E+="L".concat(N.x,",").concat(N.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(C.x,",").concat(C.y,`
- A`).concat(r,",").concat(r,",0,").concat(+(k>180),",").concat(+(d>0),",").concat(w.x,",").concat(w.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(A.x,",").concat(A.y,"Z")}else E+="L".concat(e,",").concat(n,"Z");return E},Wxe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},Kq=t=>{var e=Lr(t,Wxe),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:s,forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d,className:f}=e;if(a<i||u===d)return null;var g=Pn("recharts-sector",f),p=a-i,x=_a(s,p,0,!0),v;return x>0&&Math.abs(u-d)<360?v=Gxe({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(x,p/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):v=qq({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),S.createElement("path",L3({},ua(e),{className:g,d:v}))};function qxe(t,e,n){if(t==="horizontal")return[{x:e.x,y:n.top},{x:e.x,y:n.top+n.height}];if(t==="vertical")return[{x:n.left,y:e.y},{x:n.left+n.width,y:e.y}];if(EW(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:s,angle:l}=e,c=ui(r,i,a,l),u=ui(r,i,s,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return Wq(e)}}var eN={},tN={},nN={},RB;function Kxe(){return RB||(RB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=FW();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(nN)),nN}var DB;function Xxe(){return DB||(DB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Kxe();function n(r){return r?(r=e.toNumber(r),r===1/0||r===-1/0?(r<0?-1:1)*Number.MAX_VALUE:r===r?r:0):r===0?r:0}t.toFinite=n})(tN)),tN}var OB;function Yxe(){return OB||(OB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UW(),n=Xxe();function r(i,a,s){s&&typeof s!="number"&&e.isIterateeCall(i,a,s)&&(a=s=void 0),i=n.toFinite(i),a===void 0?(a=i,i=0):a=n.toFinite(a),s=s===void 0?i<a?1:-1:n.toFinite(s);const l=Math.max(Math.ceil((a-i)/(s||1)),0),c=new Array(l);for(let u=0;u<l;u++)c[u]=i,i+=s;return c}t.range=r})(eN)),eN}var rN,LB;function Zxe(){return LB||(LB=1,rN=Yxe().range),rN}var Qxe=Zxe();const Xq=yo(Qxe);function od(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Jxe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function KR(t){let e,n,r;t.length!==2?(e=od,n=(l,c)=>od(t(l),c),r=(l,c)=>t(l)-c):(e=t===od||t===Jxe?t:e0e,n=t,r=t);function i(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<0?u=f+1:d=f}while(u<d)}return u}function a(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<=0?u=f+1:d=f}while(u<d)}return u}function s(l,c,u=0,d=l.length){const f=i(l,c,u,d-1);return f>u&&r(l[f-1],c)>-r(l[f],c)?f-1:f}return{left:i,center:s,right:a}}function e0e(){return 0}function Yq(t){return t===null?NaN:+t}function*t0e(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const n0e=KR(od),zb=n0e.right;KR(Yq).center;class IB extends Map{constructor(e,n=a0e){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),e!=null)for(const[r,i]of e)this.set(r,i)}get(e){return super.get(FB(this,e))}has(e){return super.has(FB(this,e))}set(e,n){return super.set(r0e(this,e),n)}delete(e){return super.delete(i0e(this,e))}}function FB({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function r0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function i0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function a0e(t){return t!==null&&typeof t=="object"?t.valueOf():t}function s0e(t=od){if(t===od)return Zq;if(typeof t!="function")throw new TypeError("compare is not a function");return(e,n)=>{const r=t(e,n);return r||r===0?r:(t(n,n)===0)-(t(e,e)===0)}}function Zq(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const o0e=Math.sqrt(50),l0e=Math.sqrt(10),c0e=Math.sqrt(2);function pw(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),s=a>=o0e?10:a>=l0e?5:a>=c0e?2:1;let l,c,u;return i<0?(u=Math.pow(10,-i)/s,l=Math.round(t*u),c=Math.round(e*u),l/u<t&&++l,c/u>e&&--c,u=-u):(u=Math.pow(10,i)*s,l=Math.round(t/u),c=Math.round(e/u),l*u<t&&++l,c*u>e&&--c),c<l&&.5<=n&&n<2?pw(t,e,n*2):[l,c,u]}function I3(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,a,s]=r?pw(e,t,n):pw(t,e,n);if(!(a>=i))return[];const l=a-i+1,c=new Array(l);if(r)if(s<0)for(let u=0;u<l;++u)c[u]=(a-u)/-s;else for(let u=0;u<l;++u)c[u]=(a-u)*s;else if(s<0)for(let u=0;u<l;++u)c[u]=(i+u)/-s;else for(let u=0;u<l;++u)c[u]=(i+u)*s;return c}function F3(t,e,n){return e=+e,t=+t,n=+n,pw(t,e,n)[2]}function U3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?F3(e,t,n):F3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function UB(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function zB(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function Qq(t,e,n=0,r=1/0,i){if(e=Math.floor(e),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(t.length-1,r)),!(n<=e&&e<=r))return t;for(i=i===void 0?Zq:s0e(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),f=.5*Math.exp(2*d/3),g=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),p=Math.max(n,Math.floor(e-u*f/c+g)),x=Math.min(r,Math.floor(e+(c-u)*f/c+g));Qq(t,e,p,x,i)}const a=t[e];let s=n,l=r;for(Sx(t,n,e),i(t[r],a)>0&&Sx(t,n,r);s<l;){for(Sx(t,s,l),++s,--l;i(t[s],a)<0;)++s;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?Sx(t,n,l):(++l,Sx(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function Sx(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function u0e(t,e,n){if(t=Float64Array.from(t0e(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return zB(t);if(e>=1)return UB(t);var r,i=(r-1)*e,a=Math.floor(i),s=UB(Qq(t,a).subarray(0,a+1)),l=zB(t.subarray(a+1));return s+(l-s)*(i-a)}}function d0e(t,e,n=Yq){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,a=Math.floor(i),s=+n(t[a],a,t),l=+n(t[a+1],a+1,t);return s+(l-s)*(i-a)}}function h0e(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,a=new Array(i);++r<i;)a[r]=t+r*n;return a}function _o(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Jc(t,e){switch(arguments.length){case 0:break;case 1:{typeof t=="function"?this.interpolator(t):this.range(t);break}default:{this.domain(t),typeof e=="function"?this.interpolator(e):this.range(e);break}}return this}const z3=Symbol("implicit");function XR(){var t=new IB,e=[],n=[],r=z3;function i(a){let s=t.get(a);if(s===void 0){if(r!==z3)return r;t.set(a,s=e.push(a)-1)}return n[s%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new IB;for(const s of a)t.has(s)||t.set(s,e.push(s)-1);return i},i.range=function(a){return arguments.length?(n=Array.from(a),i):n.slice()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return XR(e,n).unknown(r)},_o.apply(i,arguments),i}function YR(){var t=XR().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,a,s,l=!1,c=0,u=0,d=.5;delete t.unknown;function f(){var g=e().length,p=i<r,x=p?i:r,v=p?r:i;a=(v-x)/Math.max(1,g-c+u*2),l&&(a=Math.floor(a)),x+=(v-x-a*(g-c))*d,s=a*(1-c),l&&(x=Math.round(x),s=Math.round(s));var y=h0e(g).map(function(b){return x+a*b});return n(p?y.reverse():y)}return t.domain=function(g){return arguments.length?(e(g),f()):e()},t.range=function(g){return arguments.length?([r,i]=g,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(g){return[r,i]=g,r=+r,i=+i,l=!0,f()},t.bandwidth=function(){return s},t.step=function(){return a},t.round=function(g){return arguments.length?(l=!!g,f()):l},t.padding=function(g){return arguments.length?(c=Math.min(1,u=+g),f()):c},t.paddingInner=function(g){return arguments.length?(c=Math.min(1,g),f()):c},t.paddingOuter=function(g){return arguments.length?(u=+g,f()):u},t.align=function(g){return arguments.length?(d=Math.max(0,Math.min(1,g)),f()):d},t.copy=function(){return YR(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},_o.apply(f(),arguments)}function Jq(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return Jq(e())},t}function f0e(){return Jq(YR.apply(null,arguments).paddingInner(1))}function ZR(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function eK(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Bb(){}var G0=.7,gw=1/G0,mp="\\s*([+-]?\\d+)\\s*",W0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",xl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",m0e=/^#([0-9a-f]{3,8})$/,p0e=new RegExp(`^rgb\\(${mp},${mp},${mp}\\)$`),g0e=new RegExp(`^rgb\\(${xl},${xl},${xl}\\)$`),x0e=new RegExp(`^rgba\\(${mp},${mp},${mp},${W0}\\)$`),b0e=new RegExp(`^rgba\\(${xl},${xl},${xl},${W0}\\)$`),y0e=new RegExp(`^hsl\\(${W0},${xl},${xl}\\)$`),v0e=new RegExp(`^hsla\\(${W0},${xl},${xl},${W0}\\)$`),BB={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ZR(Bb,q0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:HB,formatHex:HB,formatHex8:_0e,formatHsl:w0e,formatRgb:$B,toString:$B});function HB(){return this.rgb().formatHex()}function _0e(){return this.rgb().formatHex8()}function w0e(){return tK(this).formatHsl()}function $B(){return this.rgb().formatRgb()}function q0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=m0e.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?VB(e):n===3?new es(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?zv(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?zv(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=p0e.exec(t))?new es(e[1],e[2],e[3],1):(e=g0e.exec(t))?new es(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=x0e.exec(t))?zv(e[1],e[2],e[3],e[4]):(e=b0e.exec(t))?zv(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=y0e.exec(t))?qB(e[1],e[2]/100,e[3]/100,1):(e=v0e.exec(t))?qB(e[1],e[2]/100,e[3]/100,e[4]):BB.hasOwnProperty(t)?VB(BB[t]):t==="transparent"?new es(NaN,NaN,NaN,0):null}function VB(t){return new es(t>>16&255,t>>8&255,t&255,1)}function zv(t,e,n,r){return r<=0&&(t=e=n=NaN),new es(t,e,n,r)}function S0e(t){return t instanceof Bb||(t=q0(t)),t?(t=t.rgb(),new es(t.r,t.g,t.b,t.opacity)):new es}function B3(t,e,n,r){return arguments.length===1?S0e(t):new es(t,e,n,r??1)}function es(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}ZR(es,B3,eK(Bb,{brighter(t){return t=t==null?gw:Math.pow(gw,t),new es(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?G0:Math.pow(G0,t),new es(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new es(Fh(this.r),Fh(this.g),Fh(this.b),xw(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:GB,formatHex:GB,formatHex8:M0e,formatRgb:WB,toString:WB}));function GB(){return`#${Ah(this.r)}${Ah(this.g)}${Ah(this.b)}`}function M0e(){return`#${Ah(this.r)}${Ah(this.g)}${Ah(this.b)}${Ah((isNaN(this.opacity)?1:this.opacity)*255)}`}function WB(){const t=xw(this.opacity);return`${t===1?"rgb(":"rgba("}${Fh(this.r)}, ${Fh(this.g)}, ${Fh(this.b)}${t===1?")":`, ${t})`}`}function xw(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Fh(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Ah(t){return t=Fh(t),(t<16?"0":"")+t.toString(16)}function qB(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Oo(t,e,n,r)}function tK(t){if(t instanceof Oo)return new Oo(t.h,t.s,t.l,t.opacity);if(t instanceof Bb||(t=q0(t)),!t)return new Oo;if(t instanceof Oo)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),s=NaN,l=a-i,c=(a+i)/2;return l?(e===a?s=(n-r)/l+(n<r)*6:n===a?s=(r-e)/l+2:s=(e-n)/l+4,l/=c<.5?a+i:2-a-i,s*=60):l=c>0&&c<1?0:s,new Oo(s,l,c,t.opacity)}function E0e(t,e,n,r){return arguments.length===1?tK(t):new Oo(t,e,n,r??1)}function Oo(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}ZR(Oo,E0e,eK(Bb,{brighter(t){return t=t==null?gw:Math.pow(gw,t),new Oo(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?G0:Math.pow(G0,t),new Oo(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new es(iN(t>=240?t-240:t+120,i,r),iN(t,i,r),iN(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Oo(KB(this.h),Bv(this.s),Bv(this.l),xw(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=xw(this.opacity);return`${t===1?"hsl(":"hsla("}${KB(this.h)}, ${Bv(this.s)*100}%, ${Bv(this.l)*100}%${t===1?")":`, ${t})`}`}}));function KB(t){return t=(t||0)%360,t<0?t+360:t}function Bv(t){return Math.max(0,Math.min(1,t||0))}function iN(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const QR=t=>()=>t;function A0e(t,e){return function(n){return t+n*e}}function T0e(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function N0e(t){return(t=+t)==1?nK:function(e,n){return n-e?T0e(e,n,t):QR(isNaN(e)?n:e)}}function nK(t,e){var n=e-t;return n?A0e(t,n):QR(isNaN(t)?e:t)}const XB=(function t(e){var n=N0e(e);function r(i,a){var s=n((i=B3(i)).r,(a=B3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=nK(i.opacity,a.opacity);return function(d){return i.r=s(d),i.g=l(d),i.b=c(d),i.opacity=u(d),i+""}}return r.gamma=t,r})(1);function C0e(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=t[i]*(1-a)+e[i]*a;return r}}function k0e(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function P0e(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),a=new Array(n),s;for(s=0;s<r;++s)i[s]=dg(t[s],e[s]);for(;s<n;++s)a[s]=e[s];return function(l){for(s=0;s<r;++s)a[s]=i[s](l);return a}}function j0e(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function bw(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function R0e(t,e){var n={},r={},i;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in t?n[i]=dg(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var H3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,aN=new RegExp(H3.source,"g");function D0e(t){return function(){return t}}function O0e(t){return function(e){return t(e)+""}}function L0e(t,e){var n=H3.lastIndex=aN.lastIndex=0,r,i,a,s=-1,l=[],c=[];for(t=t+"",e=e+"";(r=H3.exec(t))&&(i=aN.exec(e));)(a=i.index)>n&&(a=e.slice(n,a),l[s]?l[s]+=a:l[++s]=a),(r=r[0])===(i=i[0])?l[s]?l[s]+=i:l[++s]=i:(l[++s]=null,c.push({i:s,x:bw(r,i)})),n=aN.lastIndex;return n<e.length&&(a=e.slice(n),l[s]?l[s]+=a:l[++s]=a),l.length<2?c[0]?O0e(c[0].x):D0e(e):(e=c.length,function(u){for(var d=0,f;d<e;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function dg(t,e){var n=typeof e,r;return e==null||n==="boolean"?QR(e):(n==="number"?bw:n==="string"?(r=q0(e))?(e=r,XB):L0e:e instanceof q0?XB:e instanceof Date?j0e:k0e(e)?C0e:Array.isArray(e)?P0e:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?R0e:bw)(t,e)}function JR(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function I0e(t,e){e===void 0&&(e=t,t=dg);for(var n=0,r=e.length-1,i=e[0],a=new Array(r<0?0:r);n<r;)a[n]=t(i,i=e[++n]);return function(s){var l=Math.max(0,Math.min(r-1,Math.floor(s*=r)));return a[l](s-l)}}function F0e(t){return function(){return t}}function yw(t){return+t}var YB=[0,1];function ja(t){return t}function $3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:F0e(isNaN(e)?NaN:.5)}function U0e(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function z0e(t,e,n){var r=t[0],i=t[1],a=e[0],s=e[1];return i<r?(r=$3(i,r),a=n(s,a)):(r=$3(r,i),a=n(a,s)),function(l){return a(r(l))}}function B0e(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),s=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++s<r;)i[s]=$3(t[s],t[s+1]),a[s]=n(e[s],e[s+1]);return function(l){var c=zb(t,l,1,r)-1;return a[c](i[c](l))}}function Hb(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function AM(){var t=YB,e=YB,n=dg,r,i,a,s=ja,l,c,u;function d(){var g=Math.min(t.length,e.length);return s!==ja&&(s=U0e(t[0],t[g-1])),l=g>2?B0e:z0e,c=u=null,f}function f(g){return g==null||isNaN(g=+g)?a:(c||(c=l(t.map(r),e,n)))(r(s(g)))}return f.invert=function(g){return s(i((u||(u=l(e,t.map(r),bw)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,yw),d()):t.slice()},f.range=function(g){return arguments.length?(e=Array.from(g),d()):e.slice()},f.rangeRound=function(g){return e=Array.from(g),n=JR,d()},f.clamp=function(g){return arguments.length?(s=g?!0:ja,d()):s!==ja},f.interpolate=function(g){return arguments.length?(n=g,d()):n},f.unknown=function(g){return arguments.length?(a=g,f):a},function(g,p){return r=g,i=p,d()}}function eD(){return AM()(ja,ja)}function H0e(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function vw(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Op(t){return t=vw(Math.abs(t)),t?t[1]:NaN}function $0e(t,e){return function(n,r){for(var i=n.length,a=[],s=0,l=t[0],c=0;i>0&&l>0&&(c+l+1>r&&(l=Math.max(1,r-c)),a.push(n.substring(i-=l,i+l)),!((c+=l+1)>r));)l=t[s=(s+1)%t.length];return a.reverse().join(e)}}function V0e(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var G0e=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function K0(t){if(!(e=G0e.exec(t)))throw new Error("invalid format: "+t);var e;return new tD({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}K0.prototype=tD.prototype;function tD(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}tD.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function W0e(t){e:for(var e=t.length,n=1,r=-1,i;n<e;++n)switch(t[n]){case".":r=i=n;break;case"0":r===0&&(r=n),i=n;break;default:if(!+t[n])break e;r>0&&(r=0);break}return r>0?t.slice(0,r)+t.slice(i+1):t}var rK;function q0e(t,e){var n=vw(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(rK=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,s=r.length;return a===s?r:a>s?r+new Array(a-s+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+vw(t,Math.max(0,e+a-1))[0]}function ZB(t,e){var n=vw(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const QB={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:H0e,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>ZB(t*100,e),r:ZB,s:q0e,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function JB(t){return t}var e8=Array.prototype.map,t8=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function K0e(t){var e=t.grouping===void 0||t.thousands===void 0?JB:$0e(e8.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",a=t.numerals===void 0?JB:V0e(e8.call(t.numerals,String)),s=t.percent===void 0?"%":t.percent+"",l=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=K0(f);var g=f.fill,p=f.align,x=f.sign,v=f.symbol,y=f.zero,b=f.width,E=f.comma,w=f.precision,A=f.trim,T=f.type;T==="n"?(E=!0,T="g"):QB[T]||(w===void 0&&(w=12),A=!0,T="g"),(y||g==="0"&&p==="=")&&(y=!0,g="0",p="=");var C=v==="$"?n:v==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",N=v==="$"?r:/[%p]/.test(T)?s:"",O=QB[T],k=/[defgprs%]/.test(T);w=w===void 0?6:/[gprs]/.test(T)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function j(B){var L=C,K=N,R,q,W;if(T==="c")K=O(B)+K,B="";else{B=+B;var $=B<0||1/B<0;if(B=isNaN(B)?c:O(Math.abs(B),w),A&&(B=W0e(B)),$&&+B==0&&x!=="+"&&($=!1),L=($?x==="("?x:l:x==="-"||x==="("?"":x)+L,K=(T==="s"?t8[8+rK/3]:"")+K+($&&x==="("?")":""),k){for(R=-1,q=B.length;++R<q;)if(W=B.charCodeAt(R),48>W||W>57){K=(W===46?i+B.slice(R+1):B.slice(R))+K,B=B.slice(0,R);break}}}E&&!y&&(B=e(B,1/0));var J=L.length+B.length+K.length,ee=J<b?new Array(b-J+1).join(g):"";switch(E&&y&&(B=e(ee+B,ee.length?b-K.length:1/0),ee=""),p){case"<":B=L+B+K+ee;break;case"=":B=L+ee+B+K;break;case"^":B=ee.slice(0,J=ee.length>>1)+L+B+K+ee.slice(J);break;default:B=ee+L+B+K;break}return a(B)}return j.toString=function(){return f+""},j}function d(f,g){var p=u((f=K0(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(Op(g)/3)))*3,v=Math.pow(10,-x),y=t8[8+x/3];return function(b){return p(v*b)+y}}return{format:u,formatPrefix:d}}var Hv,nD,iK;X0e({thousands:",",grouping:[3],currency:["$",""]});function X0e(t){return Hv=K0e(t),nD=Hv.format,iK=Hv.formatPrefix,Hv}function Y0e(t){return Math.max(0,-Op(Math.abs(t)))}function Z0e(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Op(e)/3)))*3-Op(Math.abs(t)))}function Q0e(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Op(e)-Op(t))+1}function aK(t,e,n,r){var i=U3(t,e,n),a;switch(r=K0(r??",f"),r.type){case"s":{var s=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=Z0e(i,s))&&(r.precision=a),iK(r,s)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=Q0e(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=Y0e(i))&&(r.precision=a-(r.type==="%")*2);break}}return nD(r)}function jd(t){var e=t.domain;return t.ticks=function(n){var r=e();return I3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return aK(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,a=r.length-1,s=r[i],l=r[a],c,u,d=10;for(l<s&&(u=s,s=l,l=u,u=i,i=a,a=u);d-- >0;){if(u=F3(s,l,n),u===c)return r[i]=s,r[a]=l,e(r);if(u>0)s=Math.floor(s/u)*u,l=Math.ceil(l/u)*u;else if(u<0)s=Math.ceil(s*u)/u,l=Math.floor(l*u)/u;else break;c=u}return t},t}function sK(){var t=eD();return t.copy=function(){return Hb(t,sK())},_o.apply(t,arguments),jd(t)}function oK(t){var e;function n(r){return r==null||isNaN(r=+r)?e:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(t=Array.from(r,yw),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return oK(t).unknown(e)},t=arguments.length?Array.from(t,yw):[0,1],jd(n)}function lK(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],a=t[r],s;return a<i&&(s=n,n=r,r=s,s=i,i=a,a=s),t[n]=e.floor(i),t[r]=e.ceil(a),t}function n8(t){return Math.log(t)}function r8(t){return Math.exp(t)}function J0e(t){return-Math.log(-t)}function ebe(t){return-Math.exp(-t)}function tbe(t){return isFinite(t)?+("1e"+t):t<0?0:t}function nbe(t){return t===10?tbe:t===Math.E?Math.exp:e=>Math.pow(t,e)}function rbe(t){return t===Math.E?Math.log:t===10&&Math.log10||t===2&&Math.log2||(t=Math.log(t),e=>Math.log(e)/t)}function i8(t){return(e,n)=>-t(-e,n)}function rD(t){const e=t(n8,r8),n=e.domain;let r=10,i,a;function s(){return i=rbe(r),a=nbe(r),n()[0]<0?(i=i8(i),a=i8(a),t(J0e,ebe)):t(n8,r8),e}return e.base=function(l){return arguments.length?(r=+l,s()):r},e.domain=function(l){return arguments.length?(n(l),s()):n()},e.ticks=l=>{const c=n();let u=c[0],d=c[c.length-1];const f=d<u;f&&([u,d]=[d,u]);let g=i(u),p=i(d),x,v;const y=l==null?10:+l;let b=[];if(!(r%1)&&p-g<y){if(g=Math.floor(g),p=Math.ceil(p),u>0){for(;g<=p;++g)for(x=1;x<r;++x)if(v=g<0?x/a(-g):x*a(g),!(v<u)){if(v>d)break;b.push(v)}}else for(;g<=p;++g)for(x=r-1;x>=1;--x)if(v=g>0?x/a(-g):x*a(g),!(v<u)){if(v>d)break;b.push(v)}b.length*2<y&&(b=I3(u,d,y))}else b=I3(g,p,Math.min(p-g,y)).map(a);return f?b.reverse():b},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=K0(c)).precision==null&&(c.trim=!0),c=nD(c)),l===1/0)return c;const u=Math.max(1,r*l/e.ticks().length);return d=>{let f=d/a(Math.round(i(d)));return f*r<r-.5&&(f*=r),f<=u?c(d):""}},e.nice=()=>n(lK(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function cK(){const t=rD(AM()).domain([1,10]);return t.copy=()=>Hb(t,cK()).base(t.base()),_o.apply(t,arguments),t}function a8(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function s8(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function iD(t){var e=1,n=t(a8(e),s8(e));return n.constant=function(r){return arguments.length?t(a8(e=+r),s8(e)):e},jd(n)}function uK(){var t=iD(AM());return t.copy=function(){return Hb(t,uK()).constant(t.constant())},_o.apply(t,arguments)}function o8(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function ibe(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function abe(t){return t<0?-t*t:t*t}function aD(t){var e=t(ja,ja),n=1;function r(){return n===1?t(ja,ja):n===.5?t(ibe,abe):t(o8(n),o8(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},jd(e)}function sD(){var t=aD(AM());return t.copy=function(){return Hb(t,sD()).exponent(t.exponent())},_o.apply(t,arguments),t}function sbe(){return sD.apply(null,arguments).exponent(.5)}function l8(t){return Math.sign(t)*t*t}function obe(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function dK(){var t=eD(),e=[0,1],n=!1,r;function i(a){var s=obe(t(a));return isNaN(s)?r:n?Math.round(s):s}return i.invert=function(a){return t.invert(l8(a))},i.domain=function(a){return arguments.length?(t.domain(a),i):t.domain()},i.range=function(a){return arguments.length?(t.range((e=Array.from(a,yw)).map(l8)),i):e.slice()},i.rangeRound=function(a){return i.range(a).round(!0)},i.round=function(a){return arguments.length?(n=!!a,i):n},i.clamp=function(a){return arguments.length?(t.clamp(a),i):t.clamp()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return dK(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},_o.apply(i,arguments),jd(i)}function hK(){var t=[],e=[],n=[],r;function i(){var s=0,l=Math.max(1,e.length);for(n=new Array(l-1);++s<l;)n[s-1]=d0e(t,s/l);return a}function a(s){return s==null||isNaN(s=+s)?r:e[zb(n,s)]}return a.invertExtent=function(s){var l=e.indexOf(s);return l<0?[NaN,NaN]:[l>0?n[l-1]:t[0],l<n.length?n[l]:t[t.length-1]]},a.domain=function(s){if(!arguments.length)return t.slice();t=[];for(let l of s)l!=null&&!isNaN(l=+l)&&t.push(l);return t.sort(od),i()},a.range=function(s){return arguments.length?(e=Array.from(s),i()):e.slice()},a.unknown=function(s){return arguments.length?(r=s,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return hK().domain(t).range(e).unknown(r)},_o.apply(a,arguments)}function fK(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function s(c){return c!=null&&c<=c?i[zb(r,c,0,n)]:a}function l(){var c=-1;for(r=new Array(n);++c<n;)r[c]=((c+1)*e-(c-n)*t)/(n+1);return s}return s.domain=function(c){return arguments.length?([t,e]=c,t=+t,e=+e,l()):[t,e]},s.range=function(c){return arguments.length?(n=(i=Array.from(c)).length-1,l()):i.slice()},s.invertExtent=function(c){var u=i.indexOf(c);return u<0?[NaN,NaN]:u<1?[t,r[0]]:u>=n?[r[n-1],e]:[r[u-1],r[u]]},s.unknown=function(c){return arguments.length&&(a=c),s},s.thresholds=function(){return r.slice()},s.copy=function(){return fK().domain([t,e]).range(i).unknown(a)},_o.apply(jd(s),arguments)}function mK(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[zb(t,a,0,r)]:n}return i.domain=function(a){return arguments.length?(t=Array.from(a),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(a){return arguments.length?(e=Array.from(a),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(a){var s=e.indexOf(a);return[t[s-1],t[s]]},i.unknown=function(a){return arguments.length?(n=a,i):n},i.copy=function(){return mK().domain(t).range(e).unknown(n)},_o.apply(i,arguments)}const sN=new Date,oN=new Date;function Ti(t,e,n,r){function i(a){return t(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(t(a=new Date(+a)),a),i.ceil=a=>(t(a=new Date(a-1)),e(a,1),t(a),a),i.round=a=>{const s=i(a),l=i.ceil(a);return a-s<l-a?s:l},i.offset=(a,s)=>(e(a=new Date(+a),s==null?1:Math.floor(s)),a),i.range=(a,s,l)=>{const c=[];if(a=i.ceil(a),l=l==null?1:Math.floor(l),!(a<s)||!(l>0))return c;let u;do c.push(u=new Date(+a)),e(a,l),t(a);while(u<a&&a<s);return c},i.filter=a=>Ti(s=>{if(s>=s)for(;t(s),!a(s);)s.setTime(s-1)},(s,l)=>{if(s>=s)if(l<0)for(;++l<=0;)for(;e(s,-1),!a(s););else for(;--l>=0;)for(;e(s,1),!a(s););}),n&&(i.count=(a,s)=>(sN.setTime(+a),oN.setTime(+s),t(sN),t(oN),Math.floor(n(sN,oN))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?s=>r(s)%a===0:s=>i.count(0,s)%a===0):i)),i}const _w=Ti(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);_w.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Ti(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):_w);_w.range;const Ec=1e3,so=Ec*60,Ac=so*60,Vc=Ac*24,oD=Vc*7,c8=Vc*30,lN=Vc*365,Th=Ti(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Ec)},(t,e)=>(e-t)/Ec,t=>t.getUTCSeconds());Th.range;const lD=Ti(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Ec)},(t,e)=>{t.setTime(+t+e*so)},(t,e)=>(e-t)/so,t=>t.getMinutes());lD.range;const cD=Ti(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*so)},(t,e)=>(e-t)/so,t=>t.getUTCMinutes());cD.range;const uD=Ti(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Ec-t.getMinutes()*so)},(t,e)=>{t.setTime(+t+e*Ac)},(t,e)=>(e-t)/Ac,t=>t.getHours());uD.range;const dD=Ti(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Ac)},(t,e)=>(e-t)/Ac,t=>t.getUTCHours());dD.range;const $b=Ti(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*so)/Vc,t=>t.getDate()-1);$b.range;const TM=Ti(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Vc,t=>t.getUTCDate()-1);TM.range;const pK=Ti(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Vc,t=>Math.floor(t/Vc));pK.range;function Af(t){return Ti(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*so)/oD)}const NM=Af(0),ww=Af(1),lbe=Af(2),cbe=Af(3),Lp=Af(4),ube=Af(5),dbe=Af(6);NM.range;ww.range;lbe.range;cbe.range;Lp.range;ube.range;dbe.range;function Tf(t){return Ti(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/oD)}const CM=Tf(0),Sw=Tf(1),hbe=Tf(2),fbe=Tf(3),Ip=Tf(4),mbe=Tf(5),pbe=Tf(6);CM.range;Sw.range;hbe.range;fbe.range;Ip.range;mbe.range;pbe.range;const hD=Ti(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());hD.range;const fD=Ti(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());fD.range;const Gc=Ti(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());Gc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ti(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)});Gc.range;const Wc=Ti(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());Wc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ti(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)});Wc.range;function gK(t,e,n,r,i,a){const s=[[Th,1,Ec],[Th,5,5*Ec],[Th,15,15*Ec],[Th,30,30*Ec],[a,1,so],[a,5,5*so],[a,15,15*so],[a,30,30*so],[i,1,Ac],[i,3,3*Ac],[i,6,6*Ac],[i,12,12*Ac],[r,1,Vc],[r,2,2*Vc],[n,1,oD],[e,1,c8],[e,3,3*c8],[t,1,lN]];function l(u,d,f){const g=d<u;g&&([u,d]=[d,u]);const p=f&&typeof f.range=="function"?f:c(u,d,f),x=p?p.range(u,+d+1):[];return g?x.reverse():x}function c(u,d,f){const g=Math.abs(d-u)/f,p=KR(([,,y])=>y).right(s,g);if(p===s.length)return t.every(U3(u/lN,d/lN,f));if(p===0)return _w.every(Math.max(U3(u,d,f),1));const[x,v]=s[g/s[p-1][2]<s[p][2]/g?p-1:p];return x.every(v)}return[l,c]}const[gbe,xbe]=gK(Wc,fD,CM,pK,dD,cD),[bbe,ybe]=gK(Gc,hD,NM,$b,uD,lD);function cN(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function uN(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Mx(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function vbe(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,s=t.shortDays,l=t.months,c=t.shortMonths,u=Ex(i),d=Ax(i),f=Ex(a),g=Ax(a),p=Ex(s),x=Ax(s),v=Ex(l),y=Ax(l),b=Ex(c),E=Ax(c),w={a:$,A:J,b:ee,B:Q,c:null,d:p8,e:p8,f:$be,g:Jbe,G:tye,H:zbe,I:Bbe,j:Hbe,L:xK,m:Vbe,M:Gbe,p:z,q:V,Q:b8,s:y8,S:Wbe,u:qbe,U:Kbe,V:Xbe,w:Ybe,W:Zbe,x:null,X:null,y:Qbe,Y:eye,Z:nye,"%":x8},A={a:X,A:te,b:ie,B:le,c:null,d:g8,e:g8,f:sye,g:gye,G:bye,H:rye,I:iye,j:aye,L:yK,m:oye,M:lye,p:ge,q:Ee,Q:b8,s:y8,S:cye,u:uye,U:dye,V:hye,w:fye,W:mye,x:null,X:null,y:pye,Y:xye,Z:yye,"%":x8},T={a:j,A:B,b:L,B:K,c:R,d:f8,e:f8,f:Lbe,g:h8,G:d8,H:m8,I:m8,j:jbe,L:Obe,m:Pbe,M:Rbe,p:k,q:kbe,Q:Fbe,s:Ube,S:Dbe,u:Ebe,U:Abe,V:Tbe,w:Mbe,W:Nbe,x:q,X:W,y:h8,Y:d8,Z:Cbe,"%":Ibe};w.x=C(n,w),w.X=C(r,w),w.c=C(e,w),A.x=C(n,A),A.X=C(r,A),A.c=C(e,A);function C(pe,de){return function(Re){var fe=[],Fe=-1,U=0,H=pe.length,re,G,Z;for(Re instanceof Date||(Re=new Date(+Re));++Fe<H;)pe.charCodeAt(Fe)===37&&(fe.push(pe.slice(U,Fe)),(G=u8[re=pe.charAt(++Fe)])!=null?re=pe.charAt(++Fe):G=re==="e"?" ":"0",(Z=de[re])&&(re=Z(Re,G)),fe.push(re),U=Fe+1);return fe.push(pe.slice(U,Fe)),fe.join("")}}function N(pe,de){return function(Re){var fe=Mx(1900,void 0,1),Fe=O(fe,pe,Re+="",0),U,H;if(Fe!=Re.length)return null;if("Q"in fe)return new Date(fe.Q);if("s"in fe)return new Date(fe.s*1e3+("L"in fe?fe.L:0));if(de&&!("Z"in fe)&&(fe.Z=0),"p"in fe&&(fe.H=fe.H%12+fe.p*12),fe.m===void 0&&(fe.m="q"in fe?fe.q:0),"V"in fe){if(fe.V<1||fe.V>53)return null;"w"in fe||(fe.w=1),"Z"in fe?(U=uN(Mx(fe.y,0,1)),H=U.getUTCDay(),U=H>4||H===0?Sw.ceil(U):Sw(U),U=TM.offset(U,(fe.V-1)*7),fe.y=U.getUTCFullYear(),fe.m=U.getUTCMonth(),fe.d=U.getUTCDate()+(fe.w+6)%7):(U=cN(Mx(fe.y,0,1)),H=U.getDay(),U=H>4||H===0?ww.ceil(U):ww(U),U=$b.offset(U,(fe.V-1)*7),fe.y=U.getFullYear(),fe.m=U.getMonth(),fe.d=U.getDate()+(fe.w+6)%7)}else("W"in fe||"U"in fe)&&("w"in fe||(fe.w="u"in fe?fe.u%7:"W"in fe?1:0),H="Z"in fe?uN(Mx(fe.y,0,1)).getUTCDay():cN(Mx(fe.y,0,1)).getDay(),fe.m=0,fe.d="W"in fe?(fe.w+6)%7+fe.W*7-(H+5)%7:fe.w+fe.U*7-(H+6)%7);return"Z"in fe?(fe.H+=fe.Z/100|0,fe.M+=fe.Z%100,uN(fe)):cN(fe)}}function O(pe,de,Re,fe){for(var Fe=0,U=de.length,H=Re.length,re,G;Fe<U;){if(fe>=H)return-1;if(re=de.charCodeAt(Fe++),re===37){if(re=de.charAt(Fe++),G=T[re in u8?de.charAt(Fe++):re],!G||(fe=G(pe,Re,fe))<0)return-1}else if(re!=Re.charCodeAt(fe++))return-1}return fe}function k(pe,de,Re){var fe=u.exec(de.slice(Re));return fe?(pe.p=d.get(fe[0].toLowerCase()),Re+fe[0].length):-1}function j(pe,de,Re){var fe=p.exec(de.slice(Re));return fe?(pe.w=x.get(fe[0].toLowerCase()),Re+fe[0].length):-1}function B(pe,de,Re){var fe=f.exec(de.slice(Re));return fe?(pe.w=g.get(fe[0].toLowerCase()),Re+fe[0].length):-1}function L(pe,de,Re){var fe=b.exec(de.slice(Re));return fe?(pe.m=E.get(fe[0].toLowerCase()),Re+fe[0].length):-1}function K(pe,de,Re){var fe=v.exec(de.slice(Re));return fe?(pe.m=y.get(fe[0].toLowerCase()),Re+fe[0].length):-1}function R(pe,de,Re){return O(pe,e,de,Re)}function q(pe,de,Re){return O(pe,n,de,Re)}function W(pe,de,Re){return O(pe,r,de,Re)}function $(pe){return s[pe.getDay()]}function J(pe){return a[pe.getDay()]}function ee(pe){return c[pe.getMonth()]}function Q(pe){return l[pe.getMonth()]}function z(pe){return i[+(pe.getHours()>=12)]}function V(pe){return 1+~~(pe.getMonth()/3)}function X(pe){return s[pe.getUTCDay()]}function te(pe){return a[pe.getUTCDay()]}function ie(pe){return c[pe.getUTCMonth()]}function le(pe){return l[pe.getUTCMonth()]}function ge(pe){return i[+(pe.getUTCHours()>=12)]}function Ee(pe){return 1+~~(pe.getUTCMonth()/3)}return{format:function(pe){var de=C(pe+="",w);return de.toString=function(){return pe},de},parse:function(pe){var de=N(pe+="",!1);return de.toString=function(){return pe},de},utcFormat:function(pe){var de=C(pe+="",A);return de.toString=function(){return pe},de},utcParse:function(pe){var de=N(pe+="",!0);return de.toString=function(){return pe},de}}}var u8={"-":"",_:" ",0:"0"},Wi=/^\s*\d+/,_be=/^%/,wbe=/[\\^$*+?|[\]().{}]/g;function In(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function Sbe(t){return t.replace(wbe,"\\$&")}function Ex(t){return new RegExp("^(?:"+t.map(Sbe).join("|")+")","i")}function Ax(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function Mbe(t,e,n){var r=Wi.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Ebe(t,e,n){var r=Wi.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Abe(t,e,n){var r=Wi.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Tbe(t,e,n){var r=Wi.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Nbe(t,e,n){var r=Wi.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function d8(t,e,n){var r=Wi.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function h8(t,e,n){var r=Wi.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Cbe(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function kbe(t,e,n){var r=Wi.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Pbe(t,e,n){var r=Wi.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function f8(t,e,n){var r=Wi.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function jbe(t,e,n){var r=Wi.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function m8(t,e,n){var r=Wi.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Rbe(t,e,n){var r=Wi.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Dbe(t,e,n){var r=Wi.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Obe(t,e,n){var r=Wi.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Lbe(t,e,n){var r=Wi.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Ibe(t,e,n){var r=_be.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Fbe(t,e,n){var r=Wi.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Ube(t,e,n){var r=Wi.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function p8(t,e){return In(t.getDate(),e,2)}function zbe(t,e){return In(t.getHours(),e,2)}function Bbe(t,e){return In(t.getHours()%12||12,e,2)}function Hbe(t,e){return In(1+$b.count(Gc(t),t),e,3)}function xK(t,e){return In(t.getMilliseconds(),e,3)}function $be(t,e){return xK(t,e)+"000"}function Vbe(t,e){return In(t.getMonth()+1,e,2)}function Gbe(t,e){return In(t.getMinutes(),e,2)}function Wbe(t,e){return In(t.getSeconds(),e,2)}function qbe(t){var e=t.getDay();return e===0?7:e}function Kbe(t,e){return In(NM.count(Gc(t)-1,t),e,2)}function bK(t){var e=t.getDay();return e>=4||e===0?Lp(t):Lp.ceil(t)}function Xbe(t,e){return t=bK(t),In(Lp.count(Gc(t),t)+(Gc(t).getDay()===4),e,2)}function Ybe(t){return t.getDay()}function Zbe(t,e){return In(ww.count(Gc(t)-1,t),e,2)}function Qbe(t,e){return In(t.getFullYear()%100,e,2)}function Jbe(t,e){return t=bK(t),In(t.getFullYear()%100,e,2)}function eye(t,e){return In(t.getFullYear()%1e4,e,4)}function tye(t,e){var n=t.getDay();return t=n>=4||n===0?Lp(t):Lp.ceil(t),In(t.getFullYear()%1e4,e,4)}function nye(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+In(e/60|0,"0",2)+In(e%60,"0",2)}function g8(t,e){return In(t.getUTCDate(),e,2)}function rye(t,e){return In(t.getUTCHours(),e,2)}function iye(t,e){return In(t.getUTCHours()%12||12,e,2)}function aye(t,e){return In(1+TM.count(Wc(t),t),e,3)}function yK(t,e){return In(t.getUTCMilliseconds(),e,3)}function sye(t,e){return yK(t,e)+"000"}function oye(t,e){return In(t.getUTCMonth()+1,e,2)}function lye(t,e){return In(t.getUTCMinutes(),e,2)}function cye(t,e){return In(t.getUTCSeconds(),e,2)}function uye(t){var e=t.getUTCDay();return e===0?7:e}function dye(t,e){return In(CM.count(Wc(t)-1,t),e,2)}function vK(t){var e=t.getUTCDay();return e>=4||e===0?Ip(t):Ip.ceil(t)}function hye(t,e){return t=vK(t),In(Ip.count(Wc(t),t)+(Wc(t).getUTCDay()===4),e,2)}function fye(t){return t.getUTCDay()}function mye(t,e){return In(Sw.count(Wc(t)-1,t),e,2)}function pye(t,e){return In(t.getUTCFullYear()%100,e,2)}function gye(t,e){return t=vK(t),In(t.getUTCFullYear()%100,e,2)}function xye(t,e){return In(t.getUTCFullYear()%1e4,e,4)}function bye(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Ip(t):Ip.ceil(t),In(t.getUTCFullYear()%1e4,e,4)}function yye(){return"+0000"}function x8(){return"%"}function b8(t){return+t}function y8(t){return Math.floor(+t/1e3)}var dm,_K,wK;vye({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function vye(t){return dm=vbe(t),_K=dm.format,dm.parse,wK=dm.utcFormat,dm.utcParse,dm}function _ye(t){return new Date(t)}function wye(t){return t instanceof Date?+t:+new Date(+t)}function mD(t,e,n,r,i,a,s,l,c,u){var d=eD(),f=d.invert,g=d.domain,p=u(".%L"),x=u(":%S"),v=u("%I:%M"),y=u("%I %p"),b=u("%a %d"),E=u("%b %d"),w=u("%B"),A=u("%Y");function T(C){return(c(C)<C?p:l(C)<C?x:s(C)<C?v:a(C)<C?y:r(C)<C?i(C)<C?b:E:n(C)<C?w:A)(C)}return d.invert=function(C){return new Date(f(C))},d.domain=function(C){return arguments.length?g(Array.from(C,wye)):g().map(_ye)},d.ticks=function(C){var N=g();return t(N[0],N[N.length-1],C??10)},d.tickFormat=function(C,N){return N==null?T:u(N)},d.nice=function(C){var N=g();return(!C||typeof C.range!="function")&&(C=e(N[0],N[N.length-1],C??10)),C?g(lK(N,C)):d},d.copy=function(){return Hb(d,mD(t,e,n,r,i,a,s,l,c,u))},d}function Sye(){return _o.apply(mD(bbe,ybe,Gc,hD,NM,$b,uD,lD,Th,_K).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Mye(){return _o.apply(mD(gbe,xbe,Wc,fD,CM,TM,dD,cD,Th,wK).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function kM(){var t=0,e=1,n,r,i,a,s=ja,l=!1,c;function u(f){return f==null||isNaN(f=+f)?c:s(i===0?.5:(f=(a(f)-n)*i,l?Math.max(0,Math.min(1,f)):f))}u.domain=function(f){return arguments.length?([t,e]=f,n=a(t=+t),r=a(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(f){return arguments.length?(l=!!f,u):l},u.interpolator=function(f){return arguments.length?(s=f,u):s};function d(f){return function(g){var p,x;return arguments.length?([p,x]=g,s=f(p,x),u):[s(0),s(1)]}}return u.range=d(dg),u.rangeRound=d(JR),u.unknown=function(f){return arguments.length?(c=f,u):c},function(f){return a=f,n=f(t),r=f(e),i=n===r?0:1/(r-n),u}}function Rd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function SK(){var t=jd(kM()(ja));return t.copy=function(){return Rd(t,SK())},Jc.apply(t,arguments)}function MK(){var t=rD(kM()).domain([1,10]);return t.copy=function(){return Rd(t,MK()).base(t.base())},Jc.apply(t,arguments)}function EK(){var t=iD(kM());return t.copy=function(){return Rd(t,EK()).constant(t.constant())},Jc.apply(t,arguments)}function pD(){var t=aD(kM());return t.copy=function(){return Rd(t,pD()).exponent(t.exponent())},Jc.apply(t,arguments)}function Eye(){return pD.apply(null,arguments).exponent(.5)}function AK(){var t=[],e=ja;function n(r){if(r!=null&&!isNaN(r=+r))return e((zb(t,r,1)-1)/(t.length-1))}return n.domain=function(r){if(!arguments.length)return t.slice();t=[];for(let i of r)i!=null&&!isNaN(i=+i)&&t.push(i);return t.sort(od),n},n.interpolator=function(r){return arguments.length?(e=r,n):e},n.range=function(){return t.map((r,i)=>e(i/(t.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,a)=>u0e(t,a/r))},n.copy=function(){return AK(e).domain(t)},Jc.apply(n,arguments)}function PM(){var t=0,e=.5,n=1,r=1,i,a,s,l,c,u=ja,d,f=!1,g;function p(v){return isNaN(v=+v)?g:(v=.5+((v=+d(v))-a)*(r*v<r*a?l:c),u(f?Math.max(0,Math.min(1,v)):v))}p.domain=function(v){return arguments.length?([t,e,n]=v,i=d(t=+t),a=d(e=+e),s=d(n=+n),l=i===a?0:.5/(a-i),c=a===s?0:.5/(s-a),r=a<i?-1:1,p):[t,e,n]},p.clamp=function(v){return arguments.length?(f=!!v,p):f},p.interpolator=function(v){return arguments.length?(u=v,p):u};function x(v){return function(y){var b,E,w;return arguments.length?([b,E,w]=y,u=I0e(v,[b,E,w]),p):[u(0),u(.5),u(1)]}}return p.range=x(dg),p.rangeRound=x(JR),p.unknown=function(v){return arguments.length?(g=v,p):g},function(v){return d=v,i=v(t),a=v(e),s=v(n),l=i===a?0:.5/(a-i),c=a===s?0:.5/(s-a),r=a<i?-1:1,p}}function TK(){var t=jd(PM()(ja));return t.copy=function(){return Rd(t,TK())},Jc.apply(t,arguments)}function NK(){var t=rD(PM()).domain([.1,1,10]);return t.copy=function(){return Rd(t,NK()).base(t.base())},Jc.apply(t,arguments)}function CK(){var t=iD(PM());return t.copy=function(){return Rd(t,CK()).constant(t.constant())},Jc.apply(t,arguments)}function gD(){var t=aD(PM());return t.copy=function(){return Rd(t,gD()).exponent(t.exponent())},Jc.apply(t,arguments)}function Aye(){return gD.apply(null,arguments).exponent(.5)}const qx=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:YR,scaleDiverging:TK,scaleDivergingLog:NK,scaleDivergingPow:gD,scaleDivergingSqrt:Aye,scaleDivergingSymlog:CK,scaleIdentity:oK,scaleImplicit:z3,scaleLinear:sK,scaleLog:cK,scaleOrdinal:XR,scalePoint:f0e,scalePow:sD,scaleQuantile:hK,scaleQuantize:fK,scaleRadial:dK,scaleSequential:SK,scaleSequentialLog:MK,scaleSequentialPow:pD,scaleSequentialQuantile:AK,scaleSequentialSqrt:Eye,scaleSequentialSymlog:EK,scaleSqrt:sbe,scaleSymlog:uK,scaleThreshold:mK,scaleTime:Sye,scaleUtc:Mye,tickFormat:aK},Symbol.toStringTag,{value:"Module"}));var Dd=t=>t.chartData,xD=Qe([Dd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),Vb=(t,e,n,r)=>r?xD(t):Dd(t);function vd(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(Qn(e)&&Qn(n))return!0}return!1}function v8(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function kK(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(Qn(n))i=n;else if(typeof n=="function")return;if(Qn(r))a=r;else if(typeof r=="function")return;var s=[i,a];if(vd(s))return s}}function Tye(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(vd(r))return v8(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,a]=t,s,l;if(i==="auto")e!=null&&(s=Math.min(...e));else if(Dt(i))s=i;else if(typeof i=="function")try{e!=null&&(s=i(e?.[0]))}catch{}else if(typeof i=="string"&&Kz.test(i)){var c=Kz.exec(i);if(c==null||e==null)s=void 0;else{var u=+c[1];s=e[0]-u}}else s=e?.[0];if(a==="auto")e!=null&&(l=Math.max(...e));else if(Dt(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&Xz.test(a)){var d=Xz.exec(a);if(d==null||e==null)l=void 0;else{var f=+d[1];l=e[1]+f}}else l=e?.[1];var g=[s,l];if(vd(g))return e==null?g:v8(g,e,n)}}}var hg=1e9,Nye={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},yD,Pr=!0,bo="[DecimalError] ",Uh=bo+"Invalid argument: ",bD=bo+"Exponent out of range: ",fg=Math.floor,gh=Math.pow,Cye=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ms,Ui=1e7,Mr=7,PK=9007199254740991,Mw=fg(PK/Mr),Ot={};Ot.absoluteValue=Ot.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Ot.comparedTo=Ot.cmp=function(t){var e,n,r,i,a=this;if(t=new a.constructor(t),a.s!==t.s)return a.s||-t.s;if(a.e!==t.e)return a.e>t.e^a.s<0?1:-1;for(r=a.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(a.d[e]!==t.d[e])return a.d[e]>t.d[e]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1};Ot.decimalPlaces=Ot.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*Mr;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Ot.dividedBy=Ot.div=function(t){return jc(this,new this.constructor(t))};Ot.dividedToIntegerBy=Ot.idiv=function(t){var e=this,n=e.constructor;return pr(jc(e,new n(t),0,1),n.precision)};Ot.equals=Ot.eq=function(t){return!this.cmp(t)};Ot.exponent=function(){return hi(this)};Ot.greaterThan=Ot.gt=function(t){return this.cmp(t)>0};Ot.greaterThanOrEqualTo=Ot.gte=function(t){return this.cmp(t)>=0};Ot.isInteger=Ot.isint=function(){return this.e>this.d.length-2};Ot.isNegative=Ot.isneg=function(){return this.s<0};Ot.isPositive=Ot.ispos=function(){return this.s>0};Ot.isZero=function(){return this.s===0};Ot.lessThan=Ot.lt=function(t){return this.cmp(t)<0};Ot.lessThanOrEqualTo=Ot.lte=function(t){return this.cmp(t)<1};Ot.logarithm=Ot.log=function(t){var e,n=this,r=n.constructor,i=r.precision,a=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(Ms))throw Error(bo+"NaN");if(n.s<1)throw Error(bo+(n.s?"NaN":"-Infinity"));return n.eq(Ms)?new r(0):(Pr=!1,e=jc(X0(n,a),X0(t,a),a),Pr=!0,pr(e,i))};Ot.minus=Ot.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?DK(e,t):jK(e,(t.s=-t.s,t))};Ot.modulo=Ot.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(bo+"NaN");return n.s?(Pr=!1,e=jc(n,t,0,1).times(t),Pr=!0,n.minus(e)):pr(new r(n),i)};Ot.naturalExponential=Ot.exp=function(){return RK(this)};Ot.naturalLogarithm=Ot.ln=function(){return X0(this)};Ot.negated=Ot.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Ot.plus=Ot.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?jK(e,t):DK(e,(t.s=-t.s,t))};Ot.precision=Ot.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Uh+t);if(e=hi(i)+1,r=i.d.length-1,n=r*Mr+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return t&&e>n?e:n};Ot.squareRoot=Ot.sqrt=function(){var t,e,n,r,i,a,s,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(bo+"NaN")}for(t=hi(l),Pr=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=ml(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=fg((t+1)/2)-(t<0||t%2),i==1/0?e="5e"+t:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),r=new c(e)):r=new c(i.toString()),n=c.precision,i=s=n+3;;)if(a=r,r=a.plus(jc(l,a,s+2)).times(.5),ml(a.d).slice(0,s)===(e=ml(r.d)).slice(0,s)){if(e=e.slice(s-3,s+1),i==s&&e=="4999"){if(pr(a,n+1,0),a.times(a).eq(l)){r=a;break}}else if(e!="9999")break;s+=4}return Pr=!0,pr(r,n)};Ot.times=Ot.mul=function(t){var e,n,r,i,a,s,l,c,u,d=this,f=d.constructor,g=d.d,p=(t=new f(t)).d;if(!d.s||!t.s)return new f(0);for(t.s*=d.s,n=d.e+t.e,c=g.length,u=p.length,c<u&&(a=g,g=p,p=a,s=c,c=u,u=s),a=[],s=c+u,r=s;r--;)a.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)l=a[i]+p[r]*g[i-r-1]+e,a[i--]=l%Ui|0,e=l/Ui|0;a[i]=(a[i]+e)%Ui|0}for(;!a[--s];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,Pr?pr(t,f.precision):t};Ot.toDecimalPlaces=Ot.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(Sl(t,0,hg),e===void 0?e=r.rounding:Sl(e,0,8),pr(n,t+hi(n)+1,e))};Ot.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=df(r,!0):(Sl(t,0,hg),e===void 0?e=i.rounding:Sl(e,0,8),r=pr(new i(r),t+1,e),n=df(r,!0,t+1)),n};Ot.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?df(i):(Sl(t,0,hg),e===void 0?e=a.rounding:Sl(e,0,8),r=pr(new a(i),t+hi(i)+1,e),n=df(r.abs(),!1,t+hi(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Ot.toInteger=Ot.toint=function(){var t=this,e=t.constructor;return pr(new e(t),hi(t)+1,e.rounding)};Ot.toNumber=function(){return+this};Ot.toPower=Ot.pow=function(t){var e,n,r,i,a,s,l=this,c=l.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(Ms);if(l=new c(l),!l.s){if(t.s<1)throw Error(bo+"Infinity");return l}if(l.eq(Ms))return l;if(r=c.precision,t.eq(Ms))return pr(l,r);if(e=t.e,n=t.d.length-1,s=e>=n,a=l.s,s){if((n=d<0?-d:d)<=PK){for(i=new c(Ms),e=Math.ceil(r/Mr+4),Pr=!1;n%2&&(i=i.times(l),w8(i.d,e)),n=fg(n/2),n!==0;)l=l.times(l),w8(l.d,e);return Pr=!0,t.s<0?new c(Ms).div(i):pr(i,r)}}else if(a<0)throw Error(bo+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,Pr=!1,i=t.times(X0(l,r+u)),Pr=!0,i=RK(i),i.s=a,i};Ot.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=hi(i),r=df(i,n<=a.toExpNeg||n>=a.toExpPos)):(Sl(t,1,hg),e===void 0?e=a.rounding:Sl(e,0,8),i=pr(new a(i),t,e),n=hi(i),r=df(i,t<=n||n<=a.toExpNeg,t)),r};Ot.toSignificantDigits=Ot.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(Sl(t,1,hg),e===void 0?e=r.rounding:Sl(e,0,8)),pr(new r(n),t,e)};Ot.toString=Ot.valueOf=Ot.val=Ot.toJSON=Ot[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=hi(t),n=t.constructor;return df(t,e<=n.toExpNeg||e>=n.toExpPos)};function jK(t,e){var n,r,i,a,s,l,c,u,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),Pr?pr(e,f):e;if(c=t.d,u=e.d,s=t.e,i=e.e,c=c.slice(),a=s-i,a){for(a<0?(r=c,a=-a,l=u.length):(r=u,i=s,l=c.length),s=Math.ceil(f/Mr),l=s>l?s+1:l+1,a>l&&(a=l,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(l=c.length,a=u.length,l-a<0&&(a=l,r=u,u=c,c=r),n=0;a;)n=(c[--a]=c[a]+u[a]+n)/Ui|0,c[a]%=Ui;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,Pr?pr(e,f):e}function Sl(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Uh+t)}function ml(t){var e,n,r,i=t.length-1,a="",s=t[0];if(i>0){for(a+=s,e=1;e<i;e++)r=t[e]+"",n=Mr-r.length,n&&(a+=Bu(n)),a+=r;s=t[e],r=s+"",n=Mr-r.length,n&&(a+=Bu(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return a+s}var jc=(function(){function t(r,i){var a,s=0,l=r.length;for(r=r.slice();l--;)a=r[l]*i+s,r[l]=a%Ui|0,s=a/Ui|0;return s&&r.unshift(s),r}function e(r,i,a,s){var l,c;if(a!=s)c=a>s?1:-1;else for(l=c=0;l<a;l++)if(r[l]!=i[l]){c=r[l]>i[l]?1:-1;break}return c}function n(r,i,a){for(var s=0;a--;)r[a]-=s,s=r[a]<i[a]?1:0,r[a]=s*Ui+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,s){var l,c,u,d,f,g,p,x,v,y,b,E,w,A,T,C,N,O,k=r.constructor,j=r.s==i.s?1:-1,B=r.d,L=i.d;if(!r.s)return new k(r);if(!i.s)throw Error(bo+"Division by zero");for(c=r.e-i.e,N=L.length,T=B.length,p=new k(j),x=p.d=[],u=0;L[u]==(B[u]||0);)++u;if(L[u]>(B[u]||0)&&--c,a==null?E=a=k.precision:s?E=a+(hi(r)-hi(i))+1:E=a,E<0)return new k(0);if(E=E/Mr+2|0,u=0,N==1)for(d=0,L=L[0],E++;(u<T||d)&&E--;u++)w=d*Ui+(B[u]||0),x[u]=w/L|0,d=w%L|0;else{for(d=Ui/(L[0]+1)|0,d>1&&(L=t(L,d),B=t(B,d),N=L.length,T=B.length),A=N,v=B.slice(0,N),y=v.length;y<N;)v[y++]=0;O=L.slice(),O.unshift(0),C=L[0],L[1]>=Ui/2&&++C;do d=0,l=e(L,v,N,y),l<0?(b=v[0],N!=y&&(b=b*Ui+(v[1]||0)),d=b/C|0,d>1?(d>=Ui&&(d=Ui-1),f=t(L,d),g=f.length,y=v.length,l=e(f,v,g,y),l==1&&(d--,n(f,N<g?O:L,g))):(d==0&&(l=d=1),f=L.slice()),g=f.length,g<y&&f.unshift(0),n(v,f,y),l==-1&&(y=v.length,l=e(L,v,N,y),l<1&&(d++,n(v,N<y?O:L,y))),y=v.length):l===0&&(d++,v=[0]),x[u++]=d,l&&v[0]?v[y++]=B[A]||0:(v=[B[A]],y=1);while((A++<T||v[0]!==void 0)&&E--)}return x[0]||x.shift(),p.e=c,pr(p,s?a+hi(p)+1:a)}})();function RK(t,e){var n,r,i,a,s,l,c=0,u=0,d=t.constructor,f=d.precision;if(hi(t)>16)throw Error(bD+hi(t));if(!t.s)return new d(Ms);for(Pr=!1,l=f,s=new d(.03125);t.abs().gte(.1);)t=t.times(s),u+=5;for(r=Math.log(gh(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d(Ms),d.precision=l;;){if(i=pr(i.times(t),l),n=n.times(++c),s=a.plus(jc(i,n,l)),ml(s.d).slice(0,l)===ml(a.d).slice(0,l)){for(;u--;)a=pr(a.times(a),l);return d.precision=f,e==null?(Pr=!0,pr(a,f)):a}a=s}}function hi(t){for(var e=t.e*Mr,n=t.d[0];n>=10;n/=10)e++;return e}function dN(t,e,n){if(e>t.LN10.sd())throw Pr=!0,n&&(t.precision=n),Error(bo+"LN10 precision limit exceeded");return pr(new t(t.LN10),e)}function Bu(t){for(var e="";t--;)e+="0";return e}function X0(t,e){var n,r,i,a,s,l,c,u,d,f=1,g=10,p=t,x=p.d,v=p.constructor,y=v.precision;if(p.s<1)throw Error(bo+(p.s?"NaN":"-Infinity"));if(p.eq(Ms))return new v(0);if(e==null?(Pr=!1,u=y):u=e,p.eq(10))return e==null&&(Pr=!0),dN(v,u);if(u+=g,v.precision=u,n=ml(x),r=n.charAt(0),a=hi(p),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(t),n=ml(p.d),r=n.charAt(0),f++;a=hi(p),r>1?(p=new v("0."+n),a++):p=new v(r+"."+n.slice(1))}else return c=dN(v,u+2,y).times(a+""),p=X0(new v(r+"."+n.slice(1)),u-g).plus(c),v.precision=y,e==null?(Pr=!0,pr(p,y)):p;for(l=s=p=jc(p.minus(Ms),p.plus(Ms),u),d=pr(p.times(p),u),i=3;;){if(s=pr(s.times(d),u),c=l.plus(jc(s,new v(i),u)),ml(c.d).slice(0,u)===ml(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(dN(v,u+2,y).times(a+""))),l=jc(l,new v(f),u),v.precision=y,e==null?(Pr=!0,pr(l,y)):l;l=c,i+=2}}function _8(t,e){var n,r,i;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(n<0&&(n=r),n+=+e.slice(r+1),e=e.substring(0,r)):n<0&&(n=e.length),r=0;e.charCodeAt(r)===48;)++r;for(i=e.length;e.charCodeAt(i-1)===48;)--i;if(e=e.slice(r,i),e){if(i-=r,n=n-r-1,t.e=fg(n/Mr),t.d=[],r=(n+1)%Mr,n<0&&(r+=Mr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=Mr;r<i;)t.d.push(+e.slice(r,r+=Mr));e=e.slice(r),r=Mr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),Pr&&(t.e>Mw||t.e<-Mw))throw Error(bD+n)}else t.s=0,t.e=0,t.d=[0];return t}function pr(t,e,n){var r,i,a,s,l,c,u,d,f=t.d;for(s=1,a=f[0];a>=10;a/=10)s++;if(r=e-s,r<0)r+=Mr,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/Mr),a=f.length,d>=a)return t;for(u=a=f[d],s=1;a>=10;a/=10)s++;r%=Mr,i=r-Mr+s}if(n!==void 0&&(a=gh(10,s-i-1),l=u/a%10|0,c=e<0||f[d+1]!==void 0||u%a,c=n<4?(l||c)&&(n==0||n==(t.s<0?3:2)):l>5||l==5&&(n==4||c||n==6&&(r>0?i>0?u/gh(10,s-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=hi(t),f.length=1,e=e-a-1,f[0]=gh(10,(Mr-e%Mr)%Mr),t.e=fg(-e/Mr)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(r==0?(f.length=d,a=1,d--):(f.length=d+1,a=gh(10,Mr-r),f[d]=i>0?(u/gh(10,s-i)%gh(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==Ui&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=Ui)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(Pr&&(t.e>Mw||t.e<-Mw))throw Error(bD+hi(t));return t}function DK(t,e){var n,r,i,a,s,l,c,u,d,f,g=t.constructor,p=g.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new g(t),Pr?pr(e,p):e;if(c=t.d,f=e.d,r=e.e,u=t.e,c=c.slice(),s=u-r,s){for(d=s<0,d?(n=c,s=-s,l=f.length):(n=f,r=u,l=c.length),i=Math.max(Math.ceil(p/Mr),l)+2,s>i&&(s=i,n.length=1),n.reverse(),i=s;i--;)n.push(0);n.reverse()}else{for(i=c.length,l=f.length,d=i<l,d&&(l=i),i=0;i<l;i++)if(c[i]!=f[i]){d=c[i]<f[i];break}s=0}for(d&&(n=c,c=f,f=n,e.s=-e.s),l=c.length,i=f.length-l;i>0;--i)c[l++]=0;for(i=f.length;i>s;){if(c[--i]<f[i]){for(a=i;a&&c[--a]===0;)c[a]=Ui-1;--c[a],c[i]+=Ui}c[i]-=f[i]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,Pr?pr(e,p):e):new g(0)}function df(t,e,n){var r,i=hi(t),a=ml(t.d),s=a.length;return e?(n&&(r=n-s)>0?a=a.charAt(0)+"."+a.slice(1)+Bu(r):s>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+Bu(-i-1)+a,n&&(r=n-s)>0&&(a+=Bu(r))):i>=s?(a+=Bu(i+1-s),n&&(r=n-i-1)>0&&(a=a+"."+Bu(r))):((r=i+1)<s&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-s)>0&&(i+1===s&&(a+="."),a+=Bu(r))),t.s<0?"-"+a:a}function w8(t,e){if(t.length>e)return t.length=e,!0}function OK(t){var e,n,r;function i(a){var s=this;if(!(s instanceof i))return new i(a);if(s.constructor=i,a instanceof i){s.s=a.s,s.e=a.e,s.d=(a=a.d)?a.slice():a;return}if(typeof a=="number"){if(a*0!==0)throw Error(Uh+a);if(a>0)s.s=1;else if(a<0)a=-a,s.s=-1;else{s.s=0,s.e=0,s.d=[0];return}if(a===~~a&&a<1e7){s.e=0,s.d=[a];return}return _8(s,a.toString())}else if(typeof a!="string")throw Error(Uh+a);if(a.charCodeAt(0)===45?(a=a.slice(1),s.s=-1):s.s=1,Cye.test(a))_8(s,a);else throw Error(Uh+a)}if(i.prototype=Ot,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=OK,i.config=i.set=kye,t===void 0&&(t={}),t)for(r=["precision","rounding","toExpNeg","toExpPos","LN10"],e=0;e<r.length;)t.hasOwnProperty(n=r[e++])||(t[n]=this[n]);return i.config(t),i}function kye(t){if(!t||typeof t!="object")throw Error(bo+"Object expected");var e,n,r,i=["precision",1,hg,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(e=0;e<i.length;e+=3)if((r=t[n=i[e]])!==void 0)if(fg(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Uh+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Uh+n+": "+r);return this}var yD=OK(Nye);Ms=new yD(1);const Yn=yD;var Pye=t=>t,LK={},IK=t=>t===LK,S8=t=>function e(){return arguments.length===0||arguments.length===1&&IK(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},FK=(t,e)=>t===1?e:S8(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var a=r.filter(s=>s!==LK).length;return a>=t?e(...r):FK(t-a,S8(function(){for(var s=arguments.length,l=new Array(s),c=0;c<s;c++)l[c]=arguments[c];var u=r.map(d=>IK(d)?l.shift():d);return e(...u,...l)}))}),jye=t=>FK(t.length,t),V3=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},Rye=jye((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),Dye=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return Pye;var i=n.reverse(),a=i[0],s=i.slice(1);return function(){return s.reduce((l,c)=>c(l),a(...arguments))}},G3=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function UK(t){var e;return t===0?e=1:e=Math.floor(new Yn(t).abs().log(10).toNumber())+1,e}function zK(t,e,n){for(var r=new Yn(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var BK=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},HK=(t,e,n)=>{if(t.lte(0))return new Yn(0);var r=UK(t.toNumber()),i=new Yn(10).pow(r),a=t.div(i),s=r!==1?.05:.1,l=new Yn(Math.ceil(a.div(s).toNumber())).add(n).mul(s),c=l.mul(i);return e?new Yn(c.toNumber()):new Yn(Math.ceil(c.toNumber()))},Oye=(t,e,n)=>{var r=new Yn(1),i=new Yn(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new Yn(10).pow(UK(t)-1),i=new Yn(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new Yn(Math.floor(t)))}else t===0?i=new Yn(Math.floor((e-1)/2)):n||(i=new Yn(Math.floor(t)));var s=Math.floor((e-1)/2),l=Dye(Rye(c=>i.add(new Yn(c-s).mul(r)).toNumber()),V3);return l(0,e)},$K=function(e,n,r,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new Yn(0),tickMin:new Yn(0),tickMax:new Yn(0)};var s=HK(new Yn(n).sub(e).div(r-1),i,a),l;e<=0&&n>=0?l=new Yn(0):(l=new Yn(e).add(n).div(2),l=l.sub(new Yn(l).mod(s)));var c=Math.ceil(l.sub(e).div(s).toNumber()),u=Math.ceil(new Yn(n).sub(l).div(s).toNumber()),d=c+u+1;return d>r?$K(e,n,r,i,a+1):(d<r&&(u=n>0?u+(r-d):u,c=n>0?c:c+(r-d)),{step:s,tickMin:l.sub(new Yn(c).mul(s)),tickMax:l.add(new Yn(u).mul(s))})},Lye=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=Math.max(i,2),[l,c]=BK([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...V3(0,i-1).map(()=>1/0)]:[...V3(0,i-1).map(()=>-1/0),c];return n>r?G3(u):u}if(l===c)return Oye(l,i,a);var{step:d,tickMin:f,tickMax:g}=$K(l,c,s,a,0),p=zK(f,g.add(new Yn(.1).mul(d)),d);return n>r?G3(p):p},Iye=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[s,l]=BK([r,i]);if(s===-1/0||l===1/0)return[r,i];if(s===l)return[s];var c=Math.max(n,2),u=HK(new Yn(l).sub(s).div(c-1),a,0),d=[...zK(new Yn(s),new Yn(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?G3(d):d},VK=t=>t.rootProps.maxBarSize,Fye=t=>t.rootProps.barGap,GK=t=>t.rootProps.barCategoryGap,Uye=t=>t.rootProps.barSize,Gb=t=>t.rootProps.stackOffset,WK=t=>t.rootProps.reverseStackOrder,vD=t=>t.options.chartName,_D=t=>t.rootProps.syncId,qK=t=>t.rootProps.syncMethod,wD=t=>t.options.eventEmitter,zye=t=>t.rootProps.baseValue,Gr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},vc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},ws={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},jM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},Bye={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:vc.angleAxisId,includeHidden:!1,name:void 0,reversed:vc.reversed,scale:vc.scale,tick:vc.tick,tickCount:void 0,ticks:void 0,type:vc.type,unit:void 0},Hye={allowDataOverflow:ws.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ws.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ws.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ws.scale,tick:ws.tick,tickCount:ws.tickCount,ticks:void 0,type:ws.type,unit:void 0},$ye={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:vc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:vc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:vc.scale,tick:vc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},Vye={allowDataOverflow:ws.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ws.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ws.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ws.scale,tick:ws.tick,tickCount:ws.tickCount,ticks:void 0,type:"category",unit:void 0},SD=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?$ye:Bye,MD=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?Vye:Hye,RM=t=>t.polarOptions,ED=Qe([Zc,Qc,Ei],Gq),KK=Qe([RM,ED],(t,e)=>{if(t!=null)return _a(t.innerRadius,e,0)}),XK=Qe([RM,ED],(t,e)=>{if(t!=null)return _a(t.outerRadius,e,e*.8)}),Gye=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},YK=Qe([RM],Gye);Qe([SD,YK],jM);var ZK=Qe([ED,KK,XK],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});Qe([MD,ZK],jM);var QK=Qe([Sn,RM,KK,XK,Zc,Qc],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:s,cy:l,startAngle:c,endAngle:u}=e;return{cx:_a(s,i,i/2),cy:_a(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),jr=(t,e)=>e,Wb=(t,e,n)=>n;function DM(t){return t?.id}function JK(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:a}=n,s=new Map;return t.forEach(l=>{var c,u=(c=l.data)!==null&&c!==void 0?c:r;if(!(u==null||u.length===0)){var d=DM(l);u.forEach((f,g)=>{var p=a==null||i?g:String(Zn(f,a,null)),x=Zn(f,l.dataKey,0),v;s.has(p)?v=s.get(p):v={},Object.assign(v,{[d]:x}),s.set(p,v)})}}),Array.from(s.values())}function OM(t){return t.stackId!=null&&t.dataKey!=null}var LM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function IM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function Wye(t,e){if(t.length===e.length){for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}return!1}var Ni=t=>{var e=Sn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},mg=t=>t.tooltip.settings.axisId;function M8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ew(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M8(Object(n),!0).forEach(function(r){qye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qye(t,e,n){return(e=Kye(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Kye(t){var e=Xye(t,"string");return typeof e=="symbol"?e:e+""}function Xye(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var W3=[0,"auto"],Li={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:void 0,height:30,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"bottom",padding:{left:0,right:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"category",unit:void 0},eX=(t,e)=>t.cartesianAxis.xAxis[e],Dl=(t,e)=>{var n=eX(t,e);return n??Li},Ii={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:W3,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"left",padding:{top:0,bottom:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"number",unit:void 0,width:Ib},tX=(t,e)=>t.cartesianAxis.yAxis[e],Ol=(t,e)=>{var n=tX(t,e);return n??Ii},Yye={domain:[0,"auto"],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:"",range:[64,64],scale:"auto",type:"number",unit:""},AD=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??Yye},Ir=(t,e,n)=>{switch(e){case"xAxis":return Dl(t,n);case"yAxis":return Ol(t,n);case"zAxis":return AD(t,n);case"angleAxis":return SD(t,n);case"radiusAxis":return MD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Zye=(t,e,n)=>{switch(e){case"xAxis":return Dl(t,n);case"yAxis":return Ol(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},qb=(t,e,n)=>{switch(e){case"xAxis":return Dl(t,n);case"yAxis":return Ol(t,n);case"angleAxis":return SD(t,n);case"radiusAxis":return MD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},nX=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function TD(t,e){return n=>{switch(t){case"xAxis":return"xAxisId"in n&&n.xAxisId===e;case"yAxis":return"yAxisId"in n&&n.yAxisId===e;case"zAxis":return"zAxisId"in n&&n.zAxisId===e;case"angleAxis":return"angleAxisId"in n&&n.angleAxisId===e;case"radiusAxis":return"radiusAxisId"in n&&n.radiusAxisId===e;default:return!1}}}var Kb=t=>t.graphicalItems.cartesianItems,Qye=Qe([jr,Wb],TD),ND=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Xb=Qe([Kb,Ir,Qye],ND,{memoizeOptions:{resultEqualityCheck:IM}}),rX=Qe([Xb],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(OM)),iX=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),Jye=Qe([Xb],iX),CD=t=>t.map(e=>e.data).filter(Boolean).flat(1),eve=Qe([Xb],CD,{memoizeOptions:{resultEqualityCheck:IM}}),kD=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},PD=Qe([eve,Vb],kD),jD=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:Zn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:Zn(i,r)}))):t.map(r=>({value:r})),FM=Qe([PD,Ir,Xb],jD);function aX(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function x1(t){if(go(t)||t instanceof Date){var e=Number(t);if(Qn(e))return e}}function E8(t){if(Array.isArray(t)){var e=[x1(t[0]),x1(t[1])];return vd(e)?e:void 0}var n=x1(t);if(n!=null)return[n,n]}function qc(t){return t.map(x1).filter(Zhe)}function tve(t,e,n){return!n||typeof e!="number"||ss(e)?[]:n.length?qc(n.flatMap(r=>{var i=Zn(t,r.dataKey),a,s;if(Array.isArray(i)?[a,s]=i:a=s=i,!(!Qn(a)||!Qn(s)))return[e-a,e+s]})):[]}var Ci=t=>{var e=Ni(t),n=mg(t);return qb(t,e,n)},Yb=Qe([Ci],t=>t?.dataKey),nve=Qe([rX,Vb,Ci],JK),sX=(t,e,n,r)=>{var i={},a=e.reduce((s,l)=>(l.stackId==null||(s[l.stackId]==null&&(s[l.stackId]=[]),s[l.stackId].push(l)),s),i);return Object.fromEntries(Object.entries(a).map(s=>{var[l,c]=s,u=r?[...c].reverse():c,d=u.map(DM);return[l,{stackedData:_pe(t,d,n),graphicalItems:u}]}))},Y0=Qe([nve,rX,Gb,WK],sX),oX=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var s=Epe(t,i,a);if(!(s!=null&&s[0]===0&&s[1]===0))return s}},rve=Qe([Ir],t=>t.allowDataOverflow),RD=t=>{var e;if(t==null||!("domain"in t))return W3;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=qc(t.ticks);return[Math.min(...n),Math.max(...n)]}if(t.type==="category")return t.ticks.map(String)}return(e=t?.domain)!==null&&e!==void 0?e:W3},DD=Qe([Ir],RD),OD=Qe([DD,rve],kK),ive=Qe([Y0,Dd,jr,OD],oX,{memoizeOptions:{resultEqualityCheck:LM}}),UM=t=>t.errorBars,ave=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>aX(n,r)),Aw=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=n.filter(Boolean);if(i.length!==0){var a=i.flat(),s=Math.min(...a),l=Math.max(...a);return[s,l]}},LD=(t,e,n,r,i)=>{var a,s;if(n.length>0&&t.forEach(l=>{n.forEach(c=>{var u,d,f=(u=r[c.id])===null||u===void 0?void 0:u.filter(b=>aX(i,b)),g=Zn(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),p=tve(l,g,f);if(p.length>=2){var x=Math.min(...p),v=Math.max(...p);(a==null||x<a)&&(a=x),(s==null||v>s)&&(s=v)}var y=E8(g);y!=null&&(a=a==null?y[0]:Math.min(a,y[0]),s=s==null?y[1]:Math.max(s,y[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=E8(Zn(l,e.dataKey));c!=null&&(a=a==null?c[0]:Math.min(a,c[0]),s=s==null?c[1]:Math.max(s,c[1]))}),Qn(a)&&Qn(s))return[a,s]},sve=Qe([PD,Ir,Jye,UM,jr],LD,{memoizeOptions:{resultEqualityCheck:LM}});function ove(t){var{value:e}=t;if(go(e)||e instanceof Date)return e}var lve=(t,e,n)=>{var r=t.map(ove).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&wW(r))?Xq(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},lX=t=>t.referenceElements.dots,pg=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),cve=Qe([lX,jr,Wb],pg),cX=t=>t.referenceElements.areas,uve=Qe([cX,jr,Wb],pg),uX=t=>t.referenceElements.lines,dve=Qe([uX,jr,Wb],pg),dX=(t,e)=>{var n=qc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},hve=Qe(cve,jr,dX),hX=(t,e)=>{var n=qc(t.flatMap(r=>[e==="xAxis"?r.x1:r.y1,e==="xAxis"?r.x2:r.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},fve=Qe([uve,jr],hX);function mve(t){var e;if(t.x!=null)return qc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:qc(n)}function pve(t){var e;if(t.y!=null)return qc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:qc(n)}var fX=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?mve(r):pve(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},gve=Qe([dve,jr],fX),xve=Qe(hve,gve,fve,(t,e,n)=>Aw(t,n,e)),ID=(t,e,n,r,i,a,s,l)=>{if(n!=null)return n;var c=s==="vertical"&&l==="xAxis"||s==="horizontal"&&l==="yAxis",u=c?Aw(r,a,i):Aw(a,i);return Tye(e,u,t.allowDataOverflow)},bve=Qe([Ir,DD,OD,ive,sve,xve,Sn,jr],ID,{memoizeOptions:{resultEqualityCheck:LM}}),yve=[0,1],FD=(t,e,n,r,i,a,s)=>{if(!((t==null||n==null||n.length===0)&&s===void 0)){var{dataKey:l,type:c}=t,u=Rl(e,a);if(u&&l==null){var d;return Xq(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?lve(r,t,u):i==="expand"?yve:s}},UD=Qe([Ir,Sn,PD,FM,Gb,jr,bve],FD),mX=(t,e,n,r,i)=>{if(t!=null){var{scale:a,type:s}=t;if(a==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":s==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":s==="category"?"band":"linear";if(typeof a=="string"){var l="scale".concat(Pb(a));return l in qx?l:"point"}}},gg=Qe([Ir,Sn,nX,vD,jr],mX);function vve(t){if(t!=null){if(t in qx)return qx[t]();var e="scale".concat(Pb(t));if(e in qx)return qx[e]()}}function zD(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=vve(e);if(i!=null){var a=i.domain(n).range(r);return gpe(a),a}}}var BD=(t,e,n)=>{var r=RD(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&vd(t))return Lye(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&vd(t))return Iye(t,e.tickCount,e.allowDecimals)}},HD=Qe([UD,qb,gg],BD),$D=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&vd(e)&&Array.isArray(n)&&n.length>0){var i=e[0],a=n[0],s=e[1],l=n[n.length-1];return[Math.min(i,a),Math.max(s,l)]}return e},_ve=Qe([Ir,UD,HD,jr],$D),wve=Qe(FM,Ir,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(qc(t.map(l=>l.value))).sort((l,c)=>l-c);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var a=0;a<r.length-1;a++){var s=r[a+1]-r[a];n=Math.min(n,s)}return n/i}}),pX=Qe(wve,Sn,GK,Ei,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!Qn(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var s=_a(n,t*a),l=t*a/2;return l-s-(l-s)/a*s}return 0}),Sve=(t,e)=>{var n=Dl(t,e);return n==null||typeof n.padding!="string"?0:pX(t,"xAxis",e,n.padding)},Mve=(t,e)=>{var n=Ol(t,e);return n==null||typeof n.padding!="string"?0:pX(t,"yAxis",e,n.padding)},Eve=Qe(Dl,Sve,(t,e)=>{var n,r;if(t==null)return{left:0,right:0};var{padding:i}=t;return typeof i=="string"?{left:e,right:e}:{left:((n=i.left)!==null&&n!==void 0?n:0)+e,right:((r=i.right)!==null&&r!==void 0?r:0)+e}}),Ave=Qe(Ol,Mve,(t,e)=>{var n,r;if(t==null)return{top:0,bottom:0};var{padding:i}=t;return typeof i=="string"?{top:e,bottom:e}:{top:((n=i.top)!==null&&n!==void 0?n:0)+e,bottom:((r=i.bottom)!==null&&r!==void 0?r:0)+e}}),Tve=Qe([Ei,Eve,_M,vM,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:a}=r;return i?[a.left,n.width-a.right]:[t.left+e.left,t.left+t.width-e.right]}),Nve=Qe([Ei,Sn,Ave,_M,vM,(t,e,n)=>n],(t,e,n,r,i,a)=>{var{padding:s}=i;return a?[r.height-s.bottom,s.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),Zb=(t,e,n,r)=>{var i;switch(e){case"xAxis":return Tve(t,n,r);case"yAxis":return Nve(t,n,r);case"zAxis":return(i=AD(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return YK(t);case"radiusAxis":return ZK(t,n);default:return}},gX=Qe([Ir,Zb],jM),_d=Qe([Ir,gg,_ve,gX],zD);Qe([Xb,UM,jr],ave);function xX(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var zM=(t,e)=>e,BM=(t,e,n)=>n,Cve=Qe(bM,zM,BM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(xX)),kve=Qe(yM,zM,BM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(xX)),bX=(t,e)=>({width:t.width,height:e.height}),Pve=(t,e)=>{var n=typeof e.width=="number"?e.width:Ib;return{width:n,height:t.height}},yX=Qe(Ei,Dl,bX),jve=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},Rve=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},Dve=Qe(Qc,Ei,Cve,zM,BM,(t,e,n,r,i)=>{var a={},s;return n.forEach(l=>{var c=bX(e,l);s==null&&(s=jve(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;a[l.id]=s-Number(u)*c.height,s+=(u?-1:1)*c.height}),a}),Ove=Qe(Zc,Ei,kve,zM,BM,(t,e,n,r,i)=>{var a={},s;return n.forEach(l=>{var c=Pve(e,l);s==null&&(s=Rve(e,r,t));var u=r==="left"&&!i||r==="right"&&i;a[l.id]=s-Number(u)*c.width,s+=(u?-1:1)*c.width}),a}),Lve=(t,e)=>{var n=Dl(t,e);if(n!=null)return Dve(t,n.orientation,n.mirror)},Ive=Qe([Ei,Dl,Lve,(t,e)=>e],(t,e,n,r)=>{if(e!=null){var i=n?.[r];return i==null?{x:t.left,y:0}:{x:t.left,y:i}}}),Fve=(t,e)=>{var n=Ol(t,e);if(n!=null)return Ove(t,n.orientation,n.mirror)},Uve=Qe([Ei,Ol,Fve,(t,e)=>e],(t,e,n,r)=>{if(e!=null){var i=n?.[r];return i==null?{x:0,y:t.top}:{x:i,y:t.top}}}),vX=Qe(Ei,Ol,(t,e)=>{var n=typeof e.width=="number"?e.width:Ib;return{width:n,height:t.height}}),A8=(t,e,n)=>{switch(e){case"xAxis":return yX(t,n).width;case"yAxis":return vX(t,n).height;default:return}},_X=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:s}=n,l=Rl(t,r),c=e.map(u=>u.value);if(s&&l&&a==="category"&&i&&wW(c))return c}},VD=Qe([Sn,FM,Ir,jr],_X),wX=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,s=Rl(t,r);if(s&&(i==="number"||a!=="auto"))return e.map(l=>l.value)}},GD=Qe([Sn,FM,qb,jr],wX),T8=Qe([Sn,Zye,gg,_d,VD,GD,Zb,HD,jr],(t,e,n,r,i,a,s,l,c)=>{if(e!=null){var u=Rl(t,c);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:c,categoricalDomain:a,duplicateDomain:i,isCategorical:u,niceTicks:l,range:s,realScaleType:n,scale:r}}}),zve=(t,e,n,r,i,a,s,l,c)=>{if(!(e==null||r==null)){var u=Rl(t,c),{type:d,ticks:f,tickCount:g}=e,p=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/p:0;x=c==="angleAxis"&&a!=null&&a.length>=2?Hi(a[0]-a[1])*2*x:x;var v=f||i;if(v){var y=v.map((b,E)=>{var w=s?s.indexOf(b):b;return{index:E,coordinate:r(w)+x,value:b,offset:x}});return y.filter(b=>Qn(b.coordinate))}return u&&l?l.map((b,E)=>({coordinate:r(b)+x,value:b,index:E,offset:x})).filter(b=>Qn(b.coordinate)):r.ticks?r.ticks(g).map(b=>({coordinate:r(b)+x,value:b,offset:x})):r.domain().map((b,E)=>({coordinate:r(b)+x,value:s?s[b]:b,index:E,offset:x}))}},SX=Qe([Sn,qb,gg,_d,HD,Zb,VD,GD,jr],zve),Bve=(t,e,n,r,i,a,s)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=Rl(t,s),{tickCount:c}=e,u=0;return u=s==="angleAxis"&&r?.length>=2?Hi(r[0]-r[1])*2*u:u,l&&a?a.map((d,f)=>({coordinate:n(d)+u,value:d,index:f,offset:u})):n.ticks?n.ticks(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,f)=>({coordinate:n(d)+u,value:i?i[d]:d,index:f,offset:u}))}},Ml=Qe([Sn,qb,_d,Zb,VD,GD,jr],Bve),El=Qe(Ir,_d,(t,e)=>{if(!(t==null||e==null))return Ew(Ew({},t),{},{scale:e})}),Hve=Qe([Ir,gg,UD,gX],zD);Qe((t,e,n)=>AD(t,n),Hve,(t,e)=>{if(!(t==null||e==null))return Ew(Ew({},t),{},{scale:e})});var $ve=Qe([Sn,bM,yM],(t,e,n)=>{switch(t){case"horizontal":return e.some(r=>r.reversed)?"right-to-left":"left-to-right";case"vertical":return n.some(r=>r.reversed)?"bottom-to-top":"top-to-bottom";case"centric":case"radial":return"left-to-right";default:return}}),MX=t=>t.options.defaultTooltipEventType,EX=t=>t.options.validateTooltipEventTypes;function AX(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function WD(t,e){var n=MX(t),r=EX(t);return AX(e,n,r)}function Vve(t){return jt(e=>WD(e,t))}var TX=(t,e)=>{var n,r=Number(e);if(!(ss(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},Gve=t=>t.tooltip.settings,Xu={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},Wve={itemInteraction:{click:Xu,hover:Xu},axisInteraction:{click:Xu,hover:Xu},keyboardInteraction:Xu,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:"hover",axisId:0,active:!1,defaultIndex:void 0}},NX=ls({name:"tooltip",initialState:Wve,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:Nr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ho(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Nr()},removeTooltipEntrySettings:{reducer(t,e){var n=Ho(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:Nr()},setTooltipSettingsState(t,e){t.settings=e.payload},setActiveMouseOverItemIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.itemInteraction.hover.active=!0,t.itemInteraction.hover.index=e.payload.activeIndex,t.itemInteraction.hover.dataKey=e.payload.activeDataKey,t.itemInteraction.hover.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.hover.coordinate=e.payload.activeCoordinate},mouseLeaveChart(t){t.itemInteraction.hover.active=!1,t.axisInteraction.hover.active=!1},mouseLeaveItem(t){t.itemInteraction.hover.active=!1},setActiveClickItemIndex(t,e){t.syncInteraction.active=!1,t.itemInteraction.click.active=!0,t.keyboardInteraction.active=!1,t.itemInteraction.click.index=e.payload.activeIndex,t.itemInteraction.click.dataKey=e.payload.activeDataKey,t.itemInteraction.click.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.click.coordinate=e.payload.activeCoordinate},setMouseOverAxisIndex(t,e){t.syncInteraction.active=!1,t.axisInteraction.hover.active=!0,t.keyboardInteraction.active=!1,t.axisInteraction.hover.index=e.payload.activeIndex,t.axisInteraction.hover.dataKey=e.payload.activeDataKey,t.axisInteraction.hover.coordinate=e.payload.activeCoordinate},setMouseClickAxisIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.axisInteraction.click.active=!0,t.axisInteraction.click.index=e.payload.activeIndex,t.axisInteraction.click.dataKey=e.payload.activeDataKey,t.axisInteraction.click.coordinate=e.payload.activeCoordinate},setSyncInteraction(t,e){t.syncInteraction=e.payload},setKeyboardInteraction(t,e){t.keyboardInteraction.active=e.payload.active,t.keyboardInteraction.index=e.payload.activeIndex,t.keyboardInteraction.coordinate=e.payload.activeCoordinate,t.keyboardInteraction.dataKey=e.payload.activeDataKey}}}),{addTooltipEntrySettings:qve,replaceTooltipEntrySettings:Kve,removeTooltipEntrySettings:Xve,setTooltipSettingsState:Yve,setActiveMouseOverItemIndex:CX,mouseLeaveItem:Zve,mouseLeaveChart:kX,setActiveClickItemIndex:Qve,setMouseOverAxisIndex:PX,setMouseClickAxisIndex:Jve,setSyncInteraction:q3,setKeyboardInteraction:K3}=NX.actions,e_e=NX.reducer;function N8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function $v(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?N8(Object(n),!0).forEach(function(r){t_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):N8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function t_e(t,e,n){return(e=n_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n_e(t){var e=r_e(t,"string");return typeof e=="symbol"?e:e+""}function r_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function i_e(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function a_e(t){return t.index!=null}var jX=(t,e,n,r)=>{if(e==null)return Xu;var i=i_e(t,e,n);if(i==null)return Xu;if(i.active)return i;if(t.keyboardInteraction.active)return t.keyboardInteraction;if(t.syncInteraction.active&&t.syncInteraction.index!=null)return t.syncInteraction;var a=t.settings.active===!0;if(a_e(i)){if(a)return $v($v({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return $v($v({},Xu),{},{coordinate:i.coordinate})};function s_e(t){if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(t instanceof Date){var e=t.valueOf();return Number.isFinite(e)?e:void 0}var n=Number(t);return Number.isFinite(n)?n:void 0}function o_e(t,e){var n=s_e(t),r=e[0],i=e[1];if(n===void 0)return!1;var a=Math.min(r,i),s=Math.max(r,i);return n>=a&&n<=s}function l_e(t,e,n){if(n==null||e==null)return!0;var r=Zn(t,e);return r==null||!vd(n)?!0:o_e(r,n)}var qD=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!Qn(a))return i;var s=0,l=1/0;e.length>0&&(l=e.length-1);var c=Math.max(s,Math.min(a,l)),u=e[c];return u==null||l_e(u,n,r)?String(c):null},RX=(t,e,n,r,i,a,s,l)=>{if(!(a==null||l==null)){var c=s[0],u=c==null?void 0:l(c.positions,a);if(u!=null)return u;var d=i?.[Number(a)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},DX=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=t.itemInteraction.hover.dataKey:i=t.itemInteraction.click.dataKey,i==null&&r!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(a=>{var s;return((s=a.settings)===null||s===void 0?void 0:s.dataKey)===i})},Qb=t=>t.options.tooltipPayloadSearcher,xg=t=>t.tooltip;function C8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function k8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?C8(Object(n),!0).forEach(function(r){c_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function c_e(t,e,n){return(e=u_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u_e(t){var e=d_e(t,"string");return typeof e=="symbol"?e:e+""}function d_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function h_e(t,e){return t??e}var OX=(t,e,n,r,i,a,s)=>{if(!(e==null||a==null)){var{chartData:l,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((g,p)=>{var x,{dataDefinedOnItem:v,settings:y}=p,b=h_e(v,l),E=Array.isArray(b)?xq(b,u,d):b,w=(x=y?.dataKey)!==null&&x!==void 0?x:r,A=y?.nameKey,T;if(r&&Array.isArray(E)&&!Array.isArray(E[0])&&s==="axis"?T=SW(E,r,i):T=a(E,e,c,A),Array.isArray(T))T.forEach(N=>{var O=k8(k8({},y),{},{name:N.name,unit:N.unit,color:void 0,fill:void 0});g.push(Yz({tooltipEntrySettings:O,dataKey:N.dataKey,payload:N.payload,value:Zn(N.payload,N.dataKey),name:N.name}))});else{var C;g.push(Yz({tooltipEntrySettings:y,dataKey:w,payload:T,value:Zn(T,w),name:(C=Zn(T,A))!==null&&C!==void 0?C:y?.name}))}return g},f)}},KD=Qe([Ci,Sn,nX,vD,Ni],mX),f_e=Qe([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),m_e=Qe([Ni,mg],TD),Jb=Qe([f_e,Ci,m_e],ND,{memoizeOptions:{resultEqualityCheck:IM}}),p_e=Qe([Jb],t=>t.filter(OM)),g_e=Qe([Jb],CD,{memoizeOptions:{resultEqualityCheck:IM}}),bg=Qe([g_e,Dd],kD),x_e=Qe([p_e,Dd,Ci],JK),XD=Qe([bg,Ci,Jb],jD),LX=Qe([Ci],RD),b_e=Qe([Ci],t=>t.allowDataOverflow),IX=Qe([LX,b_e],kK),y_e=Qe([Jb],t=>t.filter(OM)),v_e=Qe([x_e,y_e,Gb,WK],sX),__e=Qe([v_e,Dd,Ni,IX],oX),w_e=Qe([Jb],iX),S_e=Qe([bg,Ci,w_e,UM,Ni],LD,{memoizeOptions:{resultEqualityCheck:LM}}),M_e=Qe([lX,Ni,mg],pg),E_e=Qe([M_e,Ni],dX),A_e=Qe([cX,Ni,mg],pg),T_e=Qe([A_e,Ni],hX),N_e=Qe([uX,Ni,mg],pg),C_e=Qe([N_e,Ni],fX),k_e=Qe([E_e,C_e,T_e],Aw),P_e=Qe([Ci,LX,IX,__e,S_e,k_e,Sn,Ni],ID),ey=Qe([Ci,Sn,bg,XD,Gb,Ni,P_e],FD),j_e=Qe([ey,Ci,KD],BD),R_e=Qe([Ci,ey,j_e,Ni],$D),FX=t=>{var e=Ni(t),n=mg(t),r=!1;return Zb(t,e,n,r)},UX=Qe([Ci,FX],jM),zX=Qe([Ci,KD,R_e,UX],zD),D_e=Qe([Sn,XD,Ci,Ni],_X),O_e=Qe([Sn,XD,Ci,Ni],wX),L_e=(t,e,n,r,i,a,s,l)=>{if(e){var{type:c}=e,u=Rl(t,l);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=l==="angleAxis"&&i!=null&&i?.length>=2?Hi(i[0]-i[1])*2*f:f,u&&s?s.map((g,p)=>({coordinate:r(g)+f,value:g,index:p,offset:f})):r.domain().map((g,p)=>({coordinate:r(g)+f,value:a?a[g]:g,index:p,offset:f}))}}},eu=Qe([Sn,Ci,KD,zX,FX,D_e,O_e,Ni],L_e),YD=Qe([MX,EX,Gve],(t,e,n)=>AX(n.shared,t,e)),BX=t=>t.tooltip.settings.trigger,ZD=t=>t.tooltip.settings.defaultIndex,ty=Qe([xg,YD,BX,ZD],jX),wd=Qe([ty,bg,Yb,ey],qD),HX=Qe([eu,wd],TX),QD=Qe([ty],t=>{if(t)return t.dataKey}),I_e=Qe([ty],t=>{if(t)return t.graphicalItemId}),$X=Qe([xg,YD,BX,ZD],DX),F_e=Qe([Zc,Qc,Sn,Ei,eu,ZD,$X,Qb],RX),U_e=Qe([ty,F_e],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),z_e=Qe([ty],t=>t.active),B_e=Qe([$X,wd,Dd,Yb,HX,Qb,YD],OX),H_e=Qe([B_e],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function P8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function j8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P8(Object(n),!0).forEach(function(r){$_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $_e(t,e,n){return(e=V_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function V_e(t){var e=G_e(t,"string");return typeof e=="symbol"?e:e+""}function G_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var W_e=()=>jt(Ci),q_e=()=>{var t=W_e(),e=jt(eu),n=jt(zX);return yd(!t||!n?void 0:j8(j8({},t),{},{scale:n}),e)};function R8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function hm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?R8(Object(n),!0).forEach(function(r){K_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function K_e(t,e,n){return(e=X_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function X_e(t){var e=Y_e(t,"string");return typeof e=="symbol"?e:e+""}function Y_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Z_e=(t,e,n,r)=>{var i=e.find(a=>a&&a.index===n);if(i){if(t==="horizontal")return{x:i.coordinate,y:r.chartY};if(t==="vertical")return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},Q_e=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var a=i.coordinate,{radius:s}=r;return hm(hm(hm({},r),ui(r.cx,r.cy,s,a)),{},{angle:a,radius:s})}var l=i.coordinate,{angle:c}=r;return hm(hm(hm({},r),ui(r.cx,r.cy,l,c)),{},{angle:c,radius:l})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function J_e(t,e){var{chartX:n,chartY:r}=t;return n>=e.left&&n<=e.left+e.width&&r>=e.top&&r<=e.top+e.height}var VX=(t,e,n,r,i)=>{var a,s=-1,l=(a=e?.length)!==null&&a!==void 0?a:0;if(l<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c<l;c++){var u=c>0?n[c-1].coordinate:n[l-1].coordinate,d=n[c].coordinate,f=c>=l-1?n[0].coordinate:n[c+1].coordinate,g=void 0;if(Hi(d-u)!==Hi(f-d)){var p=[];if(Hi(f-d)===Hi(i[1]-i[0])){g=f;var x=d+i[1]-i[0];p[0]=Math.min(x,(x+u)/2),p[1]=Math.max(x,(x+u)/2)}else{g=u;var v=f+i[1]-i[0];p[0]=Math.min(d,(v+d)/2),p[1]=Math.max(d,(v+d)/2)}var y=[Math.min(d,(g+d)/2),Math.max(d,(g+d)/2)];if(t>y[0]&&t<=y[1]||t>=p[0]&&t<=p[1]){({index:s}=n[c]);break}}else{var b=Math.min(u,f),E=Math.max(u,f);if(t>(b+d)/2&&t<=(E+d)/2){({index:s}=n[c]);break}}}else if(e){for(var w=0;w<l;w++)if(w===0&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w>0&&w<l-1&&t>(e[w].coordinate+e[w-1].coordinate)/2&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w===l-1&&t>(e[w].coordinate+e[w-1].coordinate)/2){({index:s}=e[w]);break}}return s},GX=()=>jt(vD),JD=(t,e)=>e,WX=(t,e,n)=>n,eO=(t,e,n,r)=>r,e1e=Qe(eu,t=>cM(t,e=>e.coordinate)),tO=Qe([xg,JD,WX,eO],jX),nO=Qe([tO,bg,Yb,ey],qD),t1e=(t,e,n)=>{if(e!=null){var r=xg(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},qX=Qe([xg,JD,WX,eO],DX),Tw=Qe([Zc,Qc,Sn,Ei,eu,eO,qX,Qb],RX),n1e=Qe([tO,Tw],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),KX=Qe([eu,nO],TX),r1e=Qe([qX,nO,Dd,Yb,KX,Qb,JD],OX),i1e=Qe([tO,nO],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),a1e=(t,e,n,r,i,a,s)=>{if(!(!t||!n||!r||!i)&&J_e(t,s)){var l=Ape(t,e),c=VX(l,a,i,n,r),u=Z_e(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},s1e=(t,e,n,r,i,a,s)=>{if(!(!t||!r||!i||!a||!n)){var l=$xe(t,n);if(l){var c=Tpe(l,e),u=VX(c,s,a,r,i),d=Q_e(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},o1e=(t,e,n,r,i,a,s,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?a1e(t,e,r,i,a,s,l):s1e(t,e,n,r,i,a,s)},l1e=Qe(t=>t.zIndex.zIndexMap,(t,e)=>e,(t,e,n)=>n,(t,e,n)=>{if(e!=null){var r=t[e];if(r!=null)return n?r.panoramaElementId:r.elementId}}),c1e=Qe(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Gr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:Wye}});function D8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function O8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?D8(Object(n),!0).forEach(function(r){u1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):D8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function u1e(t,e,n){return(e=d1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function d1e(t){var e=h1e(t,"string");return typeof e=="symbol"?e:e+""}function h1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var f1e={},m1e={zIndexMap:Object.values(Gr).reduce((t,e)=>O8(O8({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),f1e)},p1e=new Set(Object.values(Gr));function g1e(t){return p1e.has(t)}var XX=ls({name:"zIndex",initialState:m1e,reducers:{registerZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]?t.zIndexMap[n].consumers+=1:t.zIndexMap[n]={consumers:1,elementId:void 0,panoramaElementId:void 0}},prepare:Nr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!g1e(n)&&delete t.zIndexMap[n])},prepare:Nr()},registerZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n,elementId:r,isPanorama:i}=e.payload;t.zIndexMap[n]?i?t.zIndexMap[n].panoramaElementId=r:t.zIndexMap[n].elementId=r:t.zIndexMap[n]={consumers:0,elementId:i?void 0:r,panoramaElementId:i?r:void 0}},prepare:Nr()},unregisterZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(e.payload.isPanorama?t.zIndexMap[n].panoramaElementId=void 0:t.zIndexMap[n].elementId=void 0)},prepare:Nr()}}}),{registerZIndexPortal:x1e,unregisterZIndexPortal:b1e,registerZIndexPortalId:y1e,unregisterZIndexPortalId:v1e}=XX.actions,_1e=XX.reducer;function wa(t){var{zIndex:e,children:n}=t,r=age(),i=r&&e!==void 0&&e!==0,a=Ai(),s=gr();S.useLayoutEffect(()=>i?(s(x1e({zIndex:e})),()=>{s(b1e({zIndex:e}))}):jb,[s,e,i]);var l=jt(u=>l1e(u,e,a));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?Mc.createPortal(n,c):null}function X3(){return X3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},X3.apply(null,arguments)}function L8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Vv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?L8(Object(n),!0).forEach(function(r){w1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function w1e(t,e,n){return(e=S1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function S1e(t){var e=M1e(t,"string");return typeof e=="symbol"?e:e+""}function M1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function E1e(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return S.isValidElement(e)?S.cloneElement(e,r):S.createElement(n,r)}function A1e(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:s,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,g=r,p=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,v,y;if(d==="ScatterChart")x=f,v=ixe,y=Gr.cursorLine;else if(d==="BarChart")x=axe(l,f,a,s),v=Vq,y=Gr.cursorRectangle;else if(l==="radial"&&EW(f)){var{cx:b,cy:E,radius:w,startAngle:A,endAngle:T}=Wq(f);x={cx:b,cy:E,startAngle:A,endAngle:T,innerRadius:w,outerRadius:w},v=Kq,y=Gr.cursorLine}else x={points:qxe(l,f,a)},v=fp,y=Gr.cursorLine;var C=typeof c=="object"&&"className"in c?c.className:void 0,N=Vv(Vv(Vv(Vv({stroke:"#ccc",pointerEvents:"none"},a),x),of(c)),{},{payload:g,payloadIndex:p,className:Pn("recharts-tooltip-cursor",C)});return S.createElement(wa,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:y},S.createElement(E1e,{cursor:c,cursorComp:v,cursorProps:N}))}function T1e(t){var e=q_e(),n=Nq(),r=Ef(),i=GX();return e==null||n==null||r==null||i==null?null:S.createElement(A1e,X3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var YX=S.createContext(null),N1e=()=>S.useContext(YX),hN={exports:{}},I8;function C1e(){return I8||(I8=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function a(c,u,d,f,g){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new i(d,f||c,g),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],p]:c._events[x].push(p):(c._events[x]=p,c._eventsCount++),c}function s(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function l(){this._events=new r,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)e.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var g=0,p=f.length,x=new Array(p);g<p;g++)x[g]=f[g].fn;return x},l.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},l.prototype.emit=function(u,d,f,g,p,x){var v=n?n+u:u;if(!this._events[v])return!1;var y=this._events[v],b=arguments.length,E,w;if(y.fn){switch(y.once&&this.removeListener(u,y.fn,void 0,!0),b){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,d),!0;case 3:return y.fn.call(y.context,d,f),!0;case 4:return y.fn.call(y.context,d,f,g),!0;case 5:return y.fn.call(y.context,d,f,g,p),!0;case 6:return y.fn.call(y.context,d,f,g,p,x),!0}for(w=1,E=new Array(b-1);w<b;w++)E[w-1]=arguments[w];y.fn.apply(y.context,E)}else{var A=y.length,T;for(w=0;w<A;w++)switch(y[w].once&&this.removeListener(u,y[w].fn,void 0,!0),b){case 1:y[w].fn.call(y[w].context);break;case 2:y[w].fn.call(y[w].context,d);break;case 3:y[w].fn.call(y[w].context,d,f);break;case 4:y[w].fn.call(y[w].context,d,f,g);break;default:if(!E)for(T=1,E=new Array(b-1);T<b;T++)E[T-1]=arguments[T];y[w].fn.apply(y[w].context,E)}}return!0},l.prototype.on=function(u,d,f){return a(this,u,d,f,!1)},l.prototype.once=function(u,d,f){return a(this,u,d,f,!0)},l.prototype.removeListener=function(u,d,f,g){var p=n?n+u:u;if(!this._events[p])return this;if(!d)return s(this,p),this;var x=this._events[p];if(x.fn)x.fn===d&&(!g||x.once)&&(!f||x.context===f)&&s(this,p);else{for(var v=0,y=[],b=x.length;v<b;v++)(x[v].fn!==d||g&&!x[v].once||f&&x[v].context!==f)&&y.push(x[v]);y.length?this._events[p]=y.length===1?y[0]:y:s(this,p)}return this},l.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&s(this,d)):(this._events=new r,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=n,l.EventEmitter=l,t.exports=l})(hN)),hN.exports}var k1e=C1e();const P1e=yo(k1e);var Z0=new P1e,Y3="recharts.syncEvent.tooltip",F8="recharts.syncEvent.brush";function HM(t,e){if(e){var n=Number.parseInt(e,10);if(!ss(n))return t?.[n]}}var j1e={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},ZX=ls({name:"options",initialState:j1e,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),R1e=ZX.reducer,{createEventEmitter:D1e}=ZX.actions;function O1e(t){return t.tooltip.syncInteraction}var L1e={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},QX=ls({name:"chartData",initialState:L1e,reducers:{setChartData(t,e){if(t.chartData=e.payload,e.payload==null){t.dataStartIndex=0,t.dataEndIndex=0;return}e.payload.length>0&&t.dataEndIndex!==e.payload.length-1&&(t.dataEndIndex=e.payload.length-1)},setComputedData(t,e){t.computedData=e.payload},setDataStartEndIndexes(t,e){var{startIndex:n,endIndex:r}=e.payload;n!=null&&(t.dataStartIndex=n),r!=null&&(t.dataEndIndex=r)}}}),{setChartData:U8,setDataStartEndIndexes:I1e,setComputedData:YWe}=QX.actions,F1e=QX.reducer,U1e=["x","y"];function z8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function fm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?z8(Object(n),!0).forEach(function(r){z1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):z8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function z1e(t,e,n){return(e=B1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function B1e(t){var e=H1e(t,"string");return typeof e=="symbol"?e:e+""}function H1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function $1e(t,e){if(t==null)return{};var n,r,i=V1e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function V1e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function G1e(){var t=jt(_D),e=jt(wD),n=gr(),r=jt(qK),i=jt(eu),a=Ef(),s=Fb(),l=jt(c=>c.rootProps.className);S.useEffect(()=>{if(t==null)return jb;var c=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var g;if(s&&d!==null&&d!==void 0&&(g=d.payload)!==null&&g!==void 0&&g.coordinate&&d.payload.sourceViewBox){var p=d.payload.coordinate,{x,y:v}=p,y=$1e(p,U1e),{x:b,y:E,width:w,height:A}=d.payload.sourceViewBox,T=fm(fm({},y),{},{x:s.x+(w?(x-b)/w:0)*s.width,y:s.y+(A?(v-E)/A:0)*s.height});n(fm(fm({},d),{},{payload:fm(fm({},d.payload),{},{coordinate:T})}))}else n(d);return}if(i!=null){var C;if(typeof r=="function"){var N={activeTooltipIndex:d.payload.index==null?void 0:Number(d.payload.index),isTooltipActive:d.payload.active,activeIndex:d.payload.index==null?void 0:Number(d.payload.index),activeLabel:d.payload.label,activeDataKey:d.payload.dataKey,activeCoordinate:d.payload.coordinate},O=r(i,N);C=i[O]}else r==="value"&&(C=i.find(W=>String(W.value)===d.payload.label));var{coordinate:k}=d.payload;if(C==null||d.payload.active===!1||k==null||s==null){n(q3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:j,y:B}=k,L=Math.min(j,s.x+s.width),K=Math.min(B,s.y+s.height),R={x:a==="horizontal"?C.coordinate:L,y:a==="horizontal"?K:C.coordinate},q=q3({active:d.payload.active,coordinate:R,dataKey:d.payload.dataKey,index:String(C.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(q)}}};return Z0.on(Y3,c),()=>{Z0.off(Y3,c)}},[l,n,e,t,r,i,a,s])}function W1e(){var t=jt(_D),e=jt(wD),n=gr();S.useEffect(()=>{if(t==null)return jb;var r=(i,a,s)=>{e!==s&&t===i&&n(I1e(a))};return Z0.on(F8,r),()=>{Z0.off(F8,r)}},[n,e,t])}function q1e(){var t=gr();S.useEffect(()=>{t(D1e())},[t]),G1e(),W1e()}function K1e(t,e,n,r,i,a){var s=jt(p=>t1e(p,t,e)),l=jt(wD),c=jt(_D),u=jt(qK),d=jt(O1e),f=d?.active,g=Fb();S.useEffect(()=>{if(!f&&c!=null&&l!=null){var p=q3({active:a,coordinate:n,dataKey:s,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});Z0.emit(Y3,c,p,l)}},[f,n,s,i,r,l,c,u,a,g])}function B8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function H8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?B8(Object(n),!0).forEach(function(r){X1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function X1e(t,e,n){return(e=Y1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Y1e(t){var e=Z1e(t,"string");return typeof e=="symbol"?e:e+""}function Z1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Q1e(t){return t.dataKey}function J1e(t,e){return S.isValidElement(t)?S.cloneElement(t,e):typeof t=="function"?S.createElement(t,e):S.createElement(Ige,e)}var $8=[],ewe={allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",axisId:0,contentStyle:{},cursor:!0,filterNull:!0,isAnimationActive:"auto",itemSorter:"name",itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,wrapperStyle:{}};function b1(t){var e,n,r=Lr(t,ewe),{active:i,allowEscapeViewBox:a,animationDuration:s,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:g,position:p,reverseDirection:x,useTranslate3d:v,wrapperStyle:y,cursor:b,shared:E,trigger:w,defaultIndex:A,portal:T,axisId:C}=r,N=gr(),O=typeof A=="number"?String(A):A;S.useEffect(()=>{N(Yve({shared:E,trigger:w,axisId:C,active:i,defaultIndex:O}))},[N,E,w,C,i,O]);var k=Fb(),j=Uq(),B=Vve(E),{activeIndex:L,isActive:K}=(e=jt(ge=>i1e(ge,B,w,O)))!==null&&e!==void 0?e:{},R=jt(ge=>r1e(ge,B,w,O)),q=jt(ge=>KX(ge,B,w,O)),W=jt(ge=>n1e(ge,B,w,O)),$=R,J=N1e(),ee=(n=i??K)!==null&&n!==void 0?n:!1,[Q,z]=BW([$,ee]),V=B==="axis"?q:void 0;K1e(B,w,W,V,L,ee);var X=T??J;if(X==null||k==null||B==null)return null;var te=$??$8;ee||(te=$8),u&&te.length&&(te=OW(te.filter(ge=>ge.value!=null&&(ge.hide!==!0||r.includeHidden)),g,Q1e));var ie=te.length>0,le=S.createElement(Vge,{allowEscapeViewBox:a,animationDuration:s,animationEasing:l,isAnimationActive:d,active:ee,coordinate:W,hasPayload:ie,offset:f,position:p,reverseDirection:x,useTranslate3d:v,viewBox:k,wrapperStyle:y,lastBoundingBox:Q,innerRef:z,hasPortalFromProps:!!T},J1e(c,H8(H8({},r),{},{payload:te,label:V,active:ee,activeIndex:L,coordinate:W,accessibilityLayer:j})));return S.createElement(S.Fragment,null,Mc.createPortal(le,X),ee&&S.createElement(T1e,{cursor:b,tooltipEventType:B,coordinate:W,payload:te,index:L}))}var ny=t=>null;ny.displayName="Cell";function twe(t,e,n){return(e=nwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nwe(t){var e=rwe(t,"string");return typeof e=="symbol"?e:e+""}function rwe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class iwe{constructor(e){twe(this,"cache",new Map),this.maxSize=e}get(e){var n=this.cache.get(e);return n!==void 0&&(this.cache.delete(e),this.cache.set(e,n)),n}set(e,n){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){var r=this.cache.keys().next().value;r!=null&&this.cache.delete(r)}this.cache.set(e,n)}clear(){this.cache.clear()}size(){return this.cache.size}}function V8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function awe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?V8(Object(n),!0).forEach(function(r){swe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):V8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function swe(t,e,n){return(e=owe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function owe(t){var e=lwe(t,"string");return typeof e=="symbol"?e:e+""}function lwe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var cwe={cacheSize:2e3,enableCache:!0},JX=awe({},cwe),G8=new iwe(JX.cacheSize),uwe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},W8="recharts_measurement_span";function dwe(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",a=e.fontStyle||"",s=e.letterSpacing||"",l=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(a,"|").concat(s,"|").concat(l)}var q8=(t,e)=>{try{var n=document.getElementById(W8);n||(n=document.createElement("span"),n.setAttribute("id",W8),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,uwe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},l0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||lg.isSsr)return{width:0,height:0};if(!JX.enableCache)return q8(e,n);var r=dwe(e,n),i=G8.get(r);if(i)return i;var a=q8(e,n);return G8.set(r,a),a},K8=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,X8=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,hwe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,fwe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,eY={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},mwe=Object.keys(eY),sp="NaN";function pwe(t,e){return t*eY[e]}class Za{static parse(e){var n,[,r,i]=(n=fwe.exec(e))!==null&&n!==void 0?n:[];return new Za(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,ss(e)&&(this.unit=""),n!==""&&!hwe.test(n)&&(this.num=NaN,this.unit=""),mwe.includes(n)&&(this.num=pwe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Za(NaN,""):new Za(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Za(NaN,""):new Za(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Za(NaN,""):new Za(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Za(NaN,""):new Za(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return ss(this.num)}}function tY(t){if(t.includes(sp))return sp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=K8.exec(e))!==null&&n!==void 0?n:[],s=Za.parse(r??""),l=Za.parse(a??""),c=i==="*"?s.multiply(l):s.divide(l);if(c.isNaN())return sp;e=e.replace(K8,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,g]=(u=X8.exec(e))!==null&&u!==void 0?u:[],p=Za.parse(d??""),x=Za.parse(g??""),v=f==="+"?p.add(x):p.subtract(x);if(v.isNaN())return sp;e=e.replace(X8,v.toString())}return e}var Y8=/\(([^()]*)\)/;function gwe(t){for(var e=t,n;(n=Y8.exec(e))!=null;){var[,r]=n;e=e.replace(Y8,tY(r))}return e}function xwe(t){var e=t.replace(/\s+/g,"");return e=gwe(e),e=tY(e),e}function bwe(t){try{return xwe(t)}catch{return sp}}function fN(t){var e=bwe(t.slice(5,-1));return e===sp?"":e}var ywe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],vwe=["dx","dy","angle","className","breakAll"];function Z3(){return Z3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Z3.apply(null,arguments)}function Z8(t,e){if(t==null)return{};var n,r,i=_we(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function _we(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var nY=/[ \f\n\r\t\v\u2028\u2029]+/,rY=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Er(e)||(n?i=e.toString().split(""):i=e.toString().split(nY));var a=i.map(l=>({word:l,width:l0(l,r).width})),s=n?0:l0(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:s}}catch{return null}};function wwe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var iY=(t,e,n,r)=>t.reduce((i,a)=>{var{word:s,width:l}=a,c=i[i.length-1];if(c&&l!=null&&(e==null||r||c.width+l+n<Number(e)))c.words.push(s),c.width+=l+n;else{var u={words:[s],width:l};i.push(u)}return i},[]),aY=t=>t.reduce((e,n)=>e.width>n.width?e:n),Swe="…",Q8=(t,e,n,r,i,a,s,l)=>{var c=t.slice(0,e),u=rY({breakAll:n,style:r,children:c+Swe});if(!u)return[!1,[]];var d=iY(u.wordsWithComputedWidth,a,s,l),f=d.length>i||aY(d).width>Number(a);return[f,d]},Mwe=(t,e,n,r,i)=>{var{maxLines:a,children:s,style:l,breakAll:c}=t,u=Dt(a),d=String(s),f=iY(e,r,n,i);if(!u||i)return f;var g=f.length>a||aY(f).width>Number(r);if(!g)return f;for(var p=0,x=d.length-1,v=0,y;p<=x&&v<=d.length-1;){var b=Math.floor((p+x)/2),E=b-1,[w,A]=Q8(d,E,c,l,a,r,n,i),[T]=Q8(d,b,c,l,a,r,n,i);if(!w&&!T&&(p=b+1),w&&T&&(x=b-1),!w&&T){y=A;break}v++}return y||f},J8=t=>{var e=Er(t)?[]:t.toString().split(nY);return[{words:e,width:void 0}]},Ewe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:s}=t;if((e||n)&&!lg.isSsr){var l,c,u=rY({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return J8(r);return Mwe({breakAll:a,children:r,maxLines:s,style:i},l,c,e,!!n)}return J8(r)},sY="#808080",Awe={angle:0,breakAll:!1,capHeight:"0.71em",fill:sY,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},$M=S.forwardRef((t,e)=>{var n=Lr(t,Awe),{x:r,y:i,lineHeight:a,capHeight:s,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=Z8(n,ywe),g=S.useMemo(()=>Ewe({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:p,dy:x,angle:v,className:y,breakAll:b}=f,E=Z8(f,vwe);if(!go(r)||!go(i)||g.length===0)return null;var w=Number(r)+(Dt(p)?p:0),A=Number(i)+(Dt(x)?x:0);if(!Qn(w)||!Qn(A))return null;var T;switch(d){case"start":T=fN("calc(".concat(s,")"));break;case"middle":T=fN("calc(".concat((g.length-1)/2," * -").concat(a," + (").concat(s," / 2))"));break;default:T=fN("calc(".concat(g.length-1," * -").concat(a,")"));break}var C=[];if(c){var N=g[0].width,{width:O}=f;C.push("scale(".concat(Dt(O)&&Dt(N)?O/N:1,")"))}return v&&C.push("rotate(".concat(v,", ").concat(w,", ").concat(A,")")),C.length&&(E.transform=C.join(" ")),S.createElement("text",Z3({},ua(E),{ref:e,x:w,y:A,className:Pn("recharts-text",y),textAnchor:u,fill:l.includes("url")?sY:l}),g.map((k,j)=>{var B=k.words.join(b?"":" ");return S.createElement("tspan",{x:w,dy:j===0?T:a,key:"".concat(B,"-").concat(j)},B)}))});$M.displayName="Text";var Twe=["labelRef"];function Nwe(t,e){if(t==null)return{};var n,r,i=Cwe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Cwe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function e6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Zr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?e6(Object(n),!0).forEach(function(r){kwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function kwe(t,e,n){return(e=Pwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Pwe(t){var e=jwe(t,"string");return typeof e=="symbol"?e:e+""}function jwe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function _c(){return _c=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_c.apply(null,arguments)}var oY=S.createContext(null),lY=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:s,children:l}=t,c=S.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:s}),[e,n,r,i,a,s]);return S.createElement(oY.Provider,{value:c},l)},cY=()=>{var t=S.useContext(oY),e=Fb();return t||Tq(e)},Rwe=S.createContext(null),Dwe=()=>{var t=S.useContext(Rwe),e=jt(QK);return t||e},Owe=t=>{var{value:e,formatter:n}=t,r=Er(t.children)?e:t.children;return typeof n=="function"?n(r):r},rO=t=>t!=null&&typeof t=="function",Lwe=(t,e)=>{var n=Hi(e-t),r=Math.min(Math.abs(e-t),360);return n*r},Iwe=(t,e,n,r,i)=>{var{offset:a,className:s}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:g,clockWise:p}=i,x=(u+d)/2,v=Lwe(f,g),y=v>=0?1:-1,b,E;switch(e){case"insideStart":b=f+y*a,E=p;break;case"insideEnd":b=g-y*a,E=!p;break;case"end":b=g+y*a,E=p;break;default:throw new Error("Unsupported position ".concat(e))}E=v<=0?E:!E;var w=ui(l,c,x,b),A=ui(l,c,x,b+(E?1:-1)*359),T="M".concat(w.x,",").concat(w.y,`
- A`).concat(x,",").concat(x,",0,1,").concat(E?0:1,`,
- `).concat(A.x,",").concat(A.y),C=Er(t.id)?I0("recharts-radial-line-"):t.id;return S.createElement("text",_c({},r,{dominantBaseline:"central",className:Pn("recharts-radial-bar-label",s)}),S.createElement("defs",null,S.createElement("path",{id:C,d:T})),S.createElement("textPath",{xlinkHref:"#".concat(C)},n))},Fwe=(t,e,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:s,startAngle:l,endAngle:c}=t,u=(l+c)/2;if(n==="outside"){var{x:d,y:f}=ui(r,i,s+e,u);return{x:d,y:f,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var g=(a+s)/2,{x:p,y:x}=ui(r,i,g,u);return{x:p,y:x,textAnchor:"middle",verticalAnchor:"middle"}},Q3=t=>"cx"in t&&Dt(t.cx),Uwe=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!Q3(n)&&(a=n);var{x:s,y:l,upperWidth:c,lowerWidth:u,height:d}=e,f=s,g=s+(c-u)/2,p=(f+g)/2,x=(c+u)/2,v=f+c/2,y=d>=0?1:-1,b=y*r,E=y>0?"end":"start",w=y>0?"start":"end",A=c>=0?1:-1,T=A*r,C=A>0?"end":"start",N=A>0?"start":"end";if(i==="top"){var O={x:f+c/2,y:l-b,textAnchor:"middle",verticalAnchor:E};return Zr(Zr({},O),a?{height:Math.max(l-a.y,0),width:c}:{})}if(i==="bottom"){var k={x:g+u/2,y:l+d+b,textAnchor:"middle",verticalAnchor:w};return Zr(Zr({},k),a?{height:Math.max(a.y+a.height-(l+d),0),width:u}:{})}if(i==="left"){var j={x:p-T,y:l+d/2,textAnchor:C,verticalAnchor:"middle"};return Zr(Zr({},j),a?{width:Math.max(j.x-a.x,0),height:d}:{})}if(i==="right"){var B={x:p+x+T,y:l+d/2,textAnchor:N,verticalAnchor:"middle"};return Zr(Zr({},B),a?{width:Math.max(a.x+a.width-B.x,0),height:d}:{})}var L=a?{width:x,height:d}:{};return i==="insideLeft"?Zr({x:p+T,y:l+d/2,textAnchor:N,verticalAnchor:"middle"},L):i==="insideRight"?Zr({x:p+x-T,y:l+d/2,textAnchor:C,verticalAnchor:"middle"},L):i==="insideTop"?Zr({x:f+c/2,y:l+b,textAnchor:"middle",verticalAnchor:w},L):i==="insideBottom"?Zr({x:g+u/2,y:l+d-b,textAnchor:"middle",verticalAnchor:E},L):i==="insideTopLeft"?Zr({x:f+T,y:l+b,textAnchor:N,verticalAnchor:w},L):i==="insideTopRight"?Zr({x:f+c-T,y:l+b,textAnchor:C,verticalAnchor:w},L):i==="insideBottomLeft"?Zr({x:g+T,y:l+d-b,textAnchor:N,verticalAnchor:E},L):i==="insideBottomRight"?Zr({x:g+u-T,y:l+d-b,textAnchor:C,verticalAnchor:E},L):i&&typeof i=="object"&&(Dt(i.x)||Hc(i.x))&&(Dt(i.y)||Hc(i.y))?Zr({x:s+_a(i.x,x),y:l+_a(i.y,d),textAnchor:"end",verticalAnchor:"end"},L):Zr({x:v,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},L)},zwe={angle:0,offset:5,zIndex:Gr.label,position:"middle",textBreakAll:!1};function Hu(t){var e=Lr(t,zwe),{viewBox:n,position:r,value:i,children:a,content:s,className:l="",textBreakAll:c,labelRef:u}=e,d=Dwe(),f=cY(),g=r==="center"?f:d??f,p,x,v;if(n==null?p=g:Q3(n)?p=n:p=Tq(n),!p||Er(i)&&Er(a)&&!S.isValidElement(s)&&typeof s!="function")return null;var y=Zr(Zr({},e),{},{viewBox:p});if(S.isValidElement(s)){var{labelRef:b}=y,E=Nwe(y,Twe);return S.cloneElement(s,E)}if(typeof s=="function"){if(x=S.createElement(s,y),S.isValidElement(x))return x}else x=Owe(e);var w=ua(e);if(Q3(p)){if(r==="insideStart"||r==="insideEnd"||r==="end")return Iwe(e,r,x,w,p);v=Fwe(p,e.offset,e.position)}else v=Uwe(e,p);return S.createElement(wa,{zIndex:e.zIndex},S.createElement($M,_c({ref:u,className:Pn("recharts-label",l)},w,v,{textAnchor:wwe(w.textAnchor)?w.textAnchor:v.textAnchor,breakAll:c}),x))}Hu.displayName="Label";var Bwe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?S.createElement(Hu,_c({key:"label-implicit"},r)):go(t)?S.createElement(Hu,_c({key:"label-implicit",value:t},r)):S.isValidElement(t)?t.type===Hu?S.cloneElement(t,Zr({key:"label-implicit"},r)):S.createElement(Hu,_c({key:"label-implicit",content:t},r)):rO(t)?S.createElement(Hu,_c({key:"label-implicit",content:t},r)):t&&typeof t=="object"?S.createElement(Hu,_c({},t,{key:"label-implicit"},r)):null};function uY(t){var{label:e,labelRef:n}=t,r=cY();return Bwe(e,r,n)||null}var mN={},pN={},t6;function Hwe(){return t6||(t6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(pN)),pN}var gN={},n6;function $we(){return n6||(n6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(gN)),gN}var r6;function Vwe(){return r6||(r6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Hwe(),n=$we(),r=PR();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(mN)),mN}var xN,i6;function Gwe(){return i6||(i6=1,xN=Vwe().last),xN}var Wwe=Gwe();const qwe=yo(Wwe);var Kwe=["valueAccessor"],Xwe=["dataKey","clockWise","id","textBreakAll","zIndex"];function Nw(){return Nw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Nw.apply(null,arguments)}function a6(t,e){if(t==null)return{};var n,r,i=Ywe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Ywe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Zwe=t=>Array.isArray(t.value)?qwe(t.value):t.value,dY=S.createContext(void 0),iO=dY.Provider,hY=S.createContext(void 0),Qwe=hY.Provider;function Jwe(){return S.useContext(dY)}function eSe(){return S.useContext(hY)}function y1(t){var{valueAccessor:e=Zwe}=t,n=a6(t,Kwe),{dataKey:r,clockWise:i,id:a,textBreakAll:s,zIndex:l}=n,c=a6(n,Xwe),u=Jwe(),d=eSe(),f=u||d;return!f||!f.length?null:S.createElement(wa,{zIndex:l??Gr.label},S.createElement(Or,{className:"recharts-label-list"},f.map((g,p)=>{var x,v=Er(r)?e(g,p):Zn(g&&g.payload,r),y=Er(a)?{}:{id:"".concat(a,"-").concat(p)};return S.createElement(Hu,Nw({key:"label-".concat(p)},ua(g),c,y,{fill:(x=n.fill)!==null&&x!==void 0?x:g.fill,parentViewBox:g.parentViewBox,value:v,textBreakAll:s,viewBox:g.viewBox,index:p,zIndex:0}))})))}y1.displayName="LabelList";function VM(t){var{label:e}=t;return e?e===!0?S.createElement(y1,{key:"labelList-implicit"}):S.isValidElement(e)||rO(e)?S.createElement(y1,{key:"labelList-implicit",content:e}):typeof e=="object"?S.createElement(y1,Nw({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function J3(){return J3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},J3.apply(null,arguments)}var fY=t=>{var{cx:e,cy:n,r,className:i}=t,a=Pn("recharts-dot",i);return Dt(e)&&Dt(n)&&Dt(r)?S.createElement("circle",J3({},La(t),kR(t),{className:a,cx:e,cy:n,r})):null},mY=t=>t.graphicalItems.polarItems,tSe=Qe([jr,Wb],TD),GM=Qe([mY,Ir,tSe],ND),nSe=Qe([GM],CD),WM=Qe([nSe,xD],kD),rSe=Qe([WM,Ir,GM],jD);Qe([WM,Ir,GM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,s=Zn(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:s,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Zn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var s6=()=>{},iSe=Qe([WM,Ir,GM,UM,jr],LD),aSe=Qe([Ir,DD,OD,s6,iSe,s6,Sn,jr],ID),pY=Qe([Ir,Sn,WM,rSe,Gb,jr,aSe],FD),sSe=Qe([pY,Ir,gg],BD);Qe([Ir,pY,sSe,jr],$D);var oSe={radiusAxis:{},angleAxis:{}},gY=ls({name:"polarAxis",initialState:oSe,reducers:{addRadiusAxis(t,e){t.radiusAxis[e.payload.id]=e.payload},removeRadiusAxis(t,e){delete t.radiusAxis[e.payload.id]},addAngleAxis(t,e){t.angleAxis[e.payload.id]=e.payload},removeAngleAxis(t,e){delete t.angleAxis[e.payload.id]}}}),{addRadiusAxis:ZWe,removeRadiusAxis:QWe,addAngleAxis:JWe,removeAngleAxis:eqe}=gY.actions,lSe=gY.reducer;function o6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function l6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?o6(Object(n),!0).forEach(function(r){cSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cSe(t,e,n){return(e=uSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uSe(t){var e=dSe(t,"string");return typeof e=="symbol"?e:e+""}function dSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var hSe=(t,e)=>e,aO=Qe([mY,hSe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),fSe=[],sO=(t,e,n)=>n?.length===0?fSe:n,xY=Qe([xD,aO,sO],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(a=>l6(l6({},e.presentationProps),a.props))),i!=null)return i}}),mSe=Qe([xY,aO,sO],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,s=Zn(r,e.nameKey,e.name),l;return n!=null&&(a=n[i])!==null&&a!==void 0&&(a=a.props)!==null&&a!==void 0&&a.fill?l=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?l=r.fill:l=e.fill,{value:Pd(s,e.dataKey),color:l,payload:r,type:e.legendType}})}),pSe=Qe([xY,aO,sO,Ei],(t,e,n,r)=>{if(!(e==null||t==null))return gMe({offset:r,pieSettings:e,displayedData:t,cells:n})}),bN={exports:{}},ir={};var c6;function gSe(){if(c6)return ir;c6=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),s=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),p=Symbol.for("react.client.reference");function x(v){if(typeof v=="object"&&v!==null){var y=v.$$typeof;switch(y){case t:switch(v=v.type,v){case n:case i:case r:case c:case u:case g:return v;default:switch(v=v&&v.$$typeof,v){case s:case l:case f:case d:return v;case a:return v;default:return y}}case e:return y}}}return ir.ContextConsumer=a,ir.ContextProvider=s,ir.Element=t,ir.ForwardRef=l,ir.Fragment=n,ir.Lazy=f,ir.Memo=d,ir.Portal=e,ir.Profiler=i,ir.StrictMode=r,ir.Suspense=c,ir.SuspenseList=u,ir.isContextConsumer=function(v){return x(v)===a},ir.isContextProvider=function(v){return x(v)===s},ir.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===t},ir.isForwardRef=function(v){return x(v)===l},ir.isFragment=function(v){return x(v)===n},ir.isLazy=function(v){return x(v)===f},ir.isMemo=function(v){return x(v)===d},ir.isPortal=function(v){return x(v)===e},ir.isProfiler=function(v){return x(v)===i},ir.isStrictMode=function(v){return x(v)===r},ir.isSuspense=function(v){return x(v)===c},ir.isSuspenseList=function(v){return x(v)===u},ir.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===i||v===r||v===c||v===u||typeof v=="object"&&v!==null&&(v.$$typeof===f||v.$$typeof===d||v.$$typeof===s||v.$$typeof===a||v.$$typeof===l||v.$$typeof===p||v.getModuleId!==void 0)},ir.typeOf=x,ir}var u6;function xSe(){return u6||(u6=1,bN.exports=gSe()),bN.exports}var bSe=xSe(),d6=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",h6=null,yN=null,bY=t=>{if(t===h6&&Array.isArray(yN))return yN;var e=[];return S.Children.forEach(t,n=>{Er(n)||(bSe.isFragment(n)?e=e.concat(bY(n.props.children)):e.push(n))}),yN=e,h6=t,e};function oO(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>d6(i)):r=[d6(e)],bY(t).forEach(i=>{var a=lf(i,"type.displayName")||lf(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var lO=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,vN={},f6;function ySe(){return f6||(f6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){if(typeof n!="object"||n==null)return!1;if(Object.getPrototypeOf(n)===null)return!0;if(Object.prototype.toString.call(n)!=="[object Object]"){const i=n[Symbol.toStringTag];return i==null||!Object.getOwnPropertyDescriptor(n,Symbol.toStringTag)?.writable?!1:n.toString()===`[object ${i}]`}let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r}t.isPlainObject=e})(vN)),vN}var _N,m6;function vSe(){return m6||(m6=1,_N=ySe().isPlainObject),_N}var _Se=vSe();const wSe=yo(_Se);function p6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function g6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?p6(Object(n),!0).forEach(function(r){SSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function SSe(t,e,n){return(e=MSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MSe(t){var e=ESe(t,"string");return typeof e=="symbol"?e:e+""}function ESe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Cw(){return Cw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Cw.apply(null,arguments)}var x6=(t,e,n,r,i)=>{var a=n-r,s;return s="M ".concat(t,",").concat(e),s+="L ".concat(t+n,",").concat(e),s+="L ".concat(t+n-a/2,",").concat(e+i),s+="L ".concat(t+n-a/2-r,",").concat(e+i),s+="L ".concat(t,",").concat(e," Z"),s},ASe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},TSe=t=>{var e=Lr(t,ASe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:s,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,g=S.useRef(null),[p,x]=S.useState(-1),v=S.useRef(i),y=S.useRef(a),b=S.useRef(s),E=S.useRef(n),w=S.useRef(r),A=ug(t,"trapezoid-");if(S.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var R=g.current.getTotalLength();R&&x(R)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||s!==+s||i===0&&a===0||s===0)return null;var T=Pn("recharts-trapezoid",l);if(!f)return S.createElement("g",null,S.createElement("path",Cw({},ua(e),{className:T,d:x6(n,r,i,a,s)})));var C=v.current,N=y.current,O=b.current,k=E.current,j=w.current,B="0px ".concat(p===-1?1:p,"px"),L="".concat(p,"px 0px"),K=zq(["strokeDasharray"],u,c);return S.createElement(cg,{animationId:A,key:A,canBegin:p>0,duration:u,easing:c,isActive:f,begin:d},R=>{var q=Vn(C,i,R),W=Vn(N,a,R),$=Vn(O,s,R),J=Vn(k,n,R),ee=Vn(j,r,R);g.current&&(v.current=q,y.current=W,b.current=$,E.current=J,w.current=ee);var Q=R>0?{transition:K,strokeDasharray:L}:{strokeDasharray:B};return S.createElement("path",Cw({},ua(e),{className:T,d:x6(J,ee,q,W,$),ref:g,style:g6(g6({},Q),e.style)}))})},NSe=["option","shapeType","propTransformer","activeClassName"];function CSe(t,e){if(t==null)return{};var n,r,i=kSe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function kSe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function b6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function kw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?b6(Object(n),!0).forEach(function(r){PSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function PSe(t,e,n){return(e=jSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function jSe(t){var e=RSe(t,"string");return typeof e=="symbol"?e:e+""}function RSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function DSe(t,e){return kw(kw({},e),t)}function OSe(t,e){return t==="symbols"}function y6(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return S.createElement(Vq,n);case"trapezoid":return S.createElement(TSe,n);case"sector":return S.createElement(Kq,n);case"symbols":if(OSe(e))return S.createElement(CR,n);break;case"curve":return S.createElement(fp,n);default:return null}}function LSe(t){return S.isValidElement(t)?t.props:t}function cO(t){var{option:e,shapeType:n,propTransformer:r=DSe,activeClassName:i="recharts-active-shape"}=t,a=CSe(t,NSe),s;if(S.isValidElement(e))s=S.cloneElement(e,kw(kw({},a),LSe(e)));else if(typeof e=="function")s=e(a,a.index);else if(wSe(e)&&typeof e!="boolean"){var l=r(e,a);s=S.createElement(y6,{shapeType:n,elementProps:l})}else{var c=a;s=S.createElement(y6,{shapeType:n,elementProps:c})}return a.isActive?S.createElement(Or,{className:i},s):s}var uO=(t,e,n)=>{var r=gr();return(i,a)=>s=>{t?.(i,a,s),r(CX({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},dO=t=>{var e=gr();return(n,r)=>i=>{t?.(n,r,i),e(Zve())}},hO=(t,e,n)=>{var r=gr();return(i,a)=>s=>{t?.(i,a,s),r(Qve({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function qM(t){var{tooltipEntrySettings:e}=t,n=gr(),r=Ai(),i=S.useRef(null);return S.useLayoutEffect(()=>{r||(i.current===null?n(qve(e)):i.current!==e&&n(Kve({prev:i.current,next:e})),i.current=e)},[e,n,r]),S.useLayoutEffect(()=>()=>{i.current&&(n(Xve(i.current)),i.current=null)},[n]),null}function fO(t){var{legendPayload:e}=t,n=gr(),r=Ai(),i=S.useRef(null);return S.useLayoutEffect(()=>{r||(i.current===null?n(Lq(e)):i.current!==e&&n(Iq({prev:i.current,next:e})),i.current=e)},[n,r,e]),S.useLayoutEffect(()=>()=>{i.current&&(n(Fq(i.current)),i.current=null)},[n]),null}function ISe(t){var{legendPayload:e}=t,n=gr(),r=jt(Sn),i=S.useRef(null);return S.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(Lq(e)):i.current!==e&&n(Iq({prev:i.current,next:e})),i.current=e)},[n,r,e]),S.useLayoutEffect(()=>()=>{i.current&&(n(Fq(i.current)),i.current=null)},[n]),null}var wN,FSe=()=>{var[t]=S.useState(()=>I0("uid-"));return t},USe=(wN=iie.useId)!==null&&wN!==void 0?wN:FSe;function yY(t,e){var n=USe();return e||(t?"".concat(t,"-").concat(n):n)}var zSe=S.createContext(void 0),KM=t=>{var{id:e,type:n,children:r}=t,i=yY("recharts-".concat(n),e);return S.createElement(zSe.Provider,{value:i},r(i))},BSe={cartesianItems:[],polarItems:[]},vY=ls({name:"graphicalItems",initialState:BSe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Nr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ho(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Nr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Ho(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:Nr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:Nr()},removePolarGraphicalItem:{reducer(t,e){var n=Ho(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Nr()}}}),{addCartesianGraphicalItem:HSe,replaceCartesianGraphicalItem:$Se,removeCartesianGraphicalItem:VSe,addPolarGraphicalItem:GSe,removePolarGraphicalItem:WSe}=vY.actions,qSe=vY.reducer,KSe=t=>{var e=gr(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?e(HSe(t)):n.current!==t&&e($Se({prev:n.current,next:t})),n.current=t},[e,t]),S.useLayoutEffect(()=>()=>{n.current&&(e(VSe(n.current)),n.current=null)},[e]),null},mO=S.memo(KSe);function XSe(t){var e=gr();return S.useLayoutEffect(()=>(e(GSe(t)),()=>{e(WSe(t))}),[e,t]),null}var YSe=["key"],ZSe=["onMouseEnter","onClick","onMouseLeave"],QSe=["id"],JSe=["id"];function v6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function $r(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?v6(Object(n),!0).forEach(function(r){eMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):v6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function eMe(t,e,n){return(e=tMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function tMe(t){var e=nMe(t,"string");return typeof e=="symbol"?e:e+""}function nMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Sd(){return Sd=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Sd.apply(null,arguments)}function XM(t,e){if(t==null)return{};var n,r,i=rMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function rMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function iMe(t){var e=S.useMemo(()=>oO(t.children,ny),[t.children]),n=jt(r=>mSe(r,t.id,e));return n==null?null:S.createElement(ISe,{legendPayload:n})}var aMe=S.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:s,name:l,hide:c,tooltipType:u}=t,d={dataDefinedOnItem:r.map(f=>f.tooltipPayload),positions:r.map(f=>f.tooltipPosition),settings:{stroke:i,strokeWidth:a,fill:s,dataKey:e,nameKey:n,name:Pd(l,e),hide:c,type:u,color:s,unit:""}};return S.createElement(qM,{tooltipEntrySettings:d})}),sMe=(t,e)=>t>e?"start":t<e?"end":"middle",oMe=(t,e,n)=>_a(typeof e=="function"?e(t):e,n,n*.8),lMe=(t,e,n)=>{var{top:r,left:i,width:a,height:s}=e,l=Gq(a,s),c=i+_a(t.cx,a,a/2),u=r+_a(t.cy,s,s/2),d=_a(t.innerRadius,l,0),f=oMe(n,t.outerRadius,l),g=t.maxRadius||Math.sqrt(a*a+s*s)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:g}},cMe=(t,e)=>{var n=Hi(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function uMe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var dMe=(t,e)=>{if(S.isValidElement(t))return S.cloneElement(t,e);if(typeof t=="function")return t(e);var n=Pn("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=XM(e,YSe);return S.createElement(fp,Sd({},i,{type:"linear",className:n}))},hMe=(t,e,n)=>{if(S.isValidElement(t))return S.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),S.isValidElement(r)))return r;var i=Pn("recharts-pie-label-text",uMe(t));return S.createElement($M,Sd({},e,{alignmentBaseline:"middle",className:i}),r)};function fMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:s}=n;if(!r||!i||!e)return null;var l=La(n),c=of(i),u=of(a),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((g,p)=>{var x=(g.startAngle+g.endAngle)/2,v=ui(g.cx,g.cy,g.outerRadius+d,x),y=$r($r($r($r({},l),g),{},{stroke:"none"},c),{},{index:p,textAnchor:sMe(v.x,g.cx)},v),b=$r($r($r($r({},l),g),{},{fill:"none",stroke:g.fill},u),{},{index:p,points:[ui(g.cx,g.cy,g.outerRadius,x),v],key:"line"});return S.createElement(wa,{zIndex:Gr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(p)},S.createElement(Or,null,a&&dMe(a,b),hMe(i,y,Zn(g,s))))});return S.createElement(Or,{className:"recharts-pie-labels"},f)}function mMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?S.createElement(VM,{label:i}):S.createElement(fMe,{sectors:e,props:n,showLabels:r})}function pMe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:s}=t,l=jt(wd),c=jt(QD),u=jt(I_e),{onMouseEnter:d,onClick:f,onMouseLeave:g}=i,p=XM(i,ZSe),x=uO(d,i.dataKey,s),v=dO(g),y=hO(f,i.dataKey,s);return e==null||e.length===0?null:S.createElement(S.Fragment,null,e.map((b,E)=>{if(b?.startAngle===0&&b?.endAngle===0&&e.length!==1)return null;var w=u==null||u===s,A=String(E)===l&&(c==null||i.dataKey===c)&&w,T=l?r:null,C=n&&A?n:T,N=$r($r({},b),{},{stroke:b.stroke,tabIndex:-1,[wq]:E,[Sq]:i.dataKey});return S.createElement(Or,Sd({key:"sector-".concat(b?.startAngle,"-").concat(b?.endAngle,"-").concat(b.midAngle,"-").concat(E),tabIndex:-1,className:"recharts-pie-sector"},Rb(p,b,E),{onMouseEnter:x(b,E),onMouseLeave:v(b,E),onClick:y(b,E)}),S.createElement(cO,Sd({option:a??C,index:E,shapeType:"sector",isActive:A},N)))}))}function gMe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:a}=t,{cornerRadius:s,startAngle:l,endAngle:c,dataKey:u,nameKey:d,tooltipType:f}=n,g=Math.abs(n.minAngle),p=cMe(l,c),x=Math.abs(p),v=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,y=r.filter(C=>Zn(C,u,0)!==0).length,b=(x>=360?y:y-1)*v,E=x-y*g-b,w=r.reduce((C,N)=>{var O=Zn(N,u,0);return C+(Dt(O)?O:0)},0),A;if(w>0){var T;A=r.map((C,N)=>{var O=Zn(C,u,0),k=Zn(C,d,N),j=lMe(n,a,C),B=(Dt(O)?O:0)/w,L,K=$r($r({},C),i&&i[N]&&i[N].props);N?L=T.endAngle+Hi(p)*v*(O!==0?1:0):L=l;var R=L+Hi(p)*((O!==0?g:0)+B*E),q=(L+R)/2,W=(j.innerRadius+j.outerRadius)/2,$=[{name:k,value:O,payload:K,dataKey:u,type:f}],J=ui(j.cx,j.cy,W,q);return T=$r($r($r($r({},n.presentationProps),{},{percent:B,cornerRadius:typeof s=="string"?parseFloat(s):s,name:k,tooltipPayload:$,midAngle:q,middleRadius:W,tooltipPosition:J},K),j),{},{value:O,dataKey:u,startAngle:L,endAngle:R,payload:K,paddingAngle:Hi(p)*v}),T})}return A}function xMe(t){var{showLabels:e,sectors:n,children:r}=t,i=S.useMemo(()=>!e||!n?[]:n.map(a=>({value:a.value,payload:a.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:a.cx,cy:a.cy,innerRadius:a.innerRadius,outerRadius:a.outerRadius,startAngle:a.startAngle,endAngle:a.endAngle,clockWise:!1},fill:a.fill})),[n,e]);return S.createElement(Qwe,{value:e?i:void 0},r)}function bMe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:a,animationBegin:s,animationDuration:l,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:g}=e,p=ug(e,"recharts-pie-"),x=n.current,[v,y]=S.useState(!1),b=S.useCallback(()=>{typeof g=="function"&&g(),y(!1)},[g]),E=S.useCallback(()=>{typeof f=="function"&&f(),y(!0)},[f]);return S.createElement(xMe,{showLabels:!v,sectors:i},S.createElement(cg,{animationId:p,begin:s,duration:l,isActive:a,easing:c,onAnimationStart:E,onAnimationEnd:b,key:p},w=>{var A=[],T=i&&i[0],C=T?.startAngle;return i?.forEach((N,O)=>{var k=x&&x[O],j=O>0?lf(N,"paddingAngle",0):0;if(k){var B=Vn(k.endAngle-k.startAngle,N.endAngle-N.startAngle,w),L=$r($r({},N),{},{startAngle:C+j,endAngle:C+B+j});A.push(L),C=L.endAngle}else{var{endAngle:K,startAngle:R}=N,q=Vn(0,K-R,w),W=$r($r({},N),{},{startAngle:C+j,endAngle:C+q+j});A.push(W),C=W.endAngle}}),n.current=A,S.createElement(Or,null,S.createElement(pMe,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),S.createElement(mMe,{showLabels:!v,sectors:i,props:e}),e.children)}var yMe={animationBegin:400,animationDuration:1500,animationEasing:"ease",cx:"50%",cy:"50%",dataKey:"value",endAngle:360,fill:"#808080",hide:!1,innerRadius:0,isAnimationActive:"auto",label:!1,labelLine:!0,legendType:"rect",minAngle:0,nameKey:"name",outerRadius:"80%",paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:"#fff",zIndex:Gr.area};function vMe(t){var{id:e}=t,n=XM(t,QSe),{hide:r,className:i,rootTabIndex:a}=t,s=S.useMemo(()=>oO(t.children,ny),[t.children]),l=jt(d=>pSe(d,e,s)),c=S.useRef(null),u=Pn("recharts-pie",i);return r||l==null?(c.current=null,S.createElement(Or,{tabIndex:a,className:u})):S.createElement(wa,{zIndex:t.zIndex},S.createElement(aMe,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:l,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),S.createElement(Or,{tabIndex:a,className:u},S.createElement(bMe,{props:$r($r({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function _Y(t){var e=Lr(t,yMe),{id:n}=e,r=XM(e,JSe),i=La(r);return S.createElement(KM,{id:n,type:"pie"},a=>S.createElement(S.Fragment,null,S.createElement(XSe,{type:"pie",id:a,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),S.createElement(iMe,Sd({},r,{id:a})),S.createElement(vMe,Sd({},r,{id:a}))))}_Y.displayName="Pie";var _Me=["points"];function _6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function SN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_6(Object(n),!0).forEach(function(r){wMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wMe(t,e,n){return(e=SMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function SMe(t){var e=MMe(t,"string");return typeof e=="symbol"?e:e+""}function MMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Pw(){return Pw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Pw.apply(null,arguments)}function EMe(t,e){if(t==null)return{};var n,r,i=AMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function AMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function TMe(t){var{option:e,dotProps:n,className:r}=t;if(S.isValidElement(e))return S.cloneElement(e,n);if(typeof e=="function")return e(n);var i=Pn(r,typeof e!="boolean"?e.className:""),a=n??{},{points:s}=a,l=EMe(a,_Me);return S.createElement(fY,Pw({},l,{className:i}))}function NMe(t,e){return t==null?!1:e?!0:t.length===1}function wY(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:s,needClip:l,clipPathId:c,zIndex:u=Gr.scatter}=t;if(!NMe(e,n))return null;var d=lO(n),f=ahe(n),g=e.map((x,v)=>{var y,b,E=SN(SN(SN({r:3},s),f),{},{index:v,cx:(y=x.x)!==null&&y!==void 0?y:void 0,cy:(b=x.y)!==null&&b!==void 0?b:void 0,dataKey:a,value:x.value,payload:x.payload,points:e});return S.createElement(TMe,{key:"dot-".concat(v),option:n,dotProps:E,className:i})}),p={};return l&&c!=null&&(p.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),S.createElement(wa,{zIndex:u},S.createElement(Or,Pw({className:r},p),g))}function w6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function S6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?w6(Object(n),!0).forEach(function(r){CMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function CMe(t,e,n){return(e=kMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kMe(t){var e=PMe(t,"string");return typeof e=="symbol"?e:e+""}function PMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var jMe={xAxis:{},yAxis:{},zAxis:{}},SY=ls({name:"cartesianAxis",initialState:jMe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:Nr()},replaceXAxis:{reducer(t,e){var{prev:n,next:r}=e.payload;t.xAxis[n.id]!==void 0&&(n.id!==r.id&&delete t.xAxis[n.id],t.xAxis[r.id]=r)},prepare:Nr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:Nr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:Nr()},replaceYAxis:{reducer(t,e){var{prev:n,next:r}=e.payload;t.yAxis[n.id]!==void 0&&(n.id!==r.id&&delete t.yAxis[n.id],t.yAxis[r.id]=r)},prepare:Nr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:Nr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:Nr()},replaceZAxis:{reducer(t,e){var{prev:n,next:r}=e.payload;t.zAxis[n.id]!==void 0&&(n.id!==r.id&&delete t.zAxis[n.id],t.zAxis[r.id]=r)},prepare:Nr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:Nr()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var a=i.widthHistory||[];if(a.length===3&&a[0]===a[2]&&r===a[1]&&r!==i.width&&Math.abs(r-a[0])<=1)return;var s=[...a,r].slice(-3);t.yAxis[n]=S6(S6({},t.yAxis[n]),{},{width:r,widthHistory:s})}}}}),{addXAxis:RMe,replaceXAxis:DMe,removeXAxis:OMe,addYAxis:LMe,replaceYAxis:IMe,removeYAxis:FMe,addZAxis:tqe,replaceZAxis:nqe,removeZAxis:rqe,updateYAxisWidth:UMe}=SY.actions,zMe=SY.reducer,BMe=Qe([Ei],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),HMe=Qe([BMe,Zc,Qc],(t,e,n)=>{if(!(!t||e==null||n==null))return{x:t.left,y:t.top,width:Math.max(0,e-t.left-t.right),height:Math.max(0,n-t.top-t.bottom)}}),YM=()=>jt(HMe),$Me=()=>jt(H_e);function M6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function MN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M6(Object(n),!0).forEach(function(r){VMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function VMe(t,e,n){return(e=GMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GMe(t){var e=WMe(t,"string");return typeof e=="symbol"?e:e+""}function WMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var qMe=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:s}=t;if(i===!1||e.x==null||e.y==null)return null;var l={index:n,dataKey:a,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},c=MN(MN(MN({},l),of(i)),kR(i)),u;return S.isValidElement(i)?u=S.cloneElement(i,c):typeof i=="function"?u=i(c):u=S.createElement(fY,c),S.createElement(Or,{className:"recharts-active-dot",clipPath:s},u)};function eP(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:s=Gr.activeDot}=t,l=jt(wd),c=$Me();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Er(u)?null:S.createElement(wa,{zIndex:s},S.createElement(qMe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var KMe="Invariant failed";function XMe(t,e){throw new Error(KMe)}var YMe=["x","y"];function tP(){return tP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},tP.apply(null,arguments)}function E6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Tx(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?E6(Object(n),!0).forEach(function(r){ZMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZMe(t,e,n){return(e=QMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QMe(t){var e=JMe(t,"string");return typeof e=="symbol"?e:e+""}function JMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function eEe(t,e){if(t==null)return{};var n,r,i=tEe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function tEe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function nEe(t,e){var{x:n,y:r}=t,i=eEe(t,YMe),a="".concat(n),s=parseInt(a,10),l="".concat(r),c=parseInt(l,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),g=parseInt(f,10);return Tx(Tx(Tx(Tx(Tx({},e),i),s?{x:s}:{}),c?{y:c}:{}),{},{height:d,width:g,name:e.name,radius:e.radius})}function jw(t){return S.createElement(cO,tP({shapeType:"rectangle",propTransformer:nEe,activeClassName:"recharts-active-bar"},t))}var rEe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Dt(e))return e;var a=Dt(r)||Er(r);return a?e(r,i):(a||XMe(),n)}},iEe={},MY=ls({name:"errorBars",initialState:iEe,reducers:{addErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]||(t[n]=[]),t[n].push(r)},replaceErrorBar:(t,e)=>{var{itemId:n,prev:r,next:i}=e.payload;t[n]&&(t[n]=t[n].map(a=>a.dataKey===r.dataKey&&a.direction===r.direction?i:a))},removeErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]&&(t[n]=t[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:iqe,replaceErrorBar:aqe,removeErrorBar:sqe}=MY.actions,aEe=MY.reducer,sEe=["children"];function oEe(t,e){if(t==null)return{};var n,r,i=lEe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function lEe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var cEe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},uEe=S.createContext(cEe);function EY(t){var{children:e}=t,n=oEe(t,sEe);return S.createElement(uEe.Provider,{value:n},e)}function ZM(t,e){var n,r,i=jt(u=>Dl(u,t)),a=jt(u=>Ol(u,e)),s=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Li.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Ii.allowDataOverflow,c=s||l;return{needClip:c,needClipX:s,needClipY:l}}function pO(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=YM(),{needClipX:a,needClipY:s,needClip:l}=ZM(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:f}=i;return S.createElement("clipPath",{id:"clipPath-".concat(r)},S.createElement("rect",{x:a?c:c-d/2,y:s?u:u-f/2,width:a?d:d*2,height:s?f:f*2}))}function dEe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&Qn(t.zIndex)?t.zIndex:e}var EN={exports:{}},AN={};var A6;function hEe(){if(A6)return AN;A6=1;var t=tg();function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,a=t.useEffect,s=t.useMemo,l=t.useDebugValue;return AN.useSyncExternalStoreWithSelector=function(c,u,d,f,g){var p=i(null);if(p.current===null){var x={hasValue:!1,value:null};p.current=x}else x=p.current;p=s(function(){function y(T){if(!b){if(b=!0,E=T,T=f(T),g!==void 0&&x.hasValue){var C=x.value;if(g(C,T))return w=C}return w=T}if(C=w,n(E,T))return C;var N=f(T);return g!==void 0&&g(C,N)?(E=T,C):(E=T,w=N)}var b=!1,E,w,A=d===void 0?null:d;return[function(){return y(u())},A===null?void 0:function(){return y(A())}]},[u,d,f,g]);var v=r(c,p[0],p[1]);return a(function(){x.hasValue=!0,x.value=v},[v]),l(v),v},AN}var T6;function fEe(){return T6||(T6=1,EN.exports=hEe()),EN.exports}fEe();function mEe(t){t()}function pEe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){mEe(()=>{let n=t;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=t;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const i=e={callback:n,next:null,prev:e};return i.prev?i.prev.next=i:t=i,function(){!r||t===null||(r=!1,i.next?i.next.prev=i.prev:e=i.prev,i.prev?i.prev.next=i.next:t=i.next)}}}}var N6={notify(){},get:()=>[]};function gEe(t,e){let n,r=N6,i=0,a=!1;function s(v){d();const y=r.subscribe(v);let b=!1;return()=>{b||(b=!0,y(),f())}}function l(){r.notify()}function c(){x.onStateChange&&x.onStateChange()}function u(){return a}function d(){i++,n||(n=t.subscribe(c),r=pEe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=N6)}function g(){a||(a=!0,d())}function p(){a&&(a=!1,f())}const x={addNestedSub:s,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:g,tryUnsubscribe:p,getListeners:()=>r};return x}var xEe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",bEe=xEe(),yEe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",vEe=yEe(),_Ee=()=>bEe||vEe?S.useLayoutEffect:S.useEffect,wEe=_Ee();function C6(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function SEe(t,e){if(C6(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(let i=0;i<n.length;i++)if(!Object.prototype.hasOwnProperty.call(e,n[i])||!C6(t[n[i]],e[n[i]]))return!1;return!0}var MEe=Symbol.for("react-redux-context"),EEe=typeof globalThis<"u"?globalThis:{};function AEe(){if(!S.createContext)return{};const t=EEe[MEe]??=new Map;let e=t.get(S.createContext);return e||(e=S.createContext(null),t.set(S.createContext,e)),e}var TEe=AEe();function NEe(t){const{children:e,context:n,serverState:r,store:i}=t,a=S.useMemo(()=>{const c=gEe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),s=S.useMemo(()=>i.getState(),[i]);wEe(()=>{const{subscription:c}=a;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),s!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[a,s]);const l=n||TEe;return S.createElement(l.Provider,{value:a},e)}var CEe=NEe,kEe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function PEe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function ry(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(kEe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!SEe(t[r],e[r]))return!1}else if(!PEe(t[r],e[r]))return!1;return!0}var jEe=["onMouseEnter","onMouseLeave","onClick"],REe=["value","background","tooltipPosition"],DEe=["id"],OEe=["onMouseEnter","onClick","onMouseLeave"];function Kc(){return Kc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Kc.apply(null,arguments)}function k6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ka(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k6(Object(n),!0).forEach(function(r){LEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function LEe(t,e,n){return(e=IEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function IEe(t){var e=FEe(t,"string");return typeof e=="symbol"?e:e+""}function FEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Rw(t,e){if(t==null)return{};var n,r,i=UEe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function UEe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var zEe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Pd(n,e),payload:t}]},BEe=S.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,hide:s,unit:l,tooltipType:c}=t,u={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:Pd(a,e),hide:s,type:c,color:i,unit:l}};return S.createElement(qM,{tooltipEntrySettings:u})});function HEe(t){var e=jt(wd),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:s,onMouseLeave:l,onClick:c}=a,u=Rw(a,jEe),d=uO(s,r),f=dO(l),g=hO(c,r);if(!i||n==null)return null;var p=of(i);return S.createElement(wa,{zIndex:dEe(i,Gr.barBackground)},n.map((x,v)=>{var{value:y,background:b,tooltipPosition:E}=x,w=Rw(x,REe);if(!b)return null;var A=d(x,v),T=f(x,v),C=g(x,v),N=ka(ka(ka(ka(ka({option:i,isActive:String(v)===e},w),{},{fill:"#eee"},b),p),Rb(u,x,v)),{},{onMouseEnter:A,onMouseLeave:T,onClick:C,dataKey:r,index:v,className:"recharts-bar-background-rectangle"});return S.createElement(jw,Kc({key:"background-bar-".concat(v)},N))}))}function $Ee(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(a=>{var s={x:a.x,y:a.y,width:a.width,lowerWidth:a.width,upperWidth:a.width,height:a.height};return ka(ka({},s),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:s,fill:a.fill})});return S.createElement(iO,{value:e?i:void 0},n)}function VEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:s}=t,l=jt(wd),c=jt(QD),u=n&&String(a)===l&&(c==null||s===c),d=u?n:e;return u?S.createElement(wa,{zIndex:Gr.activeBar},S.createElement(jw,Kc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:s}))):S.createElement(jw,Kc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:s}))}function GEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return S.createElement(jw,Kc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function WEe(t){var e,{data:n,props:r}=t,i=(e=La(r))!==null&&e!==void 0?e:{},{id:a}=i,s=Rw(i,DEe),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:g}=r,p=Rw(r,OEe),x=uO(d,c),v=dO(g),y=hO(f,c);return n?S.createElement(S.Fragment,null,n.map((b,E)=>S.createElement(Or,Kc({key:"rectangle-".concat(b?.x,"-").concat(b?.y,"-").concat(b?.value,"-").concat(E),className:"recharts-bar-rectangle"},Rb(p,b,E),{onMouseEnter:x(b,E),onMouseLeave:v(b,E),onClick:y(b,E)}),u?S.createElement(VEe,{shape:l,activeBar:u,baseProps:s,entry:b,index:E,dataKey:c}):S.createElement(GEe,{shape:l,baseProps:s,entry:b,index:E,dataKey:c})))):null}function qEe(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:a,animationBegin:s,animationDuration:l,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,g=ug(e,"recharts-bar-"),[p,x]=S.useState(!1),v=!p,y=S.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),b=S.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return S.createElement($Ee,{showLabels:v,rects:r},S.createElement(cg,{animationId:g,begin:s,duration:l,isActive:a,easing:c,onAnimationEnd:y,onAnimationStart:b,key:g},E=>{var w=E===1?r:r?.map((A,T)=>{var C=f&&f[T];if(C)return ka(ka({},A),{},{x:Vn(C.x,A.x,E),y:Vn(C.y,A.y,E),width:Vn(C.width,A.width,E),height:Vn(C.height,A.height,E)});if(i==="horizontal"){var N=Vn(0,A.height,E),O=Vn(A.stackedBarStart,A.y,E);return ka(ka({},A),{},{y:O,height:N})}var k=Vn(0,A.width,E),j=Vn(A.stackedBarStart,A.x,E);return ka(ka({},A),{},{width:k,x:j})});return E>0&&(n.current=w??null),w==null?null:S.createElement(Or,null,S.createElement(WEe,{props:e,data:w}))}),S.createElement(VM,{label:e.label}),e.children)}function KEe(t){var e=S.useRef(null);return S.createElement(qEe,{previousRectanglesRef:e,props:t})}var AY=0,XEe=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Zn(t,e)}};class YEe extends S.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:s,needClip:l,background:c,id:u}=this.props;if(e||n==null)return null;var d=Pn("recharts-bar",i),f=u;return S.createElement(Or,{className:d,id:u},l&&S.createElement("defs",null,S.createElement(pO,{clipPathId:f,xAxisId:a,yAxisId:s})),S.createElement(Or,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},S.createElement(HEe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),S.createElement(KEe,this.props)))}}var ZEe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:AY,xAxisId:0,yAxisId:0,zIndex:Gr.bar};function QEe(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:s,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=ZM(e,n),g=Ef(),p=Ai(),x=oO(t.children,ny),v=jt(E=>A2e(E,e,n,p,t.id,x));if(g!=="vertical"&&g!=="horizontal")return null;var y,b=v?.[0];return b==null||b.height==null||b.width==null?y=0:y=g==="vertical"?b.height/2:b.width/2,S.createElement(EY,{xAxisId:e,yAxisId:n,data:v,dataPointFormatter:XEe,errorBarOffset:y},S.createElement(YEe,Kc({},t,{layout:g,needClip:f,data:v,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:s,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function JEe(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:s,yAxis:l,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:f,offset:g,cells:p,parentViewBox:x,dataStartIndex:v}=t,y=e==="horizontal"?l:s,b=d?y.scale.domain():null,E=wpe({numericAxis:y}),w=y.scale(E);return f.map((A,T)=>{var C,N,O,k,j,B;d?C=xpe(d[T+v],b):(C=Zn(A,n),Array.isArray(C)||(C=[E,C]));var L=rEe(r,AY)(C[1],T);if(e==="horizontal"){var K,[R,q]=[l.scale(C[0]),l.scale(C[1])];N=qz({axis:s,ticks:c,bandSize:a,offset:i.offset,entry:A,index:T}),O=(K=q??R)!==null&&K!==void 0?K:void 0,k=i.size;var W=R-q;if(j=ss(W)?0:W,B={x:N,y:g.top,width:k,height:g.height},Math.abs(L)>0&&Math.abs(j)<Math.abs(L)){var $=Hi(j||L)*(Math.abs(L)-Math.abs(j));O-=$,j+=$}}else{var[J,ee]=[s.scale(C[0]),s.scale(C[1])];if(N=J,O=qz({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:A,index:T}),k=ee-J,j=i.size,B={x:g.left,y:O,width:g.width,height:j},Math.abs(L)>0&&Math.abs(k)<Math.abs(L)){var Q=Hi(k||L)*(Math.abs(L)-Math.abs(k));k+=Q}}if(N==null||O==null||k==null||j==null)return null;var z=ka(ka({},A),{},{stackedBarStart:w,x:N,y:O,width:k,height:j,value:d?C:C[1],payload:A,background:B,tooltipPosition:{x:N+k/2,y:O+j/2},parentViewBox:x},p&&p[T]&&p[T].props);return z}).filter(Boolean)}function e2e(t){var e=Lr(t,ZEe),n=Ai();return S.createElement(KM,{id:e.id,type:"bar"},r=>S.createElement(S.Fragment,null,S.createElement(fO,{legendPayload:zEe(e)}),S.createElement(BEe,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),S.createElement(mO,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:vq(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),S.createElement(wa,{zIndex:e.zIndex},S.createElement(QEe,Kc({},e,{id:r})))))}var TY=S.memo(e2e,ry);TY.displayName="Bar";function P6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Gv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P6(Object(n),!0).forEach(function(r){t2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function t2e(t,e,n){return(e=n2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n2e(t){var e=r2e(t,"string");return typeof e=="symbol"?e:e+""}function r2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var i2e=(t,e)=>e,a2e=(t,e,n)=>n,s2e=(t,e,n,r)=>r,o2e=(t,e,n,r,i)=>i,iy=Qe([Kb,o2e],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),l2e=Qe([iy],t=>t?.maxBarSize),c2e=(t,e,n,r,i,a)=>a,j6=(t,e,n)=>{var r=n??t;if(!Er(r))return _a(r,e,0)},u2e=Qe([Sn,Kb,i2e,a2e,s2e],(t,e,n,r,i)=>e.filter(a=>t==="horizontal"?a.xAxisId===n:a.yAxisId===r).filter(a=>a.isPanorama===i).filter(a=>a.hide===!1).filter(a=>a.type==="bar")),d2e=(t,e,n,r)=>{var i=Sn(t);return i==="horizontal"?Y0(t,"yAxis",n,r):Y0(t,"xAxis",e,r)},h2e=(t,e,n)=>{var r=Sn(t);return r==="horizontal"?A8(t,"xAxis",e):A8(t,"yAxis",n)},f2e=(t,e,n)=>{var r={},i=t.filter(OM),a=t.filter(u=>u.stackId==null),s=i.reduce((u,d)=>(u[d.stackId]||(u[d.stackId]=[]),u[d.stackId].push(d),u),r),l=Object.entries(s).map(u=>{var[d,f]=u,g=f.map(x=>x.dataKey),p=j6(e,n,f[0].barSize);return{stackId:d,dataKeys:g,barSize:p}}),c=a.map(u=>{var d=[u.dataKey].filter(g=>g!=null),f=j6(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]},m2e=Qe([u2e,Uye,h2e],f2e),p2e=(t,e,n,r,i)=>{var a,s,l=iy(t,e,n,r,i);if(l!=null){var c=Sn(t),u=VK(t),{maxBarSize:d}=l,f=Er(d)?u:d,g,p;return c==="horizontal"?(g=El(t,"xAxis",e,r),p=Ml(t,"xAxis",e,r)):(g=El(t,"yAxis",n,r),p=Ml(t,"yAxis",n,r)),(a=(s=yd(g,p,!0))!==null&&s!==void 0?s:f)!==null&&a!==void 0?a:0}},NY=(t,e,n,r)=>{var i=Sn(t),a,s;return i==="horizontal"?(a=El(t,"xAxis",e,r),s=Ml(t,"xAxis",e,r)):(a=El(t,"yAxis",n,r),s=Ml(t,"yAxis",n,r)),yd(a,s)};function g2e(t,e,n,r,i){var a=r.length;if(!(a<1)){var s=_a(t,n,0,!0),l,c=[];if(Qn(r[0].barSize)){var u=!1,d=n/a,f=r.reduce((b,E)=>b+(E.barSize||0),0);f+=(a-1)*s,f>=n&&(f-=(a-1)*s,s=0),f>=n&&d>0&&(u=!0,d*=.9,f=a*d);var g=(n-f)/2>>0,p={offset:g-s,size:0};l=r.reduce((b,E)=>{var w,A={stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:p.offset+p.size+s,size:u?d:(w=E.barSize)!==null&&w!==void 0?w:0}},T=[...b,A];return p=T[T.length-1].position,T},c)}else{var x=_a(e,n,0,!0);n-2*x-(a-1)*s<=0&&(s=0);var v=(n-2*x-(a-1)*s)/a;v>1&&(v>>=0);var y=Qn(i)?Math.min(v,i):v;l=r.reduce((b,E,w)=>[...b,{stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:x+(v+s)*w+(v-y)/2,size:y}}],c)}return l}}var x2e=(t,e,n,r,i,a,s)=>{var l=Er(s)?e:s,c=g2e(n,r,i!==a?i:a,t,l);return i!==a&&c!=null&&(c=c.map(u=>Gv(Gv({},u),{},{position:Gv(Gv({},u.position),{},{offset:u.position.offset-i/2})}))),c},b2e=Qe([m2e,VK,Fye,GK,p2e,NY,l2e],x2e),y2e=(t,e,n,r)=>El(t,"xAxis",e,r),v2e=(t,e,n,r)=>El(t,"yAxis",n,r),_2e=(t,e,n,r)=>Ml(t,"xAxis",e,r),w2e=(t,e,n,r)=>Ml(t,"yAxis",n,r),S2e=Qe([b2e,iy],(t,e)=>{if(!(t==null||e==null)){var n=t.find(r=>r.stackId===e.stackId&&e.dataKey!=null&&r.dataKeys.includes(e.dataKey));if(n!=null)return n.position}}),M2e=(t,e)=>{var n=DM(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:a}=i;if(a)return a.find(s=>s.key===n)}}}},E2e=Qe([d2e,iy],M2e),A2e=Qe([Ei,BR,y2e,v2e,_2e,w2e,S2e,Sn,Vb,NY,E2e,iy,c2e],(t,e,n,r,i,a,s,l,c,u,d,f,g)=>{var{chartData:p,dataStartIndex:x,dataEndIndex:v}=c;if(!(f==null||s==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||a==null||u==null)){var{data:y}=f,b;if(y!=null&&y.length>0?b=y:b=p?.slice(x,v+1),b!=null)return JEe({layout:l,barSettings:f,pos:s,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:b,offset:t,cells:g,dataStartIndex:x})}}),CY=t=>{var{chartData:e}=t,n=gr(),r=Ai();return S.useEffect(()=>r?()=>{}:(n(U8(e)),()=>{n(U8(void 0))}),[e,n,r]),null},R6={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},kY=ls({name:"brush",initialState:R6,reducers:{setBrushSettings(t,e){return e.payload==null?R6:e.payload}}}),{setBrushSettings:oqe}=kY.actions,T2e=kY.reducer;function D6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Wv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?D6(Object(n),!0).forEach(function(r){PY(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):D6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function PY(t,e,n){return(e=N2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function N2e(t){var e=C2e(t,"string");return typeof e=="symbol"?e:e+""}function C2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var k2e=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return{x:Math.min(n,i),y:Math.min(r,a),width:Math.abs(i-n),height:Math.abs(a-r)}},P2e=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return k2e({x:e,y:n},{x:r,y:i})};class QM{static create(e){return new QM(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var a=this.bandwidth?this.bandwidth():0;return this.scale(e)+a}default:return this.scale(e)}if(n){var s=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+s}return this.scale(e)}}isInRange(e){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?e>=r&&e<=i:e>=i&&e<=r}}PY(QM,"EPS",1e-4);var j2e=t=>{var e=Object.keys(t).reduce((n,r)=>Wv(Wv({},n),{},{[r]:QM.create(t[r])}),{});return Wv(Wv({},e),{},{apply(n){var{bandAware:r,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.fromEntries(Object.entries(n).map(a=>{var[s,l]=a;return[s,e[s].apply(l,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function R2e(t){return(t%180+180)%180}var D2e=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=R2e(i),s=a*Math.PI/180,l=Math.atan(r/n),c=s>l&&s<Math.PI-l?r/Math.sin(s):n/Math.cos(s);return Math.abs(c)},O2e={dots:[],areas:[],lines:[]},jY=ls({name:"referenceElements",initialState:O2e,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Ho(t).dots.findIndex(r=>r===e.payload);n!==-1&&t.dots.splice(n,1)},addArea:(t,e)=>{t.areas.push(e.payload)},removeArea:(t,e)=>{var n=Ho(t).areas.findIndex(r=>r===e.payload);n!==-1&&t.areas.splice(n,1)},addLine:(t,e)=>{t.lines.push(e.payload)},removeLine:(t,e)=>{var n=Ho(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:lqe,removeDot:cqe,addArea:uqe,removeArea:dqe,addLine:L2e,removeLine:I2e}=jY.actions,F2e=jY.reducer,RY=S.createContext(void 0),U2e=t=>{var{children:e}=t,[n]=S.useState("".concat(I0("recharts"),"-clip")),r=YM();if(r==null)return null;var{x:i,y:a,width:s,height:l}=r;return S.createElement(RY.Provider,{value:n},S.createElement("defs",null,S.createElement("clipPath",{id:n},S.createElement("rect",{x:i,y:a,height:l,width:s}))),e)},z2e=()=>S.useContext(RY);function O6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function L6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?O6(Object(n),!0).forEach(function(r){B2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):O6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function B2e(t,e,n){return(e=H2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function H2e(t){var e=$2e(t,"string");return typeof e=="symbol"?e:e+""}function $2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Dw(){return Dw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Dw.apply(null,arguments)}var V2e=(t,e)=>{var n;if(S.isValidElement(t))n=S.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!Qn(e.x1)||!Qn(e.y1)||!Qn(e.x2)||!Qn(e.y2))return null;n=S.createElement("line",Dw({},e,{className:"recharts-reference-line-line"}))}return n},G2e=(t,e,n,r,i,a)=>{var{x:s,width:l}=a,c=i.y.apply(t,{position:n});if(ss(c)||e==="discard"&&!i.y.isInRange(c))return null;var u=[{x:s+l,y:c},{x:s,y:c}];return r==="left"?u.reverse():u},W2e=(t,e,n,r,i,a)=>{var{y:s,height:l}=a,c=i.x.apply(t,{position:n});if(ss(c)||e==="discard"&&!i.x.isInRange(c))return null;var u=[{x:c,y:s+l},{x:c,y:s}];return r==="top"?u.reverse():u},q2e=(t,e,n,r)=>{var i=t.map(a=>r.apply(a,{position:n}));return e==="discard"&&i.some(a=>!r.isInRange(a))?null:i},K2e=(t,e,n,r,i,a)=>{var{x:s,y:l,segment:c,ifOverflow:u}=a,d=go(s),f=go(l);return f?G2e(l,u,n,i,t,e):d?W2e(s,u,n,r,t,e):c!=null&&c.length===2?q2e(c,u,n,t):null};function X2e(t){var e=gr();return S.useEffect(()=>(e(L2e(t)),()=>{e(I2e(t))})),null}function Y2e(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,s=Ai(),l=z2e(),c=jt(C=>Dl(C,e)),u=jt(C=>Ol(C,n)),d=jt(C=>_d(C,"xAxis",e,s)),f=jt(C=>_d(C,"yAxis",n,s)),g=Fb();if(!l||!g||c==null||u==null||d==null||f==null)return null;var p=j2e({x:d,y:f}),x=K2e(p,g,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:v,y},{x:b,y:E}]=x,w=a==="hidden"?"url(#".concat(l,")"):void 0,A=L6(L6({clipPath:w},ua(t)),{},{x1:v,y1:y,x2:b,y2:E}),T=P2e({x1:v,y1:y,x2:b,y2:E});return S.createElement(wa,{zIndex:t.zIndex},S.createElement(Or,{className:Pn("recharts-reference-line",i)},V2e(r,A),S.createElement(lY,Dw({},T,{lowerWidth:T.width,upperWidth:T.width}),S.createElement(uY,{label:t.label}),t.children)))}var Z2e={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:Gr.line};function Kx(t){var e=Lr(t,Z2e);return S.createElement(S.Fragment,null,S.createElement(X2e,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),S.createElement(Y2e,e))}Kx.displayName="ReferenceLine";function DY(t,e){if(e<1)return[];if(e===1)return t;for(var n=[],r=0;r<t.length;r+=e)n.push(t[r]);return n}function Q2e(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return D2e(r,n)}function J2e(t,e,n){var r=n==="width",{x:i,y:a,width:s,height:l}=t;return e===1?{start:r?i:a,end:r?i+s:a+l}:{start:r?i+s:a+l,end:r?i:a}}function Ow(t,e,n,r,i){if(t*e<t*r||t*e>t*i)return!1;var a=n();return t*(e-t*a/2-r)>=0&&t*(e+t*a/2-i)<=0}function eAe(t,e){return DY(t,e+1)}function tAe(t,e,n,r,i){for(var a=(r||[]).slice(),{start:s,end:l}=e,c=0,u=1,d=s,f=function(){var x=r?.[c];if(x===void 0)return{v:DY(r,u)};var v=c,y,b=()=>(y===void 0&&(y=n(x,v)),y),E=x.coordinate,w=c===0||Ow(t,E,b,d,l);w||(c=0,d=s,u+=1),w&&(d=E+t*(b()/2+i),c+=u)},g;u<=a.length;)if(g=f(),g)return g.v;return[]}function I6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function xa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I6(Object(n),!0).forEach(function(r){nAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nAe(t,e,n){return(e=rAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rAe(t){var e=iAe(t,"string");return typeof e=="symbol"?e:e+""}function iAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function aAe(t,e,n,r,i){for(var a=(r||[]).slice(),s=a.length,{start:l}=e,{end:c}=e,u=function(g){var p=a[g],x,v=()=>(x===void 0&&(x=n(p,g)),x);if(g===s-1){var y=t*(p.coordinate+t*v()/2-c);a[g]=p=xa(xa({},p),{},{tickCoord:y>0?p.coordinate-y*t:p.coordinate})}else a[g]=p=xa(xa({},p),{},{tickCoord:p.coordinate});if(p.tickCoord!=null){var b=Ow(t,p.tickCoord,v,l,c);b&&(c=p.tickCoord-t*(v()/2+i),a[g]=xa(xa({},p),{},{isShow:!0}))}},d=s-1;d>=0;d--)u(d);return a}function sAe(t,e,n,r,i,a){var s=(r||[]).slice(),l=s.length,{start:c,end:u}=e;if(a){var d=r[l-1],f=n(d,l-1),g=t*(d.coordinate+t*f/2-u);if(s[l-1]=d=xa(xa({},d),{},{tickCoord:g>0?d.coordinate-g*t:d.coordinate}),d.tickCoord!=null){var p=Ow(t,d.tickCoord,()=>f,c,u);p&&(u=d.tickCoord-t*(f/2+i),s[l-1]=xa(xa({},d),{},{isShow:!0}))}}for(var x=a?l-1:l,v=function(E){var w=s[E],A,T=()=>(A===void 0&&(A=n(w,E)),A);if(E===0){var C=t*(w.coordinate-t*T()/2-c);s[E]=w=xa(xa({},w),{},{tickCoord:C<0?w.coordinate-C*t:w.coordinate})}else s[E]=w=xa(xa({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var N=Ow(t,w.tickCoord,T,c,u);N&&(c=w.tickCoord+t*(T()/2+i),s[E]=xa(xa({},w),{},{isShow:!0}))}},y=0;y<x;y++)v(y);return s}function gO(t,e,n){var{tick:r,ticks:i,viewBox:a,minTickGap:s,orientation:l,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(Dt(c)||lg.isSsr){var g;return(g=eAe(i,Dt(c)?c:0))!==null&&g!==void 0?g:[]}var p=[],x=l==="top"||l==="bottom"?"width":"height",v=d&&x==="width"?l0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},y=(w,A)=>{var T=typeof u=="function"?u(w.value,A):w.value;return x==="width"?Q2e(l0(T,{fontSize:e,letterSpacing:n}),v,f):l0(T,{fontSize:e,letterSpacing:n})[x]},b=i.length>=2?Hi(i[1].coordinate-i[0].coordinate):1,E=J2e(a,b,x);return c==="equidistantPreserveStart"?tAe(b,E,y,i,s):(c==="preserveStart"||c==="preserveStartEnd"?p=sAe(b,E,y,i,s,c==="preserveStartEnd"):p=aAe(b,E,y,i,s),p.filter(w=>w.isShow))}var oAe=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=t,s=0;if(e){Array.from(e).forEach(d=>{if(d){var f=d.getBoundingClientRect();f.width>s&&(s=f.width)}});var l=n?n.getBoundingClientRect().width:0,c=i+a,u=s+c+l+(n?r:0);return Math.round(u)}return 0},lAe=["axisLine","width","height","className","hide","ticks","axisType"];function cAe(t,e){if(t==null)return{};var n,r,i=uAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function uAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function hf(){return hf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},hf.apply(null,arguments)}function F6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function oi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?F6(Object(n),!0).forEach(function(r){dAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dAe(t,e,n){return(e=hAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hAe(t){var e=fAe(t,"string");return typeof e=="symbol"?e:e+""}function fAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Rc={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:Gr.axis};function mAe(t){var{x:e,y:n,width:r,height:i,orientation:a,mirror:s,axisLine:l,otherSvgProps:c}=t;if(!l)return null;var u=oi(oi(oi({},c),La(l)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!s||a==="bottom"&&s);u=oi(oi({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!s||a==="right"&&s);u=oi(oi({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return S.createElement("line",hf({},u,{className:Pn("recharts-cartesian-axis-line",lf(l,"className"))}))}function pAe(t,e,n,r,i,a,s,l,c){var u,d,f,g,p,x,v=l?-1:1,y=t.tickSize||s,b=Dt(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,g=n+ +!l*i,f=g-v*y,x=f-v*c,p=b;break;case"left":f=g=t.coordinate,d=e+ +!l*r,u=d-v*y,p=u-v*c,x=b;break;case"right":f=g=t.coordinate,d=e+ +l*r,u=d+v*y,p=u+v*c,x=b;break;default:u=d=t.coordinate,g=n+ +l*i,f=g+v*y,x=f+v*c,p=b;break}return{line:{x1:u,y1:f,x2:d,y2:g},tick:{x:p,y:x}}}function gAe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function xAe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function bAe(t){var{option:e,tickProps:n,value:r}=t,i,a=Pn(n.className,"recharts-cartesian-axis-tick-value");if(S.isValidElement(e))i=S.cloneElement(e,oi(oi({},n),{},{className:a}));else if(typeof e=="function")i=e(oi(oi({},n),{},{className:a}));else{var s="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(s=Pn(s,e?.className)),i=S.createElement($M,hf({},n,{className:s}),r)}return i}var yAe=S.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:s,unit:l,padding:c,tickTextProps:u,orientation:d,mirror:f,x:g,y:p,width:x,height:v,tickSize:y,tickMargin:b,fontSize:E,letterSpacing:w,getTicksConfig:A,events:T,axisType:C}=t,N=gO(oi(oi({},A),{},{ticks:n}),E,w),O=gAe(d,f),k=xAe(d,f),j=La(A),B=of(r),L={};typeof i=="object"&&(L=i);var K=oi(oi({},j),{},{fill:"none"},L),R=N.map($=>oi({entry:$},pAe($,g,p,x,v,d,y,f,b))),q=R.map($=>{var{entry:J,line:ee}=$;return S.createElement(Or,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(J.value,"-").concat(J.coordinate,"-").concat(J.tickCoord)},i&&S.createElement("line",hf({},K,ee,{className:Pn("recharts-cartesian-axis-tick-line",lf(i,"className"))})))}),W=R.map(($,J)=>{var{entry:ee,tick:Q}=$,z=oi(oi(oi(oi({textAnchor:O,verticalAnchor:k},j),{},{stroke:"none",fill:a},B),Q),{},{index:J,payload:ee,visibleTicksCount:N.length,tickFormatter:s,padding:c},u);return S.createElement(Or,hf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(ee.value,"-").concat(ee.coordinate,"-").concat(ee.tickCoord)},Rb(T,ee,J)),r&&S.createElement(bAe,{option:r,tickProps:z,value:"".concat(typeof s=="function"?s(ee.value,J):ee.value).concat(l||"")}))});return S.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(C,"-ticks")},W.length>0&&S.createElement(wa,{zIndex:Gr.label},S.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(C,"-tick-labels"),ref:e},W)),q.length>0&&S.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(C,"-tick-lines")},q))}),vAe=S.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:s,ticks:l,axisType:c}=t,u=cAe(t,lAe),[d,f]=S.useState(""),[g,p]=S.useState(""),x=S.useRef(null);S.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var y;return oAe({ticks:x.current,label:(y=t.labelRef)===null||y===void 0?void 0:y.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var v=S.useCallback(y=>{if(y){var b=y.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=b;var E=b[0];if(E){var w=window.getComputedStyle(E),A=w.fontSize,T=w.letterSpacing;(A!==d||T!==g)&&(f(A),p(T))}}},[d,g]);return s||r!=null&&r<=0||i!=null&&i<=0?null:S.createElement(wa,{zIndex:t.zIndex},S.createElement(Or,{className:Pn("recharts-cartesian-axis",a)},S.createElement(mAe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:La(t)}),S.createElement(yAe,{ref:v,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:g,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:l,unit:t.unit,width:t.width,x:t.x,y:t.y}),S.createElement(lY,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},S.createElement(uY,{label:t.label,labelRef:t.labelRef}),t.children)))}),xO=S.forwardRef((t,e)=>{var n=Lr(t,Rc);return S.createElement(vAe,hf({},n,{ref:e}))});xO.displayName="CartesianAxis";var _Ae=["x1","y1","x2","y2","key"],wAe=["offset"],SAe=["xAxisId","yAxisId"],MAe=["xAxisId","yAxisId"];function U6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ya(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?U6(Object(n),!0).forEach(function(r){EAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function EAe(t,e,n){return(e=AAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function AAe(t){var e=TAe(t,"string");return typeof e=="symbol"?e:e+""}function TAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Nh(){return Nh=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Nh.apply(null,arguments)}function Lw(t,e){if(t==null)return{};var n,r,i=NAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function NAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var CAe=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:s,ry:l}=t;return S.createElement("rect",{x:r,y:i,ry:l,width:a,height:s,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function OY(t){var{option:e,lineItemProps:n}=t,r;if(S.isValidElement(e))r=S.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:a,y1:s,x2:l,y2:c,key:u}=n,d=Lw(n,_Ae),f=(i=La(d))!==null&&i!==void 0?i:{},{offset:g}=f,p=Lw(f,wAe);r=S.createElement("line",Nh({},p,{x1:a,y1:s,x2:l,y2:c,fill:"none",key:u}))}return r}function kAe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:s}=t,l=Lw(t,SAe),c=i.map((u,d)=>{var f=ya(ya({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return S.createElement(OY,{key:"line-".concat(d),option:r,lineItemProps:f})});return S.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function PAe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:s}=t,l=Lw(t,MAe),c=i.map((u,d)=>{var f=ya(ya({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return S.createElement(OY,{option:r,lineItemProps:f,key:"line-".concat(d)})});return S.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function jAe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:a,height:s,horizontalPoints:l,horizontal:c=!0}=t;if(!c||!e||!e.length||l==null)return null;var u=l.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var p=!u[g+1],x=p?i+s-f:u[g+1]-f;if(x<=0)return null;var v=g%e.length;return S.createElement("rect",{key:"react-".concat(g),y:f,x:r,height:x,width:a,stroke:"none",fill:e[v],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return S.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function RAe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:s,height:l,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var p=!u[g+1],x=p?i+s-f:u[g+1]-f;if(x<=0)return null;var v=g%n.length;return S.createElement("rect",{key:"react-".concat(g),x:f,y:a,width:x,height:l,stroke:"none",fill:n[v],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return S.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var DAe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return bq(gO(ya(ya(ya({},Rc),n),{},{ticks:yq(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},OAe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return bq(gO(ya(ya(ya({},Rc),n),{},{ticks:yq(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},LAe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Gr.grid};function Iw(t){var e=$R(),n=VR(),r=Nq(),i=ya(ya({},Lr(t,LAe)),{},{x:Dt(t.x)?t.x:r.left,y:Dt(t.y)?t.y:r.top,width:Dt(t.width)?t.width:r.width,height:Dt(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:s,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:g,verticalValues:p}=i,x=Ai(),v=jt(k=>T8(k,"xAxis",a,x)),y=jt(k=>T8(k,"yAxis",s,x));if(!wl(u)||!wl(d)||!Dt(l)||!Dt(c))return null;var b=i.verticalCoordinatesGenerator||DAe,E=i.horizontalCoordinatesGenerator||OAe,{horizontalPoints:w,verticalPoints:A}=i;if((!w||!w.length)&&typeof E=="function"){var T=g&&g.length,C=E({yAxis:y?ya(ya({},y),{},{ticks:T?g:y.ticks}):void 0,width:e??u,height:n??d,offset:r},T?!0:f);sw(Array.isArray(C),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof C,"]")),Array.isArray(C)&&(w=C)}if((!A||!A.length)&&typeof b=="function"){var N=p&&p.length,O=b({xAxis:v?ya(ya({},v),{},{ticks:N?p:v.ticks}):void 0,width:e??u,height:n??d,offset:r},N?!0:f);sw(Array.isArray(O),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof O,"]")),Array.isArray(O)&&(A=O)}return S.createElement(wa,{zIndex:i.zIndex},S.createElement("g",{className:"recharts-cartesian-grid"},S.createElement(CAe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),S.createElement(jAe,Nh({},i,{horizontalPoints:w})),S.createElement(RAe,Nh({},i,{verticalPoints:A})),S.createElement(kAe,Nh({},i,{offset:r,horizontalPoints:w,xAxis:v,yAxis:y})),S.createElement(PAe,Nh({},i,{offset:r,verticalPoints:A,xAxis:v,yAxis:y}))))}Iw.displayName="CartesianGrid";var LY=(t,e,n,r)=>El(t,"xAxis",e,r),IY=(t,e,n,r)=>Ml(t,"xAxis",e,r),FY=(t,e,n,r)=>El(t,"yAxis",n,r),UY=(t,e,n,r)=>Ml(t,"yAxis",n,r),IAe=Qe([Sn,LY,FY,IY,UY],(t,e,n,r,i)=>Rl(t,"xAxis")?yd(e,r,!1):yd(n,i,!1)),FAe=(t,e,n,r,i)=>i;function UAe(t){return t.type==="line"}var zAe=Qe([Kb,FAe],(t,e)=>t.filter(UAe).find(n=>n.id===e)),BAe=Qe([Sn,LY,FY,IY,UY,zAe,IAe,Vb],(t,e,n,r,i,a,s,l)=>{var{chartData:c,dataStartIndex:u,dataEndIndex:d}=l;if(!(a==null||e==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null||t!=="horizontal"&&t!=="vertical")){var{dataKey:f,data:g}=a,p;if(g!=null&&g.length>0?p=g:p=c?.slice(u,d+1),p!=null)return oTe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:s,displayedData:p})}});function zY(t){var e=of(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:a}=e,s=Number(i),l=Number(a);return(Number.isNaN(s)||s<0)&&(s=n),(Number.isNaN(l)||l<0)&&(l=r),{r:s,strokeWidth:l}}return{r:n,strokeWidth:r}}var HAe=["id"],$Ae=["type","layout","connectNulls","needClip","shape"],VAe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function Q0(){return Q0=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Q0.apply(null,arguments)}function z6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function cl(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?z6(Object(n),!0).forEach(function(r){GAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):z6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function GAe(t,e,n){return(e=WAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function WAe(t){var e=qAe(t,"string");return typeof e=="symbol"?e:e+""}function qAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function bO(t,e){if(t==null)return{};var n,r,i=KAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function KAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var XAe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Pd(n,e),payload:t}]},YAe=S.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:s,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Pd(s,e),hide:l,type:u,color:r,unit:c}};return S.createElement(qM,{tooltipEntrySettings:d})}),BY=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function ZAe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var QAe=(t,e,n)=>{var r=n.reduce((f,g)=>f+g);if(!r)return BY(e,t);for(var i=Math.floor(t/r),a=t%r,s=e-t,l=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>a){l=[...n.slice(0,c),a-u];break}var d=l.length%2===0?[0,s]:[s];return[...ZAe(n,i),...l,...d].map(f=>"".concat(f,"px")).join(", ")};function JAe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:s}=r,{id:l}=r,c=bO(r,HAe),u=La(c);return S.createElement(wY,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:s,clipPathId:e})}function eTe(t){var{showLabels:e,children:n,points:r}=t,i=S.useMemo(()=>r?.map(a=>{var s,l,c={x:(s=a.x)!==null&&s!==void 0?s:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return cl(cl({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return S.createElement(iO,{value:e?i:void 0},n)}function B6(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:a}=t,{type:s,layout:l,connectNulls:c,needClip:u,shape:d}=a,f=bO(a,$Ae),g=cl(cl({},ua(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:s,layout:l,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return S.createElement(S.Fragment,null,r?.length>1&&S.createElement(cO,Q0({shapeType:"curve",option:d},g,{pathRef:n})),S.createElement(JAe,{points:r,clipPathId:e,props:a}))}function tTe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function nTe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=t,{points:s,strokeDasharray:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:g,width:p,height:x,onAnimationEnd:v,onAnimationStart:y}=n,b=i.current,E=ug(s,"recharts-line-"),w=S.useRef(E),[A,T]=S.useState(!1),C=!A,N=S.useCallback(()=>{typeof v=="function"&&v(),T(!1)},[v]),O=S.useCallback(()=>{typeof y=="function"&&y(),T(!0)},[y]),k=tTe(r.current),j=S.useRef(0);w.current!==E&&(j.current=a.current,w.current=E);var B=j.current;return S.createElement(eTe,{points:s,showLabels:C},n.children,S.createElement(cg,{animationId:E,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:N,onAnimationStart:O,key:E},L=>{var K=Vn(B,k+B,L),R=Math.min(K,k),q;if(c)if(l){var W="".concat(l).split(/[,\s]+/gim).map(ee=>parseFloat(ee));q=QAe(R,k,W)}else q=BY(k,R);else q=l==null?void 0:String(l);if(L>0&&k>0&&(i.current=s,a.current=Math.max(a.current,R)),b){var $=b.length/s.length,J=L===1?s:s.map((ee,Q)=>{var z=Math.floor(Q*$);if(b[z]){var V=b[z];return cl(cl({},ee),{},{x:Vn(V.x,ee.x,L),y:Vn(V.y,ee.y,L)})}return g?cl(cl({},ee),{},{x:Vn(p*2,ee.x,L),y:Vn(x/2,ee.y,L)}):cl(cl({},ee),{},{x:ee.x,y:ee.y})});return i.current=J,S.createElement(B6,{props:n,points:J,clipPathId:e,pathRef:r,strokeDasharray:q})}return S.createElement(B6,{props:n,points:s,clipPathId:e,pathRef:r,strokeDasharray:q})}),S.createElement(VM,{label:n.label}))}function rTe(t){var{clipPathId:e,props:n}=t,r=S.useRef(null),i=S.useRef(0),a=S.useRef(null);return S.createElement(nTe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var iTe=(t,e)=>{var n,r;return{x:(n=t.x)!==null&&n!==void 0?n:void 0,y:(r=t.y)!==null&&r!==void 0?r:void 0,value:t.value,errorVal:Zn(t.payload,e)}};class aTe extends S.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:s,top:l,left:c,width:u,height:d,id:f,needClip:g,zIndex:p}=this.props;if(e)return null;var x=Pn("recharts-line",i),v=f,{r:y,strokeWidth:b}=zY(n),E=lO(n),w=y*2+b,A=g?"url(#clipPath-".concat(E?"":"dots-").concat(v,")"):void 0;return S.createElement(wa,{zIndex:p},S.createElement(Or,{className:x},g&&S.createElement("defs",null,S.createElement(pO,{clipPathId:v,xAxisId:a,yAxisId:s}),!E&&S.createElement("clipPath",{id:"clipPath-dots-".concat(v)},S.createElement("rect",{x:c-w/2,y:l-w/2,width:u+w,height:d+w}))),S.createElement(EY,{xAxisId:a,yAxisId:s,data:r,dataPointFormatter:iTe,errorBarOffset:0},S.createElement(rTe,{props:this.props,clipPathId:v}))),S.createElement(eP,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var HY={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:Gr.line,type:"linear"};function sTe(t){var e=Lr(t,HY),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:s,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:f,legendType:g,xAxisId:p,yAxisId:x,id:v}=e,y=bO(e,VAe),{needClip:b}=ZM(p,x),E=YM(),w=Ef(),A=Ai(),T=jt(j=>BAe(j,p,x,A,v));if(w!=="horizontal"&&w!=="vertical"||T==null||E==null)return null;var{height:C,width:N,x:O,y:k}=E;return S.createElement(aTe,Q0({},y,{id:v,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:s,isAnimationActive:d,hide:u,label:f,legendType:g,xAxisId:p,yAxisId:x,points:T,layout:w,height:C,width:N,left:O,top:k,needClip:b}))}function oTe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:s,bandSize:l,displayedData:c}=t;return c.map((u,d)=>{var f=Zn(u,s);if(e==="horizontal"){var g=aw({axis:n,ticks:i,bandSize:l,entry:u,index:d}),p=Er(f)?null:r.scale(f);return{x:g,y:p,value:f,payload:u}}var x=Er(f)?null:n.scale(f),v=aw({axis:r,ticks:a,bandSize:l,entry:u,index:d});return x==null||v==null?null:{x,y:v,value:f,payload:u}}).filter(Boolean)}function lTe(t){var e=Lr(t,HY),n=Ai();return S.createElement(KM,{id:e.id,type:"line"},r=>S.createElement(S.Fragment,null,S.createElement(fO,{legendPayload:XAe(e)}),S.createElement(YAe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),S.createElement(mO,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),S.createElement(sTe,Q0({},e,{id:r}))))}var $Y=S.memo(lTe,ry);$Y.displayName="Line";var VY=(t,e,n,r)=>El(t,"xAxis",e,r),GY=(t,e,n,r)=>Ml(t,"xAxis",e,r),WY=(t,e,n,r)=>El(t,"yAxis",n,r),qY=(t,e,n,r)=>Ml(t,"yAxis",n,r),cTe=Qe([Sn,VY,WY,GY,qY],(t,e,n,r,i)=>Rl(t,"xAxis")?yd(e,r,!1):yd(n,i,!1)),uTe=(t,e,n,r,i)=>i,KY=Qe([Kb,uTe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),dTe=(t,e,n,r,i)=>{var a,s=KY(t,e,n,r,i);if(s!=null){var l=Sn(t),c=Rl(l,"xAxis"),u;if(c?u=Y0(t,"yAxis",n,r):u=Y0(t,"xAxis",e,r),u!=null){var{stackId:d}=s,f=DM(s);if(!(d==null||f==null)){var g=(a=u[d])===null||a===void 0?void 0:a.stackedData;return g?.find(p=>p.key===f)}}}},hTe=Qe([Sn,VY,WY,GY,qY,dTe,Vb,cTe,KY,zye],(t,e,n,r,i,a,s,l,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:g}=s;if(!(c==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||l==null)){var{data:p}=c,x;if(p&&p.length>0?x=p:x=d?.slice(f,g+1),x!=null)return PTe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:x,chartBaseValue:u,bandSize:l})}}),fTe=["id"],mTe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function zh(){return zh=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},zh.apply(null,arguments)}function XY(t,e){if(t==null)return{};var n,r,i=pTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function pTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function H6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function op(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?H6(Object(n),!0).forEach(function(r){gTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):H6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gTe(t,e,n){return(e=xTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xTe(t){var e=bTe(t,"string");return typeof e=="symbol"?e:e+""}function bTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Fw(t,e){return t&&t!=="none"?t:e}var yTe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:s}=t;return[{inactive:s,dataKey:e,type:a,color:Fw(r,i),value:Pd(n,e),payload:t}]},vTe=S.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:s,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Pd(s,e),hide:l,type:u,color:Fw(r,a),unit:c}};return S.createElement(qM,{tooltipEntrySettings:d})});function _Te(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:s}=r,l=La(r);return S.createElement(wY,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:s,baseProps:l,needClip:i,clipPathId:e})}function wTe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(a=>{var s,l,c={x:(s=a.x)!==null&&s!==void 0?s:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return op(op({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return S.createElement(iO,{value:e?i:void 0},n)}function $6(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:a}=t,{layout:s,type:l,stroke:c,connectNulls:u,isRange:d}=a,{id:f}=a,g=XY(a,fTe),p=La(g),x=ua(g);return S.createElement(S.Fragment,null,e?.length>1&&S.createElement(Or,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},S.createElement(fp,zh({},x,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:s,stroke:"none",className:"recharts-area-area"})),c!=="none"&&S.createElement(fp,zh({},p,{className:"recharts-area-curve",layout:s,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&S.createElement(fp,zh({},p,{className:"recharts-area-curve",layout:s,type:l,connectNulls:u,fill:"none",points:n}))),S.createElement(_Te,{points:e,props:g,clipPathId:i}))}function STe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,s=r[r.length-1].y;if(!Qn(a)||!Qn(s))return null;var l=e*Math.abs(a-s),c=Math.max(...r.map(u=>u.x||0));return Dt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Dt(c)?S.createElement("rect",{x:0,y:a<s?a:a-l,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(l)}):null}function MTe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,s=r[r.length-1].x;if(!Qn(a)||!Qn(s))return null;var l=e*Math.abs(a-s),c=Math.max(...r.map(u=>u.y||0));return Dt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Dt(c)?S.createElement("rect",{x:a<s?a:a-l,y:0,width:l,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function ETe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?S.createElement(STe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):S.createElement(MTe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function ATe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=t,{points:s,baseLine:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:g,onAnimationEnd:p}=r,x=S.useMemo(()=>({points:s,baseLine:l}),[s,l]),v=ug(x,"recharts-area-"),y=ige(),[b,E]=S.useState(!1),w=!b,A=S.useCallback(()=>{typeof p=="function"&&p(),E(!1)},[p]),T=S.useCallback(()=>{typeof g=="function"&&g(),E(!0)},[g]);if(y==null)return null;var C=i.current,N=a.current;return S.createElement(wTe,{showLabels:w,points:s},r.children,S.createElement(cg,{animationId:v,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:A,onAnimationStart:T,key:v},O=>{if(C){var k=C.length/s.length,j=O===1?s:s.map((L,K)=>{var R=Math.floor(K*k);if(C[R]){var q=C[R];return op(op({},L),{},{x:Vn(q.x,L.x,O),y:Vn(q.y,L.y,O)})}return L}),B;return Dt(l)?B=Vn(N,l,O):Er(l)||ss(l)?B=Vn(N,0,O):B=l.map((L,K)=>{var R=Math.floor(K*k);if(Array.isArray(N)&&N[R]){var q=N[R];return op(op({},L),{},{x:Vn(q.x,L.x,O),y:Vn(q.y,L.y,O)})}return L}),O>0&&(i.current=j,a.current=B),S.createElement($6,{points:j,baseLine:B,needClip:e,clipPathId:n,props:r})}return O>0&&(i.current=s,a.current=l),S.createElement(Or,null,c&&S.createElement("defs",null,S.createElement("clipPath",{id:"animationClipPath-".concat(n)},S.createElement(ETe,{alpha:O,points:s,baseLine:l,layout:y,strokeWidth:r.strokeWidth}))),S.createElement(Or,{clipPath:"url(#animationClipPath-".concat(n,")")},S.createElement($6,{points:s,baseLine:l,needClip:e,clipPathId:n,props:r})))}),S.createElement(VM,{label:r.label}))}function TTe(t){var{needClip:e,clipPathId:n,props:r}=t,i=S.useRef(null),a=S.useRef();return S.createElement(ATe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class NTe extends S.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:s,needClip:l,xAxisId:c,yAxisId:u,width:d,height:f,id:g,baseLine:p,zIndex:x}=this.props;if(e)return null;var v=Pn("recharts-area",i),y=g,{r:b,strokeWidth:E}=zY(n),w=lO(n),A=b*2+E,T=l?"url(#clipPath-".concat(w?"":"dots-").concat(y,")"):void 0;return S.createElement(wa,{zIndex:x},S.createElement(Or,{className:v},l&&S.createElement("defs",null,S.createElement(pO,{clipPathId:y,xAxisId:c,yAxisId:u}),!w&&S.createElement("clipPath",{id:"clipPath-dots-".concat(y)},S.createElement("rect",{x:s-A/2,y:a-A/2,width:d+A,height:f+A}))),S.createElement(TTe,{needClip:l,clipPathId:y,props:this.props})),S.createElement(eP,{points:r,mainColor:Fw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(p)&&S.createElement(eP,{points:p,mainColor:Fw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var YY={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:Gr.area};function CTe(t){var e,n=Lr(t,YY),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:s,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:g,legendType:p,stroke:x,xAxisId:v,yAxisId:y}=n,b=XY(n,mTe),E=Ef(),w=GX(),{needClip:A}=ZM(v,y),T=Ai(),{points:C,isRange:N,baseLine:O}=(e=jt(R=>hTe(R,v,y,T,t.id)))!==null&&e!==void 0?e:{},k=YM();if(E!=="horizontal"&&E!=="vertical"||k==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:j,width:B,x:L,y:K}=k;return!C||!C.length?null:S.createElement(NTe,zh({},b,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:s,baseLine:O,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:j,hide:f,layout:E,isAnimationActive:g==="auto"?!lg.isSsr:g,isRange:N,legendType:p,needClip:A,points:C,stroke:x,width:B,left:L,top:K,xAxisId:v,yAxisId:y}))}var kTe=(t,e,n,r,i)=>{var a=n??e;if(Dt(a))return a;var s=t==="horizontal"?i:r,l=s.scale.domain();if(s.type==="number"){var c=Math.max(l[0],l[1]),u=Math.min(l[0],l[1]);return a==="dataMin"?u:a==="dataMax"||c<0?c:Math.max(Math.min(l[0],l[1]),0)}return a==="dataMin"?l[0]:a==="dataMax"?l[1]:l[0]};function PTe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:s,xAxis:l,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:g,bandSize:p}=t,x=i&&i.length,v=kTe(a,s,n,l,c),y=a==="horizontal",b=!1,E=u.map((A,T)=>{var C;x?C=i[d+T]:(C=Zn(A,r),Array.isArray(C)?b=!0:C=[v,C]);var N=C[1]==null||x&&!e&&Zn(A,r)==null;return y?{x:aw({axis:l,ticks:f,bandSize:p,entry:A,index:T}),y:N?null:c.scale(C[1]),value:C,payload:A}:{x:N?null:l.scale(C[1]),y:aw({axis:c,ticks:g,bandSize:p,entry:A,index:T}),value:C,payload:A}}),w;return x||b?w=E.map(A=>{var T=Array.isArray(A.value)?A.value[0]:null;return y?{x:A.x,y:T!=null&&A.y!=null?c.scale(T):null,payload:A.payload}:{x:T!=null?l.scale(T):null,y:A.y,payload:A.payload}}):w=y?c.scale(v):l.scale(v),{points:E,baseLine:w,isRange:b}}function jTe(t){var e=Lr(t,YY),n=Ai();return S.createElement(KM,{id:e.id,type:"area"},r=>S.createElement(S.Fragment,null,S.createElement(fO,{legendPayload:yTe(e)}),S.createElement(vTe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),S.createElement(mO,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:vq(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),S.createElement(CTe,zh({},e,{id:r}))))}var ZY=S.memo(jTe,ry);ZY.displayName="Area";var RTe=["domain","range"],DTe=["domain","range"];function V6(t,e){if(t==null)return{};var n,r,i=OTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function OTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function G6(t,e){return t===e?!0:Array.isArray(t)&&t.length===2&&Array.isArray(e)&&e.length===2?t[0]===e[0]&&t[1]===e[1]:!1}function QY(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=V6(t,RTe),{domain:a,range:s}=e,l=V6(e,DTe);return!G6(n,a)||!G6(r,s)?!1:ry(i,l)}var LTe=["dangerouslySetInnerHTML","ticks"],ITe=["id"];function nP(){return nP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},nP.apply(null,arguments)}function W6(t,e){if(t==null)return{};var n,r,i=FTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function FTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function UTe(t){var e=gr(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?e(RMe(t)):n.current!==t&&e(DMe({prev:n.current,next:t})),n.current=t},[t,e]),S.useLayoutEffect(()=>()=>{n.current&&(e(OMe(n.current)),n.current=null)},[e]),null}var zTe=t=>{var{xAxisId:e,className:n}=t,r=jt(BR),i=Ai(),a="xAxis",s=jt(y=>_d(y,a,e,i)),l=jt(y=>SX(y,a,e,i)),c=jt(y=>yX(y,e)),u=jt(y=>Ive(y,e)),d=jt(y=>eX(y,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:g}=t,p=W6(t,LTe),{id:x}=d,v=W6(d,ITe);return S.createElement(xO,nP({},p,v,{scale:s,x:u.x,y:u.y,width:c.width,height:c.height,className:Pn("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:l,axisType:a}))},BTe={allowDataOverflow:Li.allowDataOverflow,allowDecimals:Li.allowDecimals,allowDuplicatedCategory:Li.allowDuplicatedCategory,angle:Li.angle,axisLine:Rc.axisLine,height:Li.height,hide:!1,includeHidden:Li.includeHidden,interval:Li.interval,minTickGap:Li.minTickGap,mirror:Li.mirror,orientation:Li.orientation,padding:Li.padding,reversed:Li.reversed,scale:Li.scale,tick:Li.tick,tickCount:Li.tickCount,tickLine:Rc.tickLine,tickSize:Rc.tickSize,type:Li.type,xAxisId:0},HTe=t=>{var e=Lr(t,BTe);return S.createElement(S.Fragment,null,S.createElement(UTe,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),S.createElement(zTe,e))},Uw=S.memo(HTe,QY);Uw.displayName="XAxis";var $Te=["dangerouslySetInnerHTML","ticks"],VTe=["id"];function rP(){return rP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},rP.apply(null,arguments)}function q6(t,e){if(t==null)return{};var n,r,i=GTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function GTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function WTe(t){var e=gr(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?e(LMe(t)):n.current!==t&&e(IMe({prev:n.current,next:t})),n.current=t},[t,e]),S.useLayoutEffect(()=>()=>{n.current&&(e(FMe(n.current)),n.current=null)},[e]),null}var qTe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=S.useRef(null),s=S.useRef(null),l=jt(BR),c=Ai(),u=gr(),d="yAxis",f=jt(T=>_d(T,d,e,c)),g=jt(T=>vX(T,e)),p=jt(T=>Uve(T,e)),x=jt(T=>SX(T,d,e,c)),v=jt(T=>tX(T,e));if(S.useLayoutEffect(()=>{if(!(r!=="auto"||!g||rO(i)||S.isValidElement(i)||v==null)){var T=a.current;if(T){var C=T.getCalculatedWidth();Math.round(g.width)!==Math.round(C)&&u(UMe({id:e,width:C}))}}},[x,g,u,i,e,r,v]),g==null||p==null||v==null)return null;var{dangerouslySetInnerHTML:y,ticks:b}=t,E=q6(t,$Te),{id:w}=v,A=q6(v,VTe);return S.createElement(xO,rP({},E,A,{ref:a,labelRef:s,scale:f,x:p.x,y:p.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:Pn("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:x,axisType:d}))},KTe={allowDataOverflow:Ii.allowDataOverflow,allowDecimals:Ii.allowDecimals,allowDuplicatedCategory:Ii.allowDuplicatedCategory,angle:Ii.angle,axisLine:Rc.axisLine,hide:!1,includeHidden:Ii.includeHidden,interval:Ii.interval,minTickGap:Ii.minTickGap,mirror:Ii.mirror,orientation:Ii.orientation,padding:Ii.padding,reversed:Ii.reversed,scale:Ii.scale,tick:Ii.tick,tickCount:Ii.tickCount,tickLine:Rc.tickLine,tickSize:Rc.tickSize,type:Ii.type,width:Ii.width,yAxisId:0},XTe=t=>{var e=Lr(t,KTe);return S.createElement(S.Fragment,null,S.createElement(WTe,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),S.createElement(qTe,e))},zw=S.memo(XTe,QY);zw.displayName="YAxis";var YTe=(t,e)=>e,yO=Qe([YTe,Sn,QK,Ni,UX,eu,e1e,Ei],o1e),vO=t=>{var e=t.currentTarget.getBoundingClientRect(),n=e.width/t.currentTarget.offsetWidth,r=e.height/t.currentTarget.offsetHeight;return{chartX:Math.round((t.clientX-e.left)/n),chartY:Math.round((t.clientY-e.top)/r)}},JY=xo("mouseClick"),eZ=Lb();eZ.startListening({actionCreator:JY,effect:(t,e)=>{var n=t.payload,r=yO(e.getState(),vO(n));r?.activeIndex!=null&&e.dispatch(Jve({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var iP=xo("mouseMove"),tZ=Lb(),qv=null;tZ.startListening({actionCreator:iP,effect:(t,e)=>{var n=t.payload;qv!==null&&cancelAnimationFrame(qv);var r=vO(n);qv=requestAnimationFrame(()=>{var i=e.getState(),a=WD(i,i.tooltip.settings.shared);if(a==="axis"){var s=yO(i,r);s?.activeIndex!=null?e.dispatch(PX({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate})):e.dispatch(kX())}qv=null})}});var K6={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0,reverseStackOrder:!1},nZ=ls({name:"rootProps",initialState:K6,reducers:{updateOptions:(t,e)=>{var n;t.accessibilityLayer=e.payload.accessibilityLayer,t.barCategoryGap=e.payload.barCategoryGap,t.barGap=(n=e.payload.barGap)!==null&&n!==void 0?n:K6.barGap,t.barSize=e.payload.barSize,t.maxBarSize=e.payload.maxBarSize,t.stackOffset=e.payload.stackOffset,t.syncId=e.payload.syncId,t.syncMethod=e.payload.syncMethod,t.className=e.payload.className,t.baseValue=e.payload.baseValue,t.reverseStackOrder=e.payload.reverseStackOrder}}}),ZTe=nZ.reducer,{updateOptions:QTe}=nZ.actions,rZ=ls({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:JTe}=rZ.actions,eNe=rZ.reducer,iZ=xo("keyDown"),aZ=xo("focus"),_O=Lb();_O.startListening({actionCreator:iZ,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,a=t.payload;if(!(a!=="ArrowRight"&&a!=="ArrowLeft"&&a!=="Enter")){var s=qD(i,bg(n),Yb(n),ey(n)),l=s==null?-1:Number(s);if(!(!Number.isFinite(l)||l<0)){var c=eu(n);if(a==="Enter"){var u=Tw(n,"axis","hover",String(i.index));e.dispatch(K3({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=$ve(n),f=d==="left-to-right"?1:-1,g=a==="ArrowRight"?1:-1,p=l+g*f;if(!(c==null||p>=c.length||p<0)){var x=Tw(n,"axis","hover",String(p));e.dispatch(K3({active:!0,activeIndex:p.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});_O.startListening({actionCreator:aZ,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var a="0",s=Tw(n,"axis","hover",String(a));e.dispatch(K3({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:s}))}}}});var Ks=xo("externalEvent"),sZ=Lb(),TN=new Map;sZ.startListening({actionCreator:Ks,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=TN.get(i);a!==void 0&&cancelAnimationFrame(a);var s=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:U_e(l),activeDataKey:QD(l),activeIndex:wd(l),activeLabel:HX(l),activeTooltipIndex:wd(l),isTooltipActive:z_e(l)};n(c,r)}finally{TN.delete(i)}});TN.set(i,s)}}});var tNe=Qe([xg],t=>t.tooltipItemPayloads),nNe=Qe([tNe,Qb,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(l=>l.settings.dataKey===r);if(i!=null){var{positions:a}=i;if(a!=null){var s=e(a,n);return s}}}),oZ=xo("touchMove"),lZ=Lb();lZ.startListening({actionCreator:oZ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=WD(r,r.tooltip.settings.shared);if(i==="axis"){var a=yO(r,vO({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(PX({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate}))}else if(i==="item"){var s,l=n.touches[0];if(document.elementFromPoint==null)return;var c=document.elementFromPoint(l.clientX,l.clientY);if(!c||!c.getAttribute)return;var u=c.getAttribute(wq),d=(s=c.getAttribute(Sq))!==null&&s!==void 0?s:void 0,f=nNe(e.getState(),u,d);e.dispatch(CX({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var rNe=$W({brush:T2e,cartesianAxis:zMe,chartData:F1e,errorBars:aEe,graphicalItems:qSe,layout:dpe,legend:yge,options:R1e,polarAxis:lSe,polarOptions:eNe,referenceElements:F2e,rootProps:ZTe,tooltip:e_e,zIndex:_1e}),iNe=function(e){return Lme({reducer:rNe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([eZ.middleware,tZ.middleware,_O.middleware,sZ.middleware,lZ.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(iq({type:"raf"}))},devTools:lg.devToolsEnabled})};function cZ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=Ai(),a=S.useRef(null);if(i)return n;a.current==null&&(a.current=iNe(e));var s=jR;return S.createElement(CEe,{context:s,store:a.current},n)}function aNe(t){var{layout:e,margin:n}=t,r=gr(),i=Ai();return S.useEffect(()=>{i||(r(lpe(e)),r(ope(n)))},[r,i,e,n]),null}var uZ=S.memo(aNe,ry);function dZ(t){var e=gr();return S.useEffect(()=>{e(QTe(t))},[e,t]),null}function X6(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=yY("".concat(r).concat(e)),a=gr();return S.useLayoutEffect(()=>(a(y1e({zIndex:e,elementId:i,isPanorama:n})),()=>{a(v1e({zIndex:e,isPanorama:n}))}),[a,e,i,n]),S.createElement("g",{tabIndex:-1,id:i})}function Y6(t){var{children:e,isPanorama:n}=t,r=jt(c1e);if(!r||r.length===0)return e;var i=r.filter(s=>s<0),a=r.filter(s=>s>0);return S.createElement(S.Fragment,null,i.map(s=>S.createElement(X6,{key:s,zIndex:s,isPanorama:n})),e,a.map(s=>S.createElement(X6,{key:s,zIndex:s,isPanorama:n})))}var sNe=["children"];function oNe(t,e){if(t==null)return{};var n,r,i=lNe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function lNe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Bw(){return Bw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Bw.apply(null,arguments)}var cNe={width:"100%",height:"100%",display:"block"},uNe=S.forwardRef((t,e)=>{var n=$R(),r=VR(),i=Uq();if(!wl(n)||!wl(r))return null;var{children:a,otherAttributes:s,title:l,desc:c}=t,u,d;return s!=null&&(typeof s.tabIndex=="number"?u=s.tabIndex:u=i?0:void 0,typeof s.role=="string"?d=s.role:d=i?"application":void 0),S.createElement(wR,Bw({},s,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:cNe,ref:e}),a)}),dNe=t=>{var{children:e}=t,n=jt(_M);if(!n)return null;var{width:r,height:i,y:a,x:s}=n;return S.createElement(wR,{width:r,height:i,x:s,y:a},e)},Z6=S.forwardRef((t,e)=>{var{children:n}=t,r=oNe(t,sNe),i=Ai();return i?S.createElement(dNe,null,S.createElement(Y6,{isPanorama:!0},n)):S.createElement(uNe,Bw({ref:e},r),S.createElement(Y6,{isPanorama:!1},n))});function hNe(){var t=gr(),[e,n]=S.useState(null),r=jt(Npe);return S.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;Qn(a)&&a!==r&&t(upe(a))}},[e,t,r]),n}function Q6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function fNe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Q6(Object(n),!0).forEach(function(r){mNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Q6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mNe(t,e,n){return(e=pNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pNe(t){var e=gNe(t,"string");return typeof e=="symbol"?e:e+""}function gNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ff(){return ff=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},ff.apply(null,arguments)}var xNe=()=>(q1e(),null);function Hw(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var bNe=S.forwardRef((t,e)=>{var n,r,i=S.useRef(null),[a,s]=S.useState({containerWidth:Hw((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:Hw((r=t.style)===null||r===void 0?void 0:r.height)}),l=S.useCallback((u,d)=>{s(f=>{var g=Math.round(u),p=Math.round(d);return f.containerWidth===g&&f.containerHeight===p?f:{containerWidth:g,containerHeight:p}})},[]),c=S.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();l(d,f);var g=x=>{var{width:v,height:y}=x[0].contentRect;l(v,y)},p=new ResizeObserver(g);p.observe(u),i.current=p}},[e,l]);return S.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),S.createElement(S.Fragment,null,S.createElement(wM,{width:a.containerWidth,height:a.containerHeight}),S.createElement("div",ff({ref:c},t)))}),yNe=S.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=S.useState({containerWidth:Hw(n),containerHeight:Hw(r)}),s=S.useCallback((c,u)=>{a(d=>{var f=Math.round(c),g=Math.round(u);return d.containerWidth===f&&d.containerHeight===g?d:{containerWidth:f,containerHeight:g}})},[]),l=S.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();s(u,d)}},[e,s]);return S.createElement(S.Fragment,null,S.createElement(wM,{width:i.containerWidth,height:i.containerHeight}),S.createElement("div",ff({ref:l},t)))}),vNe=S.forwardRef((t,e)=>{var{width:n,height:r}=t;return S.createElement(S.Fragment,null,S.createElement(wM,{width:n,height:r}),S.createElement("div",ff({ref:e},t)))}),_Ne=S.forwardRef((t,e)=>{var{width:n,height:r}=t;return Hc(n)||Hc(r)?S.createElement(yNe,ff({},t,{ref:e})):S.createElement(vNe,ff({},t,{ref:e}))});function wNe(t){return t===!0?bNe:_Ne}var SNe=S.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:s,onDoubleClick:l,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:g,onTouchEnd:p,onTouchMove:x,onTouchStart:v,style:y,width:b,responsive:E,dispatchTouchEvents:w=!0}=t,A=S.useRef(null),T=gr(),[C,N]=S.useState(null),[O,k]=S.useState(null),j=hNe(),B=HR(),L=B?.width>0?B.width:b,K=B?.height>0?B.height:i,R=S.useCallback(pe=>{j(pe),typeof e=="function"&&e(pe),N(pe),k(pe),pe!=null&&(A.current=pe)},[j,e,N,k]),q=S.useCallback(pe=>{T(JY(pe)),T(Ks({handler:a,reactEvent:pe}))},[T,a]),W=S.useCallback(pe=>{T(iP(pe)),T(Ks({handler:u,reactEvent:pe}))},[T,u]),$=S.useCallback(pe=>{T(kX()),T(Ks({handler:d,reactEvent:pe}))},[T,d]),J=S.useCallback(pe=>{T(iP(pe)),T(Ks({handler:f,reactEvent:pe}))},[T,f]),ee=S.useCallback(()=>{T(aZ())},[T]),Q=S.useCallback(pe=>{T(iZ(pe.key))},[T]),z=S.useCallback(pe=>{T(Ks({handler:s,reactEvent:pe}))},[T,s]),V=S.useCallback(pe=>{T(Ks({handler:l,reactEvent:pe}))},[T,l]),X=S.useCallback(pe=>{T(Ks({handler:c,reactEvent:pe}))},[T,c]),te=S.useCallback(pe=>{T(Ks({handler:g,reactEvent:pe}))},[T,g]),ie=S.useCallback(pe=>{T(Ks({handler:v,reactEvent:pe}))},[T,v]),le=S.useCallback(pe=>{w&&T(oZ(pe)),T(Ks({handler:x,reactEvent:pe}))},[T,w,x]),ge=S.useCallback(pe=>{T(Ks({handler:p,reactEvent:pe}))},[T,p]),Ee=wNe(E);return S.createElement(YX.Provider,{value:C},S.createElement(iW.Provider,{value:O},S.createElement(Ee,{width:L??y?.width,height:K??y?.height,className:Pn("recharts-wrapper",r),style:fNe({position:"relative",cursor:"default",width:L,height:K},y),onClick:q,onContextMenu:z,onDoubleClick:V,onFocus:ee,onKeyDown:Q,onMouseDown:X,onMouseEnter:W,onMouseLeave:$,onMouseMove:J,onMouseUp:te,onTouchEnd:ge,onTouchMove:le,onTouchStart:ie,ref:R},S.createElement(xNe,null),n)))}),MNe=["width","height","responsive","children","className","style","compact","title","desc"];function ENe(t,e){if(t==null)return{};var n,r,i=ANe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function ANe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var hZ=S.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:s,style:l,compact:c,title:u,desc:d}=t,f=ENe(t,MNe),g=La(f);return c?S.createElement(S.Fragment,null,S.createElement(wM,{width:n,height:r}),S.createElement(Z6,{otherAttributes:g,title:u,desc:d},a)):S.createElement(SNe,{className:s,style:l,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},S.createElement(Z6,{otherAttributes:g,title:u,desc:d,ref:e},S.createElement(U2e,null,a)))});function aP(){return aP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},aP.apply(null,arguments)}var TNe={top:5,right:5,bottom:5,left:5},NNe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:TNe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},wO=S.forwardRef(function(e,n){var r,i=Lr(e.categoricalChartProps,NNe),{chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return S.createElement(cZ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},S.createElement(CY,{chartData:u.data}),S.createElement(uZ,{layout:i.layout,margin:i.margin}),S.createElement(dZ,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),S.createElement(hZ,aP({},i,{ref:n})))}),CNe=["axis"],kNe=S.forwardRef((t,e)=>S.createElement(wO,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:CNe,tooltipPayloadSearcher:HM,categoricalChartProps:t,ref:e})),PNe=["axis","item"],jNe=S.forwardRef((t,e)=>S.createElement(wO,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:PNe,tooltipPayloadSearcher:HM,categoricalChartProps:t,ref:e}));function RNe(t){var e=gr();return S.useEffect(()=>{e(JTe(t))},[e,t]),null}var DNe=["layout"];function sP(){return sP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},sP.apply(null,arguments)}function ONe(t,e){if(t==null)return{};var n,r,i=LNe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function LNe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var INe={top:5,right:5,bottom:5,left:5},fZ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:INe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},FNe=S.forwardRef(function(e,n){var r,i=Lr(e.categoricalChartProps,fZ),{layout:a}=i,s=ONe(i,DNe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return S.createElement(cZ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},S.createElement(CY,{chartData:i.data}),S.createElement(uZ,{layout:a,margin:i.margin}),S.createElement(dZ,{baseValue:void 0,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),S.createElement(RNe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),S.createElement(hZ,sP({},s,{ref:n})))});function J6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function eH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?J6(Object(n),!0).forEach(function(r){UNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):J6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function UNe(t,e,n){return(e=zNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zNe(t){var e=BNe(t,"string");return typeof e=="symbol"?e:e+""}function BNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var HNe=["item"],$Ne=eH(eH({},fZ),{},{layout:"centric",startAngle:0,endAngle:360}),VNe=S.forwardRef((t,e)=>{var n=Lr(t,$Ne);return S.createElement(FNe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:HNe,tooltipPayloadSearcher:HM,categoricalChartProps:n,ref:e})}),GNe=["axis"],WNe=S.forwardRef((t,e)=>S.createElement(wO,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:GNe,tooltipPayloadSearcher:HM,categoricalChartProps:t,ref:e}));const tH=[{value:"6h",label:"6h",hours:6},{value:"24h",label:"24h",hours:24},{value:"48h",label:"48h",hours:48},{value:"7d",label:"7d",hours:168}];function qNe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:s="humidity",thresholds:l}){const{t:c}=ng(),{mode:u}=og(),[d,f]=S.useState("24h"),[g,p]=S.useState(s),x=u==="dark";S.useEffect(()=>{if(!t)return;const V=X=>{X.key==="Escape"&&e()};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[t,e]);const v=tH.find(V=>V.value===d)?.hours||24,{data:y,isLoading:b,error:E}=gt({queryKey:["ams-history",n,i,v],queryFn:()=>_e.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const w=y?.data.map(V=>({time:new Date(V.recorded_at).getTime(),humidity:V.humidity,temperature:V.temperature,timeLabel:new Date(V.recorded_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}})}))||[],A=l?.humidityGood||40,T=l?.humidityFair||60,C=l?.tempGood||30,N=l?.tempFair||35,O=w[w.length-1],k=O?.humidity,j=O?.temperature,B=V=>{const X=V.filter(pe=>pe!=null);if(X.length<4)return"stable";const te=X.slice(0,Math.floor(X.length/4)),ie=X.slice(-Math.floor(X.length/4)),le=te.reduce((pe,de)=>pe+de,0)/te.length,Ee=ie.reduce((pe,de)=>pe+de,0)/ie.length-le;return Math.abs(Ee)<2?"stable":Ee>0?"up":"down"},L=B(w.map(V=>V.humidity)),K=B(w.map(V=>V.temperature)),R=({trend:V})=>V==="up"?o.jsx(q9,{className:"w-4 h-4 text-red-400"}):V==="down"?o.jsx(W9,{className:"w-4 h-4 text-green-400"}):o.jsx(e3,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),q=V=>V==null?"#9ca3af":V<=A?"#22a352":V<=T?"#d4a017":"#c62828",W=V=>V==null?"#9ca3af":V<=C?"#22a352":V<=N?"#d4a017":"#c62828",$=x?"#2d2d2d":"#ffffff",J=x?"#1d1d1d":"#f3f4f6",ee=x?"#3d3d3d":"#e5e7eb",Q=x?"#ffffff":"#111827",z=x?"#9ca3af":"#4b5563";return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:o.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:$},onClick:V=>V.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:ee},children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-semibold",style:{color:Q},children:[a," ",c("common.history","History")]}),o.jsx("p",{className:"text-sm",style:{color:z},children:r})]}),o.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:z},children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:J},children:[o.jsxs("button",{onClick:()=>p("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${g==="humidity"?"bg-blue-600 text-white":""}`,style:g!=="humidity"?{color:z}:void 0,children:[o.jsx(uR,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),o.jsxs("button",{onClick:()=>p("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${g==="temperature"?"bg-orange-600 text-white":""}`,style:g!=="temperature"?{color:z}:void 0,children:[o.jsx(iM,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),o.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:J},children:tH.map(V=>o.jsx("button",{onClick:()=>f(V.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===V.value?"bg-bambu-green text-white":""}`,style:d!==V.value?{color:z}:void 0,children:V.label},V.value))})]}),o.jsx("div",{className:"grid grid-cols-4 gap-4",children:g==="humidity"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:z},children:c("common.current","Current")}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("p",{className:"text-2xl font-bold",style:{color:q(k)},children:k!=null?`${k}%`:"—"}),o.jsx(R,{trend:L})]})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:z},children:c("common.average","Average")}),o.jsx("p",{className:"text-2xl font-bold",style:{color:Q},children:y?.avg_humidity!=null?`${y.avg_humidity}%`:"—"})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:z},children:c("common.min","Min")}),o.jsx("p",{className:"text-2xl font-bold text-green-500",children:y?.min_humidity!=null?`${y.min_humidity}%`:"—"})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:z},children:c("common.max","Max")}),o.jsx("p",{className:"text-2xl font-bold text-red-500",children:y?.max_humidity!=null?`${y.max_humidity}%`:"—"})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:z},children:c("common.current","Current")}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("p",{className:"text-2xl font-bold",style:{color:W(j)},children:j!=null?`${j}°C`:"—"}),o.jsx(R,{trend:K})]})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:z},children:c("common.average","Average")}),o.jsx("p",{className:"text-2xl font-bold",style:{color:Q},children:y?.avg_temperature!=null?`${y.avg_temperature}°C`:"—"})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:z},children:c("common.min","Min")}),o.jsx("p",{className:"text-2xl font-bold text-blue-500",children:y?.min_temperature!=null?`${y.min_temperature}°C`:"—"})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:z},children:c("common.max","Max")}),o.jsx("p",{className:"text-2xl font-bold text-red-500",children:y?.max_temperature!=null?`${y.max_temperature}°C`:"—"})]})]})}),o.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:b?o.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:z},children:c("common.loading","Loading...")}):E?o.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):w.length===0?o.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:z},children:c("common.noData","No data available for this time range")}):o.jsx(g1,{width:"100%",height:300,children:o.jsxs(kNe,{data:w,children:[o.jsx(Iw,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),o.jsx(Uw,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:V=>{const X=new Date(V);return v>24?X.toLocaleDateString([],{day:"numeric",month:"short"}):X.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),o.jsx(zw,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:g==="humidity"?[0,100]:["auto","auto"],tickFormatter:V=>g==="humidity"?`${V}%`:`${V}°C`}),o.jsx(b1,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:V=>new Date(V).toLocaleString(),formatter:V=>[g==="humidity"?`${V}%`:`${V}°C`,g==="humidity"?"Humidity":"Temperature"]}),o.jsx(qR,{}),g==="humidity"?o.jsxs(o.Fragment,{children:[o.jsx(Kx,{y:A,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),o.jsx(Kx,{y:T,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):o.jsxs(o.Fragment,{children:[o.jsx(Kx,{y:C,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),o.jsx(Kx,{y:N,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),o.jsx($Y,{type:"monotone",dataKey:g,name:g==="humidity"?"Humidity":"Temperature",stroke:g==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),o.jsx("div",{className:"text-xs text-center",style:{color:z},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function NN({data:t,children:e,disabled:n,className:r="",spoolman:i}){const[a,s]=S.useState(!1),[l,c]=S.useState("top"),[u,d]=S.useState(!1),f=S.useRef(null),g=S.useRef(null),p=S.useRef(null),x=()=>{const T=t.trayUuid;T&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(T).then(()=>{d(!0),setTimeout(()=>d(!1),2e3)}).catch(()=>{v(T)}):v(T))},v=T=>{const C=document.createElement("textarea");C.value=T,C.style.position="fixed",C.style.opacity="0",document.body.appendChild(C),C.select();try{document.execCommand("copy"),d(!0),setTimeout(()=>d(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(C)};S.useEffect(()=>{if(a&&f.current&&g.current){const T=f.current.getBoundingClientRect(),C=g.current.offsetHeight,N=T.top,O=window.innerHeight-T.bottom;N<C+12&&O>N?c("bottom"):c("top")}},[a]);const y=()=>{n||(p.current&&clearTimeout(p.current),p.current=setTimeout(()=>s(!0),80))},b=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>s(!1),100)};S.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);const E=T=>T<=15?"#ef4444":T<=30?"#f97316":T<=50?"#eab308":"#22c55e",w=T=>{if(!T)return!1;const C=T.replace("#",""),N=parseInt(C.slice(0,2),16),O=parseInt(C.slice(2,4),16),k=parseInt(C.slice(4,6),16);return(.299*N+.587*O+.114*k)/255>.6},A=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return o.jsxs("div",{ref:f,className:`relative ${r}`,onMouseEnter:y,onMouseLeave:b,children:[e,a&&o.jsxs("div",{ref:g,className:`
- absolute left-1/2 -translate-x-1/2 z-50
- ${l==="top"?"bottom-full mb-2":"top-full mt-2"}
- animate-in fade-in-0 zoom-in-95 duration-150
- `,style:{maxWidth:"calc(100vw - 24px)"},children:[o.jsxs("div",{className:`
- w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-lg shadow-xl overflow-hidden
- backdrop-blur-sm
- `,children:[o.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:A||"#3d3d3d"},children:[o.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),o.jsx("div",{className:`
- absolute inset-0 flex items-center justify-center
- font-semibold text-sm tracking-wide
- ${w(A)?"text-black/80":"text-white/90"}
- `,children:t.colorName}),o.jsx("div",{className:`
- absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
- ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
- `,children:t.vendor==="Bambu Lab"?"BBL":"GEN"})]}),o.jsxs("div",{className:"p-3 space-y-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Profile"}),o.jsx("span",{className:"text-xs text-white font-semibold truncate max-w-[120px]",children:t.profile})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"K Factor"}),o.jsx("span",{className:"text-xs text-bambu-green font-mono font-bold",children:t.kFactor})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium flex items-center gap-1",children:[o.jsx(uR,{className:"w-3 h-3"}),"Fill"]}),o.jsx("span",{className:"text-xs text-white font-semibold",children:t.fillLevel!==null?`${t.fillLevel}%`:"—"})]}),o.jsx("div",{className:"h-1.5 bg-black/40 rounded-full overflow-hidden",children:t.fillLevel!==null?o.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${t.fillLevel}%`,backgroundColor:E(t.fillLevel)}}):o.jsx("div",{className:"h-full w-full bg-bambu-gray/30 rounded-full"})})]}),i?.enabled&&t.trayUuid&&o.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Spool ID"}),o.jsxs("button",{onClick:T=>{T.stopPropagation(),x()},className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",title:"Copy spool UUID",children:[o.jsxs("span",{className:"font-mono text-[10px] truncate max-w-[80px]",children:[t.trayUuid.slice(0,8),"..."]}),u?o.jsx(po,{className:"w-3 h-3 text-bambu-green"}):o.jsx(vl,{className:"w-3 h-3"})]})]}),i.onLinkSpool&&o.jsxs("button",{onClick:T=>{T.stopPropagation(),i.onLinkSpool?.(t.trayUuid)},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 bg-bambu-green/20 hover:bg-bambu-green/30 text-bambu-green text-xs font-medium rounded transition-colors",children:[o.jsx(Tp,{className:"w-3.5 h-3.5"}),"Link to Spoolman"]})]})]})]}),o.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 w-0 h-0
- border-l-[6px] border-l-transparent
- border-r-[6px] border-r-transparent
- ${l==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
- `})]})]})}function nH({children:t,className:e=""}){const[n,r]=S.useState(!1),i=S.useRef(null),a=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>r(!0),80)},s=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>r(!1),100)};return S.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),o.jsxs("div",{className:`relative ${e}`,onMouseEnter:a,onMouseLeave:s,children:[t,n&&o.jsxs("div",{className:`
- absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
- animate-in fade-in-0 zoom-in-95 duration-150
- `,children:[o.jsx("div",{className:`
- px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-md shadow-lg text-xs text-bambu-gray whitespace-nowrap
- `,children:"Empty slot"}),o.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
- border-l-[5px] border-l-transparent
- border-r-[5px] border-r-transparent
- border-t-[5px] border-t-bambu-dark-tertiary
- `})]})]})}function KNe({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const i=pn(),[a,s]=S.useState(null),{data:l,isLoading:c}=gt({queryKey:["unlinked-spools"],queryFn:_e.getUnlinkedSpools,enabled:t}),u=vt({mutationFn:f=>_e.linkSpool(f,n),onSuccess:()=>{i.invalidateQueries({queryKey:["unlinked-spools"]}),i.invalidateQueries({queryKey:["spoolman-status"]}),e()}});if(!t)return null;const d=()=>{a&&u.mutate(a)};return o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[o.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),o.jsxs("div",{className:"relative w-full max-w-md mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Tp,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Link to Spoolman"})]}),o.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"p-4 space-y-4",children:[r&&o.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[o.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Linking AMS tray:"}),o.jsxs("div",{className:"flex items-center gap-2",children:[r.color&&o.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.color}`}}),o.jsx("span",{className:"text-white font-medium",children:r.type}),o.jsxs("span",{className:"text-bambu-gray",children:["(",r.location,")"]})]})]}),o.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[o.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Spool UUID:"}),o.jsx("code",{className:"text-xs text-bambu-green font-mono break-all",children:n})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Select a Spoolman spool to link:"}),c?o.jsx("div",{className:"flex justify-center py-8",children:o.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):l&&l.length>0?o.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2",children:l.map(f=>o.jsx("button",{onClick:()=>s(f.id),className:`w-full p-3 rounded-lg border text-left transition-colors ${a===f.id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:o.jsxs("div",{className:"flex items-center gap-2",children:[f.filament_color_hex&&o.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${f.filament_color_hex}`}}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-white font-medium truncate",children:f.filament_name||"Unknown filament"}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[f.filament_material||"Unknown",f.remaining_weight!==null&&` - ${Math.round(f.remaining_weight)}g`,f.location&&` - ${f.location}`]})]}),a===f.id&&o.jsx(po,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},f.id))}):o.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[o.jsx("p",{children:"No unlinked spools found in Spoolman."}),o.jsx("p",{className:"text-xs mt-1",children:"All spools are already linked to AMS trays."})]})]})]}),o.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[o.jsx(ke,{variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(ke,{onClick:d,disabled:!a||u.isPending,children:u.isPending?o.jsxs(o.Fragment,{children:[o.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Linking..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Tp,{className:"w-4 h-4"}),"Link Spool"]})})]}),u.isError&&o.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:u.error.message})]})]})}const rH=({className:t})=>o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[o.jsx("rect",{x:"2",y:"15",width:"5",height:"5",rx:"0.5"}),o.jsx("rect",{x:"9.5",y:"15",width:"5",height:"5",rx:"0.5",fill:"currentColor",opacity:"0.3"}),o.jsx("rect",{x:"17",y:"15",width:"5",height:"5",rx:"0.5"}),o.jsx("path",{d:"M4 12 C4 6, 14 6, 14 12"}),o.jsx("polyline",{points:"12,10 14,12 12,14"})]}),iH={"A00-W1":"Jade White","A00-P0":"Beige","A00-D2":"Light Gray","A00-Y0":"Yellow","A00-Y2":"Sunflower Yellow","A00-A1":"Pumpkin Orange","A00-A0":"Orange","A00-Y4":"Gold","A00-G3":"Bright Green","A00-G1":"Bambu Green","A00-G2":"Mistletoe Green","A00-R3":"Hot Pink","A00-P6":"Magenta","A00-R0":"Red","A00-R2":"Maroon Red","A00-P5":"Purple","A00-P2":"Indigo Purple","A00-B5":"Turquoise","A00-B8":"Cyan","A00-B3":"Cobalt Blue","A00-N0":"Brown","A00-N1":"Cocoa Brown","A00-Y3":"Bronze","A00-D0":"Gray","A00-D1":"Silver","A00-B1":"Blue Grey","A00-D3":"Dark Gray","A00-K0":"Black","A00-M3":"Pink Citrus","A00-M6":"Dusk Glare","A00-M0":"Arctic Whisper","A00-M1":"Solar Breeze","A00-M5":"Blueberry Bubblegum","A00-M4":"Mint Lime","A00-M2":"Ocean to Meadow","A00-M7":"Cotton Candy Cloud","A18-K0":"Black","A18-D0":"Gray","A18-W0":"White","A18-R0":"Red","A18-Y0":"Yellow","A18-B0":"Cyan","A18-B1":"Blue","A18-P0":"Matte Beige","A01-W2":"Ivory White","A01-W3":"Bone White","A01-Y2":"Lemon Yellow","A01-A2":"Mandarin Orange","A01-P3":"Sakura Pink","A01-P4":"Lilac Purple","A01-R3":"Plum","A01-R1":"Scarlet Red","A01-R4":"Dark Red","A01-G0":"Apple Green","A01-G1":"Grass Green","A01-G7":"Dark Green","A01-B4":"Ice Blue","A01-B0":"Sky Blue","A01-B3":"Marine Blue","A01-B6":"Dark Blue","A01-Y3":"Desert Tan","A01-N1":"Latte Brown","A01-N3":"Caramel","A01-R2":"Terracotta","A01-N2":"Dark Brown","A01-N0":"Dark Chocolate","A01-D3":"Ash Gray","A01-D0":"Nardo Gray","A01-K1":"Charcoal","A12-G0":"Green","A12-R0":"Pink","A12-A0":"Orange","A12-Y0":"Yellow","A12-B0":"Blue","A07-R5":"Red Granite","A07-D4":"White Marble","A11-W0":"White","A11-K0":"Black","A08-G3":"Alpine Green Sparkle","A08-D5":"Slate Gray Sparkle","A08-B7":"Royal Purple Sparkle","A08-R2":"Crimson Red Sparkle","A08-K2":"Onyx Black Sparkle","A08-Y1":"Classic Gold Sparkle","A02-B2":"Cobalt Blue Metallic","A02-G2":"Oxide Green Metallic","A02-Y1":"Iridium Gold Metallic","A02-D2":"Iron Gray Metallic","A17-B1":"Blue","A17-A0":"Orange","A17-P0":"Purple","A06-Y1":"Gold","A06-D0":"Titan Gray","A06-D1":"Silver","A06-W0":"White","A06-R0":"Candy Red","A06-G0":"Candy Green","A06-G1":"Mint","A06-B1":"Blue","A06-B0":"Baby Blue","A06-P0":"Purple","A06-R1":"Rose Gold","A06-R2":"Pink","A06-Y0":"Champagne","A05-M8":"Dawn Radiance","A05-M4":"Aurora Purple","A05-M1":"South Beach","A05-T3":"Neon City","A05-T2":"Midnight Blaze","A05-T1":"Gilded Rose","A05-T4":"Blue Hawaii","A05-T5":"Velvet Eclipse","A15-B0":"Purple","A15-G0":"Green","A15-G1":"Nebulae","A15-R0":"Brown","A16-K0":"Black Walnut","A16-R0":"Rosewood","A16-N0":"Clay Brown","A16-G0":"Classic Birch","A16-W0":"White Oak","A16-Y0":"Ochre Yellow","A50-D6":"Lava Gray","A50-K0":"Black","A50-B6":"Royal Blue","A10-W0":"White","A10-D0":"Gray","A09-B5":"Lavender Blue","A09-B4":"Light Blue","A09-A0":"Orange","A09-D1":"Silver","A09-R3":"Vermilion Red","A09-Y0":"Yellow","G02-K0":"Black","G02-W0":"White","G02-R0":"Red","G02-D0":"Gray","G02-D1":"Dark Gray","G02-Y1":"Cream","G02-Y0":"Yellow","G02-A0":"Orange","G02-N1":"Peanut Brown","G02-G1":"Lime Green","G02-G0":"Green","G02-G2":"Forest Green","G02-B1":"Lake Blue","G02-B0":"Blue","G01-G1":"Translucent Teal","G01-B0":"Translucent Light Blue","G01-C0":"Clear","G01-D0":"Translucent Gray","G01-G0":"Translucent Olive","G01-N0":"Translucent Brown","G01-A0":"Translucent Orange","G01-P1":"Translucent Pink","G01-P0":"Translucent Purple","G50-P7":"Violet Purple","G50-K0":"Black","B00-D1":"Silver","B00-K0":"Black","B00-W0":"White","B00-G6":"Bambu Green","B00-G7":"Olive","B00-Y1":"Tangerine Yellow","B00-A0":"Orange","B00-R0":"Red","B00-B4":"Azure","B00-B0":"Blue","B00-B6":"Navy Blue","B50-A0":"Orange","B50-K0":"Black","B01-W0":"White","B01-K0":"Black","B01-D0":"Gray","B02-W0":"White","C00-C1":"Transparent","C00-C0":"Clear Black","C00-K0":"Black","C00-W0":"White","C01-K0":"Black","U02-B0":"Blue","U02-D0":"Gray","U02-K0":"Black","N04-K0":"Black","N08-K0":"Black","S02-W0":"Nature","S02-W1":"White","S05-C0":"Black","S06-W0":"White","S03-G1":"Green","S04-Y0":"Clear"},XNe={W0:"White",W1:"Jade White",W2:"Ivory White",W3:"Bone White",Y0:"Yellow",Y1:"Gold",Y2:"Sunflower Yellow",Y3:"Bronze",Y4:"Gold",A0:"Orange",A1:"Pumpkin Orange",A2:"Mandarin Orange",R0:"Red",R1:"Scarlet Red",R2:"Maroon Red",R3:"Hot Pink",R4:"Dark Red",R5:"Red Granite",P0:"Beige",P1:"Pink",P2:"Indigo Purple",P3:"Sakura Pink",P4:"Lilac Purple",P5:"Purple",P6:"Magenta",P7:"Violet Purple",B0:"Blue",B1:"Blue Grey",B2:"Cobalt Blue",B3:"Cobalt Blue",B4:"Ice Blue",B5:"Turquoise",B6:"Navy Blue",B7:"Royal Purple",B8:"Cyan",G0:"Green",G1:"Grass Green",G2:"Mistletoe Green",G3:"Bright Green",G6:"Bambu Green",G7:"Dark Green",N0:"Brown",N1:"Peanut Brown",N2:"Dark Brown",N3:"Caramel",D0:"Gray",D1:"Silver",D2:"Light Gray",D3:"Dark Gray",D4:"White Marble",D5:"Slate Gray",D6:"Lava Gray",K0:"Black",K1:"Charcoal",K2:"Onyx Black",C0:"Clear Black",C1:"Transparent",M0:"Arctic Whisper",M1:"Solar Breeze",M2:"Ocean to Meadow",M3:"Pink Citrus",M4:"Aurora Purple",M5:"Blueberry Bubblegum",M6:"Dusk Glare",M7:"Cotton Candy Cloud",M8:"Dawn Radiance",T1:"Gilded Rose",T2:"Midnight Blaze",T3:"Neon City",T4:"Blue Hawaii",T5:"Velvet Eclipse"};function CN(t){if(!t)return null;if(iH[t])return iH[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return XNe[n]||null}function kN(t){if(!t||t.length<6)return"Unknown";const e=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16),i=Math.max(e,n,r)/255,a=Math.min(e,n,r)/255,s=(i+a)/2;let l=0,c=0;if(i!==a){const u=i-a;c=s>.5?u/(2-i-a):u/(i+a);const d=e/255,f=n/255,g=r/255;i===d?l=((f-g)/u+(f<g?6:0))/6:i===f?l=((g-d)/u+2)/6:l=((d-f)/u+4)/6}return l=l*360,s<.15?"Black":s>.85?"White":c<.15?s<.4?"Dark Gray":s>.6?"Light Gray":"Gray":l<15||l>=345?"Red":l<45?"Orange":l<70?"Yellow":l<150?"Green":l<200?"Cyan":l<260?"Blue":l<290?"Purple":l<345?"Pink":"Unknown"}function PN(t){return(t??.02).toFixed(3)}function aH({side:t}){const{mode:e}=og(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return o.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded",style:{backgroundColor:n,color:"#00ae42"},children:t})}function sH({className:t}){return o.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.jsx("path",{d:"M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z",fill:"#C3C2C1"})})}function YNe({className:t}){return o.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z",fill:"#C3C2C1"}),o.jsx("path",{d:"M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z",fill:"#1F8FEB"})]})}function ZNe({className:t}){return o.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z",fill:"#1F8FEB"}),o.jsx("path",{d:"M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z",fill:"#C3C2C1"})]})}function QNe({className:t}){return o.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"}),o.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function JNe({className:t}){return o.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),o.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),o.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function eCe({className:t}){return o.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),o.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),o.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function jN({className:t,color:e,isHeating:n}){const i={"text-orange-400":"#fb923c","text-blue-400":"#60a5fa","text-green-400":"#4ade80"}[e]||"#888",a=n?{filter:`drop-shadow(0 0 4px ${i}) drop-shadow(0 0 8px ${i})`}:{};return n?o.jsxs("svg",{className:t,style:a,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),o.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),o.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"})]}):o.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"}),o.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function oH({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const a=typeof t=="string"?parseInt(t,10):t,s=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(a)?(c="#C3C2C1",u="Unknown"):a<=s?(c="#22a352",u="Good"):a<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(a)||a<=s?d=sH:a<=l?d=YNe:d=ZNe,o.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${a}% - ${u}${r?" (click for history)":""}`,children:[o.jsx(d,{className:i?"w-2.5 h-3":"w-3 h-4"}),o.jsxs("span",{className:`font-medium tabular-nums ${i?"text-[10px]":"text-xs"}`,style:{color:c},children:[a,"%"]})]})}function lH({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const a=typeof e=="number"?e:28,s=typeof n=="number"?n:35;let l,c,u;return t<=a?(l="#22a352",c="Good",u=QNe):t<=s?(l="#d4a017",c="Fair",u=JNe):(l="#c62828",c="Bad",u=eCe),o.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Temperature: ${t}°C - ${c}${r?" (click for history)":""}`,children:[o.jsx(u,{className:i?"w-2.5 h-3":"w-3 h-4"}),o.jsxs("span",{className:`tabular-nums text-right ${i?"text-[10px] w-8":"w-12"}`,style:{color:l},children:[t,"°C"]})]})}function Eu(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,a=r>=128?r-128:r,s=String.fromCharCode(65+a);return i?`HT-${s}`:`AMS-${s}`}function cH(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function tCe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function nCe(t){const e=new Date,n=new Date(e.getTime()+t*60*1e3),r=new Date;r.setHours(0,0,0,0);const i=new Date(n);i.setHours(0,0,0,0);const a=n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),s=Math.floor((i.getTime()-r.getTime())/(1e3*60*60*24));return s===0?a:s===1?`Tomorrow ${a}`:n.toLocaleDateString([],{weekday:"short"})+" "+a}function rCe(t){if(!t)return"/img/printers/default.png";const e=t.toLowerCase().replace(/\s+/g,"");return e.includes("x1e")?"/img/printers/x1e.png":e.includes("x1c")||e.includes("x1carbon")||e.includes("x1")?"/img/printers/x1c.png":e.includes("h2d")||e.includes("h2c")||e.includes("h2s")?"/img/printers/h2d.png":e.includes("p2s")||e.includes("p1s")?"/img/printers/p1s.png":e.includes("p1p")?"/img/printers/p1p.png":e.includes("a1mini")?"/img/printers/a1mini.png":e.includes("a1")?"/img/printers/a1.png":"/img/printers/default.png"}function iCe(t){return t==null?{label:"",color:"text-bambu-gray",bars:0}:t>=-50?{label:"Excellent",color:"text-bambu-green",bars:4}:t>=-60?{label:"Good",color:"text-bambu-green",bars:3}:t>=-70?{label:"Fair",color:"text-yellow-400",bars:2}:t>=-80?{label:"Weak",color:"text-orange-400",bars:1}:{label:"Very weak",color:"text-red-400",bars:1}}function aCe({url:t,printName:e}){const[n,r]=S.useState(!1),[i,a]=S.useState(!1),[s,l]=S.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${t&&n?"cursor-pointer":""}`,onClick:()=>t&&n&&l(!0),children:t&&!i?o.jsxs(o.Fragment,{children:[o.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>a(!0)}),!n&&o.jsx(Qh,{className:"w-8 h-8 text-bambu-gray"})]}):o.jsx(Qh,{className:"w-8 h-8 text-bambu-gray"})}),s&&t&&o.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>l(!1),children:o.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[o.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&o.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function sCe({printers:t}){const e=pn(),n=S.useMemo(()=>{let i=0,a=0,s=0,l=0;return t?.forEach(c=>{const u=e.getQueryData(["printerStatus",c.id]);u===void 0?l++:u.connected?u.state==="RUNNING"?i++:a++:s++}),{printing:i,idle:a,offline:s,loading:l,total:t?.length||0}},[t,e]),[,r]=S.useState(0);return S.useEffect(()=>{let i=!1;const a=e.getQueryCache().subscribe(()=>{i||(i=!0,requestAnimationFrame(()=>{r(s=>s+1),i=!1}))});return()=>a()},[e]),t?.length?o.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),o.jsxs("span",{className:"text-bambu-gray",children:[o.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),o.jsxs("span",{className:"text-bambu-gray",children:[o.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),o.jsxs("span",{className:"text-bambu-gray",children:[o.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function uH(t,e){if(e)return e;switch(t){case"RUNNING":return"Printing";case"PAUSE":return"Paused";case"FINISH":return"Finished";case"FAILED":return"Failed";case"IDLE":return"Idle";default:return t?t.charAt(0)+t.slice(1).toLowerCase():"Idle"}}function dH({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",amsThresholds:i,spoolmanEnabled:a=!1}){const s=pn(),l=Eb(),{showToast:c}=Ar(),[u,d]=S.useState(!1),[f,g]=S.useState(!1),[p,x]=S.useState(!0),[v,y]=S.useState(!1),[b,E]=S.useState(!1),[w,A]=S.useState(!1),[T,C]=S.useState(!1),[N,O]=S.useState(!1),[k,j]=S.useState(!1),[B,L]=S.useState(!1),[K,R]=S.useState(!1),[q,W]=S.useState(!1),[$,J]=S.useState(!1),[ee,Q]=S.useState(null),[z,V]=S.useState(null),{data:X}=gt({queryKey:["printerStatus",t.id],queryFn:()=>_e.getPrinterStatus(t.id),refetchInterval:3e4}),te=S.useMemo(()=>{const Ae=new Set;if(X?.ams)for(const lt of X.ams)for(const _t of lt.tray||[])_t.tray_info_idx&&Ae.add(_t.tray_info_idx);return X?.vt_tray?.tray_info_idx&&Ae.add(X.vt_tray.tray_info_idx),Array.from(Ae)},[X?.ams,X?.vt_tray]),{data:ie}=gt({queryKey:["filamentInfo",te],queryFn:()=>_e.getFilamentInfo(te),enabled:te.length>0,staleTime:300*1e3}),[le,ge]=S.useState(null);S.useEffect(()=>{X?.wifi_signal!=null&&ge(X.wifi_signal)},[X?.wifi_signal]);const Ee=X?.wifi_signal??le,pe=S.useRef(void 0);S.useEffect(()=>{X?.connected!==void 0&&(pe.current=X.connected)},[X?.connected]);const de=X?.connected??pe.current,Re=S.useRef({});S.useEffect(()=>{X?.ams_extruder_map&&Object.keys(X.ams_extruder_map).length>0&&(Re.current=X.ams_extruder_map)},[X?.ams_extruder_map]);const fe=X?.ams_extruder_map&&Object.keys(X.ams_extruder_map).length>0?X.ams_extruder_map:Re.current,Fe=S.useRef([]);S.useEffect(()=>{X?.ams&&X.ams.length>0&&(Fe.current=X.ams)},[X?.ams]);const U=X?.ams&&X.ams.length>0?X.ams:Fe.current,H=S.useRef(255),re=X?.tray_now;re!==void 0&&re!==255&&(H.current=re);const G=re===void 0||re===255?H.current:re,{data:Z}=gt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>_e.getSmartPlugByPrinter(t.id)}),{data:oe}=gt({queryKey:["smartPlugStatus",Z?.id],queryFn:()=>Z?_e.getSmartPlugStatus(Z.id):null,enabled:!!Z,refetchInterval:1e4}),{data:be}=gt({queryKey:["queue",t.id,"pending"],queryFn:()=>_e.getQueue(t.id,"pending")}),Te=be?.length||0,{data:Me}=gt({queryKey:["archives",t.id,"last"],queryFn:()=>_e.getArchives(t.id,1,0),enabled:X?.connected&&X?.state!=="RUNNING"}),F=Me?.[0],I=e&&de===!1,ne=vt({mutationFn:Ae=>_e.deletePrinter(t.id,Ae.deleteArchives),onSuccess:()=>{s.invalidateQueries({queryKey:["printers"]}),s.invalidateQueries({queryKey:["archives"]})}}),ve=vt({mutationFn:()=>_e.connectPrinter(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["printerStatus",t.id]})}}),Se=vt({mutationFn:Ae=>Z?_e.controlSmartPlug(Z.id,Ae):Promise.reject("No plug"),onSuccess:()=>{s.invalidateQueries({queryKey:["smartPlugStatus",Z?.id]})}}),ye=vt({mutationFn:Ae=>Z?_e.updateSmartPlug(Z.id,{auto_off:Ae}):Promise.reject("No plug"),onSuccess:()=>{s.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),s.invalidateQueries({queryKey:["smart-plugs"]})}}),Ke=vt({mutationFn:()=>_e.stopPrint(t.id),onSuccess:()=>{c("Print stopped"),s.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Ae=>c(Ae.message||"Failed to stop print","error")}),We=vt({mutationFn:()=>_e.pausePrint(t.id),onSuccess:()=>{c("Print paused"),s.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Ae=>c(Ae.message||"Failed to pause print","error")}),qe=vt({mutationFn:()=>_e.resumePrint(t.id),onSuccess:()=>{c("Print resumed"),s.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Ae=>c(Ae.message||"Failed to resume print","error")}),ut=(X?.state==="RUNNING"||X?.state==="PAUSE"||X?.state==="PAUSED")&&(X?.printable_objects_count??0)>=2,{data:ue,refetch:se}=gt({queryKey:["printableObjects",t.id],queryFn:()=>_e.getPrintableObjects(t.id),enabled:$||ut,refetchInterval:$?5e3:ut?3e4:!1}),Ve=vt({mutationFn:Ae=>_e.skipObjects(t.id,Ae),onSuccess:Ae=>{c(Ae.message||"Objects skipped"),se()},onError:Ae=>c(Ae.message||"Failed to skip objects","error")}),[Be,Ze]=S.useState(null),ht=S.useRef(!1),me=S.useRef(null),nt=S.useRef(!1),xe=vt({mutationFn:({amsId:Ae,slotId:lt})=>_e.refreshAmsSlot(t.id,Ae,lt),onMutate:({amsId:Ae,slotId:lt})=>{me.current&&clearTimeout(me.current),ht.current=!1,nt.current=!1,Ze({amsId:Ae,slotId:lt}),setTimeout(()=>{nt.current=!0},2e3),me.current=setTimeout(()=>{Ze(null)},3e4)},onSuccess:Ae=>{c(Ae.message||"RFID re-read initiated")},onError:Ae=>{c(Ae.message||"Failed to re-read RFID","error"),me.current&&clearTimeout(me.current),Ze(null)}}),He=S.useRef(null);S.useEffect(()=>{if(!Be)return;const Ae=X?.ams_status_main??0;return Ae!==0&&(ht.current=!0,He.current&&(clearTimeout(He.current),He.current=null)),ht.current&&Ae===0&&(nt.current?(me.current&&clearTimeout(me.current),Ze(null)):He.current||(He.current=setTimeout(()=>{me.current&&clearTimeout(me.current),Ze(null)},2e3))),()=>{He.current&&clearTimeout(He.current)}},[X?.ams_status_main,Be]);const[Pe,we]=S.useState(null);return I?null:o.jsxs(Mt,{className:"relative",children:[o.jsxs(At,{children:[o.jsxs("div",{className:r==="compact"?"mb-2":"mb-4",children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[o.jsx("img",{src:rCe(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${r==="compact"?"w-10 h-10":"w-14 h-14"}`}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:`font-semibold text-white ${r==="compact"?"text-base truncate":"text-lg"}`,children:t.name}),r==="compact"&&o.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${X?.connected?"bg-bambu-green":"bg-red-500"}`,title:X?.connected?"Connected":"Offline"})]}),o.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&X?.nozzles&&X.nozzles[0]?.nozzle_diameter&&o.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:X.nozzles[0].nozzle_type||"Nozzle",children:["• ",X.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&o.jsxs("span",{className:"ml-2 text-bambu-gray",children:[o.jsx(ur,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),o.jsxs("div",{className:"relative flex-shrink-0",children:[o.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>d(!u),children:o.jsx(o0,{className:"w-4 h-4"})}),u&&o.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10",children:[o.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{y(!0),d(!1)},children:[o.jsx(Bc,{className:"w-4 h-4"}),"Edit"]}),o.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{ve.mutate(),d(!1)},children:[o.jsx(li,{className:"w-4 h-4"}),"Reconnect"]}),o.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{A(!0),d(!1)},children:[o.jsx(G9,{className:"w-4 h-4"}),"MQTT Debug"]}),o.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{g(!0),d(!1)},children:[o.jsx(Nn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&o.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[o.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${X?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[X?.connected?o.jsx(Cb,{className:"w-3 h-3"}):o.jsx(K9,{className:"w-3 h-3"}),X?.connected?"Connected":"Offline"]}),X?.connected&&Ee!=null&&o.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${Ee>=-50||Ee>=-60?"bg-bambu-green/20 text-bambu-green":Ee>=-70?"bg-amber-500/20 text-amber-600":Ee>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${Ee} dBm - ${iCe(Ee).label}`,children:[o.jsx(Uue,{className:"w-3 h-3"}),Ee,"dBm"]}),X?.connected&&(()=>{const Ae=X.hms_errors?Zde(X.hms_errors):[];return o.jsxs("button",{onClick:()=>j(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${Ae.length>0?Ae.some(lt=>lt.severity<=2)?"bg-red-500/20 text-red-400":"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:"Click to view HMS errors",children:[o.jsx(Gn,{className:"w-3 h-3"}),Ae.length>0?Ae.length:"OK"]})})(),n&&o.jsxs("button",{onClick:()=>l("/maintenance"),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?"bg-red-500/20 text-red-400":n.warning_count>0?"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:""}${n.due_count>0&&n.warning_count>0?", ":""}${n.warning_count>0?`${n.warning_count} due soon`:""} - Click to view`:"All maintenance up to date - Click to view",children:[o.jsx(bd,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Te>0&&o.jsxs("button",{onClick:()=>l("/queue"),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-purple-500/20 text-purple-400 hover:opacity-80 transition-opacity",title:`${Te} print${Te>1?"s":""} in queue`,children:[o.jsx(gd,{className:"w-3 h-3"}),Te]})]})]}),f&&o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:o.jsx(Mt,{className:"w-full max-w-md mx-4",children:o.jsxs(At,{children:[o.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[o.jsx("div",{className:"p-2 rounded-full bg-red-500/20",children:o.jsx(Gn,{className:"w-5 h-5 text-red-400"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Printer"}),o.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:['Are you sure you want to delete "',t.name,'"? This will remove all connection settings.']})]})]}),o.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:o.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:p,onChange:Ae=>x(Ae.target.checked),className:"mt-0.5 w-4 h-4 rounded border-bambu-gray bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-white",children:"Delete print archives"}),o.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:p?"All print history for this printer will be permanently deleted.":"Print history will be kept but no longer associated with this printer."})]})]})}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(ke,{variant:"secondary",onClick:()=>{g(!1),x(!0)},children:"Cancel"}),o.jsx(ke,{variant:"danger",onClick:()=>{ne.mutate({deleteArchives:p}),g(!1),x(!0)},children:"Delete"})]})]})})}),X?.connected&&o.jsxs(o.Fragment,{children:[r==="compact"?o.jsx("div",{className:"mt-2",children:X.state==="RUNNING"?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:o.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${X.progress||0}%`}})}),o.jsxs("span",{className:"text-xs text-white",children:[Math.round(X.progress||0),"%"]})]}):o.jsx("p",{className:"text-xs text-bambu-gray",children:uH(X.state,X.stg_cur_name)})}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg relative",children:[o.jsxs("button",{onClick:()=>J(!0),disabled:!(X.state==="RUNNING"||X.state==="PAUSE"||X.state==="PAUSED")||(X.printable_objects_count??0)<2,className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(X.state==="RUNNING"||X.state==="PAUSE"||X.state==="PAUSED")&&(X.printable_objects_count??0)>=2?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:X.state==="RUNNING"||X.state==="PAUSE"||X.state==="PAUSED"?(X.printable_objects_count??0)>=2?"Skip objects":"Skip objects (requires 2+ objects)":"Skip objects (only while printing)",children:[o.jsx(rH,{className:"w-4 h-4"}),ue&&ue.skipped_count>0&&o.jsx("span",{className:"absolute -top-1 -right-1 min-w-[16px] h-4 px-1 flex items-center justify-center text-[10px] font-bold bg-red-500 text-white rounded-full",children:ue.skipped_count})]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx(aCe,{url:X.state==="RUNNING"?X.cover_url:null,printName:X.state==="RUNNING"&&(X.subtask_name||X.current_print)||void 0}),o.jsx("div",{className:"flex-1 min-w-0",children:X.current_print&&X.state==="RUNNING"?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:X.stg_cur_name||"Printing"}),o.jsx("p",{className:"text-white text-sm mb-2 truncate",children:X.subtask_name||X.current_print}),o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:o.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${X.progress||0}%`}})}),o.jsxs("span",{className:"text-white",children:[Math.round(X.progress||0),"%"]})]}),o.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[X.remaining_time!=null&&X.remaining_time>0&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(ur,{className:"w-3 h-3"}),tCe(X.remaining_time*60)]}),o.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",nCe(X.remaining_time)]})]}),X.layer_num!=null&&X.total_layers!=null&&X.total_layers>0&&o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(gd,{className:"w-3 h-3"}),X.layer_num,"/",X.total_layers]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),o.jsx("p",{className:"text-white text-sm mb-2",children:uH(X.state,X.stg_cur_name)}),o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:o.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),o.jsx("span",{className:"text-bambu-gray",children:"—"})]}),F?o.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:F.print_name||F.filename,children:["Last: ",F.print_name||F.filename,F.completed_at&&o.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",new Date(F.completed_at).toLocaleDateString([],{month:"short",day:"numeric"})]})]}):o.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})]}),X.state!=="RUNNING"&&o.jsx(the,{printerId:t.id})]}),X.temperatures&&r==="expanded"&&(()=>{const Ae=X.temperatures.nozzle_heating||X.temperatures.nozzle_2_heating||!1,lt=X.temperatures.bed_heating||!1,_t=X.temperatures.chamber_heating||!1,Xe=X.state==="RUNNING",Ut=X.state==="PAUSED"||X.state==="PAUSE",Ct=Xe||Ut,$t=Ke.isPending||We.isPending||qe.isPending;return o.jsxs("div",{className:"flex gap-3",children:[o.jsxs("div",{className:"flex-1 grid grid-cols-3 gap-2",children:[o.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[o.jsx(jN,{className:"w-4 h-4 mx-auto mb-1",color:"text-orange-400",isHeating:Ae}),X.temperatures.nozzle_2!==void 0?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-[10px] text-bambu-gray",children:"L / R"}),o.jsxs("p",{className:"text-xs text-white",children:[Math.round(X.temperatures.nozzle||0),"° / ",Math.round(X.temperatures.nozzle_2||0),"°"]})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-[10px] text-bambu-gray",children:"Nozzle"}),o.jsxs("p",{className:"text-xs text-white",children:[Math.round(X.temperatures.nozzle||0),"°C"]})]})]}),o.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[o.jsx(jN,{className:"w-4 h-4 mx-auto mb-1",color:"text-blue-400",isHeating:lt}),o.jsx("p",{className:"text-[10px] text-bambu-gray",children:"Bed"}),o.jsxs("p",{className:"text-xs text-white",children:[Math.round(X.temperatures.bed||0),"°C"]})]}),X.temperatures.chamber!==void 0?o.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[o.jsx(jN,{className:"w-4 h-4 mx-auto mb-1",color:"text-green-400",isHeating:_t}),o.jsx("p",{className:"text-[10px] text-bambu-gray",children:"Chamber"}),o.jsxs("p",{className:"text-xs text-white",children:[Math.round(X.temperatures.chamber||0),"°C"]})]}):o.jsx("div",{})]}),o.jsxs("div",{className:"flex flex-col justify-center gap-1.5 w-20",children:[o.jsxs("button",{onClick:()=>L(!0),disabled:!Ct||$t,className:`
- flex items-center justify-center gap-1 px-2 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${Ct?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
- `,title:"Stop print",children:[o.jsx(af,{className:"w-3 h-3"}),"Stop"]}),o.jsxs("button",{onClick:()=>Ut?W(!0):R(!0),disabled:!Ct||$t,className:`
- flex items-center justify-center gap-1 px-2 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${Ct?Ut?"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30":"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
- `,title:Ut?"Resume print":"Pause print",children:[Ut?o.jsx(xd,{className:"w-3 h-3"}):o.jsx(gR,{className:"w-3 h-3"}),Ut?"Resume":"Pause"]})]})]})})(),U&&U.length>0&&r==="expanded"&&(()=>{const Ae=U.filter(Xe=>Xe.tray.length>1),lt=U.filter(Xe=>Xe.tray.length===1),_t=t.nozzle_count===2||X?.temperatures?.nozzle_2!==void 0;return o.jsxs("div",{className:"mt-4 pt-3 border-t border-bambu-dark-tertiary/50",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Filaments"}),o.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),o.jsxs("div",{className:"space-y-3",children:[Ae.length>0&&o.jsx("div",{className:"grid grid-cols-2 gap-3",children:Ae.map(Xe=>{const Ut=fe[String(Xe.id)],Ct=Xe.id>=128?Xe.id-128:Xe.id,$t=Ut!==void 0?Ut:Ct,gn=$t===1,Fn=$t===0;return o.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-[10px] text-white font-medium",children:Eu(Xe.id,Xe.tray.length)}),_t&&(gn||Fn)&&o.jsx(aH,{side:gn?"L":"R"})]}),(Xe.humidity!=null||Xe.temp!=null)&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[Xe.humidity!=null&&o.jsx(oH,{humidity:Xe.humidity,goodThreshold:i?.humidityGood,fairThreshold:i?.humidityFair,onClick:()=>Q({amsId:Xe.id,amsLabel:Eu(Xe.id,Xe.tray.length),mode:"humidity"}),compact:!0}),Xe.temp!=null&&o.jsx(lH,{temp:Xe.temp,goodThreshold:i?.tempGood,fairThreshold:i?.tempFair,onClick:()=>Q({amsId:Xe.id,amsLabel:Eu(Xe.id,Xe.tray.length),mode:"temperature"}),compact:!0})]})]}),o.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(It=>{const Yt=Xe.tray[It]||Xe.tray.find(ze=>ze.id===It),Jn=Yt?.tray_type&&Yt.remain>=0,er=!Yt?.tray_type,Hn=Xe.id*4+It,Un=G===Hn,jn=Yt?.tray_info_idx?ie?.[Yt.tray_info_idx]:null,sn=Yt?.tray_type?{vendor:Yt.tray_uuid?"Bambu Lab":"Generic",profile:jn?.name||Yt.tray_sub_brands||Yt.tray_type,colorName:CN(Yt.tray_id_name)||kN(Yt.tray_color),colorHex:Yt.tray_color||null,kFactor:PN(Yt.k),fillLevel:Jn?Yt.remain:null,trayUuid:Yt.tray_uuid||null}:null,Le=Be?.amsId===Xe.id&&Be?.slotId===It,he=o.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${er?"opacity-50":""} ${Un?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[o.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:Yt?.tray_color?`#${Yt.tray_color}`:Yt?.tray_type?"#333":"transparent",borderColor:er?"#666":"rgba(255,255,255,0.1)",borderStyle:er?"dashed":"solid"}}),o.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Yt?.tray_type||"—"}),o.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Jn&&Yt?o.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Yt.remain}%`,backgroundColor:cH(Yt.remain)}}):Yt?.tray_type?o.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return o.jsxs("div",{className:"relative group",children:[Le&&o.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:o.jsx(li,{className:"w-4 h-4 text-bambu-green animate-spin"})}),X?.state!=="RUNNING"&&o.jsx("button",{onClick:ze=>{ze.stopPropagation(),we(Pe?.amsId===Xe.id&&Pe?.slotId===It?null:{amsId:Xe.id,slotId:It})},className:"absolute -top-1 -right-1 w-4 h-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:bg-bambu-dark-tertiary",title:"Slot options",children:o.jsx(o0,{className:"w-2.5 h-2.5 text-bambu-gray"})}),X?.state!=="RUNNING"&&Pe?.amsId===Xe.id&&Pe?.slotId===It&&o.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:o.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-xs text-white hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:ze=>{ze.stopPropagation(),xe.mutate({amsId:Xe.id,slotId:It}),we(null)},disabled:Le,children:[o.jsx(li,{className:`w-3 h-3 ${Le?"animate-spin":""}`}),"Re-read RFID"]})}),sn?o.jsx(NN,{data:sn,spoolman:{enabled:a,onLinkSpool:a&&sn.trayUuid?ze=>{V({trayUuid:ze,trayInfo:{type:sn.profile,color:sn.colorHex||"",location:`${Eu(Xe.id,Xe.tray.length)} Slot ${It+1}`}})}:void 0},children:he}):o.jsx(nH,{children:he})]},It)})})]},Xe.id)})}),(lt.length>0||X.vt_tray&&X.vt_tray.tray_type)&&o.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[lt.map(Xe=>{const Ut=fe[String(Xe.id)],Ct=Xe.id>=128?Xe.id-128:Xe.id,$t=Ut!==void 0?Ut:Ct,gn=$t===1,Fn=$t===0,It=Xe.tray[0],Yt=It?.tray_type&&It.remain>=0,Jn=!It?.tray_type,er=Xe.id*4+(It?.id??0),Hn=G===er,Un=It?.tray_info_idx?ie?.[It.tray_info_idx]:null,jn=It?.tray_type?{vendor:It.tray_uuid?"Bambu Lab":"Generic",profile:Un?.name||It.tray_sub_brands||It.tray_type,colorName:CN(It.tray_id_name)||kN(It.tray_color),colorHex:It.tray_color||null,kFactor:PN(It.k),fillLevel:Yt?It.remain:null,trayUuid:It.tray_uuid||null}:null,sn=It?.id??0,Le=Be?.amsId===Xe.id&&Be?.slotId===sn,he=o.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Jn?"opacity-50":""} ${Hn?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[o.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:It?.tray_color?`#${It.tray_color}`:It?.tray_type?"#333":"transparent",borderColor:Jn?"#666":"rgba(255,255,255,0.1)",borderStyle:Jn?"dashed":"solid"}}),o.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:It?.tray_type||"—"}),o.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Yt?o.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${It.remain}%`,backgroundColor:cH(It.remain)}}):It?.tray_type?o.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return o.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[o.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[o.jsx("span",{className:"text-[10px] text-white font-medium",children:Eu(Xe.id,Xe.tray.length)}),_t&&(gn||Fn)&&o.jsx(aH,{side:gn?"L":"R"})]}),o.jsxs("div",{className:"flex gap-1.5",children:[o.jsxs("div",{className:"relative group flex-1",children:[Le&&o.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:o.jsx(li,{className:"w-4 h-4 text-bambu-green animate-spin"})}),X?.state!=="RUNNING"&&o.jsx("button",{onClick:ze=>{ze.stopPropagation(),we(Pe?.amsId===Xe.id&&Pe?.slotId===sn?null:{amsId:Xe.id,slotId:sn})},className:"absolute -top-1 -right-1 w-4 h-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:bg-bambu-dark-tertiary",title:"Slot options",children:o.jsx(o0,{className:"w-2.5 h-2.5 text-bambu-gray"})}),X?.state!=="RUNNING"&&Pe?.amsId===Xe.id&&Pe?.slotId===sn&&o.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:o.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-xs text-white hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:ze=>{ze.stopPropagation(),xe.mutate({amsId:Xe.id,slotId:sn}),we(null)},disabled:Le,children:[o.jsx(li,{className:`w-3 h-3 ${Le?"animate-spin":""}`}),"Re-read RFID"]})}),jn?o.jsx(NN,{data:jn,spoolman:{enabled:a,onLinkSpool:a&&jn.trayUuid?ze=>{V({trayUuid:ze,trayInfo:{type:jn.profile,color:jn.colorHex||"",location:Eu(Xe.id,Xe.tray.length)}})}:void 0},children:he}):o.jsx(nH,{children:he})]}),(Xe.humidity!=null||Xe.temp!=null)&&o.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[Xe.temp!=null&&o.jsx(lH,{temp:Xe.temp,goodThreshold:i?.tempGood,fairThreshold:i?.tempFair,onClick:()=>Q({amsId:Xe.id,amsLabel:Eu(Xe.id,Xe.tray.length),mode:"temperature"}),compact:!0}),Xe.humidity!=null&&o.jsx(oH,{humidity:Xe.humidity,goodThreshold:i?.humidityGood,fairThreshold:i?.humidityFair,onClick:()=>Q({amsId:Xe.id,amsLabel:Eu(Xe.id,Xe.tray.length),mode:"humidity"}),compact:!0})]})]})]},Xe.id)}),X.vt_tray&&X.vt_tray.tray_type&&(()=>{const Xe=X.vt_tray,Ut=G===254,Ct=Xe.tray_info_idx?ie?.[Xe.tray_info_idx]:null,$t={vendor:Xe.tray_uuid?"Bambu Lab":"Generic",profile:Ct?.name||Xe.tray_sub_brands||Xe.tray_type||"Unknown",colorName:CN(Xe.tray_id_name)||kN(Xe.tray_color),colorHex:Xe.tray_color||null,kFactor:PN(Xe.k),fillLevel:null,trayUuid:Xe.tray_uuid||null},gn=o.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${Ut?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[o.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:Xe.tray_color?`#${Xe.tray_color}`:"#333",borderColor:Ut?"var(--accent)":"rgba(255,255,255,0.1)"}}),o.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Xe.tray_type||"Spool"}),o.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"})})]});return o.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[o.jsx("div",{className:"flex items-center gap-1 mb-2",children:o.jsx("span",{className:"text-[10px] text-white font-medium",children:"External"})}),o.jsx(NN,{data:$t,spoolman:{enabled:a,onLinkSpool:a&&$t.trayUuid?Fn=>{V({trayUuid:Fn,trayInfo:{type:$t.profile,color:$t.colorHex||"",location:"External Spool"}})}:void 0},children:gn})]})})()]})]})]})})()]}),Z&&r==="expanded"&&o.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx(sf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),o.jsx("span",{className:"text-sm text-white truncate",children:Z.name}),oe&&o.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${oe.state==="ON"?"bg-bambu-green/20 text-bambu-green":oe.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:oe.state||"?"}),oe?.energy?.power!=null&&oe.state==="ON"&&o.jsxs("span",{className:"text-xs text-yellow-400 font-medium flex-shrink-0",children:[oe.energy.power,"W"]})]}),o.jsx("div",{className:"flex-1"}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsxs("button",{onClick:()=>C(!0),disabled:Se.isPending||oe?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${oe?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[o.jsx(jl,{className:"w-3 h-3"}),"On"]}),o.jsxs("button",{onClick:()=>O(!0),disabled:Se.isPending||oe?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${oe?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[o.jsx(nM,{className:"w-3 h-3"}),"Off"]})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx("span",{className:`text-xs hidden sm:inline ${Z.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:Z.auto_off_executed?"Auto-off done":"Auto-off"}),o.jsx("button",{onClick:()=>ye.mutate(!Z.auto_off),disabled:ye.isPending||Z.auto_off_executed,title:Z.auto_off_executed?"Auto-off was executed - turn printer on to reset":"Auto power-off after print",className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${Z.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":Z.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:o.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${Z.auto_off||Z.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),r==="expanded"&&o.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[o.jsxs("div",{className:"text-xs text-bambu-gray",children:[o.jsx("p",{children:t.ip_address}),o.jsx("p",{className:"truncate",children:t.serial_number})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>{const Ae=localStorage.getItem("cameraWindowState"),lt=Ae?JSON.parse(Ae):{width:640,height:400},_t=[`width=${lt.width}`,`height=${lt.height}`,lt.left!==void 0?`left=${lt.left}`:"",lt.top!==void 0?`top=${lt.top}`:"","menubar=no,toolbar=no,location=no,status=no"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,_t)},disabled:!X?.connected,title:"Open camera in new window",children:o.jsx(X9,{className:"w-4 h-4"})}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>E(!0),title:"Browse printer files",children:[o.jsx(fR,{className:"w-4 h-4"}),"Files"]})]})]})]}),b&&o.jsx(Kde,{printerId:t.id,printerName:t.name,onClose:()=>E(!1)}),w&&o.jsx(Xde,{printerId:t.id,printerName:t.name,onClose:()=>A(!1)}),T&&Z&&o.jsx(br,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{Se.mutate("on"),C(!1)},onCancel:()=>C(!1)}),N&&Z&&o.jsx(br,{title:"Power Off Printer",message:X?.state==="RUNNING"?`WARNING: "${t.name}" is currently printing! Are you sure you want to turn OFF the power? This will interrupt the print and may damage the printer.`:`Are you sure you want to turn OFF the power for "${t.name}"?`,confirmText:"Power Off",variant:"danger",onConfirm:()=>{Se.mutate("off"),O(!1)},onCancel:()=>O(!1)}),B&&o.jsx(br,{title:"Stop Print",message:`Are you sure you want to stop the current print on "${t.name}"? This will cancel the print job.`,confirmText:"Stop Print",variant:"danger",onConfirm:()=>{Ke.mutate(),L(!1)},onCancel:()=>L(!1)}),K&&o.jsx(br,{title:"Pause Print",message:`Are you sure you want to pause the current print on "${t.name}"?`,confirmText:"Pause Print",variant:"default",onConfirm:()=>{We.mutate(),R(!1)},onCancel:()=>R(!1)}),q&&o.jsx(br,{title:"Resume Print",message:`Are you sure you want to resume the print on "${t.name}"?`,confirmText:"Resume Print",variant:"default",onConfirm:()=>{qe.mutate(),W(!1)},onCancel:()=>W(!1)}),$&&o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>J(!1),onKeyDown:Ae=>Ae.key==="Escape"&&J(!1),tabIndex:-1,ref:Ae=>Ae?.focus(),children:[o.jsx("div",{className:"absolute inset-0 bg-black/50 z-0"}),o.jsxs("div",{className:"relative z-10 bg-white dark:bg-bambu-dark border border-gray-200 dark:border-bambu-dark-tertiary rounded-xl shadow-2xl w-[560px] overflow-hidden",onClick:Ae=>Ae.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(rH,{className:"w-4 h-4 text-bambu-green"}),o.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Skip Objects"})]}),o.jsx("button",{onClick:()=>J(!1),className:"p-1 text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white rounded transition-colors",children:o.jsx(Wt,{className:"w-4 h-4"})})]}),ue?ue.objects.length===0?o.jsxs("div",{className:"text-center py-8 px-4 text-bambu-gray",children:[o.jsx("p",{className:"text-sm",children:"No objects found"}),o.jsx("p",{className:"text-xs mt-1 opacity-70",children:"Objects are loaded when a print starts"})]}):o.jsxs("div",{className:"flex flex-col",children:[o.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 bg-blue-50 dark:bg-blue-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[o.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-lg bg-blue-100 dark:bg-blue-500/20 flex items-center justify-center",children:o.jsx(eue,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-300",children:"Match IDs with your printer display"}),o.jsx("p",{className:"text-[10px] text-blue-500/70 dark:text-blue-300/60",children:"The printer screen shows object IDs on the build plate"})]}),o.jsxs("div",{className:"flex-shrink-0 text-xs text-gray-500 dark:text-bambu-gray",children:[ue.skipped_count,"/",ue.total," skipped"]})]}),(X?.layer_num??0)<=1&&o.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-50 dark:bg-amber-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[o.jsx(Oa,{className:"w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0"}),o.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:["Wait for layer 2+ to skip objects (currently layer ",X?.layer_num??0,")"]})]}),o.jsxs("div",{className:"flex",children:[o.jsx("div",{className:"w-52 flex-shrink-0 p-4 border-r border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark-secondary",children:o.jsxs("div",{className:"relative",children:[X?.cover_url?o.jsx("img",{src:`${X.cover_url}?view=top`,alt:"Print preview",className:"w-full aspect-square object-contain rounded-lg bg-gray-900 dark:bg-gray-900 border border-gray-300 dark:border-gray-600"}):o.jsx("div",{className:"w-full aspect-square rounded-lg bg-gray-100 dark:bg-bambu-dark flex items-center justify-center",children:o.jsx(Qh,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),ue.objects.length>0&&o.jsx("div",{className:"absolute inset-0 pointer-events-none",children:ue.objects.map((Ae,lt)=>{let Xe,Ut;if(Ae.x!=null&&Ae.y!=null)Xe=Math.max(10,Math.min(90,Ae.x/256*100)),Ut=Math.max(10,Math.min(90,100-Ae.y/256*100));else{const Ct=Math.ceil(Math.sqrt(ue.objects.length)),$t=Math.floor(lt/Ct),gn=lt%Ct,Fn=Math.ceil(ue.objects.length/Ct);Xe=15+gn*(70/Ct)+35/Ct,Ut=15+$t*(70/Fn)+35/Fn}return o.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${Ae.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${Xe}%`,top:`${Ut}%`,transform:"translate(-50%, -50%)"},title:Ae.name,children:Ae.id},Ae.id)})}),o.jsxs("div",{className:"absolute bottom-2 right-2 px-2 py-1 bg-white/90 dark:bg-black/80 rounded text-[10px] text-gray-700 dark:text-white shadow-sm",children:[ue.objects.filter(Ae=>!Ae.skipped).length," active"]})]})}),o.jsx("div",{className:"flex-1 min-w-0",children:ue.objects.map(Ae=>o.jsxs("div",{className:`
- flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
- ${Ae.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
- `,children:[o.jsxs("div",{className:`
- w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
- ${Ae.skipped?"bg-red-100 dark:bg-red-500/20 border border-red-300 dark:border-red-500/40":"bg-green-100 dark:bg-bambu-green/20 border border-green-300 dark:border-bambu-green/40"}
- `,children:[o.jsx("span",{className:`text-lg font-mono font-bold ${Ae.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:Ae.id}),o.jsx("span",{className:`text-[8px] uppercase tracking-wider ${Ae.skipped?"text-red-400/60":"text-green-500/60 dark:text-bambu-green/60"}`,children:"ID"})]}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("span",{className:`block text-sm truncate ${Ae.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:Ae.name}),Ae.skipped&&o.jsx("span",{className:"text-[10px] text-red-400/60",children:"Will be skipped"})]}),Ae.skipped?o.jsx("span",{className:"px-4 py-2 text-xs text-red-500 dark:text-red-400/70 bg-red-100 dark:bg-red-500/10 rounded-lg",children:"Skipped"}):o.jsx("button",{onClick:()=>Ve.mutate([Ae.id]),disabled:Ve.isPending||(X?.layer_num??0)<=1,className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(X?.layer_num??0)<=1?"bg-gray-100 dark:bg-bambu-dark text-gray-400 dark:text-bambu-gray/50 cursor-not-allowed":"bg-red-100 dark:bg-red-500/20 text-red-600 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-500/30 border border-red-300 dark:border-red-500/30"}`,title:(X?.layer_num??0)<=1?"Wait for layer 2+":"Skip this object",children:"Skip"})]},Ae.id))})]})]}):o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(pt,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),k&&o.jsx(Jde,{printerName:t.name,errors:X?.hms_errors||[],onClose:()=>j(!1)}),ee&&o.jsx(qNe,{isOpen:!!ee,onClose:()=>Q(null),printerId:t.id,printerName:t.name,amsId:ee.amsId,amsLabel:ee.amsLabel,initialMode:ee.mode,thresholds:i}),z&&o.jsx(KNe,{isOpen:!!z,onClose:()=>V(null),trayUuid:z.trayUuid,trayInfo:z.trayInfo}),v&&o.jsx(lCe,{printer:t,onClose:()=>y(!1)}),Pe&&o.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>we(null)})]})}function oCe({onClose:t,onAdd:e,existingSerials:n}){const[r,i]=S.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0}),[a,s]=S.useState(!1),[l,c]=S.useState([]),[u,d]=S.useState(""),[f,g]=S.useState(!1),[p,x]=S.useState(!1),[v,y]=S.useState("192.168.1.0/24"),[b,E]=S.useState({scanned:0,total:0});S.useEffect(()=>{nl.getInfo().then(N=>{x(N.is_docker)}).catch(()=>{})},[]);const w=l.filter(N=>!n.includes(N.serial)),A=async()=>{d(""),c([]),s(!0),g(!1),E({scanned:0,total:0});try{if(p){await nl.startSubnetScan(v);const N=setInterval(async()=>{try{const O=await nl.getScanStatus();E({scanned:O.scanned,total:O.total});const k=await nl.getDiscoveredPrinters();c(k),O.running||(clearInterval(N),s(!1),g(!0))}catch(O){console.error("Failed to get scan status:",O)}},500)}else{await nl.startDiscovery(10);const N=setInterval(async()=>{try{const O=await nl.getDiscoveredPrinters();c(O)}catch(O){console.error("Failed to get discovered printers:",O)}},1e3);setTimeout(async()=>{clearInterval(N);try{await nl.stopDiscovery()}catch{}s(!1),g(!0);try{const O=await nl.getDiscoveredPrinters();c(O)}catch(O){console.error("Failed to get final discovered printers:",O)}},1e4)}}catch(N){console.error("Failed to start discovery:",N),d(N instanceof Error?N.message:"Failed to start discovery"),s(!1),g(!0)}},T=N=>N?{O1D:"H2D",O1C:"H2C",O1S:"H2S","BL-P001":"X1C","BL-P002":"X1","BL-P003":"X1E",C11:"P1S",C12:"P1P",C13:"P2S",N2S:"A1",N1:"A1 Mini",X1C:"X1C",X1:"X1",X1E:"X1E",P1S:"P1S",P1P:"P1P",P2S:"P2S",A1:"A1","A1 Mini":"A1 Mini",H2D:"H2D",H2C:"H2C",H2S:"H2S"}[N]||N:"",C=N=>{i({...r,name:N.name||"",serial_number:N.serial,ip_address:N.ip_address,model:T(N.model)}),c([])};return S.useEffect(()=>()=>{nl.stopDiscovery().catch(()=>{}),nl.stopSubnetScan().catch(()=>{})},[]),S.useEffect(()=>{const N=O=>{O.key==="Escape"&&t()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[t]),o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:o.jsx(Mt,{className:"w-full max-w-md",onClick:N=>N.stopPropagation(),children:o.jsxs(At,{children:[o.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),o.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[p&&o.jsxs("div",{className:"mb-3",children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Subnet to scan"}),o.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm",value:v,onChange:N=>y(N.target.value),placeholder:"192.168.1.0/24",disabled:a}),o.jsxs("p",{className:"mt-1 text-xs text-bambu-gray",children:["Docker detected. Enter your printer's subnet in CIDR notation. Requires ",o.jsx("code",{className:"text-bambu-green",children:"network_mode: host"})," in docker-compose.yml."]})]}),o.jsx(ke,{type:"button",variant:"secondary",onClick:A,disabled:a,className:"w-full",children:a?o.jsxs(o.Fragment,{children:[o.jsx(pt,{className:"w-4 h-4 animate-spin"}),p&&b.total>0?`Scanning... ${b.scanned}/${b.total}`:"Scanning..."]}):o.jsxs(o.Fragment,{children:[o.jsx(_l,{className:"w-4 h-4"}),p?"Scan Subnet for Printers":"Discover Printers on Network"]})}),u&&o.jsx("div",{className:"mt-2 text-sm text-red-400",children:u}),w.length>0&&o.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:w.map(N=>o.jsxs("div",{className:"flex items-center justify-between p-2 bg-bambu-dark rounded-lg hover:bg-bambu-dark-secondary cursor-pointer transition-colors",onClick:()=>C(N),children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"font-medium text-white text-sm truncate",children:N.name||N.serial}),o.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[T(N.model)||"Unknown"," • ",N.ip_address]})]}),o.jsx(vo,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},N.serial))}),a&&o.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:p?"Scanning subnet for Bambu printers...":"Scanning network..."}),f&&!a&&l.length===0&&o.jsxs("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:["No printers found",p?" in the specified subnet":" on the network","."]}),f&&!a&&l.length>0&&w.length===0&&o.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:"All discovered printers are already configured."})]}),o.jsxs("form",{onSubmit:N=>{N.preventDefault(),e(r)},className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),o.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.name,onChange:N=>i({...r,name:N.target.value}),placeholder:"My Printer"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),o.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.ip_address,onChange:N=>i({...r,ip_address:N.target.value}),placeholder:"192.168.1.100"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),o.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.serial_number,onChange:N=>i({...r,serial_number:N.target.value}),placeholder:"01P00A000000000"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),o.jsx("input",{type:"password",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:N=>i({...r,access_code:N.target.value}),placeholder:"From printer settings"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),o.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.model||"",onChange:N=>i({...r,model:N.target.value}),children:[o.jsx("option",{value:"",children:"Select model..."}),o.jsxs("optgroup",{label:"H2 Series",children:[o.jsx("option",{value:"H2C",children:"H2C"}),o.jsx("option",{value:"H2D",children:"H2D"}),o.jsx("option",{value:"H2S",children:"H2S"})]}),o.jsxs("optgroup",{label:"X1 Series",children:[o.jsx("option",{value:"X1E",children:"X1E"}),o.jsx("option",{value:"X1C",children:"X1 Carbon"}),o.jsx("option",{value:"X1",children:"X1"})]}),o.jsxs("optgroup",{label:"P Series",children:[o.jsx("option",{value:"P2S",children:"P2S"}),o.jsx("option",{value:"P1S",children:"P1S"}),o.jsx("option",{value:"P1P",children:"P1P"})]}),o.jsxs("optgroup",{label:"A1 Series",children:[o.jsx("option",{value:"A1",children:"A1"}),o.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"auto_archive",checked:r.auto_archive,onChange:N=>i({...r,auto_archive:N.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),o.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),o.jsxs("div",{className:"flex gap-3 pt-4",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),o.jsx(ke,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function lCe({printer:t,onClose:e}){const n=pn(),[r,i]=S.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),a=vt({mutationFn:l=>_e.updatePrinter(t.id,l),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});S.useEffect(()=>{const l=c=>{c.key==="Escape"&&e()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e]);const s=l=>{l.preventDefault();const c={name:r.name,ip_address:r.ip_address,model:r.model||void 0,location:r.location||void 0,auto_archive:r.auto_archive};r.access_code&&(c.access_code=r.access_code),a.mutate(c)};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:o.jsx(Mt,{className:"w-full max-w-md",onClick:l=>l.stopPropagation(),children:o.jsxs(At,{children:[o.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),o.jsxs("form",{onSubmit:s,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),o.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.name,onChange:l=>i({...r,name:l.target.value}),placeholder:"My Printer"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),o.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.ip_address,onChange:l=>i({...r,ip_address:l.target.value}),placeholder:"192.168.1.100"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),o.jsx("input",{type:"text",disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed",value:t.serial_number}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),o.jsx("input",{type:"password",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:l=>i({...r,access_code:l.target.value}),placeholder:"Leave empty to keep current"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),o.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.model,onChange:l=>i({...r,model:l.target.value}),children:[o.jsx("option",{value:"",children:"Select model..."}),o.jsxs("optgroup",{label:"H2 Series",children:[o.jsx("option",{value:"H2C",children:"H2C"}),o.jsx("option",{value:"H2D",children:"H2D"}),o.jsx("option",{value:"H2S",children:"H2S"})]}),o.jsxs("optgroup",{label:"X1 Series",children:[o.jsx("option",{value:"X1E",children:"X1E"}),o.jsx("option",{value:"X1C",children:"X1 Carbon"}),o.jsx("option",{value:"X1",children:"X1"})]}),o.jsxs("optgroup",{label:"P Series",children:[o.jsx("option",{value:"P2S",children:"P2S"}),o.jsx("option",{value:"P1S",children:"P1S"}),o.jsx("option",{value:"P1P",children:"P1P"})]}),o.jsxs("optgroup",{label:"A1 Series",children:[o.jsx("option",{value:"A1",children:"A1"}),o.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),o.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.location,onChange:l=>i({...r,location:l.target.value}),placeholder:"e.g., Workshop, Office, Basement"}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:r.auto_archive,onChange:l=>i({...r,auto_archive:l.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),o.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),o.jsxs("div",{className:"flex gap-3 pt-4",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsx(ke,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function cCe(t){const{data:e}=gt({queryKey:["printerStatus",t],queryFn:()=>_e.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function uCe({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=cCe(t.id),{data:a}=gt({queryKey:["smartPlugStatus",e.id],queryFn:()=>_e.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?o.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),a&&o.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${a.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:a.state||"?"})]}),o.jsxs("button",{onClick:()=>n(e.id),disabled:r||a?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${a?.state==="ON"?"bg-bambu-green/20 text-bambu-green cursor-default":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white"}`,children:[o.jsx(jl,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function dCe(){const[t,e]=S.useState(!1),[n,r]=S.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,a]=S.useState(!1),[s,l]=S.useState(null),[c,u]=S.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=S.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[g,p]=S.useState(()=>localStorage.getItem("printerViewMode")||"expanded"),x=pn(),{data:v,isLoading:y}=gt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:b}=gt({queryKey:["settings"],queryFn:_e.getSettings}),{data:E}=gt({queryKey:["smart-plugs"],queryFn:_e.getSmartPlugs}),{data:w}=gt({queryKey:["maintenanceOverview"],queryFn:_e.getMaintenanceOverview,staleTime:60*1e3}),{data:A}=gt({queryKey:["spoolman-status"],queryFn:_e.getSpoolmanStatus,staleTime:60*1e3}),T=A?.enabled&&A?.connected,C=w?.reduce((W,$)=>(W[$.printer_id]={due_count:$.due_count,warning_count:$.warning_count,total_print_hours:$.total_print_hours},W),{})||{},N=E?.reduce((W,$)=>($.printer_id&&(W[$.printer_id]=$),W),{})||{},O=vt({mutationFn:_e.createPrinter,onSuccess:()=>{x.invalidateQueries({queryKey:["printers"]}),e(!1)}}),k=vt({mutationFn:W=>_e.controlSmartPlug(W,"on"),onSuccess:()=>{x.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),j=()=>{const W=!n;r(W),localStorage.setItem("hideDisconnectedPrinters",String(W))},B=W=>{u(W),localStorage.setItem("printerSortBy",W)},L=()=>{const W=!d;f(W),localStorage.setItem("printerSortAsc",String(W))},K=()=>{const W=g==="expanded"?"compact":"expanded";p(W),localStorage.setItem("printerViewMode",W)},R=S.useMemo(()=>{if(!v)return[];const W=[...v];switch(c){case"name":W.sort(($,J)=>$.name.localeCompare(J.name));break;case"model":W.sort(($,J)=>($.model||"").localeCompare(J.model||""));break;case"location":W.sort(($,J)=>{const ee=$.location||"",Q=J.location||"";return!ee&&Q?1:ee&&!Q?-1:ee.localeCompare(Q)||$.name.localeCompare(J.name)});break;case"status":W.sort(($,J)=>{const ee=x.getQueryData(["printerStatus",$.id]),Q=x.getQueryData(["printerStatus",J.id]),z=V=>V?.connected?V.state==="RUNNING"?0:1:2;return z(ee)-z(Q)});break}return d||W.reverse(),W},[v,c,d,x]),q=S.useMemo(()=>{if(c!=="location")return null;const W={};return R.forEach($=>{const J=$.location||"Ungrouped";W[J]||(W[J]=[]),W[J].push($)}),W},[c,R]);return o.jsxs("div",{className:"p-4 md:p-8",children:[o.jsxs("div",{className:"flex items-center justify-between mb-6",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),o.jsx(sCe,{printers:v})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsxs("select",{value:c,onChange:W=>B(W.target.value),className:"text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-2 py-1.5 text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"name",children:"Name"}),o.jsx("option",{value:"status",children:"Status"}),o.jsx("option",{value:"model",children:"Model"}),o.jsx("option",{value:"location",children:"Location"})]}),o.jsx("button",{onClick:L,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?o.jsx(Mp,{className:"w-4 h-4 text-bambu-gray"}):o.jsx(j0,{className:"w-4 h-4 text-bambu-gray"})})]}),o.jsx("button",{onClick:K,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:g==="expanded"?"Switch to compact view":"Switch to expanded view",children:g==="expanded"?o.jsx(Mce,{className:"w-5 h-5 text-bambu-gray"}):o.jsx(tM,{className:"w-5 h-5 text-bambu-gray"})}),o.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),o.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:n,onChange:j,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(N).length>0&&o.jsxs("div",{className:"relative",children:[o.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg text-gray-600 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white hover:border-bambu-green transition-colors",children:[o.jsx(jl,{className:"w-4 h-4"}),"Power On",o.jsx(vo,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),o.jsxs("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1",children:[o.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary",children:"Offline printers with smart plugs"}),v?.filter(W=>N[W.id]).map(W=>o.jsx(uCe,{printer:W,plug:N[W.id],onPowerOn:$=>{l($),k.mutate($)},isPowering:s===N[W.id]?.id},W.id)),v?.filter(W=>N[W.id]).length===0&&o.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),o.jsxs(ke,{onClick:()=>e(!0),children:[o.jsx(fr,{className:"w-4 h-4"}),"Add Printer"]})]})]}),y?o.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):v?.length===0?o.jsx(Mt,{children:o.jsxs(At,{className:"text-center py-12",children:[o.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),o.jsxs(ke,{onClick:()=>e(!0),children:[o.jsx(fr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):q?o.jsx("div",{className:"space-y-6",children:Object.entries(q).map(([W,$])=>o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),W,o.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",$.length,")"]})]}),o.jsx("div",{className:`grid gap-4 ${g==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:$.map(J=>o.jsx(dH,{printer:J,hideIfDisconnected:n,maintenanceInfo:C[J.id],viewMode:g,amsThresholds:b?{humidityGood:Number(b.ams_humidity_good)||40,humidityFair:Number(b.ams_humidity_fair)||60,tempGood:Number(b.ams_temp_good)||28,tempFair:Number(b.ams_temp_fair)||35}:void 0,spoolmanEnabled:T},J.id))})]},W))}):o.jsx("div",{className:`grid gap-4 ${g==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:R.map(W=>o.jsx(dH,{printer:W,hideIfDisconnected:n,maintenanceInfo:C[W.id],viewMode:g,spoolmanEnabled:T,amsThresholds:b?{humidityGood:Number(b.ams_humidity_good)||40,humidityFair:Number(b.ams_humidity_fair)||60,tempGood:Number(b.ams_temp_good)||28,tempFair:Number(b.ams_temp_fair)||35}:void 0},W.id))}),t&&o.jsx(oCe,{onClose:()=>e(!1),onAdd:W=>O.mutate(W),existingSerials:v?.map(W=>W.serial_number)||[]})]})}function hCe(){const t=navigator.userAgent.toLowerCase(),e=navigator.platform?.toLowerCase()||"";return t.includes("win")||e.includes("win")?"windows":t.includes("mac")||e.includes("mac")?"macos":t.includes("linux")||e.includes("linux")?"linux":"unknown"}function fCe(){switch(hCe()){case"windows":return"bambustudio://";case"macos":case"linux":default:return"bambustudioopen://"}}function bh(t){const e=fCe();window.location.href=`${e}${encodeURIComponent(t)}`}const SO="181",pp={ROTATE:0,DOLLY:1,PAN:2},lp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},mCe=0,hH=1,pCe=2,mZ=1,gCe=2,pc=3,Md=0,ts=1,dl=2,Dc=0,gp=1,fH=2,mH=3,pH=4,xCe=5,yh=100,bCe=101,yCe=102,vCe=103,_Ce=104,wCe=200,SCe=201,MCe=202,ECe=203,oP=204,lP=205,ACe=206,TCe=207,NCe=208,CCe=209,kCe=210,PCe=211,jCe=212,RCe=213,DCe=214,cP=0,uP=1,dP=2,Fp=3,hP=4,fP=5,mP=6,pP=7,MO=0,OCe=1,LCe=2,ld=0,ICe=1,FCe=2,UCe=3,zCe=4,BCe=5,HCe=6,$Ce=7,pZ=300,Up=301,zp=302,gP=303,xP=304,JM=306,bP=1e3,Tc=1001,yP=1002,ks=1003,VCe=1004,Kv=1005,oo=1006,RN=1007,Ch=1008,Al=1009,gZ=1010,xZ=1011,J0=1012,EO=1013,mf=1014,Nc=1015,yg=1016,AO=1017,TO=1018,eb=1020,bZ=35902,yZ=35899,vZ=1021,_Z=1022,Fo=1023,tb=1026,nb=1027,wZ=1028,NO=1029,CO=1030,kO=1031,PO=1033,v1=33776,_1=33777,w1=33778,S1=33779,vP=35840,_P=35841,wP=35842,SP=35843,MP=36196,EP=37492,AP=37496,TP=37808,NP=37809,CP=37810,kP=37811,PP=37812,jP=37813,RP=37814,DP=37815,OP=37816,LP=37817,IP=37818,FP=37819,UP=37820,zP=37821,BP=36492,HP=36494,$P=36495,VP=36283,GP=36284,WP=36285,qP=36286,GCe=3200,WCe=3201,SZ=0,qCe=1,Yu="",Qs="srgb",Bp="srgb-linear",$w="linear",ar="srgb",mm=7680,gH=519,KCe=512,XCe=513,YCe=514,MZ=515,ZCe=516,QCe=517,JCe=518,eke=519,xH=35044,bH="300 es",pl=2e3,Vw=2001;function EZ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Gw(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function tke(){const t=Gw("canvas");return t.style.display="block",t}const yH={};function vH(...t){const e="THREE."+t.shift();console.log(e,...t)}function en(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Qr(...t){const e="THREE."+t.shift();console.error(e,...t)}function rb(...t){const e=t.join(" ");e in yH||(yH[e]=!0,en(...t))}function nke(t,e,n){return new Promise(function(r,i){function a(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}let Nf=class{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,s=i.length;a<s;a++)i[a].call(this,e);e.target=null}}};const ha=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],M1=Math.PI/180,KP=180/Math.PI;function ay(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ha[t&255]+ha[t>>8&255]+ha[t>>16&255]+ha[t>>24&255]+"-"+ha[e&255]+ha[e>>8&255]+"-"+ha[e>>16&15|64]+ha[e>>24&255]+"-"+ha[n&63|128]+ha[n>>8&255]+"-"+ha[n>>16&255]+ha[n>>24&255]+ha[r&255]+ha[r>>8&255]+ha[r>>16&255]+ha[r>>24&255]).toLowerCase()}function wn(t,e,n){return Math.max(e,Math.min(n,t))}function rke(t,e){return(t%e+e)%e}function DN(t,e,n){return(1-n)*t+n*e}function Nx(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Ka(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const ike={DEG2RAD:M1};let fn=class AZ{constructor(e=0,n=0){AZ.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=wn(this.x,e.x,n.x),this.y=wn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=wn(this.x,e,n),this.y=wn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(wn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(wn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,s=this.y-e.y;return this.x=a*r-s*i+e.x,this.y=a*i+s*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},pf=class{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,s,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3],g=a[s+0],p=a[s+1],x=a[s+2],v=a[s+3];if(l<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l>=1){e[n+0]=g,e[n+1]=p,e[n+2]=x,e[n+3]=v;return}if(f!==v||c!==g||u!==p||d!==x){let y=c*g+u*p+d*x+f*v;y<0&&(g=-g,p=-p,x=-x,v=-v,y=-y);let b=1-l;if(y<.9995){const E=Math.acos(y),w=Math.sin(E);b=Math.sin(b*E)/w,l=Math.sin(l*E)/w,c=c*b+g*l,u=u*b+p*l,d=d*b+x*l,f=f*b+v*l}else{c=c*b+g*l,u=u*b+p*l,d=d*b+x*l,f=f*b+v*l;const E=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=E,u*=E,d*=E,f*=E}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,s){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[s],g=a[s+1],p=a[s+2],x=a[s+3];return e[n]=l*x+d*f+c*p-u*g,e[n+1]=c*x+d*g+u*f-l*p,e[n+2]=u*x+d*p+l*g-c*f,e[n+3]=d*x-l*f-c*g-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,a=e._z,s=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),g=c(r/2),p=c(i/2),x=c(a/2);switch(s){case"XYZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"YXZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"ZXY":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"ZYX":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"YZX":this._x=g*d*f+u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f-g*p*x;break;case"XZY":this._x=g*d*f-u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f+g*p*x;break;default:en("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],s=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],g=r+l+f;if(g>0){const p=.5/Math.sqrt(g+1);this._w=.25/p,this._x=(d-c)*p,this._y=(a-u)*p,this._z=(s-i)*p}else if(r>l&&r>f){const p=2*Math.sqrt(1+r-l-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+s)/p,this._z=(a+u)/p}else if(l>f){const p=2*Math.sqrt(1+l-r-f);this._w=(a-u)/p,this._x=(i+s)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(s-i)/p,this._x=(a+u)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(wn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,s=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+s*l+i*u-a*c,this._y=i*d+s*c+a*l-r*u,this._z=a*d+s*u+r*c-i*l,this._w=s*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,a=e._z,s=e._w,l=this.dot(e);l<0&&(r=-r,i=-i,a=-a,s=-s,l=-l);let c=1-n;if(l<.9995){const u=Math.acos(l),d=Math.sin(u);c=Math.sin(c*u)/d,n=Math.sin(n*u)/d,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+s*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+s*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),a=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),a*Math.sin(n),a*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},at=class TZ{constructor(e=0,n=0,r=0){TZ.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(_H.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(_H.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,s=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*s,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*s,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*s,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,s=e.y,l=e.z,c=e.w,u=2*(s*i-l*r),d=2*(l*n-a*i),f=2*(a*r-s*n);return this.x=n+c*u+s*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*d-s*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=wn(this.x,e.x,n.x),this.y=wn(this.y,e.y,n.y),this.z=wn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=wn(this.x,e,n),this.y=wn(this.y,e,n),this.z=wn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(wn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,s=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*s-r*c,this.z=r*l-i*s,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return ON.copy(this).projectOnVector(e),this.sub(ON)}reflect(e){return this.sub(ON.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(wn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const ON=new at,_H=new pf;let xn=class NZ{constructor(e,n,r,i,a,s,l,c,u){NZ.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,l,c,u)}set(e,n,r,i,a,s,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=s,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],g=r[2],p=r[5],x=r[8],v=i[0],y=i[3],b=i[6],E=i[1],w=i[4],A=i[7],T=i[2],C=i[5],N=i[8];return a[0]=s*v+l*E+c*T,a[3]=s*y+l*w+c*C,a[6]=s*b+l*A+c*N,a[1]=u*v+d*E+f*T,a[4]=u*y+d*w+f*C,a[7]=u*b+d*A+f*N,a[2]=g*v+p*E+x*T,a[5]=g*y+p*w+x*C,a[8]=g*b+p*A+x*N,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*s*d-n*l*u-r*a*d+r*l*c+i*a*u-i*s*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*s-l*u,g=l*c-d*a,p=u*a-s*c,x=n*f+r*g+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/x;return e[0]=f*v,e[1]=(i*u-d*r)*v,e[2]=(l*r-i*s)*v,e[3]=g*v,e[4]=(d*n-i*c)*v,e[5]=(i*a-l*n)*v,e[6]=p*v,e[7]=(r*c-u*n)*v,e[8]=(s*n-r*a)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*s+u*l)+s+e,-i*u,i*c,-i*(-u*s+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(LN.makeScale(e,n)),this}rotate(e){return this.premultiply(LN.makeRotation(-e)),this}translate(e,n){return this.premultiply(LN.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,r,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const LN=new xn,wH=new xn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),SH=new xn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ake(){const t={enabled:!0,workingColorSpace:Bp,spaces:{},convert:function(i,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===ar&&(i.r=Oc(i.r),i.g=Oc(i.g),i.b=Oc(i.b)),this.spaces[a].primaries!==this.spaces[s].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===ar&&(i.r=xp(i.r),i.g=xp(i.g),i.b=xp(i.b))),i},workingToColorSpace:function(i,a){return this.convert(i,this.workingColorSpace,a)},colorSpaceToWorking:function(i,a){return this.convert(i,a,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Yu?$w:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,a=this.workingColorSpace){return i.fromArray(this.spaces[a].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,a,s){return i.copy(this.spaces[a].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,a){return rb("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return rb("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,a)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[Bp]:{primaries:e,whitePoint:r,transfer:$w,toXYZ:wH,fromXYZ:SH,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Qs},outputColorSpaceConfig:{drawingBufferColorSpace:Qs}},[Qs]:{primaries:e,whitePoint:r,transfer:ar,toXYZ:wH,fromXYZ:SH,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Qs}}}),t}const Ln=ake();function Oc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function xp(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let pm,ske=class{static getDataURL(e,n="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let r;if(e instanceof HTMLCanvasElement)r=e;else{pm===void 0&&(pm=Gw("canvas")),pm.width=e.width,pm.height=e.height;const i=pm.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=pm}return r.toDataURL(n)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=Gw("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let s=0;s<a.length;s++)a[s]=Oc(a[s]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(Oc(n[r]/255)*255):n[r]=Oc(n[r]);return{data:n,width:e.width,height:e.height}}else return en("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},oke=0,jO=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:oke++}),this.uuid=ay(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let s=0,l=i.length;s<l;s++)i[s].isDataTexture?a.push(IN(i[s].image)):a.push(IN(i[s]))}else a=IN(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function IN(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?ske.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(en("Texture: Unable to serialize Texture."),{})}let lke=0;const FN=new at;let Yo=class E1 extends Nf{constructor(e=E1.DEFAULT_IMAGE,n=E1.DEFAULT_MAPPING,r=Tc,i=Tc,a=oo,s=Ch,l=Fo,c=Al,u=E1.DEFAULT_ANISOTROPY,d=Yu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:lke++}),this.uuid=ay(),this.name="",this.source=new jO(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=s,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new fn(0,0),this.repeat=new fn(1,1),this.center=new fn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new xn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(FN).x}get height(){return this.source.getSize(FN).y}get depth(){return this.source.getSize(FN).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const n in e){const r=e[n];if(r===void 0){en(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){en(`Texture.setValues(): property '${n}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==pZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case bP:e.x=e.x-Math.floor(e.x);break;case Tc:e.x=e.x<0?0:1;break;case yP:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case bP:e.y=e.y-Math.floor(e.y);break;case Tc:e.y=e.y<0?0:1;break;case yP:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Yo.DEFAULT_IMAGE=null;Yo.DEFAULT_MAPPING=pZ;Yo.DEFAULT_ANISOTROPY=1;let ci=class CZ{constructor(e=0,n=0,r=0,i=1){CZ.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i+s[12]*a,this.y=s[1]*n+s[5]*r+s[9]*i+s[13]*a,this.z=s[2]*n+s[6]*r+s[10]*i+s[14]*a,this.w=s[3]*n+s[7]*r+s[11]*i+s[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],g=c[1],p=c[5],x=c[9],v=c[2],y=c[6],b=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-v)<.01&&Math.abs(x-y)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+v)<.1&&Math.abs(x+y)<.1&&Math.abs(u+p+b-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(u+1)/2,A=(p+1)/2,T=(b+1)/2,C=(d+g)/4,N=(f+v)/4,O=(x+y)/4;return w>A&&w>T?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=C/r,a=N/r):A>T?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=C/i,a=O/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=N/a,i=O/a),this.set(r,i,a,n),this}let E=Math.sqrt((y-x)*(y-x)+(f-v)*(f-v)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(y-x)/E,this.y=(f-v)/E,this.z=(g-d)/E,this.w=Math.acos((u+p+b-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=wn(this.x,e.x,n.x),this.y=wn(this.y,e.y,n.y),this.z=wn(this.z,e.z,n.z),this.w=wn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=wn(this.x,e,n),this.y=wn(this.y,e,n),this.z=wn(this.z,e,n),this.w=wn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(wn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},cke=class extends Nf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:oo,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},r),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=r.depth,this.scissor=new ci(0,0,e,n),this.scissorTest=!1,this.viewport=new ci(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new Yo(i);this.textures=[];const s=r.count;for(let l=0;l<s;l++)this.textures[l]=a.clone(),this.textures[l].isRenderTargetTexture=!0,this.textures[l].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:oo,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,a=this.textures.length;i<a;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new jO(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},gf=class extends cke{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},kZ=class extends Yo{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ks,this.minFilter=ks,this.wrapR=Tc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},uke=class extends Yo{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ks,this.minFilter=ks,this.wrapR=Tc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},xf=class{constructor(e=new at(1/0,1/0,1/0),n=new at(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(Ao.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Ao.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=Ao.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,l=a.count;s<l;s++)e.isMesh===!0?e.getVertexPosition(s,Ao):Ao.fromBufferAttribute(a,s),Ao.applyMatrix4(e.matrixWorld),this.expandByPoint(Ao);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Xv.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Xv.copy(r.boundingBox)),Xv.applyMatrix4(e.matrixWorld),this.union(Xv)}const i=e.children;for(let a=0,s=i.length;a<s;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ao),Ao.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Cx),Yv.subVectors(this.max,Cx),gm.subVectors(e.a,Cx),xm.subVectors(e.b,Cx),bm.subVectors(e.c,Cx),Au.subVectors(xm,gm),Tu.subVectors(bm,xm),eh.subVectors(gm,bm);let n=[0,-Au.z,Au.y,0,-Tu.z,Tu.y,0,-eh.z,eh.y,Au.z,0,-Au.x,Tu.z,0,-Tu.x,eh.z,0,-eh.x,-Au.y,Au.x,0,-Tu.y,Tu.x,0,-eh.y,eh.x,0];return!UN(n,gm,xm,bm,Yv)||(n=[1,0,0,0,1,0,0,0,1],!UN(n,gm,xm,bm,Yv))?!1:(Zv.crossVectors(Au,Tu),n=[Zv.x,Zv.y,Zv.z],UN(n,gm,xm,bm,Yv))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ao).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ao).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(tc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),tc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),tc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),tc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),tc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),tc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),tc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),tc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(tc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}};const tc=[new at,new at,new at,new at,new at,new at,new at,new at],Ao=new at,Xv=new xf,gm=new at,xm=new at,bm=new at,Au=new at,Tu=new at,eh=new at,Cx=new at,Yv=new at,Zv=new at,th=new at;function UN(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){th.fromArray(t,a);const l=i.x*Math.abs(th.x)+i.y*Math.abs(th.y)+i.z*Math.abs(th.z),c=e.dot(th),u=n.dot(th),d=r.dot(th);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const dke=new xf,kx=new at,zN=new at;let eE=class{constructor(e=new at,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):dke.setFromPoints(e).getCenter(r);let i=0;for(let a=0,s=e.length;a<s;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;kx.subVectors(e,this.center);const n=kx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(kx,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(zN.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(kx.copy(e.center).add(zN)),this.expandByPoint(kx.copy(e.center).sub(zN))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const nc=new at,BN=new at,Qv=new at,Nu=new at,HN=new at,Jv=new at,$N=new at;let RO=class{constructor(e=new at,n=new at(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,nc)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=nc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(nc.copy(this.origin).addScaledVector(this.direction,n),nc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){BN.copy(e).add(n).multiplyScalar(.5),Qv.copy(n).sub(e).normalize(),Nu.copy(this.origin).sub(BN);const a=e.distanceTo(n)*.5,s=-this.direction.dot(Qv),l=Nu.dot(this.direction),c=-Nu.dot(Qv),u=Nu.lengthSq(),d=Math.abs(1-s*s);let f,g,p,x;if(d>0)if(f=s*c-l,g=s*l-c,x=a*d,f>=0)if(g>=-x)if(g<=x){const v=1/d;f*=v,g*=v,p=f*(f+s*g+2*l)+g*(s*f+g+2*c)+u}else g=a,f=Math.max(0,-(s*g+l)),p=-f*f+g*(g+2*c)+u;else g=-a,f=Math.max(0,-(s*g+l)),p=-f*f+g*(g+2*c)+u;else g<=-x?(f=Math.max(0,-(-s*a+l)),g=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u):g<=x?(f=0,g=Math.min(Math.max(-a,-c),a),p=g*(g+2*c)+u):(f=Math.max(0,-(s*a+l)),g=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u);else g=s>0?-a:a,f=Math.max(0,-(s*g+l)),p=-f*f+g*(g+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(BN).addScaledVector(Qv,g),p}intersectSphere(e,n){nc.subVectors(e.center,this.origin);const r=nc.dot(this.direction),i=nc.dot(nc)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),l=r-s,c=r+s;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,s,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(a=(e.min.y-g.y)*d,s=(e.max.y-g.y)*d):(a=(e.max.y-g.y)*d,s=(e.min.y-g.y)*d),r>s||a>i||((a>r||isNaN(r))&&(r=a),(s<i||isNaN(i))&&(i=s),f>=0?(l=(e.min.z-g.z)*f,c=(e.max.z-g.z)*f):(l=(e.max.z-g.z)*f,c=(e.min.z-g.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,nc)!==null}intersectTriangle(e,n,r,i,a){HN.subVectors(n,e),Jv.subVectors(r,e),$N.crossVectors(HN,Jv);let s=this.direction.dot($N),l;if(s>0){if(i)return null;l=1}else if(s<0)l=-1,s=-s;else return null;Nu.subVectors(this.origin,e);const c=l*this.direction.dot(Jv.crossVectors(Nu,Jv));if(c<0)return null;const u=l*this.direction.dot(HN.cross(Nu));if(u<0||c+u>s)return null;const d=-l*Nu.dot($N);return d<0?null:this.at(d/s,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},fi=class XP{constructor(e,n,r,i,a,s,l,c,u,d,f,g,p,x,v,y){XP.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,l,c,u,d,f,g,p,x,v,y)}set(e,n,r,i,a,s,l,c,u,d,f,g,p,x,v,y){const b=this.elements;return b[0]=e,b[4]=n,b[8]=r,b[12]=i,b[1]=a,b[5]=s,b[9]=l,b[13]=c,b[2]=u,b[6]=d,b[10]=f,b[14]=g,b[3]=p,b[7]=x,b[11]=v,b[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new XP().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,r=e.elements,i=1/ym.setFromMatrixColumn(e,0).length(),a=1/ym.setFromMatrixColumn(e,1).length(),s=1/ym.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*s,n[9]=r[9]*s,n[10]=r[10]*s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,s=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const g=s*d,p=s*f,x=l*d,v=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=g-v*u,n[9]=-l*c,n[2]=v-g*u,n[6]=x+p*u,n[10]=s*c}else if(e.order==="YXZ"){const g=c*d,p=c*f,x=u*d,v=u*f;n[0]=g+v*l,n[4]=x*l-p,n[8]=s*u,n[1]=s*f,n[5]=s*d,n[9]=-l,n[2]=p*l-x,n[6]=v+g*l,n[10]=s*c}else if(e.order==="ZXY"){const g=c*d,p=c*f,x=u*d,v=u*f;n[0]=g-v*l,n[4]=-s*f,n[8]=x+p*l,n[1]=p+x*l,n[5]=s*d,n[9]=v-g*l,n[2]=-s*u,n[6]=l,n[10]=s*c}else if(e.order==="ZYX"){const g=s*d,p=s*f,x=l*d,v=l*f;n[0]=c*d,n[4]=x*u-p,n[8]=g*u+v,n[1]=c*f,n[5]=v*u+g,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=s*c}else if(e.order==="YZX"){const g=s*c,p=s*u,x=l*c,v=l*u;n[0]=c*d,n[4]=v-g*f,n[8]=x*f+p,n[1]=f,n[5]=s*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+x,n[10]=g-v*f}else if(e.order==="XZY"){const g=s*c,p=s*u,x=l*c,v=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=g*f+v,n[5]=s*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=l*d,n[10]=v*f+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(hke,e,fke)}lookAt(e,n,r){const i=this.elements;return bs.subVectors(e,n),bs.lengthSq()===0&&(bs.z=1),bs.normalize(),Cu.crossVectors(r,bs),Cu.lengthSq()===0&&(Math.abs(r.z)===1?bs.x+=1e-4:bs.z+=1e-4,bs.normalize(),Cu.crossVectors(r,bs)),Cu.normalize(),e_.crossVectors(bs,Cu),i[0]=Cu.x,i[4]=e_.x,i[8]=bs.x,i[1]=Cu.y,i[5]=e_.y,i[9]=bs.y,i[2]=Cu.z,i[6]=e_.z,i[10]=bs.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],g=r[9],p=r[13],x=r[2],v=r[6],y=r[10],b=r[14],E=r[3],w=r[7],A=r[11],T=r[15],C=i[0],N=i[4],O=i[8],k=i[12],j=i[1],B=i[5],L=i[9],K=i[13],R=i[2],q=i[6],W=i[10],$=i[14],J=i[3],ee=i[7],Q=i[11],z=i[15];return a[0]=s*C+l*j+c*R+u*J,a[4]=s*N+l*B+c*q+u*ee,a[8]=s*O+l*L+c*W+u*Q,a[12]=s*k+l*K+c*$+u*z,a[1]=d*C+f*j+g*R+p*J,a[5]=d*N+f*B+g*q+p*ee,a[9]=d*O+f*L+g*W+p*Q,a[13]=d*k+f*K+g*$+p*z,a[2]=x*C+v*j+y*R+b*J,a[6]=x*N+v*B+y*q+b*ee,a[10]=x*O+v*L+y*W+b*Q,a[14]=x*k+v*K+y*$+b*z,a[3]=E*C+w*j+A*R+T*J,a[7]=E*N+w*B+A*q+T*ee,a[11]=E*O+w*L+A*W+T*Q,a[15]=E*k+w*K+A*$+T*z,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],s=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],g=e[10],p=e[14],x=e[3],v=e[7],y=e[11],b=e[15];return x*(+a*c*f-i*u*f-a*l*g+r*u*g+i*l*p-r*c*p)+v*(+n*c*p-n*u*g+a*s*g-i*s*p+i*u*d-a*c*d)+y*(+n*u*f-n*l*p-a*s*f+r*s*p+a*l*d-r*u*d)+b*(-i*l*d-n*c*f+n*l*g+i*s*f-r*s*g+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],g=e[10],p=e[11],x=e[12],v=e[13],y=e[14],b=e[15],E=f*y*u-v*g*u+v*c*p-l*y*p-f*c*b+l*g*b,w=x*g*u-d*y*u-x*c*p+s*y*p+d*c*b-s*g*b,A=d*v*u-x*f*u+x*l*p-s*v*p-d*l*b+s*f*b,T=x*f*c-d*v*c-x*l*g+s*v*g+d*l*y-s*f*y,C=n*E+r*w+i*A+a*T;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/C;return e[0]=E*N,e[1]=(v*g*a-f*y*a-v*i*p+r*y*p+f*i*b-r*g*b)*N,e[2]=(l*y*a-v*c*a+v*i*u-r*y*u-l*i*b+r*c*b)*N,e[3]=(f*c*a-l*g*a-f*i*u+r*g*u+l*i*p-r*c*p)*N,e[4]=w*N,e[5]=(d*y*a-x*g*a+x*i*p-n*y*p-d*i*b+n*g*b)*N,e[6]=(x*c*a-s*y*a-x*i*u+n*y*u+s*i*b-n*c*b)*N,e[7]=(s*g*a-d*c*a+d*i*u-n*g*u-s*i*p+n*c*p)*N,e[8]=A*N,e[9]=(x*f*a-d*v*a-x*r*p+n*v*p+d*r*b-n*f*b)*N,e[10]=(s*v*a-x*l*a+x*r*u-n*v*u-s*r*b+n*l*b)*N,e[11]=(d*l*a-s*f*a-d*r*u+n*f*u+s*r*p-n*l*p)*N,e[12]=T*N,e[13]=(d*v*i-x*f*i+x*r*g-n*v*g-d*r*y+n*f*y)*N,e[14]=(x*l*i-s*v*i-x*r*c+n*v*c+s*r*y-n*l*y)*N,e[15]=(s*f*i-d*l*i+d*r*c-n*f*c-s*r*g+n*l*g)*N,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,s=e.x,l=e.y,c=e.z,u=a*s,d=a*l;return this.set(u*s+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*s,0,u*c-i*l,d*c+i*s,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,s){return this.set(1,r,a,0,e,1,s,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,s=n._y,l=n._z,c=n._w,u=a+a,d=s+s,f=l+l,g=a*u,p=a*d,x=a*f,v=s*d,y=s*f,b=l*f,E=c*u,w=c*d,A=c*f,T=r.x,C=r.y,N=r.z;return i[0]=(1-(v+b))*T,i[1]=(p+A)*T,i[2]=(x-w)*T,i[3]=0,i[4]=(p-A)*C,i[5]=(1-(g+b))*C,i[6]=(y+E)*C,i[7]=0,i[8]=(x+w)*N,i[9]=(y-E)*N,i[10]=(1-(g+v))*N,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=ym.set(i[0],i[1],i[2]).length();const s=ym.set(i[4],i[5],i[6]).length(),l=ym.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],To.copy(this);const u=1/a,d=1/s,f=1/l;return To.elements[0]*=u,To.elements[1]*=u,To.elements[2]*=u,To.elements[4]*=d,To.elements[5]*=d,To.elements[6]*=d,To.elements[8]*=f,To.elements[9]*=f,To.elements[10]*=f,n.setFromRotationMatrix(To),r.x=a,r.y=s,r.z=l,this}makePerspective(e,n,r,i,a,s,l=pl,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),g=(n+e)/(n-e),p=(r+i)/(r-i);let x,v;if(c)x=a/(s-a),v=s*a/(s-a);else if(l===pl)x=-(s+a)/(s-a),v=-2*s*a/(s-a);else if(l===Vw)x=-s/(s-a),v=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=g,u[12]=0,u[1]=0,u[5]=f,u[9]=p,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=v,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,s,l=pl,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),g=-(n+e)/(n-e),p=-(r+i)/(r-i);let x,v;if(c)x=1/(s-a),v=s/(s-a);else if(l===pl)x=-2/(s-a),v=-(s+a)/(s-a);else if(l===Vw)x=-1/(s-a),v=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=0,u[12]=g,u[1]=0,u[5]=f,u[9]=0,u[13]=p,u[2]=0,u[6]=0,u[10]=x,u[14]=v,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const ym=new at,To=new fi,hke=new at(0,0,0),fke=new at(1,1,1),Cu=new at,e_=new at,bs=new at,MH=new fi,EH=new pf;let Ed=class PZ{constructor(e=0,n=0,r=0,i=PZ.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],s=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],g=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(wn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-wn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(wn(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-s,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-wn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-s,u));break;case"YZX":this._z=Math.asin(wn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,p));break;case"XZY":this._z=Math.asin(-wn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:en("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return MH.makeRotationFromQuaternion(e),this.setFromRotationMatrix(MH,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return EH.setFromEuler(this),this.setFromQuaternion(EH,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Ed.DEFAULT_ORDER="XYZ";let jZ=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},mke=0;const AH=new at,vm=new pf,rc=new fi,t_=new at,Px=new at,pke=new at,gke=new pf,TH=new at(1,0,0),NH=new at(0,1,0),CH=new at(0,0,1),kH={type:"added"},xke={type:"removed"},_m={type:"childadded",child:null},VN={type:"childremoved",child:null};let Ds=class A1 extends Nf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:mke++}),this.uuid=ay(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=A1.DEFAULT_UP.clone();const e=new at,n=new Ed,r=new pf,i=new at(1,1,1);function a(){r.setFromEuler(n,!1)}function s(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new fi},normalMatrix:{value:new xn}}),this.matrix=new fi,this.matrixWorld=new fi,this.matrixAutoUpdate=A1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=A1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new jZ,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,n){this.quaternion.setFromAxisAngle(e,n)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,n){return vm.setFromAxisAngle(e,n),this.quaternion.multiply(vm),this}rotateOnWorldAxis(e,n){return vm.setFromAxisAngle(e,n),this.quaternion.premultiply(vm),this}rotateX(e){return this.rotateOnAxis(TH,e)}rotateY(e){return this.rotateOnAxis(NH,e)}rotateZ(e){return this.rotateOnAxis(CH,e)}translateOnAxis(e,n){return AH.copy(e).applyQuaternion(this.quaternion),this.position.add(AH.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(TH,e)}translateY(e){return this.translateOnAxis(NH,e)}translateZ(e){return this.translateOnAxis(CH,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(rc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?t_.copy(e):t_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Px.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?rc.lookAt(Px,t_,this.up):rc.lookAt(t_,Px,this.up),this.quaternion.setFromRotationMatrix(rc),i&&(rc.extractRotation(i.matrixWorld),vm.setFromRotationMatrix(rc),this.quaternion.premultiply(vm.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Qr("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(kH),_m.child=e,this.dispatchEvent(_m),_m.child=null):Qr("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(xke),VN.child=e,this.dispatchEvent(VN),VN.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),rc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),rc.multiply(e.parent.matrixWorld)),e.applyMatrix4(rc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(kH),_m.child=e,this.dispatchEvent(_m),_m.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const s=this.children[r].getObjectByProperty(e,n);if(s!==void 0)return s}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,s=i.length;a<s;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Px,e,pke),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Px,gke,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let a=0,s=i.length;a<s;a++)i[a].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(l=>({...l,boundingBox:l.boundingBox?l.boundingBox.toJSON():void 0,boundingSphere:l.boundingSphere?l.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(l=>({...l})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function a(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(a(e.animations,c))}}if(n){const l=s(e.geometries),c=s(e.materials),u=s(e.textures),d=s(e.images),f=s(e.shapes),g=s(e.skeletons),p=s(e.animations),x=s(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function s(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};Ds.DEFAULT_UP=new at(0,1,0);Ds.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ds.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const No=new at,ic=new at,GN=new at,ac=new at,wm=new at,Sm=new at,PH=new at,WN=new at,qN=new at,KN=new at,XN=new ci,YN=new ci,ZN=new ci;let jx=class Jm{constructor(e=new at,n=new at,r=new at){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),No.subVectors(e,n),i.cross(No);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){No.subVectors(i,n),ic.subVectors(r,n),GN.subVectors(e,n);const s=No.dot(No),l=No.dot(ic),c=No.dot(GN),u=ic.dot(ic),d=ic.dot(GN),f=s*u-l*l;if(f===0)return a.set(0,0,0),null;const g=1/f,p=(u*c-l*d)*g,x=(s*d-l*c)*g;return a.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,ac)===null?!1:ac.x>=0&&ac.y>=0&&ac.x+ac.y<=1}static getInterpolation(e,n,r,i,a,s,l,c){return this.getBarycoord(e,n,r,i,ac)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(a,ac.x),c.addScaledVector(s,ac.y),c.addScaledVector(l,ac.z),c)}static getInterpolatedAttribute(e,n,r,i,a,s){return XN.setScalar(0),YN.setScalar(0),ZN.setScalar(0),XN.fromBufferAttribute(e,n),YN.fromBufferAttribute(e,r),ZN.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(XN,a.x),s.addScaledVector(YN,a.y),s.addScaledVector(ZN,a.z),s}static isFrontFacing(e,n,r,i){return No.subVectors(r,n),ic.subVectors(e,n),No.cross(ic).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return No.subVectors(this.c,this.b),ic.subVectors(this.a,this.b),No.cross(ic).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Jm.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Jm.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return Jm.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Jm.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Jm.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let s,l;wm.subVectors(i,r),Sm.subVectors(a,r),WN.subVectors(e,r);const c=wm.dot(WN),u=Sm.dot(WN);if(c<=0&&u<=0)return n.copy(r);qN.subVectors(e,i);const d=wm.dot(qN),f=Sm.dot(qN);if(d>=0&&f<=d)return n.copy(i);const g=c*f-d*u;if(g<=0&&c>=0&&d<=0)return s=c/(c-d),n.copy(r).addScaledVector(wm,s);KN.subVectors(e,a);const p=wm.dot(KN),x=Sm.dot(KN);if(x>=0&&p<=x)return n.copy(a);const v=p*u-c*x;if(v<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Sm,l);const y=d*x-p*f;if(y<=0&&f-d>=0&&p-x>=0)return PH.subVectors(a,i),l=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(PH,l);const b=1/(y+v+g);return s=v*b,l=g*b,n.copy(r).addScaledVector(wm,s).addScaledVector(Sm,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const RZ={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ku={h:0,s:0,l:0},n_={h:0,s:0,l:0};function QN(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let Tn=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=Qs){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ln.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Ln.workingColorSpace){return this.r=e,this.g=n,this.b=r,Ln.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Ln.workingColorSpace){if(e=rke(e,1),n=wn(n,0,1),r=wn(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,s=2*r-a;this.r=QN(s,a,e+1/3),this.g=QN(s,a,e),this.b=QN(s,a,e-1/3)}return Ln.colorSpaceToWorking(this,i),this}setStyle(e,n=Qs){function r(a){a!==void 0&&parseFloat(a)<1&&en("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=i[1],l=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:en("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(s===6)return this.setHex(parseInt(a,16),n);en("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Qs){const r=RZ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):en("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Oc(e.r),this.g=Oc(e.g),this.b=Oc(e.b),this}copyLinearToSRGB(e){return this.r=xp(e.r),this.g=xp(e.g),this.b=xp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Qs){return Ln.workingToColorSpace(fa.copy(this),e),Math.round(wn(fa.r*255,0,255))*65536+Math.round(wn(fa.g*255,0,255))*256+Math.round(wn(fa.b*255,0,255))}getHexString(e=Qs){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Ln.workingColorSpace){Ln.workingToColorSpace(fa.copy(this),n);const r=fa.r,i=fa.g,a=fa.b,s=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+s)/2;if(l===s)c=0,u=0;else{const f=s-l;switch(u=d<=.5?f/(s+l):f/(2-s-l),s){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Ln.workingColorSpace){return Ln.workingToColorSpace(fa.copy(this),n),e.r=fa.r,e.g=fa.g,e.b=fa.b,e}getStyle(e=Qs){Ln.workingToColorSpace(fa.copy(this),e);const n=fa.r,r=fa.g,i=fa.b;return e!==Qs?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(ku),this.setHSL(ku.h+e,ku.s+n,ku.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,r){return this.r=e.r+(n.r-e.r)*r,this.g=e.g+(n.g-e.g)*r,this.b=e.b+(n.b-e.b)*r,this}lerpHSL(e,n){this.getHSL(ku),e.getHSL(n_);const r=DN(ku.h,n_.h,n),i=DN(ku.s,n_.s,n),a=DN(ku.l,n_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const fa=new Tn;Tn.NAMES=RZ;let bke=0,vg=class extends Nf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:bke++}),this.uuid=ay(),this.name="",this.type="Material",this.blending=gp,this.side=Md,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=oP,this.blendDst=lP,this.blendEquation=yh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Tn(0,0,0),this.blendAlpha=0,this.depthFunc=Fp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=gH,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=mm,this.stencilZFail=mm,this.stencilZPass=mm,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const r=e[n];if(r===void 0){en(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){en(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==gp&&(r.blending=this.blending),this.side!==Md&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==oP&&(r.blendSrc=this.blendSrc),this.blendDst!==lP&&(r.blendDst=this.blendDst),this.blendEquation!==yh&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==Fp&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==gH&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==mm&&(r.stencilFail=this.stencilFail),this.stencilZFail!==mm&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==mm&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const s=[];for(const l in a){const c=a[l];delete c.metadata,s.push(c)}return s}if(n){const a=i(e.textures),s=i(e.images);a.length>0&&(r.textures=a),s.length>0&&(r.images=s)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},DO=class extends vg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Tn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ed,this.combine=MO,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};const ai=new at,r_=new fn;let yke=0,uo=class{constructor(e,n,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:yke++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=xH,this.updateRanges=[],this.gpuType=Nc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)r_.fromBufferAttribute(this,n),r_.applyMatrix3(e),this.setXY(n,r_.x,r_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)ai.fromBufferAttribute(this,n),ai.applyMatrix3(e),this.setXYZ(n,ai.x,ai.y,ai.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)ai.fromBufferAttribute(this,n),ai.applyMatrix4(e),this.setXYZ(n,ai.x,ai.y,ai.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)ai.fromBufferAttribute(this,n),ai.applyNormalMatrix(e),this.setXYZ(n,ai.x,ai.y,ai.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)ai.fromBufferAttribute(this,n),ai.transformDirection(e),this.setXYZ(n,ai.x,ai.y,ai.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=Nx(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Ka(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Nx(n,this.array)),n}setX(e,n){return this.normalized&&(n=Ka(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Nx(n,this.array)),n}setY(e,n){return this.normalized&&(n=Ka(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=Nx(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Ka(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=Nx(n,this.array)),n}setW(e,n){return this.normalized&&(n=Ka(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Ka(n,this.array),r=Ka(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=Ka(n,this.array),r=Ka(r,this.array),i=Ka(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=Ka(n,this.array),r=Ka(r,this.array),i=Ka(i,this.array),a=Ka(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==xH&&(e.usage=this.usage),e}},DZ=class extends uo{constructor(e,n,r){super(new Uint16Array(e),n,r)}},OZ=class extends uo{constructor(e,n,r){super(new Uint32Array(e),n,r)}},$o=class extends uo{constructor(e,n,r){super(new Float32Array(e),n,r)}},vke=0;const Gs=new fi,JN=new Ds,Mm=new at,ys=new xf,Rx=new xf,Di=new at;let Ll=class LZ extends Nf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:vke++}),this.uuid=ay(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(EZ(e)?OZ:DZ)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new xn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Gs.makeRotationFromQuaternion(e),this.applyMatrix4(Gs),this}rotateX(e){return Gs.makeRotationX(e),this.applyMatrix4(Gs),this}rotateY(e){return Gs.makeRotationY(e),this.applyMatrix4(Gs),this}rotateZ(e){return Gs.makeRotationZ(e),this.applyMatrix4(Gs),this}translate(e,n,r){return Gs.makeTranslation(e,n,r),this.applyMatrix4(Gs),this}scale(e,n,r){return Gs.makeScale(e,n,r),this.applyMatrix4(Gs),this}lookAt(e){return JN.lookAt(e),JN.updateMatrix(),this.applyMatrix4(JN.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Mm).negate(),this.translate(Mm.x,Mm.y,Mm.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,a=e.length;i<a;i++){const s=e[i];r.push(s.x,s.y,s.z||0)}this.setAttribute("position",new $o(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const a=e[i];n.setXYZ(i,a.x,a.y,a.z||0)}e.length>n.count&&en("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new xf);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Qr("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new at(-1/0,-1/0,-1/0),new at(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];ys.setFromBufferAttribute(a),this.morphTargetsRelative?(Di.addVectors(this.boundingBox.min,ys.min),this.boundingBox.expandByPoint(Di),Di.addVectors(this.boundingBox.max,ys.max),this.boundingBox.expandByPoint(Di)):(this.boundingBox.expandByPoint(ys.min),this.boundingBox.expandByPoint(ys.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Qr('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new eE);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Qr("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new at,1/0);return}if(e){const r=this.boundingSphere.center;if(ys.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const l=n[a];Rx.setFromBufferAttribute(l),this.morphTargetsRelative?(Di.addVectors(ys.min,Rx.min),ys.expandByPoint(Di),Di.addVectors(ys.max,Rx.max),ys.expandByPoint(Di)):(ys.expandByPoint(Rx.min),ys.expandByPoint(Rx.max))}ys.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)Di.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Di));if(n)for(let a=0,s=n.length;a<s;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)Di.fromBufferAttribute(l,u),c&&(Mm.fromBufferAttribute(e,u),Di.add(Mm)),i=Math.max(i,r.distanceToSquared(Di))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Qr('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){Qr("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,a=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new uo(new Float32Array(4*r.count),4));const s=this.getAttribute("tangent"),l=[],c=[];for(let O=0;O<r.count;O++)l[O]=new at,c[O]=new at;const u=new at,d=new at,f=new at,g=new fn,p=new fn,x=new fn,v=new at,y=new at;function b(O,k,j){u.fromBufferAttribute(r,O),d.fromBufferAttribute(r,k),f.fromBufferAttribute(r,j),g.fromBufferAttribute(a,O),p.fromBufferAttribute(a,k),x.fromBufferAttribute(a,j),d.sub(u),f.sub(u),p.sub(g),x.sub(g);const B=1/(p.x*x.y-x.x*p.y);isFinite(B)&&(v.copy(d).multiplyScalar(x.y).addScaledVector(f,-p.y).multiplyScalar(B),y.copy(f).multiplyScalar(p.x).addScaledVector(d,-x.x).multiplyScalar(B),l[O].add(v),l[k].add(v),l[j].add(v),c[O].add(y),c[k].add(y),c[j].add(y))}let E=this.groups;E.length===0&&(E=[{start:0,count:e.count}]);for(let O=0,k=E.length;O<k;++O){const j=E[O],B=j.start,L=j.count;for(let K=B,R=B+L;K<R;K+=3)b(e.getX(K+0),e.getX(K+1),e.getX(K+2))}const w=new at,A=new at,T=new at,C=new at;function N(O){T.fromBufferAttribute(i,O),C.copy(T);const k=l[O];w.copy(k),w.sub(T.multiplyScalar(T.dot(k))).normalize(),A.crossVectors(C,k);const B=A.dot(c[O])<0?-1:1;s.setXYZW(O,w.x,w.y,w.z,B)}for(let O=0,k=E.length;O<k;++O){const j=E[O],B=j.start,L=j.count;for(let K=B,R=B+L;K<R;K+=3)N(e.getX(K+0)),N(e.getX(K+1)),N(e.getX(K+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new uo(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,p=r.count;g<p;g++)r.setXYZ(g,0,0,0);const i=new at,a=new at,s=new at,l=new at,c=new at,u=new at,d=new at,f=new at;if(e)for(let g=0,p=e.count;g<p;g+=3){const x=e.getX(g+0),v=e.getX(g+1),y=e.getX(g+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,v),s.fromBufferAttribute(n,y),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,y),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(y,u.x,u.y,u.z)}else for(let g=0,p=n.count;g<p;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),s.fromBufferAttribute(n,g+2),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),r.setXYZ(g+0,d.x,d.y,d.z),r.setXYZ(g+1,d.x,d.y,d.z),r.setXYZ(g+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Di.fromBufferAttribute(e,n),Di.normalize(),e.setXYZ(n,Di.x,Di.y,Di.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,g=new u.constructor(c.length*d);let p=0,x=0;for(let v=0,y=c.length;v<y;v++){l.isInterleavedBufferAttribute?p=c[v]*l.data.stride+l.offset:p=c[v]*d;for(let b=0;b<d;b++)g[x++]=u[p++]}return new uo(g,d,f)}if(this.index===null)return en("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new LZ,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const g=u[d],p=e(g,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let l=0,c=s.length;l<c;l++){const u=s[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,g=u.length;f<g;f++){const p=u[f];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere=l.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let g=0,p=f.length;g<p;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let u=0,d=s.length;u<d;u++){const f=s[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const jH=new fi,nh=new RO,i_=new eE,RH=new at,a_=new at,s_=new at,o_=new at,eC=new at,l_=new at,DH=new at,c_=new at;let Tl=class extends Ds{constructor(e=new Ll,n=new DO){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){l_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(eC.fromBufferAttribute(f,e),s?l_.addScaledVector(eC,d):l_.addScaledVector(eC.sub(n),d))}n.add(l_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),i_.copy(r.boundingSphere),i_.applyMatrix4(a),nh.copy(e.ray).recast(e.near),!(i_.containsPoint(nh.origin)===!1&&(nh.intersectSphere(i_,RH)===null||nh.origin.distanceToSquared(RH)>(e.far-e.near)**2))&&(jH.copy(a).invert(),nh.copy(e.ray).applyMatrix4(jH),!(r.boundingBox!==null&&nh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,nh)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,g=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],E=Math.max(y.start,p.start),w=Math.min(l.count,Math.min(y.start+y.count,p.start+p.count));for(let A=E,T=w;A<T;A+=3){const C=l.getX(A),N=l.getX(A+1),O=l.getX(A+2);i=u_(this,b,e,r,u,d,f,C,N,O),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let y=x,b=v;y<b;y+=3){const E=l.getX(y),w=l.getX(y+1),A=l.getX(y+2);i=u_(this,s,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],E=Math.max(y.start,p.start),w=Math.min(c.count,Math.min(y.start+y.count,p.start+p.count));for(let A=E,T=w;A<T;A+=3){const C=A,N=A+1,O=A+2;i=u_(this,b,e,r,u,d,f,C,N,O),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let y=x,b=v;y<b;y+=3){const E=y,w=y+1,A=y+2;i=u_(this,s,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}}};function _ke(t,e,n,r,i,a,s,l){let c;if(e.side===ts?c=r.intersectTriangle(s,a,i,!0,l):c=r.intersectTriangle(i,a,s,e.side===Md,l),c===null)return null;c_.copy(l),c_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(c_);return u<n.near||u>n.far?null:{distance:u,point:c_.clone(),object:t}}function u_(t,e,n,r,i,a,s,l,c,u){t.getVertexPosition(l,a_),t.getVertexPosition(c,s_),t.getVertexPosition(u,o_);const d=_ke(t,e,n,r,a_,s_,o_,DH);if(d){const f=new at;jx.getBarycoord(DH,a_,s_,o_,f),i&&(d.uv=jx.getInterpolatedAttribute(i,l,c,u,f,new fn)),a&&(d.uv1=jx.getInterpolatedAttribute(a,l,c,u,f,new fn)),s&&(d.normal=jx.getInterpolatedAttribute(s,l,c,u,f,new at),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const g={a:l,b:c,c:u,normal:new at,materialIndex:0};jx.getNormal(a_,s_,o_,g.normal),d.face=g,d.barycoord=f}return d}let OO=class IZ extends Ll{constructor(e=1,n=1,r=1,i=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:s};const l=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const c=[],u=[],d=[],f=[];let g=0,p=0;x("z","y","x",-1,-1,r,n,e,s,a,0),x("z","y","x",1,-1,r,n,-e,s,a,1),x("x","z","y",1,1,e,r,n,i,s,2),x("x","z","y",1,-1,e,r,-n,i,s,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new $o(u,3)),this.setAttribute("normal",new $o(d,3)),this.setAttribute("uv",new $o(f,2));function x(v,y,b,E,w,A,T,C,N,O,k){const j=A/N,B=T/O,L=A/2,K=T/2,R=C/2,q=N+1,W=O+1;let $=0,J=0;const ee=new at;for(let Q=0;Q<W;Q++){const z=Q*B-K;for(let V=0;V<q;V++){const X=V*j-L;ee[v]=X*E,ee[y]=z*w,ee[b]=R,u.push(ee.x,ee.y,ee.z),ee[v]=0,ee[y]=0,ee[b]=C>0?1:-1,d.push(ee.x,ee.y,ee.z),f.push(V/N),f.push(1-Q/O),$+=1}}for(let Q=0;Q<O;Q++)for(let z=0;z<N;z++){const V=g+z+q*Q,X=g+z+q*(Q+1),te=g+(z+1)+q*(Q+1),ie=g+(z+1)+q*Q;c.push(V,X,ie),c.push(X,te,ie),J+=6}l.addGroup(p,J,k),p+=J,g+=$}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new IZ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Hp(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(en("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function Ta(t){const e={};for(let n=0;n<t.length;n++){const r=Hp(t[n]);for(const i in r)e[i]=r[i]}return e}function wke(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function FZ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ln.workingColorSpace}const Ske={clone:Hp,merge:Ta};var Mke=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,Eke=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let Xc=class extends vg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Mke,this.fragmentShader=Eke,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Hp(e.uniforms),this.uniformsGroups=wke(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const s=this.uniforms[i].value;s&&s.isTexture?n.uniforms[i]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?n.uniforms[i]={type:"c",value:s.getHex()}:s&&s.isVector2?n.uniforms[i]={type:"v2",value:s.toArray()}:s&&s.isVector3?n.uniforms[i]={type:"v3",value:s.toArray()}:s&&s.isVector4?n.uniforms[i]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?n.uniforms[i]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?n.uniforms[i]={type:"m4",value:s.toArray()}:n.uniforms[i]={value:s}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}},UZ=class extends Ds{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new fi,this.projectionMatrix=new fi,this.projectionMatrixInverse=new fi,this.coordinateSystem=pl,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const Pu=new at,OH=new fn,LH=new fn;let to=class extends UZ{constructor(e=50,n=1,r=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=i,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const n=.5*this.getFilmHeight()/e;this.fov=KP*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(M1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return KP*2*Math.atan(Math.tan(M1*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,n,r){Pu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Pu.x,Pu.y).multiplyScalar(-e/Pu.z),Pu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Pu.x,Pu.y).multiplyScalar(-e/Pu.z)}getViewSize(e,n){return this.getViewBounds(e,OH,LH),n.subVectors(LH,OH)}setViewOffset(e,n,r,i,a,s){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(M1*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const s=this.view;if(this.view!==null&&this.view.enabled){const c=s.fullWidth,u=s.fullHeight;a+=s.offsetX*i/c,n-=s.offsetY*r/u,i*=s.width/c,r*=s.height/u}const l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}};const Em=-90,Am=1;let Ake=class extends Ds{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new to(Em,Am,e,n);i.layers=this.layers,this.add(i);const a=new to(Em,Am,e,n);a.layers=this.layers,this.add(a);const s=new to(Em,Am,e,n);s.layers=this.layers,this.add(s);const l=new to(Em,Am,e,n);l.layers=this.layers,this.add(l);const c=new to(Em,Am,e,n);c.layers=this.layers,this.add(c);const u=new to(Em,Am,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,s,l,c]=n;for(const u of n)this.remove(u);if(e===pl)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Vw)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,l,c,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,s),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},zZ=class extends Yo{constructor(e=[],n=Up,r,i,a,s,l,c,u,d){super(e,n,r,i,a,s,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Tke=class extends gf{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];this.texture=new zZ(i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new OO(5,5,5),a=new Xc({name:"CubemapFromEquirect",uniforms:Hp(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ts,blending:Dc});a.uniforms.tEquirect.value=n;const s=new Tl(i,a),l=n.minFilter;return n.minFilter===Ch&&(n.minFilter=oo),new Ake(1,10,this).update(e,s),n.minFilter=l,s.geometry.dispose(),s.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(n,r,i);e.setRenderTarget(a)}},Xx=class extends Ds{constructor(){super(),this.isGroup=!0,this.type="Group"}};const Nke={type:"move"};let tC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Xx,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Xx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new at,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new at),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Xx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new at,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new at),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,s=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){s=!0;for(const v of e.hand.values()){const y=n.getJointPose(v,r),b=this._getHandJoint(u,v);y!==null&&(b.matrix.fromArray(y.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=y.radius),b.visible=y!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&g>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(Nke)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Xx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},Cke=class extends Ds{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ed,this.environmentIntensity=1,this.environmentRotation=new Ed,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const n=super.toJSON(e);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(n.object.environmentIntensity=this.environmentIntensity),n.object.environmentRotation=this.environmentRotation.toArray(),n}},kke=class extends Yo{constructor(e=null,n=1,r=1,i,a,s,l,c,u=ks,d=ks,f,g){super(null,s,l,c,u,d,i,a,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const nC=new at,Pke=new at,jke=new xn;let $u=class{constructor(e=new at(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=nC.subVectors(r,n).cross(Pke.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n){const r=e.delta(nC),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||jke.getNormalMatrix(e),i=this.coplanarPoint(nC).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const rh=new eE,Rke=new fn(.5,.5),d_=new at;let LO=class{constructor(e=new $u,n=new $u,r=new $u,i=new $u,a=new $u,s=new $u){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(a),l[5].copy(s),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=pl,r=!1){const i=this.planes,a=e.elements,s=a[0],l=a[1],c=a[2],u=a[3],d=a[4],f=a[5],g=a[6],p=a[7],x=a[8],v=a[9],y=a[10],b=a[11],E=a[12],w=a[13],A=a[14],T=a[15];if(i[0].setComponents(u-s,p-d,b-x,T-E).normalize(),i[1].setComponents(u+s,p+d,b+x,T+E).normalize(),i[2].setComponents(u+l,p+f,b+v,T+w).normalize(),i[3].setComponents(u-l,p-f,b-v,T-w).normalize(),r)i[4].setComponents(c,g,y,A).normalize(),i[5].setComponents(u-c,p-g,b-y,T-A).normalize();else if(i[4].setComponents(u-c,p-g,b-y,T-A).normalize(),n===pl)i[5].setComponents(u+c,p+g,b+y,T+A).normalize();else if(n===Vw)i[5].setComponents(c,g,y,A).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),rh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),rh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(rh)}intersectsSprite(e){rh.center.set(0,0,0);const n=Rke.distanceTo(e.center);return rh.radius=.7071067811865476+n,rh.applyMatrix4(e.matrixWorld),this.intersectsSphere(rh)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(d_.x=i.normal.x>0?e.max.x:e.min.x,d_.y=i.normal.y>0?e.max.y:e.min.y,d_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(d_)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},BZ=class extends vg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Tn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}};const Ww=new at,qw=new at,IH=new fi,Dx=new RO,h_=new eE,rC=new at,FH=new at;let Dke=class extends Ds{constructor(e=new Ll,n=new BZ){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)Ww.fromBufferAttribute(n,i-1),qw.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=Ww.distanceTo(qw);e.setAttribute("lineDistance",new $o(r,1))}else en("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,s=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),h_.copy(r.boundingSphere),h_.applyMatrix4(i),h_.radius+=a,e.ray.intersectsSphere(h_)===!1)return;IH.copy(i).invert(),Dx.copy(e.ray).applyMatrix4(IH);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,g=r.attributes.position;if(d!==null){const p=Math.max(0,s.start),x=Math.min(d.count,s.start+s.count);for(let v=p,y=x-1;v<y;v+=u){const b=d.getX(v),E=d.getX(v+1),w=f_(this,e,Dx,c,b,E,v);w&&n.push(w)}if(this.isLineLoop){const v=d.getX(x-1),y=d.getX(p),b=f_(this,e,Dx,c,v,y,x-1);b&&n.push(b)}}else{const p=Math.max(0,s.start),x=Math.min(g.count,s.start+s.count);for(let v=p,y=x-1;v<y;v+=u){const b=f_(this,e,Dx,c,v,v+1,v);b&&n.push(b)}if(this.isLineLoop){const v=f_(this,e,Dx,c,x-1,p,x-1);v&&n.push(v)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}};function f_(t,e,n,r,i,a,s){const l=t.geometry.attributes.position;if(Ww.fromBufferAttribute(l,i),qw.fromBufferAttribute(l,a),n.distanceSqToSegment(Ww,qw,rC,FH)>r)return;rC.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(rC);if(!(u<e.near||u>e.far))return{distance:u,point:FH.clone().applyMatrix4(t.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:t}}const UH=new at,zH=new at;let Oke=class extends Dke{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)UH.fromBufferAttribute(n,i),zH.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+UH.distanceTo(zH);e.setAttribute("lineDistance",new $o(r,1))}else en("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},HZ=class extends Yo{constructor(e,n,r=mf,i,a,s,l=ks,c=ks,u,d=tb,f=1){if(d!==tb&&d!==nb)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const g={width:e,height:n,depth:f};super(g,i,a,s,l,c,d,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new jO(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}};class $Z extends Yo{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let IO=class VZ extends Ll{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,s=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,g=n/c,p=[],x=[],v=[],y=[];for(let b=0;b<d;b++){const E=b*g-s;for(let w=0;w<u;w++){const A=w*f-a;x.push(A,-E,0),v.push(0,0,1),y.push(w/l),y.push(1-b/c)}}for(let b=0;b<c;b++)for(let E=0;E<l;E++){const w=E+u*b,A=E+u*(b+1),T=E+1+u*(b+1),C=E+1+u*b;p.push(w,A,C),p.push(A,T,C)}this.setIndex(p),this.setAttribute("position",new $o(x,3)),this.setAttribute("normal",new $o(v,3)),this.setAttribute("uv",new $o(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new VZ(e.width,e.height,e.widthSegments,e.heightSegments)}};class Lke extends vg{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Tn(16777215),this.specular=new Tn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Tn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=SZ,this.normalScale=new fn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ed,this.combine=MO,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}let Ike=class extends vg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=GCe,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Fke=class extends vg{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},GZ=class extends Ds{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Tn(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(n.object.target=this.target.uuid),n}};const iC=new fi,BH=new at,HH=new at;let Uke=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new fn(512,512),this.mapType=Al,this.map=null,this.mapPass=null,this.matrix=new fi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new LO,this._frameExtents=new fn(1,1),this._viewportCount=1,this._viewports=[new ci(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;BH.setFromMatrixPosition(e.matrixWorld),n.position.copy(BH),HH.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(HH),n.updateMatrixWorld(),iC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(iC,n.coordinateSystem,n.reversedDepth),n.reversedDepth?r.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(iC)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},WZ=class extends UZ{constructor(e=-1,n=1,r=1,i=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,s=r+e,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=u*this.view.offsetX,s=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,l,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}};class zke extends Uke{constructor(){super(new WZ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class $H extends GZ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ds.DEFAULT_UP),this.updateMatrix(),this.target=new Ds,this.shadow=new zke}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let Bke=class extends GZ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},Hke=class extends to{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},VH=class{constructor(e=1,n=0,r=0){this.radius=e,this.phi=n,this.theta=r}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=wn(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(wn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class $ke extends Oke{constructor(e=10,n=10,r=4473924,i=8947848){r=new Tn(r),i=new Tn(i);const a=n/2,s=e/n,l=e/2,c=[],u=[];for(let g=0,p=0,x=-l;g<=n;g++,x+=s){c.push(-l,0,x,l,0,x),c.push(x,0,-l,x,0,l);const v=g===a?r:i;v.toArray(u,p),p+=3,v.toArray(u,p),p+=3,v.toArray(u,p),p+=3,v.toArray(u,p),p+=3}const d=new Ll;d.setAttribute("position",new $o(c,3)),d.setAttribute("color",new $o(u,3));const f=new BZ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Vke extends Nf{constructor(e,n=null){super(),this.object=e,this.domElement=n,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){en("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function GH(t,e,n,r){const i=Gke(r);switch(n){case vZ:return t*e;case wZ:return t*e/i.components*i.byteLength;case NO:return t*e/i.components*i.byteLength;case CO:return t*e*2/i.components*i.byteLength;case kO:return t*e*2/i.components*i.byteLength;case _Z:return t*e*3/i.components*i.byteLength;case Fo:return t*e*4/i.components*i.byteLength;case PO:return t*e*4/i.components*i.byteLength;case v1:case _1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case w1:case S1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case _P:case SP:return Math.max(t,16)*Math.max(e,8)/4;case vP:case wP:return Math.max(t,8)*Math.max(e,8)/2;case MP:case EP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case AP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case TP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case NP:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case CP:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case kP:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case PP:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case jP:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case RP:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case DP:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case OP:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case LP:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case IP:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case FP:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case UP:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case zP:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case BP:case HP:case $P:return Math.ceil(t/4)*Math.ceil(e/4)*16;case VP:case GP:return Math.ceil(t/4)*Math.ceil(e/4)*8;case WP:case qP:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function Gke(t){switch(t){case Al:case gZ:return{byteLength:1,components:1};case J0:case xZ:case yg:return{byteLength:2,components:1};case AO:case TO:return{byteLength:2,components:4};case mf:case EO:case Nc:return{byteLength:4,components:1};case bZ:case yZ:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:SO}}));typeof window<"u"&&(window.__THREE__?en("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=SO);function qZ(){let t=null,e=!1,n=null,r=null;function i(a,s){n(a,s),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function Wke(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,f=u.byteLength,g=t.createBuffer();t.bindBuffer(c,g),t.bufferData(c,u,d),l.onUploadCallback();let p;if(u instanceof Float32Array)p=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)p=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?p=t.HALF_FLOAT:p=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)p=t.SHORT;else if(u instanceof Uint32Array)p=t.UNSIGNED_INT;else if(u instanceof Int32Array)p=t.INT;else if(u instanceof Int8Array)p=t.BYTE;else if(u instanceof Uint8Array)p=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)p=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:g,type:p,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version,size:f}}function r(l,c,u){const d=c.array,f=c.updateRanges;if(t.bindBuffer(u,l),f.length===0)t.bufferSubData(u,0,d);else{f.sort((p,x)=>p.start-x.start);let g=0;for(let p=1;p<f.length;p++){const x=f[g],v=f[p];v.start<=x.start+x.count+1?x.count=Math.max(x.count,v.start+v.count-x.start):(++g,f[g]=v)}f.length=g+1;for(let p=0,x=f.length;p<x;p++){const v=f[p];t.bufferSubData(u,v.start*d.BYTES_PER_ELEMENT,d,v.start,v.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function a(l){l.isInterleavedBufferAttribute&&(l=l.data);const c=e.get(l);c&&(t.deleteBuffer(c.buffer),e.delete(l))}function s(l,c){if(l.isInterleavedBufferAttribute&&(l=l.data),l.isGLBufferAttribute){const d=e.get(l);(!d||d.version<l.version)&&e.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}const u=e.get(l);if(u===void 0)e.set(l,n(l,c));else if(u.version<l.version){if(u.size!==l.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(u.buffer,l,c),u.version=l.version}}return{get:i,remove:a,update:s}}var qke=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,Kke=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,Xke=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,Yke=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Zke=`#ifdef USE_ALPHATEST
- #ifdef ALPHA_TO_COVERAGE
- diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- if ( diffuseColor.a < alphaTest ) discard;
- #endif
- #endif`,Qke=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,Jke=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,e3e=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,t3e=`#ifdef USE_BATCHING
- #if ! defined( GL_ANGLE_multi_draw )
- #define gl_DrawID _gl_DrawID
- uniform int _gl_DrawID;
- #endif
- uniform highp sampler2D batchingTexture;
- uniform highp usampler2D batchingIdTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- float getIndirectIndex( const in int i ) {
- int size = textureSize( batchingIdTexture, 0 ).x;
- int x = i % size;
- int y = i / size;
- return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
- }
- #endif
- #ifdef USE_BATCHING_COLOR
- uniform sampler2D batchingColorTexture;
- vec3 getBatchingColor( const in float i ) {
- int size = textureSize( batchingColorTexture, 0 ).x;
- int j = int( i );
- int x = j % size;
- int y = j / size;
- return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
- }
- #endif`,n3e=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,r3e=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,i3e=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,a3e=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,s3e=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,o3e=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,l3e=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #ifdef ALPHA_TO_COVERAGE
- float distanceToPlane, distanceGradient;
- float clipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- if ( clipOpacity == 0.0 ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- float unionClipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- }
- #pragma unroll_loop_end
- clipOpacity *= 1.0 - unionClipOpacity;
- #endif
- diffuseColor.a *= clipOpacity;
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif
- #endif`,c3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,u3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,d3e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,h3e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,f3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,m3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,p3e=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif
- #ifdef USE_BATCHING_COLOR
- vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
- vColor.xyz *= batchingColor.xyz;
- #endif`,g3e=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,x3e=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,b3e=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,y3e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,v3e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,_3e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,w3e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,S3e="gl_FragColor = linearToOutputTexel( gl_FragColor );",M3e=`vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferEOTF( in vec4 value ) {
- return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }`,E3e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,A3e=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- uniform mat3 envMapRotation;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
- #endif`,T3e=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,N3e=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,C3e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,k3e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,P3e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,j3e=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,R3e=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,D3e=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,O3e=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,L3e=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,I3e=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,F3e=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,U3e=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,z3e=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,B3e=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,H3e=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,$3e=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,V3e=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_DISPERSION
- material.dispersion = dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,G3e=`uniform sampler2D dfgLUT;
- struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- float dispersion;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 uv = vec2( roughness, dotNV );
- return texture2D( dfgLUT, uv ).rg;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
- vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
- vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
- vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
- float Ess_V = dfgV.x + dfgV.y;
- float Ess_L = dfgL.x + dfgL.y;
- float Ems_V = 1.0 - Ess_V;
- float Ems_L = 1.0 - Ess_L;
- vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
- vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
- float compensationFactor = Ems_V * Ems_L;
- vec3 multiScatter = Fms * compensationFactor;
- return singleScatter + multiScatter;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,W3e=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,q3e=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,K3e=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,X3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,Y3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,Z3e=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,Q3e=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,J3e=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,ePe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,tPe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,nPe=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,rPe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,iPe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,aPe=`#ifdef USE_INSTANCING_MORPH
- float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
- }
- #endif`,sPe=`#if defined( USE_MORPHCOLORS )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,oPe=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,lPe=`#ifdef USE_MORPHTARGETS
- #ifndef USE_INSTANCING_MORPH
- uniform float morphTargetBaseInfluence;
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- #endif
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #endif`,cPe=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,uPe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,dPe=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,hPe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,fPe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,mPe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,pPe=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,gPe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,xPe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,bPe=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,yPe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,vPe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,_Pe=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
- const float Inv255 = 1. / 255.;
- const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
- const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
- const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
- const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
- vec4 packDepthToRGBA( const in float v ) {
- if( v <= 0.0 )
- return vec4( 0., 0., 0., 0. );
- if( v >= 1.0 )
- return vec4( 1., 1., 1., 1. );
- float vuf;
- float af = modf( v * PackFactors.a, vuf );
- float bf = modf( vuf * ShiftRight8, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
- }
- vec3 packDepthToRGB( const in float v ) {
- if( v <= 0.0 )
- return vec3( 0., 0., 0. );
- if( v >= 1.0 )
- return vec3( 1., 1., 1. );
- float vuf;
- float bf = modf( v * PackFactors.b, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec3( vuf * Inv255, gf * PackUpscale, bf );
- }
- vec2 packDepthToRG( const in float v ) {
- if( v <= 0.0 )
- return vec2( 0., 0. );
- if( v >= 1.0 )
- return vec2( 1., 1. );
- float vuf;
- float gf = modf( v * 256., vuf );
- return vec2( vuf * Inv255, gf );
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors4 );
- }
- float unpackRGBToDepth( const in vec3 v ) {
- return dot( v, UnpackFactors3 );
- }
- float unpackRGToDepth( const in vec2 v ) {
- return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
- }
- vec4 pack2HalfToRGBA( const in vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( const in vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,wPe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,SPe=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,MPe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,EPe=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,APe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,TPe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,NPe=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- return step( depth, compare );
- #else
- return step( compare, depth );
- #endif
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float hard_shadow = step( distribution.x, compare );
- #else
- float hard_shadow = step( compare, distribution.x );
- #endif
- if ( hard_shadow != 1.0 ) {
- float distance = compare - distribution.x;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- float shadow = 1.0;
- vec3 lightToPosition = shadowCoord.xyz;
-
- float lightToPositionLength = length( lightToPosition );
- if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
- float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- shadow = (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- #endif`,CPe=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,kPe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,PPe=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,jPe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,RPe=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,DPe=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,OPe=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,LPe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,IPe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,FPe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,UPe=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 CineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
- vec3( 1.6605, - 0.1246, - 0.0182 ),
- vec3( - 0.5876, 1.1329, - 0.1006 ),
- vec3( - 0.0728, - 0.0083, 1.1187 )
- );
- const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
- vec3( 0.6274, 0.0691, 0.0164 ),
- vec3( 0.3293, 0.9195, 0.0880 ),
- vec3( 0.0433, 0.0113, 0.8956 )
- );
- vec3 agxDefaultContrastApprox( vec3 x ) {
- vec3 x2 = x * x;
- vec3 x4 = x2 * x2;
- return + 15.5 * x4 * x2
- - 40.14 * x4 * x
- + 31.96 * x4
- - 6.868 * x2 * x
- + 0.4298 * x2
- + 0.1191 * x
- - 0.00232;
- }
- vec3 AgXToneMapping( vec3 color ) {
- const mat3 AgXInsetMatrix = mat3(
- vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
- vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
- vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
- );
- const mat3 AgXOutsetMatrix = mat3(
- vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
- vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
- vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
- );
- const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
- color *= toneMappingExposure;
- color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
- color = AgXInsetMatrix * color;
- color = max( color, 1e-10 ); color = log2( color );
- color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
- color = clamp( color, 0.0, 1.0 );
- color = agxDefaultContrastApprox( color );
- color = AgXOutsetMatrix * color;
- color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
- color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
- color = clamp( color, 0.0, 1.0 );
- return color;
- }
- vec3 NeutralToneMapping( vec3 color ) {
- const float StartCompression = 0.8 - 0.04;
- const float Desaturation = 0.15;
- color *= toneMappingExposure;
- float x = min( color.r, min( color.g, color.b ) );
- float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
- color -= offset;
- float peak = max( color.r, max( color.g, color.b ) );
- if ( peak < StartCompression ) return color;
- float d = 1. - StartCompression;
- float newPeak = 1. - d * d / ( peak + d - StartCompression );
- color *= newPeak / peak;
- float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
- return mix( color, vec3( newPeak ), g );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,zPe=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,BPe=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec4 transmittedLight;
- vec3 transmittance;
- #ifdef USE_DISPERSION
- float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
- vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
- for ( int i = 0; i < 3; i ++ ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
- transmittedLight[ i ] = transmissionSample[ i ];
- transmittedLight.a += transmissionSample.a;
- transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
- }
- transmittedLight.a /= 3.0;
- #else
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- #endif
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,HPe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,$Pe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,VPe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,GPe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const WPe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,qPe=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,KPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,XPe=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- uniform mat3 backgroundRotation;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,YPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,ZPe=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,QPe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,JPe=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
- #else
- float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
- #endif
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #elif DEPTH_PACKING == 3202
- gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
- #elif DEPTH_PACKING == 3203
- gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
- #endif
- }`,eje=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,tje=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,nje=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,rje=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,ije=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,aje=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,sje=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,oje=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,lje=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,cje=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,uje=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,dje=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,hje=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,fje=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,mje=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,pje=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,gje=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,xje=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_DISPERSION
- uniform float dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,bje=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,yje=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,vje=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,_je=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,wje=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,Sje=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,Mje=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix[ 3 ];
- vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,Eje=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,dn={alphahash_fragment:qke,alphahash_pars_fragment:Kke,alphamap_fragment:Xke,alphamap_pars_fragment:Yke,alphatest_fragment:Zke,alphatest_pars_fragment:Qke,aomap_fragment:Jke,aomap_pars_fragment:e3e,batching_pars_vertex:t3e,batching_vertex:n3e,begin_vertex:r3e,beginnormal_vertex:i3e,bsdfs:a3e,iridescence_fragment:s3e,bumpmap_pars_fragment:o3e,clipping_planes_fragment:l3e,clipping_planes_pars_fragment:c3e,clipping_planes_pars_vertex:u3e,clipping_planes_vertex:d3e,color_fragment:h3e,color_pars_fragment:f3e,color_pars_vertex:m3e,color_vertex:p3e,common:g3e,cube_uv_reflection_fragment:x3e,defaultnormal_vertex:b3e,displacementmap_pars_vertex:y3e,displacementmap_vertex:v3e,emissivemap_fragment:_3e,emissivemap_pars_fragment:w3e,colorspace_fragment:S3e,colorspace_pars_fragment:M3e,envmap_fragment:E3e,envmap_common_pars_fragment:A3e,envmap_pars_fragment:T3e,envmap_pars_vertex:N3e,envmap_physical_pars_fragment:U3e,envmap_vertex:C3e,fog_vertex:k3e,fog_pars_vertex:P3e,fog_fragment:j3e,fog_pars_fragment:R3e,gradientmap_pars_fragment:D3e,lightmap_pars_fragment:O3e,lights_lambert_fragment:L3e,lights_lambert_pars_fragment:I3e,lights_pars_begin:F3e,lights_toon_fragment:z3e,lights_toon_pars_fragment:B3e,lights_phong_fragment:H3e,lights_phong_pars_fragment:$3e,lights_physical_fragment:V3e,lights_physical_pars_fragment:G3e,lights_fragment_begin:W3e,lights_fragment_maps:q3e,lights_fragment_end:K3e,logdepthbuf_fragment:X3e,logdepthbuf_pars_fragment:Y3e,logdepthbuf_pars_vertex:Z3e,logdepthbuf_vertex:Q3e,map_fragment:J3e,map_pars_fragment:ePe,map_particle_fragment:tPe,map_particle_pars_fragment:nPe,metalnessmap_fragment:rPe,metalnessmap_pars_fragment:iPe,morphinstance_vertex:aPe,morphcolor_vertex:sPe,morphnormal_vertex:oPe,morphtarget_pars_vertex:lPe,morphtarget_vertex:cPe,normal_fragment_begin:uPe,normal_fragment_maps:dPe,normal_pars_fragment:hPe,normal_pars_vertex:fPe,normal_vertex:mPe,normalmap_pars_fragment:pPe,clearcoat_normal_fragment_begin:gPe,clearcoat_normal_fragment_maps:xPe,clearcoat_pars_fragment:bPe,iridescence_pars_fragment:yPe,opaque_fragment:vPe,packing:_Pe,premultiplied_alpha_fragment:wPe,project_vertex:SPe,dithering_fragment:MPe,dithering_pars_fragment:EPe,roughnessmap_fragment:APe,roughnessmap_pars_fragment:TPe,shadowmap_pars_fragment:NPe,shadowmap_pars_vertex:CPe,shadowmap_vertex:kPe,shadowmask_pars_fragment:PPe,skinbase_vertex:jPe,skinning_pars_vertex:RPe,skinning_vertex:DPe,skinnormal_vertex:OPe,specularmap_fragment:LPe,specularmap_pars_fragment:IPe,tonemapping_fragment:FPe,tonemapping_pars_fragment:UPe,transmission_fragment:zPe,transmission_pars_fragment:BPe,uv_pars_fragment:HPe,uv_pars_vertex:$Pe,uv_vertex:VPe,worldpos_vertex:GPe,background_vert:WPe,background_frag:qPe,backgroundCube_vert:KPe,backgroundCube_frag:XPe,cube_vert:YPe,cube_frag:ZPe,depth_vert:QPe,depth_frag:JPe,distanceRGBA_vert:eje,distanceRGBA_frag:tje,equirect_vert:nje,equirect_frag:rje,linedashed_vert:ije,linedashed_frag:aje,meshbasic_vert:sje,meshbasic_frag:oje,meshlambert_vert:lje,meshlambert_frag:cje,meshmatcap_vert:uje,meshmatcap_frag:dje,meshnormal_vert:hje,meshnormal_frag:fje,meshphong_vert:mje,meshphong_frag:pje,meshphysical_vert:gje,meshphysical_frag:xje,meshtoon_vert:bje,meshtoon_frag:yje,points_vert:vje,points_frag:_je,shadow_vert:wje,shadow_frag:Sje,sprite_vert:Mje,sprite_frag:Eje},kt={common:{diffuse:{value:new Tn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new xn},alphaMap:{value:null},alphaMapTransform:{value:new xn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new xn}},envmap:{envMap:{value:null},envMapRotation:{value:new xn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new xn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new xn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new xn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new xn},normalScale:{value:new fn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new xn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new xn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new xn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new xn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Tn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Tn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new xn},alphaTest:{value:0},uvTransform:{value:new xn}},sprite:{diffuse:{value:new Tn(16777215)},opacity:{value:1},center:{value:new fn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new xn},alphaMap:{value:null},alphaMapTransform:{value:new xn},alphaTest:{value:0}}},ul={basic:{uniforms:Ta([kt.common,kt.specularmap,kt.envmap,kt.aomap,kt.lightmap,kt.fog]),vertexShader:dn.meshbasic_vert,fragmentShader:dn.meshbasic_frag},lambert:{uniforms:Ta([kt.common,kt.specularmap,kt.envmap,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.fog,kt.lights,{emissive:{value:new Tn(0)}}]),vertexShader:dn.meshlambert_vert,fragmentShader:dn.meshlambert_frag},phong:{uniforms:Ta([kt.common,kt.specularmap,kt.envmap,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.fog,kt.lights,{emissive:{value:new Tn(0)},specular:{value:new Tn(1118481)},shininess:{value:30}}]),vertexShader:dn.meshphong_vert,fragmentShader:dn.meshphong_frag},standard:{uniforms:Ta([kt.common,kt.envmap,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.roughnessmap,kt.metalnessmap,kt.fog,kt.lights,{emissive:{value:new Tn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:dn.meshphysical_vert,fragmentShader:dn.meshphysical_frag},toon:{uniforms:Ta([kt.common,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.gradientmap,kt.fog,kt.lights,{emissive:{value:new Tn(0)}}]),vertexShader:dn.meshtoon_vert,fragmentShader:dn.meshtoon_frag},matcap:{uniforms:Ta([kt.common,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.fog,{matcap:{value:null}}]),vertexShader:dn.meshmatcap_vert,fragmentShader:dn.meshmatcap_frag},points:{uniforms:Ta([kt.points,kt.fog]),vertexShader:dn.points_vert,fragmentShader:dn.points_frag},dashed:{uniforms:Ta([kt.common,kt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:dn.linedashed_vert,fragmentShader:dn.linedashed_frag},depth:{uniforms:Ta([kt.common,kt.displacementmap]),vertexShader:dn.depth_vert,fragmentShader:dn.depth_frag},normal:{uniforms:Ta([kt.common,kt.bumpmap,kt.normalmap,kt.displacementmap,{opacity:{value:1}}]),vertexShader:dn.meshnormal_vert,fragmentShader:dn.meshnormal_frag},sprite:{uniforms:Ta([kt.sprite,kt.fog]),vertexShader:dn.sprite_vert,fragmentShader:dn.sprite_frag},background:{uniforms:{uvTransform:{value:new xn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:dn.background_vert,fragmentShader:dn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new xn}},vertexShader:dn.backgroundCube_vert,fragmentShader:dn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:dn.cube_vert,fragmentShader:dn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:dn.equirect_vert,fragmentShader:dn.equirect_frag},distanceRGBA:{uniforms:Ta([kt.common,kt.displacementmap,{referencePosition:{value:new at},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:dn.distanceRGBA_vert,fragmentShader:dn.distanceRGBA_frag},shadow:{uniforms:Ta([kt.lights,kt.fog,{color:{value:new Tn(0)},opacity:{value:1}}]),vertexShader:dn.shadow_vert,fragmentShader:dn.shadow_frag}};ul.physical={uniforms:Ta([ul.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new xn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new xn},clearcoatNormalScale:{value:new fn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new xn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new xn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new xn},sheen:{value:0},sheenColor:{value:new Tn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new xn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new xn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new xn},transmissionSamplerSize:{value:new fn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new xn},attenuationDistance:{value:0},attenuationColor:{value:new Tn(0)},specularColor:{value:new Tn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new xn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new xn},anisotropyVector:{value:new fn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new xn}}]),vertexShader:dn.meshphysical_vert,fragmentShader:dn.meshphysical_frag};const m_={r:0,b:0,g:0},ih=new Ed,Aje=new fi;function Tje(t,e,n,r,i,a,s){const l=new Tn(0);let c=a===!0?0:1,u,d,f=null,g=0,p=null;function x(w){let A=w.isScene===!0?w.background:null;return A&&A.isTexture&&(A=(w.backgroundBlurriness>0?n:e).get(A)),A}function v(w){let A=!1;const T=x(w);T===null?b(l,c):T&&T.isColor&&(b(T,1),A=!0);const C=t.xr.getEnvironmentBlendMode();C==="additive"?r.buffers.color.setClear(0,0,0,1,s):C==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,s),(t.autoClear||A)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function y(w,A){const T=x(A);T&&(T.isCubeTexture||T.mapping===JM)?(d===void 0&&(d=new Tl(new OO(1,1,1),new Xc({name:"BackgroundCubeMaterial",uniforms:Hp(ul.backgroundCube.uniforms),vertexShader:ul.backgroundCube.vertexShader,fragmentShader:ul.backgroundCube.fragmentShader,side:ts,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(C,N,O){this.matrixWorld.copyPosition(O.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),ih.copy(A.backgroundRotation),ih.x*=-1,ih.y*=-1,ih.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(ih.y*=-1,ih.z*=-1),d.material.uniforms.envMap.value=T,d.material.uniforms.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(Aje.makeRotationFromEuler(ih)),d.material.toneMapped=Ln.getTransfer(T.colorSpace)!==ar,(f!==T||g!==T.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=T,g=T.version,p=t.toneMapping),d.layers.enableAll(),w.unshift(d,d.geometry,d.material,0,0,null)):T&&T.isTexture&&(u===void 0&&(u=new Tl(new IO(2,2),new Xc({name:"BackgroundMaterial",uniforms:Hp(ul.background.uniforms),vertexShader:ul.background.vertexShader,fragmentShader:ul.background.fragmentShader,side:Md,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=T,u.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,u.material.toneMapped=Ln.getTransfer(T.colorSpace)!==ar,T.matrixAutoUpdate===!0&&T.updateMatrix(),u.material.uniforms.uvTransform.value.copy(T.matrix),(f!==T||g!==T.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=T,g=T.version,p=t.toneMapping),u.layers.enableAll(),w.unshift(u,u.geometry,u.material,0,0,null))}function b(w,A){w.getRGB(m_,FZ(t)),r.buffers.color.setClear(m_.r,m_.g,m_.b,A,s)}function E(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return l},setClearColor:function(w,A=1){l.set(w),c=A,b(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(w){c=w,b(l,c)},render:v,addToRenderList:y,dispose:E}}function Nje(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=g(null);let a=i,s=!1;function l(j,B,L,K,R){let q=!1;const W=f(K,L,B);a!==W&&(a=W,u(a.object)),q=p(j,K,L,R),q&&x(j,K,L,R),R!==null&&e.update(R,t.ELEMENT_ARRAY_BUFFER),(q||s)&&(s=!1,A(j,B,L,K),R!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(R).buffer))}function c(){return t.createVertexArray()}function u(j){return t.bindVertexArray(j)}function d(j){return t.deleteVertexArray(j)}function f(j,B,L){const K=L.wireframe===!0;let R=r[j.id];R===void 0&&(R={},r[j.id]=R);let q=R[B.id];q===void 0&&(q={},R[B.id]=q);let W=q[K];return W===void 0&&(W=g(c()),q[K]=W),W}function g(j){const B=[],L=[],K=[];for(let R=0;R<n;R++)B[R]=0,L[R]=0,K[R]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:B,enabledAttributes:L,attributeDivisors:K,object:j,attributes:{},index:null}}function p(j,B,L,K){const R=a.attributes,q=B.attributes;let W=0;const $=L.getAttributes();for(const J in $)if($[J].location>=0){const Q=R[J];let z=q[J];if(z===void 0&&(J==="instanceMatrix"&&j.instanceMatrix&&(z=j.instanceMatrix),J==="instanceColor"&&j.instanceColor&&(z=j.instanceColor)),Q===void 0||Q.attribute!==z||z&&Q.data!==z.data)return!0;W++}return a.attributesNum!==W||a.index!==K}function x(j,B,L,K){const R={},q=B.attributes;let W=0;const $=L.getAttributes();for(const J in $)if($[J].location>=0){let Q=q[J];Q===void 0&&(J==="instanceMatrix"&&j.instanceMatrix&&(Q=j.instanceMatrix),J==="instanceColor"&&j.instanceColor&&(Q=j.instanceColor));const z={};z.attribute=Q,Q&&Q.data&&(z.data=Q.data),R[J]=z,W++}a.attributes=R,a.attributesNum=W,a.index=K}function v(){const j=a.newAttributes;for(let B=0,L=j.length;B<L;B++)j[B]=0}function y(j){b(j,0)}function b(j,B){const L=a.newAttributes,K=a.enabledAttributes,R=a.attributeDivisors;L[j]=1,K[j]===0&&(t.enableVertexAttribArray(j),K[j]=1),R[j]!==B&&(t.vertexAttribDivisor(j,B),R[j]=B)}function E(){const j=a.newAttributes,B=a.enabledAttributes;for(let L=0,K=B.length;L<K;L++)B[L]!==j[L]&&(t.disableVertexAttribArray(L),B[L]=0)}function w(j,B,L,K,R,q,W){W===!0?t.vertexAttribIPointer(j,B,L,R,q):t.vertexAttribPointer(j,B,L,K,R,q)}function A(j,B,L,K){v();const R=K.attributes,q=L.getAttributes(),W=B.defaultAttributeValues;for(const $ in q){const J=q[$];if(J.location>=0){let ee=R[$];if(ee===void 0&&($==="instanceMatrix"&&j.instanceMatrix&&(ee=j.instanceMatrix),$==="instanceColor"&&j.instanceColor&&(ee=j.instanceColor)),ee!==void 0){const Q=ee.normalized,z=ee.itemSize,V=e.get(ee);if(V===void 0)continue;const X=V.buffer,te=V.type,ie=V.bytesPerElement,le=te===t.INT||te===t.UNSIGNED_INT||ee.gpuType===EO;if(ee.isInterleavedBufferAttribute){const ge=ee.data,Ee=ge.stride,pe=ee.offset;if(ge.isInstancedInterleavedBuffer){for(let de=0;de<J.locationSize;de++)b(J.location+de,ge.meshPerAttribute);j.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=ge.meshPerAttribute*ge.count)}else for(let de=0;de<J.locationSize;de++)y(J.location+de);t.bindBuffer(t.ARRAY_BUFFER,X);for(let de=0;de<J.locationSize;de++)w(J.location+de,z/J.locationSize,te,Q,Ee*ie,(pe+z/J.locationSize*de)*ie,le)}else{if(ee.isInstancedBufferAttribute){for(let ge=0;ge<J.locationSize;ge++)b(J.location+ge,ee.meshPerAttribute);j.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let ge=0;ge<J.locationSize;ge++)y(J.location+ge);t.bindBuffer(t.ARRAY_BUFFER,X);for(let ge=0;ge<J.locationSize;ge++)w(J.location+ge,z/J.locationSize,te,Q,z*ie,z/J.locationSize*ge*ie,le)}}else if(W!==void 0){const Q=W[$];if(Q!==void 0)switch(Q.length){case 2:t.vertexAttrib2fv(J.location,Q);break;case 3:t.vertexAttrib3fv(J.location,Q);break;case 4:t.vertexAttrib4fv(J.location,Q);break;default:t.vertexAttrib1fv(J.location,Q)}}}}E()}function T(){O();for(const j in r){const B=r[j];for(const L in B){const K=B[L];for(const R in K)d(K[R].object),delete K[R];delete B[L]}delete r[j]}}function C(j){if(r[j.id]===void 0)return;const B=r[j.id];for(const L in B){const K=B[L];for(const R in K)d(K[R].object),delete K[R];delete B[L]}delete r[j.id]}function N(j){for(const B in r){const L=r[B];if(L[j.id]===void 0)continue;const K=L[j.id];for(const R in K)d(K[R].object),delete K[R];delete L[j.id]}}function O(){k(),s=!0,a!==i&&(a=i,u(a.object))}function k(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:O,resetDefaultState:k,dispose:T,releaseStatesOfGeometry:C,releaseStatesOfProgram:N,initAttributes:v,enableAttribute:y,disableUnusedAttributes:E}}function Cje(t,e,n){let r;function i(u){r=u}function a(u,d){t.drawArrays(r,u,d),n.update(d,r,1)}function s(u,d,f){f!==0&&(t.drawArraysInstanced(r,u,d,f),n.update(d,r,f))}function l(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,f);let p=0;for(let x=0;x<f;x++)p+=d[x];n.update(p,r,1)}function c(u,d,f,g){if(f===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<u.length;x++)s(u[x],d[x],g[x]);else{p.multiDrawArraysInstancedWEBGL(r,u,0,d,0,g,0,f);let x=0;for(let v=0;v<f;v++)x+=d[v]*g[v];n.update(x,r,1)}}this.setMode=i,this.render=a,this.renderInstances=s,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function kje(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const N=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(N.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function s(N){return!(N!==Fo&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(N){const O=N===yg&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(N!==Al&&r.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&N!==Nc&&!O)}function c(N){if(N==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";N="mediump"}return N==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let u=n.precision!==void 0?n.precision:"highp";const d=c(u);d!==u&&(en("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,g=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=t.getParameter(t.MAX_TEXTURE_SIZE),y=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),b=t.getParameter(t.MAX_VERTEX_ATTRIBS),E=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),w=t.getParameter(t.MAX_VARYING_VECTORS),A=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),T=x>0,C=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:s,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:g,maxTextures:p,maxVertexTextures:x,maxTextureSize:v,maxCubemapSize:y,maxAttributes:b,maxVertexUniforms:E,maxVaryings:w,maxFragmentUniforms:A,vertexTextures:T,maxSamples:C}}function Pje(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new $u,l=new xn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const p=f.length!==0||g||r!==0||i;return i=g,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,p){const x=f.clippingPlanes,v=f.clipIntersection,y=f.clipShadows,b=t.get(f);if(!i||x===null||x.length===0||a&&!y)a?d(null):u();else{const E=a?0:r,w=E*4;let A=b.clippingState||null;c.value=A,A=d(x,g,w,p);for(let T=0;T!==w;++T)A[T]=n[T];b.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=E}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,g,p,x){const v=f!==null?f.length:0;let y=null;if(v!==0){if(y=c.value,x!==!0||y===null){const b=p+v*4,E=g.matrixWorldInverse;l.getNormalMatrix(E),(y===null||y.length<b)&&(y=new Float32Array(b));for(let w=0,A=p;w!==v;++w,A+=4)s.copy(f[w]).applyMatrix4(E,l),s.normal.toArray(y,A),y[A+3]=s.constant}c.value=y,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,y}}function jje(t){let e=new WeakMap;function n(s,l){return l===gP?s.mapping=Up:l===xP&&(s.mapping=zp),s}function r(s){if(s&&s.isTexture){const l=s.mapping;if(l===gP||l===xP)if(e.has(s)){const c=e.get(s).texture;return n(c,s.mapping)}else{const c=s.image;if(c&&c.height>0){const u=new Tke(c.height);return u.fromEquirectangularTexture(t,s),e.set(s,u),s.addEventListener("dispose",i),n(u.texture,s.mapping)}else return null}}return s}function i(s){const l=s.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}const ed=4,WH=[.125,.215,.35,.446,.526,.582],vh=20,Rje=256,Ox=new WZ,qH=new Tn;let aC=null,sC=0,oC=0,lC=!1;const Dje=new at;let KH=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,r=.1,i=100,a={}){const{size:s=256,position:l=Dje}=a;aC=this._renderer.getRenderTarget(),sC=this._renderer.getActiveCubeFace(),oC=this._renderer.getActiveMipmapLevel(),lC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,r,i,c,l),n>0&&this._blur(c,0,0,n),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ZH(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=YH(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(aC,sC,oC),this._renderer.xr.enabled=lC,e.scissorTest=!1,Tm(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Up||e.mapping===zp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),aC=this._renderer.getRenderTarget(),sC=this._renderer.getActiveCubeFace(),oC=this._renderer.getActiveMipmapLevel(),lC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:oo,minFilter:oo,generateMipmaps:!1,type:yg,format:Fo,colorSpace:Bp,depthBuffer:!1},i=XH(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=XH(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Oje(a)),this._blurMaterial=Ije(a,e,n),this._ggxMaterial=Lje(a,e,n)}return i}_compileMaterial(e){const n=new Tl(new Ll,e);this._renderer.compile(n,Ox)}_sceneToCubeUV(e,n,r,i,a){const c=new to(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,g=f.autoClear,p=f.toneMapping;f.getClearColor(qH),f.toneMapping=ld,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Tl(new OO,new DO({name:"PMREM.Background",side:ts,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,y=v.material;let b=!1;const E=e.background;E?E.isColor&&(y.color.copy(E),e.background=null,b=!0):(y.color.copy(qH),b=!0);for(let w=0;w<6;w++){const A=w%3;A===0?(c.up.set(0,u[w],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x+d[w],a.y,a.z)):A===1?(c.up.set(0,0,u[w]),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y+d[w],a.z)):(c.up.set(0,u[w],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y,a.z+d[w]));const T=this._cubeSize;Tm(i,A*T,w>2?T:0,T,T),f.setRenderTarget(i),b&&f.render(v,c),f.render(e,c)}f.toneMapping=p,f.autoClear=g,e.background=E}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Up||e.mapping===zp;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=ZH()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=YH());const a=i?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=a;const l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;Tm(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(s,Ox)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let a=1;a<i;a++)this._applyGGXFilter(e,a-1,a);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,a=this._pingPongRenderTarget,s=this._ggxMaterial,l=this._lodMeshes[r];l.material=s;const c=s.uniforms,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(u*u-d*d),g=.05+u*.95,p=f*g,{_lodMax:x}=this,v=this._sizeLods[r],y=3*v*(r>x-ed?r-x+ed:0),b=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=x-n,Tm(a,y,b,3*v,2*v),i.setRenderTarget(a),i.render(l,Ox),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=x-r,Tm(e,y,b,3*v,2*v),i.setRenderTarget(e),i.render(l,Ox)}_blur(e,n,r,i,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,n,r,i,"latitudinal",a),this._halfBlur(s,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,s,l){const c=this._renderer,u=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&Qr("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const g=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*vh-1),v=a/x,y=isFinite(a)?1+Math.floor(d*v):vh;y>vh&&en(`sigmaRadians, ${a}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${vh}`);const b=[];let E=0;for(let N=0;N<vh;++N){const O=N/v,k=Math.exp(-O*O/2);b.push(k),N===0?E+=k:N<y&&(E+=2*k)}for(let N=0;N<b.length;N++)b[N]=b[N]/E;g.envMap.value=e.texture,g.samples.value=y,g.weights.value=b,g.latitudinal.value=s==="latitudinal",l&&(g.poleAxis.value=l);const{_lodMax:w}=this;g.dTheta.value=x,g.mipInt.value=w-r;const A=this._sizeLods[i],T=3*A*(i>w-ed?i-w+ed:0),C=4*(this._cubeSize-A);Tm(n,T,C,3*A,2*A),c.setRenderTarget(n),c.render(f,Ox)}};function Oje(t){const e=[],n=[],r=[];let i=t;const a=t-ed+1+WH.length;for(let s=0;s<a;s++){const l=Math.pow(2,i);e.push(l);let c=1/l;s>t-ed?c=WH[s-t+ed-1]:s===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,v=3,y=2,b=1,E=new Float32Array(v*x*p),w=new Float32Array(y*x*p),A=new Float32Array(b*x*p);for(let C=0;C<p;C++){const N=C%3*2/3-1,O=C>2?0:-1,k=[N,O,0,N+2/3,O,0,N+2/3,O+1,0,N,O,0,N+2/3,O+1,0,N,O+1,0];E.set(k,v*x*C),w.set(g,y*x*C);const j=[C,C,C,C,C,C];A.set(j,b*x*C)}const T=new Ll;T.setAttribute("position",new uo(E,v)),T.setAttribute("uv",new uo(w,y)),T.setAttribute("faceIndex",new uo(A,b)),r.push(new Tl(T,null)),i>ed&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function XH(t,e,n){const r=new gf(t,e,n);return r.texture.mapping=JM,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Tm(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function Lje(t,e,n){return new Xc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Rje,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:tE(),fragmentShader:`
- precision highp float;
- precision highp int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform float roughness;
- uniform float mipInt;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- #define PI 3.14159265359
- // Van der Corput radical inverse
- float radicalInverse_VdC(uint bits) {
- bits = (bits << 16u) | (bits >> 16u);
- bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return float(bits) * 2.3283064365386963e-10; // / 0x100000000
- }
- // Hammersley sequence
- vec2 hammersley(uint i, uint N) {
- return vec2(float(i) / float(N), radicalInverse_VdC(i));
- }
- // GGX VNDF importance sampling (Eric Heitz 2018)
- // "Sampling the GGX Distribution of Visible Normals"
- // https://jcgt.org/published/0007/04/01/
- vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
- float alpha = roughness * roughness;
- // Section 3.2: Transform view direction to hemisphere configuration
- vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
- // Section 4.1: Orthonormal basis
- float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
- vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
- vec3 T2 = cross(Vh, T1);
- // Section 4.2: Parameterization of projected area
- float r = sqrt(Xi.x);
- float phi = 2.0 * PI * Xi.y;
- float t1 = r * cos(phi);
- float t2 = r * sin(phi);
- float s = 0.5 * (1.0 + Vh.z);
- t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
- // Section 4.3: Reprojection onto hemisphere
- vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
- // Section 3.4: Transform back to ellipsoid configuration
- return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
- }
- void main() {
- vec3 N = normalize(vOutputDirection);
- vec3 V = N; // Assume view direction equals normal for pre-filtering
- vec3 prefilteredColor = vec3(0.0);
- float totalWeight = 0.0;
- // For very low roughness, just sample the environment directly
- if (roughness < 0.001) {
- gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
- return;
- }
- // Tangent space basis for VNDF sampling
- vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
- vec3 tangent = normalize(cross(up, N));
- vec3 bitangent = cross(N, tangent);
- for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
- vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
- // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
- vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
- // Transform H back to world space
- vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
- vec3 L = normalize(2.0 * dot(V, H) * H - V);
- float NdotL = max(dot(N, L), 0.0);
- if(NdotL > 0.0) {
- // Sample environment at fixed mip level
- // VNDF importance sampling handles the distribution filtering
- vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
- // Weight by NdotL for the split-sum approximation
- // VNDF PDF naturally accounts for the visible microfacet distribution
- prefilteredColor += sampleColor * NdotL;
- totalWeight += NdotL;
- }
- }
- if (totalWeight > 0.0) {
- prefilteredColor = prefilteredColor / totalWeight;
- }
- gl_FragColor = vec4(prefilteredColor, 1.0);
- }
- `,blending:Dc,depthTest:!1,depthWrite:!1})}function Ije(t,e,n){const r=new Float32Array(vh),i=new at(0,1,0);return new Xc({name:"SphericalGaussianBlur",defines:{n:vh,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:tE(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:Dc,depthTest:!1,depthWrite:!1})}function YH(){return new Xc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:tE(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:Dc,depthTest:!1,depthWrite:!1})}function ZH(){return new Xc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:tE(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:Dc,depthTest:!1,depthWrite:!1})}function tE(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function Fje(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===gP||c===xP,d=c===Up||c===zp;if(u||d){let f=e.get(l);const g=f!==void 0?f.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==g)return n===null&&(n=new KH(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),f.texture;if(f!==void 0)return f.texture;{const p=l.image;return u&&p&&p.height>0||d&&p&&i(p)?(n===null&&(n=new KH(t)),f=u?n.fromEquirectangular(l):n.fromCubemap(l),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),l.addEventListener("dispose",a),f.texture):null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function a(l){const c=l.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:s}}function Uje(t){const e={};function n(r){if(e[r]!==void 0)return e[r];const i=t.getExtension(r);return e[r]=i,i}return{has:function(r){return n(r)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(r){const i=n(r);return i===null&&rb("WebGLRenderer: "+r+" extension not supported."),i}}}function zje(t,e,n,r){const i={},a=new WeakMap;function s(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const x in g.attributes)e.remove(g.attributes[x]);g.removeEventListener("dispose",s),delete i[g.id];const p=a.get(g);p&&(e.remove(p),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function l(f,g){return i[g.id]===!0||(g.addEventListener("dispose",s),i[g.id]=!0,n.memory.geometries++),g}function c(f){const g=f.attributes;for(const p in g)e.update(g[p],t.ARRAY_BUFFER)}function u(f){const g=[],p=f.index,x=f.attributes.position;let v=0;if(p!==null){const E=p.array;v=p.version;for(let w=0,A=E.length;w<A;w+=3){const T=E[w+0],C=E[w+1],N=E[w+2];g.push(T,C,C,N,N,T)}}else if(x!==void 0){const E=x.array;v=x.version;for(let w=0,A=E.length/3-1;w<A;w+=3){const T=w+0,C=w+1,N=w+2;g.push(T,C,C,N,N,T)}}else return;const y=new(EZ(g)?OZ:DZ)(g,1);y.version=v;const b=a.get(f);b&&e.remove(b),a.set(f,y)}function d(f){const g=a.get(f);if(g){const p=f.index;p!==null&&g.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function Bje(t,e,n){let r;function i(g){r=g}let a,s;function l(g){a=g.type,s=g.bytesPerElement}function c(g,p){t.drawElements(r,p,a,g*s),n.update(p,r,1)}function u(g,p,x){x!==0&&(t.drawElementsInstanced(r,p,a,g*s,x),n.update(p,r,x))}function d(g,p,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,p,0,a,g,0,x);let y=0;for(let b=0;b<x;b++)y+=p[b];n.update(y,r,1)}function f(g,p,x,v){if(x===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let b=0;b<g.length;b++)u(g[b]/s,p[b],v[b]);else{y.multiDrawElementsInstancedWEBGL(r,p,0,a,g,0,v,0,x);let b=0;for(let E=0;E<x;E++)b+=p[E]*v[E];n.update(b,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function Hje(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,s,l){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;break;default:Qr("WebGLInfo: Unknown draw mode:",s);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function $je(t,e,n){const r=new WeakMap,i=new ci;function a(s,l,c){const u=s.morphTargetInfluences,d=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,f=d!==void 0?d.length:0;let g=r.get(l);if(g===void 0||g.count!==f){let j=function(){O.dispose(),r.delete(l),l.removeEventListener("dispose",j)};var p=j;g!==void 0&&g.texture.dispose();const x=l.morphAttributes.position!==void 0,v=l.morphAttributes.normal!==void 0,y=l.morphAttributes.color!==void 0,b=l.morphAttributes.position||[],E=l.morphAttributes.normal||[],w=l.morphAttributes.color||[];let A=0;x===!0&&(A=1),v===!0&&(A=2),y===!0&&(A=3);let T=l.attributes.position.count*A,C=1;T>e.maxTextureSize&&(C=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const N=new Float32Array(T*C*4*f),O=new kZ(N,T,C,f);O.type=Nc,O.needsUpdate=!0;const k=A*4;for(let B=0;B<f;B++){const L=b[B],K=E[B],R=w[B],q=T*C*4*B;for(let W=0;W<L.count;W++){const $=W*k;x===!0&&(i.fromBufferAttribute(L,W),N[q+$+0]=i.x,N[q+$+1]=i.y,N[q+$+2]=i.z,N[q+$+3]=0),v===!0&&(i.fromBufferAttribute(K,W),N[q+$+4]=i.x,N[q+$+5]=i.y,N[q+$+6]=i.z,N[q+$+7]=0),y===!0&&(i.fromBufferAttribute(R,W),N[q+$+8]=i.x,N[q+$+9]=i.y,N[q+$+10]=i.z,N[q+$+11]=R.itemSize===4?i.w:1)}}g={count:f,texture:O,size:new fn(T,C)},r.set(l,g),l.addEventListener("dispose",j)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",s.morphTexture,n);else{let x=0;for(let y=0;y<u.length;y++)x+=u[y];const v=l.morphTargetsRelative?1:1-x;c.getUniforms().setValue(t,"morphTargetBaseInfluence",v),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",g.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",g.size)}return{update:a}}function Vje(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const g=c.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function s(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:s}}const KZ=new Yo,QH=new HZ(1,1),XZ=new kZ,YZ=new uke,ZZ=new zZ,JH=[],e$=[],t$=new Float32Array(16),n$=new Float32Array(9),r$=new Float32Array(4);function _g(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=JH[i];if(a===void 0&&(a=new Float32Array(i),JH[i]=a),e!==0){r.toArray(a,0);for(let s=1,l=0;s!==e;++s)l+=n,t[s].toArray(a,l)}return a}function _i(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function wi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function nE(t,e){let n=e$[e];n===void 0&&(n=new Int32Array(e),e$[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function Gje(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Wje(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(_i(n,e))return;t.uniform2fv(this.addr,e),wi(n,e)}}function qje(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(_i(n,e))return;t.uniform3fv(this.addr,e),wi(n,e)}}function Kje(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(_i(n,e))return;t.uniform4fv(this.addr,e),wi(n,e)}}function Xje(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(_i(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),wi(n,e)}else{if(_i(n,r))return;r$.set(r),t.uniformMatrix2fv(this.addr,!1,r$),wi(n,r)}}function Yje(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(_i(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),wi(n,e)}else{if(_i(n,r))return;n$.set(r),t.uniformMatrix3fv(this.addr,!1,n$),wi(n,r)}}function Zje(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(_i(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),wi(n,e)}else{if(_i(n,r))return;t$.set(r),t.uniformMatrix4fv(this.addr,!1,t$),wi(n,r)}}function Qje(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Jje(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(_i(n,e))return;t.uniform2iv(this.addr,e),wi(n,e)}}function eRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(_i(n,e))return;t.uniform3iv(this.addr,e),wi(n,e)}}function tRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(_i(n,e))return;t.uniform4iv(this.addr,e),wi(n,e)}}function nRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function rRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(_i(n,e))return;t.uniform2uiv(this.addr,e),wi(n,e)}}function iRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(_i(n,e))return;t.uniform3uiv(this.addr,e),wi(n,e)}}function aRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(_i(n,e))return;t.uniform4uiv(this.addr,e),wi(n,e)}}function sRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let a;this.type===t.SAMPLER_2D_SHADOW?(QH.compareFunction=MZ,a=QH):a=KZ,n.setTexture2D(e||a,i)}function oRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||YZ,i)}function lRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||ZZ,i)}function cRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||XZ,i)}function uRe(t){switch(t){case 5126:return Gje;case 35664:return Wje;case 35665:return qje;case 35666:return Kje;case 35674:return Xje;case 35675:return Yje;case 35676:return Zje;case 5124:case 35670:return Qje;case 35667:case 35671:return Jje;case 35668:case 35672:return eRe;case 35669:case 35673:return tRe;case 5125:return nRe;case 36294:return rRe;case 36295:return iRe;case 36296:return aRe;case 35678:case 36198:case 36298:case 36306:case 35682:return sRe;case 35679:case 36299:case 36307:return oRe;case 35680:case 36300:case 36308:case 36293:return lRe;case 36289:case 36303:case 36311:case 36292:return cRe}}function dRe(t,e){t.uniform1fv(this.addr,e)}function hRe(t,e){const n=_g(e,this.size,2);t.uniform2fv(this.addr,n)}function fRe(t,e){const n=_g(e,this.size,3);t.uniform3fv(this.addr,n)}function mRe(t,e){const n=_g(e,this.size,4);t.uniform4fv(this.addr,n)}function pRe(t,e){const n=_g(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function gRe(t,e){const n=_g(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function xRe(t,e){const n=_g(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function bRe(t,e){t.uniform1iv(this.addr,e)}function yRe(t,e){t.uniform2iv(this.addr,e)}function vRe(t,e){t.uniform3iv(this.addr,e)}function _Re(t,e){t.uniform4iv(this.addr,e)}function wRe(t,e){t.uniform1uiv(this.addr,e)}function SRe(t,e){t.uniform2uiv(this.addr,e)}function MRe(t,e){t.uniform3uiv(this.addr,e)}function ERe(t,e){t.uniform4uiv(this.addr,e)}function ARe(t,e,n){const r=this.cache,i=e.length,a=nE(n,i);_i(r,a)||(t.uniform1iv(this.addr,a),wi(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||KZ,a[s])}function TRe(t,e,n){const r=this.cache,i=e.length,a=nE(n,i);_i(r,a)||(t.uniform1iv(this.addr,a),wi(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||YZ,a[s])}function NRe(t,e,n){const r=this.cache,i=e.length,a=nE(n,i);_i(r,a)||(t.uniform1iv(this.addr,a),wi(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||ZZ,a[s])}function CRe(t,e,n){const r=this.cache,i=e.length,a=nE(n,i);_i(r,a)||(t.uniform1iv(this.addr,a),wi(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||XZ,a[s])}function kRe(t){switch(t){case 5126:return dRe;case 35664:return hRe;case 35665:return fRe;case 35666:return mRe;case 35674:return pRe;case 35675:return gRe;case 35676:return xRe;case 5124:case 35670:return bRe;case 35667:case 35671:return yRe;case 35668:case 35672:return vRe;case 35669:case 35673:return _Re;case 5125:return wRe;case 36294:return SRe;case 36295:return MRe;case 36296:return ERe;case 35678:case 36198:case 36298:case 36306:case 35682:return ARe;case 35679:case 36299:case 36307:return TRe;case 35680:case 36300:case 36308:case 36293:return NRe;case 36289:case 36303:case 36311:case 36292:return CRe}}let PRe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=uRe(n.type)}},jRe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=kRe(n.type)}},RRe=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,s=i.length;a!==s;++a){const l=i[a];l.setValue(e,n[l.id],r)}}};const cC=/(\w+)(\])?(\[|\.)?/g;function i$(t,e){t.seq.push(e),t.map[e.id]=e}function DRe(t,e,n){const r=t.name,i=r.length;for(cC.lastIndex=0;;){const a=cC.exec(r),s=cC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&s+2===i){i$(n,u===void 0?new PRe(l,t,e):new jRe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new RRe(l),i$(n,f)),n=f}}}let T1=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),s=e.getUniformLocation(n,a.name);DRe(a,s,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,s=n.length;a!==s;++a){const l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const s=e[i];s.id in n&&r.push(s)}return r}};function a$(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const ORe=37297;let LRe=0;function IRe(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=i;s<a;s++){const l=s+1;r.push(`${l===e?">":" "} ${l}: ${n[s]}`)}return r.join(`
- `)}const s$=new xn;function FRe(t){Ln._getMatrix(s$,Ln.workingColorSpace,t);const e=`mat3( ${s$.elements.map(n=>n.toFixed(4))} )`;switch(Ln.getTransfer(t)){case $w:return[e,"LinearTransferOETF"];case ar:return[e,"sRGBTransferOETF"];default:return en("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function o$(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const s=/ERROR: 0:(\d+)/.exec(a);if(s){const l=parseInt(s[1]);return n.toUpperCase()+`
- `+a+`
- `+IRe(t.getShaderSource(e),l)}else return a}function URe(t,e){const n=FRe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function zRe(t,e){let n;switch(e){case ICe:n="Linear";break;case FCe:n="Reinhard";break;case UCe:n="Cineon";break;case zCe:n="ACESFilmic";break;case HCe:n="AgX";break;case $Ce:n="Neutral";break;case BCe:n="Custom";break;default:en("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const p_=new at;function BRe(){Ln.getLuminanceCoefficients(p_);const t=p_.x.toFixed(4),e=p_.y.toFixed(4),n=p_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function HRe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Yx).join(`
- `)}function $Re(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function VRe(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),s=a.name;let l=1;a.type===t.FLOAT_MAT2&&(l=2),a.type===t.FLOAT_MAT3&&(l=3),a.type===t.FLOAT_MAT4&&(l=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:l}}return n}function Yx(t){return t!==""}function l$(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function c$(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const GRe=/^[ \t]*#include +<([\w\d./]+)>/gm;function YP(t){return t.replace(GRe,qRe)}const WRe=new Map;function qRe(t,e){let n=dn[e];if(n===void 0){const r=WRe.get(e);if(r!==void 0)n=dn[r],en('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return YP(n)}const KRe=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function u$(t){return t.replace(KRe,XRe)}function XRe(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function d$(t){let e=`precision ${t.precision} float;
- precision ${t.precision} int;
- precision ${t.precision} sampler2D;
- precision ${t.precision} samplerCube;
- precision ${t.precision} sampler3D;
- precision ${t.precision} sampler2DArray;
- precision ${t.precision} sampler2DShadow;
- precision ${t.precision} samplerCubeShadow;
- precision ${t.precision} sampler2DArrayShadow;
- precision ${t.precision} isampler2D;
- precision ${t.precision} isampler3D;
- precision ${t.precision} isamplerCube;
- precision ${t.precision} isampler2DArray;
- precision ${t.precision} usampler2D;
- precision ${t.precision} usampler3D;
- precision ${t.precision} usamplerCube;
- precision ${t.precision} usampler2DArray;
- `;return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function YRe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===mZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===gCe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===pc&&(e="SHADOWMAP_TYPE_VSM"),e}function ZRe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Up:case zp:e="ENVMAP_TYPE_CUBE";break;case JM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function QRe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case zp:e="ENVMAP_MODE_REFRACTION";break}return e}function JRe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case MO:e="ENVMAP_BLENDING_MULTIPLY";break;case OCe:e="ENVMAP_BLENDING_MIX";break;case LCe:e="ENVMAP_BLENDING_ADD";break}return e}function eDe(t){const e=t.envMapCubeUVHeight;if(e===null)return null;const n=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:r,maxMip:n}}function tDe(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,l=n.fragmentShader;const c=YRe(n),u=ZRe(n),d=QRe(n),f=JRe(n),g=eDe(n),p=HRe(n),x=$Re(a),v=i.createProgram();let y,b,E=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Yx).join(`
- `),y.length>0&&(y+=`
- `),b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Yx).join(`
- `),b.length>0&&(b+=`
- `)):(y=[d$(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(Yx).join(`
- `),b=[d$(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ld?"#define TONE_MAPPING":"",n.toneMapping!==ld?dn.tonemapping_pars_fragment:"",n.toneMapping!==ld?zRe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",dn.colorspace_pars_fragment,URe("linearToOutputTexel",n.outputColorSpace),BRe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Yx).join(`
- `)),s=YP(s),s=l$(s,n),s=c$(s,n),l=YP(l),l=l$(l,n),l=c$(l,n),s=u$(s),l=u$(l),n.isRawShaderMaterial!==!0&&(E=`#version 300 es
- `,y=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+y,b=["#define varying in",n.glslVersion===bH?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===bH?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
- `)+`
- `+b);const w=E+y+s,A=E+b+l,T=a$(i,i.VERTEX_SHADER,w),C=a$(i,i.FRAGMENT_SHADER,A);i.attachShader(v,T),i.attachShader(v,C),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function N(B){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(v)||"",K=i.getShaderInfoLog(T)||"",R=i.getShaderInfoLog(C)||"",q=L.trim(),W=K.trim(),$=R.trim();let J=!0,ee=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(J=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,T,C);else{const Q=o$(i,T,"vertex"),z=o$(i,C,"fragment");Qr("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
- Material Name: `+B.name+`
- Material Type: `+B.type+`
- Program Info Log: `+q+`
- `+Q+`
- `+z)}else q!==""?en("WebGLProgram: Program Info Log:",q):(W===""||$==="")&&(ee=!1);ee&&(B.diagnostics={runnable:J,programLog:q,vertexShader:{log:W,prefix:y},fragmentShader:{log:$,prefix:b}})}i.deleteShader(T),i.deleteShader(C),O=new T1(i,v),k=VRe(i,v)}let O;this.getUniforms=function(){return O===void 0&&N(this),O};let k;this.getAttributes=function(){return k===void 0&&N(this),k};let j=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return j===!1&&(j=i.getProgramParameter(v,ORe)),j},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=LRe++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=T,this.fragmentShader=C,this}let nDe=0,rDe=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),s=this._getShaderCacheForMaterial(e);return s.has(i)===!1&&(s.add(i),i.usedTimes++),s.has(a)===!1&&(s.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new iDe(e),n.set(e,r)),r}},iDe=class{constructor(e){this.id=nDe++,this.code=e,this.usedTimes=0}};function aDe(t,e,n,r,i,a,s){const l=new jZ,c=new rDe,u=new Set,d=[],f=i.logarithmicDepthBuffer,g=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(k){return u.add(k),k===0?"uv":`uv${k}`}function y(k,j,B,L,K){const R=L.fog,q=K.geometry,W=k.isMeshStandardMaterial?L.environment:null,$=(k.isMeshStandardMaterial?n:e).get(k.envMap||W),J=$&&$.mapping===JM?$.image.height:null,ee=x[k.type];k.precision!==null&&(p=i.getMaxPrecision(k.precision),p!==k.precision&&en("WebGLProgram.getParameters:",k.precision,"not supported, using",p,"instead."));const Q=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,z=Q!==void 0?Q.length:0;let V=0;q.morphAttributes.position!==void 0&&(V=1),q.morphAttributes.normal!==void 0&&(V=2),q.morphAttributes.color!==void 0&&(V=3);let X,te,ie,le;if(ee){const Xe=ul[ee];X=Xe.vertexShader,te=Xe.fragmentShader}else X=k.vertexShader,te=k.fragmentShader,c.update(k),ie=c.getVertexShaderID(k),le=c.getFragmentShaderID(k);const ge=t.getRenderTarget(),Ee=t.state.buffers.depth.getReversed(),pe=K.isInstancedMesh===!0,de=K.isBatchedMesh===!0,Re=!!k.map,fe=!!k.matcap,Fe=!!$,U=!!k.aoMap,H=!!k.lightMap,re=!!k.bumpMap,G=!!k.normalMap,Z=!!k.displacementMap,oe=!!k.emissiveMap,be=!!k.metalnessMap,Te=!!k.roughnessMap,Me=k.anisotropy>0,F=k.clearcoat>0,I=k.dispersion>0,ne=k.iridescence>0,ve=k.sheen>0,Se=k.transmission>0,ye=Me&&!!k.anisotropyMap,Ke=F&&!!k.clearcoatMap,We=F&&!!k.clearcoatNormalMap,qe=F&&!!k.clearcoatRoughnessMap,ut=ne&&!!k.iridescenceMap,ue=ne&&!!k.iridescenceThicknessMap,se=ve&&!!k.sheenColorMap,Ve=ve&&!!k.sheenRoughnessMap,Be=!!k.specularMap,Ze=!!k.specularColorMap,ht=!!k.specularIntensityMap,me=Se&&!!k.transmissionMap,nt=Se&&!!k.thicknessMap,xe=!!k.gradientMap,He=!!k.alphaMap,Pe=k.alphaTest>0,we=!!k.alphaHash,Ae=!!k.extensions;let lt=ld;k.toneMapped&&(ge===null||ge.isXRRenderTarget===!0)&&(lt=t.toneMapping);const _t={shaderID:ee,shaderType:k.type,shaderName:k.name,vertexShader:X,fragmentShader:te,defines:k.defines,customVertexShaderID:ie,customFragmentShaderID:le,isRawShaderMaterial:k.isRawShaderMaterial===!0,glslVersion:k.glslVersion,precision:p,batching:de,batchingColor:de&&K._colorsTexture!==null,instancing:pe,instancingColor:pe&&K.instanceColor!==null,instancingMorph:pe&&K.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:ge===null?t.outputColorSpace:ge.isXRRenderTarget===!0?ge.texture.colorSpace:Bp,alphaToCoverage:!!k.alphaToCoverage,map:Re,matcap:fe,envMap:Fe,envMapMode:Fe&&$.mapping,envMapCubeUVHeight:J,aoMap:U,lightMap:H,bumpMap:re,normalMap:G,displacementMap:g&&Z,emissiveMap:oe,normalMapObjectSpace:G&&k.normalMapType===qCe,normalMapTangentSpace:G&&k.normalMapType===SZ,metalnessMap:be,roughnessMap:Te,anisotropy:Me,anisotropyMap:ye,clearcoat:F,clearcoatMap:Ke,clearcoatNormalMap:We,clearcoatRoughnessMap:qe,dispersion:I,iridescence:ne,iridescenceMap:ut,iridescenceThicknessMap:ue,sheen:ve,sheenColorMap:se,sheenRoughnessMap:Ve,specularMap:Be,specularColorMap:Ze,specularIntensityMap:ht,transmission:Se,transmissionMap:me,thicknessMap:nt,gradientMap:xe,opaque:k.transparent===!1&&k.blending===gp&&k.alphaToCoverage===!1,alphaMap:He,alphaTest:Pe,alphaHash:we,combine:k.combine,mapUv:Re&&v(k.map.channel),aoMapUv:U&&v(k.aoMap.channel),lightMapUv:H&&v(k.lightMap.channel),bumpMapUv:re&&v(k.bumpMap.channel),normalMapUv:G&&v(k.normalMap.channel),displacementMapUv:Z&&v(k.displacementMap.channel),emissiveMapUv:oe&&v(k.emissiveMap.channel),metalnessMapUv:be&&v(k.metalnessMap.channel),roughnessMapUv:Te&&v(k.roughnessMap.channel),anisotropyMapUv:ye&&v(k.anisotropyMap.channel),clearcoatMapUv:Ke&&v(k.clearcoatMap.channel),clearcoatNormalMapUv:We&&v(k.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:qe&&v(k.clearcoatRoughnessMap.channel),iridescenceMapUv:ut&&v(k.iridescenceMap.channel),iridescenceThicknessMapUv:ue&&v(k.iridescenceThicknessMap.channel),sheenColorMapUv:se&&v(k.sheenColorMap.channel),sheenRoughnessMapUv:Ve&&v(k.sheenRoughnessMap.channel),specularMapUv:Be&&v(k.specularMap.channel),specularColorMapUv:Ze&&v(k.specularColorMap.channel),specularIntensityMapUv:ht&&v(k.specularIntensityMap.channel),transmissionMapUv:me&&v(k.transmissionMap.channel),thicknessMapUv:nt&&v(k.thicknessMap.channel),alphaMapUv:He&&v(k.alphaMap.channel),vertexTangents:!!q.attributes.tangent&&(G||Me),vertexColors:k.vertexColors,vertexAlphas:k.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,pointsUvs:K.isPoints===!0&&!!q.attributes.uv&&(Re||He),fog:!!R,useFog:k.fog===!0,fogExp2:!!R&&R.isFogExp2,flatShading:k.flatShading===!0&&k.wireframe===!1,sizeAttenuation:k.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Ee,skinning:K.isSkinnedMesh===!0,morphTargets:q.morphAttributes.position!==void 0,morphNormals:q.morphAttributes.normal!==void 0,morphColors:q.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:V,numDirLights:j.directional.length,numPointLights:j.point.length,numSpotLights:j.spot.length,numSpotLightMaps:j.spotLightMap.length,numRectAreaLights:j.rectArea.length,numHemiLights:j.hemi.length,numDirLightShadows:j.directionalShadowMap.length,numPointLightShadows:j.pointShadowMap.length,numSpotLightShadows:j.spotShadowMap.length,numSpotLightShadowsWithMaps:j.numSpotLightShadowsWithMaps,numLightProbes:j.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:k.dithering,shadowMapEnabled:t.shadowMap.enabled&&B.length>0,shadowMapType:t.shadowMap.type,toneMapping:lt,decodeVideoTexture:Re&&k.map.isVideoTexture===!0&&Ln.getTransfer(k.map.colorSpace)===ar,decodeVideoTextureEmissive:oe&&k.emissiveMap.isVideoTexture===!0&&Ln.getTransfer(k.emissiveMap.colorSpace)===ar,premultipliedAlpha:k.premultipliedAlpha,doubleSided:k.side===dl,flipSided:k.side===ts,useDepthPacking:k.depthPacking>=0,depthPacking:k.depthPacking||0,index0AttributeName:k.index0AttributeName,extensionClipCullDistance:Ae&&k.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ae&&k.extensions.multiDraw===!0||de)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:k.customProgramCacheKey()};return _t.vertexUv1s=u.has(1),_t.vertexUv2s=u.has(2),_t.vertexUv3s=u.has(3),u.clear(),_t}function b(k){const j=[];if(k.shaderID?j.push(k.shaderID):(j.push(k.customVertexShaderID),j.push(k.customFragmentShaderID)),k.defines!==void 0)for(const B in k.defines)j.push(B),j.push(k.defines[B]);return k.isRawShaderMaterial===!1&&(E(j,k),w(j,k),j.push(t.outputColorSpace)),j.push(k.customProgramCacheKey),j.join()}function E(k,j){k.push(j.precision),k.push(j.outputColorSpace),k.push(j.envMapMode),k.push(j.envMapCubeUVHeight),k.push(j.mapUv),k.push(j.alphaMapUv),k.push(j.lightMapUv),k.push(j.aoMapUv),k.push(j.bumpMapUv),k.push(j.normalMapUv),k.push(j.displacementMapUv),k.push(j.emissiveMapUv),k.push(j.metalnessMapUv),k.push(j.roughnessMapUv),k.push(j.anisotropyMapUv),k.push(j.clearcoatMapUv),k.push(j.clearcoatNormalMapUv),k.push(j.clearcoatRoughnessMapUv),k.push(j.iridescenceMapUv),k.push(j.iridescenceThicknessMapUv),k.push(j.sheenColorMapUv),k.push(j.sheenRoughnessMapUv),k.push(j.specularMapUv),k.push(j.specularColorMapUv),k.push(j.specularIntensityMapUv),k.push(j.transmissionMapUv),k.push(j.thicknessMapUv),k.push(j.combine),k.push(j.fogExp2),k.push(j.sizeAttenuation),k.push(j.morphTargetsCount),k.push(j.morphAttributeCount),k.push(j.numDirLights),k.push(j.numPointLights),k.push(j.numSpotLights),k.push(j.numSpotLightMaps),k.push(j.numHemiLights),k.push(j.numRectAreaLights),k.push(j.numDirLightShadows),k.push(j.numPointLightShadows),k.push(j.numSpotLightShadows),k.push(j.numSpotLightShadowsWithMaps),k.push(j.numLightProbes),k.push(j.shadowMapType),k.push(j.toneMapping),k.push(j.numClippingPlanes),k.push(j.numClipIntersection),k.push(j.depthPacking)}function w(k,j){l.disableAll(),j.supportsVertexTextures&&l.enable(0),j.instancing&&l.enable(1),j.instancingColor&&l.enable(2),j.instancingMorph&&l.enable(3),j.matcap&&l.enable(4),j.envMap&&l.enable(5),j.normalMapObjectSpace&&l.enable(6),j.normalMapTangentSpace&&l.enable(7),j.clearcoat&&l.enable(8),j.iridescence&&l.enable(9),j.alphaTest&&l.enable(10),j.vertexColors&&l.enable(11),j.vertexAlphas&&l.enable(12),j.vertexUv1s&&l.enable(13),j.vertexUv2s&&l.enable(14),j.vertexUv3s&&l.enable(15),j.vertexTangents&&l.enable(16),j.anisotropy&&l.enable(17),j.alphaHash&&l.enable(18),j.batching&&l.enable(19),j.dispersion&&l.enable(20),j.batchingColor&&l.enable(21),j.gradientMap&&l.enable(22),k.push(l.mask),l.disableAll(),j.fog&&l.enable(0),j.useFog&&l.enable(1),j.flatShading&&l.enable(2),j.logarithmicDepthBuffer&&l.enable(3),j.reversedDepthBuffer&&l.enable(4),j.skinning&&l.enable(5),j.morphTargets&&l.enable(6),j.morphNormals&&l.enable(7),j.morphColors&&l.enable(8),j.premultipliedAlpha&&l.enable(9),j.shadowMapEnabled&&l.enable(10),j.doubleSided&&l.enable(11),j.flipSided&&l.enable(12),j.useDepthPacking&&l.enable(13),j.dithering&&l.enable(14),j.transmission&&l.enable(15),j.sheen&&l.enable(16),j.opaque&&l.enable(17),j.pointsUvs&&l.enable(18),j.decodeVideoTexture&&l.enable(19),j.decodeVideoTextureEmissive&&l.enable(20),j.alphaToCoverage&&l.enable(21),k.push(l.mask)}function A(k){const j=x[k.type];let B;if(j){const L=ul[j];B=Ske.clone(L.uniforms)}else B=k.uniforms;return B}function T(k,j){let B;for(let L=0,K=d.length;L<K;L++){const R=d[L];if(R.cacheKey===j){B=R,++B.usedTimes;break}}return B===void 0&&(B=new tDe(t,j,k,a),d.push(B)),B}function C(k){if(--k.usedTimes===0){const j=d.indexOf(k);d[j]=d[d.length-1],d.pop(),k.destroy()}}function N(k){c.remove(k)}function O(){c.dispose()}return{getParameters:y,getProgramCacheKey:b,getUniforms:A,acquireProgram:T,releaseProgram:C,releaseShaderCache:N,programs:d,dispose:O}}function sDe(){let t=new WeakMap;function e(s){return t.has(s)}function n(s){let l=t.get(s);return l===void 0&&(l={},t.set(s,l)),l}function r(s){t.delete(s)}function i(s,l,c){t.get(s)[l]=c}function a(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:a}}function oDe(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function h$(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function f$(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function s(f,g,p,x,v,y){let b=t[e];return b===void 0?(b={id:f.id,object:f,geometry:g,material:p,groupOrder:x,renderOrder:f.renderOrder,z:v,group:y},t[e]=b):(b.id=f.id,b.object=f,b.geometry=g,b.material=p,b.groupOrder=x,b.renderOrder=f.renderOrder,b.z=v,b.group=y),e++,b}function l(f,g,p,x,v,y){const b=s(f,g,p,x,v,y);p.transmission>0?r.push(b):p.transparent===!0?i.push(b):n.push(b)}function c(f,g,p,x,v,y){const b=s(f,g,p,x,v,y);p.transmission>0?r.unshift(b):p.transparent===!0?i.unshift(b):n.unshift(b)}function u(f,g){n.length>1&&n.sort(f||oDe),r.length>1&&r.sort(g||h$),i.length>1&&i.sort(g||h$)}function d(){for(let f=e,g=t.length;f<g;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function lDe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new f$,t.set(r,[s])):i>=a.length?(s=new f$,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function cDe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new at,color:new Tn};break;case"SpotLight":n={position:new at,direction:new at,color:new Tn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new at,color:new Tn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new at,skyColor:new Tn,groundColor:new Tn};break;case"RectAreaLight":n={color:new Tn,position:new at,halfWidth:new at,halfHeight:new at};break}return t[e.id]=n,n}}}function uDe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let dDe=0;function hDe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function fDe(t){const e=new cDe,n=uDe(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)r.probe.push(new at);const i=new at,a=new fi,s=new fi;function l(u){let d=0,f=0,g=0;for(let k=0;k<9;k++)r.probe[k].set(0,0,0);let p=0,x=0,v=0,y=0,b=0,E=0,w=0,A=0,T=0,C=0,N=0;u.sort(hDe);for(let k=0,j=u.length;k<j;k++){const B=u[k],L=B.color,K=B.intensity,R=B.distance,q=B.shadow&&B.shadow.map?B.shadow.map.texture:null;if(B.isAmbientLight)d+=L.r*K,f+=L.g*K,g+=L.b*K;else if(B.isLightProbe){for(let W=0;W<9;W++)r.probe[W].addScaledVector(B.sh.coefficients[W],K);N++}else if(B.isDirectionalLight){const W=e.get(B);if(W.color.copy(B.color).multiplyScalar(B.intensity),B.castShadow){const $=B.shadow,J=n.get(B);J.shadowIntensity=$.intensity,J.shadowBias=$.bias,J.shadowNormalBias=$.normalBias,J.shadowRadius=$.radius,J.shadowMapSize=$.mapSize,r.directionalShadow[p]=J,r.directionalShadowMap[p]=q,r.directionalShadowMatrix[p]=B.shadow.matrix,E++}r.directional[p]=W,p++}else if(B.isSpotLight){const W=e.get(B);W.position.setFromMatrixPosition(B.matrixWorld),W.color.copy(L).multiplyScalar(K),W.distance=R,W.coneCos=Math.cos(B.angle),W.penumbraCos=Math.cos(B.angle*(1-B.penumbra)),W.decay=B.decay,r.spot[v]=W;const $=B.shadow;if(B.map&&(r.spotLightMap[T]=B.map,T++,$.updateMatrices(B),B.castShadow&&C++),r.spotLightMatrix[v]=$.matrix,B.castShadow){const J=n.get(B);J.shadowIntensity=$.intensity,J.shadowBias=$.bias,J.shadowNormalBias=$.normalBias,J.shadowRadius=$.radius,J.shadowMapSize=$.mapSize,r.spotShadow[v]=J,r.spotShadowMap[v]=q,A++}v++}else if(B.isRectAreaLight){const W=e.get(B);W.color.copy(L).multiplyScalar(K),W.halfWidth.set(B.width*.5,0,0),W.halfHeight.set(0,B.height*.5,0),r.rectArea[y]=W,y++}else if(B.isPointLight){const W=e.get(B);if(W.color.copy(B.color).multiplyScalar(B.intensity),W.distance=B.distance,W.decay=B.decay,B.castShadow){const $=B.shadow,J=n.get(B);J.shadowIntensity=$.intensity,J.shadowBias=$.bias,J.shadowNormalBias=$.normalBias,J.shadowRadius=$.radius,J.shadowMapSize=$.mapSize,J.shadowCameraNear=$.camera.near,J.shadowCameraFar=$.camera.far,r.pointShadow[x]=J,r.pointShadowMap[x]=q,r.pointShadowMatrix[x]=B.shadow.matrix,w++}r.point[x]=W,x++}else if(B.isHemisphereLight){const W=e.get(B);W.skyColor.copy(B.color).multiplyScalar(K),W.groundColor.copy(B.groundColor).multiplyScalar(K),r.hemi[b]=W,b++}}y>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=kt.LTC_FLOAT_1,r.rectAreaLTC2=kt.LTC_FLOAT_2):(r.rectAreaLTC1=kt.LTC_HALF_1,r.rectAreaLTC2=kt.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=g;const O=r.hash;(O.directionalLength!==p||O.pointLength!==x||O.spotLength!==v||O.rectAreaLength!==y||O.hemiLength!==b||O.numDirectionalShadows!==E||O.numPointShadows!==w||O.numSpotShadows!==A||O.numSpotMaps!==T||O.numLightProbes!==N)&&(r.directional.length=p,r.spot.length=v,r.rectArea.length=y,r.point.length=x,r.hemi.length=b,r.directionalShadow.length=E,r.directionalShadowMap.length=E,r.pointShadow.length=w,r.pointShadowMap.length=w,r.spotShadow.length=A,r.spotShadowMap.length=A,r.directionalShadowMatrix.length=E,r.pointShadowMatrix.length=w,r.spotLightMatrix.length=A+T-C,r.spotLightMap.length=T,r.numSpotLightShadowsWithMaps=C,r.numLightProbes=N,O.directionalLength=p,O.pointLength=x,O.spotLength=v,O.rectAreaLength=y,O.hemiLength=b,O.numDirectionalShadows=E,O.numPointShadows=w,O.numSpotShadows=A,O.numSpotMaps=T,O.numLightProbes=N,r.version=dDe++)}function c(u,d){let f=0,g=0,p=0,x=0,v=0;const y=d.matrixWorldInverse;for(let b=0,E=u.length;b<E;b++){const w=u[b];if(w.isDirectionalLight){const A=r.directional[f];A.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(y),f++}else if(w.isSpotLight){const A=r.spot[p];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(y),A.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(y),p++}else if(w.isRectAreaLight){const A=r.rectArea[x];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(y),s.identity(),a.copy(w.matrixWorld),a.premultiply(y),s.extractRotation(a),A.halfWidth.set(w.width*.5,0,0),A.halfHeight.set(0,w.height*.5,0),A.halfWidth.applyMatrix4(s),A.halfHeight.applyMatrix4(s),x++}else if(w.isPointLight){const A=r.point[g];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(y),g++}else if(w.isHemisphereLight){const A=r.hemi[v];A.direction.setFromMatrixPosition(w.matrixWorld),A.direction.transformDirection(y),v++}}}return{setup:l,setupView:c,state:r}}function m$(t){const e=new fDe(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function a(d){n.push(d)}function s(d){r.push(d)}function l(){e.setup(n)}function c(d){e.setupView(n,d)}const u={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:u,setupLights:l,setupLightsView:c,pushLight:a,pushShadow:s}}function mDe(t){let e=new WeakMap;function n(i,a=0){const s=e.get(i);let l;return s===void 0?(l=new m$(t),e.set(i,[l])):a>=s.length?(l=new m$(t),s.push(l)):l=s[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const pDe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,gDe=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function xDe(t,e,n){let r=new LO;const i=new fn,a=new fn,s=new ci,l=new Ike({depthPacking:WCe}),c=new Fke,u={},d=n.maxTextureSize,f={[Md]:ts,[ts]:Md,[dl]:dl},g=new Xc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new fn},radius:{value:4}},vertexShader:pDe,fragmentShader:gDe}),p=g.clone();p.defines.HORIZONTAL_PASS=1;const x=new Ll;x.setAttribute("position",new uo(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Tl(x,g),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=mZ;let b=this.type;this.render=function(C,N,O){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||C.length===0)return;const k=t.getRenderTarget(),j=t.getActiveCubeFace(),B=t.getActiveMipmapLevel(),L=t.state;L.setBlending(Dc),L.buffers.depth.getReversed()===!0?L.buffers.color.setClear(0,0,0,0):L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const K=b!==pc&&this.type===pc,R=b===pc&&this.type!==pc;for(let q=0,W=C.length;q<W;q++){const $=C[q],J=$.shadow;if(J===void 0){en("WebGLShadowMap:",$,"has no shadow.");continue}if(J.autoUpdate===!1&&J.needsUpdate===!1)continue;i.copy(J.mapSize);const ee=J.getFrameExtents();if(i.multiply(ee),a.copy(J.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/ee.x),i.x=a.x*ee.x,J.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/ee.y),i.y=a.y*ee.y,J.mapSize.y=a.y)),J.map===null||K===!0||R===!0){const z=this.type!==pc?{minFilter:ks,magFilter:ks}:{};J.map!==null&&J.map.dispose(),J.map=new gf(i.x,i.y,z),J.map.texture.name=$.name+".shadowMap",J.camera.updateProjectionMatrix()}t.setRenderTarget(J.map),t.clear();const Q=J.getViewportCount();for(let z=0;z<Q;z++){const V=J.getViewport(z);s.set(a.x*V.x,a.y*V.y,a.x*V.z,a.y*V.w),L.viewport(s),J.updateMatrices($,z),r=J.getFrustum(),A(N,O,J.camera,$,this.type)}J.isPointLightShadow!==!0&&this.type===pc&&E(J,O),J.needsUpdate=!1}b=this.type,y.needsUpdate=!1,t.setRenderTarget(k,j,B)};function E(C,N){const O=e.update(v);g.defines.VSM_SAMPLES!==C.blurSamples&&(g.defines.VSM_SAMPLES=C.blurSamples,p.defines.VSM_SAMPLES=C.blurSamples,g.needsUpdate=!0,p.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new gf(i.x,i.y)),g.uniforms.shadow_pass.value=C.map.texture,g.uniforms.resolution.value=C.mapSize,g.uniforms.radius.value=C.radius,t.setRenderTarget(C.mapPass),t.clear(),t.renderBufferDirect(N,null,O,g,v,null),p.uniforms.shadow_pass.value=C.mapPass.texture,p.uniforms.resolution.value=C.mapSize,p.uniforms.radius.value=C.radius,t.setRenderTarget(C.map),t.clear(),t.renderBufferDirect(N,null,O,p,v,null)}function w(C,N,O,k){let j=null;const B=O.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(B!==void 0)j=B;else if(j=O.isPointLight===!0?c:l,t.localClippingEnabled&&N.clipShadows===!0&&Array.isArray(N.clippingPlanes)&&N.clippingPlanes.length!==0||N.displacementMap&&N.displacementScale!==0||N.alphaMap&&N.alphaTest>0||N.map&&N.alphaTest>0||N.alphaToCoverage===!0){const L=j.uuid,K=N.uuid;let R=u[L];R===void 0&&(R={},u[L]=R);let q=R[K];q===void 0&&(q=j.clone(),R[K]=q,N.addEventListener("dispose",T)),j=q}if(j.visible=N.visible,j.wireframe=N.wireframe,k===pc?j.side=N.shadowSide!==null?N.shadowSide:N.side:j.side=N.shadowSide!==null?N.shadowSide:f[N.side],j.alphaMap=N.alphaMap,j.alphaTest=N.alphaToCoverage===!0?.5:N.alphaTest,j.map=N.map,j.clipShadows=N.clipShadows,j.clippingPlanes=N.clippingPlanes,j.clipIntersection=N.clipIntersection,j.displacementMap=N.displacementMap,j.displacementScale=N.displacementScale,j.displacementBias=N.displacementBias,j.wireframeLinewidth=N.wireframeLinewidth,j.linewidth=N.linewidth,O.isPointLight===!0&&j.isMeshDistanceMaterial===!0){const L=t.properties.get(j);L.light=O}return j}function A(C,N,O,k,j){if(C.visible===!1)return;if(C.layers.test(N.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&j===pc)&&(!C.frustumCulled||r.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(O.matrixWorldInverse,C.matrixWorld);const K=e.update(C),R=C.material;if(Array.isArray(R)){const q=K.groups;for(let W=0,$=q.length;W<$;W++){const J=q[W],ee=R[J.materialIndex];if(ee&&ee.visible){const Q=w(C,ee,k,j);C.onBeforeShadow(t,C,N,O,K,Q,J),t.renderBufferDirect(O,null,K,Q,C,J),C.onAfterShadow(t,C,N,O,K,Q,J)}}}else if(R.visible){const q=w(C,R,k,j);C.onBeforeShadow(t,C,N,O,K,q,null),t.renderBufferDirect(O,null,K,q,C,null),C.onAfterShadow(t,C,N,O,K,q,null)}}const L=C.children;for(let K=0,R=L.length;K<R;K++)A(L[K],N,O,k,j)}function T(C){C.target.removeEventListener("dispose",T);for(const O in u){const k=u[O],j=C.target.uuid;j in k&&(k[j].dispose(),delete k[j])}}}const bDe={[cP]:uP,[dP]:mP,[hP]:pP,[Fp]:fP,[uP]:cP,[mP]:dP,[pP]:hP,[fP]:Fp};function yDe(t,e){function n(){let me=!1;const nt=new ci;let xe=null;const He=new ci(0,0,0,0);return{setMask:function(Pe){xe!==Pe&&!me&&(t.colorMask(Pe,Pe,Pe,Pe),xe=Pe)},setLocked:function(Pe){me=Pe},setClear:function(Pe,we,Ae,lt,_t){_t===!0&&(Pe*=lt,we*=lt,Ae*=lt),nt.set(Pe,we,Ae,lt),He.equals(nt)===!1&&(t.clearColor(Pe,we,Ae,lt),He.copy(nt))},reset:function(){me=!1,xe=null,He.set(-1,0,0,0)}}}function r(){let me=!1,nt=!1,xe=null,He=null,Pe=null;return{setReversed:function(we){if(nt!==we){const Ae=e.get("EXT_clip_control");we?Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.ZERO_TO_ONE_EXT):Ae.clipControlEXT(Ae.LOWER_LEFT_EXT,Ae.NEGATIVE_ONE_TO_ONE_EXT),nt=we;const lt=Pe;Pe=null,this.setClear(lt)}},getReversed:function(){return nt},setTest:function(we){we?ge(t.DEPTH_TEST):Ee(t.DEPTH_TEST)},setMask:function(we){xe!==we&&!me&&(t.depthMask(we),xe=we)},setFunc:function(we){if(nt&&(we=bDe[we]),He!==we){switch(we){case cP:t.depthFunc(t.NEVER);break;case uP:t.depthFunc(t.ALWAYS);break;case dP:t.depthFunc(t.LESS);break;case Fp:t.depthFunc(t.LEQUAL);break;case hP:t.depthFunc(t.EQUAL);break;case fP:t.depthFunc(t.GEQUAL);break;case mP:t.depthFunc(t.GREATER);break;case pP:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}He=we}},setLocked:function(we){me=we},setClear:function(we){Pe!==we&&(nt&&(we=1-we),t.clearDepth(we),Pe=we)},reset:function(){me=!1,xe=null,He=null,Pe=null,nt=!1}}}function i(){let me=!1,nt=null,xe=null,He=null,Pe=null,we=null,Ae=null,lt=null,_t=null;return{setTest:function(Xe){me||(Xe?ge(t.STENCIL_TEST):Ee(t.STENCIL_TEST))},setMask:function(Xe){nt!==Xe&&!me&&(t.stencilMask(Xe),nt=Xe)},setFunc:function(Xe,Ut,Ct){(xe!==Xe||He!==Ut||Pe!==Ct)&&(t.stencilFunc(Xe,Ut,Ct),xe=Xe,He=Ut,Pe=Ct)},setOp:function(Xe,Ut,Ct){(we!==Xe||Ae!==Ut||lt!==Ct)&&(t.stencilOp(Xe,Ut,Ct),we=Xe,Ae=Ut,lt=Ct)},setLocked:function(Xe){me=Xe},setClear:function(Xe){_t!==Xe&&(t.clearStencil(Xe),_t=Xe)},reset:function(){me=!1,nt=null,xe=null,He=null,Pe=null,we=null,Ae=null,lt=null,_t=null}}}const a=new n,s=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},g=new WeakMap,p=[],x=null,v=!1,y=null,b=null,E=null,w=null,A=null,T=null,C=null,N=new Tn(0,0,0),O=0,k=!1,j=null,B=null,L=null,K=null,R=null;const q=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let W=!1,$=0;const J=t.getParameter(t.VERSION);J.indexOf("WebGL")!==-1?($=parseFloat(/^WebGL (\d)/.exec(J)[1]),W=$>=1):J.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(J)[1]),W=$>=2);let ee=null,Q={};const z=t.getParameter(t.SCISSOR_BOX),V=t.getParameter(t.VIEWPORT),X=new ci().fromArray(z),te=new ci().fromArray(V);function ie(me,nt,xe,He){const Pe=new Uint8Array(4),we=t.createTexture();t.bindTexture(me,we),t.texParameteri(me,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(me,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Ae=0;Ae<xe;Ae++)me===t.TEXTURE_3D||me===t.TEXTURE_2D_ARRAY?t.texImage3D(nt,0,t.RGBA,1,1,He,0,t.RGBA,t.UNSIGNED_BYTE,Pe):t.texImage2D(nt+Ae,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Pe);return we}const le={};le[t.TEXTURE_2D]=ie(t.TEXTURE_2D,t.TEXTURE_2D,1),le[t.TEXTURE_CUBE_MAP]=ie(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),le[t.TEXTURE_2D_ARRAY]=ie(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),le[t.TEXTURE_3D]=ie(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),l.setClear(0),ge(t.DEPTH_TEST),s.setFunc(Fp),re(!1),G(hH),ge(t.CULL_FACE),U(Dc);function ge(me){d[me]!==!0&&(t.enable(me),d[me]=!0)}function Ee(me){d[me]!==!1&&(t.disable(me),d[me]=!1)}function pe(me,nt){return f[me]!==nt?(t.bindFramebuffer(me,nt),f[me]=nt,me===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=nt),me===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=nt),!0):!1}function de(me,nt){let xe=p,He=!1;if(me){xe=g.get(nt),xe===void 0&&(xe=[],g.set(nt,xe));const Pe=me.textures;if(xe.length!==Pe.length||xe[0]!==t.COLOR_ATTACHMENT0){for(let we=0,Ae=Pe.length;we<Ae;we++)xe[we]=t.COLOR_ATTACHMENT0+we;xe.length=Pe.length,He=!0}}else xe[0]!==t.BACK&&(xe[0]=t.BACK,He=!0);He&&t.drawBuffers(xe)}function Re(me){return x!==me?(t.useProgram(me),x=me,!0):!1}const fe={[yh]:t.FUNC_ADD,[bCe]:t.FUNC_SUBTRACT,[yCe]:t.FUNC_REVERSE_SUBTRACT};fe[vCe]=t.MIN,fe[_Ce]=t.MAX;const Fe={[wCe]:t.ZERO,[SCe]:t.ONE,[MCe]:t.SRC_COLOR,[oP]:t.SRC_ALPHA,[kCe]:t.SRC_ALPHA_SATURATE,[NCe]:t.DST_COLOR,[ACe]:t.DST_ALPHA,[ECe]:t.ONE_MINUS_SRC_COLOR,[lP]:t.ONE_MINUS_SRC_ALPHA,[CCe]:t.ONE_MINUS_DST_COLOR,[TCe]:t.ONE_MINUS_DST_ALPHA,[PCe]:t.CONSTANT_COLOR,[jCe]:t.ONE_MINUS_CONSTANT_COLOR,[RCe]:t.CONSTANT_ALPHA,[DCe]:t.ONE_MINUS_CONSTANT_ALPHA};function U(me,nt,xe,He,Pe,we,Ae,lt,_t,Xe){if(me===Dc){v===!0&&(Ee(t.BLEND),v=!1);return}if(v===!1&&(ge(t.BLEND),v=!0),me!==xCe){if(me!==y||Xe!==k){if((b!==yh||A!==yh)&&(t.blendEquation(t.FUNC_ADD),b=yh,A=yh),Xe)switch(me){case gp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case fH:t.blendFunc(t.ONE,t.ONE);break;case mH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case pH:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Qr("WebGLState: Invalid blending: ",me);break}else switch(me){case gp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case fH:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case mH:Qr("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case pH:Qr("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Qr("WebGLState: Invalid blending: ",me);break}E=null,w=null,T=null,C=null,N.set(0,0,0),O=0,y=me,k=Xe}return}Pe=Pe||nt,we=we||xe,Ae=Ae||He,(nt!==b||Pe!==A)&&(t.blendEquationSeparate(fe[nt],fe[Pe]),b=nt,A=Pe),(xe!==E||He!==w||we!==T||Ae!==C)&&(t.blendFuncSeparate(Fe[xe],Fe[He],Fe[we],Fe[Ae]),E=xe,w=He,T=we,C=Ae),(lt.equals(N)===!1||_t!==O)&&(t.blendColor(lt.r,lt.g,lt.b,_t),N.copy(lt),O=_t),y=me,k=!1}function H(me,nt){me.side===dl?Ee(t.CULL_FACE):ge(t.CULL_FACE);let xe=me.side===ts;nt&&(xe=!xe),re(xe),me.blending===gp&&me.transparent===!1?U(Dc):U(me.blending,me.blendEquation,me.blendSrc,me.blendDst,me.blendEquationAlpha,me.blendSrcAlpha,me.blendDstAlpha,me.blendColor,me.blendAlpha,me.premultipliedAlpha),s.setFunc(me.depthFunc),s.setTest(me.depthTest),s.setMask(me.depthWrite),a.setMask(me.colorWrite);const He=me.stencilWrite;l.setTest(He),He&&(l.setMask(me.stencilWriteMask),l.setFunc(me.stencilFunc,me.stencilRef,me.stencilFuncMask),l.setOp(me.stencilFail,me.stencilZFail,me.stencilZPass)),oe(me.polygonOffset,me.polygonOffsetFactor,me.polygonOffsetUnits),me.alphaToCoverage===!0?ge(t.SAMPLE_ALPHA_TO_COVERAGE):Ee(t.SAMPLE_ALPHA_TO_COVERAGE)}function re(me){j!==me&&(me?t.frontFace(t.CW):t.frontFace(t.CCW),j=me)}function G(me){me!==mCe?(ge(t.CULL_FACE),me!==B&&(me===hH?t.cullFace(t.BACK):me===pCe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ee(t.CULL_FACE),B=me}function Z(me){me!==L&&(W&&t.lineWidth(me),L=me)}function oe(me,nt,xe){me?(ge(t.POLYGON_OFFSET_FILL),(K!==nt||R!==xe)&&(t.polygonOffset(nt,xe),K=nt,R=xe)):Ee(t.POLYGON_OFFSET_FILL)}function be(me){me?ge(t.SCISSOR_TEST):Ee(t.SCISSOR_TEST)}function Te(me){me===void 0&&(me=t.TEXTURE0+q-1),ee!==me&&(t.activeTexture(me),ee=me)}function Me(me,nt,xe){xe===void 0&&(ee===null?xe=t.TEXTURE0+q-1:xe=ee);let He=Q[xe];He===void 0&&(He={type:void 0,texture:void 0},Q[xe]=He),(He.type!==me||He.texture!==nt)&&(ee!==xe&&(t.activeTexture(xe),ee=xe),t.bindTexture(me,nt||le[me]),He.type=me,He.texture=nt)}function F(){const me=Q[ee];me!==void 0&&me.type!==void 0&&(t.bindTexture(me.type,null),me.type=void 0,me.texture=void 0)}function I(){try{t.compressedTexImage2D(...arguments)}catch(me){me("WebGLState:",me)}}function ne(){try{t.compressedTexImage3D(...arguments)}catch(me){me("WebGLState:",me)}}function ve(){try{t.texSubImage2D(...arguments)}catch(me){me("WebGLState:",me)}}function Se(){try{t.texSubImage3D(...arguments)}catch(me){me("WebGLState:",me)}}function ye(){try{t.compressedTexSubImage2D(...arguments)}catch(me){me("WebGLState:",me)}}function Ke(){try{t.compressedTexSubImage3D(...arguments)}catch(me){me("WebGLState:",me)}}function We(){try{t.texStorage2D(...arguments)}catch(me){me("WebGLState:",me)}}function qe(){try{t.texStorage3D(...arguments)}catch(me){me("WebGLState:",me)}}function ut(){try{t.texImage2D(...arguments)}catch(me){me("WebGLState:",me)}}function ue(){try{t.texImage3D(...arguments)}catch(me){me("WebGLState:",me)}}function se(me){X.equals(me)===!1&&(t.scissor(me.x,me.y,me.z,me.w),X.copy(me))}function Ve(me){te.equals(me)===!1&&(t.viewport(me.x,me.y,me.z,me.w),te.copy(me))}function Be(me,nt){let xe=u.get(nt);xe===void 0&&(xe=new WeakMap,u.set(nt,xe));let He=xe.get(me);He===void 0&&(He=t.getUniformBlockIndex(nt,me.name),xe.set(me,He))}function Ze(me,nt){const He=u.get(nt).get(me);c.get(nt)!==He&&(t.uniformBlockBinding(nt,He,me.__bindingPointIndex),c.set(nt,He))}function ht(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),s.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},ee=null,Q={},f={},g=new WeakMap,p=[],x=null,v=!1,y=null,b=null,E=null,w=null,A=null,T=null,C=null,N=new Tn(0,0,0),O=0,k=!1,j=null,B=null,L=null,K=null,R=null,X.set(0,0,t.canvas.width,t.canvas.height),te.set(0,0,t.canvas.width,t.canvas.height),a.reset(),s.reset(),l.reset()}return{buffers:{color:a,depth:s,stencil:l},enable:ge,disable:Ee,bindFramebuffer:pe,drawBuffers:de,useProgram:Re,setBlending:U,setMaterial:H,setFlipSided:re,setCullFace:G,setLineWidth:Z,setPolygonOffset:oe,setScissorTest:be,activeTexture:Te,bindTexture:Me,unbindTexture:F,compressedTexImage2D:I,compressedTexImage3D:ne,texImage2D:ut,texImage3D:ue,updateUBOMapping:Be,uniformBlockBinding:Ze,texStorage2D:We,texStorage3D:qe,texSubImage2D:ve,texSubImage3D:Se,compressedTexSubImage2D:ye,compressedTexSubImage3D:Ke,scissor:se,viewport:Ve,reset:ht}}function vDe(t,e,n,r,i,a,s){const l=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),u=new fn,d=new WeakMap;let f;const g=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(F,I){return p?new OffscreenCanvas(F,I):Gw("canvas")}function v(F,I,ne){let ve=1;const Se=Me(F);if((Se.width>ne||Se.height>ne)&&(ve=ne/Math.max(Se.width,Se.height)),ve<1)if(typeof HTMLImageElement<"u"&&F instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&F instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&F instanceof ImageBitmap||typeof VideoFrame<"u"&&F instanceof VideoFrame){const ye=Math.floor(ve*Se.width),Ke=Math.floor(ve*Se.height);f===void 0&&(f=x(ye,Ke));const We=I?x(ye,Ke):f;return We.width=ye,We.height=Ke,We.getContext("2d").drawImage(F,0,0,ye,Ke),en("WebGLRenderer: Texture has been resized from ("+Se.width+"x"+Se.height+") to ("+ye+"x"+Ke+")."),We}else return"data"in F&&en("WebGLRenderer: Image in DataTexture is too big ("+Se.width+"x"+Se.height+")."),F;return F}function y(F){return F.generateMipmaps}function b(F){t.generateMipmap(F)}function E(F){return F.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:F.isWebGL3DRenderTarget?t.TEXTURE_3D:F.isWebGLArrayRenderTarget||F.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function w(F,I,ne,ve,Se=!1){if(F!==null){if(t[F]!==void 0)return t[F];en("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+F+"'")}let ye=I;if(I===t.RED&&(ne===t.FLOAT&&(ye=t.R32F),ne===t.HALF_FLOAT&&(ye=t.R16F),ne===t.UNSIGNED_BYTE&&(ye=t.R8)),I===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ye=t.R8UI),ne===t.UNSIGNED_SHORT&&(ye=t.R16UI),ne===t.UNSIGNED_INT&&(ye=t.R32UI),ne===t.BYTE&&(ye=t.R8I),ne===t.SHORT&&(ye=t.R16I),ne===t.INT&&(ye=t.R32I)),I===t.RG&&(ne===t.FLOAT&&(ye=t.RG32F),ne===t.HALF_FLOAT&&(ye=t.RG16F),ne===t.UNSIGNED_BYTE&&(ye=t.RG8)),I===t.RG_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ye=t.RG8UI),ne===t.UNSIGNED_SHORT&&(ye=t.RG16UI),ne===t.UNSIGNED_INT&&(ye=t.RG32UI),ne===t.BYTE&&(ye=t.RG8I),ne===t.SHORT&&(ye=t.RG16I),ne===t.INT&&(ye=t.RG32I)),I===t.RGB_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ye=t.RGB8UI),ne===t.UNSIGNED_SHORT&&(ye=t.RGB16UI),ne===t.UNSIGNED_INT&&(ye=t.RGB32UI),ne===t.BYTE&&(ye=t.RGB8I),ne===t.SHORT&&(ye=t.RGB16I),ne===t.INT&&(ye=t.RGB32I)),I===t.RGBA_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ye=t.RGBA8UI),ne===t.UNSIGNED_SHORT&&(ye=t.RGBA16UI),ne===t.UNSIGNED_INT&&(ye=t.RGBA32UI),ne===t.BYTE&&(ye=t.RGBA8I),ne===t.SHORT&&(ye=t.RGBA16I),ne===t.INT&&(ye=t.RGBA32I)),I===t.RGB&&(ne===t.UNSIGNED_INT_5_9_9_9_REV&&(ye=t.RGB9_E5),ne===t.UNSIGNED_INT_10F_11F_11F_REV&&(ye=t.R11F_G11F_B10F)),I===t.RGBA){const Ke=Se?$w:Ln.getTransfer(ve);ne===t.FLOAT&&(ye=t.RGBA32F),ne===t.HALF_FLOAT&&(ye=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(ye=Ke===ar?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(ye=t.RGBA4),ne===t.UNSIGNED_SHORT_5_5_5_1&&(ye=t.RGB5_A1)}return(ye===t.R16F||ye===t.R32F||ye===t.RG16F||ye===t.RG32F||ye===t.RGBA16F||ye===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ye}function A(F,I){let ne;return F?I===null||I===mf||I===eb?ne=t.DEPTH24_STENCIL8:I===Nc?ne=t.DEPTH32F_STENCIL8:I===J0&&(ne=t.DEPTH24_STENCIL8,en("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):I===null||I===mf||I===eb?ne=t.DEPTH_COMPONENT24:I===Nc?ne=t.DEPTH_COMPONENT32F:I===J0&&(ne=t.DEPTH_COMPONENT16),ne}function T(F,I){return y(F)===!0||F.isFramebufferTexture&&F.minFilter!==ks&&F.minFilter!==oo?Math.log2(Math.max(I.width,I.height))+1:F.mipmaps!==void 0&&F.mipmaps.length>0?F.mipmaps.length:F.isCompressedTexture&&Array.isArray(F.image)?I.mipmaps.length:1}function C(F){const I=F.target;I.removeEventListener("dispose",C),O(I),I.isVideoTexture&&d.delete(I)}function N(F){const I=F.target;I.removeEventListener("dispose",N),j(I)}function O(F){const I=r.get(F);if(I.__webglInit===void 0)return;const ne=F.source,ve=g.get(ne);if(ve){const Se=ve[I.__cacheKey];Se.usedTimes--,Se.usedTimes===0&&k(F),Object.keys(ve).length===0&&g.delete(ne)}r.remove(F)}function k(F){const I=r.get(F);t.deleteTexture(I.__webglTexture);const ne=F.source,ve=g.get(ne);delete ve[I.__cacheKey],s.memory.textures--}function j(F){const I=r.get(F);if(F.depthTexture&&(F.depthTexture.dispose(),r.remove(F.depthTexture)),F.isWebGLCubeRenderTarget)for(let ve=0;ve<6;ve++){if(Array.isArray(I.__webglFramebuffer[ve]))for(let Se=0;Se<I.__webglFramebuffer[ve].length;Se++)t.deleteFramebuffer(I.__webglFramebuffer[ve][Se]);else t.deleteFramebuffer(I.__webglFramebuffer[ve]);I.__webglDepthbuffer&&t.deleteRenderbuffer(I.__webglDepthbuffer[ve])}else{if(Array.isArray(I.__webglFramebuffer))for(let ve=0;ve<I.__webglFramebuffer.length;ve++)t.deleteFramebuffer(I.__webglFramebuffer[ve]);else t.deleteFramebuffer(I.__webglFramebuffer);if(I.__webglDepthbuffer&&t.deleteRenderbuffer(I.__webglDepthbuffer),I.__webglMultisampledFramebuffer&&t.deleteFramebuffer(I.__webglMultisampledFramebuffer),I.__webglColorRenderbuffer)for(let ve=0;ve<I.__webglColorRenderbuffer.length;ve++)I.__webglColorRenderbuffer[ve]&&t.deleteRenderbuffer(I.__webglColorRenderbuffer[ve]);I.__webglDepthRenderbuffer&&t.deleteRenderbuffer(I.__webglDepthRenderbuffer)}const ne=F.textures;for(let ve=0,Se=ne.length;ve<Se;ve++){const ye=r.get(ne[ve]);ye.__webglTexture&&(t.deleteTexture(ye.__webglTexture),s.memory.textures--),r.remove(ne[ve])}r.remove(F)}let B=0;function L(){B=0}function K(){const F=B;return F>=i.maxTextures&&en("WebGLTextures: Trying to use "+F+" texture units while this GPU supports only "+i.maxTextures),B+=1,F}function R(F){const I=[];return I.push(F.wrapS),I.push(F.wrapT),I.push(F.wrapR||0),I.push(F.magFilter),I.push(F.minFilter),I.push(F.anisotropy),I.push(F.internalFormat),I.push(F.format),I.push(F.type),I.push(F.generateMipmaps),I.push(F.premultiplyAlpha),I.push(F.flipY),I.push(F.unpackAlignment),I.push(F.colorSpace),I.join()}function q(F,I){const ne=r.get(F);if(F.isVideoTexture&&be(F),F.isRenderTargetTexture===!1&&F.isExternalTexture!==!0&&F.version>0&&ne.__version!==F.version){const ve=F.image;if(ve===null)en("WebGLRenderer: Texture marked for update but no image data found.");else if(ve.complete===!1)en("WebGLRenderer: Texture marked for update but image is incomplete");else{le(ne,F,I);return}}else F.isExternalTexture&&(ne.__webglTexture=F.sourceTexture?F.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+I)}function W(F,I){const ne=r.get(F);if(F.isRenderTargetTexture===!1&&F.version>0&&ne.__version!==F.version){le(ne,F,I);return}else F.isExternalTexture&&(ne.__webglTexture=F.sourceTexture?F.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+I)}function $(F,I){const ne=r.get(F);if(F.isRenderTargetTexture===!1&&F.version>0&&ne.__version!==F.version){le(ne,F,I);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+I)}function J(F,I){const ne=r.get(F);if(F.version>0&&ne.__version!==F.version){ge(ne,F,I);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+I)}const ee={[bP]:t.REPEAT,[Tc]:t.CLAMP_TO_EDGE,[yP]:t.MIRRORED_REPEAT},Q={[ks]:t.NEAREST,[VCe]:t.NEAREST_MIPMAP_NEAREST,[Kv]:t.NEAREST_MIPMAP_LINEAR,[oo]:t.LINEAR,[RN]:t.LINEAR_MIPMAP_NEAREST,[Ch]:t.LINEAR_MIPMAP_LINEAR},z={[KCe]:t.NEVER,[eke]:t.ALWAYS,[XCe]:t.LESS,[MZ]:t.LEQUAL,[YCe]:t.EQUAL,[JCe]:t.GEQUAL,[ZCe]:t.GREATER,[QCe]:t.NOTEQUAL};function V(F,I){if(I.type===Nc&&e.has("OES_texture_float_linear")===!1&&(I.magFilter===oo||I.magFilter===RN||I.magFilter===Kv||I.magFilter===Ch||I.minFilter===oo||I.minFilter===RN||I.minFilter===Kv||I.minFilter===Ch)&&en("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(F,t.TEXTURE_WRAP_S,ee[I.wrapS]),t.texParameteri(F,t.TEXTURE_WRAP_T,ee[I.wrapT]),(F===t.TEXTURE_3D||F===t.TEXTURE_2D_ARRAY)&&t.texParameteri(F,t.TEXTURE_WRAP_R,ee[I.wrapR]),t.texParameteri(F,t.TEXTURE_MAG_FILTER,Q[I.magFilter]),t.texParameteri(F,t.TEXTURE_MIN_FILTER,Q[I.minFilter]),I.compareFunction&&(t.texParameteri(F,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(F,t.TEXTURE_COMPARE_FUNC,z[I.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(I.magFilter===ks||I.minFilter!==Kv&&I.minFilter!==Ch||I.type===Nc&&e.has("OES_texture_float_linear")===!1)return;if(I.anisotropy>1||r.get(I).__currentAnisotropy){const ne=e.get("EXT_texture_filter_anisotropic");t.texParameterf(F,ne.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,i.getMaxAnisotropy())),r.get(I).__currentAnisotropy=I.anisotropy}}}function X(F,I){let ne=!1;F.__webglInit===void 0&&(F.__webglInit=!0,I.addEventListener("dispose",C));const ve=I.source;let Se=g.get(ve);Se===void 0&&(Se={},g.set(ve,Se));const ye=R(I);if(ye!==F.__cacheKey){Se[ye]===void 0&&(Se[ye]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,ne=!0),Se[ye].usedTimes++;const Ke=Se[F.__cacheKey];Ke!==void 0&&(Se[F.__cacheKey].usedTimes--,Ke.usedTimes===0&&k(I)),F.__cacheKey=ye,F.__webglTexture=Se[ye].texture}return ne}function te(F,I,ne){return Math.floor(Math.floor(F/ne)/I)}function ie(F,I,ne,ve){const ye=F.updateRanges;if(ye.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,I.width,I.height,ne,ve,I.data);else{ye.sort((ue,se)=>ue.start-se.start);let Ke=0;for(let ue=1;ue<ye.length;ue++){const se=ye[Ke],Ve=ye[ue],Be=se.start+se.count,Ze=te(Ve.start,I.width,4),ht=te(se.start,I.width,4);Ve.start<=Be+1&&Ze===ht&&te(Ve.start+Ve.count-1,I.width,4)===Ze?se.count=Math.max(se.count,Ve.start+Ve.count-se.start):(++Ke,ye[Ke]=Ve)}ye.length=Ke+1;const We=t.getParameter(t.UNPACK_ROW_LENGTH),qe=t.getParameter(t.UNPACK_SKIP_PIXELS),ut=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,I.width);for(let ue=0,se=ye.length;ue<se;ue++){const Ve=ye[ue],Be=Math.floor(Ve.start/4),Ze=Math.ceil(Ve.count/4),ht=Be%I.width,me=Math.floor(Be/I.width),nt=Ze,xe=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ht),t.pixelStorei(t.UNPACK_SKIP_ROWS,me),n.texSubImage2D(t.TEXTURE_2D,0,ht,me,nt,xe,ne,ve,I.data)}F.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,We),t.pixelStorei(t.UNPACK_SKIP_PIXELS,qe),t.pixelStorei(t.UNPACK_SKIP_ROWS,ut)}}function le(F,I,ne){let ve=t.TEXTURE_2D;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(ve=t.TEXTURE_2D_ARRAY),I.isData3DTexture&&(ve=t.TEXTURE_3D);const Se=X(F,I),ye=I.source;n.bindTexture(ve,F.__webglTexture,t.TEXTURE0+ne);const Ke=r.get(ye);if(ye.version!==Ke.__version||Se===!0){n.activeTexture(t.TEXTURE0+ne);const We=Ln.getPrimaries(Ln.workingColorSpace),qe=I.colorSpace===Yu?null:Ln.getPrimaries(I.colorSpace),ut=I.colorSpace===Yu||We===qe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ut);let ue=v(I.image,!1,i.maxTextureSize);ue=Te(I,ue);const se=a.convert(I.format,I.colorSpace),Ve=a.convert(I.type);let Be=w(I.internalFormat,se,Ve,I.colorSpace,I.isVideoTexture);V(ve,I);let Ze;const ht=I.mipmaps,me=I.isVideoTexture!==!0,nt=Ke.__version===void 0||Se===!0,xe=ye.dataReady,He=T(I,ue);if(I.isDepthTexture)Be=A(I.format===nb,I.type),nt&&(me?n.texStorage2D(t.TEXTURE_2D,1,Be,ue.width,ue.height):n.texImage2D(t.TEXTURE_2D,0,Be,ue.width,ue.height,0,se,Ve,null));else if(I.isDataTexture)if(ht.length>0){me&&nt&&n.texStorage2D(t.TEXTURE_2D,He,Be,ht[0].width,ht[0].height);for(let Pe=0,we=ht.length;Pe<we;Pe++)Ze=ht[Pe],me?xe&&n.texSubImage2D(t.TEXTURE_2D,Pe,0,0,Ze.width,Ze.height,se,Ve,Ze.data):n.texImage2D(t.TEXTURE_2D,Pe,Be,Ze.width,Ze.height,0,se,Ve,Ze.data);I.generateMipmaps=!1}else me?(nt&&n.texStorage2D(t.TEXTURE_2D,He,Be,ue.width,ue.height),xe&&ie(I,ue,se,Ve)):n.texImage2D(t.TEXTURE_2D,0,Be,ue.width,ue.height,0,se,Ve,ue.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){me&&nt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,He,Be,ht[0].width,ht[0].height,ue.depth);for(let Pe=0,we=ht.length;Pe<we;Pe++)if(Ze=ht[Pe],I.format!==Fo)if(se!==null)if(me){if(xe)if(I.layerUpdates.size>0){const Ae=GH(Ze.width,Ze.height,I.format,I.type);for(const lt of I.layerUpdates){const _t=Ze.data.subarray(lt*Ae/Ze.data.BYTES_PER_ELEMENT,(lt+1)*Ae/Ze.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Pe,0,0,lt,Ze.width,Ze.height,1,se,_t)}I.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Pe,0,0,0,Ze.width,Ze.height,ue.depth,se,Ze.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Pe,Be,Ze.width,Ze.height,ue.depth,0,Ze.data,0,0);else en("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else me?xe&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Pe,0,0,0,Ze.width,Ze.height,ue.depth,se,Ve,Ze.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Pe,Be,Ze.width,Ze.height,ue.depth,0,se,Ve,Ze.data)}else{me&&nt&&n.texStorage2D(t.TEXTURE_2D,He,Be,ht[0].width,ht[0].height);for(let Pe=0,we=ht.length;Pe<we;Pe++)Ze=ht[Pe],I.format!==Fo?se!==null?me?xe&&n.compressedTexSubImage2D(t.TEXTURE_2D,Pe,0,0,Ze.width,Ze.height,se,Ze.data):n.compressedTexImage2D(t.TEXTURE_2D,Pe,Be,Ze.width,Ze.height,0,Ze.data):en("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):me?xe&&n.texSubImage2D(t.TEXTURE_2D,Pe,0,0,Ze.width,Ze.height,se,Ve,Ze.data):n.texImage2D(t.TEXTURE_2D,Pe,Be,Ze.width,Ze.height,0,se,Ve,Ze.data)}else if(I.isDataArrayTexture)if(me){if(nt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,He,Be,ue.width,ue.height,ue.depth),xe)if(I.layerUpdates.size>0){const Pe=GH(ue.width,ue.height,I.format,I.type);for(const we of I.layerUpdates){const Ae=ue.data.subarray(we*Pe/ue.data.BYTES_PER_ELEMENT,(we+1)*Pe/ue.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,we,ue.width,ue.height,1,se,Ve,Ae)}I.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ue.width,ue.height,ue.depth,se,Ve,ue.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Be,ue.width,ue.height,ue.depth,0,se,Ve,ue.data);else if(I.isData3DTexture)me?(nt&&n.texStorage3D(t.TEXTURE_3D,He,Be,ue.width,ue.height,ue.depth),xe&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ue.width,ue.height,ue.depth,se,Ve,ue.data)):n.texImage3D(t.TEXTURE_3D,0,Be,ue.width,ue.height,ue.depth,0,se,Ve,ue.data);else if(I.isFramebufferTexture){if(nt)if(me)n.texStorage2D(t.TEXTURE_2D,He,Be,ue.width,ue.height);else{let Pe=ue.width,we=ue.height;for(let Ae=0;Ae<He;Ae++)n.texImage2D(t.TEXTURE_2D,Ae,Be,Pe,we,0,se,Ve,null),Pe>>=1,we>>=1}}else if(ht.length>0){if(me&&nt){const Pe=Me(ht[0]);n.texStorage2D(t.TEXTURE_2D,He,Be,Pe.width,Pe.height)}for(let Pe=0,we=ht.length;Pe<we;Pe++)Ze=ht[Pe],me?xe&&n.texSubImage2D(t.TEXTURE_2D,Pe,0,0,se,Ve,Ze):n.texImage2D(t.TEXTURE_2D,Pe,Be,se,Ve,Ze);I.generateMipmaps=!1}else if(me){if(nt){const Pe=Me(ue);n.texStorage2D(t.TEXTURE_2D,He,Be,Pe.width,Pe.height)}xe&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,se,Ve,ue)}else n.texImage2D(t.TEXTURE_2D,0,Be,se,Ve,ue);y(I)&&b(ve),Ke.__version=ye.version,I.onUpdate&&I.onUpdate(I)}F.__version=I.version}function ge(F,I,ne){if(I.image.length!==6)return;const ve=X(F,I),Se=I.source;n.bindTexture(t.TEXTURE_CUBE_MAP,F.__webglTexture,t.TEXTURE0+ne);const ye=r.get(Se);if(Se.version!==ye.__version||ve===!0){n.activeTexture(t.TEXTURE0+ne);const Ke=Ln.getPrimaries(Ln.workingColorSpace),We=I.colorSpace===Yu?null:Ln.getPrimaries(I.colorSpace),qe=I.colorSpace===Yu||Ke===We?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,qe);const ut=I.isCompressedTexture||I.image[0].isCompressedTexture,ue=I.image[0]&&I.image[0].isDataTexture,se=[];for(let we=0;we<6;we++)!ut&&!ue?se[we]=v(I.image[we],!0,i.maxCubemapSize):se[we]=ue?I.image[we].image:I.image[we],se[we]=Te(I,se[we]);const Ve=se[0],Be=a.convert(I.format,I.colorSpace),Ze=a.convert(I.type),ht=w(I.internalFormat,Be,Ze,I.colorSpace),me=I.isVideoTexture!==!0,nt=ye.__version===void 0||ve===!0,xe=Se.dataReady;let He=T(I,Ve);V(t.TEXTURE_CUBE_MAP,I);let Pe;if(ut){me&&nt&&n.texStorage2D(t.TEXTURE_CUBE_MAP,He,ht,Ve.width,Ve.height);for(let we=0;we<6;we++){Pe=se[we].mipmaps;for(let Ae=0;Ae<Pe.length;Ae++){const lt=Pe[Ae];I.format!==Fo?Be!==null?me?xe&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae,0,0,lt.width,lt.height,Be,lt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae,ht,lt.width,lt.height,0,lt.data):en("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):me?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae,0,0,lt.width,lt.height,Be,Ze,lt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae,ht,lt.width,lt.height,0,Be,Ze,lt.data)}}}else{if(Pe=I.mipmaps,me&&nt){Pe.length>0&&He++;const we=Me(se[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,He,ht,we.width,we.height)}for(let we=0;we<6;we++)if(ue){me?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,se[we].width,se[we].height,Be,Ze,se[we].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,ht,se[we].width,se[we].height,0,Be,Ze,se[we].data);for(let Ae=0;Ae<Pe.length;Ae++){const _t=Pe[Ae].image[we].image;me?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae+1,0,0,_t.width,_t.height,Be,Ze,_t.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae+1,ht,_t.width,_t.height,0,Be,Ze,_t.data)}}else{me?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,Be,Ze,se[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,ht,Be,Ze,se[we]);for(let Ae=0;Ae<Pe.length;Ae++){const lt=Pe[Ae];me?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae+1,0,0,Be,Ze,lt.image[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae+1,ht,Be,Ze,lt.image[we])}}}y(I)&&b(t.TEXTURE_CUBE_MAP),ye.__version=Se.version,I.onUpdate&&I.onUpdate(I)}F.__version=I.version}function Ee(F,I,ne,ve,Se,ye){const Ke=a.convert(ne.format,ne.colorSpace),We=a.convert(ne.type),qe=w(ne.internalFormat,Ke,We,ne.colorSpace),ut=r.get(I),ue=r.get(ne);if(ue.__renderTarget=I,!ut.__hasExternalTextures){const se=Math.max(1,I.width>>ye),Ve=Math.max(1,I.height>>ye);Se===t.TEXTURE_3D||Se===t.TEXTURE_2D_ARRAY?n.texImage3D(Se,ye,qe,se,Ve,I.depth,0,Ke,We,null):n.texImage2D(Se,ye,qe,se,Ve,0,Ke,We,null)}n.bindFramebuffer(t.FRAMEBUFFER,F),oe(I)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ve,Se,ue.__webglTexture,0,Z(I)):(Se===t.TEXTURE_2D||Se>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Se<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ve,Se,ue.__webglTexture,ye),n.bindFramebuffer(t.FRAMEBUFFER,null)}function pe(F,I,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,F),I.depthBuffer){const ve=I.depthTexture,Se=ve&&ve.isDepthTexture?ve.type:null,ye=A(I.stencilBuffer,Se),Ke=I.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,We=Z(I);oe(I)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,We,ye,I.width,I.height):ne?t.renderbufferStorageMultisample(t.RENDERBUFFER,We,ye,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,ye,I.width,I.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,Ke,t.RENDERBUFFER,F)}else{const ve=I.textures;for(let Se=0;Se<ve.length;Se++){const ye=ve[Se],Ke=a.convert(ye.format,ye.colorSpace),We=a.convert(ye.type),qe=w(ye.internalFormat,Ke,We,ye.colorSpace),ut=Z(I);ne&&oe(I)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ut,qe,I.width,I.height):oe(I)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ut,qe,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,qe,I.width,I.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function de(F,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,F),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ve=r.get(I.depthTexture);ve.__renderTarget=I,(!ve.__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),q(I.depthTexture,0);const Se=ve.__webglTexture,ye=Z(I);if(I.depthTexture.format===tb)oe(I)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Se,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Se,0);else if(I.depthTexture.format===nb)oe(I)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Se,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Se,0);else throw new Error("Unknown depthTexture format")}function Re(F){const I=r.get(F),ne=F.isWebGLCubeRenderTarget===!0;if(I.__boundDepthTexture!==F.depthTexture){const ve=F.depthTexture;if(I.__depthDisposeCallback&&I.__depthDisposeCallback(),ve){const Se=()=>{delete I.__boundDepthTexture,delete I.__depthDisposeCallback,ve.removeEventListener("dispose",Se)};ve.addEventListener("dispose",Se),I.__depthDisposeCallback=Se}I.__boundDepthTexture=ve}if(F.depthTexture&&!I.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");const ve=F.texture.mipmaps;ve&&ve.length>0?de(I.__webglFramebuffer[0],F):de(I.__webglFramebuffer,F)}else if(ne){I.__webglDepthbuffer=[];for(let ve=0;ve<6;ve++)if(n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer[ve]),I.__webglDepthbuffer[ve]===void 0)I.__webglDepthbuffer[ve]=t.createRenderbuffer(),pe(I.__webglDepthbuffer[ve],F,!1);else{const Se=F.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ye=I.__webglDepthbuffer[ve];t.bindRenderbuffer(t.RENDERBUFFER,ye),t.framebufferRenderbuffer(t.FRAMEBUFFER,Se,t.RENDERBUFFER,ye)}}else{const ve=F.texture.mipmaps;if(ve&&ve.length>0?n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer),I.__webglDepthbuffer===void 0)I.__webglDepthbuffer=t.createRenderbuffer(),pe(I.__webglDepthbuffer,F,!1);else{const Se=F.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ye=I.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ye),t.framebufferRenderbuffer(t.FRAMEBUFFER,Se,t.RENDERBUFFER,ye)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function fe(F,I,ne){const ve=r.get(F);I!==void 0&&Ee(ve.__webglFramebuffer,F,F.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&Re(F)}function Fe(F){const I=F.texture,ne=r.get(F),ve=r.get(I);F.addEventListener("dispose",N);const Se=F.textures,ye=F.isWebGLCubeRenderTarget===!0,Ke=Se.length>1;if(Ke||(ve.__webglTexture===void 0&&(ve.__webglTexture=t.createTexture()),ve.__version=I.version,s.memory.textures++),ye){ne.__webglFramebuffer=[];for(let We=0;We<6;We++)if(I.mipmaps&&I.mipmaps.length>0){ne.__webglFramebuffer[We]=[];for(let qe=0;qe<I.mipmaps.length;qe++)ne.__webglFramebuffer[We][qe]=t.createFramebuffer()}else ne.__webglFramebuffer[We]=t.createFramebuffer()}else{if(I.mipmaps&&I.mipmaps.length>0){ne.__webglFramebuffer=[];for(let We=0;We<I.mipmaps.length;We++)ne.__webglFramebuffer[We]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if(Ke)for(let We=0,qe=Se.length;We<qe;We++){const ut=r.get(Se[We]);ut.__webglTexture===void 0&&(ut.__webglTexture=t.createTexture(),s.memory.textures++)}if(F.samples>0&&oe(F)===!1){ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let We=0;We<Se.length;We++){const qe=Se[We];ne.__webglColorRenderbuffer[We]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[We]);const ut=a.convert(qe.format,qe.colorSpace),ue=a.convert(qe.type),se=w(qe.internalFormat,ut,ue,qe.colorSpace,F.isXRRenderTarget===!0),Ve=Z(F);t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,se,F.width,F.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+We,t.RENDERBUFFER,ne.__webglColorRenderbuffer[We])}t.bindRenderbuffer(t.RENDERBUFFER,null),F.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),pe(ne.__webglDepthRenderbuffer,F,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ye){n.bindTexture(t.TEXTURE_CUBE_MAP,ve.__webglTexture),V(t.TEXTURE_CUBE_MAP,I);for(let We=0;We<6;We++)if(I.mipmaps&&I.mipmaps.length>0)for(let qe=0;qe<I.mipmaps.length;qe++)Ee(ne.__webglFramebuffer[We][qe],F,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+We,qe);else Ee(ne.__webglFramebuffer[We],F,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+We,0);y(I)&&b(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(Ke){for(let We=0,qe=Se.length;We<qe;We++){const ut=Se[We],ue=r.get(ut);let se=t.TEXTURE_2D;(F.isWebGL3DRenderTarget||F.isWebGLArrayRenderTarget)&&(se=F.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(se,ue.__webglTexture),V(se,ut),Ee(ne.__webglFramebuffer,F,ut,t.COLOR_ATTACHMENT0+We,se,0),y(ut)&&b(se)}n.unbindTexture()}else{let We=t.TEXTURE_2D;if((F.isWebGL3DRenderTarget||F.isWebGLArrayRenderTarget)&&(We=F.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(We,ve.__webglTexture),V(We,I),I.mipmaps&&I.mipmaps.length>0)for(let qe=0;qe<I.mipmaps.length;qe++)Ee(ne.__webglFramebuffer[qe],F,I,t.COLOR_ATTACHMENT0,We,qe);else Ee(ne.__webglFramebuffer,F,I,t.COLOR_ATTACHMENT0,We,0);y(I)&&b(We),n.unbindTexture()}F.depthBuffer&&Re(F)}function U(F){const I=F.textures;for(let ne=0,ve=I.length;ne<ve;ne++){const Se=I[ne];if(y(Se)){const ye=E(F),Ke=r.get(Se).__webglTexture;n.bindTexture(ye,Ke),b(ye),n.unbindTexture()}}}const H=[],re=[];function G(F){if(F.samples>0){if(oe(F)===!1){const I=F.textures,ne=F.width,ve=F.height;let Se=t.COLOR_BUFFER_BIT;const ye=F.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ke=r.get(F),We=I.length>1;if(We)for(let ut=0;ut<I.length;ut++)n.bindFramebuffer(t.FRAMEBUFFER,Ke.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ke.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ke.__webglMultisampledFramebuffer);const qe=F.texture.mipmaps;qe&&qe.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ke.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ke.__webglFramebuffer);for(let ut=0;ut<I.length;ut++){if(F.resolveDepthBuffer&&(F.depthBuffer&&(Se|=t.DEPTH_BUFFER_BIT),F.stencilBuffer&&F.resolveStencilBuffer&&(Se|=t.STENCIL_BUFFER_BIT)),We){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ke.__webglColorRenderbuffer[ut]);const ue=r.get(I[ut]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ue,0)}t.blitFramebuffer(0,0,ne,ve,0,0,ne,ve,Se,t.NEAREST),c===!0&&(H.length=0,re.length=0,H.push(t.COLOR_ATTACHMENT0+ut),F.depthBuffer&&F.resolveDepthBuffer===!1&&(H.push(ye),re.push(ye),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,re)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,H))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),We)for(let ut=0;ut<I.length;ut++){n.bindFramebuffer(t.FRAMEBUFFER,Ke.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.RENDERBUFFER,Ke.__webglColorRenderbuffer[ut]);const ue=r.get(I[ut]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ke.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.TEXTURE_2D,ue,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ke.__webglMultisampledFramebuffer)}else if(F.depthBuffer&&F.resolveDepthBuffer===!1&&c){const I=F.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[I])}}}function Z(F){return Math.min(i.maxSamples,F.samples)}function oe(F){const I=r.get(F);return F.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function be(F){const I=s.render.frame;d.get(F)!==I&&(d.set(F,I),F.update())}function Te(F,I){const ne=F.colorSpace,ve=F.format,Se=F.type;return F.isCompressedTexture===!0||F.isVideoTexture===!0||ne!==Bp&&ne!==Yu&&(Ln.getTransfer(ne)===ar?(ve!==Fo||Se!==Al)&&en("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Qr("WebGLTextures: Unsupported texture color space:",ne)),I}function Me(F){return typeof HTMLImageElement<"u"&&F instanceof HTMLImageElement?(u.width=F.naturalWidth||F.width,u.height=F.naturalHeight||F.height):typeof VideoFrame<"u"&&F instanceof VideoFrame?(u.width=F.displayWidth,u.height=F.displayHeight):(u.width=F.width,u.height=F.height),u}this.allocateTextureUnit=K,this.resetTextureUnits=L,this.setTexture2D=q,this.setTexture2DArray=W,this.setTexture3D=$,this.setTextureCube=J,this.rebindTextures=fe,this.setupRenderTarget=Fe,this.updateRenderTargetMipmap=U,this.updateMultisampleRenderTarget=G,this.setupDepthRenderbuffer=Re,this.setupFrameBufferTexture=Ee,this.useMultisampledRTT=oe}function _De(t,e){function n(r,i=Yu){let a;const s=Ln.getTransfer(i);if(r===Al)return t.UNSIGNED_BYTE;if(r===AO)return t.UNSIGNED_SHORT_4_4_4_4;if(r===TO)return t.UNSIGNED_SHORT_5_5_5_1;if(r===bZ)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===yZ)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===gZ)return t.BYTE;if(r===xZ)return t.SHORT;if(r===J0)return t.UNSIGNED_SHORT;if(r===EO)return t.INT;if(r===mf)return t.UNSIGNED_INT;if(r===Nc)return t.FLOAT;if(r===yg)return t.HALF_FLOAT;if(r===vZ)return t.ALPHA;if(r===_Z)return t.RGB;if(r===Fo)return t.RGBA;if(r===tb)return t.DEPTH_COMPONENT;if(r===nb)return t.DEPTH_STENCIL;if(r===wZ)return t.RED;if(r===NO)return t.RED_INTEGER;if(r===CO)return t.RG;if(r===kO)return t.RG_INTEGER;if(r===PO)return t.RGBA_INTEGER;if(r===v1||r===_1||r===w1||r===S1)if(s===ar)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===v1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===_1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===w1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===S1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===v1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===_1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===w1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===S1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===vP||r===_P||r===wP||r===SP)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===vP)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===_P)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===wP)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===SP)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===MP||r===EP||r===AP)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===MP||r===EP)return s===ar?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===AP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===TP||r===NP||r===CP||r===kP||r===PP||r===jP||r===RP||r===DP||r===OP||r===LP||r===IP||r===FP||r===UP||r===zP)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===TP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===NP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===CP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===kP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===PP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===jP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===RP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===DP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===OP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===LP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===IP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===FP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===UP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===zP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===BP||r===HP||r===$P)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===BP)return s===ar?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===HP)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===$P)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===VP||r===GP||r===WP||r===qP)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===VP)return a.COMPRESSED_RED_RGTC1_EXT;if(r===GP)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===WP)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===qP)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===eb?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const wDe=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,SDe=`
- uniform sampler2DArray depthColor;
- uniform float depthWidth;
- uniform float depthHeight;
- void main() {
- vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
- if ( coord.x >= 1.0 ) {
- gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
- } else {
- gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
- }
- }`;class MDe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new $Z(e.texture);(e.depthNear!==n.depthNear||e.depthFar!==n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const n=e.cameras[0].viewport,r=new Xc({vertexShader:wDe,fragmentShader:SDe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Tl(new IO(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let EDe=class extends Nf{constructor(e,n){super();const r=this;let i=null,a=1,s=null,l="local-floor",c=1,u=null,d=null,f=null,g=null,p=null,x=null;const v=typeof XRWebGLBinding<"u",y=new MDe,b={},E=n.getContextAttributes();let w=null,A=null;const T=[],C=[],N=new fn;let O=null;const k=new to;k.viewport=new ci;const j=new to;j.viewport=new ci;const B=[k,j],L=new Hke;let K=null,R=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(le){let ge=T[le];return ge===void 0&&(ge=new tC,T[le]=ge),ge.getTargetRaySpace()},this.getControllerGrip=function(le){let ge=T[le];return ge===void 0&&(ge=new tC,T[le]=ge),ge.getGripSpace()},this.getHand=function(le){let ge=T[le];return ge===void 0&&(ge=new tC,T[le]=ge),ge.getHandSpace()};function q(le){const ge=C.indexOf(le.inputSource);if(ge===-1)return;const Ee=T[ge];Ee!==void 0&&(Ee.update(le.inputSource,le.frame,u||s),Ee.dispatchEvent({type:le.type,data:le.inputSource}))}function W(){i.removeEventListener("select",q),i.removeEventListener("selectstart",q),i.removeEventListener("selectend",q),i.removeEventListener("squeeze",q),i.removeEventListener("squeezestart",q),i.removeEventListener("squeezeend",q),i.removeEventListener("end",W),i.removeEventListener("inputsourceschange",$);for(let le=0;le<T.length;le++){const ge=C[le];ge!==null&&(C[le]=null,T[le].disconnect(ge))}K=null,R=null,y.reset();for(const le in b)delete b[le];e.setRenderTarget(w),p=null,g=null,f=null,i=null,A=null,ie.stop(),r.isPresenting=!1,e.setPixelRatio(O),e.setSize(N.width,N.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(le){a=le,r.isPresenting===!0&&en("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(le){l=le,r.isPresenting===!0&&en("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||s},this.setReferenceSpace=function(le){u=le},this.getBaseLayer=function(){return g!==null?g:p},this.getBinding=function(){return f===null&&v&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(le){if(i=le,i!==null){if(w=e.getRenderTarget(),i.addEventListener("select",q),i.addEventListener("selectstart",q),i.addEventListener("selectend",q),i.addEventListener("squeeze",q),i.addEventListener("squeezestart",q),i.addEventListener("squeezeend",q),i.addEventListener("end",W),i.addEventListener("inputsourceschange",$),E.xrCompatible!==!0&&await n.makeXRCompatible(),O=e.getPixelRatio(),e.getSize(N),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ee=null,pe=null,de=null;E.depth&&(de=E.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ee=E.stencil?nb:tb,pe=E.stencil?eb:mf);const Re={colorFormat:n.RGBA8,depthFormat:de,scaleFactor:a};f=this.getBinding(),g=f.createProjectionLayer(Re),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),A=new gf(g.textureWidth,g.textureHeight,{format:Fo,type:Al,depthTexture:new HZ(g.textureWidth,g.textureHeight,pe,void 0,void 0,void 0,void 0,void 0,void 0,Ee),stencilBuffer:E.stencil,colorSpace:e.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const Ee={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,Ee),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),A=new gf(p.framebufferWidth,p.framebufferHeight,{format:Fo,type:Al,colorSpace:e.outputColorSpace,stencilBuffer:E.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(c),u=null,s=await i.requestReferenceSpace(l),ie.setContext(i),ie.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return y.getDepthTexture()};function $(le){for(let ge=0;ge<le.removed.length;ge++){const Ee=le.removed[ge],pe=C.indexOf(Ee);pe>=0&&(C[pe]=null,T[pe].disconnect(Ee))}for(let ge=0;ge<le.added.length;ge++){const Ee=le.added[ge];let pe=C.indexOf(Ee);if(pe===-1){for(let Re=0;Re<T.length;Re++)if(Re>=C.length){C.push(Ee),pe=Re;break}else if(C[Re]===null){C[Re]=Ee,pe=Re;break}if(pe===-1)break}const de=T[pe];de&&de.connect(Ee)}}const J=new at,ee=new at;function Q(le,ge,Ee){J.setFromMatrixPosition(ge.matrixWorld),ee.setFromMatrixPosition(Ee.matrixWorld);const pe=J.distanceTo(ee),de=ge.projectionMatrix.elements,Re=Ee.projectionMatrix.elements,fe=de[14]/(de[10]-1),Fe=de[14]/(de[10]+1),U=(de[9]+1)/de[5],H=(de[9]-1)/de[5],re=(de[8]-1)/de[0],G=(Re[8]+1)/Re[0],Z=fe*re,oe=fe*G,be=pe/(-re+G),Te=be*-re;if(ge.matrixWorld.decompose(le.position,le.quaternion,le.scale),le.translateX(Te),le.translateZ(be),le.matrixWorld.compose(le.position,le.quaternion,le.scale),le.matrixWorldInverse.copy(le.matrixWorld).invert(),de[10]===-1)le.projectionMatrix.copy(ge.projectionMatrix),le.projectionMatrixInverse.copy(ge.projectionMatrixInverse);else{const Me=fe+be,F=Fe+be,I=Z-Te,ne=oe+(pe-Te),ve=U*Fe/F*Me,Se=H*Fe/F*Me;le.projectionMatrix.makePerspective(I,ne,ve,Se,Me,F),le.projectionMatrixInverse.copy(le.projectionMatrix).invert()}}function z(le,ge){ge===null?le.matrixWorld.copy(le.matrix):le.matrixWorld.multiplyMatrices(ge.matrixWorld,le.matrix),le.matrixWorldInverse.copy(le.matrixWorld).invert()}this.updateCamera=function(le){if(i===null)return;let ge=le.near,Ee=le.far;y.texture!==null&&(y.depthNear>0&&(ge=y.depthNear),y.depthFar>0&&(Ee=y.depthFar)),L.near=j.near=k.near=ge,L.far=j.far=k.far=Ee,(K!==L.near||R!==L.far)&&(i.updateRenderState({depthNear:L.near,depthFar:L.far}),K=L.near,R=L.far),L.layers.mask=le.layers.mask|6,k.layers.mask=L.layers.mask&3,j.layers.mask=L.layers.mask&5;const pe=le.parent,de=L.cameras;z(L,pe);for(let Re=0;Re<de.length;Re++)z(de[Re],pe);de.length===2?Q(L,k,j):L.projectionMatrix.copy(k.projectionMatrix),V(le,L,pe)};function V(le,ge,Ee){Ee===null?le.matrix.copy(ge.matrixWorld):(le.matrix.copy(Ee.matrixWorld),le.matrix.invert(),le.matrix.multiply(ge.matrixWorld)),le.matrix.decompose(le.position,le.quaternion,le.scale),le.updateMatrixWorld(!0),le.projectionMatrix.copy(ge.projectionMatrix),le.projectionMatrixInverse.copy(ge.projectionMatrixInverse),le.isPerspectiveCamera&&(le.fov=KP*2*Math.atan(1/le.projectionMatrix.elements[5]),le.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(g===null&&p===null))return c},this.setFoveation=function(le){c=le,g!==null&&(g.fixedFoveation=le),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=le)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(L)},this.getCameraTexture=function(le){return b[le]};let X=null;function te(le,ge){if(d=ge.getViewerPose(u||s),x=ge,d!==null){const Ee=d.views;p!==null&&(e.setRenderTargetFramebuffer(A,p.framebuffer),e.setRenderTarget(A));let pe=!1;Ee.length!==L.cameras.length&&(L.cameras.length=0,pe=!0);for(let Fe=0;Fe<Ee.length;Fe++){const U=Ee[Fe];let H=null;if(p!==null)H=p.getViewport(U);else{const G=f.getViewSubImage(g,U);H=G.viewport,Fe===0&&(e.setRenderTargetTextures(A,G.colorTexture,G.depthStencilTexture),e.setRenderTarget(A))}let re=B[Fe];re===void 0&&(re=new to,re.layers.enable(Fe),re.viewport=new ci,B[Fe]=re),re.matrix.fromArray(U.transform.matrix),re.matrix.decompose(re.position,re.quaternion,re.scale),re.projectionMatrix.fromArray(U.projectionMatrix),re.projectionMatrixInverse.copy(re.projectionMatrix).invert(),re.viewport.set(H.x,H.y,H.width,H.height),Fe===0&&(L.matrix.copy(re.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),pe===!0&&L.cameras.push(re)}const de=i.enabledFeatures;if(de&&de.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){f=r.getBinding();const Fe=f.getDepthInformation(Ee[0]);Fe&&Fe.isValid&&Fe.texture&&y.init(Fe,i.renderState)}if(de&&de.includes("camera-access")&&v){e.state.unbindTexture(),f=r.getBinding();for(let Fe=0;Fe<Ee.length;Fe++){const U=Ee[Fe].camera;if(U){let H=b[U];H||(H=new $Z,b[U]=H);const re=f.getCameraImage(U);H.sourceTexture=re}}}}for(let Ee=0;Ee<T.length;Ee++){const pe=C[Ee],de=T[Ee];pe!==null&&de!==void 0&&de.update(pe,ge,u||s)}X&&X(le,ge),ge.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ge}),x=null}const ie=new qZ;ie.setAnimationLoop(te),this.setAnimationLoop=function(le){X=le},this.dispose=function(){}}};const ah=new Ed,ADe=new fi;function TDe(t,e){function n(y,b){y.matrixAutoUpdate===!0&&y.updateMatrix(),b.value.copy(y.matrix)}function r(y,b){b.color.getRGB(y.fogColor.value,FZ(t)),b.isFog?(y.fogNear.value=b.near,y.fogFar.value=b.far):b.isFogExp2&&(y.fogDensity.value=b.density)}function i(y,b,E,w,A){b.isMeshBasicMaterial||b.isMeshLambertMaterial?a(y,b):b.isMeshToonMaterial?(a(y,b),f(y,b)):b.isMeshPhongMaterial?(a(y,b),d(y,b)):b.isMeshStandardMaterial?(a(y,b),g(y,b),b.isMeshPhysicalMaterial&&p(y,b,A)):b.isMeshMatcapMaterial?(a(y,b),x(y,b)):b.isMeshDepthMaterial?a(y,b):b.isMeshDistanceMaterial?(a(y,b),v(y,b)):b.isMeshNormalMaterial?a(y,b):b.isLineBasicMaterial?(s(y,b),b.isLineDashedMaterial&&l(y,b)):b.isPointsMaterial?c(y,b,E,w):b.isSpriteMaterial?u(y,b):b.isShadowMaterial?(y.color.value.copy(b.color),y.opacity.value=b.opacity):b.isShaderMaterial&&(b.uniformsNeedUpdate=!1)}function a(y,b){y.opacity.value=b.opacity,b.color&&y.diffuse.value.copy(b.color),b.emissive&&y.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity),b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.bumpMap&&(y.bumpMap.value=b.bumpMap,n(b.bumpMap,y.bumpMapTransform),y.bumpScale.value=b.bumpScale,b.side===ts&&(y.bumpScale.value*=-1)),b.normalMap&&(y.normalMap.value=b.normalMap,n(b.normalMap,y.normalMapTransform),y.normalScale.value.copy(b.normalScale),b.side===ts&&y.normalScale.value.negate()),b.displacementMap&&(y.displacementMap.value=b.displacementMap,n(b.displacementMap,y.displacementMapTransform),y.displacementScale.value=b.displacementScale,y.displacementBias.value=b.displacementBias),b.emissiveMap&&(y.emissiveMap.value=b.emissiveMap,n(b.emissiveMap,y.emissiveMapTransform)),b.specularMap&&(y.specularMap.value=b.specularMap,n(b.specularMap,y.specularMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest);const E=e.get(b),w=E.envMap,A=E.envMapRotation;w&&(y.envMap.value=w,ah.copy(A),ah.x*=-1,ah.y*=-1,ah.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(ah.y*=-1,ah.z*=-1),y.envMapRotation.value.setFromMatrix4(ADe.makeRotationFromEuler(ah)),y.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=b.reflectivity,y.ior.value=b.ior,y.refractionRatio.value=b.refractionRatio),b.lightMap&&(y.lightMap.value=b.lightMap,y.lightMapIntensity.value=b.lightMapIntensity,n(b.lightMap,y.lightMapTransform)),b.aoMap&&(y.aoMap.value=b.aoMap,y.aoMapIntensity.value=b.aoMapIntensity,n(b.aoMap,y.aoMapTransform))}function s(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform))}function l(y,b){y.dashSize.value=b.dashSize,y.totalSize.value=b.dashSize+b.gapSize,y.scale.value=b.scale}function c(y,b,E,w){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.size.value=b.size*E,y.scale.value=w*.5,b.map&&(y.map.value=b.map,n(b.map,y.uvTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function u(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.rotation.value=b.rotation,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function d(y,b){y.specular.value.copy(b.specular),y.shininess.value=Math.max(b.shininess,1e-4)}function f(y,b){b.gradientMap&&(y.gradientMap.value=b.gradientMap)}function g(y,b){y.metalness.value=b.metalness,b.metalnessMap&&(y.metalnessMap.value=b.metalnessMap,n(b.metalnessMap,y.metalnessMapTransform)),y.roughness.value=b.roughness,b.roughnessMap&&(y.roughnessMap.value=b.roughnessMap,n(b.roughnessMap,y.roughnessMapTransform)),b.envMap&&(y.envMapIntensity.value=b.envMapIntensity)}function p(y,b,E){y.ior.value=b.ior,b.sheen>0&&(y.sheenColor.value.copy(b.sheenColor).multiplyScalar(b.sheen),y.sheenRoughness.value=b.sheenRoughness,b.sheenColorMap&&(y.sheenColorMap.value=b.sheenColorMap,n(b.sheenColorMap,y.sheenColorMapTransform)),b.sheenRoughnessMap&&(y.sheenRoughnessMap.value=b.sheenRoughnessMap,n(b.sheenRoughnessMap,y.sheenRoughnessMapTransform))),b.clearcoat>0&&(y.clearcoat.value=b.clearcoat,y.clearcoatRoughness.value=b.clearcoatRoughness,b.clearcoatMap&&(y.clearcoatMap.value=b.clearcoatMap,n(b.clearcoatMap,y.clearcoatMapTransform)),b.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=b.clearcoatRoughnessMap,n(b.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),b.clearcoatNormalMap&&(y.clearcoatNormalMap.value=b.clearcoatNormalMap,n(b.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(b.clearcoatNormalScale),b.side===ts&&y.clearcoatNormalScale.value.negate())),b.dispersion>0&&(y.dispersion.value=b.dispersion),b.iridescence>0&&(y.iridescence.value=b.iridescence,y.iridescenceIOR.value=b.iridescenceIOR,y.iridescenceThicknessMinimum.value=b.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=b.iridescenceThicknessRange[1],b.iridescenceMap&&(y.iridescenceMap.value=b.iridescenceMap,n(b.iridescenceMap,y.iridescenceMapTransform)),b.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=b.iridescenceThicknessMap,n(b.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),b.transmission>0&&(y.transmission.value=b.transmission,y.transmissionSamplerMap.value=E.texture,y.transmissionSamplerSize.value.set(E.width,E.height),b.transmissionMap&&(y.transmissionMap.value=b.transmissionMap,n(b.transmissionMap,y.transmissionMapTransform)),y.thickness.value=b.thickness,b.thicknessMap&&(y.thicknessMap.value=b.thicknessMap,n(b.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=b.attenuationDistance,y.attenuationColor.value.copy(b.attenuationColor)),b.anisotropy>0&&(y.anisotropyVector.value.set(b.anisotropy*Math.cos(b.anisotropyRotation),b.anisotropy*Math.sin(b.anisotropyRotation)),b.anisotropyMap&&(y.anisotropyMap.value=b.anisotropyMap,n(b.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=b.specularIntensity,y.specularColor.value.copy(b.specularColor),b.specularColorMap&&(y.specularColorMap.value=b.specularColorMap,n(b.specularColorMap,y.specularColorMapTransform)),b.specularIntensityMap&&(y.specularIntensityMap.value=b.specularIntensityMap,n(b.specularIntensityMap,y.specularIntensityMapTransform))}function x(y,b){b.matcap&&(y.matcap.value=b.matcap)}function v(y,b){const E=e.get(b).light;y.referencePosition.value.setFromMatrixPosition(E.matrixWorld),y.nearDistance.value=E.shadow.camera.near,y.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function NDe(t,e,n,r){let i={},a={},s=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(E,w){const A=w.program;r.uniformBlockBinding(E,A)}function u(E,w){let A=i[E.id];A===void 0&&(x(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",y));const T=w.program;r.updateUBOMapping(E,T);const C=e.render.frame;a[E.id]!==C&&(g(E),a[E.id]=C)}function d(E){const w=f();E.__bindingPointIndex=w;const A=t.createBuffer(),T=E.__size,C=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,A),A}function f(){for(let E=0;E<l;E++)if(s.indexOf(E)===-1)return s.push(E),E;return Qr("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(E){const w=i[E.id],A=E.uniforms,T=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let C=0,N=A.length;C<N;C++){const O=Array.isArray(A[C])?A[C]:[A[C]];for(let k=0,j=O.length;k<j;k++){const B=O[k];if(p(B,C,k,T)===!0){const L=B.__offset,K=Array.isArray(B.value)?B.value:[B.value];let R=0;for(let q=0;q<K.length;q++){const W=K[q],$=v(W);typeof W=="number"||typeof W=="boolean"?(B.__data[0]=W,t.bufferSubData(t.UNIFORM_BUFFER,L+R,B.__data)):W.isMatrix3?(B.__data[0]=W.elements[0],B.__data[1]=W.elements[1],B.__data[2]=W.elements[2],B.__data[3]=0,B.__data[4]=W.elements[3],B.__data[5]=W.elements[4],B.__data[6]=W.elements[5],B.__data[7]=0,B.__data[8]=W.elements[6],B.__data[9]=W.elements[7],B.__data[10]=W.elements[8],B.__data[11]=0):(W.toArray(B.__data,R),R+=$.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,L,B.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(E,w,A,T){const C=E.value,N=w+"_"+A;if(T[N]===void 0)return typeof C=="number"||typeof C=="boolean"?T[N]=C:T[N]=C.clone(),!0;{const O=T[N];if(typeof C=="number"||typeof C=="boolean"){if(O!==C)return T[N]=C,!0}else if(O.equals(C)===!1)return O.copy(C),!0}return!1}function x(E){const w=E.uniforms;let A=0;const T=16;for(let N=0,O=w.length;N<O;N++){const k=Array.isArray(w[N])?w[N]:[w[N]];for(let j=0,B=k.length;j<B;j++){const L=k[j],K=Array.isArray(L.value)?L.value:[L.value];for(let R=0,q=K.length;R<q;R++){const W=K[R],$=v(W),J=A%T,ee=J%$.boundary,Q=J+ee;A+=ee,Q!==0&&T-Q<$.storage&&(A+=T-Q),L.__data=new Float32Array($.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=A,A+=$.storage}}}const C=A%T;return C>0&&(A+=T-C),E.__size=A,E.__cache={},this}function v(E){const w={boundary:0,storage:0};return typeof E=="number"||typeof E=="boolean"?(w.boundary=4,w.storage=4):E.isVector2?(w.boundary=8,w.storage=8):E.isVector3||E.isColor?(w.boundary=16,w.storage=12):E.isVector4?(w.boundary=16,w.storage=16):E.isMatrix3?(w.boundary=48,w.storage=48):E.isMatrix4?(w.boundary=64,w.storage=64):E.isTexture?en("WebGLRenderer: Texture samplers can not be part of an uniforms group."):en("WebGLRenderer: Unsupported uniform value type.",E),w}function y(E){const w=E.target;w.removeEventListener("dispose",y);const A=s.indexOf(w.__bindingPointIndex);s.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function b(){for(const E in i)t.deleteBuffer(i[E]);s=[],i={},a={}}return{bind:c,update:u,dispose:b}}const CDe=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let sc=null;function kDe(){return sc===null&&(sc=new kke(CDe,32,32,CO,yg),sc.minFilter=oo,sc.magFilter=oo,sc.wrapS=Tc,sc.wrapT=Tc,sc.generateMipmaps=!1,sc.needsUpdate=!0),sc}let PDe=class{constructor(e={}){const{canvas:n=tke(),context:r=null,depth:i=!0,stencil:a=!1,alpha:s=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:g=!1}=e;this.isWebGLRenderer=!0;let p;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=r.getContextAttributes().alpha}else p=s;const x=new Set([PO,kO,NO]),v=new Set([Al,mf,J0,eb,AO,TO]),y=new Uint32Array(4),b=new Int32Array(4);let E=null,w=null;const A=[],T=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ld,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let N=!1;this._outputColorSpace=Qs;let O=0,k=0,j=null,B=-1,L=null;const K=new ci,R=new ci;let q=null;const W=new Tn(0);let $=0,J=n.width,ee=n.height,Q=1,z=null,V=null;const X=new ci(0,0,J,ee),te=new ci(0,0,J,ee);let ie=!1;const le=new LO;let ge=!1,Ee=!1;const pe=new fi,de=new at,Re=new ci,fe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Fe=!1;function U(){return j===null?Q:1}let H=r;function re(ae,Ne){return n.getContext(ae,Ne)}try{const ae={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${SO}`),n.addEventListener("webglcontextlost",Pe,!1),n.addEventListener("webglcontextrestored",we,!1),n.addEventListener("webglcontextcreationerror",Ae,!1),H===null){const Ne="webgl2";if(H=re(Ne,ae),H===null)throw re(Ne)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(ae){throw ae("WebGLRenderer: "+ae.message),ae}let G,Z,oe,be,Te,Me,F,I,ne,ve,Se,ye,Ke,We,qe,ut,ue,se,Ve,Be,Ze,ht,me,nt;function xe(){G=new Uje(H),G.init(),ht=new _De(H,G),Z=new kje(H,G,e,ht),oe=new yDe(H,G),Z.reversedDepthBuffer&&g&&oe.buffers.depth.setReversed(!0),be=new Hje(H),Te=new sDe,Me=new vDe(H,G,oe,Te,Z,ht,be),F=new jje(C),I=new Fje(C),ne=new Wke(H),me=new Nje(H,ne),ve=new zje(H,ne,be,me),Se=new Vje(H,ve,ne,be),Ve=new $je(H,Z,Me),ut=new Pje(Te),ye=new aDe(C,F,I,G,Z,me,ut),Ke=new TDe(C,Te),We=new lDe,qe=new mDe(G),se=new Tje(C,F,I,oe,Se,p,c),ue=new xDe(C,Se,Z),nt=new NDe(H,be,Z,oe),Be=new Cje(H,G,be),Ze=new Bje(H,G,be),be.programs=ye.programs,C.capabilities=Z,C.extensions=G,C.properties=Te,C.renderLists=We,C.shadowMap=ue,C.state=oe,C.info=be}xe();const He=new EDe(C,H);this.xr=He,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){const ae=G.get("WEBGL_lose_context");ae&&ae.loseContext()},this.forceContextRestore=function(){const ae=G.get("WEBGL_lose_context");ae&&ae.restoreContext()},this.getPixelRatio=function(){return Q},this.setPixelRatio=function(ae){ae!==void 0&&(Q=ae,this.setSize(J,ee,!1))},this.getSize=function(ae){return ae.set(J,ee)},this.setSize=function(ae,Ne,Ue=!0){if(He.isPresenting){en("WebGLRenderer: Can't change size while VR device is presenting.");return}J=ae,ee=Ne,n.width=Math.floor(ae*Q),n.height=Math.floor(Ne*Q),Ue===!0&&(n.style.width=ae+"px",n.style.height=Ne+"px"),this.setViewport(0,0,ae,Ne)},this.getDrawingBufferSize=function(ae){return ae.set(J*Q,ee*Q).floor()},this.setDrawingBufferSize=function(ae,Ne,Ue){J=ae,ee=Ne,Q=Ue,n.width=Math.floor(ae*Ue),n.height=Math.floor(Ne*Ue),this.setViewport(0,0,ae,Ne)},this.getCurrentViewport=function(ae){return ae.copy(K)},this.getViewport=function(ae){return ae.copy(X)},this.setViewport=function(ae,Ne,Ue,Ie){ae.isVector4?X.set(ae.x,ae.y,ae.z,ae.w):X.set(ae,Ne,Ue,Ie),oe.viewport(K.copy(X).multiplyScalar(Q).round())},this.getScissor=function(ae){return ae.copy(te)},this.setScissor=function(ae,Ne,Ue,Ie){ae.isVector4?te.set(ae.x,ae.y,ae.z,ae.w):te.set(ae,Ne,Ue,Ie),oe.scissor(R.copy(te).multiplyScalar(Q).round())},this.getScissorTest=function(){return ie},this.setScissorTest=function(ae){oe.setScissorTest(ie=ae)},this.setOpaqueSort=function(ae){z=ae},this.setTransparentSort=function(ae){V=ae},this.getClearColor=function(ae){return ae.copy(se.getClearColor())},this.setClearColor=function(){se.setClearColor(...arguments)},this.getClearAlpha=function(){return se.getClearAlpha()},this.setClearAlpha=function(){se.setClearAlpha(...arguments)},this.clear=function(ae=!0,Ne=!0,Ue=!0){let Ie=0;if(ae){let je=!1;if(j!==null){const ct=j.texture.format;je=x.has(ct)}if(je){const ct=j.texture.type,xt=v.has(ct),Tt=se.getClearColor(),Et=se.getClearAlpha(),Ft=Tt.r,Pt=Tt.g,wt=Tt.b;xt?(y[0]=Ft,y[1]=Pt,y[2]=wt,y[3]=Et,H.clearBufferuiv(H.COLOR,0,y)):(b[0]=Ft,b[1]=Pt,b[2]=wt,b[3]=Et,H.clearBufferiv(H.COLOR,0,b))}else Ie|=H.COLOR_BUFFER_BIT}Ne&&(Ie|=H.DEPTH_BUFFER_BIT),Ue&&(Ie|=H.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H.clear(Ie)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Pe,!1),n.removeEventListener("webglcontextrestored",we,!1),n.removeEventListener("webglcontextcreationerror",Ae,!1),se.dispose(),We.dispose(),qe.dispose(),Te.dispose(),F.dispose(),I.dispose(),Se.dispose(),me.dispose(),nt.dispose(),ye.dispose(),He.dispose(),He.removeEventListener("sessionstart",gn),He.removeEventListener("sessionend",Fn),It.stop()};function Pe(ae){ae.preventDefault(),vH("WebGLRenderer: Context Lost."),N=!0}function we(){vH("WebGLRenderer: Context Restored."),N=!1;const ae=be.autoReset,Ne=ue.enabled,Ue=ue.autoUpdate,Ie=ue.needsUpdate,je=ue.type;xe(),be.autoReset=ae,ue.enabled=Ne,ue.autoUpdate=Ue,ue.needsUpdate=Ie,ue.type=je}function Ae(ae){Qr("WebGLRenderer: A WebGL context could not be created. Reason: ",ae.statusMessage)}function lt(ae){const Ne=ae.target;Ne.removeEventListener("dispose",lt),_t(Ne)}function _t(ae){Xe(ae),Te.remove(ae)}function Xe(ae){const Ne=Te.get(ae).programs;Ne!==void 0&&(Ne.forEach(function(Ue){ye.releaseProgram(Ue)}),ae.isShaderMaterial&&ye.releaseShaderCache(ae))}this.renderBufferDirect=function(ae,Ne,Ue,Ie,je,ct){Ne===null&&(Ne=fe);const xt=je.isMesh&&je.matrixWorld.determinant()<0,Tt=he(ae,Ne,Ue,Ie,je);oe.setMaterial(Ie,xt);let Et=Ue.index,Ft=1;if(Ie.wireframe===!0){if(Et=ve.getWireframeAttribute(Ue),Et===void 0)return;Ft=2}const Pt=Ue.drawRange,wt=Ue.attributes.position;let Jt=Pt.start*Ft,Ht=(Pt.start+Pt.count)*Ft;ct!==null&&(Jt=Math.max(Jt,ct.start*Ft),Ht=Math.min(Ht,(ct.start+ct.count)*Ft)),Et!==null?(Jt=Math.max(Jt,0),Ht=Math.min(Ht,Et.count)):wt!=null&&(Jt=Math.max(Jt,0),Ht=Math.min(Ht,wt.count));const cn=Ht-Jt;if(cn<0||cn===1/0)return;me.setup(je,Ie,Tt,Ue,Et);let bn,Mn=Be;if(Et!==null&&(bn=ne.get(Et),Mn=Ze,Mn.setIndex(bn)),je.isMesh)Ie.wireframe===!0?(oe.setLineWidth(Ie.wireframeLinewidth*U()),Mn.setMode(H.LINES)):Mn.setMode(H.TRIANGLES);else if(je.isLine){let Bt=Ie.linewidth;Bt===void 0&&(Bt=1),oe.setLineWidth(Bt*U()),je.isLineSegments?Mn.setMode(H.LINES):je.isLineLoop?Mn.setMode(H.LINE_LOOP):Mn.setMode(H.LINE_STRIP)}else je.isPoints?Mn.setMode(H.POINTS):je.isSprite&&Mn.setMode(H.TRIANGLES);if(je.isBatchedMesh)if(je._multiDrawInstances!==null)rb("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Mn.renderMultiDrawInstances(je._multiDrawStarts,je._multiDrawCounts,je._multiDrawCount,je._multiDrawInstances);else if(G.get("WEBGL_multi_draw"))Mn.renderMultiDraw(je._multiDrawStarts,je._multiDrawCounts,je._multiDrawCount);else{const Bt=je._multiDrawStarts,nn=je._multiDrawCounts,an=je._multiDrawCount,Ur=Et?ne.get(Et).bytesPerElement:1,qr=Te.get(Ie).currentProgram.getUniforms();for(let $n=0;$n<an;$n++)qr.setValue(H,"_gl_DrawID",$n),Mn.render(Bt[$n]/Ur,nn[$n])}else if(je.isInstancedMesh)Mn.renderInstances(Jt,cn,je.count);else if(Ue.isInstancedBufferGeometry){const Bt=Ue._maxInstanceCount!==void 0?Ue._maxInstanceCount:1/0,nn=Math.min(Ue.instanceCount,Bt);Mn.renderInstances(Jt,cn,nn)}else Mn.render(Jt,cn)};function Ut(ae,Ne,Ue){ae.transparent===!0&&ae.side===dl&&ae.forceSinglePass===!1?(ae.side=ts,ae.needsUpdate=!0,jn(ae,Ne,Ue),ae.side=Md,ae.needsUpdate=!0,jn(ae,Ne,Ue),ae.side=dl):jn(ae,Ne,Ue)}this.compile=function(ae,Ne,Ue=null){Ue===null&&(Ue=ae),w=qe.get(Ue),w.init(Ne),T.push(w),Ue.traverseVisible(function(je){je.isLight&&je.layers.test(Ne.layers)&&(w.pushLight(je),je.castShadow&&w.pushShadow(je))}),ae!==Ue&&ae.traverseVisible(function(je){je.isLight&&je.layers.test(Ne.layers)&&(w.pushLight(je),je.castShadow&&w.pushShadow(je))}),w.setupLights();const Ie=new Set;return ae.traverse(function(je){if(!(je.isMesh||je.isPoints||je.isLine||je.isSprite))return;const ct=je.material;if(ct)if(Array.isArray(ct))for(let xt=0;xt<ct.length;xt++){const Tt=ct[xt];Ut(Tt,Ue,je),Ie.add(Tt)}else Ut(ct,Ue,je),Ie.add(ct)}),w=T.pop(),Ie},this.compileAsync=function(ae,Ne,Ue=null){const Ie=this.compile(ae,Ne,Ue);return new Promise(je=>{function ct(){if(Ie.forEach(function(xt){Te.get(xt).currentProgram.isReady()&&Ie.delete(xt)}),Ie.size===0){je(ae);return}setTimeout(ct,10)}G.get("KHR_parallel_shader_compile")!==null?ct():setTimeout(ct,10)})};let Ct=null;function $t(ae){Ct&&Ct(ae)}function gn(){It.stop()}function Fn(){It.start()}const It=new qZ;It.setAnimationLoop($t),typeof self<"u"&&It.setContext(self),this.setAnimationLoop=function(ae){Ct=ae,He.setAnimationLoop(ae),ae===null?It.stop():It.start()},He.addEventListener("sessionstart",gn),He.addEventListener("sessionend",Fn),this.render=function(ae,Ne){if(Ne!==void 0&&Ne.isCamera!==!0){Qr("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(ae.matrixWorldAutoUpdate===!0&&ae.updateMatrixWorld(),Ne.parent===null&&Ne.matrixWorldAutoUpdate===!0&&Ne.updateMatrixWorld(),He.enabled===!0&&He.isPresenting===!0&&(He.cameraAutoUpdate===!0&&He.updateCamera(Ne),Ne=He.getCamera()),ae.isScene===!0&&ae.onBeforeRender(C,ae,Ne,j),w=qe.get(ae,T.length),w.init(Ne),T.push(w),pe.multiplyMatrices(Ne.projectionMatrix,Ne.matrixWorldInverse),le.setFromProjectionMatrix(pe,pl,Ne.reversedDepth),Ee=this.localClippingEnabled,ge=ut.init(this.clippingPlanes,Ee),E=We.get(ae,A.length),E.init(),A.push(E),He.enabled===!0&&He.isPresenting===!0){const ct=C.xr.getDepthSensingMesh();ct!==null&&Yt(ct,Ne,-1/0,C.sortObjects)}Yt(ae,Ne,0,C.sortObjects),E.finish(),C.sortObjects===!0&&E.sort(z,V),Fe=He.enabled===!1||He.isPresenting===!1||He.hasDepthSensing()===!1,Fe&&se.addToRenderList(E,ae),this.info.render.frame++,ge===!0&&ut.beginShadows();const Ue=w.state.shadowsArray;ue.render(Ue,ae,Ne),ge===!0&&ut.endShadows(),this.info.autoReset===!0&&this.info.reset();const Ie=E.opaque,je=E.transmissive;if(w.setupLights(),Ne.isArrayCamera){const ct=Ne.cameras;if(je.length>0)for(let xt=0,Tt=ct.length;xt<Tt;xt++){const Et=ct[xt];er(Ie,je,ae,Et)}Fe&&se.render(ae);for(let xt=0,Tt=ct.length;xt<Tt;xt++){const Et=ct[xt];Jn(E,ae,Et,Et.viewport)}}else je.length>0&&er(Ie,je,ae,Ne),Fe&&se.render(ae),Jn(E,ae,Ne);j!==null&&k===0&&(Me.updateMultisampleRenderTarget(j),Me.updateRenderTargetMipmap(j)),ae.isScene===!0&&ae.onAfterRender(C,ae,Ne),me.resetDefaultState(),B=-1,L=null,T.pop(),T.length>0?(w=T[T.length-1],ge===!0&&ut.setGlobalState(C.clippingPlanes,w.state.camera)):w=null,A.pop(),A.length>0?E=A[A.length-1]:E=null};function Yt(ae,Ne,Ue,Ie){if(ae.visible===!1)return;if(ae.layers.test(Ne.layers)){if(ae.isGroup)Ue=ae.renderOrder;else if(ae.isLOD)ae.autoUpdate===!0&&ae.update(Ne);else if(ae.isLight)w.pushLight(ae),ae.castShadow&&w.pushShadow(ae);else if(ae.isSprite){if(!ae.frustumCulled||le.intersectsSprite(ae)){Ie&&Re.setFromMatrixPosition(ae.matrixWorld).applyMatrix4(pe);const xt=Se.update(ae),Tt=ae.material;Tt.visible&&E.push(ae,xt,Tt,Ue,Re.z,null)}}else if((ae.isMesh||ae.isLine||ae.isPoints)&&(!ae.frustumCulled||le.intersectsObject(ae))){const xt=Se.update(ae),Tt=ae.material;if(Ie&&(ae.boundingSphere!==void 0?(ae.boundingSphere===null&&ae.computeBoundingSphere(),Re.copy(ae.boundingSphere.center)):(xt.boundingSphere===null&&xt.computeBoundingSphere(),Re.copy(xt.boundingSphere.center)),Re.applyMatrix4(ae.matrixWorld).applyMatrix4(pe)),Array.isArray(Tt)){const Et=xt.groups;for(let Ft=0,Pt=Et.length;Ft<Pt;Ft++){const wt=Et[Ft],Jt=Tt[wt.materialIndex];Jt&&Jt.visible&&E.push(ae,xt,Jt,Ue,Re.z,wt)}}else Tt.visible&&E.push(ae,xt,Tt,Ue,Re.z,null)}}const ct=ae.children;for(let xt=0,Tt=ct.length;xt<Tt;xt++)Yt(ct[xt],Ne,Ue,Ie)}function Jn(ae,Ne,Ue,Ie){const{opaque:je,transmissive:ct,transparent:xt}=ae;w.setupLightsView(Ue),ge===!0&&ut.setGlobalState(C.clippingPlanes,Ue),Ie&&oe.viewport(K.copy(Ie)),je.length>0&&Hn(je,Ne,Ue),ct.length>0&&Hn(ct,Ne,Ue),xt.length>0&&Hn(xt,Ne,Ue),oe.buffers.depth.setTest(!0),oe.buffers.depth.setMask(!0),oe.buffers.color.setMask(!0),oe.setPolygonOffset(!1)}function er(ae,Ne,Ue,Ie){if((Ue.isScene===!0?Ue.overrideMaterial:null)!==null)return;w.state.transmissionRenderTarget[Ie.id]===void 0&&(w.state.transmissionRenderTarget[Ie.id]=new gf(1,1,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")||G.has("EXT_color_buffer_float")?yg:Al,minFilter:Ch,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ln.workingColorSpace}));const ct=w.state.transmissionRenderTarget[Ie.id],xt=Ie.viewport||K;ct.setSize(xt.z*C.transmissionResolutionScale,xt.w*C.transmissionResolutionScale);const Tt=C.getRenderTarget(),Et=C.getActiveCubeFace(),Ft=C.getActiveMipmapLevel();C.setRenderTarget(ct),C.getClearColor(W),$=C.getClearAlpha(),$<1&&C.setClearColor(16777215,.5),C.clear(),Fe&&se.render(Ue);const Pt=C.toneMapping;C.toneMapping=ld;const wt=Ie.viewport;if(Ie.viewport!==void 0&&(Ie.viewport=void 0),w.setupLightsView(Ie),ge===!0&&ut.setGlobalState(C.clippingPlanes,Ie),Hn(ae,Ue,Ie),Me.updateMultisampleRenderTarget(ct),Me.updateRenderTargetMipmap(ct),G.has("WEBGL_multisampled_render_to_texture")===!1){let Jt=!1;for(let Ht=0,cn=Ne.length;Ht<cn;Ht++){const bn=Ne[Ht],{object:Mn,geometry:Bt,material:nn,group:an}=bn;if(nn.side===dl&&Mn.layers.test(Ie.layers)){const Ur=nn.side;nn.side=ts,nn.needsUpdate=!0,Un(Mn,Ue,Ie,Bt,nn,an),nn.side=Ur,nn.needsUpdate=!0,Jt=!0}}Jt===!0&&(Me.updateMultisampleRenderTarget(ct),Me.updateRenderTargetMipmap(ct))}C.setRenderTarget(Tt,Et,Ft),C.setClearColor(W,$),wt!==void 0&&(Ie.viewport=wt),C.toneMapping=Pt}function Hn(ae,Ne,Ue){const Ie=Ne.isScene===!0?Ne.overrideMaterial:null;for(let je=0,ct=ae.length;je<ct;je++){const xt=ae[je],{object:Tt,geometry:Et,group:Ft}=xt;let Pt=xt.material;Pt.allowOverride===!0&&Ie!==null&&(Pt=Ie),Tt.layers.test(Ue.layers)&&Un(Tt,Ne,Ue,Et,Pt,Ft)}}function Un(ae,Ne,Ue,Ie,je,ct){ae.onBeforeRender(C,Ne,Ue,Ie,je,ct),ae.modelViewMatrix.multiplyMatrices(Ue.matrixWorldInverse,ae.matrixWorld),ae.normalMatrix.getNormalMatrix(ae.modelViewMatrix),je.onBeforeRender(C,Ne,Ue,Ie,ae,ct),je.transparent===!0&&je.side===dl&&je.forceSinglePass===!1?(je.side=ts,je.needsUpdate=!0,C.renderBufferDirect(Ue,Ne,Ie,je,ae,ct),je.side=Md,je.needsUpdate=!0,C.renderBufferDirect(Ue,Ne,Ie,je,ae,ct),je.side=dl):C.renderBufferDirect(Ue,Ne,Ie,je,ae,ct),ae.onAfterRender(C,Ne,Ue,Ie,je,ct)}function jn(ae,Ne,Ue){Ne.isScene!==!0&&(Ne=fe);const Ie=Te.get(ae),je=w.state.lights,ct=w.state.shadowsArray,xt=je.state.version,Tt=ye.getParameters(ae,je.state,ct,Ne,Ue),Et=ye.getProgramCacheKey(Tt);let Ft=Ie.programs;Ie.environment=ae.isMeshStandardMaterial?Ne.environment:null,Ie.fog=Ne.fog,Ie.envMap=(ae.isMeshStandardMaterial?I:F).get(ae.envMap||Ie.environment),Ie.envMapRotation=Ie.environment!==null&&ae.envMap===null?Ne.environmentRotation:ae.envMapRotation,Ft===void 0&&(ae.addEventListener("dispose",lt),Ft=new Map,Ie.programs=Ft);let Pt=Ft.get(Et);if(Pt!==void 0){if(Ie.currentProgram===Pt&&Ie.lightsStateVersion===xt)return Le(ae,Tt),Pt}else Tt.uniforms=ye.getUniforms(ae),ae.onBeforeCompile(Tt,C),Pt=ye.acquireProgram(Tt,Et),Ft.set(Et,Pt),Ie.uniforms=Tt.uniforms;const wt=Ie.uniforms;return(!ae.isShaderMaterial&&!ae.isRawShaderMaterial||ae.clipping===!0)&&(wt.clippingPlanes=ut.uniform),Le(ae,Tt),Ie.needsLights=et(ae),Ie.lightsStateVersion=xt,Ie.needsLights&&(wt.ambientLightColor.value=je.state.ambient,wt.lightProbe.value=je.state.probe,wt.directionalLights.value=je.state.directional,wt.directionalLightShadows.value=je.state.directionalShadow,wt.spotLights.value=je.state.spot,wt.spotLightShadows.value=je.state.spotShadow,wt.rectAreaLights.value=je.state.rectArea,wt.ltc_1.value=je.state.rectAreaLTC1,wt.ltc_2.value=je.state.rectAreaLTC2,wt.pointLights.value=je.state.point,wt.pointLightShadows.value=je.state.pointShadow,wt.hemisphereLights.value=je.state.hemi,wt.directionalShadowMap.value=je.state.directionalShadowMap,wt.directionalShadowMatrix.value=je.state.directionalShadowMatrix,wt.spotShadowMap.value=je.state.spotShadowMap,wt.spotLightMatrix.value=je.state.spotLightMatrix,wt.spotLightMap.value=je.state.spotLightMap,wt.pointShadowMap.value=je.state.pointShadowMap,wt.pointShadowMatrix.value=je.state.pointShadowMatrix),Ie.currentProgram=Pt,Ie.uniformsList=null,Pt}function sn(ae){if(ae.uniformsList===null){const Ne=ae.currentProgram.getUniforms();ae.uniformsList=T1.seqWithValue(Ne.seq,ae.uniforms)}return ae.uniformsList}function Le(ae,Ne){const Ue=Te.get(ae);Ue.outputColorSpace=Ne.outputColorSpace,Ue.batching=Ne.batching,Ue.batchingColor=Ne.batchingColor,Ue.instancing=Ne.instancing,Ue.instancingColor=Ne.instancingColor,Ue.instancingMorph=Ne.instancingMorph,Ue.skinning=Ne.skinning,Ue.morphTargets=Ne.morphTargets,Ue.morphNormals=Ne.morphNormals,Ue.morphColors=Ne.morphColors,Ue.morphTargetsCount=Ne.morphTargetsCount,Ue.numClippingPlanes=Ne.numClippingPlanes,Ue.numIntersection=Ne.numClipIntersection,Ue.vertexAlphas=Ne.vertexAlphas,Ue.vertexTangents=Ne.vertexTangents,Ue.toneMapping=Ne.toneMapping}function he(ae,Ne,Ue,Ie,je){Ne.isScene!==!0&&(Ne=fe),Me.resetTextureUnits();const ct=Ne.fog,xt=Ie.isMeshStandardMaterial?Ne.environment:null,Tt=j===null?C.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:Bp,Et=(Ie.isMeshStandardMaterial?I:F).get(Ie.envMap||xt),Ft=Ie.vertexColors===!0&&!!Ue.attributes.color&&Ue.attributes.color.itemSize===4,Pt=!!Ue.attributes.tangent&&(!!Ie.normalMap||Ie.anisotropy>0),wt=!!Ue.morphAttributes.position,Jt=!!Ue.morphAttributes.normal,Ht=!!Ue.morphAttributes.color;let cn=ld;Ie.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(cn=C.toneMapping);const bn=Ue.morphAttributes.position||Ue.morphAttributes.normal||Ue.morphAttributes.color,Mn=bn!==void 0?bn.length:0,Bt=Te.get(Ie),nn=w.state.lights;if(ge===!0&&(Ee===!0||ae!==L)){const ji=ae===L&&Ie.id===B;ut.setState(Ie,ae,ji)}let an=!1;Ie.version===Bt.__version?(Bt.needsLights&&Bt.lightsStateVersion!==nn.state.version||Bt.outputColorSpace!==Tt||je.isBatchedMesh&&Bt.batching===!1||!je.isBatchedMesh&&Bt.batching===!0||je.isBatchedMesh&&Bt.batchingColor===!0&&je.colorTexture===null||je.isBatchedMesh&&Bt.batchingColor===!1&&je.colorTexture!==null||je.isInstancedMesh&&Bt.instancing===!1||!je.isInstancedMesh&&Bt.instancing===!0||je.isSkinnedMesh&&Bt.skinning===!1||!je.isSkinnedMesh&&Bt.skinning===!0||je.isInstancedMesh&&Bt.instancingColor===!0&&je.instanceColor===null||je.isInstancedMesh&&Bt.instancingColor===!1&&je.instanceColor!==null||je.isInstancedMesh&&Bt.instancingMorph===!0&&je.morphTexture===null||je.isInstancedMesh&&Bt.instancingMorph===!1&&je.morphTexture!==null||Bt.envMap!==Et||Ie.fog===!0&&Bt.fog!==ct||Bt.numClippingPlanes!==void 0&&(Bt.numClippingPlanes!==ut.numPlanes||Bt.numIntersection!==ut.numIntersection)||Bt.vertexAlphas!==Ft||Bt.vertexTangents!==Pt||Bt.morphTargets!==wt||Bt.morphNormals!==Jt||Bt.morphColors!==Ht||Bt.toneMapping!==cn||Bt.morphTargetsCount!==Mn)&&(an=!0):(an=!0,Bt.__version=Ie.version);let Ur=Bt.currentProgram;an===!0&&(Ur=jn(Ie,Ne,je));let qr=!1,$n=!1,wo=!1;const Wn=Ur.getUniforms(),Pi=Bt.uniforms;if(oe.useProgram(Ur.program)&&(qr=!0,$n=!0,wo=!0),Ie.id!==B&&(B=Ie.id,$n=!0),qr||L!==ae){oe.buffers.depth.getReversed()&&ae.reversedDepth!==!0&&(ae._reversedDepth=!0,ae.updateProjectionMatrix()),Wn.setValue(H,"projectionMatrix",ae.projectionMatrix),Wn.setValue(H,"viewMatrix",ae.matrixWorldInverse);const qi=Wn.map.cameraPosition;qi!==void 0&&qi.setValue(H,de.setFromMatrixPosition(ae.matrixWorld)),Z.logarithmicDepthBuffer&&Wn.setValue(H,"logDepthBufFC",2/(Math.log(ae.far+1)/Math.LN2)),(Ie.isMeshPhongMaterial||Ie.isMeshToonMaterial||Ie.isMeshLambertMaterial||Ie.isMeshBasicMaterial||Ie.isMeshStandardMaterial||Ie.isShaderMaterial)&&Wn.setValue(H,"isOrthographic",ae.isOrthographicCamera===!0),L!==ae&&(L=ae,$n=!0,wo=!0)}if(je.isSkinnedMesh){Wn.setOptional(H,je,"bindMatrix"),Wn.setOptional(H,je,"bindMatrixInverse");const ji=je.skeleton;ji&&(ji.boneTexture===null&&ji.computeBoneTexture(),Wn.setValue(H,"boneTexture",ji.boneTexture,Me))}je.isBatchedMesh&&(Wn.setOptional(H,je,"batchingTexture"),Wn.setValue(H,"batchingTexture",je._matricesTexture,Me),Wn.setOptional(H,je,"batchingIdTexture"),Wn.setValue(H,"batchingIdTexture",je._indirectTexture,Me),Wn.setOptional(H,je,"batchingColorTexture"),je._colorsTexture!==null&&Wn.setValue(H,"batchingColorTexture",je._colorsTexture,Me));const pi=Ue.morphAttributes;if((pi.position!==void 0||pi.normal!==void 0||pi.color!==void 0)&&Ve.update(je,Ue,Ur),($n||Bt.receiveShadow!==je.receiveShadow)&&(Bt.receiveShadow=je.receiveShadow,Wn.setValue(H,"receiveShadow",je.receiveShadow)),Ie.isMeshGouraudMaterial&&Ie.envMap!==null&&(Pi.envMap.value=Et,Pi.flipEnvMap.value=Et.isCubeTexture&&Et.isRenderTargetTexture===!1?-1:1),Ie.isMeshStandardMaterial&&Ie.envMap===null&&Ne.environment!==null&&(Pi.envMapIntensity.value=Ne.environmentIntensity),Pi.dfgLUT!==void 0&&(Pi.dfgLUT.value=kDe()),$n&&(Wn.setValue(H,"toneMappingExposure",C.toneMappingExposure),Bt.needsLights&&ze(Pi,wo),ct&&Ie.fog===!0&&Ke.refreshFogUniforms(Pi,ct),Ke.refreshMaterialUniforms(Pi,Ie,Q,ee,w.state.transmissionRenderTarget[ae.id]),T1.upload(H,sn(Bt),Pi,Me)),Ie.isShaderMaterial&&Ie.uniformsNeedUpdate===!0&&(T1.upload(H,sn(Bt),Pi,Me),Ie.uniformsNeedUpdate=!1),Ie.isSpriteMaterial&&Wn.setValue(H,"center",je.center),Wn.setValue(H,"modelViewMatrix",je.modelViewMatrix),Wn.setValue(H,"normalMatrix",je.normalMatrix),Wn.setValue(H,"modelMatrix",je.matrixWorld),Ie.isShaderMaterial||Ie.isRawShaderMaterial){const ji=Ie.uniformsGroups;for(let qi=0,Zo=ji.length;qi<Zo;qi++){const Il=ji[qi];nt.update(Il,Ur),nt.bind(Il,Ur)}}return Ur}function ze(ae,Ne){ae.ambientLightColor.needsUpdate=Ne,ae.lightProbe.needsUpdate=Ne,ae.directionalLights.needsUpdate=Ne,ae.directionalLightShadows.needsUpdate=Ne,ae.pointLights.needsUpdate=Ne,ae.pointLightShadows.needsUpdate=Ne,ae.spotLights.needsUpdate=Ne,ae.spotLightShadows.needsUpdate=Ne,ae.rectAreaLights.needsUpdate=Ne,ae.hemisphereLights.needsUpdate=Ne}function et(ae){return ae.isMeshLambertMaterial||ae.isMeshToonMaterial||ae.isMeshPhongMaterial||ae.isMeshStandardMaterial||ae.isShadowMaterial||ae.isShaderMaterial&&ae.lights===!0}this.getActiveCubeFace=function(){return O},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return j},this.setRenderTargetTextures=function(ae,Ne,Ue){const Ie=Te.get(ae);Ie.__autoAllocateDepthBuffer=ae.resolveDepthBuffer===!1,Ie.__autoAllocateDepthBuffer===!1&&(Ie.__useRenderToTexture=!1),Te.get(ae.texture).__webglTexture=Ne,Te.get(ae.depthTexture).__webglTexture=Ie.__autoAllocateDepthBuffer?void 0:Ue,Ie.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(ae,Ne){const Ue=Te.get(ae);Ue.__webglFramebuffer=Ne,Ue.__useDefaultFramebuffer=Ne===void 0};const st=H.createFramebuffer();this.setRenderTarget=function(ae,Ne=0,Ue=0){j=ae,O=Ne,k=Ue;let Ie=!0,je=null,ct=!1,xt=!1;if(ae){const Et=Te.get(ae);if(Et.__useDefaultFramebuffer!==void 0)oe.bindFramebuffer(H.FRAMEBUFFER,null),Ie=!1;else if(Et.__webglFramebuffer===void 0)Me.setupRenderTarget(ae);else if(Et.__hasExternalTextures)Me.rebindTextures(ae,Te.get(ae.texture).__webglTexture,Te.get(ae.depthTexture).__webglTexture);else if(ae.depthBuffer){const wt=ae.depthTexture;if(Et.__boundDepthTexture!==wt){if(wt!==null&&Te.has(wt)&&(ae.width!==wt.image.width||ae.height!==wt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Me.setupDepthRenderbuffer(ae)}}const Ft=ae.texture;(Ft.isData3DTexture||Ft.isDataArrayTexture||Ft.isCompressedArrayTexture)&&(xt=!0);const Pt=Te.get(ae).__webglFramebuffer;ae.isWebGLCubeRenderTarget?(Array.isArray(Pt[Ne])?je=Pt[Ne][Ue]:je=Pt[Ne],ct=!0):ae.samples>0&&Me.useMultisampledRTT(ae)===!1?je=Te.get(ae).__webglMultisampledFramebuffer:Array.isArray(Pt)?je=Pt[Ue]:je=Pt,K.copy(ae.viewport),R.copy(ae.scissor),q=ae.scissorTest}else K.copy(X).multiplyScalar(Q).floor(),R.copy(te).multiplyScalar(Q).floor(),q=ie;if(Ue!==0&&(je=st),oe.bindFramebuffer(H.FRAMEBUFFER,je)&&Ie&&oe.drawBuffers(ae,je),oe.viewport(K),oe.scissor(R),oe.setScissorTest(q),ct){const Et=Te.get(ae.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Et.__webglTexture,Ue)}else if(xt){const Et=Ne;for(let Ft=0;Ft<ae.textures.length;Ft++){const Pt=Te.get(ae.textures[Ft]);H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0+Ft,Pt.__webglTexture,Ue,Et)}}else if(ae!==null&&Ue!==0){const Et=Te.get(ae.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,Et.__webglTexture,Ue)}B=-1},this.readRenderTargetPixels=function(ae,Ne,Ue,Ie,je,ct,xt,Tt=0){if(!(ae&&ae.isWebGLRenderTarget)){Qr("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Et=Te.get(ae).__webglFramebuffer;if(ae.isWebGLCubeRenderTarget&&xt!==void 0&&(Et=Et[xt]),Et){oe.bindFramebuffer(H.FRAMEBUFFER,Et);try{const Ft=ae.textures[Tt],Pt=Ft.format,wt=Ft.type;if(!Z.textureFormatReadable(Pt)){Qr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Z.textureTypeReadable(wt)){Qr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ne>=0&&Ne<=ae.width-Ie&&Ue>=0&&Ue<=ae.height-je&&(ae.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+Tt),H.readPixels(Ne,Ue,Ie,je,ht.convert(Pt),ht.convert(wt),ct))}finally{const Ft=j!==null?Te.get(j).__webglFramebuffer:null;oe.bindFramebuffer(H.FRAMEBUFFER,Ft)}}},this.readRenderTargetPixelsAsync=async function(ae,Ne,Ue,Ie,je,ct,xt,Tt=0){if(!(ae&&ae.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Et=Te.get(ae).__webglFramebuffer;if(ae.isWebGLCubeRenderTarget&&xt!==void 0&&(Et=Et[xt]),Et)if(Ne>=0&&Ne<=ae.width-Ie&&Ue>=0&&Ue<=ae.height-je){oe.bindFramebuffer(H.FRAMEBUFFER,Et);const Ft=ae.textures[Tt],Pt=Ft.format,wt=Ft.type;if(!Z.textureFormatReadable(Pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Z.textureTypeReadable(wt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Jt=H.createBuffer();H.bindBuffer(H.PIXEL_PACK_BUFFER,Jt),H.bufferData(H.PIXEL_PACK_BUFFER,ct.byteLength,H.STREAM_READ),ae.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+Tt),H.readPixels(Ne,Ue,Ie,je,ht.convert(Pt),ht.convert(wt),0);const Ht=j!==null?Te.get(j).__webglFramebuffer:null;oe.bindFramebuffer(H.FRAMEBUFFER,Ht);const cn=H.fenceSync(H.SYNC_GPU_COMMANDS_COMPLETE,0);return H.flush(),await nke(H,cn,4),H.bindBuffer(H.PIXEL_PACK_BUFFER,Jt),H.getBufferSubData(H.PIXEL_PACK_BUFFER,0,ct),H.deleteBuffer(Jt),H.deleteSync(cn),ct}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(ae,Ne=null,Ue=0){const Ie=Math.pow(2,-Ue),je=Math.floor(ae.image.width*Ie),ct=Math.floor(ae.image.height*Ie),xt=Ne!==null?Ne.x:0,Tt=Ne!==null?Ne.y:0;Me.setTexture2D(ae,0),H.copyTexSubImage2D(H.TEXTURE_2D,Ue,0,0,xt,Tt,je,ct),oe.unbindTexture()};const rt=H.createFramebuffer(),yt=H.createFramebuffer();this.copyTextureToTexture=function(ae,Ne,Ue=null,Ie=null,je=0,ct=null){ct===null&&(je!==0?(rb("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),ct=je,je=0):ct=0);let xt,Tt,Et,Ft,Pt,wt,Jt,Ht,cn;const bn=ae.isCompressedTexture?ae.mipmaps[ct]:ae.image;if(Ue!==null)xt=Ue.max.x-Ue.min.x,Tt=Ue.max.y-Ue.min.y,Et=Ue.isBox3?Ue.max.z-Ue.min.z:1,Ft=Ue.min.x,Pt=Ue.min.y,wt=Ue.isBox3?Ue.min.z:0;else{const pi=Math.pow(2,-je);xt=Math.floor(bn.width*pi),Tt=Math.floor(bn.height*pi),ae.isDataArrayTexture?Et=bn.depth:ae.isData3DTexture?Et=Math.floor(bn.depth*pi):Et=1,Ft=0,Pt=0,wt=0}Ie!==null?(Jt=Ie.x,Ht=Ie.y,cn=Ie.z):(Jt=0,Ht=0,cn=0);const Mn=ht.convert(Ne.format),Bt=ht.convert(Ne.type);let nn;Ne.isData3DTexture?(Me.setTexture3D(Ne,0),nn=H.TEXTURE_3D):Ne.isDataArrayTexture||Ne.isCompressedArrayTexture?(Me.setTexture2DArray(Ne,0),nn=H.TEXTURE_2D_ARRAY):(Me.setTexture2D(Ne,0),nn=H.TEXTURE_2D),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,Ne.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ne.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,Ne.unpackAlignment);const an=H.getParameter(H.UNPACK_ROW_LENGTH),Ur=H.getParameter(H.UNPACK_IMAGE_HEIGHT),qr=H.getParameter(H.UNPACK_SKIP_PIXELS),$n=H.getParameter(H.UNPACK_SKIP_ROWS),wo=H.getParameter(H.UNPACK_SKIP_IMAGES);H.pixelStorei(H.UNPACK_ROW_LENGTH,bn.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,bn.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Ft),H.pixelStorei(H.UNPACK_SKIP_ROWS,Pt),H.pixelStorei(H.UNPACK_SKIP_IMAGES,wt);const Wn=ae.isDataArrayTexture||ae.isData3DTexture,Pi=Ne.isDataArrayTexture||Ne.isData3DTexture;if(ae.isDepthTexture){const pi=Te.get(ae),ji=Te.get(Ne),qi=Te.get(pi.__renderTarget),Zo=Te.get(ji.__renderTarget);oe.bindFramebuffer(H.READ_FRAMEBUFFER,qi.__webglFramebuffer),oe.bindFramebuffer(H.DRAW_FRAMEBUFFER,Zo.__webglFramebuffer);for(let Il=0;Il<Et;Il++)Wn&&(H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Te.get(ae).__webglTexture,je,wt+Il),H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Te.get(Ne).__webglTexture,ct,cn+Il)),H.blitFramebuffer(Ft,Pt,xt,Tt,Jt,Ht,xt,Tt,H.DEPTH_BUFFER_BIT,H.NEAREST);oe.bindFramebuffer(H.READ_FRAMEBUFFER,null),oe.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else if(je!==0||ae.isRenderTargetTexture||Te.has(ae)){const pi=Te.get(ae),ji=Te.get(Ne);oe.bindFramebuffer(H.READ_FRAMEBUFFER,rt),oe.bindFramebuffer(H.DRAW_FRAMEBUFFER,yt);for(let qi=0;qi<Et;qi++)Wn?H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,pi.__webglTexture,je,wt+qi):H.framebufferTexture2D(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,pi.__webglTexture,je),Pi?H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,ji.__webglTexture,ct,cn+qi):H.framebufferTexture2D(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,ji.__webglTexture,ct),je!==0?H.blitFramebuffer(Ft,Pt,xt,Tt,Jt,Ht,xt,Tt,H.COLOR_BUFFER_BIT,H.NEAREST):Pi?H.copyTexSubImage3D(nn,ct,Jt,Ht,cn+qi,Ft,Pt,xt,Tt):H.copyTexSubImage2D(nn,ct,Jt,Ht,Ft,Pt,xt,Tt);oe.bindFramebuffer(H.READ_FRAMEBUFFER,null),oe.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else Pi?ae.isDataTexture||ae.isData3DTexture?H.texSubImage3D(nn,ct,Jt,Ht,cn,xt,Tt,Et,Mn,Bt,bn.data):Ne.isCompressedArrayTexture?H.compressedTexSubImage3D(nn,ct,Jt,Ht,cn,xt,Tt,Et,Mn,bn.data):H.texSubImage3D(nn,ct,Jt,Ht,cn,xt,Tt,Et,Mn,Bt,bn):ae.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,ct,Jt,Ht,xt,Tt,Mn,Bt,bn.data):ae.isCompressedTexture?H.compressedTexSubImage2D(H.TEXTURE_2D,ct,Jt,Ht,bn.width,bn.height,Mn,bn.data):H.texSubImage2D(H.TEXTURE_2D,ct,Jt,Ht,xt,Tt,Mn,Bt,bn);H.pixelStorei(H.UNPACK_ROW_LENGTH,an),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,Ur),H.pixelStorei(H.UNPACK_SKIP_PIXELS,qr),H.pixelStorei(H.UNPACK_SKIP_ROWS,$n),H.pixelStorei(H.UNPACK_SKIP_IMAGES,wo),ct===0&&Ne.generateMipmaps&&H.generateMipmap(nn),oe.unbindTexture()},this.initRenderTarget=function(ae){Te.get(ae).__webglFramebuffer===void 0&&Me.setupRenderTarget(ae)},this.initTexture=function(ae){ae.isCubeTexture?Me.setTextureCube(ae,0):ae.isData3DTexture?Me.setTexture3D(ae,0):ae.isDataArrayTexture||ae.isCompressedArrayTexture?Me.setTexture2DArray(ae,0):Me.setTexture2D(ae,0),oe.unbindTexture()},this.resetState=function(){O=0,k=0,j=null,oe.reset(),me.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return pl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Ln._getDrawingBufferColorSpace(e),n.unpackColorSpace=Ln._getUnpackColorSpace()}};const p$={type:"change"},FO={type:"start"},QZ={type:"end"},g_=new RO,g$=new $u,jDe=Math.cos(70*ike.DEG2RAD),xi=new at,Xa=2*Math.PI,lr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},uC=1e-6;class RDe extends Vke{constructor(e,n=null){super(e,n),this.state=lr.NONE,this.target=new at,this.cursor=new at,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:pp.ROTATE,MIDDLE:pp.DOLLY,RIGHT:pp.PAN},this.touches={ONE:lp.ROTATE,TWO:lp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new at,this._lastQuaternion=new pf,this._lastTargetPosition=new at,this._quat=new pf().setFromUnitVectors(e.up,new at(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new VH,this._sphericalDelta=new VH,this._scale=1,this._panOffset=new at,this._rotateStart=new fn,this._rotateEnd=new fn,this._rotateDelta=new fn,this._panStart=new fn,this._panEnd=new fn,this._panDelta=new fn,this._dollyStart=new fn,this._dollyEnd=new fn,this._dollyDelta=new fn,this._dollyDirection=new at,this._mouse=new fn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=ODe.bind(this),this._onPointerDown=DDe.bind(this),this._onPointerUp=LDe.bind(this),this._onContextMenu=$De.bind(this),this._onMouseWheel=UDe.bind(this),this._onKeyDown=zDe.bind(this),this._onTouchStart=BDe.bind(this),this._onTouchMove=HDe.bind(this),this._onMouseDown=IDe.bind(this),this._onMouseMove=FDe.bind(this),this._interceptControlDown=VDe.bind(this),this._interceptControlUp=GDe.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(p$),this.update(),this.state=lr.NONE}update(e=null){const n=this.object.position;xi.copy(n).sub(this.target),xi.applyQuaternion(this._quat),this._spherical.setFromVector3(xi),this.autoRotate&&this.state===lr.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=Xa:r>Math.PI&&(r-=Xa),i<-Math.PI?i+=Xa:i>Math.PI&&(i-=Xa),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=s!=this._spherical.radius}if(xi.setFromSpherical(this._spherical),xi.applyQuaternion(this._quatInverse),n.copy(this.target).add(xi),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){const l=xi.length();s=this._clampDistance(l*this._scale);const c=l-s;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),a=!!c}else if(this.object.isOrthographicCamera){const l=new at(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=c!==this.object.zoom;const u=new at(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),s=xi.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;s!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position):(g_.origin.copy(this.object.position),g_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(g_.direction))<jDe?this.object.lookAt(this.target):(g$.setFromNormalAndCoplanarPoint(this.object.up,this.target),g_.intersectPlane(g$,this.target))))}else if(this.object.isOrthographicCamera){const s=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>uC||8*(1-this._lastQuaternion.dot(this.object.quaternion))>uC||this._lastTargetPosition.distanceToSquared(this.target)>uC?(this.dispatchEvent(p$),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Xa/60*this.autoRotateSpeed*e:Xa/60/60*this.autoRotateSpeed}_getZoomScale(e){const n=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,n){xi.setFromMatrixColumn(n,0),xi.multiplyScalar(-e),this._panOffset.add(xi)}_panUp(e,n){this.screenSpacePanning===!0?xi.setFromMatrixColumn(n,1):(xi.setFromMatrixColumn(n,0),xi.crossVectors(this.object.up,xi)),xi.multiplyScalar(e),this._panOffset.add(xi)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;xi.copy(i).sub(this.target);let a=xi.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/r.clientHeight,this.object.matrix),this._panUp(2*n*a/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,a=n-r.top,s=r.width,l=r.height;this._mouse.x=i/s*2-1,this._mouse.y=-(a/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Xa*this._rotateDelta.x/n.clientHeight),this._rotateUp(Xa*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let n=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Xa*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),n=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Xa*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),n=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Xa*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),n=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Xa*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),a=.5*(e.pageY+r.y);this._rotateEnd.set(i,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Xa*this._rotateDelta.x/n.clientHeight),this._rotateUp(Xa*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const s=(e.pageX+n.x)*.5,l=(e.pageY+n.y)*.5;this._updateZoomParameters(s,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new fn,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function DDe(t){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(t)&&(this._addPointer(t),t.pointerType==="touch"?this._onTouchStart(t):this._onMouseDown(t)))}function ODe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function LDe(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(QZ),this.state=lr.NONE;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function IDe(t){let e;switch(t.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case pp.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=lr.DOLLY;break;case pp.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=lr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=lr.ROTATE}break;case pp.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=lr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=lr.PAN}break;default:this.state=lr.NONE}this.state!==lr.NONE&&this.dispatchEvent(FO)}function FDe(t){switch(this.state){case lr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case lr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case lr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function UDe(t){this.enabled===!1||this.enableZoom===!1||this.state!==lr.NONE||(t.preventDefault(),this.dispatchEvent(FO),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(QZ))}function zDe(t){this.enabled!==!1&&this._handleKeyDown(t)}function BDe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case lp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=lr.TOUCH_ROTATE;break;case lp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=lr.TOUCH_PAN;break;default:this.state=lr.NONE}break;case 2:switch(this.touches.TWO){case lp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=lr.TOUCH_DOLLY_PAN;break;case lp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=lr.TOUCH_DOLLY_ROTATE;break;default:this.state=lr.NONE}break;default:this.state=lr.NONE}this.state!==lr.NONE&&this.dispatchEvent(FO)}function HDe(t){switch(this._trackPointer(t),this.state){case lr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case lr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case lr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case lr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=lr.NONE}}function $De(t){this.enabled!==!1&&t.preventDefault()}function VDe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function GDe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function WDe(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),a={},s={},l=t[0].morphTargetsRelative,c=new Ll;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let g=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in f.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;a[p]===void 0&&(a[p]=[]),a[p].push(f.attributes[p]),g++}if(g!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(l!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in f.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;s[p]===void 0&&(s[p]=[]),s[p].push(f.morphAttributes[p])}if(e){let p;if(n)p=f.index.count;else if(f.attributes.position!==void 0)p=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(u,p,d),u+=p}}if(n){let d=0;const f=[];for(let g=0;g<t.length;++g){const p=t[g].index;for(let x=0;x<p.count;++x)f.push(p.getX(x)+d);d+=t[g].attributes.position.count}c.setIndex(f)}for(const d in a){const f=x$(a[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,f)}for(const d in s){const f=s[d][0].length;if(f===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let g=0;g<f;++g){const p=[];for(let v=0;v<s[d].length;++v)p.push(s[d][v][g]);const x=x$(p);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(x)}}return c}function x$(t){let e,n,r,i=-1,a=0;for(let u=0;u<t.length;++u){const d=t[u];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=d.normalized),r!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=d.count*n}const s=new e(a),l=new uo(s,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=c/n;for(let g=0,p=d.count;g<p;g++)for(let x=0;x<n;x++){const v=d.getComponent(g,x);l.setComponent(g+f,x,v)}}else s.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}function x_(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var dC={exports:{}};var b$;function qDe(){return b$||(b$=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,a){function s(u,d){if(!i[u]){if(!r[u]){var f=typeof x_=="function"&&x_;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var g=new Error("Cannot find module '"+u+"'");throw g.code="MODULE_NOT_FOUND",g}var p=i[u]={exports:{}};r[u][0].call(p.exports,function(x){var v=r[u][1][x];return s(v||x)},p,p.exports,n,r,i,a)}return i[u].exports}for(var l=typeof x_=="function"&&x_,c=0;c<a.length;c++)s(a[c]);return s})({1:[function(n,r,i){var a=n("./utils"),s=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,f,g,p,x,v,y=[],b=0,E=c.length,w=E,A=a.getTypeOf(c)!=="string";b<c.length;)w=E-b,f=A?(u=c[b++],d=b<E?c[b++]:0,b<E?c[b++]:0):(u=c.charCodeAt(b++),d=b<E?c.charCodeAt(b++):0,b<E?c.charCodeAt(b++):0),g=u>>2,p=(3&u)<<4|d>>4,x=1<w?(15&d)<<2|f>>6:64,v=2<w?63&f:64,y.push(l.charAt(g)+l.charAt(p)+l.charAt(x)+l.charAt(v));return y.join("")},i.decode=function(c){var u,d,f,g,p,x,v=0,y=0,b="data:";if(c.substr(0,b.length)===b)throw new Error("Invalid base64 input, it looks like a data url.");var E,w=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&w--,c.charAt(c.length-2)===l.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");for(E=s.uint8array?new Uint8Array(0|w):new Array(0|w);v<c.length;)u=l.indexOf(c.charAt(v++))<<2|(g=l.indexOf(c.charAt(v++)))>>4,d=(15&g)<<4|(p=l.indexOf(c.charAt(v++)))>>2,f=(3&p)<<6|(x=l.indexOf(c.charAt(v++))),E[y++]=u,p!==64&&(E[y++]=d),x!==64&&(E[y++]=f);return E}},{"./support":30,"./utils":32}],2:[function(n,r,i){var a=n("./external"),s=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,g,p,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=g,this.compression=p,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new s(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new s(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,g){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(g)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var a=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var a=n("./utils"),s=(function(){for(var l,c=[],u=0;u<256;u++){l=u;for(var d=0;d<8;d++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c})();r.exports=function(l,c){return l!==void 0&&l.length?a.getTypeOf(l)!=="string"?(function(u,d,f,g){var p=s,x=g+f;u^=-1;for(var v=g;v<x;v++)u=u>>>8^p[255&(u^d[v])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,g){var p=s,x=g+f;u^=-1;for(var v=g;v<x;v++)u=u>>>8^p[255&(u^d.charCodeAt(v))];return-1^u})(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var a=null;a=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:a}},{lie:37}],7:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=a?"uint8array":"array";function d(f,g){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=g,this.meta={}}i.magic="\b\0",l.inherits(d,c),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,f.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(g){f.push({data:g,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function a(p,x){var v,y="";for(v=0;v<x;v++)y+=String.fromCharCode(255&p),p>>>=8;return y}function s(p,x,v,y,b,E){var w,A,T=p.file,C=p.compression,N=E!==u.utf8encode,O=l.transformTo("string",E(T.name)),k=l.transformTo("string",u.utf8encode(T.name)),j=T.comment,B=l.transformTo("string",E(j)),L=l.transformTo("string",u.utf8encode(j)),K=k.length!==T.name.length,R=L.length!==j.length,q="",W="",$="",J=T.dir,ee=T.date,Q={crc32:0,compressedSize:0,uncompressedSize:0};x&&!v||(Q.crc32=p.crc32,Q.compressedSize=p.compressedSize,Q.uncompressedSize=p.uncompressedSize);var z=0;x&&(z|=8),N||!K&&!R||(z|=2048);var V=0,X=0;J&&(V|=16),b==="UNIX"?(X=798,V|=(function(ie,le){var ge=ie;return ie||(ge=le?16893:33204),(65535&ge)<<16})(T.unixPermissions,J)):(X=20,V|=(function(ie){return 63&(ie||0)})(T.dosPermissions)),w=ee.getUTCHours(),w<<=6,w|=ee.getUTCMinutes(),w<<=5,w|=ee.getUTCSeconds()/2,A=ee.getUTCFullYear()-1980,A<<=4,A|=ee.getUTCMonth()+1,A<<=5,A|=ee.getUTCDate(),K&&(W=a(1,1)+a(d(O),4)+k,q+="up"+a(W.length,2)+W),R&&($=a(1,1)+a(d(B),4)+L,q+="uc"+a($.length,2)+$);var te="";return te+=`
- \0`,te+=a(z,2),te+=C.magic,te+=a(w,2),te+=a(A,2),te+=a(Q.crc32,4),te+=a(Q.compressedSize,4),te+=a(Q.uncompressedSize,4),te+=a(O.length,2),te+=a(q.length,2),{fileRecord:f.LOCAL_FILE_HEADER+te+O+q,dirRecord:f.CENTRAL_FILE_HEADER+a(X,2)+te+a(B.length,2)+"\0\0\0\0"+a(V,4)+a(y,4)+O+q+B}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function g(p,x,v,y){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=v,this.encodeFileName=y,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(g,c),g.prototype.push=function(p){var x=p.meta.percent||0,v=this.entriesCount,y=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,c.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:v?(x+100*(v-y-1))/v:100}}))},g.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var x=this.streamFiles&&!p.file.dir;if(x){var v=s(p,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:v.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(p){this.accumulate=!1;var x=this.streamFiles&&!p.file.dir,v=s(p,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(v.dirRecord),x)this.push({data:(function(y){return f.DATA_DESCRIPTOR+a(y.crc32,4)+a(y.compressedSize,4)+a(y.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:v.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var p=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var v=this.bytesWritten-p,y=(function(b,E,w,A,T){var C=l.transformTo("string",T(A));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(b,2)+a(b,2)+a(E,4)+a(w,4)+a(C.length,2)+C})(this.dirRecords.length,v,p,this.zipComment,this.encodeFileName);this.push({data:y,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(p){this._sources.push(p);var x=this;return p.on("data",function(v){x.processChunk(v)}),p.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),p.on("error",function(v){x.error(v)}),this},g.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(p){var x=this._sources;if(!c.prototype.error.call(this,p))return!1;for(var v=0;v<x.length;v++)try{x[v].error(p)}catch{}return!0},g.prototype.lock=function(){c.prototype.lock.call(this);for(var p=this._sources,x=0;x<p.length;x++)p[x].lock()},r.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var a=n("../compressions"),s=n("./ZipFileWorker");i.generateWorker=function(l,c,u){var d=new s(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{l.forEach(function(g,p){f++;var x=(function(E,w){var A=E||w,T=a[A];if(!T)throw new Error(A+" is not a valid compression method !");return T})(p.options.compression,c.compression),v=p.options.compressionOptions||c.compressionOptions||{},y=p.dir,b=p.date;p._compressWorker(x,v).withStreamInfo("file",{name:g,dir:y,date:b,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(g){d.error(g)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new a;for(var l in this)typeof this[l]!="function"&&(s[l]=this[l]);return s}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(s,l){return new a().loadAsync(s,l)},a.external=n("./external"),r.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var a=n("./utils"),s=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(g){return new s.Promise(function(p,x){var v=g.decompressed.getContentWorker().pipe(new u);v.on("error",function(y){x(y)}).on("end",function(){v.streamInfo.crc32!==g.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}r.exports=function(g,p){var x=this;return p=a.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(g)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",g,!0,p.optimizedBinaryString,p.base64).then(function(v){var y=new c(p);return y.load(v),y}).then(function(v){var y=[s.Promise.resolve(v)],b=v.files;if(p.checkCRC32)for(var E=0;E<b.length;E++)y.push(f(b[E]));return s.Promise.all(y)}).then(function(v){for(var y=v.shift(),b=y.files,E=0;E<b.length;E++){var w=b[E],A=w.fileNameStr,T=a.resolve(w.fileNameStr);x.file(T,w.decompressed,{binary:!0,optimizedBinaryString:!0,date:w.date,dir:w.dir,comment:w.fileCommentStr.length?w.fileCommentStr:null,unixPermissions:w.unixPermissions,dosPermissions:w.dosPermissions,createFolders:p.createFolders}),w.dir||(x.file(T).unsafeOriginalName=A)}return y.zipComment.length&&(x.comment=y.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var a=n("../utils"),s=n("../stream/GenericWorker");function l(c,u){s.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}a.inherits(l,s),l.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},l.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var a=n("readable-stream").Readable;function s(l,c,u){a.call(this,c),this._helper=l;var d=this;l.on("data",function(f,g){d.push(f)||d._helper.pause(),u&&u(g)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(s,a),s.prototype._read=function(){this._helper.resume()},r.exports=s},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,s);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,s)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var s=new Buffer(a);return s.fill(0),s},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,r,i){function a(T,C,N){var O,k=l.getTypeOf(C),j=l.extend(N||{},d);j.date=j.date||new Date,j.compression!==null&&(j.compression=j.compression.toUpperCase()),typeof j.unixPermissions=="string"&&(j.unixPermissions=parseInt(j.unixPermissions,8)),j.unixPermissions&&16384&j.unixPermissions&&(j.dir=!0),j.dosPermissions&&16&j.dosPermissions&&(j.dir=!0),j.dir&&(T=b(T)),j.createFolders&&(O=y(T))&&E.call(this,O,!0);var B=k==="string"&&j.binary===!1&&j.base64===!1;N&&N.binary!==void 0||(j.binary=!B),(C instanceof f&&C.uncompressedSize===0||j.dir||!C||C.length===0)&&(j.base64=!1,j.binary=!0,C="",j.compression="STORE",k="string");var L=null;L=C instanceof f||C instanceof c?C:x.isNode&&x.isStream(C)?new v(T,C):l.prepareContent(T,C,j.binary,j.optimizedBinaryString,j.base64);var K=new g(T,L,j);this.files[T]=K}var s=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),g=n("./zipObject"),p=n("./generate"),x=n("./nodejsUtils"),v=n("./nodejs/NodejsStreamInputAdapter"),y=function(T){T.slice(-1)==="/"&&(T=T.substring(0,T.length-1));var C=T.lastIndexOf("/");return 0<C?T.substring(0,C):""},b=function(T){return T.slice(-1)!=="/"&&(T+="/"),T},E=function(T,C){return C=C!==void 0?C:d.createFolders,T=b(T),this.files[T]||a.call(this,T,null,{dir:!0,createFolders:C}),this.files[T]};function w(T){return Object.prototype.toString.call(T)==="[object RegExp]"}var A={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(T){var C,N,O;for(C in this.files)O=this.files[C],(N=C.slice(this.root.length,C.length))&&C.slice(0,this.root.length)===this.root&&T(N,O)},filter:function(T){var C=[];return this.forEach(function(N,O){T(N,O)&&C.push(O)}),C},file:function(T,C,N){if(arguments.length!==1)return T=this.root+T,a.call(this,T,C,N),this;if(w(T)){var O=T;return this.filter(function(j,B){return!B.dir&&O.test(j)})}var k=this.files[this.root+T];return k&&!k.dir?k:null},folder:function(T){if(!T)return this;if(w(T))return this.filter(function(k,j){return j.dir&&T.test(k)});var C=this.root+T,N=E.call(this,C),O=this.clone();return O.root=N.name,O},remove:function(T){T=this.root+T;var C=this.files[T];if(C||(T.slice(-1)!=="/"&&(T+="/"),C=this.files[T]),C&&!C.dir)delete this.files[T];else for(var N=this.filter(function(k,j){return j.name.slice(0,T.length)===T}),O=0;O<N.length;O++)delete this.files[N[O].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(T){var C,N={};try{if((N=l.extend(T||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=N.type.toLowerCase(),N.compression=N.compression.toUpperCase(),N.type==="binarystring"&&(N.type="string"),!N.type)throw new Error("No output type specified.");l.checkSupport(N.type),N.platform!=="darwin"&&N.platform!=="freebsd"&&N.platform!=="linux"&&N.platform!=="sunos"||(N.platform="UNIX"),N.platform==="win32"&&(N.platform="DOS");var O=N.comment||this.comment||"";C=p.generateWorker(this,N,O)}catch(k){(C=new c("error")).error(k)}return new u(C,N.type||"string",N.mimeType)},generateAsync:function(T,C){return this.generateInternalStream(T).accumulate(C)},generateNodeStream:function(T,C){return(T=T||{}).type||(T.type="nodebuffer"),this.generateInternalStream(T).toNodejsStream(C)}};r.exports=A},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var a=n("./DataReader");function s(l){a.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(s,a),s.prototype.byteAt=function(l){return this.data[this.zero+l]},s.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===c&&this.data[g+1]===u&&this.data[g+2]===d&&this.data[g+3]===f)return g-this.zero;return-1},s.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),g=this.readData(4);return c===g[0]&&u===g[1]&&d===g[2]&&f===g[3]},s.prototype.readData=function(l){if(this.checkOffset(l),l===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=s},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var a=n("../utils");function s(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return a.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},r.exports=s},{"../utils":32}],19:[function(n,r,i){var a=n("./Uint8ArrayReader");function s(l){a.call(this,l)}n("../utils").inherits(s,a),s.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var a=n("./DataReader");function s(l){a.call(this,l)}n("../utils").inherits(s,a),s.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},s.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},s.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},s.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=s},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var a=n("./ArrayReader");function s(l){a.call(this,l)}n("../utils").inherits(s,a),s.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var a=n("../utils"),s=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var g=a.getTypeOf(f);return a.checkSupport(g),g!=="string"||s.uint8array?g==="nodebuffer"?new u(f):s.uint8array?new d(a.transformTo("uint8array",f)):new l(a.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var a=n("./GenericWorker"),s=n("../utils");function l(c){a.call(this,"ConvertWorker to "+c),this.destType=c}s.inherits(l,a),l.prototype.processChunk=function(c){this.push({data:s.transformTo(this.destType,c.data),meta:c.meta})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var a=n("./GenericWorker"),s=n("../crc32");function l(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,a),l.prototype.processChunk=function(c){this.streamInfo.crc32=s(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var a=n("../utils"),s=n("./GenericWorker");function l(c){s.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}a.inherits(l,s),l.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}s.prototype.processChunk.call(this,c)},r.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var a=n("../utils"),s=n("./GenericWorker");function l(c){s.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=a.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}a.inherits(l,s),l.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function a(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}a.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,l){return this._listeners[s].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,l){if(this._listeners[s])for(var c=0;c<this._listeners[s].length;c++)this._listeners[s][c].call(this,l)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var l=this;return s.on("data",function(c){l.processChunk(c)}),s.on("end",function(){l.end()}),s.on("error",function(c){l.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,l){return this.extraStreamInfo[s]=l,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},r.exports=a},{}],29:[function(n,r,i){var a=n("../utils"),s=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(x,v){return new d.Promise(function(y,b){var E=[],w=x._internalType,A=x._outputType,T=x._mimeType;x.on("data",function(C,N){E.push(C),v&&v(N)}).on("error",function(C){E=[],b(C)}).on("end",function(){try{var C=(function(N,O,k){switch(N){case"blob":return a.newBlob(a.transformTo("arraybuffer",O),k);case"base64":return c.encode(O);default:return a.transformTo(N,O)}})(A,(function(N,O){var k,j=0,B=null,L=0;for(k=0;k<O.length;k++)L+=O[k].length;switch(N){case"string":return O.join("");case"array":return Array.prototype.concat.apply([],O);case"uint8array":for(B=new Uint8Array(L),k=0;k<O.length;k++)B.set(O[k],j),j+=O[k].length;return B;case"nodebuffer":return Buffer.concat(O);default:throw new Error("concat : unsupported type '"+N+"'")}})(w,E),T);y(C)}catch(N){b(N)}E=[]}).resume()})}function p(x,v,y){var b=v;switch(v){case"blob":case"arraybuffer":b="uint8array";break;case"base64":b="string"}try{this._internalType=b,this._outputType=v,this._mimeType=y,a.checkSupport(b),this._worker=x.pipe(new s(b)),x.lock()}catch(E){this._worker=new l("error"),this._worker.error(E)}}p.prototype={accumulate:function(x){return g(this,x)},on:function(x,v){var y=this;return x==="data"?this._worker.on(x,function(b){v.call(y,b.data,b.meta)}):this._worker.on(x,function(){a.delay(v,arguments,y)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var a=new ArrayBuffer(0);try{i.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(a),i.blob=s.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){for(var a=n("./utils"),s=n("./support"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function g(){c.call(this,"utf-8 encode")}i.utf8encode=function(p){return s.nodebuffer?l.newBufferFrom(p,"utf-8"):(function(x){var v,y,b,E,w,A=x.length,T=0;for(E=0;E<A;E++)(64512&(y=x.charCodeAt(E)))==55296&&E+1<A&&(64512&(b=x.charCodeAt(E+1)))==56320&&(y=65536+(y-55296<<10)+(b-56320),E++),T+=y<128?1:y<2048?2:y<65536?3:4;for(v=s.uint8array?new Uint8Array(T):new Array(T),E=w=0;w<T;E++)(64512&(y=x.charCodeAt(E)))==55296&&E+1<A&&(64512&(b=x.charCodeAt(E+1)))==56320&&(y=65536+(y-55296<<10)+(b-56320),E++),y<128?v[w++]=y:(y<2048?v[w++]=192|y>>>6:(y<65536?v[w++]=224|y>>>12:(v[w++]=240|y>>>18,v[w++]=128|y>>>12&63),v[w++]=128|y>>>6&63),v[w++]=128|63&y);return v})(p)},i.utf8decode=function(p){return s.nodebuffer?a.transformTo("nodebuffer",p).toString("utf-8"):(function(x){var v,y,b,E,w=x.length,A=new Array(2*w);for(v=y=0;v<w;)if((b=x[v++])<128)A[y++]=b;else if(4<(E=u[b]))A[y++]=65533,v+=E-1;else{for(b&=E===2?31:E===3?15:7;1<E&&v<w;)b=b<<6|63&x[v++],E--;1<E?A[y++]=65533:b<65536?A[y++]=b:(b-=65536,A[y++]=55296|b>>10&1023,A[y++]=56320|1023&b)}return A.length!==y&&(A.subarray?A=A.subarray(0,y):A.length=y),a.applyFromCharCode(A)})(p=a.transformTo(s.uint8array?"uint8array":"array",p))},a.inherits(f,c),f.prototype.processChunk=function(p){var x=a.transformTo(s.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var v=x;(x=new Uint8Array(v.length+this.leftOver.length)).set(this.leftOver,0),x.set(v,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var y=(function(E,w){var A;for((w=w||E.length)>E.length&&(w=E.length),A=w-1;0<=A&&(192&E[A])==128;)A--;return A<0||A===0?w:A+u[E[A]]>w?A:w})(x),b=x;y!==x.length&&(s.uint8array?(b=x.subarray(0,y),this.leftOver=x.subarray(y,x.length)):(b=x.slice(0,y),this.leftOver=x.slice(y,x.length))),this.push({data:i.utf8decode(b),meta:p.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,a.inherits(g,c),g.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var a=n("./support"),s=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(v){return v}function d(v,y){for(var b=0;b<v.length;++b)y[b]=255&v.charCodeAt(b);return y}n("setimmediate"),i.newBlob=function(v,y){i.checkSupport("blob");try{return new Blob([v],{type:y})}catch{try{var b=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return b.append(v),b.getBlob(y)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(v,y,b){var E=[],w=0,A=v.length;if(A<=b)return String.fromCharCode.apply(null,v);for(;w<A;)y==="array"||y==="nodebuffer"?E.push(String.fromCharCode.apply(null,v.slice(w,Math.min(w+b,A)))):E.push(String.fromCharCode.apply(null,v.subarray(w,Math.min(w+b,A)))),w+=b;return E.join("")},stringifyByChar:function(v){for(var y="",b=0;b<v.length;b++)y+=String.fromCharCode(v[b]);return y},applyCanBeUsed:{uint8array:(function(){try{return a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}})()}};function g(v){var y=65536,b=i.getTypeOf(v),E=!0;if(b==="uint8array"?E=f.applyCanBeUsed.uint8array:b==="nodebuffer"&&(E=f.applyCanBeUsed.nodebuffer),E)for(;1<y;)try{return f.stringifyByChunk(v,b,y)}catch{y=Math.floor(y/2)}return f.stringifyByChar(v)}function p(v,y){for(var b=0;b<v.length;b++)y[b]=v[b];return y}i.applyFromCharCode=g;var x={};x.string={string:u,array:function(v){return d(v,new Array(v.length))},arraybuffer:function(v){return x.string.uint8array(v).buffer},uint8array:function(v){return d(v,new Uint8Array(v.length))},nodebuffer:function(v){return d(v,l.allocBuffer(v.length))}},x.array={string:g,array:u,arraybuffer:function(v){return new Uint8Array(v).buffer},uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return l.newBufferFrom(v)}},x.arraybuffer={string:function(v){return g(new Uint8Array(v))},array:function(v){return p(new Uint8Array(v),new Array(v.byteLength))},arraybuffer:u,uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return l.newBufferFrom(new Uint8Array(v))}},x.uint8array={string:g,array:function(v){return p(v,new Array(v.length))},arraybuffer:function(v){return v.buffer},uint8array:u,nodebuffer:function(v){return l.newBufferFrom(v)}},x.nodebuffer={string:g,array:function(v){return p(v,new Array(v.length))},arraybuffer:function(v){return x.nodebuffer.uint8array(v).buffer},uint8array:function(v){return p(v,new Uint8Array(v.length))},nodebuffer:u},i.transformTo=function(v,y){if(y=y||"",!v)return y;i.checkSupport(v);var b=i.getTypeOf(y);return x[b][v](y)},i.resolve=function(v){for(var y=v.split("/"),b=[],E=0;E<y.length;E++){var w=y[E];w==="."||w===""&&E!==0&&E!==y.length-1||(w===".."?b.pop():b.push(w))}return b.join("/")},i.getTypeOf=function(v){return typeof v=="string"?"string":Object.prototype.toString.call(v)==="[object Array]"?"array":a.nodebuffer&&l.isBuffer(v)?"nodebuffer":a.uint8array&&v instanceof Uint8Array?"uint8array":a.arraybuffer&&v instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(v){if(!a[v.toLowerCase()])throw new Error(v+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(v){var y,b,E="";for(b=0;b<(v||"").length;b++)E+="\\x"+((y=v.charCodeAt(b))<16?"0":"")+y.toString(16).toUpperCase();return E},i.delay=function(v,y,b){setImmediate(function(){v.apply(b||null,y||[])})},i.inherits=function(v,y){function b(){}b.prototype=y.prototype,v.prototype=new b},i.extend=function(){var v,y,b={};for(v=0;v<arguments.length;v++)for(y in arguments[v])Object.prototype.hasOwnProperty.call(arguments[v],y)&&b[y]===void 0&&(b[y]=arguments[v][y]);return b},i.prepareContent=function(v,y,b,E,w){return c.Promise.resolve(y).then(function(A){return a.blob&&(A instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(A))!==-1)&&typeof FileReader<"u"?new c.Promise(function(T,C){var N=new FileReader;N.onload=function(O){T(O.target.result)},N.onerror=function(O){C(O.target.error)},N.readAsArrayBuffer(A)}):A}).then(function(A){var T=i.getTypeOf(A);return T?(T==="arraybuffer"?A=i.transformTo("uint8array",A):T==="string"&&(w?A=s.decode(A):b&&E!==!0&&(A=(function(C){return d(C,a.uint8array?new Uint8Array(C.length):new Array(C.length))})(A))),A):c.Promise.reject(new Error("Can't read the data of '"+v+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var a=n("./reader/readerFor"),s=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(g)+", expected "+s.pretty(f)+")")}},isSignature:function(f,g){var p=this.reader.index;this.reader.setIndex(f);var x=this.reader.readString(4)===g;return this.reader.setIndex(p),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),g=u.uint8array?"uint8array":"array",p=s.transformTo(g,f);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,g,p,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),g=this.reader.readInt(4),p=this.reader.readData(g),this.zip64ExtensibleData[f]={id:f,length:g,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,g;for(f=0;f<this.files.length;f++)g=this.files[f],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(f=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,l.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var g=f;if(this.checkSignature(l.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var x=g-p;if(0<x)this.isSignature(g,l.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(f){this.reader=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var a=n("./reader/readerFor"),s=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function g(p,x){this.options=p,this.loadOptions=x}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var x,v;if(p.skip(22),this.fileNameLength=p.readInt(2),v=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(v),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=(function(y){for(var b in d)if(Object.prototype.hasOwnProperty.call(d,b)&&d[b].magic===y)return d[b];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,x,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var x=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(x),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=a(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var x,v,y,b=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<b;)x=p.readInt(2),v=p.readInt(2),y=p.readData(v),this.extraFields[x]={id:x,length:v,value:y};p.setIndex(b)},handleUTF8:function(){var p=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var v=s.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(v)}var y=this.findExtraFieldUnicodeComment();if(y!==null)this.fileCommentStr=y;else{var b=s.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(b)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null}},r.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function a(x,v,y){this.name=x,this.dir=y.dir,this.date=y.date,this.comment=y.comment,this.unixPermissions=y.unixPermissions,this.dosPermissions=y.dosPermissions,this._data=v,this._dataBinary=y.binary,this.options={compression:y.compression,compressionOptions:y.compressionOptions}}var s=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");a.prototype={internalStream:function(x){var v=null,y="string";try{if(!x)throw new Error("No output type specified.");var b=(y=x.toLowerCase())==="string"||y==="text";y!=="binarystring"&&y!=="text"||(y="string"),v=this._decompressWorker();var E=!this._dataBinary;E&&!b&&(v=v.pipe(new c.Utf8EncodeWorker)),!E&&b&&(v=v.pipe(new c.Utf8DecodeWorker))}catch(w){(v=new d("error")).error(w)}return new s(v,y,"")},async:function(x,v){return this.internalStream(x).accumulate(v)},nodeStream:function(x,v){return this.internalStream(x||"nodebuffer").toNodejsStream(v)},_compressWorker:function(x,v){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var y=this._decompressWorker();return this._dataBinary||(y=y.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(y,x,v)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<f.length;p++)a.prototype[f[p]]=g;r.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(a){var s,l,c=a.MutationObserver||a.WebKitMutationObserver;if(c){var u=0,d=new c(x),f=a.document.createTextNode("");d.observe(f,{characterData:!0}),s=function(){f.data=u=++u%2}}else if(a.setImmediate||a.MessageChannel===void 0)s="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var v=a.document.createElement("script");v.onreadystatechange=function(){x(),v.onreadystatechange=null,v.parentNode.removeChild(v),v=null},a.document.documentElement.appendChild(v)}:function(){setTimeout(x,0)};else{var g=new a.MessageChannel;g.port1.onmessage=x,s=function(){g.port2.postMessage(0)}}var p=[];function x(){var v,y;l=!0;for(var b=p.length;b;){for(y=p,p=[],v=-1;++v<b;)y[v]();b=p.length}l=!1}r.exports=function(v){p.push(v)!==1||l||s()}}).call(this,typeof Ev<"u"?Ev:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var a=n("immediate");function s(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(b){if(typeof b!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,b!==s&&v(this,b)}function g(b,E,w){this.promise=b,typeof E=="function"&&(this.onFulfilled=E,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function p(b,E,w){a(function(){var A;try{A=E(w)}catch(T){return l.reject(b,T)}A===b?l.reject(b,new TypeError("Cannot resolve promise with itself")):l.resolve(b,A)})}function x(b){var E=b&&b.then;if(b&&(typeof b=="object"||typeof b=="function")&&typeof E=="function")return function(){E.apply(b,arguments)}}function v(b,E){var w=!1;function A(N){w||(w=!0,l.reject(b,N))}function T(N){w||(w=!0,l.resolve(b,N))}var C=y(function(){E(T,A)});C.status==="error"&&A(C.value)}function y(b,E){var w={};try{w.value=b(E),w.status="success"}catch(A){w.status="error",w.value=A}return w}(r.exports=f).prototype.finally=function(b){if(typeof b!="function")return this;var E=this.constructor;return this.then(function(w){return E.resolve(b()).then(function(){return w})},function(w){return E.resolve(b()).then(function(){throw w})})},f.prototype.catch=function(b){return this.then(null,b)},f.prototype.then=function(b,E){if(typeof b!="function"&&this.state===u||typeof E!="function"&&this.state===c)return this;var w=new this.constructor(s);return this.state!==d?p(w,this.state===u?b:E,this.outcome):this.queue.push(new g(w,b,E)),w},g.prototype.callFulfilled=function(b){l.resolve(this.promise,b)},g.prototype.otherCallFulfilled=function(b){p(this.promise,this.onFulfilled,b)},g.prototype.callRejected=function(b){l.reject(this.promise,b)},g.prototype.otherCallRejected=function(b){p(this.promise,this.onRejected,b)},l.resolve=function(b,E){var w=y(x,E);if(w.status==="error")return l.reject(b,w.value);var A=w.value;if(A)v(b,A);else{b.state=u,b.outcome=E;for(var T=-1,C=b.queue.length;++T<C;)b.queue[T].callFulfilled(E)}return b},l.reject=function(b,E){b.state=c,b.outcome=E;for(var w=-1,A=b.queue.length;++w<A;)b.queue[w].callRejected(E);return b},f.resolve=function(b){return b instanceof this?b:l.resolve(new this(s),b)},f.reject=function(b){var E=new this(s);return l.reject(E,b)},f.all=function(b){var E=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=b.length,A=!1;if(!w)return this.resolve([]);for(var T=new Array(w),C=0,N=-1,O=new this(s);++N<w;)k(b[N],N);return O;function k(j,B){E.resolve(j).then(function(L){T[B]=L,++C!==w||A||(A=!0,l.resolve(O,T))},function(L){A||(A=!0,l.reject(O,L))})}},f.race=function(b){var E=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=b.length,A=!1;if(!w)return this.resolve([]);for(var T=-1,C=new this(s);++T<w;)N=b[T],E.resolve(N).then(function(O){A||(A=!0,l.resolve(C,O))},function(O){A||(A=!0,l.reject(C,O))});var N;return C}},{immediate:36}],38:[function(n,r,i){var a={};(0,n("./lib/utils/common").assign)(a,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=a},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var a=n("./zlib/deflate"),s=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,g=-1,p=0,x=8;function v(b){if(!(this instanceof v))return new v(b);this.options=s.assign({level:g,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},b||{});var E=this.options;E.raw&&0<E.windowBits?E.windowBits=-E.windowBits:E.gzip&&0<E.windowBits&&E.windowBits<16&&(E.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var w=a.deflateInit2(this.strm,E.level,E.method,E.windowBits,E.memLevel,E.strategy);if(w!==f)throw new Error(c[w]);if(E.header&&a.deflateSetHeader(this.strm,E.header),E.dictionary){var A;if(A=typeof E.dictionary=="string"?l.string2buf(E.dictionary):d.call(E.dictionary)==="[object ArrayBuffer]"?new Uint8Array(E.dictionary):E.dictionary,(w=a.deflateSetDictionary(this.strm,A))!==f)throw new Error(c[w]);this._dict_set=!0}}function y(b,E){var w=new v(E);if(w.push(b,!0),w.err)throw w.msg||c[w.err];return w.result}v.prototype.push=function(b,E){var w,A,T=this.strm,C=this.options.chunkSize;if(this.ended)return!1;A=E===~~E?E:E===!0?4:0,typeof b=="string"?T.input=l.string2buf(b):d.call(b)==="[object ArrayBuffer]"?T.input=new Uint8Array(b):T.input=b,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new s.Buf8(C),T.next_out=0,T.avail_out=C),(w=a.deflate(T,A))!==1&&w!==f)return this.onEnd(w),!(this.ended=!0);T.avail_out!==0&&(T.avail_in!==0||A!==4&&A!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(s.shrinkBuf(T.output,T.next_out))):this.onData(s.shrinkBuf(T.output,T.next_out)))}while((0<T.avail_in||T.avail_out===0)&&w!==1);return A===4?(w=a.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===f):A!==2||(this.onEnd(f),!(T.avail_out=0))},v.prototype.onData=function(b){this.chunks.push(b)},v.prototype.onEnd=function(b){b===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},i.Deflate=v,i.deflate=y,i.deflateRaw=function(b,E){return(E=E||{}).raw=!0,y(b,E)},i.gzip=function(b,E){return(E=E||{}).gzip=!0,y(b,E)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var a=n("./zlib/inflate"),s=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),g=Object.prototype.toString;function p(v){if(!(this instanceof p))return new p(v);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},v||{});var y=this.options;y.raw&&0<=y.windowBits&&y.windowBits<16&&(y.windowBits=-y.windowBits,y.windowBits===0&&(y.windowBits=-15)),!(0<=y.windowBits&&y.windowBits<16)||v&&v.windowBits||(y.windowBits+=32),15<y.windowBits&&y.windowBits<48&&(15&y.windowBits)==0&&(y.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var b=a.inflateInit2(this.strm,y.windowBits);if(b!==c.Z_OK)throw new Error(u[b]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function x(v,y){var b=new p(y);if(b.push(v,!0),b.err)throw b.msg||u[b.err];return b.result}p.prototype.push=function(v,y){var b,E,w,A,T,C,N=this.strm,O=this.options.chunkSize,k=this.options.dictionary,j=!1;if(this.ended)return!1;E=y===~~y?y:y===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof v=="string"?N.input=l.binstring2buf(v):g.call(v)==="[object ArrayBuffer]"?N.input=new Uint8Array(v):N.input=v,N.next_in=0,N.avail_in=N.input.length;do{if(N.avail_out===0&&(N.output=new s.Buf8(O),N.next_out=0,N.avail_out=O),(b=a.inflate(N,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&k&&(C=typeof k=="string"?l.string2buf(k):g.call(k)==="[object ArrayBuffer]"?new Uint8Array(k):k,b=a.inflateSetDictionary(this.strm,C)),b===c.Z_BUF_ERROR&&j===!0&&(b=c.Z_OK,j=!1),b!==c.Z_STREAM_END&&b!==c.Z_OK)return this.onEnd(b),!(this.ended=!0);N.next_out&&(N.avail_out!==0&&b!==c.Z_STREAM_END&&(N.avail_in!==0||E!==c.Z_FINISH&&E!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=l.utf8border(N.output,N.next_out),A=N.next_out-w,T=l.buf2string(N.output,w),N.next_out=A,N.avail_out=O-A,A&&s.arraySet(N.output,N.output,w,A,0),this.onData(T)):this.onData(s.shrinkBuf(N.output,N.next_out)))),N.avail_in===0&&N.avail_out===0&&(j=!0)}while((0<N.avail_in||N.avail_out===0)&&b!==c.Z_STREAM_END);return b===c.Z_STREAM_END&&(E=c.Z_FINISH),E===c.Z_FINISH?(b=a.inflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===c.Z_OK):E!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(N.avail_out=0))},p.prototype.onData=function(v){this.chunks.push(v)},p.prototype.onEnd=function(v){v===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},i.Inflate=p,i.inflate=x,i.inflateRaw=function(v,y){return(y=y||{}).raw=!0,x(v,y)},i.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var s={arraySet:function(c,u,d,f,g){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),g);else for(var p=0;p<f;p++)c[g+p]=u[d+p]},flattenChunks:function(c){var u,d,f,g,p,x;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(x=new Uint8Array(f),u=g=0,d=c.length;u<d;u++)p=c[u],x.set(p,g),g+=p.length;return x}},l={arraySet:function(c,u,d,f,g){for(var p=0;p<f;p++)c[g+p]=u[d+p]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,s)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,l))},i.setTyped(a)},{}],42:[function(n,r,i){var a=n("./common"),s=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!1}for(var c=new a.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,g){if(g<65537&&(f.subarray&&l||!f.subarray&&s))return String.fromCharCode.apply(null,a.shrinkBuf(f,g));for(var p="",x=0;x<g;x++)p+=String.fromCharCode(f[x]);return p}c[254]=c[254]=1,i.string2buf=function(f){var g,p,x,v,y,b=f.length,E=0;for(v=0;v<b;v++)(64512&(p=f.charCodeAt(v)))==55296&&v+1<b&&(64512&(x=f.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),v++),E+=p<128?1:p<2048?2:p<65536?3:4;for(g=new a.Buf8(E),v=y=0;y<E;v++)(64512&(p=f.charCodeAt(v)))==55296&&v+1<b&&(64512&(x=f.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),v++),p<128?g[y++]=p:(p<2048?g[y++]=192|p>>>6:(p<65536?g[y++]=224|p>>>12:(g[y++]=240|p>>>18,g[y++]=128|p>>>12&63),g[y++]=128|p>>>6&63),g[y++]=128|63&p);return g},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var g=new a.Buf8(f.length),p=0,x=g.length;p<x;p++)g[p]=f.charCodeAt(p);return g},i.buf2string=function(f,g){var p,x,v,y,b=g||f.length,E=new Array(2*b);for(p=x=0;p<b;)if((v=f[p++])<128)E[x++]=v;else if(4<(y=c[v]))E[x++]=65533,p+=y-1;else{for(v&=y===2?31:y===3?15:7;1<y&&p<b;)v=v<<6|63&f[p++],y--;1<y?E[x++]=65533:v<65536?E[x++]=v:(v-=65536,E[x++]=55296|v>>10&1023,E[x++]=56320|1023&v)}return d(E,x)},i.utf8border=function(f,g){var p;for((g=g||f.length)>f.length&&(g=f.length),p=g-1;0<=p&&(192&f[p])==128;)p--;return p<0||p===0?g:p+c[f[p]]>g?p:g}},{"./common":41}],43:[function(n,r,i){r.exports=function(a,s,l,c){for(var u=65535&a|0,d=a>>>16&65535|0,f=0;l!==0;){for(l-=f=2e3<l?2e3:l;d=d+(u=u+s[c++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var a=(function(){for(var s,l=[],c=0;c<256;c++){s=c;for(var u=0;u<8;u++)s=1&s?3988292384^s>>>1:s>>>1;l[c]=s}return l})();r.exports=function(s,l,c,u){var d=a,f=u+c;s^=-1;for(var g=u;g<f;g++)s=s>>>8^d[255&(s^l[g])];return-1^s}},{}],46:[function(n,r,i){var a,s=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,g=4,p=0,x=-2,v=-1,y=4,b=2,E=8,w=9,A=286,T=30,C=19,N=2*A+1,O=15,k=3,j=258,B=j+k+1,L=42,K=113,R=1,q=2,W=3,$=4;function J(U,H){return U.msg=d[H],H}function ee(U){return(U<<1)-(4<U?9:0)}function Q(U){for(var H=U.length;0<=--H;)U[H]=0}function z(U){var H=U.state,re=H.pending;re>U.avail_out&&(re=U.avail_out),re!==0&&(s.arraySet(U.output,H.pending_buf,H.pending_out,re,U.next_out),U.next_out+=re,H.pending_out+=re,U.total_out+=re,U.avail_out-=re,H.pending-=re,H.pending===0&&(H.pending_out=0))}function V(U,H){l._tr_flush_block(U,0<=U.block_start?U.block_start:-1,U.strstart-U.block_start,H),U.block_start=U.strstart,z(U.strm)}function X(U,H){U.pending_buf[U.pending++]=H}function te(U,H){U.pending_buf[U.pending++]=H>>>8&255,U.pending_buf[U.pending++]=255&H}function ie(U,H){var re,G,Z=U.max_chain_length,oe=U.strstart,be=U.prev_length,Te=U.nice_match,Me=U.strstart>U.w_size-B?U.strstart-(U.w_size-B):0,F=U.window,I=U.w_mask,ne=U.prev,ve=U.strstart+j,Se=F[oe+be-1],ye=F[oe+be];U.prev_length>=U.good_match&&(Z>>=2),Te>U.lookahead&&(Te=U.lookahead);do if(F[(re=H)+be]===ye&&F[re+be-1]===Se&&F[re]===F[oe]&&F[++re]===F[oe+1]){oe+=2,re++;do;while(F[++oe]===F[++re]&&F[++oe]===F[++re]&&F[++oe]===F[++re]&&F[++oe]===F[++re]&&F[++oe]===F[++re]&&F[++oe]===F[++re]&&F[++oe]===F[++re]&&F[++oe]===F[++re]&&oe<ve);if(G=j-(ve-oe),oe=ve-j,be<G){if(U.match_start=H,Te<=(be=G))break;Se=F[oe+be-1],ye=F[oe+be]}}while((H=ne[H&I])>Me&&--Z!=0);return be<=U.lookahead?be:U.lookahead}function le(U){var H,re,G,Z,oe,be,Te,Me,F,I,ne=U.w_size;do{if(Z=U.window_size-U.lookahead-U.strstart,U.strstart>=ne+(ne-B)){for(s.arraySet(U.window,U.window,ne,ne,0),U.match_start-=ne,U.strstart-=ne,U.block_start-=ne,H=re=U.hash_size;G=U.head[--H],U.head[H]=ne<=G?G-ne:0,--re;);for(H=re=ne;G=U.prev[--H],U.prev[H]=ne<=G?G-ne:0,--re;);Z+=ne}if(U.strm.avail_in===0)break;if(be=U.strm,Te=U.window,Me=U.strstart+U.lookahead,F=Z,I=void 0,I=be.avail_in,F<I&&(I=F),re=I===0?0:(be.avail_in-=I,s.arraySet(Te,be.input,be.next_in,I,Me),be.state.wrap===1?be.adler=c(be.adler,Te,I,Me):be.state.wrap===2&&(be.adler=u(be.adler,Te,I,Me)),be.next_in+=I,be.total_in+=I,I),U.lookahead+=re,U.lookahead+U.insert>=k)for(oe=U.strstart-U.insert,U.ins_h=U.window[oe],U.ins_h=(U.ins_h<<U.hash_shift^U.window[oe+1])&U.hash_mask;U.insert&&(U.ins_h=(U.ins_h<<U.hash_shift^U.window[oe+k-1])&U.hash_mask,U.prev[oe&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=oe,oe++,U.insert--,!(U.lookahead+U.insert<k)););}while(U.lookahead<B&&U.strm.avail_in!==0)}function ge(U,H){for(var re,G;;){if(U.lookahead<B){if(le(U),U.lookahead<B&&H===f)return R;if(U.lookahead===0)break}if(re=0,U.lookahead>=k&&(U.ins_h=(U.ins_h<<U.hash_shift^U.window[U.strstart+k-1])&U.hash_mask,re=U.prev[U.strstart&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=U.strstart),re!==0&&U.strstart-re<=U.w_size-B&&(U.match_length=ie(U,re)),U.match_length>=k)if(G=l._tr_tally(U,U.strstart-U.match_start,U.match_length-k),U.lookahead-=U.match_length,U.match_length<=U.max_lazy_match&&U.lookahead>=k){for(U.match_length--;U.strstart++,U.ins_h=(U.ins_h<<U.hash_shift^U.window[U.strstart+k-1])&U.hash_mask,re=U.prev[U.strstart&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=U.strstart,--U.match_length!=0;);U.strstart++}else U.strstart+=U.match_length,U.match_length=0,U.ins_h=U.window[U.strstart],U.ins_h=(U.ins_h<<U.hash_shift^U.window[U.strstart+1])&U.hash_mask;else G=l._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++;if(G&&(V(U,!1),U.strm.avail_out===0))return R}return U.insert=U.strstart<k-1?U.strstart:k-1,H===g?(V(U,!0),U.strm.avail_out===0?W:$):U.last_lit&&(V(U,!1),U.strm.avail_out===0)?R:q}function Ee(U,H){for(var re,G,Z;;){if(U.lookahead<B){if(le(U),U.lookahead<B&&H===f)return R;if(U.lookahead===0)break}if(re=0,U.lookahead>=k&&(U.ins_h=(U.ins_h<<U.hash_shift^U.window[U.strstart+k-1])&U.hash_mask,re=U.prev[U.strstart&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=U.strstart),U.prev_length=U.match_length,U.prev_match=U.match_start,U.match_length=k-1,re!==0&&U.prev_length<U.max_lazy_match&&U.strstart-re<=U.w_size-B&&(U.match_length=ie(U,re),U.match_length<=5&&(U.strategy===1||U.match_length===k&&4096<U.strstart-U.match_start)&&(U.match_length=k-1)),U.prev_length>=k&&U.match_length<=U.prev_length){for(Z=U.strstart+U.lookahead-k,G=l._tr_tally(U,U.strstart-1-U.prev_match,U.prev_length-k),U.lookahead-=U.prev_length-1,U.prev_length-=2;++U.strstart<=Z&&(U.ins_h=(U.ins_h<<U.hash_shift^U.window[U.strstart+k-1])&U.hash_mask,re=U.prev[U.strstart&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=U.strstart),--U.prev_length!=0;);if(U.match_available=0,U.match_length=k-1,U.strstart++,G&&(V(U,!1),U.strm.avail_out===0))return R}else if(U.match_available){if((G=l._tr_tally(U,0,U.window[U.strstart-1]))&&V(U,!1),U.strstart++,U.lookahead--,U.strm.avail_out===0)return R}else U.match_available=1,U.strstart++,U.lookahead--}return U.match_available&&(G=l._tr_tally(U,0,U.window[U.strstart-1]),U.match_available=0),U.insert=U.strstart<k-1?U.strstart:k-1,H===g?(V(U,!0),U.strm.avail_out===0?W:$):U.last_lit&&(V(U,!1),U.strm.avail_out===0)?R:q}function pe(U,H,re,G,Z){this.good_length=U,this.max_lazy=H,this.nice_length=re,this.max_chain=G,this.func=Z}function de(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=E,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*N),this.dyn_dtree=new s.Buf16(2*(2*T+1)),this.bl_tree=new s.Buf16(2*(2*C+1)),Q(this.dyn_ltree),Q(this.dyn_dtree),Q(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(O+1),this.heap=new s.Buf16(2*A+1),Q(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*A+1),Q(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Re(U){var H;return U&&U.state?(U.total_in=U.total_out=0,U.data_type=b,(H=U.state).pending=0,H.pending_out=0,H.wrap<0&&(H.wrap=-H.wrap),H.status=H.wrap?L:K,U.adler=H.wrap===2?0:1,H.last_flush=f,l._tr_init(H),p):J(U,x)}function fe(U){var H=Re(U);return H===p&&(function(re){re.window_size=2*re.w_size,Q(re.head),re.max_lazy_match=a[re.level].max_lazy,re.good_match=a[re.level].good_length,re.nice_match=a[re.level].nice_length,re.max_chain_length=a[re.level].max_chain,re.strstart=0,re.block_start=0,re.lookahead=0,re.insert=0,re.match_length=re.prev_length=k-1,re.match_available=0,re.ins_h=0})(U.state),H}function Fe(U,H,re,G,Z,oe){if(!U)return x;var be=1;if(H===v&&(H=6),G<0?(be=0,G=-G):15<G&&(be=2,G-=16),Z<1||w<Z||re!==E||G<8||15<G||H<0||9<H||oe<0||y<oe)return J(U,x);G===8&&(G=9);var Te=new de;return(U.state=Te).strm=U,Te.wrap=be,Te.gzhead=null,Te.w_bits=G,Te.w_size=1<<Te.w_bits,Te.w_mask=Te.w_size-1,Te.hash_bits=Z+7,Te.hash_size=1<<Te.hash_bits,Te.hash_mask=Te.hash_size-1,Te.hash_shift=~~((Te.hash_bits+k-1)/k),Te.window=new s.Buf8(2*Te.w_size),Te.head=new s.Buf16(Te.hash_size),Te.prev=new s.Buf16(Te.w_size),Te.lit_bufsize=1<<Z+6,Te.pending_buf_size=4*Te.lit_bufsize,Te.pending_buf=new s.Buf8(Te.pending_buf_size),Te.d_buf=1*Te.lit_bufsize,Te.l_buf=3*Te.lit_bufsize,Te.level=H,Te.strategy=oe,Te.method=re,fe(U)}a=[new pe(0,0,0,0,function(U,H){var re=65535;for(re>U.pending_buf_size-5&&(re=U.pending_buf_size-5);;){if(U.lookahead<=1){if(le(U),U.lookahead===0&&H===f)return R;if(U.lookahead===0)break}U.strstart+=U.lookahead,U.lookahead=0;var G=U.block_start+re;if((U.strstart===0||U.strstart>=G)&&(U.lookahead=U.strstart-G,U.strstart=G,V(U,!1),U.strm.avail_out===0)||U.strstart-U.block_start>=U.w_size-B&&(V(U,!1),U.strm.avail_out===0))return R}return U.insert=0,H===g?(V(U,!0),U.strm.avail_out===0?W:$):(U.strstart>U.block_start&&(V(U,!1),U.strm.avail_out),R)}),new pe(4,4,8,4,ge),new pe(4,5,16,8,ge),new pe(4,6,32,32,ge),new pe(4,4,16,16,Ee),new pe(8,16,32,32,Ee),new pe(8,16,128,128,Ee),new pe(8,32,128,256,Ee),new pe(32,128,258,1024,Ee),new pe(32,258,258,4096,Ee)],i.deflateInit=function(U,H){return Fe(U,H,E,15,8,0)},i.deflateInit2=Fe,i.deflateReset=fe,i.deflateResetKeep=Re,i.deflateSetHeader=function(U,H){return U&&U.state?U.state.wrap!==2?x:(U.state.gzhead=H,p):x},i.deflate=function(U,H){var re,G,Z,oe;if(!U||!U.state||5<H||H<0)return U?J(U,x):x;if(G=U.state,!U.output||!U.input&&U.avail_in!==0||G.status===666&&H!==g)return J(U,U.avail_out===0?-5:x);if(G.strm=U,re=G.last_flush,G.last_flush=H,G.status===L)if(G.wrap===2)U.adler=0,X(G,31),X(G,139),X(G,8),G.gzhead?(X(G,(G.gzhead.text?1:0)+(G.gzhead.hcrc?2:0)+(G.gzhead.extra?4:0)+(G.gzhead.name?8:0)+(G.gzhead.comment?16:0)),X(G,255&G.gzhead.time),X(G,G.gzhead.time>>8&255),X(G,G.gzhead.time>>16&255),X(G,G.gzhead.time>>24&255),X(G,G.level===9?2:2<=G.strategy||G.level<2?4:0),X(G,255&G.gzhead.os),G.gzhead.extra&&G.gzhead.extra.length&&(X(G,255&G.gzhead.extra.length),X(G,G.gzhead.extra.length>>8&255)),G.gzhead.hcrc&&(U.adler=u(U.adler,G.pending_buf,G.pending,0)),G.gzindex=0,G.status=69):(X(G,0),X(G,0),X(G,0),X(G,0),X(G,0),X(G,G.level===9?2:2<=G.strategy||G.level<2?4:0),X(G,3),G.status=K);else{var be=E+(G.w_bits-8<<4)<<8;be|=(2<=G.strategy||G.level<2?0:G.level<6?1:G.level===6?2:3)<<6,G.strstart!==0&&(be|=32),be+=31-be%31,G.status=K,te(G,be),G.strstart!==0&&(te(G,U.adler>>>16),te(G,65535&U.adler)),U.adler=1}if(G.status===69)if(G.gzhead.extra){for(Z=G.pending;G.gzindex<(65535&G.gzhead.extra.length)&&(G.pending!==G.pending_buf_size||(G.gzhead.hcrc&&G.pending>Z&&(U.adler=u(U.adler,G.pending_buf,G.pending-Z,Z)),z(U),Z=G.pending,G.pending!==G.pending_buf_size));)X(G,255&G.gzhead.extra[G.gzindex]),G.gzindex++;G.gzhead.hcrc&&G.pending>Z&&(U.adler=u(U.adler,G.pending_buf,G.pending-Z,Z)),G.gzindex===G.gzhead.extra.length&&(G.gzindex=0,G.status=73)}else G.status=73;if(G.status===73)if(G.gzhead.name){Z=G.pending;do{if(G.pending===G.pending_buf_size&&(G.gzhead.hcrc&&G.pending>Z&&(U.adler=u(U.adler,G.pending_buf,G.pending-Z,Z)),z(U),Z=G.pending,G.pending===G.pending_buf_size)){oe=1;break}oe=G.gzindex<G.gzhead.name.length?255&G.gzhead.name.charCodeAt(G.gzindex++):0,X(G,oe)}while(oe!==0);G.gzhead.hcrc&&G.pending>Z&&(U.adler=u(U.adler,G.pending_buf,G.pending-Z,Z)),oe===0&&(G.gzindex=0,G.status=91)}else G.status=91;if(G.status===91)if(G.gzhead.comment){Z=G.pending;do{if(G.pending===G.pending_buf_size&&(G.gzhead.hcrc&&G.pending>Z&&(U.adler=u(U.adler,G.pending_buf,G.pending-Z,Z)),z(U),Z=G.pending,G.pending===G.pending_buf_size)){oe=1;break}oe=G.gzindex<G.gzhead.comment.length?255&G.gzhead.comment.charCodeAt(G.gzindex++):0,X(G,oe)}while(oe!==0);G.gzhead.hcrc&&G.pending>Z&&(U.adler=u(U.adler,G.pending_buf,G.pending-Z,Z)),oe===0&&(G.status=103)}else G.status=103;if(G.status===103&&(G.gzhead.hcrc?(G.pending+2>G.pending_buf_size&&z(U),G.pending+2<=G.pending_buf_size&&(X(G,255&U.adler),X(G,U.adler>>8&255),U.adler=0,G.status=K)):G.status=K),G.pending!==0){if(z(U),U.avail_out===0)return G.last_flush=-1,p}else if(U.avail_in===0&&ee(H)<=ee(re)&&H!==g)return J(U,-5);if(G.status===666&&U.avail_in!==0)return J(U,-5);if(U.avail_in!==0||G.lookahead!==0||H!==f&&G.status!==666){var Te=G.strategy===2?(function(Me,F){for(var I;;){if(Me.lookahead===0&&(le(Me),Me.lookahead===0)){if(F===f)return R;break}if(Me.match_length=0,I=l._tr_tally(Me,0,Me.window[Me.strstart]),Me.lookahead--,Me.strstart++,I&&(V(Me,!1),Me.strm.avail_out===0))return R}return Me.insert=0,F===g?(V(Me,!0),Me.strm.avail_out===0?W:$):Me.last_lit&&(V(Me,!1),Me.strm.avail_out===0)?R:q})(G,H):G.strategy===3?(function(Me,F){for(var I,ne,ve,Se,ye=Me.window;;){if(Me.lookahead<=j){if(le(Me),Me.lookahead<=j&&F===f)return R;if(Me.lookahead===0)break}if(Me.match_length=0,Me.lookahead>=k&&0<Me.strstart&&(ne=ye[ve=Me.strstart-1])===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]){Se=Me.strstart+j;do;while(ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ne===ye[++ve]&&ve<Se);Me.match_length=j-(Se-ve),Me.match_length>Me.lookahead&&(Me.match_length=Me.lookahead)}if(Me.match_length>=k?(I=l._tr_tally(Me,1,Me.match_length-k),Me.lookahead-=Me.match_length,Me.strstart+=Me.match_length,Me.match_length=0):(I=l._tr_tally(Me,0,Me.window[Me.strstart]),Me.lookahead--,Me.strstart++),I&&(V(Me,!1),Me.strm.avail_out===0))return R}return Me.insert=0,F===g?(V(Me,!0),Me.strm.avail_out===0?W:$):Me.last_lit&&(V(Me,!1),Me.strm.avail_out===0)?R:q})(G,H):a[G.level].func(G,H);if(Te!==W&&Te!==$||(G.status=666),Te===R||Te===W)return U.avail_out===0&&(G.last_flush=-1),p;if(Te===q&&(H===1?l._tr_align(G):H!==5&&(l._tr_stored_block(G,0,0,!1),H===3&&(Q(G.head),G.lookahead===0&&(G.strstart=0,G.block_start=0,G.insert=0))),z(U),U.avail_out===0))return G.last_flush=-1,p}return H!==g?p:G.wrap<=0?1:(G.wrap===2?(X(G,255&U.adler),X(G,U.adler>>8&255),X(G,U.adler>>16&255),X(G,U.adler>>24&255),X(G,255&U.total_in),X(G,U.total_in>>8&255),X(G,U.total_in>>16&255),X(G,U.total_in>>24&255)):(te(G,U.adler>>>16),te(G,65535&U.adler)),z(U),0<G.wrap&&(G.wrap=-G.wrap),G.pending!==0?p:1)},i.deflateEnd=function(U){var H;return U&&U.state?(H=U.state.status)!==L&&H!==69&&H!==73&&H!==91&&H!==103&&H!==K&&H!==666?J(U,x):(U.state=null,H===K?J(U,-3):p):x},i.deflateSetDictionary=function(U,H){var re,G,Z,oe,be,Te,Me,F,I=H.length;if(!U||!U.state||(oe=(re=U.state).wrap)===2||oe===1&&re.status!==L||re.lookahead)return x;for(oe===1&&(U.adler=c(U.adler,H,I,0)),re.wrap=0,I>=re.w_size&&(oe===0&&(Q(re.head),re.strstart=0,re.block_start=0,re.insert=0),F=new s.Buf8(re.w_size),s.arraySet(F,H,I-re.w_size,re.w_size,0),H=F,I=re.w_size),be=U.avail_in,Te=U.next_in,Me=U.input,U.avail_in=I,U.next_in=0,U.input=H,le(re);re.lookahead>=k;){for(G=re.strstart,Z=re.lookahead-(k-1);re.ins_h=(re.ins_h<<re.hash_shift^re.window[G+k-1])&re.hash_mask,re.prev[G&re.w_mask]=re.head[re.ins_h],re.head[re.ins_h]=G,G++,--Z;);re.strstart=G,re.lookahead=k-1,le(re)}return re.strstart+=re.lookahead,re.block_start=re.strstart,re.insert=re.lookahead,re.lookahead=0,re.match_length=re.prev_length=k-1,re.match_available=0,U.next_in=Te,U.input=Me,U.avail_in=be,re.wrap=oe,p},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(a,s){var l,c,u,d,f,g,p,x,v,y,b,E,w,A,T,C,N,O,k,j,B,L,K,R,q;l=a.state,c=a.next_in,R=a.input,u=c+(a.avail_in-5),d=a.next_out,q=a.output,f=d-(s-a.avail_out),g=d+(a.avail_out-257),p=l.dmax,x=l.wsize,v=l.whave,y=l.wnext,b=l.window,E=l.hold,w=l.bits,A=l.lencode,T=l.distcode,C=(1<<l.lenbits)-1,N=(1<<l.distbits)-1;e:do{w<15&&(E+=R[c++]<<w,w+=8,E+=R[c++]<<w,w+=8),O=A[E&C];t:for(;;){if(E>>>=k=O>>>24,w-=k,(k=O>>>16&255)===0)q[d++]=65535&O;else{if(!(16&k)){if((64&k)==0){O=A[(65535&O)+(E&(1<<k)-1)];continue t}if(32&k){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}j=65535&O,(k&=15)&&(w<k&&(E+=R[c++]<<w,w+=8),j+=E&(1<<k)-1,E>>>=k,w-=k),w<15&&(E+=R[c++]<<w,w+=8,E+=R[c++]<<w,w+=8),O=T[E&N];n:for(;;){if(E>>>=k=O>>>24,w-=k,!(16&(k=O>>>16&255))){if((64&k)==0){O=T[(65535&O)+(E&(1<<k)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(B=65535&O,w<(k&=15)&&(E+=R[c++]<<w,(w+=8)<k&&(E+=R[c++]<<w,w+=8)),p<(B+=E&(1<<k)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(E>>>=k,w-=k,(k=d-f)<B){if(v<(k=B-k)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(K=b,(L=0)===y){if(L+=x-k,k<j){for(j-=k;q[d++]=b[L++],--k;);L=d-B,K=q}}else if(y<k){if(L+=x+y-k,(k-=y)<j){for(j-=k;q[d++]=b[L++],--k;);if(L=0,y<j){for(j-=k=y;q[d++]=b[L++],--k;);L=d-B,K=q}}}else if(L+=y-k,k<j){for(j-=k;q[d++]=b[L++],--k;);L=d-B,K=q}for(;2<j;)q[d++]=K[L++],q[d++]=K[L++],q[d++]=K[L++],j-=3;j&&(q[d++]=K[L++],1<j&&(q[d++]=K[L++]))}else{for(L=d-B;q[d++]=q[L++],q[d++]=q[L++],q[d++]=q[L++],2<(j-=3););j&&(q[d++]=q[L++],1<j&&(q[d++]=q[L++]))}break}}break}}while(c<u&&d<g);c-=j=w>>3,E&=(1<<(w-=j<<3))-1,a.next_in=c,a.next_out=d,a.avail_in=c<u?u-c+5:5-(c-u),a.avail_out=d<g?g-d+257:257-(d-g),l.hold=E,l.bits=w}},{}],49:[function(n,r,i){var a=n("../utils/common"),s=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,g=0,p=-2,x=1,v=852,y=592;function b(L){return(L>>>24&255)+(L>>>8&65280)+((65280&L)<<8)+((255&L)<<24)}function E(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(L){var K;return L&&L.state?(K=L.state,L.total_in=L.total_out=K.total=0,L.msg="",K.wrap&&(L.adler=1&K.wrap),K.mode=x,K.last=0,K.havedict=0,K.dmax=32768,K.head=null,K.hold=0,K.bits=0,K.lencode=K.lendyn=new a.Buf32(v),K.distcode=K.distdyn=new a.Buf32(y),K.sane=1,K.back=-1,g):p}function A(L){var K;return L&&L.state?((K=L.state).wsize=0,K.whave=0,K.wnext=0,w(L)):p}function T(L,K){var R,q;return L&&L.state?(q=L.state,K<0?(R=0,K=-K):(R=1+(K>>4),K<48&&(K&=15)),K&&(K<8||15<K)?p:(q.window!==null&&q.wbits!==K&&(q.window=null),q.wrap=R,q.wbits=K,A(L))):p}function C(L,K){var R,q;return L?(q=new E,(L.state=q).window=null,(R=T(L,K))!==g&&(L.state=null),R):p}var N,O,k=!0;function j(L){if(k){var K;for(N=new a.Buf32(512),O=new a.Buf32(32),K=0;K<144;)L.lens[K++]=8;for(;K<256;)L.lens[K++]=9;for(;K<280;)L.lens[K++]=7;for(;K<288;)L.lens[K++]=8;for(u(d,L.lens,0,288,N,0,L.work,{bits:9}),K=0;K<32;)L.lens[K++]=5;u(f,L.lens,0,32,O,0,L.work,{bits:5}),k=!1}L.lencode=N,L.lenbits=9,L.distcode=O,L.distbits=5}function B(L,K,R,q){var W,$=L.state;return $.window===null&&($.wsize=1<<$.wbits,$.wnext=0,$.whave=0,$.window=new a.Buf8($.wsize)),q>=$.wsize?(a.arraySet($.window,K,R-$.wsize,$.wsize,0),$.wnext=0,$.whave=$.wsize):(q<(W=$.wsize-$.wnext)&&(W=q),a.arraySet($.window,K,R-q,W,$.wnext),(q-=W)?(a.arraySet($.window,K,R-q,q,0),$.wnext=q,$.whave=$.wsize):($.wnext+=W,$.wnext===$.wsize&&($.wnext=0),$.whave<$.wsize&&($.whave+=W))),0}i.inflateReset=A,i.inflateReset2=T,i.inflateResetKeep=w,i.inflateInit=function(L){return C(L,15)},i.inflateInit2=C,i.inflate=function(L,K){var R,q,W,$,J,ee,Q,z,V,X,te,ie,le,ge,Ee,pe,de,Re,fe,Fe,U,H,re,G,Z=0,oe=new a.Buf8(4),be=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!L||!L.state||!L.output||!L.input&&L.avail_in!==0)return p;(R=L.state).mode===12&&(R.mode=13),J=L.next_out,W=L.output,Q=L.avail_out,$=L.next_in,q=L.input,ee=L.avail_in,z=R.hold,V=R.bits,X=ee,te=Q,H=g;e:for(;;)switch(R.mode){case x:if(R.wrap===0){R.mode=13;break}for(;V<16;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}if(2&R.wrap&&z===35615){oe[R.check=0]=255&z,oe[1]=z>>>8&255,R.check=l(R.check,oe,2,0),V=z=0,R.mode=2;break}if(R.flags=0,R.head&&(R.head.done=!1),!(1&R.wrap)||(((255&z)<<8)+(z>>8))%31){L.msg="incorrect header check",R.mode=30;break}if((15&z)!=8){L.msg="unknown compression method",R.mode=30;break}if(V-=4,U=8+(15&(z>>>=4)),R.wbits===0)R.wbits=U;else if(U>R.wbits){L.msg="invalid window size",R.mode=30;break}R.dmax=1<<U,L.adler=R.check=1,R.mode=512&z?10:12,V=z=0;break;case 2:for(;V<16;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}if(R.flags=z,(255&R.flags)!=8){L.msg="unknown compression method",R.mode=30;break}if(57344&R.flags){L.msg="unknown header flags set",R.mode=30;break}R.head&&(R.head.text=z>>8&1),512&R.flags&&(oe[0]=255&z,oe[1]=z>>>8&255,R.check=l(R.check,oe,2,0)),V=z=0,R.mode=3;case 3:for(;V<32;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}R.head&&(R.head.time=z),512&R.flags&&(oe[0]=255&z,oe[1]=z>>>8&255,oe[2]=z>>>16&255,oe[3]=z>>>24&255,R.check=l(R.check,oe,4,0)),V=z=0,R.mode=4;case 4:for(;V<16;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}R.head&&(R.head.xflags=255&z,R.head.os=z>>8),512&R.flags&&(oe[0]=255&z,oe[1]=z>>>8&255,R.check=l(R.check,oe,2,0)),V=z=0,R.mode=5;case 5:if(1024&R.flags){for(;V<16;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}R.length=z,R.head&&(R.head.extra_len=z),512&R.flags&&(oe[0]=255&z,oe[1]=z>>>8&255,R.check=l(R.check,oe,2,0)),V=z=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(ee<(ie=R.length)&&(ie=ee),ie&&(R.head&&(U=R.head.extra_len-R.length,R.head.extra||(R.head.extra=new Array(R.head.extra_len)),a.arraySet(R.head.extra,q,$,ie,U)),512&R.flags&&(R.check=l(R.check,q,ie,$)),ee-=ie,$+=ie,R.length-=ie),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(ee===0)break e;for(ie=0;U=q[$+ie++],R.head&&U&&R.length<65536&&(R.head.name+=String.fromCharCode(U)),U&&ie<ee;);if(512&R.flags&&(R.check=l(R.check,q,ie,$)),ee-=ie,$+=ie,U)break e}else R.head&&(R.head.name=null);R.length=0,R.mode=8;case 8:if(4096&R.flags){if(ee===0)break e;for(ie=0;U=q[$+ie++],R.head&&U&&R.length<65536&&(R.head.comment+=String.fromCharCode(U)),U&&ie<ee;);if(512&R.flags&&(R.check=l(R.check,q,ie,$)),ee-=ie,$+=ie,U)break e}else R.head&&(R.head.comment=null);R.mode=9;case 9:if(512&R.flags){for(;V<16;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}if(z!==(65535&R.check)){L.msg="header crc mismatch",R.mode=30;break}V=z=0}R.head&&(R.head.hcrc=R.flags>>9&1,R.head.done=!0),L.adler=R.check=0,R.mode=12;break;case 10:for(;V<32;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}L.adler=R.check=b(z),V=z=0,R.mode=11;case 11:if(R.havedict===0)return L.next_out=J,L.avail_out=Q,L.next_in=$,L.avail_in=ee,R.hold=z,R.bits=V,2;L.adler=R.check=1,R.mode=12;case 12:if(K===5||K===6)break e;case 13:if(R.last){z>>>=7&V,V-=7&V,R.mode=27;break}for(;V<3;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}switch(R.last=1&z,V-=1,3&(z>>>=1)){case 0:R.mode=14;break;case 1:if(j(R),R.mode=20,K!==6)break;z>>>=2,V-=2;break e;case 2:R.mode=17;break;case 3:L.msg="invalid block type",R.mode=30}z>>>=2,V-=2;break;case 14:for(z>>>=7&V,V-=7&V;V<32;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}if((65535&z)!=(z>>>16^65535)){L.msg="invalid stored block lengths",R.mode=30;break}if(R.length=65535&z,V=z=0,R.mode=15,K===6)break e;case 15:R.mode=16;case 16:if(ie=R.length){if(ee<ie&&(ie=ee),Q<ie&&(ie=Q),ie===0)break e;a.arraySet(W,q,$,ie,J),ee-=ie,$+=ie,Q-=ie,J+=ie,R.length-=ie;break}R.mode=12;break;case 17:for(;V<14;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}if(R.nlen=257+(31&z),z>>>=5,V-=5,R.ndist=1+(31&z),z>>>=5,V-=5,R.ncode=4+(15&z),z>>>=4,V-=4,286<R.nlen||30<R.ndist){L.msg="too many length or distance symbols",R.mode=30;break}R.have=0,R.mode=18;case 18:for(;R.have<R.ncode;){for(;V<3;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}R.lens[be[R.have++]]=7&z,z>>>=3,V-=3}for(;R.have<19;)R.lens[be[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,re={bits:R.lenbits},H=u(0,R.lens,0,19,R.lencode,0,R.work,re),R.lenbits=re.bits,H){L.msg="invalid code lengths set",R.mode=30;break}R.have=0,R.mode=19;case 19:for(;R.have<R.nlen+R.ndist;){for(;pe=(Z=R.lencode[z&(1<<R.lenbits)-1])>>>16&255,de=65535&Z,!((Ee=Z>>>24)<=V);){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}if(de<16)z>>>=Ee,V-=Ee,R.lens[R.have++]=de;else{if(de===16){for(G=Ee+2;V<G;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}if(z>>>=Ee,V-=Ee,R.have===0){L.msg="invalid bit length repeat",R.mode=30;break}U=R.lens[R.have-1],ie=3+(3&z),z>>>=2,V-=2}else if(de===17){for(G=Ee+3;V<G;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}V-=Ee,U=0,ie=3+(7&(z>>>=Ee)),z>>>=3,V-=3}else{for(G=Ee+7;V<G;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}V-=Ee,U=0,ie=11+(127&(z>>>=Ee)),z>>>=7,V-=7}if(R.have+ie>R.nlen+R.ndist){L.msg="invalid bit length repeat",R.mode=30;break}for(;ie--;)R.lens[R.have++]=U}}if(R.mode===30)break;if(R.lens[256]===0){L.msg="invalid code -- missing end-of-block",R.mode=30;break}if(R.lenbits=9,re={bits:R.lenbits},H=u(d,R.lens,0,R.nlen,R.lencode,0,R.work,re),R.lenbits=re.bits,H){L.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,re={bits:R.distbits},H=u(f,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,re),R.distbits=re.bits,H){L.msg="invalid distances set",R.mode=30;break}if(R.mode=20,K===6)break e;case 20:R.mode=21;case 21:if(6<=ee&&258<=Q){L.next_out=J,L.avail_out=Q,L.next_in=$,L.avail_in=ee,R.hold=z,R.bits=V,c(L,te),J=L.next_out,W=L.output,Q=L.avail_out,$=L.next_in,q=L.input,ee=L.avail_in,z=R.hold,V=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;pe=(Z=R.lencode[z&(1<<R.lenbits)-1])>>>16&255,de=65535&Z,!((Ee=Z>>>24)<=V);){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}if(pe&&(240&pe)==0){for(Re=Ee,fe=pe,Fe=de;pe=(Z=R.lencode[Fe+((z&(1<<Re+fe)-1)>>Re)])>>>16&255,de=65535&Z,!(Re+(Ee=Z>>>24)<=V);){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}z>>>=Re,V-=Re,R.back+=Re}if(z>>>=Ee,V-=Ee,R.back+=Ee,R.length=de,pe===0){R.mode=26;break}if(32&pe){R.back=-1,R.mode=12;break}if(64&pe){L.msg="invalid literal/length code",R.mode=30;break}R.extra=15&pe,R.mode=22;case 22:if(R.extra){for(G=R.extra;V<G;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}R.length+=z&(1<<R.extra)-1,z>>>=R.extra,V-=R.extra,R.back+=R.extra}R.was=R.length,R.mode=23;case 23:for(;pe=(Z=R.distcode[z&(1<<R.distbits)-1])>>>16&255,de=65535&Z,!((Ee=Z>>>24)<=V);){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}if((240&pe)==0){for(Re=Ee,fe=pe,Fe=de;pe=(Z=R.distcode[Fe+((z&(1<<Re+fe)-1)>>Re)])>>>16&255,de=65535&Z,!(Re+(Ee=Z>>>24)<=V);){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}z>>>=Re,V-=Re,R.back+=Re}if(z>>>=Ee,V-=Ee,R.back+=Ee,64&pe){L.msg="invalid distance code",R.mode=30;break}R.offset=de,R.extra=15&pe,R.mode=24;case 24:if(R.extra){for(G=R.extra;V<G;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}R.offset+=z&(1<<R.extra)-1,z>>>=R.extra,V-=R.extra,R.back+=R.extra}if(R.offset>R.dmax){L.msg="invalid distance too far back",R.mode=30;break}R.mode=25;case 25:if(Q===0)break e;if(ie=te-Q,R.offset>ie){if((ie=R.offset-ie)>R.whave&&R.sane){L.msg="invalid distance too far back",R.mode=30;break}le=ie>R.wnext?(ie-=R.wnext,R.wsize-ie):R.wnext-ie,ie>R.length&&(ie=R.length),ge=R.window}else ge=W,le=J-R.offset,ie=R.length;for(Q<ie&&(ie=Q),Q-=ie,R.length-=ie;W[J++]=ge[le++],--ie;);R.length===0&&(R.mode=21);break;case 26:if(Q===0)break e;W[J++]=R.length,Q--,R.mode=21;break;case 27:if(R.wrap){for(;V<32;){if(ee===0)break e;ee--,z|=q[$++]<<V,V+=8}if(te-=Q,L.total_out+=te,R.total+=te,te&&(L.adler=R.check=R.flags?l(R.check,W,te,J-te):s(R.check,W,te,J-te)),te=Q,(R.flags?z:b(z))!==R.check){L.msg="incorrect data check",R.mode=30;break}V=z=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;V<32;){if(ee===0)break e;ee--,z+=q[$++]<<V,V+=8}if(z!==(4294967295&R.total)){L.msg="incorrect length check",R.mode=30;break}V=z=0}R.mode=29;case 29:H=1;break e;case 30:H=-3;break e;case 31:return-4;case 32:default:return p}return L.next_out=J,L.avail_out=Q,L.next_in=$,L.avail_in=ee,R.hold=z,R.bits=V,(R.wsize||te!==L.avail_out&&R.mode<30&&(R.mode<27||K!==4))&&B(L,L.output,L.next_out,te-L.avail_out)?(R.mode=31,-4):(X-=L.avail_in,te-=L.avail_out,L.total_in+=X,L.total_out+=te,R.total+=te,R.wrap&&te&&(L.adler=R.check=R.flags?l(R.check,W,te,L.next_out-te):s(R.check,W,te,L.next_out-te)),L.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(X==0&&te===0||K===4)&&H===g&&(H=-5),H)},i.inflateEnd=function(L){if(!L||!L.state)return p;var K=L.state;return K.window&&(K.window=null),L.state=null,g},i.inflateGetHeader=function(L,K){var R;return L&&L.state?(2&(R=L.state).wrap)==0?p:((R.head=K).done=!1,g):p},i.inflateSetDictionary=function(L,K){var R,q=K.length;return L&&L.state?(R=L.state).wrap!==0&&R.mode!==11?p:R.mode===11&&s(1,K,q,0)!==R.check?-3:B(L,K,q,q)?(R.mode=31,-4):(R.havedict=1,g):p},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var a=n("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,g,p,x,v,y,b){var E,w,A,T,C,N,O,k,j,B=b.bits,L=0,K=0,R=0,q=0,W=0,$=0,J=0,ee=0,Q=0,z=0,V=null,X=0,te=new a.Buf16(16),ie=new a.Buf16(16),le=null,ge=0;for(L=0;L<=15;L++)te[L]=0;for(K=0;K<p;K++)te[f[g+K]]++;for(W=B,q=15;1<=q&&te[q]===0;q--);if(q<W&&(W=q),q===0)return x[v++]=20971520,x[v++]=20971520,b.bits=1,0;for(R=1;R<q&&te[R]===0;R++);for(W<R&&(W=R),L=ee=1;L<=15;L++)if(ee<<=1,(ee-=te[L])<0)return-1;if(0<ee&&(d===0||q!==1))return-1;for(ie[1]=0,L=1;L<15;L++)ie[L+1]=ie[L]+te[L];for(K=0;K<p;K++)f[g+K]!==0&&(y[ie[f[g+K]]++]=K);if(N=d===0?(V=le=y,19):d===1?(V=s,X-=257,le=l,ge-=257,256):(V=c,le=u,-1),L=R,C=v,J=K=z=0,A=-1,T=(Q=1<<($=W))-1,d===1&&852<Q||d===2&&592<Q)return 1;for(;;){for(O=L-J,j=y[K]<N?(k=0,y[K]):y[K]>N?(k=le[ge+y[K]],V[X+y[K]]):(k=96,0),E=1<<L-J,R=w=1<<$;x[C+(z>>J)+(w-=E)]=O<<24|k<<16|j|0,w!==0;);for(E=1<<L-1;z&E;)E>>=1;if(E!==0?(z&=E-1,z+=E):z=0,K++,--te[L]==0){if(L===q)break;L=f[g+y[K]]}if(W<L&&(z&T)!==A){for(J===0&&(J=W),C+=R,ee=1<<($=L-J);$+J<q&&!((ee-=te[$+J])<=0);)$++,ee<<=1;if(Q+=1<<$,d===1&&852<Q||d===2&&592<Q)return 1;x[A=z&T]=W<<24|$<<16|C-v|0}}return z!==0&&(x[C+z]=L-J<<24|64<<16|0),b.bits=W,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var a=n("../utils/common"),s=0,l=1;function c(Z){for(var oe=Z.length;0<=--oe;)Z[oe]=0}var u=0,d=29,f=256,g=f+1+d,p=30,x=19,v=2*g+1,y=15,b=16,E=7,w=256,A=16,T=17,C=18,N=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],O=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],k=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],j=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],B=new Array(2*(g+2));c(B);var L=new Array(2*p);c(L);var K=new Array(512);c(K);var R=new Array(256);c(R);var q=new Array(d);c(q);var W,$,J,ee=new Array(p);function Q(Z,oe,be,Te,Me){this.static_tree=Z,this.extra_bits=oe,this.extra_base=be,this.elems=Te,this.max_length=Me,this.has_stree=Z&&Z.length}function z(Z,oe){this.dyn_tree=Z,this.max_code=0,this.stat_desc=oe}function V(Z){return Z<256?K[Z]:K[256+(Z>>>7)]}function X(Z,oe){Z.pending_buf[Z.pending++]=255&oe,Z.pending_buf[Z.pending++]=oe>>>8&255}function te(Z,oe,be){Z.bi_valid>b-be?(Z.bi_buf|=oe<<Z.bi_valid&65535,X(Z,Z.bi_buf),Z.bi_buf=oe>>b-Z.bi_valid,Z.bi_valid+=be-b):(Z.bi_buf|=oe<<Z.bi_valid&65535,Z.bi_valid+=be)}function ie(Z,oe,be){te(Z,be[2*oe],be[2*oe+1])}function le(Z,oe){for(var be=0;be|=1&Z,Z>>>=1,be<<=1,0<--oe;);return be>>>1}function ge(Z,oe,be){var Te,Me,F=new Array(y+1),I=0;for(Te=1;Te<=y;Te++)F[Te]=I=I+be[Te-1]<<1;for(Me=0;Me<=oe;Me++){var ne=Z[2*Me+1];ne!==0&&(Z[2*Me]=le(F[ne]++,ne))}}function Ee(Z){var oe;for(oe=0;oe<g;oe++)Z.dyn_ltree[2*oe]=0;for(oe=0;oe<p;oe++)Z.dyn_dtree[2*oe]=0;for(oe=0;oe<x;oe++)Z.bl_tree[2*oe]=0;Z.dyn_ltree[2*w]=1,Z.opt_len=Z.static_len=0,Z.last_lit=Z.matches=0}function pe(Z){8<Z.bi_valid?X(Z,Z.bi_buf):0<Z.bi_valid&&(Z.pending_buf[Z.pending++]=Z.bi_buf),Z.bi_buf=0,Z.bi_valid=0}function de(Z,oe,be,Te){var Me=2*oe,F=2*be;return Z[Me]<Z[F]||Z[Me]===Z[F]&&Te[oe]<=Te[be]}function Re(Z,oe,be){for(var Te=Z.heap[be],Me=be<<1;Me<=Z.heap_len&&(Me<Z.heap_len&&de(oe,Z.heap[Me+1],Z.heap[Me],Z.depth)&&Me++,!de(oe,Te,Z.heap[Me],Z.depth));)Z.heap[be]=Z.heap[Me],be=Me,Me<<=1;Z.heap[be]=Te}function fe(Z,oe,be){var Te,Me,F,I,ne=0;if(Z.last_lit!==0)for(;Te=Z.pending_buf[Z.d_buf+2*ne]<<8|Z.pending_buf[Z.d_buf+2*ne+1],Me=Z.pending_buf[Z.l_buf+ne],ne++,Te===0?ie(Z,Me,oe):(ie(Z,(F=R[Me])+f+1,oe),(I=N[F])!==0&&te(Z,Me-=q[F],I),ie(Z,F=V(--Te),be),(I=O[F])!==0&&te(Z,Te-=ee[F],I)),ne<Z.last_lit;);ie(Z,w,oe)}function Fe(Z,oe){var be,Te,Me,F=oe.dyn_tree,I=oe.stat_desc.static_tree,ne=oe.stat_desc.has_stree,ve=oe.stat_desc.elems,Se=-1;for(Z.heap_len=0,Z.heap_max=v,be=0;be<ve;be++)F[2*be]!==0?(Z.heap[++Z.heap_len]=Se=be,Z.depth[be]=0):F[2*be+1]=0;for(;Z.heap_len<2;)F[2*(Me=Z.heap[++Z.heap_len]=Se<2?++Se:0)]=1,Z.depth[Me]=0,Z.opt_len--,ne&&(Z.static_len-=I[2*Me+1]);for(oe.max_code=Se,be=Z.heap_len>>1;1<=be;be--)Re(Z,F,be);for(Me=ve;be=Z.heap[1],Z.heap[1]=Z.heap[Z.heap_len--],Re(Z,F,1),Te=Z.heap[1],Z.heap[--Z.heap_max]=be,Z.heap[--Z.heap_max]=Te,F[2*Me]=F[2*be]+F[2*Te],Z.depth[Me]=(Z.depth[be]>=Z.depth[Te]?Z.depth[be]:Z.depth[Te])+1,F[2*be+1]=F[2*Te+1]=Me,Z.heap[1]=Me++,Re(Z,F,1),2<=Z.heap_len;);Z.heap[--Z.heap_max]=Z.heap[1],(function(ye,Ke){var We,qe,ut,ue,se,Ve,Be=Ke.dyn_tree,Ze=Ke.max_code,ht=Ke.stat_desc.static_tree,me=Ke.stat_desc.has_stree,nt=Ke.stat_desc.extra_bits,xe=Ke.stat_desc.extra_base,He=Ke.stat_desc.max_length,Pe=0;for(ue=0;ue<=y;ue++)ye.bl_count[ue]=0;for(Be[2*ye.heap[ye.heap_max]+1]=0,We=ye.heap_max+1;We<v;We++)He<(ue=Be[2*Be[2*(qe=ye.heap[We])+1]+1]+1)&&(ue=He,Pe++),Be[2*qe+1]=ue,Ze<qe||(ye.bl_count[ue]++,se=0,xe<=qe&&(se=nt[qe-xe]),Ve=Be[2*qe],ye.opt_len+=Ve*(ue+se),me&&(ye.static_len+=Ve*(ht[2*qe+1]+se)));if(Pe!==0){do{for(ue=He-1;ye.bl_count[ue]===0;)ue--;ye.bl_count[ue]--,ye.bl_count[ue+1]+=2,ye.bl_count[He]--,Pe-=2}while(0<Pe);for(ue=He;ue!==0;ue--)for(qe=ye.bl_count[ue];qe!==0;)Ze<(ut=ye.heap[--We])||(Be[2*ut+1]!==ue&&(ye.opt_len+=(ue-Be[2*ut+1])*Be[2*ut],Be[2*ut+1]=ue),qe--)}})(Z,oe),ge(F,Se,Z.bl_count)}function U(Z,oe,be){var Te,Me,F=-1,I=oe[1],ne=0,ve=7,Se=4;for(I===0&&(ve=138,Se=3),oe[2*(be+1)+1]=65535,Te=0;Te<=be;Te++)Me=I,I=oe[2*(Te+1)+1],++ne<ve&&Me===I||(ne<Se?Z.bl_tree[2*Me]+=ne:Me!==0?(Me!==F&&Z.bl_tree[2*Me]++,Z.bl_tree[2*A]++):ne<=10?Z.bl_tree[2*T]++:Z.bl_tree[2*C]++,F=Me,Se=(ne=0)===I?(ve=138,3):Me===I?(ve=6,3):(ve=7,4))}function H(Z,oe,be){var Te,Me,F=-1,I=oe[1],ne=0,ve=7,Se=4;for(I===0&&(ve=138,Se=3),Te=0;Te<=be;Te++)if(Me=I,I=oe[2*(Te+1)+1],!(++ne<ve&&Me===I)){if(ne<Se)for(;ie(Z,Me,Z.bl_tree),--ne!=0;);else Me!==0?(Me!==F&&(ie(Z,Me,Z.bl_tree),ne--),ie(Z,A,Z.bl_tree),te(Z,ne-3,2)):ne<=10?(ie(Z,T,Z.bl_tree),te(Z,ne-3,3)):(ie(Z,C,Z.bl_tree),te(Z,ne-11,7));F=Me,Se=(ne=0)===I?(ve=138,3):Me===I?(ve=6,3):(ve=7,4)}}c(ee);var re=!1;function G(Z,oe,be,Te){te(Z,(u<<1)+(Te?1:0),3),(function(Me,F,I,ne){pe(Me),X(Me,I),X(Me,~I),a.arraySet(Me.pending_buf,Me.window,F,I,Me.pending),Me.pending+=I})(Z,oe,be)}i._tr_init=function(Z){re||((function(){var oe,be,Te,Me,F,I=new Array(y+1);for(Me=Te=0;Me<d-1;Me++)for(q[Me]=Te,oe=0;oe<1<<N[Me];oe++)R[Te++]=Me;for(R[Te-1]=Me,Me=F=0;Me<16;Me++)for(ee[Me]=F,oe=0;oe<1<<O[Me];oe++)K[F++]=Me;for(F>>=7;Me<p;Me++)for(ee[Me]=F<<7,oe=0;oe<1<<O[Me]-7;oe++)K[256+F++]=Me;for(be=0;be<=y;be++)I[be]=0;for(oe=0;oe<=143;)B[2*oe+1]=8,oe++,I[8]++;for(;oe<=255;)B[2*oe+1]=9,oe++,I[9]++;for(;oe<=279;)B[2*oe+1]=7,oe++,I[7]++;for(;oe<=287;)B[2*oe+1]=8,oe++,I[8]++;for(ge(B,g+1,I),oe=0;oe<p;oe++)L[2*oe+1]=5,L[2*oe]=le(oe,5);W=new Q(B,N,f+1,g,y),$=new Q(L,O,0,p,y),J=new Q(new Array(0),k,0,x,E)})(),re=!0),Z.l_desc=new z(Z.dyn_ltree,W),Z.d_desc=new z(Z.dyn_dtree,$),Z.bl_desc=new z(Z.bl_tree,J),Z.bi_buf=0,Z.bi_valid=0,Ee(Z)},i._tr_stored_block=G,i._tr_flush_block=function(Z,oe,be,Te){var Me,F,I=0;0<Z.level?(Z.strm.data_type===2&&(Z.strm.data_type=(function(ne){var ve,Se=4093624447;for(ve=0;ve<=31;ve++,Se>>>=1)if(1&Se&&ne.dyn_ltree[2*ve]!==0)return s;if(ne.dyn_ltree[18]!==0||ne.dyn_ltree[20]!==0||ne.dyn_ltree[26]!==0)return l;for(ve=32;ve<f;ve++)if(ne.dyn_ltree[2*ve]!==0)return l;return s})(Z)),Fe(Z,Z.l_desc),Fe(Z,Z.d_desc),I=(function(ne){var ve;for(U(ne,ne.dyn_ltree,ne.l_desc.max_code),U(ne,ne.dyn_dtree,ne.d_desc.max_code),Fe(ne,ne.bl_desc),ve=x-1;3<=ve&&ne.bl_tree[2*j[ve]+1]===0;ve--);return ne.opt_len+=3*(ve+1)+5+5+4,ve})(Z),Me=Z.opt_len+3+7>>>3,(F=Z.static_len+3+7>>>3)<=Me&&(Me=F)):Me=F=be+5,be+4<=Me&&oe!==-1?G(Z,oe,be,Te):Z.strategy===4||F===Me?(te(Z,2+(Te?1:0),3),fe(Z,B,L)):(te(Z,4+(Te?1:0),3),(function(ne,ve,Se,ye){var Ke;for(te(ne,ve-257,5),te(ne,Se-1,5),te(ne,ye-4,4),Ke=0;Ke<ye;Ke++)te(ne,ne.bl_tree[2*j[Ke]+1],3);H(ne,ne.dyn_ltree,ve-1),H(ne,ne.dyn_dtree,Se-1)})(Z,Z.l_desc.max_code+1,Z.d_desc.max_code+1,I+1),fe(Z,Z.dyn_ltree,Z.dyn_dtree)),Ee(Z),Te&&pe(Z)},i._tr_tally=function(Z,oe,be){return Z.pending_buf[Z.d_buf+2*Z.last_lit]=oe>>>8&255,Z.pending_buf[Z.d_buf+2*Z.last_lit+1]=255&oe,Z.pending_buf[Z.l_buf+Z.last_lit]=255&be,Z.last_lit++,oe===0?Z.dyn_ltree[2*be]++:(Z.matches++,oe--,Z.dyn_ltree[2*(R[be]+f+1)]++,Z.dyn_dtree[2*V(oe)]++),Z.last_lit===Z.lit_bufsize-1},i._tr_align=function(Z){te(Z,2,3),ie(Z,w,B),(function(oe){oe.bi_valid===16?(X(oe,oe.bi_buf),oe.bi_buf=0,oe.bi_valid=0):8<=oe.bi_valid&&(oe.pending_buf[oe.pending++]=255&oe.bi_buf,oe.bi_buf>>=8,oe.bi_valid-=8)})(Z)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(a){(function(s,l){if(!s.setImmediate){var c,u,d,f,g=1,p={},x=!1,v=s.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(s);y=y&&y.setTimeout?y:s,c={}.toString.call(s.process)==="[object process]"?function(A){process.nextTick(function(){E(A)})}:(function(){if(s.postMessage&&!s.importScripts){var A=!0,T=s.onmessage;return s.onmessage=function(){A=!1},s.postMessage("","*"),s.onmessage=T,A}})()?(f="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",w,!1):s.attachEvent("onmessage",w),function(A){s.postMessage(f+A,"*")}):s.MessageChannel?((d=new MessageChannel).port1.onmessage=function(A){E(A.data)},function(A){d.port2.postMessage(A)}):v&&"onreadystatechange"in v.createElement("script")?(u=v.documentElement,function(A){var T=v.createElement("script");T.onreadystatechange=function(){E(A),T.onreadystatechange=null,u.removeChild(T),T=null},u.appendChild(T)}):function(A){setTimeout(E,0,A)},y.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var T=new Array(arguments.length-1),C=0;C<T.length;C++)T[C]=arguments[C+1];var N={callback:A,args:T};return p[g]=N,c(g),g++},y.clearImmediate=b}function b(A){delete p[A]}function E(A){if(x)setTimeout(E,0,A);else{var T=p[A];if(T){x=!0;try{(function(C){var N=C.callback,O=C.args;switch(O.length){case 0:N();break;case 1:N(O[0]);break;case 2:N(O[0],O[1]);break;case 3:N(O[0],O[1],O[2]);break;default:N.apply(l,O)}})(T)}finally{b(A),x=!1}}}}function w(A){A.source===s&&typeof A.data=="string"&&A.data.indexOf(f)===0&&E(+A.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Ev<"u"?Ev:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(dC)),dC.exports}var KDe=qDe();const XDe=yo(KDe);function YDe(t){const e=new fi;if(!t)return e;const n=t.trim().split(/\s+/).map(parseFloat);return n.length>=12&&e.set(n[0],n[1],n[2],n[9],n[3],n[4],n[5],n[10],n[6],n[7],n[8],n[11],0,0,0,1),e}const y$=YDe;async function v$(t){const e=[],n=t.getElementsByTagName("mesh");for(let r=0;r<n.length;r++){const i=n[r],a=[],s=[],l=i.getElementsByTagName("vertex");for(let u=0;u<l.length;u++){const d=l[u];a.push(parseFloat(d.getAttribute("x")||"0"),parseFloat(d.getAttribute("y")||"0"),parseFloat(d.getAttribute("z")||"0"))}const c=i.getElementsByTagName("triangle");for(let u=0;u<c.length;u++){const d=c[u];s.push(parseInt(d.getAttribute("v1")||"0"),parseInt(d.getAttribute("v2")||"0"),parseInt(d.getAttribute("v3")||"0"))}a.length>0&&s.length>0&&e.push({vertices:a,triangles:s})}return e}async function ZDe(t){const e=await XDe.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(d){const f=d.startsWith("/")?d.slice(1):d,g=e.files[f];if(!g)return null;const p=await g.async("string");return i.parseFromString(p,"application/xml")}const s=Object.keys(e.files).find(d=>d==="3D/3dmodel.model"||d.endsWith("/3dmodel.model"));if(!s){const d=Object.keys(e.files).find(f=>f.endsWith(".model"));if(d){const f=await a(d);if(f){const g=await v$(f);g.length>0&&n.set("1",{id:"1",meshes:g})}}return{objects:n,buildItems:r}}const l=await a(s);if(!l)return{objects:n,buildItems:r};const c=l.getElementsByTagName("object");for(let d=0;d<c.length;d++){const f=c[d],g=f.getAttribute("id");if(!g)continue;const p=[],x=f.getElementsByTagName("mesh");for(let y=0;y<x.length;y++){const b=x[y],E=[],w=[],A=b.getElementsByTagName("vertex");for(let C=0;C<A.length;C++){const N=A[C];E.push(parseFloat(N.getAttribute("x")||"0"),parseFloat(N.getAttribute("y")||"0"),parseFloat(N.getAttribute("z")||"0"))}const T=b.getElementsByTagName("triangle");for(let C=0;C<T.length;C++){const N=T[C];w.push(parseInt(N.getAttribute("v1")||"0"),parseInt(N.getAttribute("v2")||"0"),parseInt(N.getAttribute("v3")||"0"))}E.length>0&&w.length>0&&p.push({vertices:E,triangles:w})}const v=f.getElementsByTagName("component");for(let y=0;y<v.length;y++){const b=v[y],E=b.getAttribute("p:path")||b.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path");if(E){const w=await a(E);if(w){const A=await v$(w),T=b.getAttribute("transform"),C=y$(T);for(const N of A)if(T){const O=[];for(let k=0;k<N.vertices.length;k+=3){const j=new at(N.vertices[k],N.vertices[k+1],N.vertices[k+2]);j.applyMatrix4(C),O.push(j.x,j.y,j.z)}p.push({vertices:O,triangles:N.triangles})}else p.push(N)}}}p.length>0&&n.set(g,{id:g,meshes:p})}const u=l.getElementsByTagName("build");if(u.length>0){const d=u[0].getElementsByTagName("item");for(let f=0;f<d.length;f++){const g=d[f],p=g.getAttribute("objectid");if(!p)continue;const x=y$(g.getAttribute("transform"));r.push({objectId:p,transform:x})}}return{objects:n,buildItems:r}}function _$(t){const e=new Ll,n=new Float32Array(t.vertices.length);for(let r=0;r<t.vertices.length;r+=3)n[r]=t.vertices[r],n[r+1]=t.vertices[r+2],n[r+2]=t.vertices[r+1];return e.setAttribute("position",new uo(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function QDe({url:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const r=S.useRef(null),i=S.useRef(null),a=S.useRef(null),s=S.useRef(null),l=S.useRef(null),[c,u]=S.useState(!0),[d,f]=S.useState(null);S.useEffect(()=>{if(!r.current)return;const x=r.current,v=x.clientWidth,y=x.clientHeight,b=new Cke;b.background=new Tn(1710618),a.current=b;const E=new to(45,v/y,.1,1e4);E.position.set(150,150,150),s.current=E;const w=new PDe({antialias:!0});w.setSize(v,y),w.setPixelRatio(window.devicePixelRatio),x.appendChild(w.domElement),i.current=w;const A=new RDe(E,w.domElement);A.enableDamping=!0,A.dampingFactor=.05,l.current=A;const T=new Bke(16777215,.6);b.add(T);const C=new $H(16777215,.8);C.position.set(100,100,100),b.add(C);const N=new $H(16777215,.4);N.position.set(-100,50,-100),b.add(N);const O=Math.max(e.x,e.y),k=Math.ceil(O/16),j=new $ke(O,k,4473924,3355443);b.add(j);const B=new IO(e.x,e.y),L=new DO({color:44610,transparent:!0,opacity:.15,side:dl}),K=new Tl(B,L);K.rotation.x=-Math.PI/2,K.position.y=-.5,b.add(K);let R;const q=()=>{R=requestAnimationFrame(q),A.update(),w.render(b,E)};q(),fetch(t).then($=>{if(!$.ok)throw new Error("Failed to load file");return $.arrayBuffer()}).then(ZDe).then(({objects:$,buildItems:J})=>{if($.size===0)throw new Error("No meshes found in 3MF file");const ee=new Lke({color:44610,shininess:30,flatShading:!1}),Q=new Xx,z=[];if(J.length>0)for(const pe of J){const de=$.get(pe.objectId);if(de)for(const Re of de.meshes){const fe=[];for(let U=0;U<Re.vertices.length;U+=3){const H=new at(Re.vertices[U],Re.vertices[U+1],Re.vertices[U+2]);H.applyMatrix4(pe.transform),fe.push(H.x,H.y,H.z)}const Fe=_$({vertices:fe,triangles:Re.triangles});z.push(Fe)}}else for(const pe of $.values())for(const de of pe.meshes){const Re=_$(de);z.push(Re)}if(z.length>0){const pe=z.length===1?z[0]:WDe(z,!1);if(pe){const de=new Tl(pe,ee);Q.add(de)}if(z.length>1)for(const de of z)de.dispose()}const V=new xf().setFromObject(Q),X=V.getCenter(new at);Q.position.y=-V.min.y,J.length===0&&(Q.position.x=-X.x,Q.position.z=-X.z),b.add(Q);const te=new xf().setFromObject(Q),ie=te.getCenter(new at),le=te.getSize(new at),Ee=Math.max(le.x,le.y,le.z)*1.8;E.position.set(ie.x+Ee*.7,ie.y+Ee*.5,ie.z+Ee*.7),A.target.copy(ie),A.update(),u(!1)}).catch($=>{f($.message),u(!1)});const W=()=>{if(!x)return;const $=x.clientWidth,J=x.clientHeight;E.aspect=$/J,E.updateProjectionMatrix(),w.setSize($,J)};return window.addEventListener("resize",W),()=>{window.removeEventListener("resize",W),cancelAnimationFrame(R),A.dispose(),w.dispose(),x.removeChild(w.domElement)}},[t,e]);const g=()=>{s.current&&l.current&&(s.current.position.set(150,150,150),l.current.target.set(0,50,0),l.current.update())},p=x=>{s.current&&s.current.position.multiplyScalar(x)};return o.jsxs("div",{className:`relative ${n}`,children:[o.jsx("div",{ref:r,className:"w-full h-full min-h-[400px]"}),c&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}),d&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:o.jsx("p",{className:"text-red-400",children:d})}),!c&&!d&&o.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>p(.8),children:o.jsx(kde,{className:"w-4 h-4"})}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>p(1.25),children:o.jsx(Rde,{className:"w-4 h-4"})}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:g,children:o.jsx(sg,{className:"w-4 h-4"})})]})]})}const rE="159",Nm={ROTATE:0,DOLLY:1,PAN:2},Cm={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},JDe=0,w$=1,eOe=2,JZ=1,tOe=2,gc=3,Ad=0,ns=1,wc=2,cd=0,bp=1,S$=2,M$=3,E$=4,nOe=5,_h=100,rOe=101,iOe=102,A$=103,T$=104,aOe=200,sOe=201,oOe=202,lOe=203,ZP=204,QP=205,cOe=206,uOe=207,dOe=208,hOe=209,fOe=210,mOe=211,pOe=212,gOe=213,xOe=214,bOe=0,yOe=1,vOe=2,Kw=3,_Oe=4,wOe=5,SOe=6,MOe=7,UO=0,EOe=1,AOe=2,ud=0,TOe=1,NOe=2,COe=3,kOe=4,POe=5,eQ=300,$p=301,Vp=302,JP=303,ej=304,iE=306,tj=1e3,Lo=1001,nj=1002,ra=1003,N$=1004,hC=1005,no=1006,jOe=1007,ib=1008,dd=1009,ROe=1010,DOe=1011,zO=1012,tQ=1013,td=1014,Cc=1015,ab=1016,nQ=1017,rQ=1018,Bh=1020,OOe=1021,ro=1023,LOe=1024,IOe=1025,Hh=1026,Gp=1027,FOe=1028,iQ=1029,UOe=1030,aQ=1031,sQ=1033,fC=33776,mC=33777,pC=33778,gC=33779,C$=35840,k$=35841,P$=35842,j$=35843,oQ=36196,R$=37492,D$=37496,O$=37808,L$=37809,I$=37810,F$=37811,U$=37812,z$=37813,B$=37814,H$=37815,$$=37816,V$=37817,G$=37818,W$=37819,q$=37820,K$=37821,xC=36492,X$=36494,Y$=36495,zOe=36283,Z$=36284,Q$=36285,J$=36286,lQ=3e3,$h=3001,BOe=3200,HOe=3201,cQ=0,$Oe=1,io="",ia="srgb",Yc="srgb-linear",BO="display-p3",aE="display-p3-linear",Xw="linear",wr="srgb",Yw="rec709",Zw="p3",km=7680,eV=519,VOe=512,GOe=513,WOe=514,uQ=515,qOe=516,KOe=517,XOe=518,YOe=519,rj=35044,tV="300 es",ij=1035,gl=2e3,sb=2001;class Cf{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,s=i.length;a<s;a++)i[a].call(this,e);e.target=null}}}const ma=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let nV=1234567;const c0=Math.PI/180,ob=180/Math.PI;function Lc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ma[t&255]+ma[t>>8&255]+ma[t>>16&255]+ma[t>>24&255]+"-"+ma[e&255]+ma[e>>8&255]+"-"+ma[e>>16&15|64]+ma[e>>24&255]+"-"+ma[n&63|128]+ma[n>>8&255]+"-"+ma[n>>16&255]+ma[n>>24&255]+ma[r&255]+ma[r>>8&255]+ma[r>>16&255]+ma[r>>24&255]).toLowerCase()}function aa(t,e,n){return Math.max(e,Math.min(n,t))}function HO(t,e){return(t%e+e)%e}function ZOe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function QOe(t,e,n){return t!==e?(n-t)/(e-t):0}function u0(t,e,n){return(1-n)*t+n*e}function JOe(t,e,n,r){return u0(t,e,1-Math.exp(-n*r))}function eLe(t,e=1){return e-Math.abs(HO(t,e*2)-e)}function tLe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function nLe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function rLe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function iLe(t,e){return t+Math.random()*(e-t)}function aLe(t){return t*(.5-Math.random())}function sLe(t){t!==void 0&&(nV=t);let e=nV+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function oLe(t){return t*c0}function lLe(t){return t*ob}function aj(t){return(t&t-1)===0&&t!==0}function cLe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function Qw(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function uLe(t,e,n,r,i){const a=Math.cos,s=Math.sin,l=a(n/2),c=s(n/2),u=a((e+r)/2),d=s((e+r)/2),f=a((e-r)/2),g=s((e-r)/2),p=a((r-e)/2),x=s((r-e)/2);switch(i){case"XYX":t.set(l*d,c*f,c*g,l*u);break;case"YZY":t.set(c*g,l*d,c*f,l*u);break;case"ZXZ":t.set(c*f,c*g,l*d,l*u);break;case"XZX":t.set(l*d,c*x,c*p,l*u);break;case"YXY":t.set(c*p,l*d,c*x,l*u);break;case"ZYZ":t.set(c*x,c*p,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function hl(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function sr(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const dQ={DEG2RAD:c0,RAD2DEG:ob,generateUUID:Lc,clamp:aa,euclideanModulo:HO,mapLinear:ZOe,inverseLerp:QOe,lerp:u0,damp:JOe,pingpong:eLe,smoothstep:tLe,smootherstep:nLe,randInt:rLe,randFloat:iLe,randFloatSpread:aLe,seededRandom:sLe,degToRad:oLe,radToDeg:lLe,isPowerOfTwo:aj,ceilPowerOfTwo:cLe,floorPowerOfTwo:Qw,setQuaternionFromProperEuler:uLe,normalize:sr,denormalize:hl};class tn{constructor(e=0,n=0){tn.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(aa(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,s=this.y-e.y;return this.x=a*r-s*i+e.x,this.y=a*i+s*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class yn{constructor(e,n,r,i,a,s,l,c,u){yn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,l,c,u)}set(e,n,r,i,a,s,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=s,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],g=r[2],p=r[5],x=r[8],v=i[0],y=i[3],b=i[6],E=i[1],w=i[4],A=i[7],T=i[2],C=i[5],N=i[8];return a[0]=s*v+l*E+c*T,a[3]=s*y+l*w+c*C,a[6]=s*b+l*A+c*N,a[1]=u*v+d*E+f*T,a[4]=u*y+d*w+f*C,a[7]=u*b+d*A+f*N,a[2]=g*v+p*E+x*T,a[5]=g*y+p*w+x*C,a[8]=g*b+p*A+x*N,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*s*d-n*l*u-r*a*d+r*l*c+i*a*u-i*s*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*s-l*u,g=l*c-d*a,p=u*a-s*c,x=n*f+r*g+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/x;return e[0]=f*v,e[1]=(i*u-d*r)*v,e[2]=(l*r-i*s)*v,e[3]=g*v,e[4]=(d*n-i*c)*v,e[5]=(i*a-l*n)*v,e[6]=p*v,e[7]=(r*c-u*n)*v,e[8]=(s*n-r*a)*v,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,s,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*s+u*l)+s+e,-i*u,i*c,-i*(-u*s+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(bC.makeScale(e,n)),this}rotate(e){return this.premultiply(bC.makeRotation(-e)),this}translate(e,n){return this.premultiply(bC.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,r,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const bC=new yn;function hQ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Jw(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function dLe(){const t=Jw("canvas");return t.style.display="block",t}const rV={};function d0(t){t in rV||(rV[t]=!0,console.warn(t))}const iV=new yn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),aV=new yn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),b_={[Yc]:{transfer:Xw,primaries:Yw,toReference:t=>t,fromReference:t=>t},[ia]:{transfer:wr,primaries:Yw,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[aE]:{transfer:Xw,primaries:Zw,toReference:t=>t.applyMatrix3(aV),fromReference:t=>t.applyMatrix3(iV)},[BO]:{transfer:wr,primaries:Zw,toReference:t=>t.convertSRGBToLinear().applyMatrix3(aV),fromReference:t=>t.applyMatrix3(iV).convertLinearToSRGB()}},hLe=new Set([Yc,aE]),or={enabled:!0,_workingColorSpace:Yc,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(t){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!t},get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!hLe.has(t))throw new Error(`Unsupported working color space, "${t}".`);this._workingColorSpace=t},convert:function(t,e,n){if(this.enabled===!1||e===n||!e||!n)return t;const r=b_[e].toReference,i=b_[n].fromReference;return i(r(t))},fromWorkingColorSpace:function(t,e){return this.convert(t,this._workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this._workingColorSpace)},getPrimaries:function(t){return b_[t].primaries},getTransfer:function(t){return t===io?Xw:b_[t].transfer}};function yp(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function yC(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Pm;class fQ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Pm===void 0&&(Pm=Jw("canvas")),Pm.width=e.width,Pm.height=e.height;const r=Pm.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Pm}return n.width>2048||n.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),n.toDataURL("image/jpeg",.6)):n.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=Jw("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let s=0;s<a.length;s++)a[s]=yp(a[s]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(yp(n[r]/255)*255):n[r]=yp(n[r]);return{data:n,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let fLe=0;class mQ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:fLe++}),this.uuid=Lc(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let s=0,l=i.length;s<l;s++)i[s].isDataTexture?a.push(vC(i[s].image)):a.push(vC(i[s]))}else a=vC(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function vC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?fQ.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let mLe=0;class rs extends Cf{constructor(e=rs.DEFAULT_IMAGE,n=rs.DEFAULT_MAPPING,r=Lo,i=Lo,a=no,s=ib,l=ro,c=dd,u=rs.DEFAULT_ANISOTROPY,d=io){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:mLe++}),this.uuid=Lc(),this.name="",this.source=new mQ(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=s,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new tn(0,0),this.repeat=new tn(1,1),this.center=new tn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new yn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(d0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===$h?ia:io),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==eQ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case tj:e.x=e.x-Math.floor(e.x);break;case Lo:e.x=e.x<0?0:1;break;case nj:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case tj:e.y=e.y-Math.floor(e.y);break;case Lo:e.y=e.y<0?0:1;break;case nj:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return d0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===ia?$h:lQ}set encoding(e){d0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===$h?ia:io}}rs.DEFAULT_IMAGE=null;rs.DEFAULT_MAPPING=eQ;rs.DEFAULT_ANISOTROPY=1;class cr{constructor(e=0,n=0,r=0,i=1){cr.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,s=e.elements;return this.x=s[0]*n+s[4]*r+s[8]*i+s[12]*a,this.y=s[1]*n+s[5]*r+s[9]*i+s[13]*a,this.z=s[2]*n+s[6]*r+s[10]*i+s[14]*a,this.w=s[3]*n+s[7]*r+s[11]*i+s[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],g=c[1],p=c[5],x=c[9],v=c[2],y=c[6],b=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-v)<.01&&Math.abs(x-y)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+v)<.1&&Math.abs(x+y)<.1&&Math.abs(u+p+b-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(u+1)/2,A=(p+1)/2,T=(b+1)/2,C=(d+g)/4,N=(f+v)/4,O=(x+y)/4;return w>A&&w>T?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=C/r,a=N/r):A>T?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=C/i,a=O/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=N/a,i=O/a),this.set(r,i,a,n),this}let E=Math.sqrt((y-x)*(y-x)+(f-v)*(f-v)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(y-x)/E,this.y=(f-v)/E,this.z=(g-d)/E,this.w=Math.acos((u+p+b-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class pLe extends Cf{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new cr(0,0,e,n),this.scissorTest=!1,this.viewport=new cr(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(d0("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===$h?ia:io),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:no,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new rs(i,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=r.generateMipmaps,this.texture.internalFormat=r.internalFormat,this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.depthTexture=r.depthTexture,this.samples=r.samples}setSize(e,n,r=1){(this.width!==e||this.height!==n||this.depth!==r)&&(this.width=e,this.height=n,this.depth=r,this.texture.image.width=e,this.texture.image.height=n,this.texture.image.depth=r,this.dispose()),this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const n=Object.assign({},e.texture.image);return this.texture.source=new mQ(n),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class bf extends pLe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class pQ extends rs{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ra,this.minFilter=ra,this.wrapR=Lo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class gLe extends rs{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ra,this.minFilter=ra,this.wrapR=Lo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class yf{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,s,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3];const g=a[s+0],p=a[s+1],x=a[s+2],v=a[s+3];if(l===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l===1){e[n+0]=g,e[n+1]=p,e[n+2]=x,e[n+3]=v;return}if(f!==v||c!==g||u!==p||d!==x){let y=1-l;const b=c*g+u*p+d*x+f*v,E=b>=0?1:-1,w=1-b*b;if(w>Number.EPSILON){const T=Math.sqrt(w),C=Math.atan2(T,b*E);y=Math.sin(y*C)/T,l=Math.sin(l*C)/T}const A=l*E;if(c=c*y+g*A,u=u*y+p*A,d=d*y+x*A,f=f*y+v*A,y===1-l){const T=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=T,u*=T,d*=T,f*=T}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,s){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[s],g=a[s+1],p=a[s+2],x=a[s+3];return e[n]=l*x+d*f+c*p-u*g,e[n+1]=c*x+d*g+u*f-l*p,e[n+2]=u*x+d*p+l*g-c*f,e[n+3]=d*x-l*f-c*g-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,a=e._z,s=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),g=c(r/2),p=c(i/2),x=c(a/2);switch(s){case"XYZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"YXZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"ZXY":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"ZYX":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"YZX":this._x=g*d*f+u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f-g*p*x;break;case"XZY":this._x=g*d*f-u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f+g*p*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],s=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],g=r+l+f;if(g>0){const p=.5/Math.sqrt(g+1);this._w=.25/p,this._x=(d-c)*p,this._y=(a-u)*p,this._z=(s-i)*p}else if(r>l&&r>f){const p=2*Math.sqrt(1+r-l-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+s)/p,this._z=(a+u)/p}else if(l>f){const p=2*Math.sqrt(1+l-r-f);this._w=(a-u)/p,this._x=(i+s)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(s-i)/p,this._x=(a+u)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(aa(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,s=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+s*l+i*u-a*c,this._y=i*d+s*c+a*l-r*u,this._z=a*d+s*u+r*c-i*l,this._w=s*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,a=this._z,s=this._w;let l=s*e._w+r*e._x+i*e._y+a*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=s,this._x=r,this._y=i,this._z=a,this;const c=1-l*l;if(c<=Number.EPSILON){const p=1-n;return this._w=p*s+n*this._w,this._x=p*r+n*this._x,this._y=p*i+n*this._y,this._z=p*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,l),f=Math.sin((1-n)*d)/u,g=Math.sin(n*d)/u;return this._w=s*f+this._w*g,this._x=r*f+this._x*g,this._y=i*f+this._y*g,this._z=a*f+this._z*g,this._onChangeCallback(),this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=Math.random(),n=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),a=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(a),r*Math.cos(a),n*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Oe{constructor(e=0,n=0,r=0){Oe.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(sV.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(sV.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,s=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*s,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*s,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*s,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,s=e.y,l=e.z,c=e.w,u=2*(s*i-l*r),d=2*(l*n-a*i),f=2*(a*r-s*n);return this.x=n+c*u+s*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*d-s*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,s=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*s-r*c,this.z=r*l-i*s,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return _C.copy(this).projectOnVector(e),this.sub(_C)}reflect(e){return this.sub(_C.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(aa(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,n=Math.random()*Math.PI*2,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(n),this.y=r*Math.sin(n),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const _C=new Oe,sV=new yf;class ho{constructor(e=new Oe(1/0,1/0,1/0),n=new Oe(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(Co.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Co.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=Co.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,l=a.count;s<l;s++)e.isMesh===!0?e.getVertexPosition(s,Co):Co.fromBufferAttribute(a,s),Co.applyMatrix4(e.matrixWorld),this.expandByPoint(Co);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),y_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),y_.copy(r.boundingBox)),y_.applyMatrix4(e.matrixWorld),this.union(y_)}const i=e.children;for(let a=0,s=i.length;a<s;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Co),Co.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Lx),v_.subVectors(this.max,Lx),jm.subVectors(e.a,Lx),Rm.subVectors(e.b,Lx),Dm.subVectors(e.c,Lx),ju.subVectors(Rm,jm),Ru.subVectors(Dm,Rm),sh.subVectors(jm,Dm);let n=[0,-ju.z,ju.y,0,-Ru.z,Ru.y,0,-sh.z,sh.y,ju.z,0,-ju.x,Ru.z,0,-Ru.x,sh.z,0,-sh.x,-ju.y,ju.x,0,-Ru.y,Ru.x,0,-sh.y,sh.x,0];return!wC(n,jm,Rm,Dm,v_)||(n=[1,0,0,0,1,0,0,0,1],!wC(n,jm,Rm,Dm,v_))?!1:(__.crossVectors(ju,Ru),n=[__.x,__.y,__.z],wC(n,jm,Rm,Dm,v_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Co).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Co).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(oc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const oc=[new Oe,new Oe,new Oe,new Oe,new Oe,new Oe,new Oe,new Oe],Co=new Oe,y_=new ho,jm=new Oe,Rm=new Oe,Dm=new Oe,ju=new Oe,Ru=new Oe,sh=new Oe,Lx=new Oe,v_=new Oe,__=new Oe,oh=new Oe;function wC(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){oh.fromArray(t,a);const l=i.x*Math.abs(oh.x)+i.y*Math.abs(oh.y)+i.z*Math.abs(oh.z),c=e.dot(oh),u=n.dot(oh),d=r.dot(oh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const xLe=new ho,Ix=new Oe,SC=new Oe;class bl{constructor(e=new Oe,n=-1){this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):xLe.setFromPoints(e).getCenter(r);let i=0;for(let a=0,s=e.length;a<s;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ix.subVectors(e,this.center);const n=Ix.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Ix,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(SC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ix.copy(e.center).add(SC)),this.expandByPoint(Ix.copy(e.center).sub(SC))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const lc=new Oe,MC=new Oe,w_=new Oe,Du=new Oe,EC=new Oe,S_=new Oe,AC=new Oe;class $O{constructor(e=new Oe,n=new Oe(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,lc)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=lc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(lc.copy(this.origin).addScaledVector(this.direction,n),lc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){MC.copy(e).add(n).multiplyScalar(.5),w_.copy(n).sub(e).normalize(),Du.copy(this.origin).sub(MC);const a=e.distanceTo(n)*.5,s=-this.direction.dot(w_),l=Du.dot(this.direction),c=-Du.dot(w_),u=Du.lengthSq(),d=Math.abs(1-s*s);let f,g,p,x;if(d>0)if(f=s*c-l,g=s*l-c,x=a*d,f>=0)if(g>=-x)if(g<=x){const v=1/d;f*=v,g*=v,p=f*(f+s*g+2*l)+g*(s*f+g+2*c)+u}else g=a,f=Math.max(0,-(s*g+l)),p=-f*f+g*(g+2*c)+u;else g=-a,f=Math.max(0,-(s*g+l)),p=-f*f+g*(g+2*c)+u;else g<=-x?(f=Math.max(0,-(-s*a+l)),g=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u):g<=x?(f=0,g=Math.min(Math.max(-a,-c),a),p=g*(g+2*c)+u):(f=Math.max(0,-(s*a+l)),g=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u);else g=s>0?-a:a,f=Math.max(0,-(s*g+l)),p=-f*f+g*(g+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(MC).addScaledVector(w_,g),p}intersectSphere(e,n){lc.subVectors(e.center,this.origin);const r=lc.dot(this.direction),i=lc.dot(lc)-r*r,a=e.radius*e.radius;if(i>a)return null;const s=Math.sqrt(a-i),l=r-s,c=r+s;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,s,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(a=(e.min.y-g.y)*d,s=(e.max.y-g.y)*d):(a=(e.max.y-g.y)*d,s=(e.min.y-g.y)*d),r>s||a>i||((a>r||isNaN(r))&&(r=a),(s<i||isNaN(i))&&(i=s),f>=0?(l=(e.min.z-g.z)*f,c=(e.max.z-g.z)*f):(l=(e.max.z-g.z)*f,c=(e.min.z-g.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,lc)!==null}intersectTriangle(e,n,r,i,a){EC.subVectors(n,e),S_.subVectors(r,e),AC.crossVectors(EC,S_);let s=this.direction.dot(AC),l;if(s>0){if(i)return null;l=1}else if(s<0)l=-1,s=-s;else return null;Du.subVectors(this.origin,e);const c=l*this.direction.dot(S_.crossVectors(Du,S_));if(c<0)return null;const u=l*this.direction.dot(EC.cross(Du));if(u<0||c+u>s)return null;const d=-l*Du.dot(AC);return d<0?null:this.at(d/s,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class yr{constructor(e,n,r,i,a,s,l,c,u,d,f,g,p,x,v,y){yr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,s,l,c,u,d,f,g,p,x,v,y)}set(e,n,r,i,a,s,l,c,u,d,f,g,p,x,v,y){const b=this.elements;return b[0]=e,b[4]=n,b[8]=r,b[12]=i,b[1]=a,b[5]=s,b[9]=l,b[13]=c,b[2]=u,b[6]=d,b[10]=f,b[14]=g,b[3]=p,b[7]=x,b[11]=v,b[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new yr().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,r=e.elements,i=1/Om.setFromMatrixColumn(e,0).length(),a=1/Om.setFromMatrixColumn(e,1).length(),s=1/Om.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*s,n[9]=r[9]*s,n[10]=r[10]*s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,s=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const g=s*d,p=s*f,x=l*d,v=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=g-v*u,n[9]=-l*c,n[2]=v-g*u,n[6]=x+p*u,n[10]=s*c}else if(e.order==="YXZ"){const g=c*d,p=c*f,x=u*d,v=u*f;n[0]=g+v*l,n[4]=x*l-p,n[8]=s*u,n[1]=s*f,n[5]=s*d,n[9]=-l,n[2]=p*l-x,n[6]=v+g*l,n[10]=s*c}else if(e.order==="ZXY"){const g=c*d,p=c*f,x=u*d,v=u*f;n[0]=g-v*l,n[4]=-s*f,n[8]=x+p*l,n[1]=p+x*l,n[5]=s*d,n[9]=v-g*l,n[2]=-s*u,n[6]=l,n[10]=s*c}else if(e.order==="ZYX"){const g=s*d,p=s*f,x=l*d,v=l*f;n[0]=c*d,n[4]=x*u-p,n[8]=g*u+v,n[1]=c*f,n[5]=v*u+g,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=s*c}else if(e.order==="YZX"){const g=s*c,p=s*u,x=l*c,v=l*u;n[0]=c*d,n[4]=v-g*f,n[8]=x*f+p,n[1]=f,n[5]=s*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+x,n[10]=g-v*f}else if(e.order==="XZY"){const g=s*c,p=s*u,x=l*c,v=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=g*f+v,n[5]=s*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=l*d,n[10]=v*f+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(bLe,e,yLe)}lookAt(e,n,r){const i=this.elements;return vs.subVectors(e,n),vs.lengthSq()===0&&(vs.z=1),vs.normalize(),Ou.crossVectors(r,vs),Ou.lengthSq()===0&&(Math.abs(r.z)===1?vs.x+=1e-4:vs.z+=1e-4,vs.normalize(),Ou.crossVectors(r,vs)),Ou.normalize(),M_.crossVectors(vs,Ou),i[0]=Ou.x,i[4]=M_.x,i[8]=vs.x,i[1]=Ou.y,i[5]=M_.y,i[9]=vs.y,i[2]=Ou.z,i[6]=M_.z,i[10]=vs.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,s=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],g=r[9],p=r[13],x=r[2],v=r[6],y=r[10],b=r[14],E=r[3],w=r[7],A=r[11],T=r[15],C=i[0],N=i[4],O=i[8],k=i[12],j=i[1],B=i[5],L=i[9],K=i[13],R=i[2],q=i[6],W=i[10],$=i[14],J=i[3],ee=i[7],Q=i[11],z=i[15];return a[0]=s*C+l*j+c*R+u*J,a[4]=s*N+l*B+c*q+u*ee,a[8]=s*O+l*L+c*W+u*Q,a[12]=s*k+l*K+c*$+u*z,a[1]=d*C+f*j+g*R+p*J,a[5]=d*N+f*B+g*q+p*ee,a[9]=d*O+f*L+g*W+p*Q,a[13]=d*k+f*K+g*$+p*z,a[2]=x*C+v*j+y*R+b*J,a[6]=x*N+v*B+y*q+b*ee,a[10]=x*O+v*L+y*W+b*Q,a[14]=x*k+v*K+y*$+b*z,a[3]=E*C+w*j+A*R+T*J,a[7]=E*N+w*B+A*q+T*ee,a[11]=E*O+w*L+A*W+T*Q,a[15]=E*k+w*K+A*$+T*z,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],s=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],g=e[10],p=e[14],x=e[3],v=e[7],y=e[11],b=e[15];return x*(+a*c*f-i*u*f-a*l*g+r*u*g+i*l*p-r*c*p)+v*(+n*c*p-n*u*g+a*s*g-i*s*p+i*u*d-a*c*d)+y*(+n*u*f-n*l*p-a*s*f+r*s*p+a*l*d-r*u*d)+b*(-i*l*d-n*c*f+n*l*g+i*s*f-r*s*g+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],g=e[10],p=e[11],x=e[12],v=e[13],y=e[14],b=e[15],E=f*y*u-v*g*u+v*c*p-l*y*p-f*c*b+l*g*b,w=x*g*u-d*y*u-x*c*p+s*y*p+d*c*b-s*g*b,A=d*v*u-x*f*u+x*l*p-s*v*p-d*l*b+s*f*b,T=x*f*c-d*v*c-x*l*g+s*v*g+d*l*y-s*f*y,C=n*E+r*w+i*A+a*T;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/C;return e[0]=E*N,e[1]=(v*g*a-f*y*a-v*i*p+r*y*p+f*i*b-r*g*b)*N,e[2]=(l*y*a-v*c*a+v*i*u-r*y*u-l*i*b+r*c*b)*N,e[3]=(f*c*a-l*g*a-f*i*u+r*g*u+l*i*p-r*c*p)*N,e[4]=w*N,e[5]=(d*y*a-x*g*a+x*i*p-n*y*p-d*i*b+n*g*b)*N,e[6]=(x*c*a-s*y*a-x*i*u+n*y*u+s*i*b-n*c*b)*N,e[7]=(s*g*a-d*c*a+d*i*u-n*g*u-s*i*p+n*c*p)*N,e[8]=A*N,e[9]=(x*f*a-d*v*a-x*r*p+n*v*p+d*r*b-n*f*b)*N,e[10]=(s*v*a-x*l*a+x*r*u-n*v*u-s*r*b+n*l*b)*N,e[11]=(d*l*a-s*f*a-d*r*u+n*f*u+s*r*p-n*l*p)*N,e[12]=T*N,e[13]=(d*v*i-x*f*i+x*r*g-n*v*g-d*r*y+n*f*y)*N,e[14]=(x*l*i-s*v*i-x*r*c+n*v*c+s*r*y-n*l*y)*N,e[15]=(s*f*i-d*l*i+d*r*c-n*f*c-s*r*g+n*l*g)*N,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,s=e.x,l=e.y,c=e.z,u=a*s,d=a*l;return this.set(u*s+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*s,0,u*c-i*l,d*c+i*s,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,s){return this.set(1,r,a,0,e,1,s,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,s=n._y,l=n._z,c=n._w,u=a+a,d=s+s,f=l+l,g=a*u,p=a*d,x=a*f,v=s*d,y=s*f,b=l*f,E=c*u,w=c*d,A=c*f,T=r.x,C=r.y,N=r.z;return i[0]=(1-(v+b))*T,i[1]=(p+A)*T,i[2]=(x-w)*T,i[3]=0,i[4]=(p-A)*C,i[5]=(1-(g+b))*C,i[6]=(y+E)*C,i[7]=0,i[8]=(x+w)*N,i[9]=(y-E)*N,i[10]=(1-(g+v))*N,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=Om.set(i[0],i[1],i[2]).length();const s=Om.set(i[4],i[5],i[6]).length(),l=Om.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],ko.copy(this);const u=1/a,d=1/s,f=1/l;return ko.elements[0]*=u,ko.elements[1]*=u,ko.elements[2]*=u,ko.elements[4]*=d,ko.elements[5]*=d,ko.elements[6]*=d,ko.elements[8]*=f,ko.elements[9]*=f,ko.elements[10]*=f,n.setFromRotationMatrix(ko),r.x=a,r.y=s,r.z=l,this}makePerspective(e,n,r,i,a,s,l=gl){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),g=(r+i)/(r-i);let p,x;if(l===gl)p=-(s+a)/(s-a),x=-2*s*a/(s-a);else if(l===sb)p=-s/(s-a),x=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=u,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=g,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,s,l=gl){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(s-a),g=(n+e)*u,p=(r+i)*d;let x,v;if(l===gl)x=(s+a)*f,v=-2*f;else if(l===sb)x=a*f,v=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-g,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=v,c[14]=-x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const Om=new Oe,ko=new yr,bLe=new Oe(0,0,0),yLe=new Oe(1,1,1),Ou=new Oe,M_=new Oe,vs=new Oe,oV=new yr,lV=new yf;class sy{constructor(e=0,n=0,r=0,i=sy.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],s=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],g=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(aa(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-aa(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(aa(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-s,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-aa(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-s,u));break;case"YZX":this._z=Math.asin(aa(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,p));break;case"XZY":this._z=Math.asin(-aa(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return oV.makeRotationFromQuaternion(e),this.setFromRotationMatrix(oV,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return lV.setFromEuler(this),this.setFromQuaternion(lV,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}sy.DEFAULT_ORDER="XYZ";class gQ{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let vLe=0;const cV=new Oe,Lm=new yf,cc=new yr,E_=new Oe,Fx=new Oe,_Le=new Oe,wLe=new yf,uV=new Oe(1,0,0),dV=new Oe(0,1,0),hV=new Oe(0,0,1),SLe={type:"added"},MLe={type:"removed"};class Da extends Cf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:vLe++}),this.uuid=Lc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Da.DEFAULT_UP.clone();const e=new Oe,n=new sy,r=new yf,i=new Oe(1,1,1);function a(){r.setFromEuler(n,!1)}function s(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new yr},normalMatrix:{value:new yn}}),this.matrix=new yr,this.matrixWorld=new yr,this.matrixAutoUpdate=Da.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Da.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new gQ,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,n){this.quaternion.setFromAxisAngle(e,n)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,n){return Lm.setFromAxisAngle(e,n),this.quaternion.multiply(Lm),this}rotateOnWorldAxis(e,n){return Lm.setFromAxisAngle(e,n),this.quaternion.premultiply(Lm),this}rotateX(e){return this.rotateOnAxis(uV,e)}rotateY(e){return this.rotateOnAxis(dV,e)}rotateZ(e){return this.rotateOnAxis(hV,e)}translateOnAxis(e,n){return cV.copy(e).applyQuaternion(this.quaternion),this.position.add(cV.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(uV,e)}translateY(e){return this.translateOnAxis(dV,e)}translateZ(e){return this.translateOnAxis(hV,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(cc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?E_.copy(e):E_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Fx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?cc.lookAt(Fx,E_,this.up):cc.lookAt(E_,Fx,this.up),this.quaternion.setFromRotationMatrix(cc),i&&(cc.extractRotation(i.matrixWorld),Lm.setFromRotationMatrix(cc),this.quaternion.premultiply(Lm.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(SLe)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(MLe)),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),cc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),cc.multiply(e.parent.matrixWorld)),e.applyMatrix4(cc),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const s=this.children[r].getObjectByProperty(e,n);if(s!==void 0)return s}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,s=i.length;a<s;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Fx,e,_Le),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Fx,wLe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++){const a=n[r];(a.matrixWorldAutoUpdate===!0||e===!0)&&a.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const i=this.children;for(let a=0,s=i.length;a<s;a++){const l=i[a];l.matrixWorldAutoUpdate===!0&&l.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function a(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(a(e.animations,c))}}if(n){const l=s(e.geometries),c=s(e.materials),u=s(e.textures),d=s(e.images),f=s(e.shapes),g=s(e.skeletons),p=s(e.animations),x=s(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function s(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}Da.DEFAULT_UP=new Oe(0,1,0);Da.DEFAULT_MATRIX_AUTO_UPDATE=!0;Da.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Po=new Oe,uc=new Oe,TC=new Oe,dc=new Oe,Im=new Oe,Fm=new Oe,fV=new Oe,NC=new Oe,CC=new Oe,kC=new Oe;let A_=!1;class jo{constructor(e=new Oe,n=new Oe,r=new Oe){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Po.subVectors(e,n),i.cross(Po);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){Po.subVectors(i,n),uc.subVectors(r,n),TC.subVectors(e,n);const s=Po.dot(Po),l=Po.dot(uc),c=Po.dot(TC),u=uc.dot(uc),d=uc.dot(TC),f=s*u-l*l;if(f===0)return a.set(-2,-1,-1);const g=1/f,p=(u*c-l*d)*g,x=(s*d-l*c)*g;return a.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,dc),dc.x>=0&&dc.y>=0&&dc.x+dc.y<=1}static getUV(e,n,r,i,a,s,l,c){return A_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),A_=!0),this.getInterpolation(e,n,r,i,a,s,l,c)}static getInterpolation(e,n,r,i,a,s,l,c){return this.getBarycoord(e,n,r,i,dc),c.setScalar(0),c.addScaledVector(a,dc.x),c.addScaledVector(s,dc.y),c.addScaledVector(l,dc.z),c}static isFrontFacing(e,n,r,i){return Po.subVectors(r,n),uc.subVectors(e,n),Po.cross(uc).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Po.subVectors(this.c,this.b),uc.subVectors(this.a,this.b),Po.cross(uc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return jo.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return jo.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return A_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),A_=!0),jo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return jo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return jo.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return jo.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let s,l;Im.subVectors(i,r),Fm.subVectors(a,r),NC.subVectors(e,r);const c=Im.dot(NC),u=Fm.dot(NC);if(c<=0&&u<=0)return n.copy(r);CC.subVectors(e,i);const d=Im.dot(CC),f=Fm.dot(CC);if(d>=0&&f<=d)return n.copy(i);const g=c*f-d*u;if(g<=0&&c>=0&&d<=0)return s=c/(c-d),n.copy(r).addScaledVector(Im,s);kC.subVectors(e,a);const p=Im.dot(kC),x=Fm.dot(kC);if(x>=0&&p<=x)return n.copy(a);const v=p*u-c*x;if(v<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Fm,l);const y=d*x-p*f;if(y<=0&&f-d>=0&&p-x>=0)return fV.subVectors(a,i),l=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(fV,l);const b=1/(y+v+g);return s=v*b,l=g*b,n.copy(r).addScaledVector(Im,s).addScaledVector(Fm,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const xQ={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Lu={h:0,s:0,l:0},T_={h:0,s:0,l:0};function PC(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let Kt=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=ia){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,or.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=or.workingColorSpace){return this.r=e,this.g=n,this.b=r,or.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=or.workingColorSpace){if(e=HO(e,1),n=aa(n,0,1),r=aa(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,s=2*r-a;this.r=PC(s,a,e+1/3),this.g=PC(s,a,e),this.b=PC(s,a,e-1/3)}return or.toWorkingColorSpace(this,i),this}setStyle(e,n=ia){function r(a){a!==void 0&&parseFloat(a)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=i[1],l=i[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(s===6)return this.setHex(parseInt(a,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=ia){const r=xQ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=yp(e.r),this.g=yp(e.g),this.b=yp(e.b),this}copyLinearToSRGB(e){return this.r=yC(e.r),this.g=yC(e.g),this.b=yC(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ia){return or.fromWorkingColorSpace(pa.copy(this),e),Math.round(aa(pa.r*255,0,255))*65536+Math.round(aa(pa.g*255,0,255))*256+Math.round(aa(pa.b*255,0,255))}getHexString(e=ia){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=or.workingColorSpace){or.fromWorkingColorSpace(pa.copy(this),n);const r=pa.r,i=pa.g,a=pa.b,s=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+s)/2;if(l===s)c=0,u=0;else{const f=s-l;switch(u=d<=.5?f/(s+l):f/(2-s-l),s){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=or.workingColorSpace){return or.fromWorkingColorSpace(pa.copy(this),n),e.r=pa.r,e.g=pa.g,e.b=pa.b,e}getStyle(e=ia){or.fromWorkingColorSpace(pa.copy(this),e);const n=pa.r,r=pa.g,i=pa.b;return e!==ia?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(Lu),this.setHSL(Lu.h+e,Lu.s+n,Lu.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,r){return this.r=e.r+(n.r-e.r)*r,this.g=e.g+(n.g-e.g)*r,this.b=e.b+(n.b-e.b)*r,this}lerpHSL(e,n){this.getHSL(Lu),e.getHSL(T_);const r=u0(Lu.h,T_.h,n),i=u0(Lu.s,T_.s,n),a=u0(Lu.l,T_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const pa=new Kt;Kt.NAMES=xQ;let ELe=0;class wg extends Cf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ELe++}),this.uuid=Lc(),this.name="",this.type="Material",this.blending=bp,this.side=Ad,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ZP,this.blendDst=QP,this.blendEquation=_h,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Kt(0,0,0),this.blendAlpha=0,this.depthFunc=Kw,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=eV,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=km,this.stencilZFail=km,this.stencilZPass=km,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const r=e[n];if(r===void 0){console.warn(`THREE.Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){console.warn(`THREE.Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==bp&&(r.blending=this.blending),this.side!==Ad&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==ZP&&(r.blendSrc=this.blendSrc),this.blendDst!==QP&&(r.blendDst=this.blendDst),this.blendEquation!==_h&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==Kw&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==eV&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==km&&(r.stencilFail=this.stencilFail),this.stencilZFail!==km&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==km&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const s=[];for(const l in a){const c=a[l];delete c.metadata,s.push(c)}return s}if(n){const a=i(e.textures),s=i(e.images);a.length>0&&(r.textures=a),s.length>0&&(r.images=s)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class bQ extends wg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Kt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=UO,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const si=new Oe,N_=new tn;class Ps{constructor(e,n,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=rj,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Cc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)N_.fromBufferAttribute(this,n),N_.applyMatrix3(e),this.setXY(n,N_.x,N_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)si.fromBufferAttribute(this,n),si.applyMatrix3(e),this.setXYZ(n,si.x,si.y,si.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)si.fromBufferAttribute(this,n),si.applyMatrix4(e),this.setXYZ(n,si.x,si.y,si.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)si.fromBufferAttribute(this,n),si.applyNormalMatrix(e),this.setXYZ(n,si.x,si.y,si.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)si.fromBufferAttribute(this,n),si.transformDirection(e),this.setXYZ(n,si.x,si.y,si.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=hl(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=sr(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=hl(n,this.array)),n}setX(e,n){return this.normalized&&(n=sr(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=hl(n,this.array)),n}setY(e,n){return this.normalized&&(n=sr(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=hl(n,this.array)),n}setZ(e,n){return this.normalized&&(n=sr(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=hl(n,this.array)),n}setW(e,n){return this.normalized&&(n=sr(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=sr(n,this.array),r=sr(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=sr(n,this.array),r=sr(r,this.array),i=sr(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=sr(n,this.array),r=sr(r,this.array),i=sr(i,this.array),a=sr(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==rj&&(e.usage=this.usage),e}}class yQ extends Ps{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class vQ extends Ps{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class ei extends Ps{constructor(e,n,r){super(new Float32Array(e),n,r)}}let ALe=0;const Ws=new yr,jC=new Da,Um=new Oe,_s=new ho,Ux=new ho,Oi=new Oe;class Sa extends Cf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ALe++}),this.uuid=Lc(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(hQ(e)?vQ:yQ)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new yn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ws.makeRotationFromQuaternion(e),this.applyMatrix4(Ws),this}rotateX(e){return Ws.makeRotationX(e),this.applyMatrix4(Ws),this}rotateY(e){return Ws.makeRotationY(e),this.applyMatrix4(Ws),this}rotateZ(e){return Ws.makeRotationZ(e),this.applyMatrix4(Ws),this}translate(e,n,r){return Ws.makeTranslation(e,n,r),this.applyMatrix4(Ws),this}scale(e,n,r){return Ws.makeScale(e,n,r),this.applyMatrix4(Ws),this}lookAt(e){return jC.lookAt(e),jC.updateMatrix(),this.applyMatrix4(jC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Um).negate(),this.translate(Um.x,Um.y,Um.z),this}setFromPoints(e){const n=[];for(let r=0,i=e.length;r<i;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}return this.setAttribute("position",new ei(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ho);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new Oe(-1/0,-1/0,-1/0),new Oe(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];_s.setFromBufferAttribute(a),this.morphTargetsRelative?(Oi.addVectors(this.boundingBox.min,_s.min),this.boundingBox.expandByPoint(Oi),Oi.addVectors(this.boundingBox.max,_s.max),this.boundingBox.expandByPoint(Oi)):(this.boundingBox.expandByPoint(_s.min),this.boundingBox.expandByPoint(_s.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new bl);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new Oe,1/0);return}if(e){const r=this.boundingSphere.center;if(_s.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const l=n[a];Ux.setFromBufferAttribute(l),this.morphTargetsRelative?(Oi.addVectors(_s.min,Ux.min),_s.expandByPoint(Oi),Oi.addVectors(_s.max,Ux.max),_s.expandByPoint(Oi)):(_s.expandByPoint(Ux.min),_s.expandByPoint(Ux.max))}_s.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)Oi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Oi));if(n)for(let a=0,s=n.length;a<s;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)Oi.fromBufferAttribute(l,u),c&&(Um.fromBufferAttribute(e,u),Oi.add(Um)),i=Math.max(i,r.distanceToSquared(Oi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,a=n.normal.array,s=n.uv.array,l=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ps(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let j=0;j<l;j++)u[j]=new Oe,d[j]=new Oe;const f=new Oe,g=new Oe,p=new Oe,x=new tn,v=new tn,y=new tn,b=new Oe,E=new Oe;function w(j,B,L){f.fromArray(i,j*3),g.fromArray(i,B*3),p.fromArray(i,L*3),x.fromArray(s,j*2),v.fromArray(s,B*2),y.fromArray(s,L*2),g.sub(f),p.sub(f),v.sub(x),y.sub(x);const K=1/(v.x*y.y-y.x*v.y);isFinite(K)&&(b.copy(g).multiplyScalar(y.y).addScaledVector(p,-v.y).multiplyScalar(K),E.copy(p).multiplyScalar(v.x).addScaledVector(g,-y.x).multiplyScalar(K),u[j].add(b),u[B].add(b),u[L].add(b),d[j].add(E),d[B].add(E),d[L].add(E))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let j=0,B=A.length;j<B;++j){const L=A[j],K=L.start,R=L.count;for(let q=K,W=K+R;q<W;q+=3)w(r[q+0],r[q+1],r[q+2])}const T=new Oe,C=new Oe,N=new Oe,O=new Oe;function k(j){N.fromArray(a,j*3),O.copy(N);const B=u[j];T.copy(B),T.sub(N.multiplyScalar(N.dot(B))).normalize(),C.crossVectors(O,B);const K=C.dot(d[j])<0?-1:1;c[j*4]=T.x,c[j*4+1]=T.y,c[j*4+2]=T.z,c[j*4+3]=K}for(let j=0,B=A.length;j<B;++j){const L=A[j],K=L.start,R=L.count;for(let q=K,W=K+R;q<W;q+=3)k(r[q+0]),k(r[q+1]),k(r[q+2])}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new Ps(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,p=r.count;g<p;g++)r.setXYZ(g,0,0,0);const i=new Oe,a=new Oe,s=new Oe,l=new Oe,c=new Oe,u=new Oe,d=new Oe,f=new Oe;if(e)for(let g=0,p=e.count;g<p;g+=3){const x=e.getX(g+0),v=e.getX(g+1),y=e.getX(g+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,v),s.fromBufferAttribute(n,y),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,y),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(y,u.x,u.y,u.z)}else for(let g=0,p=n.count;g<p;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),s.fromBufferAttribute(n,g+2),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),r.setXYZ(g+0,d.x,d.y,d.z),r.setXYZ(g+1,d.x,d.y,d.z),r.setXYZ(g+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Oi.fromBufferAttribute(e,n),Oi.normalize(),e.setXYZ(n,Oi.x,Oi.y,Oi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,g=new u.constructor(c.length*d);let p=0,x=0;for(let v=0,y=c.length;v<y;v++){l.isInterleavedBufferAttribute?p=c[v]*l.data.stride+l.offset:p=c[v]*d;for(let b=0;b<d;b++)g[x++]=u[p++]}return new Ps(g,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Sa,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const g=u[d],p=e(g,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let l=0,c=s.length;l<c;l++){const u=s[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,g=u.length;f<g;f++){const p=u[f];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let g=0,p=f.length;g<p;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let u=0,d=s.length;u<d;u++){const f=s[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const mV=new yr,lh=new $O,C_=new bl,pV=new Oe,zm=new Oe,Bm=new Oe,Hm=new Oe,RC=new Oe,k_=new Oe,P_=new tn,j_=new tn,R_=new tn,gV=new Oe,xV=new Oe,bV=new Oe,D_=new Oe,O_=new Oe;class Uo extends Da{constructor(e=new Sa,n=new bQ){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,s=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){k_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(RC.fromBufferAttribute(f,e),s?k_.addScaledVector(RC,d):k_.addScaledVector(RC.sub(n),d))}n.add(k_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),C_.copy(r.boundingSphere),C_.applyMatrix4(a),lh.copy(e.ray).recast(e.near),!(C_.containsPoint(lh.origin)===!1&&(lh.intersectSphere(C_,pV)===null||lh.origin.distanceToSquared(pV)>(e.far-e.near)**2))&&(mV.copy(a).invert(),lh.copy(e.ray).applyMatrix4(mV),!(r.boundingBox!==null&&lh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,lh)))}_computeIntersections(e,n,r){let i;const a=this.geometry,s=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,g=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],E=Math.max(y.start,p.start),w=Math.min(l.count,Math.min(y.start+y.count,p.start+p.count));for(let A=E,T=w;A<T;A+=3){const C=l.getX(A),N=l.getX(A+1),O=l.getX(A+2);i=L_(this,b,e,r,u,d,f,C,N,O),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let y=x,b=v;y<b;y+=3){const E=l.getX(y),w=l.getX(y+1),A=l.getX(y+2);i=L_(this,s,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(s))for(let x=0,v=g.length;x<v;x++){const y=g[x],b=s[y.materialIndex],E=Math.max(y.start,p.start),w=Math.min(c.count,Math.min(y.start+y.count,p.start+p.count));for(let A=E,T=w;A<T;A+=3){const C=A,N=A+1,O=A+2;i=L_(this,b,e,r,u,d,f,C,N,O),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=y.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let y=x,b=v;y<b;y+=3){const E=y,w=y+1,A=y+2;i=L_(this,s,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(y/3),n.push(i))}}}}function TLe(t,e,n,r,i,a,s,l){let c;if(e.side===ns?c=r.intersectTriangle(s,a,i,!0,l):c=r.intersectTriangle(i,a,s,e.side===Ad,l),c===null)return null;O_.copy(l),O_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(O_);return u<n.near||u>n.far?null:{distance:u,point:O_.clone(),object:t}}function L_(t,e,n,r,i,a,s,l,c,u){t.getVertexPosition(l,zm),t.getVertexPosition(c,Bm),t.getVertexPosition(u,Hm);const d=TLe(t,e,n,r,zm,Bm,Hm,D_);if(d){i&&(P_.fromBufferAttribute(i,l),j_.fromBufferAttribute(i,c),R_.fromBufferAttribute(i,u),d.uv=jo.getInterpolation(D_,zm,Bm,Hm,P_,j_,R_,new tn)),a&&(P_.fromBufferAttribute(a,l),j_.fromBufferAttribute(a,c),R_.fromBufferAttribute(a,u),d.uv1=jo.getInterpolation(D_,zm,Bm,Hm,P_,j_,R_,new tn),d.uv2=d.uv1),s&&(gV.fromBufferAttribute(s,l),xV.fromBufferAttribute(s,c),bV.fromBufferAttribute(s,u),d.normal=jo.getInterpolation(D_,zm,Bm,Hm,gV,xV,bV,new Oe),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new Oe,materialIndex:0};jo.getNormal(zm,Bm,Hm,f.normal),d.face=f}return d}class oy extends Sa{constructor(e=1,n=1,r=1,i=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:s};const l=this;i=Math.floor(i),a=Math.floor(a),s=Math.floor(s);const c=[],u=[],d=[],f=[];let g=0,p=0;x("z","y","x",-1,-1,r,n,e,s,a,0),x("z","y","x",1,-1,r,n,-e,s,a,1),x("x","z","y",1,1,e,r,n,i,s,2),x("x","z","y",1,-1,e,r,-n,i,s,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new ei(u,3)),this.setAttribute("normal",new ei(d,3)),this.setAttribute("uv",new ei(f,2));function x(v,y,b,E,w,A,T,C,N,O,k){const j=A/N,B=T/O,L=A/2,K=T/2,R=C/2,q=N+1,W=O+1;let $=0,J=0;const ee=new Oe;for(let Q=0;Q<W;Q++){const z=Q*B-K;for(let V=0;V<q;V++){const X=V*j-L;ee[v]=X*E,ee[y]=z*w,ee[b]=R,u.push(ee.x,ee.y,ee.z),ee[v]=0,ee[y]=0,ee[b]=C>0?1:-1,d.push(ee.x,ee.y,ee.z),f.push(V/N),f.push(1-Q/O),$+=1}}for(let Q=0;Q<O;Q++)for(let z=0;z<N;z++){const V=g+z+q*Q,X=g+z+q*(Q+1),te=g+(z+1)+q*(Q+1),ie=g+(z+1)+q*Q;c.push(V,X,ie),c.push(X,te,ie),J+=6}l.addGroup(p,J,k),p+=J,g+=$}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new oy(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Wp(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function Na(t){const e={};for(let n=0;n<t.length;n++){const r=Wp(t[n]);for(const i in r)e[i]=r[i]}return e}function NLe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function _Q(t){return t.getRenderTarget()===null?t.outputColorSpace:or.workingColorSpace}const VO={clone:Wp,merge:Na};var CLe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,kLe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class Td extends wg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=CLe,this.fragmentShader=kLe,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Wp(e.uniforms),this.uniformsGroups=NLe(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const s=this.uniforms[i].value;s&&s.isTexture?n.uniforms[i]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?n.uniforms[i]={type:"c",value:s.getHex()}:s&&s.isVector2?n.uniforms[i]={type:"v2",value:s.toArray()}:s&&s.isVector3?n.uniforms[i]={type:"v3",value:s.toArray()}:s&&s.isVector4?n.uniforms[i]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?n.uniforms[i]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?n.uniforms[i]={type:"m4",value:s.toArray()}:n.uniforms[i]={value:s}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}}class wQ extends Da{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new yr,this.projectionMatrix=new yr,this.projectionMatrixInverse=new yr,this.coordinateSystem=gl}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class Ss extends wQ{constructor(e=50,n=1,r=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=i,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const n=.5*this.getFilmHeight()/e;this.fov=ob*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(c0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ob*2*Math.atan(Math.tan(c0*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,r,i,a,s){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(c0*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const s=this.view;if(this.view!==null&&this.view.enabled){const c=s.fullWidth,u=s.fullHeight;a+=s.offsetX*i/c,n-=s.offsetY*r/u,i*=s.width/c,r*=s.height/u}const l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const $m=-90,Vm=1;class PLe extends Da{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ss($m,Vm,e,n);i.layers=this.layers,this.add(i);const a=new Ss($m,Vm,e,n);a.layers=this.layers,this.add(a);const s=new Ss($m,Vm,e,n);s.layers=this.layers,this.add(s);const l=new Ss($m,Vm,e,n);l.layers=this.layers,this.add(l);const c=new Ss($m,Vm,e,n);c.layers=this.layers,this.add(c);const u=new Ss($m,Vm,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,s,l,c]=n;for(const u of n)this.remove(u);if(e===gl)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===sb)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,l,c,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,s),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class SQ extends rs{constructor(e,n,r,i,a,s,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:$p,super(e,n,r,i,a,s,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class jLe extends bf{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];n.encoding!==void 0&&(d0("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===$h?ia:io),this.texture=new SQ(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:no}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new oy(5,5,5),a=new Td({name:"CubemapFromEquirect",uniforms:Wp(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ns,blending:cd});a.uniforms.tEquirect.value=n;const s=new Uo(i,a),l=n.minFilter;return n.minFilter===ib&&(n.minFilter=no),new PLe(1,10,this).update(e,s),n.minFilter=l,s.geometry.dispose(),s.material.dispose(),this}clear(e,n,r,i){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(n,r,i);e.setRenderTarget(a)}}const DC=new Oe,RLe=new Oe,DLe=new yn;class Vu{constructor(e=new Oe(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=DC.subVectors(r,n).cross(RLe.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n){const r=e.delta(DC),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||DLe.getNormalMatrix(e),i=this.coplanarPoint(DC).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const ch=new bl,I_=new Oe;class sE{constructor(e=new Vu,n=new Vu,r=new Vu,i=new Vu,a=new Vu,s=new Vu){this.planes=[e,n,r,i,a,s]}set(e,n,r,i,a,s){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(a),l[5].copy(s),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=gl){const r=this.planes,i=e.elements,a=i[0],s=i[1],l=i[2],c=i[3],u=i[4],d=i[5],f=i[6],g=i[7],p=i[8],x=i[9],v=i[10],y=i[11],b=i[12],E=i[13],w=i[14],A=i[15];if(r[0].setComponents(c-a,g-u,y-p,A-b).normalize(),r[1].setComponents(c+a,g+u,y+p,A+b).normalize(),r[2].setComponents(c+s,g+d,y+x,A+E).normalize(),r[3].setComponents(c-s,g-d,y-x,A-E).normalize(),r[4].setComponents(c-l,g-f,y-v,A-w).normalize(),n===gl)r[5].setComponents(c+l,g+f,y+v,A+w).normalize();else if(n===sb)r[5].setComponents(l,f,v,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),ch.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),ch.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ch)}intersectsSprite(e){return ch.center.set(0,0,0),ch.radius=.7071067811865476,ch.applyMatrix4(e.matrixWorld),this.intersectsSphere(ch)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(I_.x=i.normal.x>0?e.max.x:e.min.x,I_.y=i.normal.y>0?e.max.y:e.min.y,I_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(I_)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function MQ(){let t=null,e=!1,n=null,r=null;function i(a,s){n(a,s),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function OLe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,g=u.usage,p=f.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,f,g),u.onUploadCallback();let v;if(f instanceof Float32Array)v=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)v=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else v=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)v=t.SHORT;else if(f instanceof Uint32Array)v=t.UNSIGNED_INT;else if(f instanceof Int32Array)v=t.INT;else if(f instanceof Int8Array)v=t.BYTE;else if(f instanceof Uint8Array)v=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)v=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:x,type:v,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:p}}function a(u,d,f){const g=d.array,p=d._updateRange,x=d.updateRanges;if(t.bindBuffer(f,u),p.count===-1&&x.length===0&&t.bufferSubData(f,0,g),x.length!==0){for(let v=0,y=x.length;v<y;v++){const b=x[v];n?t.bufferSubData(f,b.start*g.BYTES_PER_ELEMENT,g,b.start,b.count):t.bufferSubData(f,b.start*g.BYTES_PER_ELEMENT,g.subarray(b.start,b.start+b.count))}d.clearUpdateRanges()}p.count!==-1&&(n?t.bufferSubData(f,p.offset*g.BYTES_PER_ELEMENT,g,p.offset,p.count):t.bufferSubData(f,p.offset*g.BYTES_PER_ELEMENT,g.subarray(p.offset,p.offset+p.count)),p.count=-1),d.onUploadCallback()}function s(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function l(u){u.isInterleavedBufferAttribute&&(u=u.data);const d=r.get(u);d&&(t.deleteBuffer(d.buffer),r.delete(u))}function c(u,d){if(u.isGLBufferAttribute){const g=r.get(u);(!g||g.version<u.version)&&r.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);const f=r.get(u);if(f===void 0)r.set(u,i(u,d));else if(f.version<u.version){if(f.size!==u.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");a(f.buffer,u,d),f.version=u.version}}return{get:s,remove:l,update:c}}class GO extends Sa{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,s=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,g=n/c,p=[],x=[],v=[],y=[];for(let b=0;b<d;b++){const E=b*g-s;for(let w=0;w<u;w++){const A=w*f-a;x.push(A,-E,0),v.push(0,0,1),y.push(w/l),y.push(1-b/c)}}for(let b=0;b<c;b++)for(let E=0;E<l;E++){const w=E+u*b,A=E+u*(b+1),T=E+1+u*(b+1),C=E+1+u*b;p.push(w,A,C),p.push(A,T,C)}this.setIndex(p),this.setAttribute("position",new ei(x,3)),this.setAttribute("normal",new ei(v,3)),this.setAttribute("uv",new ei(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new GO(e.width,e.height,e.widthSegments,e.heightSegments)}}var LLe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,ILe=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,FLe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,ULe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,zLe=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,BLe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,HLe=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,$Le=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,VLe=`#ifdef USE_BATCHING
- attribute float batchId;
- uniform highp sampler2D batchingTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,GLe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,WLe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,qLe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,KLe=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,XLe=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,YLe=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,ZLe=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif`,QLe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,JLe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,e4e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,t4e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,n4e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,r4e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,i4e=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif`,a4e=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- mat3 transposeMat3( const in mat3 m ) {
- mat3 tmp;
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
- return tmp;
- }
- float luminance( const in vec3 rgb ) {
- const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
- return dot( weights, rgb );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,s4e=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_v0 0.339
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_v1 0.276
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_v4 0.046
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_v5 0.016
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_v6 0.0038
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,o4e=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,l4e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,c4e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,u4e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,d4e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,h4e="gl_FragColor = linearToOutputTexel( gl_FragColor );",f4e=`
- const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
- vec3( 0.8224621, 0.177538, 0.0 ),
- vec3( 0.0331941, 0.9668058, 0.0 ),
- vec3( 0.0170827, 0.0723974, 0.9105199 )
- );
- const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
- vec3( 1.2249401, - 0.2249404, 0.0 ),
- vec3( - 0.0420569, 1.0420571, 0.0 ),
- vec3( - 0.0196376, - 0.0786361, 1.0982735 )
- );
- vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
- return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
- }
- vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
- return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
- }
- vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }
- vec4 LinearToLinear( in vec4 value ) {
- return value;
- }
- vec4 LinearTosRGB( in vec4 value ) {
- return sRGBTransferOETF( value );
- }`,m4e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,p4e=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,g4e=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,x4e=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,b4e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,y4e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,v4e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,_4e=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,w4e=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,S4e=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,M4e=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,E4e=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,A4e=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,T4e=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,N4e=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- #if defined ( LEGACY_LIGHTS )
- if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
- return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
- }
- return 1.0;
- #else
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- #endif
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,C4e=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,k4e=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,P4e=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,j4e=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,R4e=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,D4e=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,O4e=`struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
- vec4 r = roughness * c0 + c1;
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
- return fab;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,L4e=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,I4e=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,F4e=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,U4e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,z4e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,B4e=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,H4e=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #else
- if ( isPerspectiveMatrix( projectionMatrix ) ) {
- gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
- gl_Position.z *= gl_Position.w;
- }
- #endif
- #endif`,$4e=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
-
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,V4e=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,G4e=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,W4e=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,q4e=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,K4e=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,X4e=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,Y4e=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
- objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
- objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
- objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
- #endif
- #endif`,Z4e=`#ifdef USE_MORPHTARGETS
- uniform float morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #else
- #ifndef USE_MORPHNORMALS
- uniform float morphTargetInfluences[ 8 ];
- #else
- uniform float morphTargetInfluences[ 4 ];
- #endif
- #endif
- #endif`,Q4e=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- transformed += morphTarget0 * morphTargetInfluences[ 0 ];
- transformed += morphTarget1 * morphTargetInfluences[ 1 ];
- transformed += morphTarget2 * morphTargetInfluences[ 2 ];
- transformed += morphTarget3 * morphTargetInfluences[ 3 ];
- #ifndef USE_MORPHNORMALS
- transformed += morphTarget4 * morphTargetInfluences[ 4 ];
- transformed += morphTarget5 * morphTargetInfluences[ 5 ];
- transformed += morphTarget6 * morphTargetInfluences[ 6 ];
- transformed += morphTarget7 * morphTargetInfluences[ 7 ];
- #endif
- #endif
- #endif`,J4e=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,eIe=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,tIe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,nIe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,rIe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,iIe=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,aIe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,sIe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,oIe=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,lIe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,cIe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,uIe=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
- const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
- const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
- const float ShiftRight8 = 1. / 256.;
- vec4 packDepthToRGBA( const in float v ) {
- vec4 r = vec4( fract( v * PackFactors ), v );
- r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors );
- }
- vec2 packDepthToRG( in highp float v ) {
- return packDepthToRGBA( v ).yx;
- }
- float unpackRGToDepth( const in highp vec2 v ) {
- return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
- }
- vec4 pack2HalfToRGBA( vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,dIe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,hIe=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,fIe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,mIe=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,pIe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,gIe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,xIe=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- float hard_shadow = step( compare , distribution.x );
- if (hard_shadow != 1.0 ) {
- float distance = compare - distribution.x ;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return shadow;
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- vec3 lightToPosition = shadowCoord.xyz;
- float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- return (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- #endif`,bIe=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,yIe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,vIe=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,_Ie=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,wIe=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,SIe=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,MIe=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,EIe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,AIe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,TIe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,NIe=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 OptimizedCineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,CIe=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,kIe=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,PIe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,jIe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,RIe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,DIe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const OIe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,LIe=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,IIe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,FIe=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,UIe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,zIe=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,BIe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,HIe=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #endif
- }`,$Ie=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,VIe=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,GIe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,WIe=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,qIe=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,KIe=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,XIe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,YIe=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,ZIe=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,QIe=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,JIe=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,e5e=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,t5e=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,n5e=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,r5e=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,i5e=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,a5e=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,s5e=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,o5e=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,l5e=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,c5e=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,u5e=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,d5e=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,h5e=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,f5e=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
- vec2 scale;
- scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
- scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,m5e=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,hn={alphahash_fragment:LLe,alphahash_pars_fragment:ILe,alphamap_fragment:FLe,alphamap_pars_fragment:ULe,alphatest_fragment:zLe,alphatest_pars_fragment:BLe,aomap_fragment:HLe,aomap_pars_fragment:$Le,batching_pars_vertex:VLe,batching_vertex:GLe,begin_vertex:WLe,beginnormal_vertex:qLe,bsdfs:KLe,iridescence_fragment:XLe,bumpmap_pars_fragment:YLe,clipping_planes_fragment:ZLe,clipping_planes_pars_fragment:QLe,clipping_planes_pars_vertex:JLe,clipping_planes_vertex:e4e,color_fragment:t4e,color_pars_fragment:n4e,color_pars_vertex:r4e,color_vertex:i4e,common:a4e,cube_uv_reflection_fragment:s4e,defaultnormal_vertex:o4e,displacementmap_pars_vertex:l4e,displacementmap_vertex:c4e,emissivemap_fragment:u4e,emissivemap_pars_fragment:d4e,colorspace_fragment:h4e,colorspace_pars_fragment:f4e,envmap_fragment:m4e,envmap_common_pars_fragment:p4e,envmap_pars_fragment:g4e,envmap_pars_vertex:x4e,envmap_physical_pars_fragment:C4e,envmap_vertex:b4e,fog_vertex:y4e,fog_pars_vertex:v4e,fog_fragment:_4e,fog_pars_fragment:w4e,gradientmap_pars_fragment:S4e,lightmap_fragment:M4e,lightmap_pars_fragment:E4e,lights_lambert_fragment:A4e,lights_lambert_pars_fragment:T4e,lights_pars_begin:N4e,lights_toon_fragment:k4e,lights_toon_pars_fragment:P4e,lights_phong_fragment:j4e,lights_phong_pars_fragment:R4e,lights_physical_fragment:D4e,lights_physical_pars_fragment:O4e,lights_fragment_begin:L4e,lights_fragment_maps:I4e,lights_fragment_end:F4e,logdepthbuf_fragment:U4e,logdepthbuf_pars_fragment:z4e,logdepthbuf_pars_vertex:B4e,logdepthbuf_vertex:H4e,map_fragment:$4e,map_pars_fragment:V4e,map_particle_fragment:G4e,map_particle_pars_fragment:W4e,metalnessmap_fragment:q4e,metalnessmap_pars_fragment:K4e,morphcolor_vertex:X4e,morphnormal_vertex:Y4e,morphtarget_pars_vertex:Z4e,morphtarget_vertex:Q4e,normal_fragment_begin:J4e,normal_fragment_maps:eIe,normal_pars_fragment:tIe,normal_pars_vertex:nIe,normal_vertex:rIe,normalmap_pars_fragment:iIe,clearcoat_normal_fragment_begin:aIe,clearcoat_normal_fragment_maps:sIe,clearcoat_pars_fragment:oIe,iridescence_pars_fragment:lIe,opaque_fragment:cIe,packing:uIe,premultiplied_alpha_fragment:dIe,project_vertex:hIe,dithering_fragment:fIe,dithering_pars_fragment:mIe,roughnessmap_fragment:pIe,roughnessmap_pars_fragment:gIe,shadowmap_pars_fragment:xIe,shadowmap_pars_vertex:bIe,shadowmap_vertex:yIe,shadowmask_pars_fragment:vIe,skinbase_vertex:_Ie,skinning_pars_vertex:wIe,skinning_vertex:SIe,skinnormal_vertex:MIe,specularmap_fragment:EIe,specularmap_pars_fragment:AIe,tonemapping_fragment:TIe,tonemapping_pars_fragment:NIe,transmission_fragment:CIe,transmission_pars_fragment:kIe,uv_pars_fragment:PIe,uv_pars_vertex:jIe,uv_vertex:RIe,worldpos_vertex:DIe,background_vert:OIe,background_frag:LIe,backgroundCube_vert:IIe,backgroundCube_frag:FIe,cube_vert:UIe,cube_frag:zIe,depth_vert:BIe,depth_frag:HIe,distanceRGBA_vert:$Ie,distanceRGBA_frag:VIe,equirect_vert:GIe,equirect_frag:WIe,linedashed_vert:qIe,linedashed_frag:KIe,meshbasic_vert:XIe,meshbasic_frag:YIe,meshlambert_vert:ZIe,meshlambert_frag:QIe,meshmatcap_vert:JIe,meshmatcap_frag:e5e,meshnormal_vert:t5e,meshnormal_frag:n5e,meshphong_vert:r5e,meshphong_frag:i5e,meshphysical_vert:a5e,meshphysical_frag:s5e,meshtoon_vert:o5e,meshtoon_frag:l5e,points_vert:c5e,points_frag:u5e,shadow_vert:d5e,shadow_frag:h5e,sprite_vert:f5e,sprite_frag:m5e},Nt={common:{diffuse:{value:new Kt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new yn},alphaMap:{value:null},alphaMapTransform:{value:new yn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new yn}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new yn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new yn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new yn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new yn},normalScale:{value:new tn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new yn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new yn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new yn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new yn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Kt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Kt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new yn},alphaTest:{value:0},uvTransform:{value:new yn}},sprite:{diffuse:{value:new Kt(16777215)},opacity:{value:1},center:{value:new tn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new yn},alphaMap:{value:null},alphaMapTransform:{value:new yn},alphaTest:{value:0}}},Qa={basic:{uniforms:Na([Nt.common,Nt.specularmap,Nt.envmap,Nt.aomap,Nt.lightmap,Nt.fog]),vertexShader:hn.meshbasic_vert,fragmentShader:hn.meshbasic_frag},lambert:{uniforms:Na([Nt.common,Nt.specularmap,Nt.envmap,Nt.aomap,Nt.lightmap,Nt.emissivemap,Nt.bumpmap,Nt.normalmap,Nt.displacementmap,Nt.fog,Nt.lights,{emissive:{value:new Kt(0)}}]),vertexShader:hn.meshlambert_vert,fragmentShader:hn.meshlambert_frag},phong:{uniforms:Na([Nt.common,Nt.specularmap,Nt.envmap,Nt.aomap,Nt.lightmap,Nt.emissivemap,Nt.bumpmap,Nt.normalmap,Nt.displacementmap,Nt.fog,Nt.lights,{emissive:{value:new Kt(0)},specular:{value:new Kt(1118481)},shininess:{value:30}}]),vertexShader:hn.meshphong_vert,fragmentShader:hn.meshphong_frag},standard:{uniforms:Na([Nt.common,Nt.envmap,Nt.aomap,Nt.lightmap,Nt.emissivemap,Nt.bumpmap,Nt.normalmap,Nt.displacementmap,Nt.roughnessmap,Nt.metalnessmap,Nt.fog,Nt.lights,{emissive:{value:new Kt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:hn.meshphysical_vert,fragmentShader:hn.meshphysical_frag},toon:{uniforms:Na([Nt.common,Nt.aomap,Nt.lightmap,Nt.emissivemap,Nt.bumpmap,Nt.normalmap,Nt.displacementmap,Nt.gradientmap,Nt.fog,Nt.lights,{emissive:{value:new Kt(0)}}]),vertexShader:hn.meshtoon_vert,fragmentShader:hn.meshtoon_frag},matcap:{uniforms:Na([Nt.common,Nt.bumpmap,Nt.normalmap,Nt.displacementmap,Nt.fog,{matcap:{value:null}}]),vertexShader:hn.meshmatcap_vert,fragmentShader:hn.meshmatcap_frag},points:{uniforms:Na([Nt.points,Nt.fog]),vertexShader:hn.points_vert,fragmentShader:hn.points_frag},dashed:{uniforms:Na([Nt.common,Nt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:hn.linedashed_vert,fragmentShader:hn.linedashed_frag},depth:{uniforms:Na([Nt.common,Nt.displacementmap]),vertexShader:hn.depth_vert,fragmentShader:hn.depth_frag},normal:{uniforms:Na([Nt.common,Nt.bumpmap,Nt.normalmap,Nt.displacementmap,{opacity:{value:1}}]),vertexShader:hn.meshnormal_vert,fragmentShader:hn.meshnormal_frag},sprite:{uniforms:Na([Nt.sprite,Nt.fog]),vertexShader:hn.sprite_vert,fragmentShader:hn.sprite_frag},background:{uniforms:{uvTransform:{value:new yn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:hn.background_vert,fragmentShader:hn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:hn.backgroundCube_vert,fragmentShader:hn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:hn.cube_vert,fragmentShader:hn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:hn.equirect_vert,fragmentShader:hn.equirect_frag},distanceRGBA:{uniforms:Na([Nt.common,Nt.displacementmap,{referencePosition:{value:new Oe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:hn.distanceRGBA_vert,fragmentShader:hn.distanceRGBA_frag},shadow:{uniforms:Na([Nt.lights,Nt.fog,{color:{value:new Kt(0)},opacity:{value:1}}]),vertexShader:hn.shadow_vert,fragmentShader:hn.shadow_frag}};Qa.physical={uniforms:Na([Qa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new yn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new yn},clearcoatNormalScale:{value:new tn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new yn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new yn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new yn},sheen:{value:0},sheenColor:{value:new Kt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new yn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new yn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new yn},transmissionSamplerSize:{value:new tn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new yn},attenuationDistance:{value:0},attenuationColor:{value:new Kt(0)},specularColor:{value:new Kt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new yn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new yn},anisotropyVector:{value:new tn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new yn}}]),vertexShader:hn.meshphysical_vert,fragmentShader:hn.meshphysical_frag};const F_={r:0,b:0,g:0};function p5e(t,e,n,r,i,a,s){const l=new Kt(0);let c=a===!0?0:1,u,d,f=null,g=0,p=null;function x(y,b){let E=!1,w=b.isScene===!0?b.background:null;w&&w.isTexture&&(w=(b.backgroundBlurriness>0?n:e).get(w)),w===null?v(l,c):w&&w.isColor&&(v(w,1),E=!0);const A=t.xr.getEnvironmentBlendMode();A==="additive"?r.buffers.color.setClear(0,0,0,1,s):A==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,s),(t.autoClear||E)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),w&&(w.isCubeTexture||w.mapping===iE)?(d===void 0&&(d=new Uo(new oy(1,1,1),new Td({name:"BackgroundCubeMaterial",uniforms:Wp(Qa.backgroundCube.uniforms),vertexShader:Qa.backgroundCube.vertexShader,fragmentShader:Qa.backgroundCube.fragmentShader,side:ns,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(T,C,N){this.matrixWorld.copyPosition(N.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=w,d.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,d.material.toneMapped=or.getTransfer(w.colorSpace)!==wr,(f!==w||g!==w.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=w,g=w.version,p=t.toneMapping),d.layers.enableAll(),y.unshift(d,d.geometry,d.material,0,0,null)):w&&w.isTexture&&(u===void 0&&(u=new Uo(new GO(2,2),new Td({name:"BackgroundMaterial",uniforms:Wp(Qa.background.uniforms),vertexShader:Qa.background.vertexShader,fragmentShader:Qa.background.fragmentShader,side:Ad,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=w,u.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,u.material.toneMapped=or.getTransfer(w.colorSpace)!==wr,w.matrixAutoUpdate===!0&&w.updateMatrix(),u.material.uniforms.uvTransform.value.copy(w.matrix),(f!==w||g!==w.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=w,g=w.version,p=t.toneMapping),u.layers.enableAll(),y.unshift(u,u.geometry,u.material,0,0,null))}function v(y,b){y.getRGB(F_,_Q(t)),r.buffers.color.setClear(F_.r,F_.g,F_.b,b,s)}return{getClearColor:function(){return l},setClearColor:function(y,b=1){l.set(y),c=b,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(y){c=y,v(l,c)},render:x}}function g5e(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),s=r.isWebGL2||a!==null,l={},c=y(null);let u=c,d=!1;function f(R,q,W,$,J){let ee=!1;if(s){const Q=v($,W,q);u!==Q&&(u=Q,p(u.object)),ee=b(R,$,W,J),ee&&E(R,$,W,J)}else{const Q=q.wireframe===!0;(u.geometry!==$.id||u.program!==W.id||u.wireframe!==Q)&&(u.geometry=$.id,u.program=W.id,u.wireframe=Q,ee=!0)}J!==null&&n.update(J,t.ELEMENT_ARRAY_BUFFER),(ee||d)&&(d=!1,O(R,q,W,$),J!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(J).buffer))}function g(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function p(R){return r.isWebGL2?t.bindVertexArray(R):a.bindVertexArrayOES(R)}function x(R){return r.isWebGL2?t.deleteVertexArray(R):a.deleteVertexArrayOES(R)}function v(R,q,W){const $=W.wireframe===!0;let J=l[R.id];J===void 0&&(J={},l[R.id]=J);let ee=J[q.id];ee===void 0&&(ee={},J[q.id]=ee);let Q=ee[$];return Q===void 0&&(Q=y(g()),ee[$]=Q),Q}function y(R){const q=[],W=[],$=[];for(let J=0;J<i;J++)q[J]=0,W[J]=0,$[J]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:q,enabledAttributes:W,attributeDivisors:$,object:R,attributes:{},index:null}}function b(R,q,W,$){const J=u.attributes,ee=q.attributes;let Q=0;const z=W.getAttributes();for(const V in z)if(z[V].location>=0){const te=J[V];let ie=ee[V];if(ie===void 0&&(V==="instanceMatrix"&&R.instanceMatrix&&(ie=R.instanceMatrix),V==="instanceColor"&&R.instanceColor&&(ie=R.instanceColor)),te===void 0||te.attribute!==ie||ie&&te.data!==ie.data)return!0;Q++}return u.attributesNum!==Q||u.index!==$}function E(R,q,W,$){const J={},ee=q.attributes;let Q=0;const z=W.getAttributes();for(const V in z)if(z[V].location>=0){let te=ee[V];te===void 0&&(V==="instanceMatrix"&&R.instanceMatrix&&(te=R.instanceMatrix),V==="instanceColor"&&R.instanceColor&&(te=R.instanceColor));const ie={};ie.attribute=te,te&&te.data&&(ie.data=te.data),J[V]=ie,Q++}u.attributes=J,u.attributesNum=Q,u.index=$}function w(){const R=u.newAttributes;for(let q=0,W=R.length;q<W;q++)R[q]=0}function A(R){T(R,0)}function T(R,q){const W=u.newAttributes,$=u.enabledAttributes,J=u.attributeDivisors;W[R]=1,$[R]===0&&(t.enableVertexAttribArray(R),$[R]=1),J[R]!==q&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](R,q),J[R]=q)}function C(){const R=u.newAttributes,q=u.enabledAttributes;for(let W=0,$=q.length;W<$;W++)q[W]!==R[W]&&(t.disableVertexAttribArray(W),q[W]=0)}function N(R,q,W,$,J,ee,Q){Q===!0?t.vertexAttribIPointer(R,q,W,J,ee):t.vertexAttribPointer(R,q,W,$,J,ee)}function O(R,q,W,$){if(r.isWebGL2===!1&&(R.isInstancedMesh||$.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();const J=$.attributes,ee=W.getAttributes(),Q=q.defaultAttributeValues;for(const z in ee){const V=ee[z];if(V.location>=0){let X=J[z];if(X===void 0&&(z==="instanceMatrix"&&R.instanceMatrix&&(X=R.instanceMatrix),z==="instanceColor"&&R.instanceColor&&(X=R.instanceColor)),X!==void 0){const te=X.normalized,ie=X.itemSize,le=n.get(X);if(le===void 0)continue;const ge=le.buffer,Ee=le.type,pe=le.bytesPerElement,de=r.isWebGL2===!0&&(Ee===t.INT||Ee===t.UNSIGNED_INT||X.gpuType===tQ);if(X.isInterleavedBufferAttribute){const Re=X.data,fe=Re.stride,Fe=X.offset;if(Re.isInstancedInterleavedBuffer){for(let U=0;U<V.locationSize;U++)T(V.location+U,Re.meshPerAttribute);R.isInstancedMesh!==!0&&$._maxInstanceCount===void 0&&($._maxInstanceCount=Re.meshPerAttribute*Re.count)}else for(let U=0;U<V.locationSize;U++)A(V.location+U);t.bindBuffer(t.ARRAY_BUFFER,ge);for(let U=0;U<V.locationSize;U++)N(V.location+U,ie/V.locationSize,Ee,te,fe*pe,(Fe+ie/V.locationSize*U)*pe,de)}else{if(X.isInstancedBufferAttribute){for(let Re=0;Re<V.locationSize;Re++)T(V.location+Re,X.meshPerAttribute);R.isInstancedMesh!==!0&&$._maxInstanceCount===void 0&&($._maxInstanceCount=X.meshPerAttribute*X.count)}else for(let Re=0;Re<V.locationSize;Re++)A(V.location+Re);t.bindBuffer(t.ARRAY_BUFFER,ge);for(let Re=0;Re<V.locationSize;Re++)N(V.location+Re,ie/V.locationSize,Ee,te,ie*pe,ie/V.locationSize*Re*pe,de)}}else if(Q!==void 0){const te=Q[z];if(te!==void 0)switch(te.length){case 2:t.vertexAttrib2fv(V.location,te);break;case 3:t.vertexAttrib3fv(V.location,te);break;case 4:t.vertexAttrib4fv(V.location,te);break;default:t.vertexAttrib1fv(V.location,te)}}}}C()}function k(){L();for(const R in l){const q=l[R];for(const W in q){const $=q[W];for(const J in $)x($[J].object),delete $[J];delete q[W]}delete l[R]}}function j(R){if(l[R.id]===void 0)return;const q=l[R.id];for(const W in q){const $=q[W];for(const J in $)x($[J].object),delete $[J];delete q[W]}delete l[R.id]}function B(R){for(const q in l){const W=l[q];if(W[R.id]===void 0)continue;const $=W[R.id];for(const J in $)x($[J].object),delete $[J];delete W[R.id]}}function L(){K(),d=!0,u!==c&&(u=c,p(u.object))}function K(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:L,resetDefaultState:K,dispose:k,releaseStatesOfGeometry:j,releaseStatesOfProgram:B,initAttributes:w,enableAttribute:A,disableUnusedAttributes:C}}function x5e(t,e,n,r){const i=r.isWebGL2;let a;function s(d){a=d}function l(d,f){t.drawArrays(a,d,f),n.update(f,a,1)}function c(d,f,g){if(g===0)return;let p,x;if(i)p=t,x="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[x](a,d,f,g),n.update(f,a,g)}function u(d,f,g){if(g===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<g;x++)this.render(d[x],f[x]);else{p.multiDrawArraysWEBGL(a,d,0,f,0,g);let x=0;for(let v=0;v<g;v++)x+=f[v];n.update(x,a,1)}}this.setMode=s,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function b5e(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const N=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(N.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(N){if(N==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";N="mediump"}return N==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let l=n.precision!==void 0?n.precision:"highp";const c=a(l);c!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",c,"instead."),l=c);const u=s||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),g=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),y=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),b=t.getParameter(t.MAX_VARYING_VECTORS),E=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),w=g>0,A=s||e.has("OES_texture_float"),T=w&&A,C=s?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:s,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:a,precision:l,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:p,maxCubemapSize:x,maxAttributes:v,maxVertexUniforms:y,maxVaryings:b,maxFragmentUniforms:E,vertexTextures:w,floatFragmentTextures:A,floatVertexTextures:T,maxSamples:C}}function y5e(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new Vu,l=new yn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const p=f.length!==0||g||r!==0||i;return i=g,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,p){const x=f.clippingPlanes,v=f.clipIntersection,y=f.clipShadows,b=t.get(f);if(!i||x===null||x.length===0||a&&!y)a?d(null):u();else{const E=a?0:r,w=E*4;let A=b.clippingState||null;c.value=A,A=d(x,g,w,p);for(let T=0;T!==w;++T)A[T]=n[T];b.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=E}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,g,p,x){const v=f!==null?f.length:0;let y=null;if(v!==0){if(y=c.value,x!==!0||y===null){const b=p+v*4,E=g.matrixWorldInverse;l.getNormalMatrix(E),(y===null||y.length<b)&&(y=new Float32Array(b));for(let w=0,A=p;w!==v;++w,A+=4)s.copy(f[w]).applyMatrix4(E,l),s.normal.toArray(y,A),y[A+3]=s.constant}c.value=y,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,y}}function v5e(t){let e=new WeakMap;function n(s,l){return l===JP?s.mapping=$p:l===ej&&(s.mapping=Vp),s}function r(s){if(s&&s.isTexture){const l=s.mapping;if(l===JP||l===ej)if(e.has(s)){const c=e.get(s).texture;return n(c,s.mapping)}else{const c=s.image;if(c&&c.height>0){const u=new jLe(c.height/2);return u.fromEquirectangularTexture(t,s),e.set(s,u),s.addEventListener("dispose",i),n(u.texture,s.mapping)}else return null}}return s}function i(s){const l=s.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}class _5e extends wQ{constructor(e=-1,n=1,r=1,i=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,r,i,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,s=r+e,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=u*this.view.offsetX,s=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,l,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const cp=4,yV=[.125,.215,.35,.446,.526,.582],wh=20,OC=new _5e,vV=new Kt;let LC=null,IC=0,FC=0;const xh=(1+Math.sqrt(5))/2,Gm=1/xh,_V=[new Oe(1,1,1),new Oe(-1,1,1),new Oe(1,1,-1),new Oe(-1,1,-1),new Oe(0,xh,Gm),new Oe(0,xh,-Gm),new Oe(Gm,0,xh),new Oe(-Gm,0,xh),new Oe(xh,Gm,0),new Oe(-xh,Gm,0)];class wV{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,n=0,r=.1,i=100){LC=this._renderer.getRenderTarget(),IC=this._renderer.getActiveCubeFace(),FC=this._renderer.getActiveMipmapLevel(),this._setSize(256);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,r,i,a),n>0&&this._blur(a,0,0,n),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=EV(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=MV(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(LC,IC,FC),e.scissorTest=!1,U_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===$p||e.mapping===Vp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),LC=this._renderer.getRenderTarget(),IC=this._renderer.getActiveCubeFace(),FC=this._renderer.getActiveMipmapLevel();const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:no,minFilter:no,generateMipmaps:!1,type:ab,format:ro,colorSpace:Yc,depthBuffer:!1},i=SV(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=SV(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=w5e(a)),this._blurMaterial=S5e(a,e,n)}return i}_compileMaterial(e){const n=new Uo(this._lodPlanes[0],e);this._renderer.compile(n,OC)}_sceneToCubeUV(e,n,r,i){const l=new Ss(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,g=d.toneMapping;d.getClearColor(vV),d.toneMapping=ud,d.autoClear=!1;const p=new bQ({name:"PMREM.Background",side:ns,depthWrite:!1,depthTest:!1}),x=new Uo(new oy,p);let v=!1;const y=e.background;y?y.isColor&&(p.color.copy(y),e.background=null,v=!0):(p.color.copy(vV),v=!0);for(let b=0;b<6;b++){const E=b%3;E===0?(l.up.set(0,c[b],0),l.lookAt(u[b],0,0)):E===1?(l.up.set(0,0,c[b]),l.lookAt(0,u[b],0)):(l.up.set(0,c[b],0),l.lookAt(0,0,u[b]));const w=this._cubeSize;U_(i,E*w,b>2?w:0,w,w),d.setRenderTarget(i),v&&d.render(x,l),d.render(e,l)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=g,d.autoClear=f,e.background=y}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===$p||e.mapping===Vp;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=EV()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=MV());const a=i?this._cubemapMaterial:this._equirectMaterial,s=new Uo(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;U_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(s,OC)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const a=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),s=_V[(i-1)%_V.length];this._blur(e,i-1,i,a,s)}n.autoClear=r}_blur(e,n,r,i,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,n,r,i,"latitudinal",a),this._halfBlur(s,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,s,l){const c=this._renderer,u=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new Uo(this._lodPlanes[i],u),g=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*wh-1),v=a/x,y=isFinite(a)?1+Math.floor(d*v):wh;y>wh&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${wh}`);const b=[];let E=0;for(let N=0;N<wh;++N){const O=N/v,k=Math.exp(-O*O/2);b.push(k),N===0?E+=k:N<y&&(E+=2*k)}for(let N=0;N<b.length;N++)b[N]=b[N]/E;g.envMap.value=e.texture,g.samples.value=y,g.weights.value=b,g.latitudinal.value=s==="latitudinal",l&&(g.poleAxis.value=l);const{_lodMax:w}=this;g.dTheta.value=x,g.mipInt.value=w-r;const A=this._sizeLods[i],T=3*A*(i>w-cp?i-w+cp:0),C=4*(this._cubeSize-A);U_(n,T,C,3*A,2*A),c.setRenderTarget(n),c.render(f,OC)}}function w5e(t){const e=[],n=[],r=[];let i=t;const a=t-cp+1+yV.length;for(let s=0;s<a;s++){const l=Math.pow(2,i);n.push(l);let c=1/l;s>t-cp?c=yV[s-t+cp-1]:s===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,v=3,y=2,b=1,E=new Float32Array(v*x*p),w=new Float32Array(y*x*p),A=new Float32Array(b*x*p);for(let C=0;C<p;C++){const N=C%3*2/3-1,O=C>2?0:-1,k=[N,O,0,N+2/3,O,0,N+2/3,O+1,0,N,O,0,N+2/3,O+1,0,N,O+1,0];E.set(k,v*x*C),w.set(g,y*x*C);const j=[C,C,C,C,C,C];A.set(j,b*x*C)}const T=new Sa;T.setAttribute("position",new Ps(E,v)),T.setAttribute("uv",new Ps(w,y)),T.setAttribute("faceIndex",new Ps(A,b)),e.push(T),i>cp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function SV(t,e,n){const r=new bf(t,e,n);return r.texture.mapping=iE,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function U_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function S5e(t,e,n){const r=new Float32Array(wh),i=new Oe(0,1,0);return new Td({name:"SphericalGaussianBlur",defines:{n:wh,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:WO(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:cd,depthTest:!1,depthWrite:!1})}function MV(){return new Td({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:WO(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:cd,depthTest:!1,depthWrite:!1})}function EV(){return new Td({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:WO(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:cd,depthTest:!1,depthWrite:!1})}function WO(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function M5e(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===JP||c===ej,d=c===$p||c===Vp;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new wV(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),e.set(l,f),f.texture}else{if(e.has(l))return e.get(l).texture;{const f=l.image;if(u&&f&&f.height>0||d&&f&&i(f)){n===null&&(n=new wV(t));const g=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,g),l.addEventListener("dispose",a),g.texture}else return null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function a(l){const c=l.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:s}}function E5e(t){const e={};function n(r){if(e[r]!==void 0)return e[r];let i;switch(r){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=t.getExtension(r)}return e[r]=i,i}return{has:function(r){return n(r)!==null},init:function(r){r.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(r){const i=n(r);return i===null&&console.warn("THREE.WebGLRenderer: "+r+" extension not supported."),i}}}function A5e(t,e,n,r){const i={},a=new WeakMap;function s(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const x in g.attributes)e.remove(g.attributes[x]);for(const x in g.morphAttributes){const v=g.morphAttributes[x];for(let y=0,b=v.length;y<b;y++)e.remove(v[y])}g.removeEventListener("dispose",s),delete i[g.id];const p=a.get(g);p&&(e.remove(p),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function l(f,g){return i[g.id]===!0||(g.addEventListener("dispose",s),i[g.id]=!0,n.memory.geometries++),g}function c(f){const g=f.attributes;for(const x in g)e.update(g[x],t.ARRAY_BUFFER);const p=f.morphAttributes;for(const x in p){const v=p[x];for(let y=0,b=v.length;y<b;y++)e.update(v[y],t.ARRAY_BUFFER)}}function u(f){const g=[],p=f.index,x=f.attributes.position;let v=0;if(p!==null){const E=p.array;v=p.version;for(let w=0,A=E.length;w<A;w+=3){const T=E[w+0],C=E[w+1],N=E[w+2];g.push(T,C,C,N,N,T)}}else if(x!==void 0){const E=x.array;v=x.version;for(let w=0,A=E.length/3-1;w<A;w+=3){const T=w+0,C=w+1,N=w+2;g.push(T,C,C,N,N,T)}}else return;const y=new(hQ(g)?vQ:yQ)(g,1);y.version=v;const b=a.get(f);b&&e.remove(b),a.set(f,y)}function d(f){const g=a.get(f);if(g){const p=f.index;p!==null&&g.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function T5e(t,e,n,r){const i=r.isWebGL2;let a;function s(p){a=p}let l,c;function u(p){l=p.type,c=p.bytesPerElement}function d(p,x){t.drawElements(a,x,l,p*c),n.update(x,a,1)}function f(p,x,v){if(v===0)return;let y,b;if(i)y=t,b="drawElementsInstanced";else if(y=e.get("ANGLE_instanced_arrays"),b="drawElementsInstancedANGLE",y===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}y[b](a,x,l,p*c,v),n.update(x,a,v)}function g(p,x,v){if(v===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let b=0;b<v;b++)this.render(p[b]/c,x[b]);else{y.multiDrawElementsWEBGL(a,x,0,l,p,0,v);let b=0;for(let E=0;E<v;E++)b+=x[E];n.update(b,a,1)}}this.setMode=s,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=g}function N5e(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,s,l){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",s);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function C5e(t,e){return t[0]-e[0]}function k5e(t,e){return Math.abs(e[1])-Math.abs(t[1])}function P5e(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,s=new cr,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,f){const g=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,v=x!==void 0?x.length:0;let y=a.get(d);if(y===void 0||y.count!==v){let q=function(){K.dispose(),a.delete(d),d.removeEventListener("dispose",q)};var p=q;y!==void 0&&y.texture.dispose();const w=d.morphAttributes.position!==void 0,A=d.morphAttributes.normal!==void 0,T=d.morphAttributes.color!==void 0,C=d.morphAttributes.position||[],N=d.morphAttributes.normal||[],O=d.morphAttributes.color||[];let k=0;w===!0&&(k=1),A===!0&&(k=2),T===!0&&(k=3);let j=d.attributes.position.count*k,B=1;j>e.maxTextureSize&&(B=Math.ceil(j/e.maxTextureSize),j=e.maxTextureSize);const L=new Float32Array(j*B*4*v),K=new pQ(L,j,B,v);K.type=Cc,K.needsUpdate=!0;const R=k*4;for(let W=0;W<v;W++){const $=C[W],J=N[W],ee=O[W],Q=j*B*4*W;for(let z=0;z<$.count;z++){const V=z*R;w===!0&&(s.fromBufferAttribute($,z),L[Q+V+0]=s.x,L[Q+V+1]=s.y,L[Q+V+2]=s.z,L[Q+V+3]=0),A===!0&&(s.fromBufferAttribute(J,z),L[Q+V+4]=s.x,L[Q+V+5]=s.y,L[Q+V+6]=s.z,L[Q+V+7]=0),T===!0&&(s.fromBufferAttribute(ee,z),L[Q+V+8]=s.x,L[Q+V+9]=s.y,L[Q+V+10]=s.z,L[Q+V+11]=ee.itemSize===4?s.w:1)}}y={count:v,texture:K,size:new tn(j,B)},a.set(d,y),d.addEventListener("dispose",q)}let b=0;for(let w=0;w<g.length;w++)b+=g[w];const E=d.morphTargetsRelative?1:1-b;f.getUniforms().setValue(t,"morphTargetBaseInfluence",E),f.getUniforms().setValue(t,"morphTargetInfluences",g),f.getUniforms().setValue(t,"morphTargetsTexture",y.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",y.size)}else{const x=g===void 0?0:g.length;let v=r[d.id];if(v===void 0||v.length!==x){v=[];for(let A=0;A<x;A++)v[A]=[A,0];r[d.id]=v}for(let A=0;A<x;A++){const T=v[A];T[0]=A,T[1]=g[A]}v.sort(k5e);for(let A=0;A<8;A++)A<x&&v[A][1]?(l[A][0]=v[A][0],l[A][1]=v[A][1]):(l[A][0]=Number.MAX_SAFE_INTEGER,l[A][1]=0);l.sort(C5e);const y=d.morphAttributes.position,b=d.morphAttributes.normal;let E=0;for(let A=0;A<8;A++){const T=l[A],C=T[0],N=T[1];C!==Number.MAX_SAFE_INTEGER&&N?(y&&d.getAttribute("morphTarget"+A)!==y[C]&&d.setAttribute("morphTarget"+A,y[C]),b&&d.getAttribute("morphNormal"+A)!==b[C]&&d.setAttribute("morphNormal"+A,b[C]),i[A]=N,E+=N):(y&&d.hasAttribute("morphTarget"+A)===!0&&d.deleteAttribute("morphTarget"+A),b&&d.hasAttribute("morphNormal"+A)===!0&&d.deleteAttribute("morphNormal"+A),i[A]=0)}const w=d.morphTargetsRelative?1:1-E;f.getUniforms().setValue(t,"morphTargetBaseInfluence",w),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function j5e(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const g=c.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function s(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:s}}class EQ extends rs{constructor(e,n,r,i,a,s,l,c,u,d){if(d=d!==void 0?d:Hh,d!==Hh&&d!==Gp)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===Hh&&(r=td),r===void 0&&d===Gp&&(r=Bh),super(null,i,a,s,l,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=l!==void 0?l:ra,this.minFilter=c!==void 0?c:ra,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}}const AQ=new rs,TQ=new EQ(1,1);TQ.compareFunction=uQ;const NQ=new pQ,CQ=new gLe,kQ=new SQ,AV=[],TV=[],NV=new Float32Array(16),CV=new Float32Array(9),kV=new Float32Array(4);function Sg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=AV[i];if(a===void 0&&(a=new Float32Array(i),AV[i]=a),e!==0){r.toArray(a,0);for(let s=1,l=0;s!==e;++s)l+=n,t[s].toArray(a,l)}return a}function Si(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function Mi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function oE(t,e){let n=TV[e];n===void 0&&(n=new Int32Array(e),TV[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function R5e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function D5e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Si(n,e))return;t.uniform2fv(this.addr,e),Mi(n,e)}}function O5e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(Si(n,e))return;t.uniform3fv(this.addr,e),Mi(n,e)}}function L5e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Si(n,e))return;t.uniform4fv(this.addr,e),Mi(n,e)}}function I5e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Si(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Mi(n,e)}else{if(Si(n,r))return;kV.set(r),t.uniformMatrix2fv(this.addr,!1,kV),Mi(n,r)}}function F5e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Si(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Mi(n,e)}else{if(Si(n,r))return;CV.set(r),t.uniformMatrix3fv(this.addr,!1,CV),Mi(n,r)}}function U5e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Si(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Mi(n,e)}else{if(Si(n,r))return;NV.set(r),t.uniformMatrix4fv(this.addr,!1,NV),Mi(n,r)}}function z5e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function B5e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Si(n,e))return;t.uniform2iv(this.addr,e),Mi(n,e)}}function H5e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Si(n,e))return;t.uniform3iv(this.addr,e),Mi(n,e)}}function $5e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Si(n,e))return;t.uniform4iv(this.addr,e),Mi(n,e)}}function V5e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function G5e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Si(n,e))return;t.uniform2uiv(this.addr,e),Mi(n,e)}}function W5e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Si(n,e))return;t.uniform3uiv(this.addr,e),Mi(n,e)}}function q5e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Si(n,e))return;t.uniform4uiv(this.addr,e),Mi(n,e)}}function K5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);const a=this.type===t.SAMPLER_2D_SHADOW?TQ:AQ;n.setTexture2D(e||a,i)}function X5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||CQ,i)}function Y5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||kQ,i)}function Z5e(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||NQ,i)}function Q5e(t){switch(t){case 5126:return R5e;case 35664:return D5e;case 35665:return O5e;case 35666:return L5e;case 35674:return I5e;case 35675:return F5e;case 35676:return U5e;case 5124:case 35670:return z5e;case 35667:case 35671:return B5e;case 35668:case 35672:return H5e;case 35669:case 35673:return $5e;case 5125:return V5e;case 36294:return G5e;case 36295:return W5e;case 36296:return q5e;case 35678:case 36198:case 36298:case 36306:case 35682:return K5e;case 35679:case 36299:case 36307:return X5e;case 35680:case 36300:case 36308:case 36293:return Y5e;case 36289:case 36303:case 36311:case 36292:return Z5e}}function J5e(t,e){t.uniform1fv(this.addr,e)}function eFe(t,e){const n=Sg(e,this.size,2);t.uniform2fv(this.addr,n)}function tFe(t,e){const n=Sg(e,this.size,3);t.uniform3fv(this.addr,n)}function nFe(t,e){const n=Sg(e,this.size,4);t.uniform4fv(this.addr,n)}function rFe(t,e){const n=Sg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function iFe(t,e){const n=Sg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function aFe(t,e){const n=Sg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function sFe(t,e){t.uniform1iv(this.addr,e)}function oFe(t,e){t.uniform2iv(this.addr,e)}function lFe(t,e){t.uniform3iv(this.addr,e)}function cFe(t,e){t.uniform4iv(this.addr,e)}function uFe(t,e){t.uniform1uiv(this.addr,e)}function dFe(t,e){t.uniform2uiv(this.addr,e)}function hFe(t,e){t.uniform3uiv(this.addr,e)}function fFe(t,e){t.uniform4uiv(this.addr,e)}function mFe(t,e,n){const r=this.cache,i=e.length,a=oE(n,i);Si(r,a)||(t.uniform1iv(this.addr,a),Mi(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||AQ,a[s])}function pFe(t,e,n){const r=this.cache,i=e.length,a=oE(n,i);Si(r,a)||(t.uniform1iv(this.addr,a),Mi(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||CQ,a[s])}function gFe(t,e,n){const r=this.cache,i=e.length,a=oE(n,i);Si(r,a)||(t.uniform1iv(this.addr,a),Mi(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||kQ,a[s])}function xFe(t,e,n){const r=this.cache,i=e.length,a=oE(n,i);Si(r,a)||(t.uniform1iv(this.addr,a),Mi(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||NQ,a[s])}function bFe(t){switch(t){case 5126:return J5e;case 35664:return eFe;case 35665:return tFe;case 35666:return nFe;case 35674:return rFe;case 35675:return iFe;case 35676:return aFe;case 5124:case 35670:return sFe;case 35667:case 35671:return oFe;case 35668:case 35672:return lFe;case 35669:case 35673:return cFe;case 5125:return uFe;case 36294:return dFe;case 36295:return hFe;case 36296:return fFe;case 35678:case 36198:case 36298:case 36306:case 35682:return mFe;case 35679:case 36299:case 36307:return pFe;case 35680:case 36300:case 36308:case 36293:return gFe;case 36289:case 36303:case 36311:case 36292:return xFe}}class yFe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=Q5e(n.type)}}class vFe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=bFe(n.type)}}class _Fe{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,s=i.length;a!==s;++a){const l=i[a];l.setValue(e,n[l.id],r)}}}const UC=/(\w+)(\])?(\[|\.)?/g;function PV(t,e){t.seq.push(e),t.map[e.id]=e}function wFe(t,e,n){const r=t.name,i=r.length;for(UC.lastIndex=0;;){const a=UC.exec(r),s=UC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&s+2===i){PV(n,u===void 0?new yFe(l,t,e):new vFe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new _Fe(l),PV(n,f)),n=f}}}class N1{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),s=e.getUniformLocation(n,a.name);wFe(a,s,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,s=n.length;a!==s;++a){const l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const s=e[i];s.id in n&&r.push(s)}return r}}function jV(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const SFe=37297;let MFe=0;function EFe(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=i;s<a;s++){const l=s+1;r.push(`${l===e?">":" "} ${l}: ${n[s]}`)}return r.join(`
- `)}function AFe(t){const e=or.getPrimaries(or.workingColorSpace),n=or.getPrimaries(t);let r;switch(e===n?r="":e===Zw&&n===Yw?r="LinearDisplayP3ToLinearSRGB":e===Yw&&n===Zw&&(r="LinearSRGBToLinearDisplayP3"),t){case Yc:case aE:return[r,"LinearTransferOETF"];case ia:case BO:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function RV(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const a=/ERROR: 0:(\d+)/.exec(i);if(a){const s=parseInt(a[1]);return n.toUpperCase()+`
- `+i+`
- `+EFe(t.getShaderSource(e),s)}else return i}function TFe(t,e){const n=AFe(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function NFe(t,e){let n;switch(e){case TOe:n="Linear";break;case NOe:n="Reinhard";break;case COe:n="OptimizedCineon";break;case kOe:n="ACESFilmic";break;case POe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function CFe(t){return[t.extensionDerivatives||t.envMapCubeUVHeight||t.bumpMap||t.normalMapTangentSpace||t.clearcoatNormalMap||t.flatShading||t.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap||t.transmission)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Zx).join(`
- `)}function kFe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function PFe(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),s=a.name;let l=1;a.type===t.FLOAT_MAT2&&(l=2),a.type===t.FLOAT_MAT3&&(l=3),a.type===t.FLOAT_MAT4&&(l=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:l}}return n}function Zx(t){return t!==""}function DV(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function OV(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const jFe=/^[ \t]*#include +<([\w\d./]+)>/gm;function sj(t){return t.replace(jFe,DFe)}const RFe=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function DFe(t,e){let n=hn[e];if(n===void 0){const r=RFe.get(e);if(r!==void 0)n=hn[r],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return sj(n)}const OFe=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function LV(t){return t.replace(OFe,LFe)}function LFe(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function IV(t){let e="precision "+t.precision+` float;
- precision `+t.precision+" int;";return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function IFe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===JZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===tOe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===gc&&(e="SHADOWMAP_TYPE_VSM"),e}function FFe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case $p:case Vp:e="ENVMAP_TYPE_CUBE";break;case iE:e="ENVMAP_TYPE_CUBE_UV";break}return e}function UFe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Vp:e="ENVMAP_MODE_REFRACTION";break}return e}function zFe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case UO:e="ENVMAP_BLENDING_MULTIPLY";break;case EOe:e="ENVMAP_BLENDING_MIX";break;case AOe:e="ENVMAP_BLENDING_ADD";break}return e}function BFe(t){const e=t.envMapCubeUVHeight;if(e===null)return null;const n=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:r,maxMip:n}}function HFe(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,l=n.fragmentShader;const c=IFe(n),u=FFe(n),d=UFe(n),f=zFe(n),g=BFe(n),p=n.isWebGL2?"":CFe(n),x=kFe(a),v=i.createProgram();let y,b,E=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Zx).join(`
- `),y.length>0&&(y+=`
- `),b=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(Zx).join(`
- `),b.length>0&&(b+=`
- `)):(y=[IV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(Zx).join(`
- `),b=[p,IV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ud?"#define TONE_MAPPING":"",n.toneMapping!==ud?hn.tonemapping_pars_fragment:"",n.toneMapping!==ud?NFe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",hn.colorspace_pars_fragment,TFe("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Zx).join(`
- `)),s=sj(s),s=DV(s,n),s=OV(s,n),l=sj(l),l=DV(l,n),l=OV(l,n),s=LV(s),l=LV(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(E=`#version 300 es
- `,y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+y,b=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===tV?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===tV?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
- `)+`
- `+b);const w=E+y+s,A=E+b+l,T=jV(i,i.VERTEX_SHADER,w),C=jV(i,i.FRAGMENT_SHADER,A);i.attachShader(v,T),i.attachShader(v,C),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function N(B){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(v).trim(),K=i.getShaderInfoLog(T).trim(),R=i.getShaderInfoLog(C).trim();let q=!0,W=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(q=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,T,C);else{const $=RV(i,T,"vertex"),J=RV(i,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
- Program Info Log: `+L+`
- `+$+`
- `+J)}else L!==""?console.warn("THREE.WebGLProgram: Program Info Log:",L):(K===""||R==="")&&(W=!1);W&&(B.diagnostics={runnable:q,programLog:L,vertexShader:{log:K,prefix:y},fragmentShader:{log:R,prefix:b}})}i.deleteShader(T),i.deleteShader(C),O=new N1(i,v),k=PFe(i,v)}let O;this.getUniforms=function(){return O===void 0&&N(this),O};let k;this.getAttributes=function(){return k===void 0&&N(this),k};let j=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return j===!1&&(j=i.getProgramParameter(v,SFe)),j},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=MFe++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=T,this.fragmentShader=C,this}let $Fe=0;class VFe{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),s=this._getShaderCacheForMaterial(e);return s.has(i)===!1&&(s.add(i),i.usedTimes++),s.has(a)===!1&&(s.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new GFe(e),n.set(e,r)),r}}class GFe{constructor(e){this.id=$Fe++,this.code=e,this.usedTimes=0}}function WFe(t,e,n,r,i,a,s){const l=new gQ,c=new VFe,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,g=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(k){return k===0?"uv":`uv${k}`}function y(k,j,B,L,K){const R=L.fog,q=K.geometry,W=k.isMeshStandardMaterial?L.environment:null,$=(k.isMeshStandardMaterial?n:e).get(k.envMap||W),J=$&&$.mapping===iE?$.image.height:null,ee=x[k.type];k.precision!==null&&(p=i.getMaxPrecision(k.precision),p!==k.precision&&console.warn("THREE.WebGLProgram.getParameters:",k.precision,"not supported, using",p,"instead."));const Q=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,z=Q!==void 0?Q.length:0;let V=0;q.morphAttributes.position!==void 0&&(V=1),q.morphAttributes.normal!==void 0&&(V=2),q.morphAttributes.color!==void 0&&(V=3);let X,te,ie,le;if(ee){const Ut=Qa[ee];X=Ut.vertexShader,te=Ut.fragmentShader}else X=k.vertexShader,te=k.fragmentShader,c.update(k),ie=c.getVertexShaderID(k),le=c.getFragmentShaderID(k);const ge=t.getRenderTarget(),Ee=K.isInstancedMesh===!0,pe=K.isBatchedMesh===!0,de=!!k.map,Re=!!k.matcap,fe=!!$,Fe=!!k.aoMap,U=!!k.lightMap,H=!!k.bumpMap,re=!!k.normalMap,G=!!k.displacementMap,Z=!!k.emissiveMap,oe=!!k.metalnessMap,be=!!k.roughnessMap,Te=k.anisotropy>0,Me=k.clearcoat>0,F=k.iridescence>0,I=k.sheen>0,ne=k.transmission>0,ve=Te&&!!k.anisotropyMap,Se=Me&&!!k.clearcoatMap,ye=Me&&!!k.clearcoatNormalMap,Ke=Me&&!!k.clearcoatRoughnessMap,We=F&&!!k.iridescenceMap,qe=F&&!!k.iridescenceThicknessMap,ut=I&&!!k.sheenColorMap,ue=I&&!!k.sheenRoughnessMap,se=!!k.specularMap,Ve=!!k.specularColorMap,Be=!!k.specularIntensityMap,Ze=ne&&!!k.transmissionMap,ht=ne&&!!k.thicknessMap,me=!!k.gradientMap,nt=!!k.alphaMap,xe=k.alphaTest>0,He=!!k.alphaHash,Pe=!!k.extensions,we=!!q.attributes.uv1,Ae=!!q.attributes.uv2,lt=!!q.attributes.uv3;let _t=ud;return k.toneMapped&&(ge===null||ge.isXRRenderTarget===!0)&&(_t=t.toneMapping),{isWebGL2:d,shaderID:ee,shaderType:k.type,shaderName:k.name,vertexShader:X,fragmentShader:te,defines:k.defines,customVertexShaderID:ie,customFragmentShaderID:le,isRawShaderMaterial:k.isRawShaderMaterial===!0,glslVersion:k.glslVersion,precision:p,batching:pe,instancing:Ee,instancingColor:Ee&&K.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:ge===null?t.outputColorSpace:ge.isXRRenderTarget===!0?ge.texture.colorSpace:Yc,map:de,matcap:Re,envMap:fe,envMapMode:fe&&$.mapping,envMapCubeUVHeight:J,aoMap:Fe,lightMap:U,bumpMap:H,normalMap:re,displacementMap:g&&G,emissiveMap:Z,normalMapObjectSpace:re&&k.normalMapType===$Oe,normalMapTangentSpace:re&&k.normalMapType===cQ,metalnessMap:oe,roughnessMap:be,anisotropy:Te,anisotropyMap:ve,clearcoat:Me,clearcoatMap:Se,clearcoatNormalMap:ye,clearcoatRoughnessMap:Ke,iridescence:F,iridescenceMap:We,iridescenceThicknessMap:qe,sheen:I,sheenColorMap:ut,sheenRoughnessMap:ue,specularMap:se,specularColorMap:Ve,specularIntensityMap:Be,transmission:ne,transmissionMap:Ze,thicknessMap:ht,gradientMap:me,opaque:k.transparent===!1&&k.blending===bp,alphaMap:nt,alphaTest:xe,alphaHash:He,combine:k.combine,mapUv:de&&v(k.map.channel),aoMapUv:Fe&&v(k.aoMap.channel),lightMapUv:U&&v(k.lightMap.channel),bumpMapUv:H&&v(k.bumpMap.channel),normalMapUv:re&&v(k.normalMap.channel),displacementMapUv:G&&v(k.displacementMap.channel),emissiveMapUv:Z&&v(k.emissiveMap.channel),metalnessMapUv:oe&&v(k.metalnessMap.channel),roughnessMapUv:be&&v(k.roughnessMap.channel),anisotropyMapUv:ve&&v(k.anisotropyMap.channel),clearcoatMapUv:Se&&v(k.clearcoatMap.channel),clearcoatNormalMapUv:ye&&v(k.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ke&&v(k.clearcoatRoughnessMap.channel),iridescenceMapUv:We&&v(k.iridescenceMap.channel),iridescenceThicknessMapUv:qe&&v(k.iridescenceThicknessMap.channel),sheenColorMapUv:ut&&v(k.sheenColorMap.channel),sheenRoughnessMapUv:ue&&v(k.sheenRoughnessMap.channel),specularMapUv:se&&v(k.specularMap.channel),specularColorMapUv:Ve&&v(k.specularColorMap.channel),specularIntensityMapUv:Be&&v(k.specularIntensityMap.channel),transmissionMapUv:Ze&&v(k.transmissionMap.channel),thicknessMapUv:ht&&v(k.thicknessMap.channel),alphaMapUv:nt&&v(k.alphaMap.channel),vertexTangents:!!q.attributes.tangent&&(re||Te),vertexColors:k.vertexColors,vertexAlphas:k.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,vertexUv1s:we,vertexUv2s:Ae,vertexUv3s:lt,pointsUvs:K.isPoints===!0&&!!q.attributes.uv&&(de||nt),fog:!!R,useFog:k.fog===!0,fogExp2:R&&R.isFogExp2,flatShading:k.flatShading===!0,sizeAttenuation:k.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:K.isSkinnedMesh===!0,morphTargets:q.morphAttributes.position!==void 0,morphNormals:q.morphAttributes.normal!==void 0,morphColors:q.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:V,numDirLights:j.directional.length,numPointLights:j.point.length,numSpotLights:j.spot.length,numSpotLightMaps:j.spotLightMap.length,numRectAreaLights:j.rectArea.length,numHemiLights:j.hemi.length,numDirLightShadows:j.directionalShadowMap.length,numPointLightShadows:j.pointShadowMap.length,numSpotLightShadows:j.spotShadowMap.length,numSpotLightShadowsWithMaps:j.numSpotLightShadowsWithMaps,numLightProbes:j.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:k.dithering,shadowMapEnabled:t.shadowMap.enabled&&B.length>0,shadowMapType:t.shadowMap.type,toneMapping:_t,useLegacyLights:t._useLegacyLights,decodeVideoTexture:de&&k.map.isVideoTexture===!0&&or.getTransfer(k.map.colorSpace)===wr,premultipliedAlpha:k.premultipliedAlpha,doubleSided:k.side===wc,flipSided:k.side===ns,useDepthPacking:k.depthPacking>=0,depthPacking:k.depthPacking||0,index0AttributeName:k.index0AttributeName,extensionDerivatives:Pe&&k.extensions.derivatives===!0,extensionFragDepth:Pe&&k.extensions.fragDepth===!0,extensionDrawBuffers:Pe&&k.extensions.drawBuffers===!0,extensionShaderTextureLOD:Pe&&k.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:k.customProgramCacheKey()}}function b(k){const j=[];if(k.shaderID?j.push(k.shaderID):(j.push(k.customVertexShaderID),j.push(k.customFragmentShaderID)),k.defines!==void 0)for(const B in k.defines)j.push(B),j.push(k.defines[B]);return k.isRawShaderMaterial===!1&&(E(j,k),w(j,k),j.push(t.outputColorSpace)),j.push(k.customProgramCacheKey),j.join()}function E(k,j){k.push(j.precision),k.push(j.outputColorSpace),k.push(j.envMapMode),k.push(j.envMapCubeUVHeight),k.push(j.mapUv),k.push(j.alphaMapUv),k.push(j.lightMapUv),k.push(j.aoMapUv),k.push(j.bumpMapUv),k.push(j.normalMapUv),k.push(j.displacementMapUv),k.push(j.emissiveMapUv),k.push(j.metalnessMapUv),k.push(j.roughnessMapUv),k.push(j.anisotropyMapUv),k.push(j.clearcoatMapUv),k.push(j.clearcoatNormalMapUv),k.push(j.clearcoatRoughnessMapUv),k.push(j.iridescenceMapUv),k.push(j.iridescenceThicknessMapUv),k.push(j.sheenColorMapUv),k.push(j.sheenRoughnessMapUv),k.push(j.specularMapUv),k.push(j.specularColorMapUv),k.push(j.specularIntensityMapUv),k.push(j.transmissionMapUv),k.push(j.thicknessMapUv),k.push(j.combine),k.push(j.fogExp2),k.push(j.sizeAttenuation),k.push(j.morphTargetsCount),k.push(j.morphAttributeCount),k.push(j.numDirLights),k.push(j.numPointLights),k.push(j.numSpotLights),k.push(j.numSpotLightMaps),k.push(j.numHemiLights),k.push(j.numRectAreaLights),k.push(j.numDirLightShadows),k.push(j.numPointLightShadows),k.push(j.numSpotLightShadows),k.push(j.numSpotLightShadowsWithMaps),k.push(j.numLightProbes),k.push(j.shadowMapType),k.push(j.toneMapping),k.push(j.numClippingPlanes),k.push(j.numClipIntersection),k.push(j.depthPacking)}function w(k,j){l.disableAll(),j.isWebGL2&&l.enable(0),j.supportsVertexTextures&&l.enable(1),j.instancing&&l.enable(2),j.instancingColor&&l.enable(3),j.matcap&&l.enable(4),j.envMap&&l.enable(5),j.normalMapObjectSpace&&l.enable(6),j.normalMapTangentSpace&&l.enable(7),j.clearcoat&&l.enable(8),j.iridescence&&l.enable(9),j.alphaTest&&l.enable(10),j.vertexColors&&l.enable(11),j.vertexAlphas&&l.enable(12),j.vertexUv1s&&l.enable(13),j.vertexUv2s&&l.enable(14),j.vertexUv3s&&l.enable(15),j.vertexTangents&&l.enable(16),j.anisotropy&&l.enable(17),j.alphaHash&&l.enable(18),j.batching&&l.enable(19),k.push(l.mask),l.disableAll(),j.fog&&l.enable(0),j.useFog&&l.enable(1),j.flatShading&&l.enable(2),j.logarithmicDepthBuffer&&l.enable(3),j.skinning&&l.enable(4),j.morphTargets&&l.enable(5),j.morphNormals&&l.enable(6),j.morphColors&&l.enable(7),j.premultipliedAlpha&&l.enable(8),j.shadowMapEnabled&&l.enable(9),j.useLegacyLights&&l.enable(10),j.doubleSided&&l.enable(11),j.flipSided&&l.enable(12),j.useDepthPacking&&l.enable(13),j.dithering&&l.enable(14),j.transmission&&l.enable(15),j.sheen&&l.enable(16),j.opaque&&l.enable(17),j.pointsUvs&&l.enable(18),j.decodeVideoTexture&&l.enable(19),k.push(l.mask)}function A(k){const j=x[k.type];let B;if(j){const L=Qa[j];B=VO.clone(L.uniforms)}else B=k.uniforms;return B}function T(k,j){let B;for(let L=0,K=u.length;L<K;L++){const R=u[L];if(R.cacheKey===j){B=R,++B.usedTimes;break}}return B===void 0&&(B=new HFe(t,j,k,a),u.push(B)),B}function C(k){if(--k.usedTimes===0){const j=u.indexOf(k);u[j]=u[u.length-1],u.pop(),k.destroy()}}function N(k){c.remove(k)}function O(){c.dispose()}return{getParameters:y,getProgramCacheKey:b,getUniforms:A,acquireProgram:T,releaseProgram:C,releaseShaderCache:N,programs:u,dispose:O}}function qFe(){let t=new WeakMap;function e(a){let s=t.get(a);return s===void 0&&(s={},t.set(a,s)),s}function n(a){t.delete(a)}function r(a,s,l){t.get(a)[s]=l}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function KFe(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function FV(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function UV(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function s(f,g,p,x,v,y){let b=t[e];return b===void 0?(b={id:f.id,object:f,geometry:g,material:p,groupOrder:x,renderOrder:f.renderOrder,z:v,group:y},t[e]=b):(b.id=f.id,b.object=f,b.geometry=g,b.material=p,b.groupOrder=x,b.renderOrder=f.renderOrder,b.z=v,b.group=y),e++,b}function l(f,g,p,x,v,y){const b=s(f,g,p,x,v,y);p.transmission>0?r.push(b):p.transparent===!0?i.push(b):n.push(b)}function c(f,g,p,x,v,y){const b=s(f,g,p,x,v,y);p.transmission>0?r.unshift(b):p.transparent===!0?i.unshift(b):n.unshift(b)}function u(f,g){n.length>1&&n.sort(f||KFe),r.length>1&&r.sort(g||FV),i.length>1&&i.sort(g||FV)}function d(){for(let f=e,g=t.length;f<g;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function XFe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new UV,t.set(r,[s])):i>=a.length?(s=new UV,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function YFe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Oe,color:new Kt};break;case"SpotLight":n={position:new Oe,direction:new Oe,color:new Kt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Oe,color:new Kt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Oe,skyColor:new Kt,groundColor:new Kt};break;case"RectAreaLight":n={color:new Kt,position:new Oe,halfWidth:new Oe,halfHeight:new Oe};break}return t[e.id]=n,n}}}function ZFe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let QFe=0;function JFe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function eUe(t,e){const n=new YFe,r=ZFe(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let d=0;d<9;d++)i.probe.push(new Oe);const a=new Oe,s=new yr,l=new yr;function c(d,f){let g=0,p=0,x=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let v=0,y=0,b=0,E=0,w=0,A=0,T=0,C=0,N=0,O=0,k=0;d.sort(JFe);const j=f===!0?Math.PI:1;for(let L=0,K=d.length;L<K;L++){const R=d[L],q=R.color,W=R.intensity,$=R.distance,J=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)g+=q.r*W*j,p+=q.g*W*j,x+=q.b*W*j;else if(R.isLightProbe){for(let ee=0;ee<9;ee++)i.probe[ee].addScaledVector(R.sh.coefficients[ee],W);k++}else if(R.isDirectionalLight){const ee=n.get(R);if(ee.color.copy(R.color).multiplyScalar(R.intensity*j),R.castShadow){const Q=R.shadow,z=r.get(R);z.shadowBias=Q.bias,z.shadowNormalBias=Q.normalBias,z.shadowRadius=Q.radius,z.shadowMapSize=Q.mapSize,i.directionalShadow[v]=z,i.directionalShadowMap[v]=J,i.directionalShadowMatrix[v]=R.shadow.matrix,A++}i.directional[v]=ee,v++}else if(R.isSpotLight){const ee=n.get(R);ee.position.setFromMatrixPosition(R.matrixWorld),ee.color.copy(q).multiplyScalar(W*j),ee.distance=$,ee.coneCos=Math.cos(R.angle),ee.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),ee.decay=R.decay,i.spot[b]=ee;const Q=R.shadow;if(R.map&&(i.spotLightMap[N]=R.map,N++,Q.updateMatrices(R),R.castShadow&&O++),i.spotLightMatrix[b]=Q.matrix,R.castShadow){const z=r.get(R);z.shadowBias=Q.bias,z.shadowNormalBias=Q.normalBias,z.shadowRadius=Q.radius,z.shadowMapSize=Q.mapSize,i.spotShadow[b]=z,i.spotShadowMap[b]=J,C++}b++}else if(R.isRectAreaLight){const ee=n.get(R);ee.color.copy(q).multiplyScalar(W),ee.halfWidth.set(R.width*.5,0,0),ee.halfHeight.set(0,R.height*.5,0),i.rectArea[E]=ee,E++}else if(R.isPointLight){const ee=n.get(R);if(ee.color.copy(R.color).multiplyScalar(R.intensity*j),ee.distance=R.distance,ee.decay=R.decay,R.castShadow){const Q=R.shadow,z=r.get(R);z.shadowBias=Q.bias,z.shadowNormalBias=Q.normalBias,z.shadowRadius=Q.radius,z.shadowMapSize=Q.mapSize,z.shadowCameraNear=Q.camera.near,z.shadowCameraFar=Q.camera.far,i.pointShadow[y]=z,i.pointShadowMap[y]=J,i.pointShadowMatrix[y]=R.shadow.matrix,T++}i.point[y]=ee,y++}else if(R.isHemisphereLight){const ee=n.get(R);ee.skyColor.copy(R.color).multiplyScalar(W*j),ee.groundColor.copy(R.groundColor).multiplyScalar(W*j),i.hemi[w]=ee,w++}}E>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Nt.LTC_FLOAT_1,i.rectAreaLTC2=Nt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Nt.LTC_HALF_1,i.rectAreaLTC2=Nt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=g,i.ambient[1]=p,i.ambient[2]=x;const B=i.hash;(B.directionalLength!==v||B.pointLength!==y||B.spotLength!==b||B.rectAreaLength!==E||B.hemiLength!==w||B.numDirectionalShadows!==A||B.numPointShadows!==T||B.numSpotShadows!==C||B.numSpotMaps!==N||B.numLightProbes!==k)&&(i.directional.length=v,i.spot.length=b,i.rectArea.length=E,i.point.length=y,i.hemi.length=w,i.directionalShadow.length=A,i.directionalShadowMap.length=A,i.pointShadow.length=T,i.pointShadowMap.length=T,i.spotShadow.length=C,i.spotShadowMap.length=C,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=T,i.spotLightMatrix.length=C+N-O,i.spotLightMap.length=N,i.numSpotLightShadowsWithMaps=O,i.numLightProbes=k,B.directionalLength=v,B.pointLength=y,B.spotLength=b,B.rectAreaLength=E,B.hemiLength=w,B.numDirectionalShadows=A,B.numPointShadows=T,B.numSpotShadows=C,B.numSpotMaps=N,B.numLightProbes=k,i.version=QFe++)}function u(d,f){let g=0,p=0,x=0,v=0,y=0;const b=f.matrixWorldInverse;for(let E=0,w=d.length;E<w;E++){const A=d[E];if(A.isDirectionalLight){const T=i.directional[g];T.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(b),g++}else if(A.isSpotLight){const T=i.spot[x];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),T.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(b),x++}else if(A.isRectAreaLight){const T=i.rectArea[v];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),l.identity(),s.copy(A.matrixWorld),s.premultiply(b),l.extractRotation(s),T.halfWidth.set(A.width*.5,0,0),T.halfHeight.set(0,A.height*.5,0),T.halfWidth.applyMatrix4(l),T.halfHeight.applyMatrix4(l),v++}else if(A.isPointLight){const T=i.point[p];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(b),p++}else if(A.isHemisphereLight){const T=i.hemi[y];T.direction.setFromMatrixPosition(A.matrixWorld),T.direction.transformDirection(b),y++}}}return{setup:c,setupView:u,state:i}}function zV(t,e){const n=new eUe(t,e),r=[],i=[];function a(){r.length=0,i.length=0}function s(f){r.push(f)}function l(f){i.push(f)}function c(f){n.setup(r,f)}function u(f){n.setupView(r,f)}return{init:a,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:u,pushLight:s,pushShadow:l}}function tUe(t,e){let n=new WeakMap;function r(a,s=0){const l=n.get(a);let c;return l===void 0?(c=new zV(t,e),n.set(a,[c])):s>=l.length?(c=new zV(t,e),l.push(c)):c=l[s],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class nUe extends wg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=BOe,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class rUe extends wg{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const iUe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,aUe=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function sUe(t,e,n){let r=new sE;const i=new tn,a=new tn,s=new cr,l=new nUe({depthPacking:HOe}),c=new rUe,u={},d=n.maxTextureSize,f={[Ad]:ns,[ns]:Ad,[wc]:wc},g=new Td({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new tn},radius:{value:4}},vertexShader:iUe,fragmentShader:aUe}),p=g.clone();p.defines.HORIZONTAL_PASS=1;const x=new Sa;x.setAttribute("position",new Ps(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Uo(x,g),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=JZ;let b=this.type;this.render=function(T,C,N){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||T.length===0)return;const O=t.getRenderTarget(),k=t.getActiveCubeFace(),j=t.getActiveMipmapLevel(),B=t.state;B.setBlending(cd),B.buffers.color.setClear(1,1,1,1),B.buffers.depth.setTest(!0),B.setScissorTest(!1);const L=b!==gc&&this.type===gc,K=b===gc&&this.type!==gc;for(let R=0,q=T.length;R<q;R++){const W=T[R],$=W.shadow;if($===void 0){console.warn("THREE.WebGLShadowMap:",W,"has no shadow.");continue}if($.autoUpdate===!1&&$.needsUpdate===!1)continue;i.copy($.mapSize);const J=$.getFrameExtents();if(i.multiply(J),a.copy($.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/J.x),i.x=a.x*J.x,$.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/J.y),i.y=a.y*J.y,$.mapSize.y=a.y)),$.map===null||L===!0||K===!0){const Q=this.type!==gc?{minFilter:ra,magFilter:ra}:{};$.map!==null&&$.map.dispose(),$.map=new bf(i.x,i.y,Q),$.map.texture.name=W.name+".shadowMap",$.camera.updateProjectionMatrix()}t.setRenderTarget($.map),t.clear();const ee=$.getViewportCount();for(let Q=0;Q<ee;Q++){const z=$.getViewport(Q);s.set(a.x*z.x,a.y*z.y,a.x*z.z,a.y*z.w),B.viewport(s),$.updateMatrices(W,Q),r=$.getFrustum(),A(C,N,$.camera,W,this.type)}$.isPointLightShadow!==!0&&this.type===gc&&E($,N),$.needsUpdate=!1}b=this.type,y.needsUpdate=!1,t.setRenderTarget(O,k,j)};function E(T,C){const N=e.update(v);g.defines.VSM_SAMPLES!==T.blurSamples&&(g.defines.VSM_SAMPLES=T.blurSamples,p.defines.VSM_SAMPLES=T.blurSamples,g.needsUpdate=!0,p.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new bf(i.x,i.y)),g.uniforms.shadow_pass.value=T.map.texture,g.uniforms.resolution.value=T.mapSize,g.uniforms.radius.value=T.radius,t.setRenderTarget(T.mapPass),t.clear(),t.renderBufferDirect(C,null,N,g,v,null),p.uniforms.shadow_pass.value=T.mapPass.texture,p.uniforms.resolution.value=T.mapSize,p.uniforms.radius.value=T.radius,t.setRenderTarget(T.map),t.clear(),t.renderBufferDirect(C,null,N,p,v,null)}function w(T,C,N,O){let k=null;const j=N.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(j!==void 0)k=j;else if(k=N.isPointLight===!0?c:l,t.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0){const B=k.uuid,L=C.uuid;let K=u[B];K===void 0&&(K={},u[B]=K);let R=K[L];R===void 0&&(R=k.clone(),K[L]=R),k=R}if(k.visible=C.visible,k.wireframe=C.wireframe,O===gc?k.side=C.shadowSide!==null?C.shadowSide:C.side:k.side=C.shadowSide!==null?C.shadowSide:f[C.side],k.alphaMap=C.alphaMap,k.alphaTest=C.alphaTest,k.map=C.map,k.clipShadows=C.clipShadows,k.clippingPlanes=C.clippingPlanes,k.clipIntersection=C.clipIntersection,k.displacementMap=C.displacementMap,k.displacementScale=C.displacementScale,k.displacementBias=C.displacementBias,k.wireframeLinewidth=C.wireframeLinewidth,k.linewidth=C.linewidth,N.isPointLight===!0&&k.isMeshDistanceMaterial===!0){const B=t.properties.get(k);B.light=N}return k}function A(T,C,N,O,k){if(T.visible===!1)return;if(T.layers.test(C.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&k===gc)&&(!T.frustumCulled||r.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,T.matrixWorld);const L=e.update(T),K=T.material;if(Array.isArray(K)){const R=L.groups;for(let q=0,W=R.length;q<W;q++){const $=R[q],J=K[$.materialIndex];if(J&&J.visible){const ee=w(T,J,O,k);T.onBeforeShadow(t,T,C,N,L,ee,$),t.renderBufferDirect(N,null,L,ee,T,$),T.onAfterShadow(t,T,C,N,L,ee,$)}}}else if(K.visible){const R=w(T,K,O,k);T.onBeforeShadow(t,T,C,N,L,R,null),t.renderBufferDirect(N,null,L,R,T,null),T.onAfterShadow(t,T,C,N,L,R,null)}}const B=T.children;for(let L=0,K=B.length;L<K;L++)A(B[L],C,N,O,k)}}function oUe(t,e,n){const r=n.isWebGL2;function i(){let xe=!1;const He=new cr;let Pe=null;const we=new cr(0,0,0,0);return{setMask:function(Ae){Pe!==Ae&&!xe&&(t.colorMask(Ae,Ae,Ae,Ae),Pe=Ae)},setLocked:function(Ae){xe=Ae},setClear:function(Ae,lt,_t,Xe,Ut){Ut===!0&&(Ae*=Xe,lt*=Xe,_t*=Xe),He.set(Ae,lt,_t,Xe),we.equals(He)===!1&&(t.clearColor(Ae,lt,_t,Xe),we.copy(He))},reset:function(){xe=!1,Pe=null,we.set(-1,0,0,0)}}}function a(){let xe=!1,He=null,Pe=null,we=null;return{setTest:function(Ae){Ae?pe(t.DEPTH_TEST):de(t.DEPTH_TEST)},setMask:function(Ae){He!==Ae&&!xe&&(t.depthMask(Ae),He=Ae)},setFunc:function(Ae){if(Pe!==Ae){switch(Ae){case bOe:t.depthFunc(t.NEVER);break;case yOe:t.depthFunc(t.ALWAYS);break;case vOe:t.depthFunc(t.LESS);break;case Kw:t.depthFunc(t.LEQUAL);break;case _Oe:t.depthFunc(t.EQUAL);break;case wOe:t.depthFunc(t.GEQUAL);break;case SOe:t.depthFunc(t.GREATER);break;case MOe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Pe=Ae}},setLocked:function(Ae){xe=Ae},setClear:function(Ae){we!==Ae&&(t.clearDepth(Ae),we=Ae)},reset:function(){xe=!1,He=null,Pe=null,we=null}}}function s(){let xe=!1,He=null,Pe=null,we=null,Ae=null,lt=null,_t=null,Xe=null,Ut=null;return{setTest:function(Ct){xe||(Ct?pe(t.STENCIL_TEST):de(t.STENCIL_TEST))},setMask:function(Ct){He!==Ct&&!xe&&(t.stencilMask(Ct),He=Ct)},setFunc:function(Ct,$t,gn){(Pe!==Ct||we!==$t||Ae!==gn)&&(t.stencilFunc(Ct,$t,gn),Pe=Ct,we=$t,Ae=gn)},setOp:function(Ct,$t,gn){(lt!==Ct||_t!==$t||Xe!==gn)&&(t.stencilOp(Ct,$t,gn),lt=Ct,_t=$t,Xe=gn)},setLocked:function(Ct){xe=Ct},setClear:function(Ct){Ut!==Ct&&(t.clearStencil(Ct),Ut=Ct)},reset:function(){xe=!1,He=null,Pe=null,we=null,Ae=null,lt=null,_t=null,Xe=null,Ut=null}}}const l=new i,c=new a,u=new s,d=new WeakMap,f=new WeakMap;let g={},p={},x=new WeakMap,v=[],y=null,b=!1,E=null,w=null,A=null,T=null,C=null,N=null,O=null,k=new Kt(0,0,0),j=0,B=!1,L=null,K=null,R=null,q=null,W=null;const $=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let J=!1,ee=0;const Q=t.getParameter(t.VERSION);Q.indexOf("WebGL")!==-1?(ee=parseFloat(/^WebGL (\d)/.exec(Q)[1]),J=ee>=1):Q.indexOf("OpenGL ES")!==-1&&(ee=parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]),J=ee>=2);let z=null,V={};const X=t.getParameter(t.SCISSOR_BOX),te=t.getParameter(t.VIEWPORT),ie=new cr().fromArray(X),le=new cr().fromArray(te);function ge(xe,He,Pe,we){const Ae=new Uint8Array(4),lt=t.createTexture();t.bindTexture(xe,lt),t.texParameteri(xe,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(xe,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let _t=0;_t<Pe;_t++)r&&(xe===t.TEXTURE_3D||xe===t.TEXTURE_2D_ARRAY)?t.texImage3D(He,0,t.RGBA,1,1,we,0,t.RGBA,t.UNSIGNED_BYTE,Ae):t.texImage2D(He+_t,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ae);return lt}const Ee={};Ee[t.TEXTURE_2D]=ge(t.TEXTURE_2D,t.TEXTURE_2D,1),Ee[t.TEXTURE_CUBE_MAP]=ge(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ee[t.TEXTURE_2D_ARRAY]=ge(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ee[t.TEXTURE_3D]=ge(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),pe(t.DEPTH_TEST),c.setFunc(Kw),Z(!1),oe(w$),pe(t.CULL_FACE),re(cd);function pe(xe){g[xe]!==!0&&(t.enable(xe),g[xe]=!0)}function de(xe){g[xe]!==!1&&(t.disable(xe),g[xe]=!1)}function Re(xe,He){return p[xe]!==He?(t.bindFramebuffer(xe,He),p[xe]=He,r&&(xe===t.DRAW_FRAMEBUFFER&&(p[t.FRAMEBUFFER]=He),xe===t.FRAMEBUFFER&&(p[t.DRAW_FRAMEBUFFER]=He)),!0):!1}function fe(xe,He){let Pe=v,we=!1;if(xe)if(Pe=x.get(He),Pe===void 0&&(Pe=[],x.set(He,Pe)),xe.isWebGLMultipleRenderTargets){const Ae=xe.texture;if(Pe.length!==Ae.length||Pe[0]!==t.COLOR_ATTACHMENT0){for(let lt=0,_t=Ae.length;lt<_t;lt++)Pe[lt]=t.COLOR_ATTACHMENT0+lt;Pe.length=Ae.length,we=!0}}else Pe[0]!==t.COLOR_ATTACHMENT0&&(Pe[0]=t.COLOR_ATTACHMENT0,we=!0);else Pe[0]!==t.BACK&&(Pe[0]=t.BACK,we=!0);we&&(n.isWebGL2?t.drawBuffers(Pe):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Pe))}function Fe(xe){return y!==xe?(t.useProgram(xe),y=xe,!0):!1}const U={[_h]:t.FUNC_ADD,[rOe]:t.FUNC_SUBTRACT,[iOe]:t.FUNC_REVERSE_SUBTRACT};if(r)U[A$]=t.MIN,U[T$]=t.MAX;else{const xe=e.get("EXT_blend_minmax");xe!==null&&(U[A$]=xe.MIN_EXT,U[T$]=xe.MAX_EXT)}const H={[aOe]:t.ZERO,[sOe]:t.ONE,[oOe]:t.SRC_COLOR,[ZP]:t.SRC_ALPHA,[fOe]:t.SRC_ALPHA_SATURATE,[dOe]:t.DST_COLOR,[cOe]:t.DST_ALPHA,[lOe]:t.ONE_MINUS_SRC_COLOR,[QP]:t.ONE_MINUS_SRC_ALPHA,[hOe]:t.ONE_MINUS_DST_COLOR,[uOe]:t.ONE_MINUS_DST_ALPHA,[mOe]:t.CONSTANT_COLOR,[pOe]:t.ONE_MINUS_CONSTANT_COLOR,[gOe]:t.CONSTANT_ALPHA,[xOe]:t.ONE_MINUS_CONSTANT_ALPHA};function re(xe,He,Pe,we,Ae,lt,_t,Xe,Ut,Ct){if(xe===cd){b===!0&&(de(t.BLEND),b=!1);return}if(b===!1&&(pe(t.BLEND),b=!0),xe!==nOe){if(xe!==E||Ct!==B){if((w!==_h||C!==_h)&&(t.blendEquation(t.FUNC_ADD),w=_h,C=_h),Ct)switch(xe){case bp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case S$:t.blendFunc(t.ONE,t.ONE);break;case M$:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case E$:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",xe);break}else switch(xe){case bp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case S$:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case M$:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case E$:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",xe);break}A=null,T=null,N=null,O=null,k.set(0,0,0),j=0,E=xe,B=Ct}return}Ae=Ae||He,lt=lt||Pe,_t=_t||we,(He!==w||Ae!==C)&&(t.blendEquationSeparate(U[He],U[Ae]),w=He,C=Ae),(Pe!==A||we!==T||lt!==N||_t!==O)&&(t.blendFuncSeparate(H[Pe],H[we],H[lt],H[_t]),A=Pe,T=we,N=lt,O=_t),(Xe.equals(k)===!1||Ut!==j)&&(t.blendColor(Xe.r,Xe.g,Xe.b,Ut),k.copy(Xe),j=Ut),E=xe,B=!1}function G(xe,He){xe.side===wc?de(t.CULL_FACE):pe(t.CULL_FACE);let Pe=xe.side===ns;He&&(Pe=!Pe),Z(Pe),xe.blending===bp&&xe.transparent===!1?re(cd):re(xe.blending,xe.blendEquation,xe.blendSrc,xe.blendDst,xe.blendEquationAlpha,xe.blendSrcAlpha,xe.blendDstAlpha,xe.blendColor,xe.blendAlpha,xe.premultipliedAlpha),c.setFunc(xe.depthFunc),c.setTest(xe.depthTest),c.setMask(xe.depthWrite),l.setMask(xe.colorWrite);const we=xe.stencilWrite;u.setTest(we),we&&(u.setMask(xe.stencilWriteMask),u.setFunc(xe.stencilFunc,xe.stencilRef,xe.stencilFuncMask),u.setOp(xe.stencilFail,xe.stencilZFail,xe.stencilZPass)),Te(xe.polygonOffset,xe.polygonOffsetFactor,xe.polygonOffsetUnits),xe.alphaToCoverage===!0?pe(t.SAMPLE_ALPHA_TO_COVERAGE):de(t.SAMPLE_ALPHA_TO_COVERAGE)}function Z(xe){L!==xe&&(xe?t.frontFace(t.CW):t.frontFace(t.CCW),L=xe)}function oe(xe){xe!==JDe?(pe(t.CULL_FACE),xe!==K&&(xe===w$?t.cullFace(t.BACK):xe===eOe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):de(t.CULL_FACE),K=xe}function be(xe){xe!==R&&(J&&t.lineWidth(xe),R=xe)}function Te(xe,He,Pe){xe?(pe(t.POLYGON_OFFSET_FILL),(q!==He||W!==Pe)&&(t.polygonOffset(He,Pe),q=He,W=Pe)):de(t.POLYGON_OFFSET_FILL)}function Me(xe){xe?pe(t.SCISSOR_TEST):de(t.SCISSOR_TEST)}function F(xe){xe===void 0&&(xe=t.TEXTURE0+$-1),z!==xe&&(t.activeTexture(xe),z=xe)}function I(xe,He,Pe){Pe===void 0&&(z===null?Pe=t.TEXTURE0+$-1:Pe=z);let we=V[Pe];we===void 0&&(we={type:void 0,texture:void 0},V[Pe]=we),(we.type!==xe||we.texture!==He)&&(z!==Pe&&(t.activeTexture(Pe),z=Pe),t.bindTexture(xe,He||Ee[xe]),we.type=xe,we.texture=He)}function ne(){const xe=V[z];xe!==void 0&&xe.type!==void 0&&(t.bindTexture(xe.type,null),xe.type=void 0,xe.texture=void 0)}function ve(){try{t.compressedTexImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Se(){try{t.compressedTexImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function ye(){try{t.texSubImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Ke(){try{t.texSubImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function We(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function qe(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function ut(){try{t.texStorage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function ue(){try{t.texStorage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function se(){try{t.texImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Ve(){try{t.texImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Be(xe){ie.equals(xe)===!1&&(t.scissor(xe.x,xe.y,xe.z,xe.w),ie.copy(xe))}function Ze(xe){le.equals(xe)===!1&&(t.viewport(xe.x,xe.y,xe.z,xe.w),le.copy(xe))}function ht(xe,He){let Pe=f.get(He);Pe===void 0&&(Pe=new WeakMap,f.set(He,Pe));let we=Pe.get(xe);we===void 0&&(we=t.getUniformBlockIndex(He,xe.name),Pe.set(xe,we))}function me(xe,He){const we=f.get(He).get(xe);d.get(He)!==we&&(t.uniformBlockBinding(He,we,xe.__bindingPointIndex),d.set(He,we))}function nt(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),r===!0&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),g={},z=null,V={},p={},x=new WeakMap,v=[],y=null,b=!1,E=null,w=null,A=null,T=null,C=null,N=null,O=null,k=new Kt(0,0,0),j=0,B=!1,L=null,K=null,R=null,q=null,W=null,ie.set(0,0,t.canvas.width,t.canvas.height),le.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:pe,disable:de,bindFramebuffer:Re,drawBuffers:fe,useProgram:Fe,setBlending:re,setMaterial:G,setFlipSided:Z,setCullFace:oe,setLineWidth:be,setPolygonOffset:Te,setScissorTest:Me,activeTexture:F,bindTexture:I,unbindTexture:ne,compressedTexImage2D:ve,compressedTexImage3D:Se,texImage2D:se,texImage3D:Ve,updateUBOMapping:ht,uniformBlockBinding:me,texStorage2D:ut,texStorage3D:ue,texSubImage2D:ye,texSubImage3D:Ke,compressedTexSubImage2D:We,compressedTexSubImage3D:qe,scissor:Be,viewport:Ze,reset:nt}}function lUe(t,e,n,r,i,a,s){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,g=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let v;const y=new WeakMap;let b=!1;try{b=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function E(F,I){return b?new OffscreenCanvas(F,I):Jw("canvas")}function w(F,I,ne,ve){let Se=1;if((F.width>ve||F.height>ve)&&(Se=ve/Math.max(F.width,F.height)),Se<1||I===!0)if(typeof HTMLImageElement<"u"&&F instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&F instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&F instanceof ImageBitmap){const ye=I?Qw:Math.floor,Ke=ye(Se*F.width),We=ye(Se*F.height);v===void 0&&(v=E(Ke,We));const qe=ne?E(Ke,We):v;return qe.width=Ke,qe.height=We,qe.getContext("2d").drawImage(F,0,0,Ke,We),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+F.width+"x"+F.height+") to ("+Ke+"x"+We+")."),qe}else return"data"in F&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+F.width+"x"+F.height+")."),F;return F}function A(F){return aj(F.width)&&aj(F.height)}function T(F){return l?!1:F.wrapS!==Lo||F.wrapT!==Lo||F.minFilter!==ra&&F.minFilter!==no}function C(F,I){return F.generateMipmaps&&I&&F.minFilter!==ra&&F.minFilter!==no}function N(F){t.generateMipmap(F)}function O(F,I,ne,ve,Se=!1){if(l===!1)return I;if(F!==null){if(t[F]!==void 0)return t[F];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+F+"'")}let ye=I;if(I===t.RED&&(ne===t.FLOAT&&(ye=t.R32F),ne===t.HALF_FLOAT&&(ye=t.R16F),ne===t.UNSIGNED_BYTE&&(ye=t.R8)),I===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ye=t.R8UI),ne===t.UNSIGNED_SHORT&&(ye=t.R16UI),ne===t.UNSIGNED_INT&&(ye=t.R32UI),ne===t.BYTE&&(ye=t.R8I),ne===t.SHORT&&(ye=t.R16I),ne===t.INT&&(ye=t.R32I)),I===t.RG&&(ne===t.FLOAT&&(ye=t.RG32F),ne===t.HALF_FLOAT&&(ye=t.RG16F),ne===t.UNSIGNED_BYTE&&(ye=t.RG8)),I===t.RGBA){const Ke=Se?Xw:or.getTransfer(ve);ne===t.FLOAT&&(ye=t.RGBA32F),ne===t.HALF_FLOAT&&(ye=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(ye=Ke===wr?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(ye=t.RGBA4),ne===t.UNSIGNED_SHORT_5_5_5_1&&(ye=t.RGB5_A1)}return(ye===t.R16F||ye===t.R32F||ye===t.RG16F||ye===t.RG32F||ye===t.RGBA16F||ye===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ye}function k(F,I,ne){return C(F,ne)===!0||F.isFramebufferTexture&&F.minFilter!==ra&&F.minFilter!==no?Math.log2(Math.max(I.width,I.height))+1:F.mipmaps!==void 0&&F.mipmaps.length>0?F.mipmaps.length:F.isCompressedTexture&&Array.isArray(F.image)?I.mipmaps.length:1}function j(F){return F===ra||F===N$||F===hC?t.NEAREST:t.LINEAR}function B(F){const I=F.target;I.removeEventListener("dispose",B),K(I),I.isVideoTexture&&x.delete(I)}function L(F){const I=F.target;I.removeEventListener("dispose",L),q(I)}function K(F){const I=r.get(F);if(I.__webglInit===void 0)return;const ne=F.source,ve=y.get(ne);if(ve){const Se=ve[I.__cacheKey];Se.usedTimes--,Se.usedTimes===0&&R(F),Object.keys(ve).length===0&&y.delete(ne)}r.remove(F)}function R(F){const I=r.get(F);t.deleteTexture(I.__webglTexture);const ne=F.source,ve=y.get(ne);delete ve[I.__cacheKey],s.memory.textures--}function q(F){const I=F.texture,ne=r.get(F),ve=r.get(I);if(ve.__webglTexture!==void 0&&(t.deleteTexture(ve.__webglTexture),s.memory.textures--),F.depthTexture&&F.depthTexture.dispose(),F.isWebGLCubeRenderTarget)for(let Se=0;Se<6;Se++){if(Array.isArray(ne.__webglFramebuffer[Se]))for(let ye=0;ye<ne.__webglFramebuffer[Se].length;ye++)t.deleteFramebuffer(ne.__webglFramebuffer[Se][ye]);else t.deleteFramebuffer(ne.__webglFramebuffer[Se]);ne.__webglDepthbuffer&&t.deleteRenderbuffer(ne.__webglDepthbuffer[Se])}else{if(Array.isArray(ne.__webglFramebuffer))for(let Se=0;Se<ne.__webglFramebuffer.length;Se++)t.deleteFramebuffer(ne.__webglFramebuffer[Se]);else t.deleteFramebuffer(ne.__webglFramebuffer);if(ne.__webglDepthbuffer&&t.deleteRenderbuffer(ne.__webglDepthbuffer),ne.__webglMultisampledFramebuffer&&t.deleteFramebuffer(ne.__webglMultisampledFramebuffer),ne.__webglColorRenderbuffer)for(let Se=0;Se<ne.__webglColorRenderbuffer.length;Se++)ne.__webglColorRenderbuffer[Se]&&t.deleteRenderbuffer(ne.__webglColorRenderbuffer[Se]);ne.__webglDepthRenderbuffer&&t.deleteRenderbuffer(ne.__webglDepthRenderbuffer)}if(F.isWebGLMultipleRenderTargets)for(let Se=0,ye=I.length;Se<ye;Se++){const Ke=r.get(I[Se]);Ke.__webglTexture&&(t.deleteTexture(Ke.__webglTexture),s.memory.textures--),r.remove(I[Se])}r.remove(I),r.remove(F)}let W=0;function $(){W=0}function J(){const F=W;return F>=c&&console.warn("THREE.WebGLTextures: Trying to use "+F+" texture units while this GPU supports only "+c),W+=1,F}function ee(F){const I=[];return I.push(F.wrapS),I.push(F.wrapT),I.push(F.wrapR||0),I.push(F.magFilter),I.push(F.minFilter),I.push(F.anisotropy),I.push(F.internalFormat),I.push(F.format),I.push(F.type),I.push(F.generateMipmaps),I.push(F.premultiplyAlpha),I.push(F.flipY),I.push(F.unpackAlignment),I.push(F.colorSpace),I.join()}function Q(F,I){const ne=r.get(F);if(F.isVideoTexture&&Te(F),F.isRenderTargetTexture===!1&&F.version>0&&ne.__version!==F.version){const ve=F.image;if(ve===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ve.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{pe(ne,F,I);return}}n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+I)}function z(F,I){const ne=r.get(F);if(F.version>0&&ne.__version!==F.version){pe(ne,F,I);return}n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+I)}function V(F,I){const ne=r.get(F);if(F.version>0&&ne.__version!==F.version){pe(ne,F,I);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+I)}function X(F,I){const ne=r.get(F);if(F.version>0&&ne.__version!==F.version){de(ne,F,I);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+I)}const te={[tj]:t.REPEAT,[Lo]:t.CLAMP_TO_EDGE,[nj]:t.MIRRORED_REPEAT},ie={[ra]:t.NEAREST,[N$]:t.NEAREST_MIPMAP_NEAREST,[hC]:t.NEAREST_MIPMAP_LINEAR,[no]:t.LINEAR,[jOe]:t.LINEAR_MIPMAP_NEAREST,[ib]:t.LINEAR_MIPMAP_LINEAR},le={[VOe]:t.NEVER,[YOe]:t.ALWAYS,[GOe]:t.LESS,[uQ]:t.LEQUAL,[WOe]:t.EQUAL,[XOe]:t.GEQUAL,[qOe]:t.GREATER,[KOe]:t.NOTEQUAL};function ge(F,I,ne){if(ne?(t.texParameteri(F,t.TEXTURE_WRAP_S,te[I.wrapS]),t.texParameteri(F,t.TEXTURE_WRAP_T,te[I.wrapT]),(F===t.TEXTURE_3D||F===t.TEXTURE_2D_ARRAY)&&t.texParameteri(F,t.TEXTURE_WRAP_R,te[I.wrapR]),t.texParameteri(F,t.TEXTURE_MAG_FILTER,ie[I.magFilter]),t.texParameteri(F,t.TEXTURE_MIN_FILTER,ie[I.minFilter])):(t.texParameteri(F,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(F,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(F===t.TEXTURE_3D||F===t.TEXTURE_2D_ARRAY)&&t.texParameteri(F,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(I.wrapS!==Lo||I.wrapT!==Lo)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(F,t.TEXTURE_MAG_FILTER,j(I.magFilter)),t.texParameteri(F,t.TEXTURE_MIN_FILTER,j(I.minFilter)),I.minFilter!==ra&&I.minFilter!==no&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),I.compareFunction&&(t.texParameteri(F,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(F,t.TEXTURE_COMPARE_FUNC,le[I.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ve=e.get("EXT_texture_filter_anisotropic");if(I.magFilter===ra||I.minFilter!==hC&&I.minFilter!==ib||I.type===Cc&&e.has("OES_texture_float_linear")===!1||l===!1&&I.type===ab&&e.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||r.get(I).__currentAnisotropy)&&(t.texParameterf(F,ve.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,i.getMaxAnisotropy())),r.get(I).__currentAnisotropy=I.anisotropy)}}function Ee(F,I){let ne=!1;F.__webglInit===void 0&&(F.__webglInit=!0,I.addEventListener("dispose",B));const ve=I.source;let Se=y.get(ve);Se===void 0&&(Se={},y.set(ve,Se));const ye=ee(I);if(ye!==F.__cacheKey){Se[ye]===void 0&&(Se[ye]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,ne=!0),Se[ye].usedTimes++;const Ke=Se[F.__cacheKey];Ke!==void 0&&(Se[F.__cacheKey].usedTimes--,Ke.usedTimes===0&&R(I)),F.__cacheKey=ye,F.__webglTexture=Se[ye].texture}return ne}function pe(F,I,ne){let ve=t.TEXTURE_2D;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(ve=t.TEXTURE_2D_ARRAY),I.isData3DTexture&&(ve=t.TEXTURE_3D);const Se=Ee(F,I),ye=I.source;n.bindTexture(ve,F.__webglTexture,t.TEXTURE0+ne);const Ke=r.get(ye);if(ye.version!==Ke.__version||Se===!0){n.activeTexture(t.TEXTURE0+ne);const We=or.getPrimaries(or.workingColorSpace),qe=I.colorSpace===io?null:or.getPrimaries(I.colorSpace),ut=I.colorSpace===io||We===qe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ut);const ue=T(I)&&A(I.image)===!1;let se=w(I.image,ue,!1,d);se=Me(I,se);const Ve=A(se)||l,Be=a.convert(I.format,I.colorSpace);let Ze=a.convert(I.type),ht=O(I.internalFormat,Be,Ze,I.colorSpace,I.isVideoTexture);ge(ve,I,Ve);let me;const nt=I.mipmaps,xe=l&&I.isVideoTexture!==!0&&ht!==oQ,He=Ke.__version===void 0||Se===!0,Pe=k(I,se,Ve);if(I.isDepthTexture)ht=t.DEPTH_COMPONENT,l?I.type===Cc?ht=t.DEPTH_COMPONENT32F:I.type===td?ht=t.DEPTH_COMPONENT24:I.type===Bh?ht=t.DEPTH24_STENCIL8:ht=t.DEPTH_COMPONENT16:I.type===Cc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===Hh&&ht===t.DEPTH_COMPONENT&&I.type!==zO&&I.type!==td&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=td,Ze=a.convert(I.type)),I.format===Gp&&ht===t.DEPTH_COMPONENT&&(ht=t.DEPTH_STENCIL,I.type!==Bh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=Bh,Ze=a.convert(I.type))),He&&(xe?n.texStorage2D(t.TEXTURE_2D,1,ht,se.width,se.height):n.texImage2D(t.TEXTURE_2D,0,ht,se.width,se.height,0,Be,Ze,null));else if(I.isDataTexture)if(nt.length>0&&Ve){xe&&He&&n.texStorage2D(t.TEXTURE_2D,Pe,ht,nt[0].width,nt[0].height);for(let we=0,Ae=nt.length;we<Ae;we++)me=nt[we],xe?n.texSubImage2D(t.TEXTURE_2D,we,0,0,me.width,me.height,Be,Ze,me.data):n.texImage2D(t.TEXTURE_2D,we,ht,me.width,me.height,0,Be,Ze,me.data);I.generateMipmaps=!1}else xe?(He&&n.texStorage2D(t.TEXTURE_2D,Pe,ht,se.width,se.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,se.width,se.height,Be,Ze,se.data)):n.texImage2D(t.TEXTURE_2D,0,ht,se.width,se.height,0,Be,Ze,se.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){xe&&He&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Pe,ht,nt[0].width,nt[0].height,se.depth);for(let we=0,Ae=nt.length;we<Ae;we++)me=nt[we],I.format!==ro?Be!==null?xe?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,we,0,0,0,me.width,me.height,se.depth,Be,me.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,we,ht,me.width,me.height,se.depth,0,me.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):xe?n.texSubImage3D(t.TEXTURE_2D_ARRAY,we,0,0,0,me.width,me.height,se.depth,Be,Ze,me.data):n.texImage3D(t.TEXTURE_2D_ARRAY,we,ht,me.width,me.height,se.depth,0,Be,Ze,me.data)}else{xe&&He&&n.texStorage2D(t.TEXTURE_2D,Pe,ht,nt[0].width,nt[0].height);for(let we=0,Ae=nt.length;we<Ae;we++)me=nt[we],I.format!==ro?Be!==null?xe?n.compressedTexSubImage2D(t.TEXTURE_2D,we,0,0,me.width,me.height,Be,me.data):n.compressedTexImage2D(t.TEXTURE_2D,we,ht,me.width,me.height,0,me.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):xe?n.texSubImage2D(t.TEXTURE_2D,we,0,0,me.width,me.height,Be,Ze,me.data):n.texImage2D(t.TEXTURE_2D,we,ht,me.width,me.height,0,Be,Ze,me.data)}else if(I.isDataArrayTexture)xe?(He&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Pe,ht,se.width,se.height,se.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,se.width,se.height,se.depth,Be,Ze,se.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ht,se.width,se.height,se.depth,0,Be,Ze,se.data);else if(I.isData3DTexture)xe?(He&&n.texStorage3D(t.TEXTURE_3D,Pe,ht,se.width,se.height,se.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,se.width,se.height,se.depth,Be,Ze,se.data)):n.texImage3D(t.TEXTURE_3D,0,ht,se.width,se.height,se.depth,0,Be,Ze,se.data);else if(I.isFramebufferTexture){if(He)if(xe)n.texStorage2D(t.TEXTURE_2D,Pe,ht,se.width,se.height);else{let we=se.width,Ae=se.height;for(let lt=0;lt<Pe;lt++)n.texImage2D(t.TEXTURE_2D,lt,ht,we,Ae,0,Be,Ze,null),we>>=1,Ae>>=1}}else if(nt.length>0&&Ve){xe&&He&&n.texStorage2D(t.TEXTURE_2D,Pe,ht,nt[0].width,nt[0].height);for(let we=0,Ae=nt.length;we<Ae;we++)me=nt[we],xe?n.texSubImage2D(t.TEXTURE_2D,we,0,0,Be,Ze,me):n.texImage2D(t.TEXTURE_2D,we,ht,Be,Ze,me);I.generateMipmaps=!1}else xe?(He&&n.texStorage2D(t.TEXTURE_2D,Pe,ht,se.width,se.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Be,Ze,se)):n.texImage2D(t.TEXTURE_2D,0,ht,Be,Ze,se);C(I,Ve)&&N(ve),Ke.__version=ye.version,I.onUpdate&&I.onUpdate(I)}F.__version=I.version}function de(F,I,ne){if(I.image.length!==6)return;const ve=Ee(F,I),Se=I.source;n.bindTexture(t.TEXTURE_CUBE_MAP,F.__webglTexture,t.TEXTURE0+ne);const ye=r.get(Se);if(Se.version!==ye.__version||ve===!0){n.activeTexture(t.TEXTURE0+ne);const Ke=or.getPrimaries(or.workingColorSpace),We=I.colorSpace===io?null:or.getPrimaries(I.colorSpace),qe=I.colorSpace===io||Ke===We?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,qe);const ut=I.isCompressedTexture||I.image[0].isCompressedTexture,ue=I.image[0]&&I.image[0].isDataTexture,se=[];for(let we=0;we<6;we++)!ut&&!ue?se[we]=w(I.image[we],!1,!0,u):se[we]=ue?I.image[we].image:I.image[we],se[we]=Me(I,se[we]);const Ve=se[0],Be=A(Ve)||l,Ze=a.convert(I.format,I.colorSpace),ht=a.convert(I.type),me=O(I.internalFormat,Ze,ht,I.colorSpace),nt=l&&I.isVideoTexture!==!0,xe=ye.__version===void 0||ve===!0;let He=k(I,Ve,Be);ge(t.TEXTURE_CUBE_MAP,I,Be);let Pe;if(ut){nt&&xe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,He,me,Ve.width,Ve.height);for(let we=0;we<6;we++){Pe=se[we].mipmaps;for(let Ae=0;Ae<Pe.length;Ae++){const lt=Pe[Ae];I.format!==ro?Ze!==null?nt?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae,0,0,lt.width,lt.height,Ze,lt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae,me,lt.width,lt.height,0,lt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae,0,0,lt.width,lt.height,Ze,ht,lt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae,me,lt.width,lt.height,0,Ze,ht,lt.data)}}}else{Pe=I.mipmaps,nt&&xe&&(Pe.length>0&&He++,n.texStorage2D(t.TEXTURE_CUBE_MAP,He,me,se[0].width,se[0].height));for(let we=0;we<6;we++)if(ue){nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,se[we].width,se[we].height,Ze,ht,se[we].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,me,se[we].width,se[we].height,0,Ze,ht,se[we].data);for(let Ae=0;Ae<Pe.length;Ae++){const _t=Pe[Ae].image[we].image;nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae+1,0,0,_t.width,_t.height,Ze,ht,_t.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae+1,me,_t.width,_t.height,0,Ze,ht,_t.data)}}else{nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,Ze,ht,se[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,me,Ze,ht,se[we]);for(let Ae=0;Ae<Pe.length;Ae++){const lt=Pe[Ae];nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae+1,0,0,Ze,ht,lt.image[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ae+1,me,Ze,ht,lt.image[we])}}}C(I,Be)&&N(t.TEXTURE_CUBE_MAP),ye.__version=Se.version,I.onUpdate&&I.onUpdate(I)}F.__version=I.version}function Re(F,I,ne,ve,Se,ye){const Ke=a.convert(ne.format,ne.colorSpace),We=a.convert(ne.type),qe=O(ne.internalFormat,Ke,We,ne.colorSpace);if(!r.get(I).__hasExternalTextures){const ue=Math.max(1,I.width>>ye),se=Math.max(1,I.height>>ye);Se===t.TEXTURE_3D||Se===t.TEXTURE_2D_ARRAY?n.texImage3D(Se,ye,qe,ue,se,I.depth,0,Ke,We,null):n.texImage2D(Se,ye,qe,ue,se,0,Ke,We,null)}n.bindFramebuffer(t.FRAMEBUFFER,F),be(I)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ve,Se,r.get(ne).__webglTexture,0,oe(I)):(Se===t.TEXTURE_2D||Se>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Se<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ve,Se,r.get(ne).__webglTexture,ye),n.bindFramebuffer(t.FRAMEBUFFER,null)}function fe(F,I,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,F),I.depthBuffer&&!I.stencilBuffer){let ve=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(ne||be(I)){const Se=I.depthTexture;Se&&Se.isDepthTexture&&(Se.type===Cc?ve=t.DEPTH_COMPONENT32F:Se.type===td&&(ve=t.DEPTH_COMPONENT24));const ye=oe(I);be(I)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ye,ve,I.width,I.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ye,ve,I.width,I.height)}else t.renderbufferStorage(t.RENDERBUFFER,ve,I.width,I.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,F)}else if(I.depthBuffer&&I.stencilBuffer){const ve=oe(I);ne&&be(I)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ve,t.DEPTH24_STENCIL8,I.width,I.height):be(I)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ve,t.DEPTH24_STENCIL8,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,I.width,I.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,F)}else{const ve=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let Se=0;Se<ve.length;Se++){const ye=ve[Se],Ke=a.convert(ye.format,ye.colorSpace),We=a.convert(ye.type),qe=O(ye.internalFormat,Ke,We,ye.colorSpace),ut=oe(I);ne&&be(I)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ut,qe,I.width,I.height):be(I)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ut,qe,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,qe,I.width,I.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Fe(F,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,F),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),Q(I.depthTexture,0);const ve=r.get(I.depthTexture).__webglTexture,Se=oe(I);if(I.depthTexture.format===Hh)be(I)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ve,0,Se):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ve,0);else if(I.depthTexture.format===Gp)be(I)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ve,0,Se):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ve,0);else throw new Error("Unknown depthTexture format")}function U(F){const I=r.get(F),ne=F.isWebGLCubeRenderTarget===!0;if(F.depthTexture&&!I.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");Fe(I.__webglFramebuffer,F)}else if(ne){I.__webglDepthbuffer=[];for(let ve=0;ve<6;ve++)n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer[ve]),I.__webglDepthbuffer[ve]=t.createRenderbuffer(),fe(I.__webglDepthbuffer[ve],F,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer),I.__webglDepthbuffer=t.createRenderbuffer(),fe(I.__webglDepthbuffer,F,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function H(F,I,ne){const ve=r.get(F);I!==void 0&&Re(ve.__webglFramebuffer,F,F.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&U(F)}function re(F){const I=F.texture,ne=r.get(F),ve=r.get(I);F.addEventListener("dispose",L),F.isWebGLMultipleRenderTargets!==!0&&(ve.__webglTexture===void 0&&(ve.__webglTexture=t.createTexture()),ve.__version=I.version,s.memory.textures++);const Se=F.isWebGLCubeRenderTarget===!0,ye=F.isWebGLMultipleRenderTargets===!0,Ke=A(F)||l;if(Se){ne.__webglFramebuffer=[];for(let We=0;We<6;We++)if(l&&I.mipmaps&&I.mipmaps.length>0){ne.__webglFramebuffer[We]=[];for(let qe=0;qe<I.mipmaps.length;qe++)ne.__webglFramebuffer[We][qe]=t.createFramebuffer()}else ne.__webglFramebuffer[We]=t.createFramebuffer()}else{if(l&&I.mipmaps&&I.mipmaps.length>0){ne.__webglFramebuffer=[];for(let We=0;We<I.mipmaps.length;We++)ne.__webglFramebuffer[We]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if(ye)if(i.drawBuffers){const We=F.texture;for(let qe=0,ut=We.length;qe<ut;qe++){const ue=r.get(We[qe]);ue.__webglTexture===void 0&&(ue.__webglTexture=t.createTexture(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(l&&F.samples>0&&be(F)===!1){const We=ye?I:[I];ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let qe=0;qe<We.length;qe++){const ut=We[qe];ne.__webglColorRenderbuffer[qe]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[qe]);const ue=a.convert(ut.format,ut.colorSpace),se=a.convert(ut.type),Ve=O(ut.internalFormat,ue,se,ut.colorSpace,F.isXRRenderTarget===!0),Be=oe(F);t.renderbufferStorageMultisample(t.RENDERBUFFER,Be,Ve,F.width,F.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+qe,t.RENDERBUFFER,ne.__webglColorRenderbuffer[qe])}t.bindRenderbuffer(t.RENDERBUFFER,null),F.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),fe(ne.__webglDepthRenderbuffer,F,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(Se){n.bindTexture(t.TEXTURE_CUBE_MAP,ve.__webglTexture),ge(t.TEXTURE_CUBE_MAP,I,Ke);for(let We=0;We<6;We++)if(l&&I.mipmaps&&I.mipmaps.length>0)for(let qe=0;qe<I.mipmaps.length;qe++)Re(ne.__webglFramebuffer[We][qe],F,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+We,qe);else Re(ne.__webglFramebuffer[We],F,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+We,0);C(I,Ke)&&N(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ye){const We=F.texture;for(let qe=0,ut=We.length;qe<ut;qe++){const ue=We[qe],se=r.get(ue);n.bindTexture(t.TEXTURE_2D,se.__webglTexture),ge(t.TEXTURE_2D,ue,Ke),Re(ne.__webglFramebuffer,F,ue,t.COLOR_ATTACHMENT0+qe,t.TEXTURE_2D,0),C(ue,Ke)&&N(t.TEXTURE_2D)}n.unbindTexture()}else{let We=t.TEXTURE_2D;if((F.isWebGL3DRenderTarget||F.isWebGLArrayRenderTarget)&&(l?We=F.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(We,ve.__webglTexture),ge(We,I,Ke),l&&I.mipmaps&&I.mipmaps.length>0)for(let qe=0;qe<I.mipmaps.length;qe++)Re(ne.__webglFramebuffer[qe],F,I,t.COLOR_ATTACHMENT0,We,qe);else Re(ne.__webglFramebuffer,F,I,t.COLOR_ATTACHMENT0,We,0);C(I,Ke)&&N(We),n.unbindTexture()}F.depthBuffer&&U(F)}function G(F){const I=A(F)||l,ne=F.isWebGLMultipleRenderTargets===!0?F.texture:[F.texture];for(let ve=0,Se=ne.length;ve<Se;ve++){const ye=ne[ve];if(C(ye,I)){const Ke=F.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,We=r.get(ye).__webglTexture;n.bindTexture(Ke,We),N(Ke),n.unbindTexture()}}}function Z(F){if(l&&F.samples>0&&be(F)===!1){const I=F.isWebGLMultipleRenderTargets?F.texture:[F.texture],ne=F.width,ve=F.height;let Se=t.COLOR_BUFFER_BIT;const ye=[],Ke=F.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,We=r.get(F),qe=F.isWebGLMultipleRenderTargets===!0;if(qe)for(let ut=0;ut<I.length;ut++)n.bindFramebuffer(t.FRAMEBUFFER,We.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,We.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,We.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,We.__webglFramebuffer);for(let ut=0;ut<I.length;ut++){ye.push(t.COLOR_ATTACHMENT0+ut),F.depthBuffer&&ye.push(Ke);const ue=We.__ignoreDepthValues!==void 0?We.__ignoreDepthValues:!1;if(ue===!1&&(F.depthBuffer&&(Se|=t.DEPTH_BUFFER_BIT),F.stencilBuffer&&(Se|=t.STENCIL_BUFFER_BIT)),qe&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,We.__webglColorRenderbuffer[ut]),ue===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[Ke]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[Ke])),qe){const se=r.get(I[ut]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,se,0)}t.blitFramebuffer(0,0,ne,ve,0,0,ne,ve,Se,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ye)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),qe)for(let ut=0;ut<I.length;ut++){n.bindFramebuffer(t.FRAMEBUFFER,We.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.RENDERBUFFER,We.__webglColorRenderbuffer[ut]);const ue=r.get(I[ut]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,We.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.TEXTURE_2D,ue,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,We.__webglMultisampledFramebuffer)}}function oe(F){return Math.min(f,F.samples)}function be(F){const I=r.get(F);return l&&F.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Te(F){const I=s.render.frame;x.get(F)!==I&&(x.set(F,I),F.update())}function Me(F,I){const ne=F.colorSpace,ve=F.format,Se=F.type;return F.isCompressedTexture===!0||F.isVideoTexture===!0||F.format===ij||ne!==Yc&&ne!==io&&(or.getTransfer(ne)===wr?l===!1?e.has("EXT_sRGB")===!0&&ve===ro?(F.format=ij,F.minFilter=no,F.generateMipmaps=!1):I=fQ.sRGBToLinear(I):(ve!==ro||Se!==dd)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ne)),I}this.allocateTextureUnit=J,this.resetTextureUnits=$,this.setTexture2D=Q,this.setTexture2DArray=z,this.setTexture3D=V,this.setTextureCube=X,this.rebindTextures=H,this.setupRenderTarget=re,this.updateRenderTargetMipmap=G,this.updateMultisampleRenderTarget=Z,this.setupDepthRenderbuffer=U,this.setupFrameBufferTexture=Re,this.useMultisampledRTT=be}function cUe(t,e,n){const r=n.isWebGL2;function i(a,s=io){let l;const c=or.getTransfer(s);if(a===dd)return t.UNSIGNED_BYTE;if(a===nQ)return t.UNSIGNED_SHORT_4_4_4_4;if(a===rQ)return t.UNSIGNED_SHORT_5_5_5_1;if(a===ROe)return t.BYTE;if(a===DOe)return t.SHORT;if(a===zO)return t.UNSIGNED_SHORT;if(a===tQ)return t.INT;if(a===td)return t.UNSIGNED_INT;if(a===Cc)return t.FLOAT;if(a===ab)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(a===OOe)return t.ALPHA;if(a===ro)return t.RGBA;if(a===LOe)return t.LUMINANCE;if(a===IOe)return t.LUMINANCE_ALPHA;if(a===Hh)return t.DEPTH_COMPONENT;if(a===Gp)return t.DEPTH_STENCIL;if(a===ij)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===FOe)return t.RED;if(a===iQ)return t.RED_INTEGER;if(a===UOe)return t.RG;if(a===aQ)return t.RG_INTEGER;if(a===sQ)return t.RGBA_INTEGER;if(a===fC||a===mC||a===pC||a===gC)if(c===wr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===fC)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===mC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===pC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===gC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===fC)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===mC)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===pC)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===gC)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===C$||a===k$||a===P$||a===j$)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===C$)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===k$)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===P$)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===j$)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===oQ)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===R$||a===D$)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===R$)return c===wr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===D$)return c===wr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===O$||a===L$||a===I$||a===F$||a===U$||a===z$||a===B$||a===H$||a===$$||a===V$||a===G$||a===W$||a===q$||a===K$)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===O$)return c===wr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===L$)return c===wr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===I$)return c===wr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===F$)return c===wr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===U$)return c===wr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===z$)return c===wr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===B$)return c===wr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===H$)return c===wr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===$$)return c===wr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===V$)return c===wr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===G$)return c===wr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===W$)return c===wr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===q$)return c===wr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===K$)return c===wr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===xC||a===X$||a===Y$)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===xC)return c===wr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===X$)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===Y$)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===zOe||a===Z$||a===Q$||a===J$)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===xC)return l.COMPRESSED_RED_RGTC1_EXT;if(a===Z$)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===Q$)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===J$)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Bh?r?t.UNSIGNED_INT_24_8:(l=e.get("WEBGL_depth_texture"),l!==null?l.UNSIGNED_INT_24_8_WEBGL:null):t[a]!==void 0?t[a]:null}return{convert:i}}class uUe extends Ss{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Qx extends Da{constructor(){super(),this.isGroup=!0,this.type="Group"}}const dUe={type:"move"};class zC{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Qx,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Qx,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Oe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Oe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Qx,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Oe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Oe),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,s=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){s=!0;for(const v of e.hand.values()){const y=n.getJointPose(v,r),b=this._getHandJoint(u,v);y!==null&&(b.matrix.fromArray(y.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=y.radius),b.visible=y!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&g>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(dUe)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new Qx;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class hUe extends Cf{constructor(e,n){super();const r=this;let i=null,a=1,s=null,l="local-floor",c=1,u=null,d=null,f=null,g=null,p=null,x=null;const v=n.getContextAttributes();let y=null,b=null;const E=[],w=[],A=new tn;let T=null;const C=new Ss;C.layers.enable(1),C.viewport=new cr;const N=new Ss;N.layers.enable(2),N.viewport=new cr;const O=[C,N],k=new uUe;k.layers.enable(1),k.layers.enable(2);let j=null,B=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let te=E[X];return te===void 0&&(te=new zC,E[X]=te),te.getTargetRaySpace()},this.getControllerGrip=function(X){let te=E[X];return te===void 0&&(te=new zC,E[X]=te),te.getGripSpace()},this.getHand=function(X){let te=E[X];return te===void 0&&(te=new zC,E[X]=te),te.getHandSpace()};function L(X){const te=w.indexOf(X.inputSource);if(te===-1)return;const ie=E[te];ie!==void 0&&(ie.update(X.inputSource,X.frame,u||s),ie.dispatchEvent({type:X.type,data:X.inputSource}))}function K(){i.removeEventListener("select",L),i.removeEventListener("selectstart",L),i.removeEventListener("selectend",L),i.removeEventListener("squeeze",L),i.removeEventListener("squeezestart",L),i.removeEventListener("squeezeend",L),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",R);for(let X=0;X<E.length;X++){const te=w[X];te!==null&&(w[X]=null,E[X].disconnect(te))}j=null,B=null,e.setRenderTarget(y),p=null,g=null,f=null,i=null,b=null,V.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){a=X,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){l=X,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||s},this.setReferenceSpace=function(X){u=X},this.getBaseLayer=function(){return g!==null?g:p},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(X){if(i=X,i!==null){if(y=e.getRenderTarget(),i.addEventListener("select",L),i.addEventListener("selectstart",L),i.addEventListener("selectend",L),i.addEventListener("squeeze",L),i.addEventListener("squeezestart",L),i.addEventListener("squeezeend",L),i.addEventListener("end",K),i.addEventListener("inputsourceschange",R),v.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const te={antialias:i.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,te),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),b=new bf(p.framebufferWidth,p.framebufferHeight,{format:ro,type:dd,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let te=null,ie=null,le=null;v.depth&&(le=v.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,te=v.stencil?Gp:Hh,ie=v.stencil?Bh:td);const ge={colorFormat:n.RGBA8,depthFormat:le,scaleFactor:a};f=new XRWebGLBinding(i,n),g=f.createProjectionLayer(ge),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),b=new bf(g.textureWidth,g.textureHeight,{format:ro,type:dd,depthTexture:new EQ(g.textureWidth,g.textureHeight,ie,void 0,void 0,void 0,void 0,void 0,void 0,te),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const Ee=e.properties.get(b);Ee.__ignoreDepthValues=g.ignoreDepthValues}b.isXRRenderTarget=!0,this.setFoveation(c),u=null,s=await i.requestReferenceSpace(l),V.setContext(i),V.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function R(X){for(let te=0;te<X.removed.length;te++){const ie=X.removed[te],le=w.indexOf(ie);le>=0&&(w[le]=null,E[le].disconnect(ie))}for(let te=0;te<X.added.length;te++){const ie=X.added[te];let le=w.indexOf(ie);if(le===-1){for(let Ee=0;Ee<E.length;Ee++)if(Ee>=w.length){w.push(ie),le=Ee;break}else if(w[Ee]===null){w[Ee]=ie,le=Ee;break}if(le===-1)break}const ge=E[le];ge&&ge.connect(ie)}}const q=new Oe,W=new Oe;function $(X,te,ie){q.setFromMatrixPosition(te.matrixWorld),W.setFromMatrixPosition(ie.matrixWorld);const le=q.distanceTo(W),ge=te.projectionMatrix.elements,Ee=ie.projectionMatrix.elements,pe=ge[14]/(ge[10]-1),de=ge[14]/(ge[10]+1),Re=(ge[9]+1)/ge[5],fe=(ge[9]-1)/ge[5],Fe=(ge[8]-1)/ge[0],U=(Ee[8]+1)/Ee[0],H=pe*Fe,re=pe*U,G=le/(-Fe+U),Z=G*-Fe;te.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(Z),X.translateZ(G),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert();const oe=pe+G,be=de+G,Te=H-Z,Me=re+(le-Z),F=Re*de/be*oe,I=fe*de/be*oe;X.projectionMatrix.makePerspective(Te,Me,F,I,oe,be),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}function J(X,te){te===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices(te.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(i===null)return;k.near=N.near=C.near=X.near,k.far=N.far=C.far=X.far,(j!==k.near||B!==k.far)&&(i.updateRenderState({depthNear:k.near,depthFar:k.far}),j=k.near,B=k.far);const te=X.parent,ie=k.cameras;J(k,te);for(let le=0;le<ie.length;le++)J(ie[le],te);ie.length===2?$(k,C,N):k.projectionMatrix.copy(C.projectionMatrix),ee(X,k,te)};function ee(X,te,ie){ie===null?X.matrix.copy(te.matrixWorld):(X.matrix.copy(ie.matrixWorld),X.matrix.invert(),X.matrix.multiply(te.matrixWorld)),X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(te.projectionMatrix),X.projectionMatrixInverse.copy(te.projectionMatrixInverse),X.isPerspectiveCamera&&(X.fov=ob*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1)}this.getCamera=function(){return k},this.getFoveation=function(){if(!(g===null&&p===null))return c},this.setFoveation=function(X){c=X,g!==null&&(g.fixedFoveation=X),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=X)};let Q=null;function z(X,te){if(d=te.getViewerPose(u||s),x=te,d!==null){const ie=d.views;p!==null&&(e.setRenderTargetFramebuffer(b,p.framebuffer),e.setRenderTarget(b));let le=!1;ie.length!==k.cameras.length&&(k.cameras.length=0,le=!0);for(let ge=0;ge<ie.length;ge++){const Ee=ie[ge];let pe=null;if(p!==null)pe=p.getViewport(Ee);else{const Re=f.getViewSubImage(g,Ee);pe=Re.viewport,ge===0&&(e.setRenderTargetTextures(b,Re.colorTexture,g.ignoreDepthValues?void 0:Re.depthStencilTexture),e.setRenderTarget(b))}let de=O[ge];de===void 0&&(de=new Ss,de.layers.enable(ge),de.viewport=new cr,O[ge]=de),de.matrix.fromArray(Ee.transform.matrix),de.matrix.decompose(de.position,de.quaternion,de.scale),de.projectionMatrix.fromArray(Ee.projectionMatrix),de.projectionMatrixInverse.copy(de.projectionMatrix).invert(),de.viewport.set(pe.x,pe.y,pe.width,pe.height),ge===0&&(k.matrix.copy(de.matrix),k.matrix.decompose(k.position,k.quaternion,k.scale)),le===!0&&k.cameras.push(de)}}for(let ie=0;ie<E.length;ie++){const le=w[ie],ge=E[ie];le!==null&&ge!==void 0&&ge.update(le,te,u||s)}Q&&Q(X,te),te.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:te}),x=null}const V=new MQ;V.setAnimationLoop(z),this.setAnimationLoop=function(X){Q=X},this.dispose=function(){}}}function fUe(t,e){function n(y,b){y.matrixAutoUpdate===!0&&y.updateMatrix(),b.value.copy(y.matrix)}function r(y,b){b.color.getRGB(y.fogColor.value,_Q(t)),b.isFog?(y.fogNear.value=b.near,y.fogFar.value=b.far):b.isFogExp2&&(y.fogDensity.value=b.density)}function i(y,b,E,w,A){b.isMeshBasicMaterial||b.isMeshLambertMaterial?a(y,b):b.isMeshToonMaterial?(a(y,b),f(y,b)):b.isMeshPhongMaterial?(a(y,b),d(y,b)):b.isMeshStandardMaterial?(a(y,b),g(y,b),b.isMeshPhysicalMaterial&&p(y,b,A)):b.isMeshMatcapMaterial?(a(y,b),x(y,b)):b.isMeshDepthMaterial?a(y,b):b.isMeshDistanceMaterial?(a(y,b),v(y,b)):b.isMeshNormalMaterial?a(y,b):b.isLineBasicMaterial?(s(y,b),b.isLineDashedMaterial&&l(y,b)):b.isPointsMaterial?c(y,b,E,w):b.isSpriteMaterial?u(y,b):b.isShadowMaterial?(y.color.value.copy(b.color),y.opacity.value=b.opacity):b.isShaderMaterial&&(b.uniformsNeedUpdate=!1)}function a(y,b){y.opacity.value=b.opacity,b.color&&y.diffuse.value.copy(b.color),b.emissive&&y.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity),b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.bumpMap&&(y.bumpMap.value=b.bumpMap,n(b.bumpMap,y.bumpMapTransform),y.bumpScale.value=b.bumpScale,b.side===ns&&(y.bumpScale.value*=-1)),b.normalMap&&(y.normalMap.value=b.normalMap,n(b.normalMap,y.normalMapTransform),y.normalScale.value.copy(b.normalScale),b.side===ns&&y.normalScale.value.negate()),b.displacementMap&&(y.displacementMap.value=b.displacementMap,n(b.displacementMap,y.displacementMapTransform),y.displacementScale.value=b.displacementScale,y.displacementBias.value=b.displacementBias),b.emissiveMap&&(y.emissiveMap.value=b.emissiveMap,n(b.emissiveMap,y.emissiveMapTransform)),b.specularMap&&(y.specularMap.value=b.specularMap,n(b.specularMap,y.specularMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest);const E=e.get(b).envMap;if(E&&(y.envMap.value=E,y.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=b.reflectivity,y.ior.value=b.ior,y.refractionRatio.value=b.refractionRatio),b.lightMap){y.lightMap.value=b.lightMap;const w=t._useLegacyLights===!0?Math.PI:1;y.lightMapIntensity.value=b.lightMapIntensity*w,n(b.lightMap,y.lightMapTransform)}b.aoMap&&(y.aoMap.value=b.aoMap,y.aoMapIntensity.value=b.aoMapIntensity,n(b.aoMap,y.aoMapTransform))}function s(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform))}function l(y,b){y.dashSize.value=b.dashSize,y.totalSize.value=b.dashSize+b.gapSize,y.scale.value=b.scale}function c(y,b,E,w){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.size.value=b.size*E,y.scale.value=w*.5,b.map&&(y.map.value=b.map,n(b.map,y.uvTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function u(y,b){y.diffuse.value.copy(b.color),y.opacity.value=b.opacity,y.rotation.value=b.rotation,b.map&&(y.map.value=b.map,n(b.map,y.mapTransform)),b.alphaMap&&(y.alphaMap.value=b.alphaMap,n(b.alphaMap,y.alphaMapTransform)),b.alphaTest>0&&(y.alphaTest.value=b.alphaTest)}function d(y,b){y.specular.value.copy(b.specular),y.shininess.value=Math.max(b.shininess,1e-4)}function f(y,b){b.gradientMap&&(y.gradientMap.value=b.gradientMap)}function g(y,b){y.metalness.value=b.metalness,b.metalnessMap&&(y.metalnessMap.value=b.metalnessMap,n(b.metalnessMap,y.metalnessMapTransform)),y.roughness.value=b.roughness,b.roughnessMap&&(y.roughnessMap.value=b.roughnessMap,n(b.roughnessMap,y.roughnessMapTransform)),e.get(b).envMap&&(y.envMapIntensity.value=b.envMapIntensity)}function p(y,b,E){y.ior.value=b.ior,b.sheen>0&&(y.sheenColor.value.copy(b.sheenColor).multiplyScalar(b.sheen),y.sheenRoughness.value=b.sheenRoughness,b.sheenColorMap&&(y.sheenColorMap.value=b.sheenColorMap,n(b.sheenColorMap,y.sheenColorMapTransform)),b.sheenRoughnessMap&&(y.sheenRoughnessMap.value=b.sheenRoughnessMap,n(b.sheenRoughnessMap,y.sheenRoughnessMapTransform))),b.clearcoat>0&&(y.clearcoat.value=b.clearcoat,y.clearcoatRoughness.value=b.clearcoatRoughness,b.clearcoatMap&&(y.clearcoatMap.value=b.clearcoatMap,n(b.clearcoatMap,y.clearcoatMapTransform)),b.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=b.clearcoatRoughnessMap,n(b.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),b.clearcoatNormalMap&&(y.clearcoatNormalMap.value=b.clearcoatNormalMap,n(b.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(b.clearcoatNormalScale),b.side===ns&&y.clearcoatNormalScale.value.negate())),b.iridescence>0&&(y.iridescence.value=b.iridescence,y.iridescenceIOR.value=b.iridescenceIOR,y.iridescenceThicknessMinimum.value=b.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=b.iridescenceThicknessRange[1],b.iridescenceMap&&(y.iridescenceMap.value=b.iridescenceMap,n(b.iridescenceMap,y.iridescenceMapTransform)),b.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=b.iridescenceThicknessMap,n(b.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),b.transmission>0&&(y.transmission.value=b.transmission,y.transmissionSamplerMap.value=E.texture,y.transmissionSamplerSize.value.set(E.width,E.height),b.transmissionMap&&(y.transmissionMap.value=b.transmissionMap,n(b.transmissionMap,y.transmissionMapTransform)),y.thickness.value=b.thickness,b.thicknessMap&&(y.thicknessMap.value=b.thicknessMap,n(b.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=b.attenuationDistance,y.attenuationColor.value.copy(b.attenuationColor)),b.anisotropy>0&&(y.anisotropyVector.value.set(b.anisotropy*Math.cos(b.anisotropyRotation),b.anisotropy*Math.sin(b.anisotropyRotation)),b.anisotropyMap&&(y.anisotropyMap.value=b.anisotropyMap,n(b.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=b.specularIntensity,y.specularColor.value.copy(b.specularColor),b.specularColorMap&&(y.specularColorMap.value=b.specularColorMap,n(b.specularColorMap,y.specularColorMapTransform)),b.specularIntensityMap&&(y.specularIntensityMap.value=b.specularIntensityMap,n(b.specularIntensityMap,y.specularIntensityMapTransform))}function x(y,b){b.matcap&&(y.matcap.value=b.matcap)}function v(y,b){const E=e.get(b).light;y.referencePosition.value.setFromMatrixPosition(E.matrixWorld),y.nearDistance.value=E.shadow.camera.near,y.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function mUe(t,e,n,r){let i={},a={},s=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(E,w){const A=w.program;r.uniformBlockBinding(E,A)}function u(E,w){let A=i[E.id];A===void 0&&(x(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",y));const T=w.program;r.updateUBOMapping(E,T);const C=e.render.frame;a[E.id]!==C&&(g(E),a[E.id]=C)}function d(E){const w=f();E.__bindingPointIndex=w;const A=t.createBuffer(),T=E.__size,C=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,T,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,A),A}function f(){for(let E=0;E<l;E++)if(s.indexOf(E)===-1)return s.push(E),E;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(E){const w=i[E.id],A=E.uniforms,T=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let C=0,N=A.length;C<N;C++){const O=A[C];if(p(O,C,T)===!0){const k=O.__offset,j=Array.isArray(O.value)?O.value:[O.value];let B=0;for(let L=0;L<j.length;L++){const K=j[L],R=v(K);typeof K=="number"?(O.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,k+B,O.__data)):K.isMatrix3?(O.__data[0]=K.elements[0],O.__data[1]=K.elements[1],O.__data[2]=K.elements[2],O.__data[3]=K.elements[0],O.__data[4]=K.elements[3],O.__data[5]=K.elements[4],O.__data[6]=K.elements[5],O.__data[7]=K.elements[0],O.__data[8]=K.elements[6],O.__data[9]=K.elements[7],O.__data[10]=K.elements[8],O.__data[11]=K.elements[0]):(K.toArray(O.__data,B),B+=R.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,k,O.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(E,w,A){const T=E.value;if(A[w]===void 0){if(typeof T=="number")A[w]=T;else{const C=Array.isArray(T)?T:[T],N=[];for(let O=0;O<C.length;O++)N.push(C[O].clone());A[w]=N}return!0}else if(typeof T=="number"){if(A[w]!==T)return A[w]=T,!0}else{const C=Array.isArray(A[w])?A[w]:[A[w]],N=Array.isArray(T)?T:[T];for(let O=0;O<C.length;O++){const k=C[O];if(k.equals(N[O])===!1)return k.copy(N[O]),!0}}return!1}function x(E){const w=E.uniforms;let A=0;const T=16;let C=0;for(let N=0,O=w.length;N<O;N++){const k=w[N],j={boundary:0,storage:0},B=Array.isArray(k.value)?k.value:[k.value];for(let L=0,K=B.length;L<K;L++){const R=B[L],q=v(R);j.boundary+=q.boundary,j.storage+=q.storage}if(k.__data=new Float32Array(j.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=A,N>0){C=A%T;const L=T-C;C!==0&&L-j.boundary<0&&(A+=T-C,k.__offset=A)}A+=j.storage}return C=A%T,C>0&&(A+=T-C),E.__size=A,E.__cache={},this}function v(E){const w={boundary:0,storage:0};return typeof E=="number"?(w.boundary=4,w.storage=4):E.isVector2?(w.boundary=8,w.storage=8):E.isVector3||E.isColor?(w.boundary=16,w.storage=12):E.isVector4?(w.boundary=16,w.storage=16):E.isMatrix3?(w.boundary=48,w.storage=48):E.isMatrix4?(w.boundary=64,w.storage=64):E.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",E),w}function y(E){const w=E.target;w.removeEventListener("dispose",y);const A=s.indexOf(w.__bindingPointIndex);s.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function b(){for(const E in i)t.deleteBuffer(i[E]);s=[],i={},a={}}return{bind:c,update:u,dispose:b}}class oj{constructor(e={}){const{canvas:n=dLe(),context:r=null,depth:i=!0,stencil:a=!0,alpha:s=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let g;r!==null?g=r.getContextAttributes().alpha:g=s;const p=new Uint32Array(4),x=new Int32Array(4);let v=null,y=null;const b=[],E=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=ia,this._useLegacyLights=!1,this.toneMapping=ud,this.toneMappingExposure=1;const w=this;let A=!1,T=0,C=0,N=null,O=-1,k=null;const j=new cr,B=new cr;let L=null;const K=new Kt(0);let R=0,q=n.width,W=n.height,$=1,J=null,ee=null;const Q=new cr(0,0,q,W),z=new cr(0,0,q,W);let V=!1;const X=new sE;let te=!1,ie=!1,le=null;const ge=new yr,Ee=new tn,pe=new Oe,de={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Re(){return N===null?$:1}let fe=r;function Fe(he,ze){for(let et=0;et<he.length;et++){const st=he[et],rt=n.getContext(st,ze);if(rt!==null)return rt}return null}try{const he={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${rE}`),n.addEventListener("webglcontextlost",nt,!1),n.addEventListener("webglcontextrestored",xe,!1),n.addEventListener("webglcontextcreationerror",He,!1),fe===null){const ze=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&ze.shift(),fe=Fe(ze,he),fe===null)throw Fe(ze)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&fe instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),fe.getShaderPrecisionFormat===void 0&&(fe.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(he){throw console.error("THREE.WebGLRenderer: "+he.message),he}let U,H,re,G,Z,oe,be,Te,Me,F,I,ne,ve,Se,ye,Ke,We,qe,ut,ue,se,Ve,Be,Ze;function ht(){U=new E5e(fe),H=new b5e(fe,U,e),U.init(H),Ve=new cUe(fe,U,H),re=new oUe(fe,U,H),G=new N5e(fe),Z=new qFe,oe=new lUe(fe,U,re,Z,H,Ve,G),be=new v5e(w),Te=new M5e(w),Me=new OLe(fe,H),Be=new g5e(fe,U,Me,H),F=new A5e(fe,Me,G,Be),I=new j5e(fe,F,Me,G),ut=new P5e(fe,H,oe),Ke=new y5e(Z),ne=new WFe(w,be,Te,U,H,Be,Ke),ve=new fUe(w,Z),Se=new XFe,ye=new tUe(U,H),qe=new p5e(w,be,Te,re,I,g,c),We=new sUe(w,I,H),Ze=new mUe(fe,G,H,re),ue=new x5e(fe,U,G,H),se=new T5e(fe,U,G,H),G.programs=ne.programs,w.capabilities=H,w.extensions=U,w.properties=Z,w.renderLists=Se,w.shadowMap=We,w.state=re,w.info=G}ht();const me=new hUe(w,fe);this.xr=me,this.getContext=function(){return fe},this.getContextAttributes=function(){return fe.getContextAttributes()},this.forceContextLoss=function(){const he=U.get("WEBGL_lose_context");he&&he.loseContext()},this.forceContextRestore=function(){const he=U.get("WEBGL_lose_context");he&&he.restoreContext()},this.getPixelRatio=function(){return $},this.setPixelRatio=function(he){he!==void 0&&($=he,this.setSize(q,W,!1))},this.getSize=function(he){return he.set(q,W)},this.setSize=function(he,ze,et=!0){if(me.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}q=he,W=ze,n.width=Math.floor(he*$),n.height=Math.floor(ze*$),et===!0&&(n.style.width=he+"px",n.style.height=ze+"px"),this.setViewport(0,0,he,ze)},this.getDrawingBufferSize=function(he){return he.set(q*$,W*$).floor()},this.setDrawingBufferSize=function(he,ze,et){q=he,W=ze,$=et,n.width=Math.floor(he*et),n.height=Math.floor(ze*et),this.setViewport(0,0,he,ze)},this.getCurrentViewport=function(he){return he.copy(j)},this.getViewport=function(he){return he.copy(Q)},this.setViewport=function(he,ze,et,st){he.isVector4?Q.set(he.x,he.y,he.z,he.w):Q.set(he,ze,et,st),re.viewport(j.copy(Q).multiplyScalar($).floor())},this.getScissor=function(he){return he.copy(z)},this.setScissor=function(he,ze,et,st){he.isVector4?z.set(he.x,he.y,he.z,he.w):z.set(he,ze,et,st),re.scissor(B.copy(z).multiplyScalar($).floor())},this.getScissorTest=function(){return V},this.setScissorTest=function(he){re.setScissorTest(V=he)},this.setOpaqueSort=function(he){J=he},this.setTransparentSort=function(he){ee=he},this.getClearColor=function(he){return he.copy(qe.getClearColor())},this.setClearColor=function(){qe.setClearColor.apply(qe,arguments)},this.getClearAlpha=function(){return qe.getClearAlpha()},this.setClearAlpha=function(){qe.setClearAlpha.apply(qe,arguments)},this.clear=function(he=!0,ze=!0,et=!0){let st=0;if(he){let rt=!1;if(N!==null){const yt=N.texture.format;rt=yt===sQ||yt===aQ||yt===iQ}if(rt){const yt=N.texture.type,ae=yt===dd||yt===td||yt===zO||yt===Bh||yt===nQ||yt===rQ,Ne=qe.getClearColor(),Ue=qe.getClearAlpha(),Ie=Ne.r,je=Ne.g,ct=Ne.b;ae?(p[0]=Ie,p[1]=je,p[2]=ct,p[3]=Ue,fe.clearBufferuiv(fe.COLOR,0,p)):(x[0]=Ie,x[1]=je,x[2]=ct,x[3]=Ue,fe.clearBufferiv(fe.COLOR,0,x))}else st|=fe.COLOR_BUFFER_BIT}ze&&(st|=fe.DEPTH_BUFFER_BIT),et&&(st|=fe.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),fe.clear(st)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",nt,!1),n.removeEventListener("webglcontextrestored",xe,!1),n.removeEventListener("webglcontextcreationerror",He,!1),Se.dispose(),ye.dispose(),Z.dispose(),be.dispose(),Te.dispose(),I.dispose(),Be.dispose(),Ze.dispose(),ne.dispose(),me.dispose(),me.removeEventListener("sessionstart",Ut),me.removeEventListener("sessionend",Ct),le&&(le.dispose(),le=null),$t.stop()};function nt(he){he.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function xe(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const he=G.autoReset,ze=We.enabled,et=We.autoUpdate,st=We.needsUpdate,rt=We.type;ht(),G.autoReset=he,We.enabled=ze,We.autoUpdate=et,We.needsUpdate=st,We.type=rt}function He(he){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",he.statusMessage)}function Pe(he){const ze=he.target;ze.removeEventListener("dispose",Pe),we(ze)}function we(he){Ae(he),Z.remove(he)}function Ae(he){const ze=Z.get(he).programs;ze!==void 0&&(ze.forEach(function(et){ne.releaseProgram(et)}),he.isShaderMaterial&&ne.releaseShaderCache(he))}this.renderBufferDirect=function(he,ze,et,st,rt,yt){ze===null&&(ze=de);const ae=rt.isMesh&&rt.matrixWorld.determinant()<0,Ne=jn(he,ze,et,st,rt);re.setMaterial(st,ae);let Ue=et.index,Ie=1;if(st.wireframe===!0){if(Ue=F.getWireframeAttribute(et),Ue===void 0)return;Ie=2}const je=et.drawRange,ct=et.attributes.position;let xt=je.start*Ie,Tt=(je.start+je.count)*Ie;yt!==null&&(xt=Math.max(xt,yt.start*Ie),Tt=Math.min(Tt,(yt.start+yt.count)*Ie)),Ue!==null?(xt=Math.max(xt,0),Tt=Math.min(Tt,Ue.count)):ct!=null&&(xt=Math.max(xt,0),Tt=Math.min(Tt,ct.count));const Et=Tt-xt;if(Et<0||Et===1/0)return;Be.setup(rt,st,Ne,et,Ue);let Ft,Pt=ue;if(Ue!==null&&(Ft=Me.get(Ue),Pt=se,Pt.setIndex(Ft)),rt.isMesh)st.wireframe===!0?(re.setLineWidth(st.wireframeLinewidth*Re()),Pt.setMode(fe.LINES)):Pt.setMode(fe.TRIANGLES);else if(rt.isLine){let wt=st.linewidth;wt===void 0&&(wt=1),re.setLineWidth(wt*Re()),rt.isLineSegments?Pt.setMode(fe.LINES):rt.isLineLoop?Pt.setMode(fe.LINE_LOOP):Pt.setMode(fe.LINE_STRIP)}else rt.isPoints?Pt.setMode(fe.POINTS):rt.isSprite&&Pt.setMode(fe.TRIANGLES);if(rt.isBatchedMesh)Pt.renderMultiDraw(rt._multiDrawStarts,rt._multiDrawCounts,rt._multiDrawCount);else if(rt.isInstancedMesh)Pt.renderInstances(xt,Et,rt.count);else if(et.isInstancedBufferGeometry){const wt=et._maxInstanceCount!==void 0?et._maxInstanceCount:1/0,Jt=Math.min(et.instanceCount,wt);Pt.renderInstances(xt,Et,Jt)}else Pt.render(xt,Et)};function lt(he,ze,et){he.transparent===!0&&he.side===wc&&he.forceSinglePass===!1?(he.side=ns,he.needsUpdate=!0,er(he,ze,et),he.side=Ad,he.needsUpdate=!0,er(he,ze,et),he.side=wc):er(he,ze,et)}this.compile=function(he,ze,et=null){et===null&&(et=he),y=ye.get(et),y.init(),E.push(y),et.traverseVisible(function(rt){rt.isLight&&rt.layers.test(ze.layers)&&(y.pushLight(rt),rt.castShadow&&y.pushShadow(rt))}),he!==et&&he.traverseVisible(function(rt){rt.isLight&&rt.layers.test(ze.layers)&&(y.pushLight(rt),rt.castShadow&&y.pushShadow(rt))}),y.setupLights(w._useLegacyLights);const st=new Set;return he.traverse(function(rt){const yt=rt.material;if(yt)if(Array.isArray(yt))for(let ae=0;ae<yt.length;ae++){const Ne=yt[ae];lt(Ne,et,rt),st.add(Ne)}else lt(yt,et,rt),st.add(yt)}),E.pop(),y=null,st},this.compileAsync=function(he,ze,et=null){const st=this.compile(he,ze,et);return new Promise(rt=>{function yt(){if(st.forEach(function(ae){Z.get(ae).currentProgram.isReady()&&st.delete(ae)}),st.size===0){rt(he);return}setTimeout(yt,10)}U.get("KHR_parallel_shader_compile")!==null?yt():setTimeout(yt,10)})};let _t=null;function Xe(he){_t&&_t(he)}function Ut(){$t.stop()}function Ct(){$t.start()}const $t=new MQ;$t.setAnimationLoop(Xe),typeof self<"u"&&$t.setContext(self),this.setAnimationLoop=function(he){_t=he,me.setAnimationLoop(he),he===null?$t.stop():$t.start()},me.addEventListener("sessionstart",Ut),me.addEventListener("sessionend",Ct),this.render=function(he,ze){if(ze!==void 0&&ze.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;he.matrixWorldAutoUpdate===!0&&he.updateMatrixWorld(),ze.parent===null&&ze.matrixWorldAutoUpdate===!0&&ze.updateMatrixWorld(),me.enabled===!0&&me.isPresenting===!0&&(me.cameraAutoUpdate===!0&&me.updateCamera(ze),ze=me.getCamera()),he.isScene===!0&&he.onBeforeRender(w,he,ze,N),y=ye.get(he,E.length),y.init(),E.push(y),ge.multiplyMatrices(ze.projectionMatrix,ze.matrixWorldInverse),X.setFromProjectionMatrix(ge),ie=this.localClippingEnabled,te=Ke.init(this.clippingPlanes,ie),v=Se.get(he,b.length),v.init(),b.push(v),gn(he,ze,0,w.sortObjects),v.finish(),w.sortObjects===!0&&v.sort(J,ee),this.info.render.frame++,te===!0&&Ke.beginShadows();const et=y.state.shadowsArray;if(We.render(et,he,ze),te===!0&&Ke.endShadows(),this.info.autoReset===!0&&this.info.reset(),qe.render(v,he),y.setupLights(w._useLegacyLights),ze.isArrayCamera){const st=ze.cameras;for(let rt=0,yt=st.length;rt<yt;rt++){const ae=st[rt];Fn(v,he,ae,ae.viewport)}}else Fn(v,he,ze);N!==null&&(oe.updateMultisampleRenderTarget(N),oe.updateRenderTargetMipmap(N)),he.isScene===!0&&he.onAfterRender(w,he,ze),Be.resetDefaultState(),O=-1,k=null,E.pop(),E.length>0?y=E[E.length-1]:y=null,b.pop(),b.length>0?v=b[b.length-1]:v=null};function gn(he,ze,et,st){if(he.visible===!1)return;if(he.layers.test(ze.layers)){if(he.isGroup)et=he.renderOrder;else if(he.isLOD)he.autoUpdate===!0&&he.update(ze);else if(he.isLight)y.pushLight(he),he.castShadow&&y.pushShadow(he);else if(he.isSprite){if(!he.frustumCulled||X.intersectsSprite(he)){st&&pe.setFromMatrixPosition(he.matrixWorld).applyMatrix4(ge);const ae=I.update(he),Ne=he.material;Ne.visible&&v.push(he,ae,Ne,et,pe.z,null)}}else if((he.isMesh||he.isLine||he.isPoints)&&(!he.frustumCulled||X.intersectsObject(he))){const ae=I.update(he),Ne=he.material;if(st&&(he.boundingSphere!==void 0?(he.boundingSphere===null&&he.computeBoundingSphere(),pe.copy(he.boundingSphere.center)):(ae.boundingSphere===null&&ae.computeBoundingSphere(),pe.copy(ae.boundingSphere.center)),pe.applyMatrix4(he.matrixWorld).applyMatrix4(ge)),Array.isArray(Ne)){const Ue=ae.groups;for(let Ie=0,je=Ue.length;Ie<je;Ie++){const ct=Ue[Ie],xt=Ne[ct.materialIndex];xt&&xt.visible&&v.push(he,ae,xt,et,pe.z,ct)}}else Ne.visible&&v.push(he,ae,Ne,et,pe.z,null)}}const yt=he.children;for(let ae=0,Ne=yt.length;ae<Ne;ae++)gn(yt[ae],ze,et,st)}function Fn(he,ze,et,st){const rt=he.opaque,yt=he.transmissive,ae=he.transparent;y.setupLightsView(et),te===!0&&Ke.setGlobalState(w.clippingPlanes,et),yt.length>0&&It(rt,yt,ze,et),st&&re.viewport(j.copy(st)),rt.length>0&&Yt(rt,ze,et),yt.length>0&&Yt(yt,ze,et),ae.length>0&&Yt(ae,ze,et),re.buffers.depth.setTest(!0),re.buffers.depth.setMask(!0),re.buffers.color.setMask(!0),re.setPolygonOffset(!1)}function It(he,ze,et,st){if((et.isScene===!0?et.overrideMaterial:null)!==null)return;const yt=H.isWebGL2;le===null&&(le=new bf(1,1,{generateMipmaps:!0,type:U.has("EXT_color_buffer_half_float")?ab:dd,minFilter:ib,samples:yt?4:0})),w.getDrawingBufferSize(Ee),yt?le.setSize(Ee.x,Ee.y):le.setSize(Qw(Ee.x),Qw(Ee.y));const ae=w.getRenderTarget();w.setRenderTarget(le),w.getClearColor(K),R=w.getClearAlpha(),R<1&&w.setClearColor(16777215,.5),w.clear();const Ne=w.toneMapping;w.toneMapping=ud,Yt(he,et,st),oe.updateMultisampleRenderTarget(le),oe.updateRenderTargetMipmap(le);let Ue=!1;for(let Ie=0,je=ze.length;Ie<je;Ie++){const ct=ze[Ie],xt=ct.object,Tt=ct.geometry,Et=ct.material,Ft=ct.group;if(Et.side===wc&&xt.layers.test(st.layers)){const Pt=Et.side;Et.side=ns,Et.needsUpdate=!0,Jn(xt,et,st,Tt,Et,Ft),Et.side=Pt,Et.needsUpdate=!0,Ue=!0}}Ue===!0&&(oe.updateMultisampleRenderTarget(le),oe.updateRenderTargetMipmap(le)),w.setRenderTarget(ae),w.setClearColor(K,R),w.toneMapping=Ne}function Yt(he,ze,et){const st=ze.isScene===!0?ze.overrideMaterial:null;for(let rt=0,yt=he.length;rt<yt;rt++){const ae=he[rt],Ne=ae.object,Ue=ae.geometry,Ie=st===null?ae.material:st,je=ae.group;Ne.layers.test(et.layers)&&Jn(Ne,ze,et,Ue,Ie,je)}}function Jn(he,ze,et,st,rt,yt){he.onBeforeRender(w,ze,et,st,rt,yt),he.modelViewMatrix.multiplyMatrices(et.matrixWorldInverse,he.matrixWorld),he.normalMatrix.getNormalMatrix(he.modelViewMatrix),rt.onBeforeRender(w,ze,et,st,he,yt),rt.transparent===!0&&rt.side===wc&&rt.forceSinglePass===!1?(rt.side=ns,rt.needsUpdate=!0,w.renderBufferDirect(et,ze,st,rt,he,yt),rt.side=Ad,rt.needsUpdate=!0,w.renderBufferDirect(et,ze,st,rt,he,yt),rt.side=wc):w.renderBufferDirect(et,ze,st,rt,he,yt),he.onAfterRender(w,ze,et,st,rt,yt)}function er(he,ze,et){ze.isScene!==!0&&(ze=de);const st=Z.get(he),rt=y.state.lights,yt=y.state.shadowsArray,ae=rt.state.version,Ne=ne.getParameters(he,rt.state,yt,ze,et),Ue=ne.getProgramCacheKey(Ne);let Ie=st.programs;st.environment=he.isMeshStandardMaterial?ze.environment:null,st.fog=ze.fog,st.envMap=(he.isMeshStandardMaterial?Te:be).get(he.envMap||st.environment),Ie===void 0&&(he.addEventListener("dispose",Pe),Ie=new Map,st.programs=Ie);let je=Ie.get(Ue);if(je!==void 0){if(st.currentProgram===je&&st.lightsStateVersion===ae)return Un(he,Ne),je}else Ne.uniforms=ne.getUniforms(he),he.onBuild(et,Ne,w),he.onBeforeCompile(Ne,w),je=ne.acquireProgram(Ne,Ue),Ie.set(Ue,je),st.uniforms=Ne.uniforms;const ct=st.uniforms;return(!he.isShaderMaterial&&!he.isRawShaderMaterial||he.clipping===!0)&&(ct.clippingPlanes=Ke.uniform),Un(he,Ne),st.needsLights=Le(he),st.lightsStateVersion=ae,st.needsLights&&(ct.ambientLightColor.value=rt.state.ambient,ct.lightProbe.value=rt.state.probe,ct.directionalLights.value=rt.state.directional,ct.directionalLightShadows.value=rt.state.directionalShadow,ct.spotLights.value=rt.state.spot,ct.spotLightShadows.value=rt.state.spotShadow,ct.rectAreaLights.value=rt.state.rectArea,ct.ltc_1.value=rt.state.rectAreaLTC1,ct.ltc_2.value=rt.state.rectAreaLTC2,ct.pointLights.value=rt.state.point,ct.pointLightShadows.value=rt.state.pointShadow,ct.hemisphereLights.value=rt.state.hemi,ct.directionalShadowMap.value=rt.state.directionalShadowMap,ct.directionalShadowMatrix.value=rt.state.directionalShadowMatrix,ct.spotShadowMap.value=rt.state.spotShadowMap,ct.spotLightMatrix.value=rt.state.spotLightMatrix,ct.spotLightMap.value=rt.state.spotLightMap,ct.pointShadowMap.value=rt.state.pointShadowMap,ct.pointShadowMatrix.value=rt.state.pointShadowMatrix),st.currentProgram=je,st.uniformsList=null,je}function Hn(he){if(he.uniformsList===null){const ze=he.currentProgram.getUniforms();he.uniformsList=N1.seqWithValue(ze.seq,he.uniforms)}return he.uniformsList}function Un(he,ze){const et=Z.get(he);et.outputColorSpace=ze.outputColorSpace,et.batching=ze.batching,et.instancing=ze.instancing,et.instancingColor=ze.instancingColor,et.skinning=ze.skinning,et.morphTargets=ze.morphTargets,et.morphNormals=ze.morphNormals,et.morphColors=ze.morphColors,et.morphTargetsCount=ze.morphTargetsCount,et.numClippingPlanes=ze.numClippingPlanes,et.numIntersection=ze.numClipIntersection,et.vertexAlphas=ze.vertexAlphas,et.vertexTangents=ze.vertexTangents,et.toneMapping=ze.toneMapping}function jn(he,ze,et,st,rt){ze.isScene!==!0&&(ze=de),oe.resetTextureUnits();const yt=ze.fog,ae=st.isMeshStandardMaterial?ze.environment:null,Ne=N===null?w.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:Yc,Ue=(st.isMeshStandardMaterial?Te:be).get(st.envMap||ae),Ie=st.vertexColors===!0&&!!et.attributes.color&&et.attributes.color.itemSize===4,je=!!et.attributes.tangent&&(!!st.normalMap||st.anisotropy>0),ct=!!et.morphAttributes.position,xt=!!et.morphAttributes.normal,Tt=!!et.morphAttributes.color;let Et=ud;st.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(Et=w.toneMapping);const Ft=et.morphAttributes.position||et.morphAttributes.normal||et.morphAttributes.color,Pt=Ft!==void 0?Ft.length:0,wt=Z.get(st),Jt=y.state.lights;if(te===!0&&(ie===!0||he!==k)){const qr=he===k&&st.id===O;Ke.setState(st,he,qr)}let Ht=!1;st.version===wt.__version?(wt.needsLights&&wt.lightsStateVersion!==Jt.state.version||wt.outputColorSpace!==Ne||rt.isBatchedMesh&&wt.batching===!1||!rt.isBatchedMesh&&wt.batching===!0||rt.isInstancedMesh&&wt.instancing===!1||!rt.isInstancedMesh&&wt.instancing===!0||rt.isSkinnedMesh&&wt.skinning===!1||!rt.isSkinnedMesh&&wt.skinning===!0||rt.isInstancedMesh&&wt.instancingColor===!0&&rt.instanceColor===null||rt.isInstancedMesh&&wt.instancingColor===!1&&rt.instanceColor!==null||wt.envMap!==Ue||st.fog===!0&&wt.fog!==yt||wt.numClippingPlanes!==void 0&&(wt.numClippingPlanes!==Ke.numPlanes||wt.numIntersection!==Ke.numIntersection)||wt.vertexAlphas!==Ie||wt.vertexTangents!==je||wt.morphTargets!==ct||wt.morphNormals!==xt||wt.morphColors!==Tt||wt.toneMapping!==Et||H.isWebGL2===!0&&wt.morphTargetsCount!==Pt)&&(Ht=!0):(Ht=!0,wt.__version=st.version);let cn=wt.currentProgram;Ht===!0&&(cn=er(st,ze,rt));let bn=!1,Mn=!1,Bt=!1;const nn=cn.getUniforms(),an=wt.uniforms;if(re.useProgram(cn.program)&&(bn=!0,Mn=!0,Bt=!0),st.id!==O&&(O=st.id,Mn=!0),bn||k!==he){nn.setValue(fe,"projectionMatrix",he.projectionMatrix),nn.setValue(fe,"viewMatrix",he.matrixWorldInverse);const qr=nn.map.cameraPosition;qr!==void 0&&qr.setValue(fe,pe.setFromMatrixPosition(he.matrixWorld)),H.logarithmicDepthBuffer&&nn.setValue(fe,"logDepthBufFC",2/(Math.log(he.far+1)/Math.LN2)),(st.isMeshPhongMaterial||st.isMeshToonMaterial||st.isMeshLambertMaterial||st.isMeshBasicMaterial||st.isMeshStandardMaterial||st.isShaderMaterial)&&nn.setValue(fe,"isOrthographic",he.isOrthographicCamera===!0),k!==he&&(k=he,Mn=!0,Bt=!0)}if(rt.isSkinnedMesh){nn.setOptional(fe,rt,"bindMatrix"),nn.setOptional(fe,rt,"bindMatrixInverse");const qr=rt.skeleton;qr&&(H.floatVertexTextures?(qr.boneTexture===null&&qr.computeBoneTexture(),nn.setValue(fe,"boneTexture",qr.boneTexture,oe)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}rt.isBatchedMesh&&(nn.setOptional(fe,rt,"batchingTexture"),nn.setValue(fe,"batchingTexture",rt._matricesTexture,oe));const Ur=et.morphAttributes;if((Ur.position!==void 0||Ur.normal!==void 0||Ur.color!==void 0&&H.isWebGL2===!0)&&ut.update(rt,et,cn),(Mn||wt.receiveShadow!==rt.receiveShadow)&&(wt.receiveShadow=rt.receiveShadow,nn.setValue(fe,"receiveShadow",rt.receiveShadow)),st.isMeshGouraudMaterial&&st.envMap!==null&&(an.envMap.value=Ue,an.flipEnvMap.value=Ue.isCubeTexture&&Ue.isRenderTargetTexture===!1?-1:1),Mn&&(nn.setValue(fe,"toneMappingExposure",w.toneMappingExposure),wt.needsLights&&sn(an,Bt),yt&&st.fog===!0&&ve.refreshFogUniforms(an,yt),ve.refreshMaterialUniforms(an,st,$,W,le),N1.upload(fe,Hn(wt),an,oe)),st.isShaderMaterial&&st.uniformsNeedUpdate===!0&&(N1.upload(fe,Hn(wt),an,oe),st.uniformsNeedUpdate=!1),st.isSpriteMaterial&&nn.setValue(fe,"center",rt.center),nn.setValue(fe,"modelViewMatrix",rt.modelViewMatrix),nn.setValue(fe,"normalMatrix",rt.normalMatrix),nn.setValue(fe,"modelMatrix",rt.matrixWorld),st.isShaderMaterial||st.isRawShaderMaterial){const qr=st.uniformsGroups;for(let $n=0,wo=qr.length;$n<wo;$n++)if(H.isWebGL2){const Wn=qr[$n];Ze.update(Wn,cn),Ze.bind(Wn,cn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return cn}function sn(he,ze){he.ambientLightColor.needsUpdate=ze,he.lightProbe.needsUpdate=ze,he.directionalLights.needsUpdate=ze,he.directionalLightShadows.needsUpdate=ze,he.pointLights.needsUpdate=ze,he.pointLightShadows.needsUpdate=ze,he.spotLights.needsUpdate=ze,he.spotLightShadows.needsUpdate=ze,he.rectAreaLights.needsUpdate=ze,he.hemisphereLights.needsUpdate=ze}function Le(he){return he.isMeshLambertMaterial||he.isMeshToonMaterial||he.isMeshPhongMaterial||he.isMeshStandardMaterial||he.isShadowMaterial||he.isShaderMaterial&&he.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(he,ze,et){Z.get(he.texture).__webglTexture=ze,Z.get(he.depthTexture).__webglTexture=et;const st=Z.get(he);st.__hasExternalTextures=!0,st.__hasExternalTextures&&(st.__autoAllocateDepthBuffer=et===void 0,st.__autoAllocateDepthBuffer||U.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),st.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(he,ze){const et=Z.get(he);et.__webglFramebuffer=ze,et.__useDefaultFramebuffer=ze===void 0},this.setRenderTarget=function(he,ze=0,et=0){N=he,T=ze,C=et;let st=!0,rt=null,yt=!1,ae=!1;if(he){const Ue=Z.get(he);Ue.__useDefaultFramebuffer!==void 0?(re.bindFramebuffer(fe.FRAMEBUFFER,null),st=!1):Ue.__webglFramebuffer===void 0?oe.setupRenderTarget(he):Ue.__hasExternalTextures&&oe.rebindTextures(he,Z.get(he.texture).__webglTexture,Z.get(he.depthTexture).__webglTexture);const Ie=he.texture;(Ie.isData3DTexture||Ie.isDataArrayTexture||Ie.isCompressedArrayTexture)&&(ae=!0);const je=Z.get(he).__webglFramebuffer;he.isWebGLCubeRenderTarget?(Array.isArray(je[ze])?rt=je[ze][et]:rt=je[ze],yt=!0):H.isWebGL2&&he.samples>0&&oe.useMultisampledRTT(he)===!1?rt=Z.get(he).__webglMultisampledFramebuffer:Array.isArray(je)?rt=je[et]:rt=je,j.copy(he.viewport),B.copy(he.scissor),L=he.scissorTest}else j.copy(Q).multiplyScalar($).floor(),B.copy(z).multiplyScalar($).floor(),L=V;if(re.bindFramebuffer(fe.FRAMEBUFFER,rt)&&H.drawBuffers&&st&&re.drawBuffers(he,rt),re.viewport(j),re.scissor(B),re.setScissorTest(L),yt){const Ue=Z.get(he.texture);fe.framebufferTexture2D(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,fe.TEXTURE_CUBE_MAP_POSITIVE_X+ze,Ue.__webglTexture,et)}else if(ae){const Ue=Z.get(he.texture),Ie=ze||0;fe.framebufferTextureLayer(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,Ue.__webglTexture,et||0,Ie)}O=-1},this.readRenderTargetPixels=function(he,ze,et,st,rt,yt,ae){if(!(he&&he.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ne=Z.get(he).__webglFramebuffer;if(he.isWebGLCubeRenderTarget&&ae!==void 0&&(Ne=Ne[ae]),Ne){re.bindFramebuffer(fe.FRAMEBUFFER,Ne);try{const Ue=he.texture,Ie=Ue.format,je=Ue.type;if(Ie!==ro&&Ve.convert(Ie)!==fe.getParameter(fe.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ct=je===ab&&(U.has("EXT_color_buffer_half_float")||H.isWebGL2&&U.has("EXT_color_buffer_float"));if(je!==dd&&Ve.convert(je)!==fe.getParameter(fe.IMPLEMENTATION_COLOR_READ_TYPE)&&!(je===Cc&&(H.isWebGL2||U.has("OES_texture_float")||U.has("WEBGL_color_buffer_float")))&&!ct){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ze>=0&&ze<=he.width-st&&et>=0&&et<=he.height-rt&&fe.readPixels(ze,et,st,rt,Ve.convert(Ie),Ve.convert(je),yt)}finally{const Ue=N!==null?Z.get(N).__webglFramebuffer:null;re.bindFramebuffer(fe.FRAMEBUFFER,Ue)}}},this.copyFramebufferToTexture=function(he,ze,et=0){const st=Math.pow(2,-et),rt=Math.floor(ze.image.width*st),yt=Math.floor(ze.image.height*st);oe.setTexture2D(ze,0),fe.copyTexSubImage2D(fe.TEXTURE_2D,et,0,0,he.x,he.y,rt,yt),re.unbindTexture()},this.copyTextureToTexture=function(he,ze,et,st=0){const rt=ze.image.width,yt=ze.image.height,ae=Ve.convert(et.format),Ne=Ve.convert(et.type);oe.setTexture2D(et,0),fe.pixelStorei(fe.UNPACK_FLIP_Y_WEBGL,et.flipY),fe.pixelStorei(fe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,et.premultiplyAlpha),fe.pixelStorei(fe.UNPACK_ALIGNMENT,et.unpackAlignment),ze.isDataTexture?fe.texSubImage2D(fe.TEXTURE_2D,st,he.x,he.y,rt,yt,ae,Ne,ze.image.data):ze.isCompressedTexture?fe.compressedTexSubImage2D(fe.TEXTURE_2D,st,he.x,he.y,ze.mipmaps[0].width,ze.mipmaps[0].height,ae,ze.mipmaps[0].data):fe.texSubImage2D(fe.TEXTURE_2D,st,he.x,he.y,ae,Ne,ze.image),st===0&&et.generateMipmaps&&fe.generateMipmap(fe.TEXTURE_2D),re.unbindTexture()},this.copyTextureToTexture3D=function(he,ze,et,st,rt=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const yt=he.max.x-he.min.x+1,ae=he.max.y-he.min.y+1,Ne=he.max.z-he.min.z+1,Ue=Ve.convert(st.format),Ie=Ve.convert(st.type);let je;if(st.isData3DTexture)oe.setTexture3D(st,0),je=fe.TEXTURE_3D;else if(st.isDataArrayTexture)oe.setTexture2DArray(st,0),je=fe.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}fe.pixelStorei(fe.UNPACK_FLIP_Y_WEBGL,st.flipY),fe.pixelStorei(fe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,st.premultiplyAlpha),fe.pixelStorei(fe.UNPACK_ALIGNMENT,st.unpackAlignment);const ct=fe.getParameter(fe.UNPACK_ROW_LENGTH),xt=fe.getParameter(fe.UNPACK_IMAGE_HEIGHT),Tt=fe.getParameter(fe.UNPACK_SKIP_PIXELS),Et=fe.getParameter(fe.UNPACK_SKIP_ROWS),Ft=fe.getParameter(fe.UNPACK_SKIP_IMAGES),Pt=et.isCompressedTexture?et.mipmaps[0]:et.image;fe.pixelStorei(fe.UNPACK_ROW_LENGTH,Pt.width),fe.pixelStorei(fe.UNPACK_IMAGE_HEIGHT,Pt.height),fe.pixelStorei(fe.UNPACK_SKIP_PIXELS,he.min.x),fe.pixelStorei(fe.UNPACK_SKIP_ROWS,he.min.y),fe.pixelStorei(fe.UNPACK_SKIP_IMAGES,he.min.z),et.isDataTexture||et.isData3DTexture?fe.texSubImage3D(je,rt,ze.x,ze.y,ze.z,yt,ae,Ne,Ue,Ie,Pt.data):et.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),fe.compressedTexSubImage3D(je,rt,ze.x,ze.y,ze.z,yt,ae,Ne,Ue,Pt.data)):fe.texSubImage3D(je,rt,ze.x,ze.y,ze.z,yt,ae,Ne,Ue,Ie,Pt),fe.pixelStorei(fe.UNPACK_ROW_LENGTH,ct),fe.pixelStorei(fe.UNPACK_IMAGE_HEIGHT,xt),fe.pixelStorei(fe.UNPACK_SKIP_PIXELS,Tt),fe.pixelStorei(fe.UNPACK_SKIP_ROWS,Et),fe.pixelStorei(fe.UNPACK_SKIP_IMAGES,Ft),rt===0&&st.generateMipmaps&&fe.generateMipmap(je),re.unbindTexture()},this.initTexture=function(he){he.isCubeTexture?oe.setTextureCube(he,0):he.isData3DTexture?oe.setTexture3D(he,0):he.isDataArrayTexture||he.isCompressedArrayTexture?oe.setTexture2DArray(he,0):oe.setTexture2D(he,0),re.unbindTexture()},this.resetState=function(){T=0,C=0,N=null,re.reset(),Be.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return gl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===BO?"display-p3":"srgb",n.unpackColorSpace=or.workingColorSpace===aE?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===ia?$h:lQ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===$h?ia:Yc}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class pUe extends oj{}pUe.prototype.isWebGL1Renderer=!0;class qO{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new Kt(e),this.near=n,this.far=r}clone(){return new qO(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class gUe extends Da{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const n=super.toJSON(e);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n}}class xUe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=rj,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Lc()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,r){e*=this.stride,r*=n.stride;for(let i=0,a=this.stride;i<a;i++)this.array[e+i]=n.array[r+i];return this}set(e,n=0){return this.array.set(e,n),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Lc()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const n=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(n,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Lc()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Aa=new Oe;class nd{constructor(e,n,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=n,this.offset=r,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let n=0,r=this.data.count;n<r;n++)Aa.fromBufferAttribute(this,n),Aa.applyMatrix4(e),this.setXYZ(n,Aa.x,Aa.y,Aa.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Aa.fromBufferAttribute(this,n),Aa.applyNormalMatrix(e),this.setXYZ(n,Aa.x,Aa.y,Aa.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Aa.fromBufferAttribute(this,n),Aa.transformDirection(e),this.setXYZ(n,Aa.x,Aa.y,Aa.z);return this}setX(e,n){return this.normalized&&(n=sr(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=sr(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=sr(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=sr(n,this.array)),this.data.array[e*this.data.stride+this.offset+3]=n,this}getX(e){let n=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(n=hl(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=hl(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=hl(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=hl(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=sr(n,this.array),r=sr(r,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this}setXYZ(e,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(n=sr(n,this.array),r=sr(r,this.array),i=sr(i,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e=e*this.data.stride+this.offset,this.normalized&&(n=sr(n,this.array),r=sr(r,this.array),i=sr(i,this.array),a=sr(a,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=a,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return new Ps(new this.array.constructor(n),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new nd(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class bUe extends rs{constructor(e=null,n=1,r=1,i,a,s,l,c,u=ra,d=ra,f,g){super(null,s,l,c,u,d,i,a,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function yUe(t,e){return t.z-e.z}function vUe(t,e){return e.z-t.z}class _Ue{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,n){const r=this.pool,i=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1});const a=r[this.index];i.push(a),this.index++,a.start=e.start,a.count=e.count,a.z=n}reset(){this.list.length=0,this.index=0}}const Wm="batchId",Iu=new yr,BV=new yr,wUe=new yr,HV=new yr,BC=new sE,z_=new ho,uh=new bl,zx=new Oe,HC=new _Ue,ga=new Uo,B_=[];function SUe(t,e,n=0){const r=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const i=t.count;for(let a=0;a<i;a++)for(let s=0;s<r;s++)e.setComponent(a+n,s,t.getComponent(a,s))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class MUe extends Uo{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new Sa,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=e,this._maxVertexCount=n,this._maxIndexCount=r,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const n=new Float32Array(e*e*4),r=new bUe(n,e,e,ro,Cc);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const l in e.attributes){const c=e.getAttribute(l),{array:u,itemSize:d,normalized:f}=c,g=new u.constructor(r*d),p=new c.constructor(g,d,f);p.setUsage(c.usage),n.setAttribute(l,p)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new Ps(l,1))}const s=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Wm,new Ps(s,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Wm))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Wm}"`);const n=this.geometry;if(!!e.getIndex()!=!!n.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const r in n.attributes){if(r===Wm)continue;if(!e.hasAttribute(r))throw new Error(`BatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),a=n.getAttribute(r);if(i.itemSize!==a.itemSize||i.normalized!==a.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ho);const e=this._geometryCount,n=this.boundingBox,r=this._active;n.makeEmpty();for(let i=0;i<e;i++)r[i]!==!1&&(this.getMatrixAt(i,Iu),this.getBoundingBoxAt(i,z_).applyMatrix4(Iu),n.union(z_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new bl);const e=this._geometryCount,n=this.boundingSphere,r=this._active;n.makeEmpty();for(let i=0;i<e;i++)r[i]!==!1&&(this.getMatrixAt(i,Iu),this.getBoundingSphereAt(i,uh).applyMatrix4(Iu),n.union(uh))}addGeometry(e,n=-1,r=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let a=null;const s=this._reservedRanges,l=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(a=s[s.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,a===null?i.vertexStart=0:i.vertexStart=a.vertexStart+a.vertexCount;const u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.count:i.indexCount=r,a===null?i.indexStart=0:i.indexStart=a.indexStart+a.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const f=this._visibility,g=this._active,p=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),g.push(!0);const v=this._geometryCount;this._geometryCount++,wUe.toArray(x,v*16),p.needsUpdate=!0,s.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new ho,sphereInitialized:!1,sphere:new bl});const y=this.geometry.getAttribute(Wm);for(let b=0;b<i.vertexCount;b++)y.setX(i.vertexStart+b,v);return y.needsUpdate=!0,this.setGeometryAt(v,e),v}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,a=r.getIndex(),s=n.getIndex(),l=this._reservedRanges[e];if(i&&s.count>l.indexCount||n.attributes.position.count>l.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=l.vertexStart,u=l.vertexCount;for(const p in r.attributes){if(p===Wm)continue;const x=n.getAttribute(p),v=r.getAttribute(p);SUe(x,v,c);const y=x.itemSize;for(let b=x.count,E=u;b<E;b++){const w=c+b;for(let A=0;A<y;A++)v.setComponent(w,A,0)}v.needsUpdate=!0}if(i){const p=l.indexStart;for(let x=0;x<s.count;x++)a.setX(p+x,c+s.getX(x));for(let x=s.count,v=l.indexCount;x<v;x++)a.setX(p+x,c);a.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],g=n.getAttribute("position");return f.count=i?s.count:g.count,this._visibilityChanged=!0,e}deleteGeometry(e){const n=this._active;return e>=n.length||n[e]===!1?this:(n[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.box,s=this.geometry;if(i.boxInitialized===!1){a.makeEmpty();const l=s.index,c=s.attributes.position,u=this._drawRanges[e];for(let d=u.start,f=u.start+u.count;d<f;d++){let g=d;l&&(g=l.getX(g)),a.expandByPoint(zx.fromBufferAttribute(c,g))}i.boxInitialized=!0}return n.copy(a),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.sphere,s=this.geometry;if(i.sphereInitialized===!1){a.makeEmpty(),this.getBoundingBoxAt(e,z_),z_.getCenter(a.center);const l=s.index,c=s.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,g=u.start+u.count;f<g;f++){let p=f;l&&(p=l.getX(p)),zx.fromBufferAttribute(c,p),d=Math.max(d,a.center.distanceToSquared(zx))}a.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(a),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,a=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||r[e]===!1?this:(n.toArray(a,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,a=this._geometryCount;return e>=a||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,a=this._drawRanges,s=this._geometryCount,l=this.matrixWorld,c=this.geometry;ga.material=this.material,ga.geometry.index=c.index,ga.geometry.attributes=c.attributes,ga.geometry.boundingBox===null&&(ga.geometry.boundingBox=new ho),ga.geometry.boundingSphere===null&&(ga.geometry.boundingSphere=new bl);for(let u=0;u<s;u++){if(!r[u]||!i[u])continue;const d=a[u];ga.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,ga.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,ga.geometry.boundingBox),this.getBoundingSphereAt(u,ga.geometry.boundingSphere),ga.raycast(e,B_);for(let f=0,g=B_.length;f<g;f++){const p=B_[f];p.object=this,p.batchId=u,n.push(p)}B_.length=0}ga.material=null,ga.geometry.index=null,ga.geometry.attributes={},ga.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,r,i,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=i.getIndex(),l=s===null?1:s.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,g=this.perObjectFrustumCulled;g&&(HV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),BC.setFromProjectionMatrix(HV,e.isWebGPURenderer?sb:gl));let p=0;if(this.sortObjects){BV.copy(this.matrixWorld).invert(),zx.setFromMatrixPosition(r.matrixWorld).applyMatrix4(BV);for(let y=0,b=c.length;y<b;y++)if(c[y]){this.getMatrixAt(y,Iu),this.getBoundingSphereAt(y,uh).applyMatrix4(Iu);let E=!1;if(g&&(E=!BC.intersectsSphere(uh)),!E){const w=zx.distanceTo(uh.center);HC.push(f[y],w)}}const x=HC.list,v=this.customSort;v===null?x.sort(a.transparent?vUe:yUe):v.call(this,x,r);for(let y=0,b=x.length;y<b;y++){const E=x[y];u[p]=E.start*l,d[p]=E.count,p++}HC.reset()}else for(let x=0,v=c.length;x<v;x++)if(c[x]){let y=!1;if(g&&(this.getMatrixAt(x,Iu),this.getBoundingSphereAt(x,uh).applyMatrix4(Iu),y=!BC.intersectsSphere(uh)),!y){const b=f[x];u[p]=b.start*l,d[p]=b.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,s){this.onBeforeRender(e,null,i,a,s)}}class ly extends wg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Kt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const $V=new Oe,VV=new Oe,GV=new yr,$C=new $O,H_=new bl;class EUe extends Da{constructor(e=new Sa,n=new ly){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)$V.fromBufferAttribute(n,i-1),VV.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=$V.distanceTo(VV);e.setAttribute("lineDistance",new ei(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,s=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),H_.copy(r.boundingSphere),H_.applyMatrix4(i),H_.radius+=a,e.ray.intersectsSphere(H_)===!1)return;GV.copy(i).invert(),$C.copy(e.ray).applyMatrix4(GV);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new Oe,d=new Oe,f=new Oe,g=new Oe,p=this.isLineSegments?2:1,x=r.index,y=r.attributes.position;if(x!==null){const b=Math.max(0,s.start),E=Math.min(x.count,s.start+s.count);for(let w=b,A=E-1;w<A;w+=p){const T=x.getX(w),C=x.getX(w+1);if(u.fromBufferAttribute(y,T),d.fromBufferAttribute(y,C),$C.distanceSqToSegment(u,d,g,f)>c)continue;g.applyMatrix4(this.matrixWorld);const O=e.ray.origin.distanceTo(g);O<e.near||O>e.far||n.push({distance:O,point:f.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{const b=Math.max(0,s.start),E=Math.min(y.count,s.start+s.count);for(let w=b,A=E-1;w<A;w+=p){if(u.fromBufferAttribute(y,w),d.fromBufferAttribute(y,w+1),$C.distanceSqToSegment(u,d,g,f)>c)continue;g.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(g);C<e.near||C>e.far||n.push({distance:C,point:f.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=i.length;a<s;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}}const WV=new Oe,qV=new Oe;class lE extends EUe{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)WV.fromBufferAttribute(n,i),qV.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+WV.distanceTo(qV);e.setAttribute("lineDistance",new ei(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class AUe extends Sa{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new Oe,a=new Oe;if(e.index!==null){const s=e.attributes.position,l=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:l.count,materialIndex:0}]);for(let u=0,d=c.length;u<d;++u){const f=c[u],g=f.start,p=f.count;for(let x=g,v=g+p;x<v;x+=3)for(let y=0;y<3;y++){const b=l.getX(x+y),E=l.getX(x+(y+1)%3);i.fromBufferAttribute(s,b),a.fromBufferAttribute(s,E),KV(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}}else{const s=e.attributes.position;for(let l=0,c=s.count/3;l<c;l++)for(let u=0;u<3;u++){const d=3*l+u,f=3*l+(u+1)%3;i.fromBufferAttribute(s,d),a.fromBufferAttribute(s,f),KV(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new ei(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function KV(t,e,n){const r=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return n.has(r)===!0||n.has(i)===!0?!1:(n.add(r),n.add(i),!0)}class TUe extends wg{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Kt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cQ,this.normalScale=new tn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=UO,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class NUe extends ly{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}class PQ extends Da{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Kt(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),n}}const VC=new yr,XV=new Oe,YV=new Oe;class CUe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new tn(512,512),this.map=null,this.mapPass=null,this.matrix=new yr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new sE,this._frameExtents=new tn(1,1),this._viewportCount=1,this._viewports=[new cr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;XV.setFromMatrixPosition(e.matrixWorld),n.position.copy(XV),YV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(YV),n.updateMatrixWorld(),VC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(VC),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(VC)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const ZV=new yr,Bx=new Oe,GC=new Oe;class kUe extends CUe{constructor(){super(new Ss(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new tn(4,2),this._viewportCount=6,this._viewports=[new cr(2,1,1,1),new cr(0,1,1,1),new cr(3,1,1,1),new cr(1,1,1,1),new cr(3,0,1,1),new cr(1,0,1,1)],this._cubeDirections=[new Oe(1,0,0),new Oe(-1,0,0),new Oe(0,0,1),new Oe(0,0,-1),new Oe(0,1,0),new Oe(0,-1,0)],this._cubeUps=[new Oe(0,1,0),new Oe(0,1,0),new Oe(0,1,0),new Oe(0,1,0),new Oe(0,0,1),new Oe(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,a=e.distance||r.far;a!==r.far&&(r.far=a,r.updateProjectionMatrix()),Bx.setFromMatrixPosition(e.matrixWorld),r.position.copy(Bx),GC.copy(r.position),GC.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(GC),r.updateMatrixWorld(),i.makeTranslation(-Bx.x,-Bx.y,-Bx.z),ZV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ZV)}}class PUe extends PQ{constructor(e,n,r=0,i=2){super(e,n),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new kUe}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,n){return super.copy(e,n),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class jUe extends PQ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class RUe extends Sa{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class lj extends xUe{constructor(e,n,r=1){super(e,n),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const n=super.clone(e);return n.meshPerAttribute=this.meshPerAttribute,n}toJSON(e){const n=super.toJSON(e);return n.isInstancedInterleavedBuffer=!0,n.meshPerAttribute=this.meshPerAttribute,n}}class QV{constructor(e=1,n=0,r=0){return this.radius=e,this.phi=n,this.theta=r,this}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(aa(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const JV=new Oe,$_=new Oe;class DUe{constructor(e=new Oe,n=new Oe){this.start=e,this.end=n}set(e,n){return this.start.copy(e),this.end.copy(n),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,n){return this.delta(n).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,n){JV.subVectors(e,this.start),$_.subVectors(this.end,this.start);const r=$_.dot($_);let a=$_.dot(JV)/r;return n&&(a=aa(a,0,1)),a}closestPointToPoint(e,n,r){const i=this.closestPointToPointParameter(e,n);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class OUe extends lE{constructor(e=1){const n=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Sa;i.setAttribute("position",new ei(n,3)),i.setAttribute("color",new ei(r,3));const a=new ly({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new Kt,a=this.geometry.attributes.color.array;return i.set(e),i.toArray(a,0),i.toArray(a,3),i.set(n),i.toArray(a,6),i.toArray(a,9),i.set(r),i.toArray(a,12),i.toArray(a,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:rE}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=rE);class yl{constructor(e,n,r,i,a="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(a),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),yl.nextNameID=yl.nextNameID||0,this.$name.id=`lil-gui-name-${++yl.nextNameID}`,this.$widget=document.createElement("div"),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",s=>s.stopPropagation()),this.domElement.addEventListener("keyup",s=>s.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(r)}name(e){return this._name=e,this.$name.textContent=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const n=this.parent.add(this.object,this.property,e);return n.name(this._name),this.destroy(),n}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.getValue()!==e&&(this.object[this.property]=e,this._callOnChange(),this.updateDisplay()),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class LUe extends yl{constructor(e,n,r){super(e,n,r,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function cj(t){let e,n;return(e=t.match(/(#|0x)?([a-f0-9]{6})/i))?n=e[2]:(e=t.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?n=parseInt(e[1]).toString(16).padStart(2,0)+parseInt(e[2]).toString(16).padStart(2,0)+parseInt(e[3]).toString(16).padStart(2,0):(e=t.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(n=e[1]+e[1]+e[2]+e[2]+e[3]+e[3]),n?"#"+n:!1}const IUe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:cj,toHexString:cj},lb={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},FUe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=lb.fromHexString(t);e[0]=(r>>16&255)/255*n,e[1]=(r>>8&255)/255*n,e[2]=(r&255)/255*n},toHexString([t,e,n],r=1){r=255/r;const i=t*r<<16^e*r<<8^n*r<<0;return lb.toHexString(i)}},UUe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=lb.fromHexString(t);e.r=(r>>16&255)/255*n,e.g=(r>>8&255)/255*n,e.b=(r&255)/255*n},toHexString({r:t,g:e,b:n},r=1){r=255/r;const i=t*r<<16^e*r<<8^n*r<<0;return lb.toHexString(i)}},zUe=[IUe,lb,FUe,UUe];function BUe(t){return zUe.find(e=>e.match(t))}class HUe extends yl{constructor(e,n,r,i){super(e,n,r,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=BUe(this.initialValue),this._rgbScale=i,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const a=cj(this.$text.value);a&&this._setValueFromHexString(a)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const n=this._format.fromHexString(e);this.setValue(n)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class WC extends yl{constructor(e,n,r){super(e,n,r,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",i=>{i.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class $Ue extends yl{constructor(e,n,r,i,a,s){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(a);const l=s!==void 0;this.step(l?s:this._getImplicitStep(),l),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let E=parseFloat(this.$input.value);isNaN(E)||(this._stepExplicit&&(E=this._snap(E)),this.setValue(this._clamp(E)))},r=E=>{const w=parseFloat(this.$input.value);isNaN(w)||(this._snapClampSetValue(w+E),this.$input.value=this.getValue())},i=E=>{E.key==="Enter"&&this.$input.blur(),E.code==="ArrowUp"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E))),E.code==="ArrowDown"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E)*-1))},a=E=>{this._inputFocused&&(E.preventDefault(),r(this._step*this._normalizeMouseWheel(E)))};let s=!1,l,c,u,d,f;const g=5,p=E=>{l=E.clientX,c=u=E.clientY,s=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",v)},x=E=>{if(s){const w=E.clientX-l,A=E.clientY-c;Math.abs(A)>g?(E.preventDefault(),this.$input.blur(),s=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(w)>g&&v()}if(!s){const w=E.clientY-u;f-=w*this._step*this._arrowKeyMultiplier(E),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=E.clientY},v=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",v)},y=()=>{this._inputFocused=!0},b=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",a,{passive:!1}),this.$input.addEventListener("mousedown",p),this.$input.addEventListener("focus",y),this.$input.addEventListener("blur",b)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(b,E,w,A,T)=>(b-E)/(w-E)*(T-A)+A,n=b=>{const E=this.$slider.getBoundingClientRect();let w=e(b,E.left,E.right,this._min,this._max);this._snapClampSetValue(w)},r=b=>{this._setDraggingStyle(!0),n(b.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=b=>{n(b.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let s=!1,l,c;const u=b=>{b.preventDefault(),this._setDraggingStyle(!0),n(b.touches[0].clientX),s=!1},d=b=>{b.touches.length>1||(this._hasScrollBar?(l=b.touches[0].clientX,c=b.touches[0].clientY,s=!0):u(b),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",g))},f=b=>{if(s){const E=b.touches[0].clientX-l,w=b.touches[0].clientY-c;Math.abs(E)>Math.abs(w)?u(b):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g))}else b.preventDefault(),n(b.touches[0].clientX)},g=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g)},p=this._callOnFinishChange.bind(this),x=400;let v;const y=b=>{if(Math.abs(b.deltaX)<Math.abs(b.deltaY)&&this._hasScrollBar)return;b.preventDefault();const w=this._normalizeMouseWheel(b)*this._step;this._snapClampSetValue(this.getValue()+w),this.$input.value=this.getValue(),clearTimeout(v),v=setTimeout(p,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",y,{passive:!1})}_setDraggingStyle(e,n="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle(`lil-gui-${n}`,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:n,deltaY:r}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(n=0,r=-e.wheelDelta/120,r*=this._stepExplicit?1:10),n+-r}_arrowKeyMultiplier(e){let n=this._stepExplicit?1:10;return e.shiftKey?n*=10:e.altKey&&(n/=10),n}_snap(e){const n=Math.round(e/this._step)*this._step;return parseFloat(n.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class VUe extends yl{constructor(e,n,r,i){super(e,n,r,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.options(i)}options(e){return this._values=Array.isArray(e)?e:Object.values(e),this._names=Array.isArray(e)?e:Object.keys(e),this.$select.replaceChildren(),this._names.forEach(n=>{const r=document.createElement("option");r.textContent=n,this.$select.appendChild(r)}),this.updateDisplay(),this}updateDisplay(){const e=this.getValue(),n=this._values.indexOf(e);return this.$select.selectedIndex=n,this.$display.textContent=n===-1?e:this._names[n],this}}class GUe extends yl{constructor(e,n,r){super(e,n,r,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("spellcheck","false"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",i=>{i.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}const WUe=`.lil-gui {
- font-family: var(--font-family);
- font-size: var(--font-size);
- line-height: 1;
- font-weight: normal;
- font-style: normal;
- text-align: left;
- color: var(--text-color);
- user-select: none;
- -webkit-user-select: none;
- touch-action: manipulation;
- --background-color: #1f1f1f;
- --text-color: #ebebeb;
- --title-background-color: #111111;
- --title-text-color: #ebebeb;
- --widget-color: #424242;
- --hover-color: #4f4f4f;
- --focus-color: #595959;
- --number-color: #2cc9ff;
- --string-color: #a2db3c;
- --font-size: 11px;
- --input-font-size: 11px;
- --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
- --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
- --padding: 4px;
- --spacing: 4px;
- --widget-height: 20px;
- --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
- --name-width: 45%;
- --slider-knob-width: 2px;
- --slider-input-width: 27%;
- --color-input-width: 27%;
- --slider-input-min-width: 45px;
- --color-input-min-width: 45px;
- --folder-indent: 7px;
- --widget-padding: 0 0 0 3px;
- --widget-border-radius: 2px;
- --checkbox-size: calc(0.75 * var(--widget-height));
- --scrollbar-width: 5px;
- }
- .lil-gui, .lil-gui * {
- box-sizing: border-box;
- margin: 0;
- padding: 0;
- }
- .lil-gui.root {
- width: var(--width, 245px);
- display: flex;
- flex-direction: column;
- background: var(--background-color);
- }
- .lil-gui.root > .title {
- background: var(--title-background-color);
- color: var(--title-text-color);
- }
- .lil-gui.root > .children {
- overflow-x: hidden;
- overflow-y: auto;
- }
- .lil-gui.root > .children::-webkit-scrollbar {
- width: var(--scrollbar-width);
- height: var(--scrollbar-width);
- background: var(--background-color);
- }
- .lil-gui.root > .children::-webkit-scrollbar-thumb {
- border-radius: var(--scrollbar-width);
- background: var(--focus-color);
- }
- @media (pointer: coarse) {
- .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- }
- .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- .lil-gui.autoPlace {
- max-height: 100%;
- position: fixed;
- top: 0;
- right: 15px;
- z-index: 1001;
- }
- .lil-gui .controller {
- display: flex;
- align-items: center;
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- }
- .lil-gui .controller.disabled {
- opacity: 0.5;
- }
- .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
- pointer-events: none !important;
- }
- .lil-gui .controller > .name {
- min-width: var(--name-width);
- flex-shrink: 0;
- white-space: pre;
- padding-right: var(--spacing);
- line-height: var(--widget-height);
- }
- .lil-gui .controller .widget {
- position: relative;
- display: flex;
- align-items: center;
- width: 100%;
- min-height: var(--widget-height);
- }
- .lil-gui .controller.string input {
- color: var(--string-color);
- }
- .lil-gui .controller.boolean {
- cursor: pointer;
- }
- .lil-gui .controller.color .display {
- width: 100%;
- height: var(--widget-height);
- border-radius: var(--widget-border-radius);
- position: relative;
- }
- @media (hover: hover) {
- .lil-gui .controller.color .display:hover:before {
- content: " ";
- display: block;
- position: absolute;
- border-radius: var(--widget-border-radius);
- border: 1px solid #fff9;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- }
- }
- .lil-gui .controller.color input[type=color] {
- opacity: 0;
- width: 100%;
- height: 100%;
- cursor: pointer;
- }
- .lil-gui .controller.color input[type=text] {
- margin-left: var(--spacing);
- font-family: var(--font-family-mono);
- min-width: var(--color-input-min-width);
- width: var(--color-input-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.option select {
- opacity: 0;
- position: absolute;
- width: 100%;
- max-width: 100%;
- }
- .lil-gui .controller.option .display {
- position: relative;
- pointer-events: none;
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- line-height: var(--widget-height);
- max-width: 100%;
- overflow: hidden;
- word-break: break-all;
- padding-left: 0.55em;
- padding-right: 1.75em;
- background: var(--widget-color);
- }
- @media (hover: hover) {
- .lil-gui .controller.option .display.focus {
- background: var(--focus-color);
- }
- }
- .lil-gui .controller.option .display.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.option .display:after {
- font-family: "lil-gui";
- content: "↕";
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- padding-right: 0.375em;
- }
- .lil-gui .controller.option .widget,
- .lil-gui .controller.option select {
- cursor: pointer;
- }
- @media (hover: hover) {
- .lil-gui .controller.option .widget:hover .display {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number input {
- color: var(--number-color);
- }
- .lil-gui .controller.number.hasSlider input {
- margin-left: var(--spacing);
- width: var(--slider-input-width);
- min-width: var(--slider-input-min-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.number .slider {
- width: 100%;
- height: var(--widget-height);
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- padding-right: var(--slider-knob-width);
- overflow: hidden;
- cursor: ew-resize;
- touch-action: pan-y;
- }
- @media (hover: hover) {
- .lil-gui .controller.number .slider:hover {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number .slider.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.number .slider.active .fill {
- opacity: 0.95;
- }
- .lil-gui .controller.number .fill {
- height: 100%;
- border-right: var(--slider-knob-width) solid var(--number-color);
- box-sizing: content-box;
- }
- .lil-gui-dragging .lil-gui {
- --hover-color: var(--widget-color);
- }
- .lil-gui-dragging * {
- cursor: ew-resize !important;
- }
- .lil-gui-dragging.lil-gui-vertical * {
- cursor: ns-resize !important;
- }
- .lil-gui .title {
- height: var(--title-height);
- line-height: calc(var(--title-height) - 4px);
- font-weight: 600;
- padding: 0 var(--padding);
- -webkit-tap-highlight-color: transparent;
- cursor: pointer;
- outline: none;
- text-decoration-skip: objects;
- }
- .lil-gui .title:before {
- font-family: "lil-gui";
- content: "▾";
- padding-right: 2px;
- display: inline-block;
- }
- .lil-gui .title:active {
- background: var(--title-background-color);
- opacity: 0.75;
- }
- @media (hover: hover) {
- body:not(.lil-gui-dragging) .lil-gui .title:hover {
- background: var(--title-background-color);
- opacity: 0.85;
- }
- .lil-gui .title:focus {
- text-decoration: underline var(--focus-color);
- }
- }
- .lil-gui.root > .title:focus {
- text-decoration: none !important;
- }
- .lil-gui.closed > .title:before {
- content: "▸";
- }
- .lil-gui.closed > .children {
- transform: translateY(-7px);
- opacity: 0;
- }
- .lil-gui.closed:not(.transition) > .children {
- display: none;
- }
- .lil-gui.transition > .children {
- transition-duration: 300ms;
- transition-property: height, opacity, transform;
- transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
- overflow: hidden;
- pointer-events: none;
- }
- .lil-gui .children:empty:before {
- content: "Empty";
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- display: block;
- height: var(--widget-height);
- font-style: italic;
- line-height: var(--widget-height);
- opacity: 0.5;
- }
- .lil-gui.root > .children > .lil-gui > .title {
- border: 0 solid var(--widget-color);
- border-width: 1px 0;
- transition: border-color 300ms;
- }
- .lil-gui.root > .children > .lil-gui.closed > .title {
- border-bottom-color: transparent;
- }
- .lil-gui + .controller {
- border-top: 1px solid var(--widget-color);
- margin-top: 0;
- padding-top: var(--spacing);
- }
- .lil-gui .lil-gui .lil-gui > .title {
- border: none;
- }
- .lil-gui .lil-gui .lil-gui > .children {
- border: none;
- margin-left: var(--folder-indent);
- border-left: 2px solid var(--widget-color);
- }
- .lil-gui .lil-gui .controller {
- border: none;
- }
- .lil-gui label, .lil-gui input, .lil-gui button {
- -webkit-tap-highlight-color: transparent;
- }
- .lil-gui input {
- border: 0;
- outline: none;
- font-family: var(--font-family);
- font-size: var(--input-font-size);
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- background: var(--widget-color);
- color: var(--text-color);
- width: 100%;
- }
- @media (hover: hover) {
- .lil-gui input:hover {
- background: var(--hover-color);
- }
- .lil-gui input:active {
- background: var(--focus-color);
- }
- }
- .lil-gui input:disabled {
- opacity: 1;
- }
- .lil-gui input[type=text],
- .lil-gui input[type=number] {
- padding: var(--widget-padding);
- -moz-appearance: textfield;
- }
- .lil-gui input[type=text]:focus,
- .lil-gui input[type=number]:focus {
- background: var(--focus-color);
- }
- .lil-gui input[type=checkbox] {
- appearance: none;
- width: var(--checkbox-size);
- height: var(--checkbox-size);
- border-radius: var(--widget-border-radius);
- text-align: center;
- cursor: pointer;
- }
- .lil-gui input[type=checkbox]:checked:before {
- font-family: "lil-gui";
- content: "✓";
- font-size: var(--checkbox-size);
- line-height: var(--checkbox-size);
- }
- @media (hover: hover) {
- .lil-gui input[type=checkbox]:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button {
- outline: none;
- cursor: pointer;
- font-family: var(--font-family);
- font-size: var(--font-size);
- color: var(--text-color);
- width: 100%;
- height: var(--widget-height);
- text-transform: none;
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- border: none;
- }
- @media (hover: hover) {
- .lil-gui button:hover {
- background: var(--hover-color);
- }
- .lil-gui button:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button:active {
- background: var(--focus-color);
- }
- @font-face {
- font-family: "lil-gui";
- src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff");
- }`;function qUe(t){const e=document.createElement("style");e.innerHTML=t;const n=document.querySelector("head link[rel=stylesheet], head style");n?document.head.insertBefore(e,n):document.head.appendChild(e)}let e7=!1;class eS{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:a="Controls",closeFolders:s=!1,injectStyles:l=!0,touchStyles:c=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",u=>{(u.code==="Enter"||u.code==="Space")&&(u.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(a),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),c&&this.domElement.classList.add("allow-touch-styles"),!e7&&l&&(qUe(WUe),e7=!0),r?r.appendChild(this.domElement):n&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),i&&this.domElement.style.setProperty("--width",i+"px"),this._closeFolders=s}add(e,n,r,i,a){if(Object(r)===r)return new VUe(this,e,n,r);const s=e[n];switch(typeof s){case"number":return new $Ue(this,e,n,r,i,a);case"boolean":return new LUe(this,e,n);case"string":return new GUe(this,e,n);case"function":return new WC(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,s)}addColor(e,n,r=1){return new HUe(this,e,n,r)}addFolder(e){const n=new eS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof WC||r._name in e.controllers&&r.load(e.controllers[r._name])}),n&&e.folders&&this.folders.forEach(r=>{r._title in e.folders&&r.load(e.folders[r._title])}),this}save(e=!0){const n={controllers:{},folders:{}};return this.controllers.forEach(r=>{if(!(r instanceof WC)){if(r._name in n.controllers)throw new Error(`Cannot save GUI with duplicate property "${r._name}"`);n.controllers[r._name]=r.save()}}),e&&this.folders.forEach(r=>{if(r._title in n.folders)throw new Error(`Cannot save GUI with duplicate folder "${r._title}"`);n.folders[r._title]=r.save()}),n}open(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const n=this.$children.clientHeight;this.$children.style.height=n+"px",this.domElement.classList.add("transition");const r=a=>{a.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",r))};this.$children.addEventListener("transitionend",r);const i=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(r=>r.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(n=>{e=e.concat(n.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(n=>{e=e.concat(n.foldersRecursive())}),e}}function qC(t,e,n,r){return new(n||(n=Promise))((function(i,a){function s(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(s,l)}c((r=r.apply(t,[])).next())}))}class KO{constructor(e,n,r,i){this.size=e,this.width=n,this.height=r,this.charLength=i,this.chars=""}static parse(e){const n=e.split(" "),r=n[0],i=r.split("x");return new KO(r,+i[0],+i[1],+n[1])}get src(){return"data:image/jpeg;base64,"+this.chars}get isValid(){return this.chars.length==this.charLength&&/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(this.chars)}}class XO{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class t7 extends XO{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Fu extends XO{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class n7{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class tS{constructor(e){this.lines=[],this.preamble=new n7(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
- `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((a=>a.comment))).thumbnails;for(const[a,s]of Object.entries(i))this.metadata.thumbnails[a]=s;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),a=i[0],s=n&&i[1]||void 0,l=a.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=l.length?`${(r=l[0])===null||r===void 0?void 0:r.toLowerCase()}${l[1]}`:"",u=this.parseParams(l.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new t7(e,c,u,s);case"t0":return new Fu(e,c,s,0);case"t1":return new Fu(e,c,s,1);case"t2":return new Fu(e,c,s,2);case"t3":return new Fu(e,c,s,3);case"t4":return new Fu(e,c,s,4);case"t5":return new Fu(e,c,s,5);case"t6":return new Fu(e,c,s,6);case"t7":return new Fu(e,c,s,7);default:return new XO(e,c,u,s)}}parseMove(e){return e.reduce(((n,r)=>{const i=r.charAt(0).toLowerCase();return i!="x"&&i!="y"&&i!="z"&&i!="e"&&i!="r"&&i!="f"&&i!="i"&&i!="j"||(n[i]=parseFloat(r.slice(1))),n}),{})}isAlpha(e){const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}parseParams(e){return e.reduce(((n,r,i,a)=>{if(i%2==0)return n;let s=a[i-1];return s=s.toLowerCase(),this.isAlpha(s)&&(n[s]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof t7){const a=i.params;if(a.z&&(this.curZ=a.z),((n=a.e)!==null&&n!==void 0?n:0)>0&&(a.x!=null||a.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){const s=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new n7(this.layers.length,[],r,s))}}this.maxLayer.commands.push(i)}return this.layers}get maxLayer(){var e;return(e=this.layers[this.layers.length-1])!==null&&e!==void 0?e:this.preamble}parseMetadata(e){const n={};let r;for(const i of e){const a=i.comment;if(!a)continue;const s=a.indexOf("thumbnail begin"),l=a.indexOf("thumbnail end");s>-1?r=KO.parse(a.slice(s+15).trim()):r&&(l==-1?r.chars+=a.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}tS.prototype.parseGcode=tS.prototype.parseGCode;const r7={type:"change"},KC={type:"start"},i7={type:"end"},V_=new $O,a7=new Vu,KUe=Math.cos(70*dQ.DEG2RAD);class XUe extends Cf{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Oe,this.cursor=new Oe,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Nm.ROTATE,MIDDLE:Nm.DOLLY,RIGHT:Nm.PAN},this.touches={ONE:Cm.ROTATE,TWO:Cm.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(H){H.addEventListener("keydown",Re),this._domElementKeyEvents=H},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Re),this._domElementKeyEvents=null},this.saveState=function(){r.target0.copy(r.target),r.position0.copy(r.object.position),r.zoom0=r.object.zoom},this.reset=function(){r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.zoom=r.zoom0,r.object.updateProjectionMatrix(),r.dispatchEvent(r7),r.update(),a=i.NONE},this.update=(function(){const H=new Oe,re=new yf().setFromUnitVectors(e.up,new Oe(0,1,0)),G=re.clone().invert(),Z=new Oe,oe=new yf,be=new Oe,Te=2*Math.PI;return function(Me=null){const F=r.object.position;H.copy(F).sub(r.target),H.applyQuaternion(re),l.setFromVector3(H),r.autoRotate&&a===i.NONE&&j((function(Se){return Se!==null?2*Math.PI/60*r.autoRotateSpeed*Se:2*Math.PI/60/60*r.autoRotateSpeed})(Me)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let I=r.minAzimuthAngle,ne=r.maxAzimuthAngle;isFinite(I)&&isFinite(ne)&&(I<-Math.PI?I+=Te:I>Math.PI&&(I-=Te),ne<-Math.PI?ne+=Te:ne>Math.PI&&(ne-=Te),l.theta=I<=ne?Math.max(I,Math.min(ne,l.theta)):l.theta>(I+ne)/2?Math.max(I,l.theta):Math.min(ne,l.theta)),l.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,l.phi)),l.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&C||r.object.isOrthographicCamera?l.radius=J(l.radius):l.radius=J(l.radius*u),H.setFromSpherical(l),H.applyQuaternion(G),F.copy(r.target).add(H),r.object.lookAt(r.target),r.enableDamping===!0?(c.theta*=1-r.dampingFactor,c.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(c.set(0,0,0),d.set(0,0,0));let ve=!1;if(r.zoomToCursor&&C){let Se=null;if(r.object.isPerspectiveCamera){const ye=H.length();Se=J(ye*u);const Ke=ye-Se;r.object.position.addScaledVector(A,Ke),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ye=new Oe(T.x,T.y,0);ye.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ve=!0;const Ke=new Oe(T.x,T.y,0);Ke.unproject(r.object),r.object.position.sub(Ke).add(ye),r.object.updateMatrixWorld(),Se=H.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;Se!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(Se).add(r.object.position):(V_.origin.copy(r.object.position),V_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(V_.direction))<KUe?e.lookAt(r.target):(a7.setFromNormalAndCoplanarPoint(r.object.up,r.target),V_.intersectPlane(a7,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ve=!0);return u=1,C=!1,!!(ve||Z.distanceToSquared(r.object.position)>s||8*(1-oe.dot(r.object.quaternion))>s||be.distanceToSquared(r.target)>0)&&(r.dispatchEvent(r7),Z.copy(r.object.position),oe.copy(r.object.quaternion),be.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",fe),r.domElement.removeEventListener("pointerdown",ge),r.domElement.removeEventListener("pointercancel",pe),r.domElement.removeEventListener("wheel",de),r.domElement.removeEventListener("pointermove",Ee),r.domElement.removeEventListener("pointerup",pe),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Re),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=i.NONE;const s=1e-6,l=new QV,c=new QV;let u=1;const d=new Oe,f=new tn,g=new tn,p=new tn,x=new tn,v=new tn,y=new tn,b=new tn,E=new tn,w=new tn,A=new Oe,T=new tn;let C=!1;const N=[],O={};function k(){return Math.pow(.95,r.zoomSpeed)}function j(H){c.theta-=H}function B(H){c.phi-=H}const L=(function(){const H=new Oe;return function(re,G){H.setFromMatrixColumn(G,0),H.multiplyScalar(-re),d.add(H)}})(),K=(function(){const H=new Oe;return function(re,G){r.screenSpacePanning===!0?H.setFromMatrixColumn(G,1):(H.setFromMatrixColumn(G,0),H.crossVectors(r.object.up,H)),H.multiplyScalar(re),d.add(H)}})(),R=(function(){const H=new Oe;return function(re,G){const Z=r.domElement;if(r.object.isPerspectiveCamera){const oe=r.object.position;H.copy(oe).sub(r.target);let be=H.length();be*=Math.tan(r.object.fov/2*Math.PI/180),L(2*re*be/Z.clientHeight,r.object.matrix),K(2*G*be/Z.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(L(re*(r.object.right-r.object.left)/r.object.zoom/Z.clientWidth,r.object.matrix),K(G*(r.object.top-r.object.bottom)/r.object.zoom/Z.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function q(H){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=H:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function W(H){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=H:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function $(H){if(!r.zoomToCursor)return;C=!0;const re=r.domElement.getBoundingClientRect(),G=H.clientX-re.left,Z=H.clientY-re.top,oe=re.width,be=re.height;T.x=G/oe*2-1,T.y=-Z/be*2+1,A.set(T.x,T.y,1).unproject(r.object).sub(r.object.position).normalize()}function J(H){return Math.max(r.minDistance,Math.min(r.maxDistance,H))}function ee(H){f.set(H.clientX,H.clientY)}function Q(H){x.set(H.clientX,H.clientY)}function z(){if(N.length===1)f.set(N[0].pageX,N[0].pageY);else{const H=.5*(N[0].pageX+N[1].pageX),re=.5*(N[0].pageY+N[1].pageY);f.set(H,re)}}function V(){if(N.length===1)x.set(N[0].pageX,N[0].pageY);else{const H=.5*(N[0].pageX+N[1].pageX),re=.5*(N[0].pageY+N[1].pageY);x.set(H,re)}}function X(){const H=N[0].pageX-N[1].pageX,re=N[0].pageY-N[1].pageY,G=Math.sqrt(H*H+re*re);b.set(0,G)}function te(H){if(N.length==1)g.set(H.pageX,H.pageY);else{const G=U(H),Z=.5*(H.pageX+G.x),oe=.5*(H.pageY+G.y);g.set(Z,oe)}p.subVectors(g,f).multiplyScalar(r.rotateSpeed);const re=r.domElement;j(2*Math.PI*p.x/re.clientHeight),B(2*Math.PI*p.y/re.clientHeight),f.copy(g)}function ie(H){if(N.length===1)v.set(H.pageX,H.pageY);else{const re=U(H),G=.5*(H.pageX+re.x),Z=.5*(H.pageY+re.y);v.set(G,Z)}y.subVectors(v,x).multiplyScalar(r.panSpeed),R(y.x,y.y),x.copy(v)}function le(H){const re=U(H),G=H.pageX-re.x,Z=H.pageY-re.y,oe=Math.sqrt(G*G+Z*Z);E.set(0,oe),w.set(0,Math.pow(E.y/b.y,r.zoomSpeed)),q(w.y),b.copy(E)}function ge(H){r.enabled!==!1&&(N.length===0&&(r.domElement.setPointerCapture(H.pointerId),r.domElement.addEventListener("pointermove",Ee),r.domElement.addEventListener("pointerup",pe)),(function(re){N.push(re)})(H),H.pointerType==="touch"?(function(re){switch(Fe(re),N.length){case 1:switch(r.touches.ONE){case Cm.ROTATE:if(r.enableRotate===!1)return;z(),a=i.TOUCH_ROTATE;break;case Cm.PAN:if(r.enablePan===!1)return;V(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case Cm.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&X(),r.enablePan&&V(),a=i.TOUCH_DOLLY_PAN;break;case Cm.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&X(),r.enableRotate&&z(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(KC)})(H):(function(re){let G;switch(re.button){case 0:G=r.mouseButtons.LEFT;break;case 1:G=r.mouseButtons.MIDDLE;break;case 2:G=r.mouseButtons.RIGHT;break;default:G=-1}switch(G){case Nm.DOLLY:if(r.enableZoom===!1)return;(function(Z){$(Z),b.set(Z.clientX,Z.clientY)})(re),a=i.DOLLY;break;case Nm.ROTATE:if(re.ctrlKey||re.metaKey||re.shiftKey){if(r.enablePan===!1)return;Q(re),a=i.PAN}else{if(r.enableRotate===!1)return;ee(re),a=i.ROTATE}break;case Nm.PAN:if(re.ctrlKey||re.metaKey||re.shiftKey){if(r.enableRotate===!1)return;ee(re),a=i.ROTATE}else{if(r.enablePan===!1)return;Q(re),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(KC)})(H))}function Ee(H){r.enabled!==!1&&(H.pointerType==="touch"?(function(re){switch(Fe(re),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;te(re),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;ie(re),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(G){r.enableZoom&&le(G),r.enablePan&&ie(G)})(re),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(G){r.enableZoom&&le(G),r.enableRotate&&te(G)})(re),r.update();break;default:a=i.NONE}})(H):(function(re){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(G){g.set(G.clientX,G.clientY),p.subVectors(g,f).multiplyScalar(r.rotateSpeed);const Z=r.domElement;j(2*Math.PI*p.x/Z.clientHeight),B(2*Math.PI*p.y/Z.clientHeight),f.copy(g),r.update()})(re);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(G){E.set(G.clientX,G.clientY),w.subVectors(E,b),w.y>0?q(k()):w.y<0&&W(k()),b.copy(E),r.update()})(re);break;case i.PAN:if(r.enablePan===!1)return;(function(G){v.set(G.clientX,G.clientY),y.subVectors(v,x).multiplyScalar(r.panSpeed),R(y.x,y.y),x.copy(v),r.update()})(re)}})(H))}function pe(H){(function(re){delete O[re.pointerId];for(let G=0;G<N.length;G++)if(N[G].pointerId==re.pointerId)return void N.splice(G,1)})(H),N.length===0&&(r.domElement.releasePointerCapture(H.pointerId),r.domElement.removeEventListener("pointermove",Ee),r.domElement.removeEventListener("pointerup",pe)),r.dispatchEvent(i7),a=i.NONE}function de(H){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(H.preventDefault(),r.dispatchEvent(KC),(function(re){$(re),re.deltaY<0?W(k()):re.deltaY>0&&q(k()),r.update()})(H),r.dispatchEvent(i7))}function Re(H){r.enabled!==!1&&r.enablePan!==!1&&(function(re){let G=!1;switch(re.code){case r.keys.UP:re.ctrlKey||re.metaKey||re.shiftKey?B(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,r.keyPanSpeed),G=!0;break;case r.keys.BOTTOM:re.ctrlKey||re.metaKey||re.shiftKey?B(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,-r.keyPanSpeed),G=!0;break;case r.keys.LEFT:re.ctrlKey||re.metaKey||re.shiftKey?j(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(r.keyPanSpeed,0),G=!0;break;case r.keys.RIGHT:re.ctrlKey||re.metaKey||re.shiftKey?j(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(-r.keyPanSpeed,0),G=!0}G&&(re.preventDefault(),r.update())})(H)}function fe(H){r.enabled!==!1&&H.preventDefault()}function Fe(H){let re=O[H.pointerId];re===void 0&&(re=new tn,O[H.pointerId]=re),re.set(H.pageX,H.pageY)}function U(H){const re=H.pointerId===N[0].pointerId?N[1]:N[0];return O[re.pointerId]}r.domElement.addEventListener("contextmenu",fe),r.domElement.addEventListener("pointerdown",ge),r.domElement.addEventListener("pointercancel",pe),r.domElement.addEventListener("wheel",de,{passive:!1}),this.update()}}Nt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new tn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Qa.line={uniforms:VO.merge([Nt.common,Nt.fog,Nt.line]),vertexShader:`
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- uniform float linewidth;
- uniform vec2 resolution;
- attribute vec3 instanceStart;
- attribute vec3 instanceEnd;
- attribute vec3 instanceColorStart;
- attribute vec3 instanceColorEnd;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #ifdef USE_DASH
- uniform float dashScale;
- attribute float instanceDistanceStart;
- attribute float instanceDistanceEnd;
- varying float vLineDistance;
- #endif
- void trimSegment( const in vec4 start, inout vec4 end ) {
- // trim end segment so it terminates between the camera plane and the near plane
- // conservative estimate of the near plane
- float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
- float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
- float nearEstimate = - 0.5 * b / a;
- float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
- end.xyz = mix( start.xyz, end.xyz, alpha );
- }
- void main() {
- #ifdef USE_COLOR
- vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
- #endif
- #ifdef USE_DASH
- vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
- vUv = uv;
- #endif
- float aspect = resolution.x / resolution.y;
- // camera space
- vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
- vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
- #ifdef WORLD_UNITS
- worldStart = start.xyz;
- worldEnd = end.xyz;
- #else
- vUv = uv;
- #endif
- // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
- // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
- // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
- // perhaps there is a more elegant solution -- WestLangley
- bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
- if ( perspective ) {
- if ( start.z < 0.0 && end.z >= 0.0 ) {
- trimSegment( start, end );
- } else if ( end.z < 0.0 && start.z >= 0.0 ) {
- trimSegment( end, start );
- }
- }
- // clip space
- vec4 clipStart = projectionMatrix * start;
- vec4 clipEnd = projectionMatrix * end;
- // ndc space
- vec3 ndcStart = clipStart.xyz / clipStart.w;
- vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
- // direction
- vec2 dir = ndcEnd.xy - ndcStart.xy;
- // account for clip-space aspect ratio
- dir.x *= aspect;
- dir = normalize( dir );
- #ifdef WORLD_UNITS
- // get the offset direction as perpendicular to the view vector
- vec3 worldDir = normalize( end.xyz - start.xyz );
- vec3 offset;
- if ( position.y < 0.5 ) {
- offset = normalize( cross( start.xyz, worldDir ) );
- } else {
- offset = normalize( cross( end.xyz, worldDir ) );
- }
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
- // don't extend the line if we're rendering dashes because we
- // won't be rendering the endcaps
- #ifndef USE_DASH
- // extend the line bounds to encompass endcaps
- start.xyz += - worldDir * linewidth * 0.5;
- end.xyz += worldDir * linewidth * 0.5;
- // shift the position of the quad so it hugs the forward edge of the line
- offset.xy -= dir * forwardOffset;
- offset.z += 0.5;
- #endif
- // endcaps
- if ( position.y > 1.0 || position.y < 0.0 ) {
- offset.xy += dir * 2.0 * forwardOffset;
- }
- // adjust for linewidth
- offset *= linewidth * 0.5;
- // set the world position
- worldPos = ( position.y < 0.5 ) ? start : end;
- worldPos.xyz += offset;
- // project the worldpos
- vec4 clip = projectionMatrix * worldPos;
- // shift the depth of the projected points so the line
- // segments overlap neatly
- vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
- clip.z = clipPose.z * clip.w;
- #else
- vec2 offset = vec2( dir.y, - dir.x );
- // undo aspect ratio adjustment
- dir.x /= aspect;
- offset.x /= aspect;
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- // endcaps
- if ( position.y < 0.0 ) {
- offset += - dir;
- } else if ( position.y > 1.0 ) {
- offset += dir;
- }
- // adjust for linewidth
- offset *= linewidth;
- // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
- offset /= resolution.y;
- // select end
- vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
- // back to clip space
- offset *= clip.w;
- clip.xy += offset;
- #endif
- gl_Position = clip;
- vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }
- `,fragmentShader:`
- uniform vec3 diffuse;
- uniform float opacity;
- uniform float linewidth;
- #ifdef USE_DASH
- uniform float dashOffset;
- uniform float dashSize;
- uniform float gapSize;
- #endif
- varying float vLineDistance;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #include <common>
- #include <color_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
- float mua;
- float mub;
- vec3 p13 = p1 - p3;
- vec3 p43 = p4 - p3;
- vec3 p21 = p2 - p1;
- float d1343 = dot( p13, p43 );
- float d4321 = dot( p43, p21 );
- float d1321 = dot( p13, p21 );
- float d4343 = dot( p43, p43 );
- float d2121 = dot( p21, p21 );
- float denom = d2121 * d4343 - d4321 * d4321;
- float numer = d1343 * d4321 - d1321 * d4343;
- mua = numer / denom;
- mua = clamp( mua, 0.0, 1.0 );
- mub = ( d1343 + d4321 * ( mua ) ) / d4343;
- mub = clamp( mub, 0.0, 1.0 );
- return vec2( mua, mub );
- }
- void main() {
- #include <clipping_planes_fragment>
- #ifdef USE_DASH
- if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
- if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
- #endif
- float alpha = opacity;
- #ifdef WORLD_UNITS
- // Find the closest points on the view ray and the line segment
- vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
- vec3 lineDir = worldEnd - worldStart;
- vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
- vec3 p1 = worldStart + lineDir * params.x;
- vec3 p2 = rayEnd * params.y;
- vec3 delta = p1 - p2;
- float len = length( delta );
- float norm = len / linewidth;
- #ifndef USE_DASH
- #ifdef USE_ALPHA_TO_COVERAGE
- float dnorm = fwidth( norm );
- alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
- #else
- if ( norm > 0.5 ) {
- discard;
- }
- #endif
- #endif
- #else
- #ifdef USE_ALPHA_TO_COVERAGE
- // artifacts appear on some hardware if a derivative is taken within a conditional
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- float dlen = fwidth( len2 );
- if ( abs( vUv.y ) > 1.0 ) {
- alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
- }
- #else
- if ( abs( vUv.y ) > 1.0 ) {
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- if ( len2 > 1.0 ) discard;
- }
- #endif
- #endif
- vec4 diffuseColor = vec4( diffuse, alpha );
- #include <logdepthbuf_fragment>
- #include <color_fragment>
- gl_FragColor = vec4( diffuseColor.rgb, alpha );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }
- `};class jQ extends Td{constructor(e){super({type:"LineMaterial",uniforms:VO.clone(Qa.line.uniforms),vertexShader:Qa.line.vertexShader,fragmentShader:Qa.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}}const s7=new ho,G_=new Oe;class RQ extends RUe{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry",this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new ei([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new ei([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){const n=this.attributes.instanceStart,r=this.attributes.instanceEnd;return n!==void 0&&(n.applyMatrix4(e),r.applyMatrix4(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const r=new lj(n,6,1);return this.setAttribute("instanceStart",new nd(r,3,0)),this.setAttribute("instanceEnd",new nd(r,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const r=new lj(n,6,1);return this.setAttribute("instanceColorStart",new nd(r,3,0)),this.setAttribute("instanceColorEnd",new nd(r,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new AUe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ho);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),s7.setFromBufferAttribute(n),this.boundingBox.union(s7))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new bl),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)G_.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(G_)),G_.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(G_));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}const o7=new Oe,l7=new Oe,Qi=new cr,Ji=new cr,rl=new cr,XC=new Oe,YC=new yr,ea=new DUe,c7=new Oe,W_=new ho,q_=new bl,il=new cr;let al,Sh;function u7(t,e,n){return il.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),il.multiplyScalar(1/il.w),il.x=Sh/n.width,il.y=Sh/n.height,il.applyMatrix4(t.projectionMatrixInverse),il.multiplyScalar(1/il.w),Math.abs(Math.max(il.x,il.y))}class YUe extends Uo{constructor(e=new RQ,n=new jQ({color:16777215*Math.random()})){super(e,n),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,r=e.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let s=0,l=0,c=n.count;s<c;s++,l+=2)o7.fromBufferAttribute(n,s),l7.fromBufferAttribute(r,s),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+o7.distanceTo(l7);const a=new lj(i,2,1);return e.setAttribute("instanceDistanceStart",new nd(a,1,0)),e.setAttribute("instanceDistanceEnd",new nd(a,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;i!==null||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;al=e.ray;const s=this.matrixWorld,l=this.geometry,c=this.material;let u,d;Sh=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),q_.copy(l.boundingSphere).applyMatrix4(s),r?u=.5*Sh:u=u7(i,Math.max(i.near,q_.distanceToPoint(al.origin)),c.resolution),q_.radius+=u,al.intersectsSphere(q_)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),W_.copy(l.boundingBox).applyMatrix4(s),r?d=.5*Sh:d=u7(i,Math.max(i.near,W_.distanceToPoint(al.origin)),c.resolution),W_.expandByScalar(d),al.intersectsBox(W_)!==!1&&(r?(function(f,g){const p=f.matrixWorld,x=f.geometry,v=x.attributes.instanceStart,y=x.attributes.instanceEnd;for(let b=0,E=Math.min(x.instanceCount,v.count);b<E;b++){ea.start.fromBufferAttribute(v,b),ea.end.fromBufferAttribute(y,b),ea.applyMatrix4(p);const w=new Oe,A=new Oe;al.distanceSqToSegment(ea.start,ea.end,A,w),A.distanceTo(w)<.5*Sh&&g.push({point:A,pointOnLine:w,distance:al.origin.distanceTo(A),object:f,face:null,faceIndex:b,uv:null,uv1:null})}})(this,n):(function(f,g,p){const x=g.projectionMatrix,v=f.material.resolution,y=f.matrixWorld,b=f.geometry,E=b.attributes.instanceStart,w=b.attributes.instanceEnd,A=Math.min(b.instanceCount,E.count),T=-g.near;al.at(1,rl),rl.w=1,rl.applyMatrix4(g.matrixWorldInverse),rl.applyMatrix4(x),rl.multiplyScalar(1/rl.w),rl.x*=v.x/2,rl.y*=v.y/2,rl.z=0,XC.copy(rl),YC.multiplyMatrices(g.matrixWorldInverse,y);for(let C=0,N=A;C<N;C++){if(Qi.fromBufferAttribute(E,C),Ji.fromBufferAttribute(w,C),Qi.w=1,Ji.w=1,Qi.applyMatrix4(YC),Ji.applyMatrix4(YC),Qi.z>T&&Ji.z>T)continue;if(Qi.z>T){const L=Qi.z-Ji.z,K=(Qi.z-T)/L;Qi.lerp(Ji,K)}else if(Ji.z>T){const L=Ji.z-Qi.z,K=(Ji.z-T)/L;Ji.lerp(Qi,K)}Qi.applyMatrix4(x),Ji.applyMatrix4(x),Qi.multiplyScalar(1/Qi.w),Ji.multiplyScalar(1/Ji.w),Qi.x*=v.x/2,Qi.y*=v.y/2,Ji.x*=v.x/2,Ji.y*=v.y/2,ea.start.copy(Qi),ea.start.z=0,ea.end.copy(Ji),ea.end.z=0;const O=ea.closestPointToPointParameter(XC,!0);ea.at(O,c7);const k=dQ.lerp(Qi.z,Ji.z,O),j=k>=-1&&k<=1,B=XC.distanceTo(c7)<.5*Sh;if(j&&B){ea.start.fromBufferAttribute(E,C),ea.end.fromBufferAttribute(w,C),ea.start.applyMatrix4(y),ea.end.applyMatrix4(y);const L=new Oe,K=new Oe;al.distanceSqToSegment(ea.start,ea.end,K,L),p.push({point:K,pointOnLine:L,distance:al.origin.distanceTo(K),object:f,face:null,faceIndex:C,uv:null,uv1:null})}}})(this,i,n)))}}class ZUe extends lE{constructor(e,n,r,i,a=4473924,s=8947848){a=new Kt(a),s=new Kt(s);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let g=-1*(e=l*n/2);g<=e;g+=n){c.push(g,0,-1*r,g,0,r);const p=g===0?a:s;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}for(let g=-1*r;g<=r;g+=i){c.push(-1*e,0,g,e,0,g);const p=g===0?a:s;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}const f=new Sa;f.setAttribute("position",new ei(c,3)),f.setAttribute("color",new ei(u,3)),super(f,new ly({vertexColors:!0,toneMapped:!1}))}}function QUe(t,e,n,r){const i=(function(s,l,c){s*=.5,l*=.5,c*=.5;const u=new Sa,d=[];return d.push(-s,-l,-c,-s,l,-c,-s,l,-c,s,l,-c,s,l,-c,s,-l,-c,s,-l,-c,-s,-l,-c,-s,-l,c,-s,l,c,-s,l,c,s,l,c,s,l,c,s,-l,c,s,-l,c,-s,-l,c,-s,-l,-c,-s,-l,c,-s,l,-c,-s,l,c,s,l,-c,s,l,c,s,-l,-c,s,-l,c),u.setAttribute("position",new ei(d,3)),u})(t,e,n),a=new lE(i,new NUe({color:new Kt(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var h0=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===d?"block":"none";t=d}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(d){d.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),a=i,s=0,l=n(new h0.Panel("FPS","#0ff","#002")),c=n(new h0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new h0.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){s++;var d=(performance||Date).now();if(c.update(d-i,200),d>=a+1e3&&(l.update(1e3*s/(d-a),100),a=d,s=0,u)){var f=performance.memory;u.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:r}};h0.Panel=function(t,e,n){var r=1/0,i=0,a=Math.round,s=a(window.devicePixelRatio||1),l=80*s,c=48*s,u=3*s,d=2*s,f=3*s,g=15*s,p=74*s,x=30*s,v=document.createElement("canvas");v.width=l,v.height=c,v.style.cssText="width:80px;height:48px";var y=v.getContext("2d");return y.font="bold "+9*s+"px Helvetica,Arial,sans-serif",y.textBaseline="top",y.fillStyle=n,y.fillRect(0,0,l,c),y.fillStyle=e,y.fillText(t,u,d),y.fillRect(f,g,p,x),y.fillStyle=n,y.globalAlpha=.9,y.fillRect(f,g,p,x),{dom:v,update:function(b,E){r=Math.min(r,b),i=Math.max(i,b),y.fillStyle=n,y.globalAlpha=1,y.fillRect(0,0,l,g),y.fillStyle=e,y.fillText(a(b)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),y.drawImage(v,f+s,g,p-s,x,f,g,p-s,x),y.fillRect(f+p-s,g,s,x),y.fillStyle=n,y.globalAlpha=.9,y.fillRect(f+p-s,g,s,a((1-b/E)*x))}}};var JUe=h0;class d7{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new eS,this.gui.title("Dev info"),this.setup()}setup(){this.loadOpenFolders(),this.options&&!this.options.renderer||this.setupRedererFolder(),this.options&&!this.options.camera||this.setupCameraFolder(),this.options&&!this.options.parser||this.setupParserFolder(),this.options&&!this.options.buildVolume||this.setupBuildVolumeFolder(),this.options&&!this.options.devHelpers||this.setupDevHelpers()}reset(){this.gui.destroy(),this.gui=new eS,this.gui.title("Dev info"),this.setup()}loadOpenFolders(){this.openFolders=JSON.parse(localStorage.getItem("dev-gui-open")||"{}").open||[]}saveOpenFolders(){this.openFolders=this.gui.foldersRecursive().filter((e=>!e._closed)).map((e=>e._title)),console.log(this.openFolders),localStorage.setItem("dev-gui-open",JSON.stringify({open:this.openFolders}))}setupRedererFolder(){const e=this.gui.addFolder("Render Info");this.openFolders.includes("Render Info")||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject.renderer.info.render,"triangles").listen(),e.add(this.watchedObject.renderer.info.render,"calls").listen(),e.add(this.watchedObject.renderer.info.render,"lines").listen(),e.add(this.watchedObject.renderer.info.render,"points").listen(),e.add(this.watchedObject.renderer.info.memory,"geometries").listen(),e.add(this.watchedObject.renderer.info.memory,"textures").listen(),e.add(this.watchedObject,"_lastRenderTime").listen()}setupCameraFolder(){const e=this.gui.addFolder("Camera");this.openFolders.includes("Camera")||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()}));const n=e.addFolder("Camera position");n.add(this.watchedObject.camera.position,"x").listen(),n.add(this.watchedObject.camera.position,"y").listen(),n.add(this.watchedObject.camera.position,"z").listen();const r=e.addFolder("Camera rotation");r.add(this.watchedObject.camera.rotation,"x").listen(),r.add(this.watchedObject.camera.rotation,"y").listen(),r.add(this.watchedObject.camera.rotation,"z").listen()}setupParserFolder(){const e=this.gui.addFolder("Parser");this.openFolders.includes("Parser")||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject.parser,"curZ").listen(),e.add(this.watchedObject.parser,"maxZ").listen(),e.add(this.watchedObject.parser,"tolerance").listen(),e.add(this.watchedObject.parser.layers,"length").name("layers.count").listen(),e.add(this.watchedObject.parser.lines,"length").name("lines.count").listen()}setupBuildVolumeFolder(){const e=this.gui.addFolder("Build Volume");this.openFolders.includes("Build Volume")||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject.buildVolume,"x").min(0).max(600).listen().onChange((()=>{this.watchedObject.render()})),e.add(this.watchedObject.buildVolume,"y").min(0).max(600).listen().onChange((()=>{this.watchedObject.render()})),e.add(this.watchedObject.buildVolume,"z").min(0).max(600).listen().onChange((()=>{this.watchedObject.render()}))}setupDevHelpers(){const e=this.gui.addFolder("Dev Helpers");this.openFolders.includes("Dev Helpers")||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject,"_wireframe").listen().onChange((()=>{this.watchedObject.render()})),e.add(this.watchedObject,"render").listen(),e.add(this.watchedObject,"clear").listen()}}class eze extends Sa{constructor(e=[new Oe],n=.6,r=.2,i=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:r,radialSegments:i,closed:!1};const a=new Oe,s=new Oe,l=new tn,c=[],u=[],d=[],f=[];function g(p){const[x,v,y]=(function(b){const E=e[b],w=new Oe,A=new Oe,T=new Oe,C=new Oe;w.copy(E).sub(e[b-1]||E).normalize().add((e[b+1]||E).clone().sub(E).normalize()).normalize();let N=Number.MAX_VALUE;const O=Math.abs(w.x),k=Math.abs(w.y),j=Math.abs(w.z);return O<=N&&(N=O,A.set(1,0,0)),k<=N&&(N=k,A.set(0,1,0)),j<=N&&A.set(0,0,1),C.crossVectors(w,A).normalize(),A.crossVectors(w,C),T.crossVectors(w,A),[E,A,T]})(p);for(let b=0;b<=i;b++){const E=b/i*Math.PI*2,w=Math.sin(E),A=-Math.cos(E);s.x=A*v.x+w*y.x,s.y=A*v.y+w*y.y,s.z=A*v.z+w*y.z,s.normalize(),u.push(s.x,s.y,s.z),a.x=x.x+n*s.x*.5,a.y=x.y+n*s.y*.5,a.z=x.z+r*s.z*.5,c.push(a.x,a.y,a.z)}}(function(){for(let p=0;p<e.length;p++)g(p);g(closed===!1?e.length-1:0),(function(){for(let p=0;p<e.length;p++)for(let x=0;x<=i;x++)l.x=p/e.length,l.y=x/i,d.push(l.x,l.y)})(),(function(){for(let p=1;p<e.length;p++)for(let x=1;x<=i;x++){const v=(i+1)*(p-1)+(x-1),y=(i+1)*p+(x-1),b=(i+1)*p+x,E=(i+1)*(p-1)+x;f.push(v,y,E),f.push(y,b,E)}})()})(),this.setIndex(f),this.setAttribute("position",new ei(c,3)),this.setAttribute("normal",new ei(u,3)),this.setAttribute("uv",new ei(d,2))}}class f0{static get initial(){const e=new f0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const ZC={h:0,s:0,l:0};class vp{constructor(e){var n,r,i,a,s,l,c,u,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=f0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=vp.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new Kt(14737632),this._travelColor=new Kt(10027008),this._toolColors={},this.devMode=!1,this._lastRenderTime=0,this._wireframe=!1,this.minLayerThreshold=(n=e.minLayerThreshold)!==null&&n!==void 0?n:this.minLayerThreshold,this.parser=new tS(this.minLayerThreshold),this.scene=new gUe,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new Kt(e.backgroundColor)),this.targetId=e.targetId,this.endLayer=e.endLayer,this.startLayer=e.startLayer,this.lineWidth=e.lineWidth,this.lineHeight=e.lineHeight,this.buildVolume=e.buildVolume,this.initialCameraPosition=(r=e.initialCameraPosition)!==null&&r!==void 0?r:this.initialCameraPosition,this.debug=(i=e.debug)!==null&&i!==void 0?i:this.debug,this.renderExtrusion=(a=e.renderExtrusion)!==null&&a!==void 0?a:this.renderExtrusion,this.renderTravel=(s=e.renderTravel)!==null&&s!==void 0?s:this.renderTravel,this.nonTravelmoves=(l=e.nonTravelMoves)!==null&&l!==void 0?l:this.nonTravelmoves,this.renderTubes=(c=e.renderTubes)!==null&&c!==void 0?c:this.renderTubes,this.extrusionWidth=(u=e.extrusionWidth)!==null&&u!==void 0?u:this.extrusionWidth,this.devMode=(d=e.devMode)!==null&&d!==void 0?d:this.devMode,this.stats=this.devMode?new JUe:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new Kt(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new Kt(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new Kt(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[p,x]of Object.entries(e.toolColors))this._toolColors[parseInt(p)]=new Kt(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+rE),console.debug("opts",e),this.targetId&&console.warn("`targetId` is deprecated and will removed in the future. Use `canvas` instead."),e.canvas)this.canvas=e.canvas,this.renderer=new oj({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const p=document.getElementById(this.targetId);if(!p)throw new Error("Unable to find element "+this.targetId);this.renderer=new oj({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,p.appendChild(this.canvas)}this.camera=new Ss(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,g=.8*f;this.scene.fog=new qO(this._backgroundColor,g,f),this.resize(),this.controls=new XUe(this.camera,this.renderer.domElement),this.initScene(),this.animate(),e.allowDragNDrop&&this._enableDropHandler(),this.initStats()}get extrusionColor(){return this._extrusionColor}set extrusionColor(e){if(Array.isArray(e)){this._extrusionColor=[];for(const[n,r]of e.entries())this._extrusionColor[n]=new Kt(r)}else this._extrusionColor=new Kt(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?vp.defaultExtrusionColor:this._extrusionColor instanceof Kt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:vp.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new Kt(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new Kt(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new Kt(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new Kt(e):void 0}get layers(){return[this.parser.preamble].concat(this.parser.layers.concat())}get maxLayerIndex(){var e;return((e=this.endLayer)!==null&&e!==void 0?e:this.layers.length)-1}get minLayerIndex(){var e;return this.singleLayerMode?this.maxLayerIndex:((e=this.startLayer)!==null&&e!==void 0?e:0)-1}animate(){var e;this.animationFrameId=requestAnimationFrame((()=>this.animate())),this.controls.update(),this.renderer.render(this.scene,this.camera),(e=this.stats)===null||e===void 0||e.update()}processGCode(e){this.parser.parseGCode(e),this.render()}initScene(){for(;this.scene.children.length>0;)this.scene.remove(this.scene.children[0]);for(;this.disposables.length>0;){const e=this.disposables.pop();e&&e.dispose()}if(this.debug&&this.buildVolume){const e=new OUe(Math.max(this.buildVolume.x/2,this.buildVolume.y/2)+20);this.scene.add(e)}if(this.buildVolume&&this.drawBuildVolume(),this.renderTubes){console.warn("Volumetric rendering is experimental. It may not work as expected or change in the future.");const e=new jUe(13421772,.3*Math.PI),n=new PUe(16777215,Math.PI,void 0,.001);n.position.set(0,500,500),this.scene.add(e),this.scene.add(n)}}createGroup(e){const n=new Qx;return n.name=e,n.quaternion.setFromEuler(new sy(-Math.PI/2,0,0)),this.buildVolume?n.position.set(-this.buildVolume.x/2,0,this.buildVolume.y/2):n.position.set(-100,0,100),n}render(){const e=performance.now();this.group=this.createGroup("allLayers"),this.state=f0.initial,this.initScene();for(let n=0;n<this.layers.length;n++)this.renderLayer(n);this.batchGeometries(),this.scene.add(this.group),this.renderer.render(this.scene,this.camera),this._lastRenderTime=performance.now()-e}renderAnimated(e=1){return qC(this,void 0,void 0,(function*(){return this.initScene(),this.renderLayerIndex=0,this.renderFrameLoop(e>0?e:1)}))}renderFrameLoop(e){return new Promise((n=>{const r=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(r))};r()}))}renderFrame(e){this.group=this.createGroup("layer"+this.renderLayerIndex);for(let n=0;n<e&&this.renderLayerIndex+n<this.layers.length;n++)this.renderLayer(this.renderLayerIndex),this.renderLayerIndex++;this.batchGeometries(),this.scene.add(this.group)}renderLayer(e){var n,r,i,a,s,l,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const g of d.commands)if(g.gcode!="g20"){if(g.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const p=g;this.state.t=p.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(g.gcode)>-1){const p=g,x={x:(n=p.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=p.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=p.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=p.params.r)!==null&&a!==void 0?a:this.state.r,e:(s=p.params.e)!==null&&s!==void 0?s:this.state.e,i:(l=p.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=p.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const v=((u=p.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(g.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(v&&this.renderExtrusion||!v&&this.renderTravel)&&(g.gcode=="g2"||g.gcode=="g3"||g.gcode=="g02"||g.gcode=="g03"?this.addArcSegment(f,this.state,x,v,g.gcode=="g2"||g.gcode=="g02"):this.addLineSegment(f,this.state,x,v))}this.state.x=x.x,this.state.y=x.y,this.state.z=x.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const s=.1+.7*n/this.layers.length;a.getHSL(ZC),a=new Kt().setHSL(ZC.h,ZC.s,s)}if(n==this.layers.length-1){const s=(r=this._topLayerColor)!==null&&r!==void 0?r:a,l=(i=this._lastSegmentColor)!==null&&i!==void 0?i:s,c=e.extrusion.splice(-3),u=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,s.getHex(),e.height),this.addTubeLine([...u,...c],l.getHex(),e.height)):(this.addLine(e.extrusion,s.getHex()),this.addLine([...u,...c],l.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,a.getHex(),e.height):this.addLine(e.extrusion,a.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new ZUe(this.buildVolume.x,10,this.buildVolume.y,10));const e=QUe(this.buildVolume.x,this.buildVolume.z,this.buildVolume.y,8947848);e.position.setY(this.buildVolume.z/2),this.scene.add(e)}clear(){this.resetState(),this.parser=new tS(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=f0.initial,(e=this.devGui)===null||e===void 0||e.reset(),this._geometries={}}resize(){const[e,n]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,n,!1)}addLineSegment(e,n,r,i){(i?e.extrusion:e.travel).push(n.x,n.y,n.z,r.x,r.y,r.z)}addArcSegment(e,n,r,i,a){const s=i?e.extrusion:e.travel,l=n.x,c=n.y,u=n.z,d=r.x,f=r.y,g=r.z;let p=r.r,x=r.i,v=r.j;if(p){const q=d-l,W=f-c,$=Math.sqrt(Math.pow(q/2,2)+Math.pow(W/2,2));p=Math.max(p,$);const J=Math.pow(q,2)+Math.pow(W,2),ee=Math.pow(p,2)-J/4;let Q=Math.sqrt(ee/J);(a&&p<0||!a&&p>0)&&(Q=-Q),x=q/2+W*Q,v=W/2-q*Q}const y=l==d&&c==f,b=l+x,E=c+v,w=Math.sqrt(x*x+v*v),A=Math.atan2(-v,-x),T=Math.atan2(f-E,d-b);let C;y?C=2*Math.PI:(C=a?A-T:T-A,C<0&&(C+=2*Math.PI));let N=w*C/1.8;this.inches&&(N*=25),N<1&&(N=1);let O=C/N;O*=a?-1:1;const k=[];k.push({x:l,y:c,z:u});const j=(u-g)/N;let B=l,L=c,K=u,R=A;for(let q=0;q<N-1;q++)R+=O,B=b+w*Math.cos(R),L=E+w*Math.sin(R),K+=j,k.push({x:B,y:L,z:K});k.push({x:r.x,y:r.y,z:r.z});for(let q=0;q<k.length-1;q++)s.push(k[q].x,k[q].y,k[q].z,k[q+1].x,k[q+1].y,k[q+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new Sa;i.setAttribute("position",new ei(e,3)),this.disposables.push(i);const a=new ly({color:n});this.disposables.push(a);const s=new lE(i,a);(r=this.group)===null||r===void 0||r.add(s)}addTubeLine(e,n,r=.2){let i=[];const a=[];for(let s=0;s<e.length;s+=6){const l=e.slice(s,s+9),c=new Oe(l[0],l[1],l[2]),u=new Oe(l[3],l[4],l[5]),d=new Oe(l[6],l[7],l[8]);i.push(c),u.equals(d)||(i.push(u),a.push(i),i=[])}a.forEach((s=>{var l;const c=new eze(s,this.extrusionWidth,this.lineHeight||r,4);(l=this._geometries)[n]||(l[n]=[]),this._geometries[n].push(c)}))}addThickLine(e,n){var r;if(!e.length||!this.lineWidth)return;const i=new RQ;this.disposables.push(i);const a=new jQ({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const s=new YUe(i,a);(r=this.group)===null||r===void 0||r.add(s)}dispose(){this.disposables.forEach((e=>e.dispose())),this.disposables=[],this.controls.dispose(),this.renderer.dispose(),this.cancelAnimation()}cancelAnimation(){this.animationFrameId!==void 0&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0}_enableDropHandler(){console.warn("Drag and drop is deprecated as a library feature. See the demo how to implement your own."),this.canvas.addEventListener("dragover",(e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),this.canvas.classList.add("dragging")})),this.canvas.addEventListener("dragleave",(e=>{e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging")})),this.canvas.addEventListener("drop",(e=>qC(this,void 0,void 0,(function*(){var n,r;e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging");const i=((r=(n=e.dataTransfer)===null||n===void 0?void 0:n.files)!==null&&r!==void 0?r:[])[0];this.clear(),yield this._readFromStream(i.stream()),this.render()}))))}batchGeometries(){if(this._geometries)for(const e in this._geometries){const n=this.createBatchMesh(parseInt(e));for(;this._geometries[e].length>0;){const r=this._geometries[e].pop();n.addGeometry(r)}}}createBatchMesh(e){var n;const r=this._geometries[e],i=new TUe({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),s=new MUe(r.length,a,void 0,i);return this.disposables.push(s),(n=this.group)===null||n===void 0||n.add(s),s}_readFromStream(e){var n,r;return qC(this,void 0,void 0,(function*(){const i=e.getReader();let a,s="",l=0;do{console.debug("reading from stream"),a=yield i.read(),l+=(r=(n=a.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=a.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
- `),f=u.slice(0,d);this.parser.parseGCode(s+f),s=u.slice(d)}while(!a.done);var c;console.debug("read from stream",l)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new d7(this):typeof this.devMode=="object"&&(this.devGui=new d7(this,this.devMode))}initStats(){var e;this.stats&&(typeof this.devMode=="object"&&(this.statsContainer=this.devMode.statsContainer),((e=this.statsContainer)!==null&&e!==void 0?e:document.body).appendChild(this.stats.dom),this.stats.dom.classList.add("stats"),this.initGui())}}vp.defaultExtrusionColor=new Kt("hotpink");const tze=function(t){return new vp(t)};function nze({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=S.useRef(null),a=S.useRef(null),s=S.useRef(null),[l,c]=S.useState(!0),[u,d]=S.useState(null),[f,g]=S.useState(!1),[p,x]=S.useState(0),[v,y]=S.useState(0);S.useEffect(()=>{if(!i.current)return;const w=i.current,A=n&&n.length>0,T=n&&n.length>1,C=A?n[0]:"#00ae42",N=tze({canvas:w,buildVolume:e,backgroundColor:1710618,travelColor:4473924,extrusionColor:T?n:C,...T?{}:{topLayerColor:C},...T?{disableGradient:!0}:{},lastSegmentColor:16777215,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=N,c(!0),d(null),g(!1),fetch(t).then(async k=>{if(!k.ok)throw k.status===404&&(await k.json().catch(()=>({}))).detail?.includes("sliced")?(g(!0),new Error("not_sliced")):new Error("Failed to load G-code");return k.text()}).then(k=>{let j=k;T&&(j=k.split(`
- `).map(L=>{const K=L.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(K){const R=parseInt(K[2],10);if(R>15)return`${K[1]}; FILTERED: T${R}${K[3]||""}`}return L}).join(`
- `),j=`T0
- ${j}`),N.processGCode(j);const B=N.layers?.length||0;y(B),x(B),N.render(),c(!1)}).catch(k=>{d(k.message),c(!1)});const O=()=>{if(w.parentElement){const k=w.parentElement.getBoundingClientRect();w.width=k.width,w.height=k.height,N.resize()}};return O(),window.addEventListener("resize",O),()=>{window.removeEventListener("resize",O),s.current&&cancelAnimationFrame(s.current),N.dispose()}},[t,e,n]);const b=S.useCallback(w=>{if(!a.current)return;const A=Math.max(1,Math.min(w,v));x(A),s.current&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=A,a.current.render())})},[v]),E=w=>{b(parseInt(w.target.value,10))};return o.jsxs("div",{className:`relative flex flex-col h-full ${r}`,children:[o.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[o.jsx("canvas",{ref:i,className:"w-full h-full"}),l&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:o.jsxs("div",{className:"text-center",children:[o.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),o.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),f&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:o.jsxs("div",{className:"text-center max-w-sm px-4",children:[o.jsx(zle,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),o.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),o.jsx("p",{className:"text-bambu-gray text-sm",children:"This file hasn't been sliced yet. G-code preview is only available after slicing the model in Bambu Studio or Orca Slicer."})]})}),u&&!f&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:o.jsx("div",{className:"text-center text-red-400",children:o.jsx("p",{className:"text-sm",children:u})})})]}),!l&&!u&&!f&&v>0&&o.jsx("div",{className:"mt-4 px-2",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(gd,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),o.jsx("button",{onClick:()=>b(p-1),disabled:p<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:o.jsx(Jh,{className:"w-4 h-4"})}),o.jsx("input",{type:"range",min:1,max:v,value:p,onChange:E,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),o.jsx("button",{onClick:()=>b(p+1),disabled:p>=v,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:o.jsx(Ko,{className:"w-4 h-4"})}),o.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[p," / ",v]})]})})]})}function rze({archiveId:t,title:e,onClose:n}){const[r,i]=S.useState(null),[a,s]=S.useState(null),[l,c]=S.useState(!0);S.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),S.useEffect(()=>{_e.getArchiveCapabilities(t).then(d=>{s(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),c(!1)}).catch(()=>{s({has_model:!0,has_gcode:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),i("3d"),c(!1)})},[t]);const u=()=>{const d=e||"model",f=`${window.location.origin}${_e.getArchiveForSlicer(t,d)}`;bh(f)};return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:d=>d.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[o.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(ke,{variant:"secondary",size:"sm",onClick:u,children:[o.jsx(la,{className:"w-4 h-4"}),"Open in Slicer"]}),o.jsx(ke,{variant:"ghost",size:"sm",onClick:n,children:o.jsx(Wt,{className:"w-5 h-5"})})]})]}),a&&o.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[o.jsxs("button",{onClick:()=>a.has_model&&i("3d"),disabled:!a.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="3d"?"text-bambu-green border-b-2 border-bambu-green":a.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[o.jsx(Qh,{className:"w-4 h-4"}),"3D Model",!a.has_model&&o.jsx("span",{className:"text-xs",children:"(not available)"})]}),o.jsxs("button",{onClick:()=>a.has_gcode&&i("gcode"),disabled:!a.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="gcode"?"text-bambu-green border-b-2 border-bambu-green":a.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[o.jsx(fle,{className:"w-4 h-4"}),"G-code Preview",!a.has_gcode&&o.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),o.jsx("div",{className:"flex-1 overflow-hidden p-4",children:l?o.jsx("div",{className:"w-full h-full flex items-center justify-center",children:o.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?o.jsx(QDe,{url:_e.getArchiveDownload(t),buildVolume:a.build_volume,className:"w-full h-full"}):r==="gcode"&&a?o.jsx(nze,{gcodeUrl:_e.getArchiveGcode(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):o.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function ize({archiveId:t,archiveName:e,onClose:n,onSuccess:r}){const i=pn(),[a,s]=S.useState(null),[l,c]=S.useState(!1);S.useEffect(()=>{const A=T=>{T.key==="Escape"&&n()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[n]);const{data:u,isLoading:d}=gt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:f}=gt({queryKey:["archive-filaments",t],queryFn:()=>_e.getArchiveFilamentRequirements(t)}),{data:g}=gt({queryKey:["printer-status",a],queryFn:()=>_e.getPrinterStatus(a),enabled:!!a}),p=vt({mutationFn:()=>{if(!a)throw new Error("No printer selected");return _e.reprintArchive(t,a)},onSuccess:()=>{r(),n()}}),x=u?.filter(A=>A.is_active)||[],v=A=>A?`#${A.replace("#","").substring(0,6)}`:"#808080",y=(A,T,C,N)=>{const O=String.fromCharCode(65+(A>=128?A-128:A));return C?`HT-${O}`:`AMS-${O} Slot ${T+1}`},b=S.useMemo(()=>{const A=[];return g?.ams?.forEach(T=>{const C=T.tray.length===1;T.tray.forEach(N=>{N.tray_type&&A.push({type:N.tray_type,color:v(N.tray_color),amsId:T.id,trayId:N.id,isHt:C,isExternal:!1,label:y(T.id,N.id,C)})})}),g?.vt_tray?.tray_type&&A.push({type:g.vt_tray.tray_type,color:v(g.vt_tray.tray_color),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External"}),A},[g]),E=S.useMemo(()=>{if(!f?.filaments||f.filaments.length===0)return[];const A=C=>C?C.replace("#","").toLowerCase().substring(0,6):"",T=(C,N,O=40)=>{const k=A(C),j=A(N);if(!k||!j||k.length<6||j.length<6)return!1;const B=parseInt(k.substring(0,2),16),L=parseInt(k.substring(2,4),16),K=parseInt(k.substring(4,6),16),R=parseInt(j.substring(0,2),16),q=parseInt(j.substring(2,4),16),W=parseInt(j.substring(4,6),16);return Math.abs(B-R)<=O&&Math.abs(L-q)<=O&&Math.abs(K-W)<=O};return f.filaments.map(C=>{const N=b.find(q=>q.type?.toUpperCase()===C.type?.toUpperCase()&&A(q.color)===A(C.color)),O=!N&&b.find(q=>q.type?.toUpperCase()===C.type?.toUpperCase()&&T(q.color,C.color)),k=!N&&!O&&b.find(q=>q.type?.toUpperCase()===C.type?.toUpperCase()),j=N||O||k||void 0,B=!!j,L=B,K=!!N||!!O;let R;return N||O?R="match":k?R="type_only":R="mismatch",{...C,loaded:j,hasFilament:B,typeMatch:L,colorMatch:K,status:R}})},[f,b]),w=E.some(A=>A.status==="mismatch");return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:o.jsx(Mt,{className:"w-full max-w-md",children:o.jsxs(At,{children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),o.jsx(ke,{variant:"ghost",size:"sm",onClick:n,children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",o.jsx("span",{className:"text-white",children:e})," to a printer"]}),d?o.jsx("div",{className:"flex justify-center py-8",children:o.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):x.length===0?o.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):o.jsx("div",{className:"space-y-2 mb-6",children:x.map(A=>o.jsxs("button",{onClick:()=>s(A.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${a===A.id?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[o.jsx("div",{className:`p-2 rounded-lg ${a===A.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:o.jsx(Gi,{className:`w-5 h-5 ${a===A.id?"text-bambu-green":"text-bambu-gray"}`})}),o.jsxs("div",{className:"text-left",children:[o.jsx("p",{className:"text-white font-medium",children:A.name}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[A.model||"Unknown model"," • ",A.ip_address]})]})]},A.id))}),a&&E.length>0&&o.jsxs("div",{className:"mb-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:"Filament Check"}),o.jsxs("button",{onClick:async()=>{if(a){c(!0);try{await _e.refreshPrinterStatus(a),await new Promise(A=>setTimeout(A,500)),await i.refetchQueries({queryKey:["printer-status",a]})}finally{c(!1)}}},className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",title:"Re-read AMS status from printer",disabled:l,children:[o.jsx(li,{className:`w-3 h-3 ${l?"animate-spin":""}`}),o.jsx("span",{children:"Re-read"})]}),w?o.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[o.jsx(Gn,{className:"w-3 h-3"}),"Type not found"]}):E.some(A=>A.status==="type_only")?o.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[o.jsx(Gn,{className:"w-3 h-3"}),"Color mismatch"]}):o.jsxs("span",{className:"text-xs text-bambu-green flex items-center gap-1",children:[o.jsx(po,{className:"w-3 h-3"}),"Ready"]})]}),o.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 space-y-2 text-xs",children:E.map((A,T)=>o.jsxs("div",{className:"grid items-center gap-2",style:{gridTemplateColumns:"16px 1fr auto 16px 1fr 16px"},children:[o.jsx("span",{title:`Required: ${A.color}`,children:o.jsx(_U,{className:"w-3 h-3 flex-shrink-0",fill:A.color,stroke:A.color})}),o.jsxs("span",{className:"text-white truncate",children:[A.type," ",o.jsxs("span",{className:"text-bambu-gray",children:["(",A.used_grams,"g)"]})]}),o.jsx("span",{className:"text-bambu-gray",children:"→"}),A.loaded?o.jsx("span",{title:`Loaded: ${A.loaded.color}`,children:o.jsx(_U,{className:"w-3 h-3 flex-shrink-0",fill:A.loaded.color,stroke:A.loaded.color})}):o.jsx("span",{}),o.jsx("span",{className:A.status==="match"?"text-bambu-green":A.status==="type_only"?"text-yellow-400":"text-orange-400",children:A.loaded?o.jsxs(o.Fragment,{children:[A.loaded.type," ",o.jsxs("span",{className:"text-bambu-gray",children:["(",A.loaded.label,")"]})]}):"Not loaded"}),A.status==="match"?o.jsx(po,{className:"w-3 h-3 text-bambu-green"}):A.status==="type_only"?o.jsx("span",{title:"Same type, different color",children:o.jsx(Gn,{className:"w-3 h-3 text-yellow-400"})}):o.jsx("span",{title:"Filament type not loaded",children:o.jsx(Gn,{className:"w-3 h-3 text-orange-400"})})]},T))}),w&&o.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]}),p.isError&&o.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:p.error.message||"Failed to start print"}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx(ke,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),o.jsx(ke,{onClick:()=>p.mutate(),disabled:!a||p.isPending,className:"flex-1",children:p.isPending?o.jsxs(o.Fragment,{children:[o.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Gi,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function aze({onClose:t,initialFiles:e}){const n=pn(),{showToast:r}=Ar(),i=S.useRef(null),[a,s]=S.useState(()=>e?.filter(N=>N.name.endsWith(".3mf")).map(N=>({file:N,status:"pending"}))||[]),[l,c]=S.useState(!1),[u,d]=S.useState(),[f,g]=S.useState(null);S.useEffect(()=>{const N=O=>{O.key==="Escape"&&t()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[t]);const{data:p}=gt({queryKey:["printers"],queryFn:_e.getPrinters}),x=vt({mutationFn:N=>_e.uploadArchivesBulk(N,u),onSuccess:N=>{g(N),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),s(O=>O.map(k=>{const j=N.results.find(L=>L.filename===k.file.name),B=N.errors.find(L=>L.filename===k.file.name);return j?{...k,status:"success",archiveId:j.id}:B?{...k,status:"error",error:B.error}:k})),N.failed===0?r(`${N.uploaded} file${N.uploaded!==1?"s":""} uploaded`):N.uploaded===0?r(`Failed to upload ${N.failed} file${N.failed!==1?"s":""}`,"error"):r(`${N.uploaded} uploaded, ${N.failed} failed`,"warning")},onError:()=>{s(N=>N.map(O=>({...O,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),v=S.useCallback(N=>{N.preventDefault(),c(!0)},[]),y=S.useCallback(N=>{N.preventDefault(),c(!1)},[]),b=S.useCallback(N=>{N.preventDefault(),c(!1);const O=Array.from(N.dataTransfer.files).filter(k=>k.name.endsWith(".3mf"));O.length>0&&s(k=>[...k,...O.map(j=>({file:j,status:"pending"}))])},[]),E=S.useCallback(N=>{const O=Array.from(N.target.files||[]).filter(k=>k.name.endsWith(".3mf"));O.length>0&&s(k=>[...k,...O.map(j=>({file:j,status:"pending"}))]),i.current&&(i.current.value="")},[]),w=S.useCallback(N=>{s(O=>O.filter((k,j)=>j!==N))},[]),A=()=>{if(a.length===0)return;const N=a.filter(O=>O.status==="pending");N.length!==0&&(s(O=>O.map(k=>k.status==="pending"?{...k,status:"uploading"}:k)),x.mutate(N.map(O=>O.file)))},T=a.filter(N=>N.status==="pending").length,C=x.isPending;return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:o.jsx(Mt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:o.jsxs(At,{className:"p-0 flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),o.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsx("div",{className:"p-4",children:o.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:v,onDragLeave:y,onDrop:b,children:[o.jsx(ca,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),o.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),o.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),o.jsx(ke,{variant:"secondary",onClick:()=>i.current?.click(),disabled:C,children:"Browse Files"}),o.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:E})]})}),o.jsxs("div",{className:"px-4 pb-4",children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),o.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u||"",onChange:N=>d(N.target.value?Number(N.target.value):void 0),disabled:C,children:[o.jsx("option",{value:"",children:"No printer"}),p?.map(N=>o.jsx("option",{value:N.id,children:N.name},N.id))]})]}),a.length>0&&o.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:o.jsx("div",{className:"space-y-2",children:a.map((N,O)=>o.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[o.jsx(dR,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),o.jsx("span",{className:"flex-1 text-white text-sm truncate",children:N.file.name}),o.jsxs("span",{className:"text-xs text-bambu-gray",children:[(N.file.size/(1024*1024)).toFixed(1)," MB"]}),N.status==="pending"&&o.jsx("button",{onClick:()=>w(O),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:C,children:o.jsx(Wt,{className:"w-4 h-4"})}),N.status==="uploading"&&o.jsx(pt,{className:"w-4 h-4 text-bambu-green animate-spin"}),N.status==="success"&&o.jsx(kr,{className:"w-4 h-4 text-bambu-green"}),N.status==="error"&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-red-400",children:N.error}),o.jsx(Oa,{className:"w-4 h-4 text-red-400"})]})]},`${N.file.name}-${O}`))})}),f&&o.jsx("div",{className:"px-4 pb-4",children:o.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:o.jsxs("p",{className:"text-sm text-white",children:[o.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&o.jsxs(o.Fragment,{children:[", ",o.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),o.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[o.jsx(ke,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&o.jsx(ke,{onClick:A,disabled:T===0||C,className:"flex-1",children:C?o.jsxs(o.Fragment,{children:[o.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):o.jsxs(o.Fragment,{children:[o.jsx(ca,{className:"w-4 h-4"}),"Upload ",T>0&&`(${T})`]})})]})]})})})}const sze=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],oze=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function lze({archive:t,onClose:e,existingTags:n=[]}){S.useEffect(()=>{const ie=le=>{le.key==="Escape"&&e()};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[e]);const r=pn(),[i,a]=S.useState(t.print_name||""),[s,l]=S.useState(t.printer_id),[c,u]=S.useState(t.project_id??null),[d,f]=S.useState(t.notes||""),[g,p]=S.useState(t.tags||""),[x,v]=S.useState(t.failure_reason||""),[y,b]=S.useState(t.status),[E,w]=S.useState(t.quantity??1),[A,T]=S.useState(t.photos||[]),[C,N]=S.useState(!1),[O,k]=S.useState(!1),j=S.useRef(null),B=S.useRef(null),L=S.useRef(null),{data:K}=gt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:R}=gt({queryKey:["projects"],queryFn:()=>_e.getProjects()}),{data:q}=gt({queryKey:["archives"],queryFn:()=>_e.getArchives(void 0,1e3,0),enabled:n.length===0}),W=n.length>0?n:[...new Set(q?.flatMap(ie=>ie.tags?.split(",").map(le=>le.trim())||[]).filter(Boolean)||[])].sort(),$=g.split(",").map(ie=>ie.trim()).filter(Boolean),J=W.filter(ie=>!$.includes(ie)),ee=ie=>{if(!$.includes(ie)){const le=[...$,ie].join(", ");p(le)}L.current!==null&&clearTimeout(L.current),j.current?.focus()},Q=ie=>{const le=$.filter(ge=>ge!==ie).join(", ");p(le)},z=vt({mutationFn:ie=>_e.updateArchive(t.id,ie),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),V=async ie=>{const le=ie.target.files?.[0];if(le){N(!0);try{const ge=await _e.uploadArchivePhoto(t.id,le);T(ge.photos),r.invalidateQueries({queryKey:["archives"]})}catch(ge){console.error("Failed to upload photo:",ge)}finally{N(!1),B.current&&(B.current.value="")}}},X=async ie=>{try{const le=await _e.deleteArchivePhoto(t.id,ie);T(le.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(le){console.error("Failed to delete photo:",le)}},te=ie=>{ie.preventDefault();const le={print_name:i||void 0,printer_id:s,project_id:c,notes:d||void 0,tags:g||void 0,quantity:E};y!==t.status&&(le.status=y),y==="failed"||y==="aborted"?le.failure_reason=x||void 0:(t.status==="failed"||t.status==="aborted")&&(le.failure_reason=null),z.mutate(le)};return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:ie=>ie.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),o.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("form",{onSubmit:te,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),o.jsx("input",{type:"text",value:i,onChange:ie=>a(ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"Print name"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),o.jsxs("select",{value:s??"",onChange:ie=>l(ie.target.value?Number(ie.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"",children:"No printer"}),K?.map(ie=>o.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[o.jsx(Bo,{className:"w-4 h-4 inline mr-1"}),"Project"]}),o.jsxs("select",{value:c??"",onChange:ie=>u(ie.target.value?Number(ie.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"",children:"No project"}),R?.map(ie=>o.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[o.jsx(cce,{className:"w-4 h-4 inline mr-1"}),"Items Printed"]}),o.jsx("input",{type:"number",min:1,value:E,onChange:ie=>w(Math.max(1,parseInt(ie.target.value)||1)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"1"}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of items produced in this print job"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),o.jsx("textarea",{value:d,onChange:ie=>f(ie.target.value),rows:3,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none resize-none",placeholder:"Add notes about this print..."})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),$.length>0&&o.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:$.map(ie=>o.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[o.jsx(Cp,{className:"w-3 h-3"}),ie,o.jsx("button",{type:"button",onClick:()=>Q(ie),className:"ml-0.5 text-bambu-gray hover:text-white",children:o.jsx(Wt,{className:"w-3 h-3"})})]},ie))}),o.jsxs("div",{className:"relative",children:[o.jsx("input",{ref:j,type:"text",value:g,onChange:ie=>p(ie.target.value),onFocus:()=>{L.current!==null&&clearTimeout(L.current),k(!0)},onBlur:()=>{L.current=window.setTimeout(()=>k(!1),200)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:$.length>0?"Add more tags...":"Add tags..."}),O&&J.length>0&&o.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10 max-h-40 overflow-y-auto",children:[o.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),o.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:J.map(ie=>o.jsx("button",{type:"button",onClick:()=>ee(ie),className:"px-2 py-0.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded text-sm text-bambu-gray hover:text-white transition-colors",children:ie},ie))})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),o.jsx("select",{value:y,onChange:ie=>{b(ie.target.value),ie.target.value==="completed"&&v("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:oze.map(ie=>o.jsx("option",{value:ie.value,children:ie.label},ie.value))})]}),(y==="failed"||y==="aborted")&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),o.jsxs("select",{value:x,onChange:ie=>v(ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"",children:"Select reason..."}),sze.map(ie=>o.jsx("option",{value:ie,children:ie},ie))]})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[o.jsx(R0,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),o.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[A.map(ie=>o.jsxs("div",{className:"relative group",children:[o.jsx("img",{src:_e.getArchivePhotoUrl(t.id,ie),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),o.jsx("button",{type:"button",onClick:()=>X(ie),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(Nn,{className:"w-3 h-3 text-white"})})]},ie)),o.jsxs("label",{className:"w-20 h-20 flex items-center justify-center border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green transition-colors",children:[o.jsx("input",{ref:B,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:V,className:"hidden",disabled:C}),C?o.jsx(pt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):o.jsx(fr,{className:"w-6 h-6 text-bambu-gray"})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{type:"submit",disabled:z.isPending,className:"flex-1",children:[o.jsx(Ts,{className:"w-4 h-4"}),z.isPending?"Saving...":"Save"]})]})]})]})})}function cze({x:t,y:e,items:n,onClose:r}){const i=S.useRef(null),[a,s]=S.useState(null),l=S.useRef(null),[c,u]=S.useState({x:t,y:e,visible:!1}),[d,f]=S.useState(!1);S.useEffect(()=>{const x=b=>{i.current&&!i.current.contains(b.target)&&r()},v=b=>{b.key==="Escape"&&r()},y=()=>{r()};return document.addEventListener("mousedown",x),document.addEventListener("keydown",v),document.addEventListener("scroll",y,!0),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",v),document.removeEventListener("scroll",y,!0),l.current&&clearTimeout(l.current)}},[r]),S.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const x=i.current.getBoundingClientRect(),v=window.innerWidth,y=window.innerHeight,b=8;let E=t,w=e;t+x.width>v-b&&(E=Math.max(b,v-x.width-b)),E<b&&(E=b),e+x.height>y-b&&(w=Math.max(b,y-x.height-b)),w<b&&(w=b);const A=180,T=v-E-x.width,C=E;f(T<A&&C>A),u({x:E,y:w,visible:!0})}},[t,e]);const g=x=>{l.current&&(clearTimeout(l.current),l.current=null),s(x)},p=()=>{l.current=window.setTimeout(()=>{s(null)},150)};return o.jsx("div",{ref:i,className:"fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1",style:{left:c.x,top:c.y,visibility:c.visible?"visible":"hidden"},children:n.map((x,v)=>{if(x.divider)return o.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},v);const y=x.submenu&&x.submenu.length>0;return o.jsxs("div",{className:"relative",onMouseEnter:()=>y&&g(v),onMouseLeave:()=>y&&p(),children:[o.jsxs("button",{onMouseEnter:()=>y&&g(v),onClick:()=>{y?s(a===v?null:v):x.disabled||(x.onClick(),r())},disabled:x.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${x.disabled?"text-bambu-gray cursor-not-allowed":x.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${y&&a===v?"bg-bambu-dark-tertiary":""}`,children:[x.icon&&o.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:x.icon}),o.jsx("span",{className:"flex-1",children:x.label}),y&&o.jsx(Ko,{className:"w-4 h-4 text-bambu-gray"})]}),y&&a===v&&o.jsx("div",{className:`absolute top-0 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60] ${d?"right-full mr-1":"left-full ml-1"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>p(),children:x.submenu.map((b,E)=>o.jsxs("button",{onClick:()=>{b.disabled||(b.onClick(),r())},disabled:b.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${b.disabled?"text-bambu-gray cursor-not-allowed":b.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[b.icon&&o.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:b.icon}),b.label]},E))})]},v)})})}function uze({selectedIds:t,existingTags:e,onClose:n}){const r=pn(),{showToast:i}=Ar(),[a,s]=S.useState(""),[l,c]=S.useState(new Set),[u,d]=S.useState("add");S.useEffect(()=>{const v=y=>{y.key==="Escape"&&n()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n]);const f=vt({mutationFn:async()=>{const v=Array.from(l);let y=0;for(const b of t)try{const E=await _e.getArchive(b),w=E.tags?E.tags.split(",").map(T=>T.trim()).filter(Boolean):[];let A;u==="add"?A=[...new Set([...w,...v])]:A=w.filter(T=>!l.has(T)),await _e.updateArchive(b,{tags:A.join(", ")}),y++}catch(E){throw console.error(`Failed to update archive ${b}:`,E),new Error(`Failed on archive ${b}: ${E instanceof Error?E.message:"Unknown error"}`)}return{count:y,mode:u,tags:v}},onSuccess:({count:v,mode:y,tags:b})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${y==="add"?"Added":"Removed"} ${b.length} tag${b.length!==1?"s":""} ${y==="add"?"to":"from"} ${v} archive${v!==1?"s":""}`),n()},onError:v=>{i(v.message||"Failed to update tags","error")}}),g=v=>{c(y=>{const b=new Set(y);return b.has(v)?b.delete(v):b.add(v),b})},p=()=>{a.trim()&&!l.has(a.trim())&&(c(v=>new Set([...v,a.trim()])),s(""))},x=v=>{v.key==="Enter"&&(v.preventDefault(),p())};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:o.jsx(Mt,{className:"w-full max-w-md",children:o.jsxs(At,{className:"p-0",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Cp,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),o.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"p-4 space-y-4",children:[o.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(ke,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),o.jsx(ke,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:a,onChange:v=>s(v.target.value),onKeyDown:x}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:p,disabled:!a.trim(),children:o.jsx(fr,{className:"w-4 h-4"})})]}),e.length>0&&o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(v=>o.jsx("button",{onClick:()=>g(v),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(v)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:v},v))})]}),l.size>0&&o.jsxs("div",{children:[o.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),o.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(l).map(v=>o.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[v,o.jsx("button",{onClick:()=>g(v),className:"hover:opacity-70",children:o.jsx(Wt,{className:"w-3 h-3"})})]},v))})]})]}),o.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[o.jsx(ke,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),o.jsx(ke,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?o.jsxs(o.Fragment,{children:[o.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Cp,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function dze(t,e){return new Date(t,e+1,0).getDate()}function hze(t,e){return new Date(t,e,1).getDay()}const fze=["January","February","March","April","May","June","July","August","September","October","November","December"],mze=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function pze({archives:t,onArchiveClick:e}){const n=new Date,[r,i]=S.useState(n.getMonth()),[a,s]=S.useState(n.getFullYear()),[l,c]=S.useState(null),u=S.useMemo(()=>{const b=new Map;return t.forEach(E=>{const w=new Date(E.completed_at||E.created_at),A=`${w.getFullYear()}-${String(w.getMonth()+1).padStart(2,"0")}-${String(w.getDate()).padStart(2,"0")}`,T=b.get(A)||[];T.push(E),b.set(A,T)}),b},[t]),d=dze(a,r),f=hze(a,r),g=()=>{r===0?(i(11),s(a-1)):i(r-1)},p=()=>{r===11?(i(0),s(a+1)):i(r+1)},x=()=>{i(n.getMonth()),s(n.getFullYear())},v=[];for(let b=0;b<f;b++)v.push(null);for(let b=1;b<=d;b++)v.push(b);const y=l?u.get(l)||[]:[];return o.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[o.jsxs("div",{className:"flex-1",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("button",{onClick:g,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Jh,{className:"w-5 h-5 text-bambu-gray"})}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white",children:[fze[r]," ",a]}),o.jsx("button",{onClick:x,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),o.jsx("button",{onClick:p,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Ko,{className:"w-5 h-5 text-bambu-gray"})})]}),o.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:mze.map(b=>o.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:b},b))}),o.jsx("div",{className:"grid grid-cols-7 gap-1",children:v.map((b,E)=>{if(b===null)return o.jsx("div",{className:"aspect-square"},`empty-${E}`);const w=`${a}-${String(r+1).padStart(2,"0")}-${String(b).padStart(2,"0")}`,A=u.get(w)||[],T=A.length>0,C=b===n.getDate()&&r===n.getMonth()&&a===n.getFullYear(),N=w===l,O=A.filter(j=>j.status==="completed").length,k=A.filter(j=>j.status==="failed").length;return o.jsxs("button",{onClick:()=>c(N?null:w),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${N?"bg-bambu-green text-white":C?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":T?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[o.jsx("span",{className:`text-sm font-medium ${C&&!N?"text-bambu-green":""}`,children:b}),T&&o.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[o.jsx("div",{className:`w-2 h-2 rounded-full ${k>0&&O===0?"bg-red-400":k>0?"bg-yellow-400":"bg-green-400"}`}),o.jsx("span",{className:"text-xs font-medium",children:A.length})]})]},b)})}),o.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:o.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===a}).length}),o.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===a&&b.status==="completed"}).length}),o.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(b=>{const E=new Date(b.completed_at||b.created_at);return E.getMonth()===r&&E.getFullYear()===a&&b.status==="failed"}).length}),o.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),o.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:l?o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(l+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),y.length>0?o.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:y.map(b=>o.jsxs("button",{onClick:()=>e?.(b),className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-left",children:[b.thumbnail_path?o.jsx("img",{src:_e.getArchiveThumbnail(b.id),alt:"",className:"w-12 h-12 rounded object-cover"}):o.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:o.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm text-white truncate",children:b.print_name||b.filename}),o.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[o.jsx("span",{className:b.status==="failed"?"text-red-400":"text-green-400",children:b.status==="failed"?"Failed":"Completed"}),b.filament_color&&o.jsx("div",{className:"flex gap-0.5",children:b.filament_color.split(",").map((E,w)=>o.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:E}},w))})]})]})]},b.id))}):o.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):o.jsx("div",{className:"text-center py-8",children:o.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function gze({archiveId:t,archiveName:e,onClose:n}){const r=_e.getArchiveQRCodeUrl(t,300);S.useEffect(()=>{const a=s=>{s.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]);const i=()=>{const a=document.createElement("a");a.href=r,a.download=`${e}_qrcode.png`,a.click()};return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),o.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"p-6 flex flex-col items-center",children:[o.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),o.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:o.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),o.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),o.jsxs(ke,{onClick:i,className:"w-full",children:[o.jsx(as,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function xze({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,s]=S.useState(0),[l,c]=S.useState(!1);if(S.useEffect(()=>{const p=x=>{x.key==="Escape"&&r(),x.key==="ArrowLeft"&&s(v=>Math.max(0,v-1)),x.key==="ArrowRight"&&s(v=>Math.min(n.length-1,v+1))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r,n.length]),S.useEffect(()=>{a>=n.length&&s(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;const u=n[a],d=_e.getArchivePhotoUrl(t,u),f=()=>{const p=document.createElement("a");p.href=d,p.download=`${e}_photo_${a+1}.jpg`,p.click()},g=()=>{i&&c(!0)};return o.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[o.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:p=>p.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),o.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(ke,{variant:"secondary",size:"sm",onClick:f,children:[o.jsx(as,{className:"w-4 h-4"}),"Download"]}),i&&o.jsx(ke,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:o.jsx(Nn,{className:"w-4 h-4"})}),o.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:o.jsx(Wt,{className:"w-6 h-6"})})]})]}),o.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&o.jsx("button",{onClick:()=>s(p=>p-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:o.jsx(Jh,{className:"w-8 h-8 text-white"})}),o.jsx("img",{src:d,alt:`Photo ${a+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),a<n.length-1&&o.jsx("button",{onClick:()=>s(p=>p+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:o.jsx(Ko,{className:"w-8 h-8 text-white"})})]}),n.length>1&&o.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((p,x)=>o.jsx("button",{onClick:()=>s(x),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${x===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:o.jsx("img",{src:_e.getArchivePhotoUrl(t,p),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},p))})]}),l&&o.jsx(br,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function na(t){this.content=t}na.prototype={constructor:na,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),a=r.content.slice();return i==-1?a.push(n||t,e):(a[i+1]=e,n&&(a[i]=n)),new na(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new na(n)},addToStart:function(t,e){return new na([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new na(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),a=r.find(t);return i.splice(a==-1?i.length:a,0,e,n),new na(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=na.from(t),t.size?new na(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=na.from(t),t.size?new na(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=na.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};na.from=function(t){if(t instanceof na)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new na(e)};function DQ(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),a=e.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let s=0;i.text[s]==a.text[s];s++)n++;return n}if(i.content.size||a.content.size){let s=DQ(i.content,a.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function OQ(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let s=t.child(--i),l=e.child(--a),c=s.nodeSize;if(s==l){n-=c,r-=c;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let u=0,d=Math.min(s.text.length,l.text.length);for(;u<d&&s.text[s.text.length-u-1]==l.text[l.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(s.content.size||l.content.size){let u=OQ(s.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class bt{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,a){for(let s=0,l=0;l<n;s++){let c=this.content[s],u=l+c.nodeSize;if(u>e&&r(c,i+l,a||null,s)!==!1&&c.content.size){let d=l+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,n-d),r,i+d)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let a="",s=!0;return this.nodesBetween(e,n,(l,c)=>{let u=l.isText?l.text.slice(Math.max(e,c)-c,n-c):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(s?s=!1:a+=r),a+=u},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<e.content.length;a++)i.push(e.content[a]);return new bt(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let a=0,s=0;s<n;a++){let l=this.content[a],c=s+l.nodeSize;c>e&&((s<e||c>n)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),i+=l.nodeSize),s=c}return new bt(r,i)}cutByIndex(e,n){return e==n?bt.empty:e==0&&n==this.content.length?this:new bt(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new bt(i,a)}addToStart(e){return new bt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new bt(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return DQ(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return OQ(this,e,n,r)}findIndex(e){if(e==0)return K_(0,e);if(e==this.size)return K_(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),a=r+i.nodeSize;if(a>=e)return a==e?K_(n+1,a):K_(n,r);r=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return bt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new bt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return bt.empty;let n,r=0;for(let i=0;i<e.length;i++){let a=e[i];r+=a.nodeSize,i&&a.isText&&e[i-1].sameMarkup(a)?(n||(n=e.slice(0,i)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new bt(n||e,r)}static from(e){if(!e)return bt.empty;if(e instanceof bt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new bt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}bt.empty=new bt([],0);const QC={index:0,offset:0};function K_(t,e){return QC.index=t,QC.offset=e,QC}function nS(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!nS(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!nS(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let mr=class uj{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,i));else{if(a.type.excludes(this.type))return e;!r&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(a)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&nS(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return uj.none;if(e instanceof uj)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};mr.none=[];class rS extends Error{}class Rt{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=IQ(this.content,e+this.openStart,n);return r&&new Rt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Rt(LQ(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Rt.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Rt(bt.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new Rt(e,r,i)}}Rt.empty=new Rt(bt.empty,0,0);function LQ(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(i==e||a.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(LQ(a.content,e-i-1,n-i-1)))}function IQ(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),s=t.maybeChild(i);if(a==e||s.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=IQ(s.content,e-a-1,n,s);return l&&t.replaceChild(i,s.copy(l))}function bze(t,e,n){if(n.openStart>t.depth)throw new rS("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new rS("Inconsistent open depths");return FQ(t,e,n,0)}function FQ(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=FQ(t,e,n,r+1);return a.copy(a.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,l=s.content;return Gh(s,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=yze(n,t);return Gh(a,zQ(t,s,l,e,r))}else return Gh(a,iS(t,e,r))}function UQ(t,e){if(!e.type.compatibleContent(t.type))throw new rS("Cannot join "+e.type.name+" onto "+t.type.name)}function dj(t,e,n){let r=t.node(n);return UQ(r,e.node(n)),r}function Vh(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function m0(t,e,n,r){let i=(e||t).node(n),a=0,s=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(Vh(t.nodeAfter,r),a++));for(let l=a;l<s;l++)Vh(i.child(l),r);e&&e.depth==n&&e.textOffset&&Vh(e.nodeBefore,r)}function Gh(t,e){return t.type.checkContent(e),t.copy(e)}function zQ(t,e,n,r,i){let a=t.depth>i&&dj(t,e,i+1),s=r.depth>i&&dj(n,r,i+1),l=[];return m0(null,t,i,l),a&&s&&e.index(i)==n.index(i)?(UQ(a,s),Vh(Gh(a,zQ(t,e,n,r,i+1)),l)):(a&&Vh(Gh(a,iS(t,e,i+1)),l),m0(e,n,i,l),s&&Vh(Gh(s,iS(n,r,i+1)),l)),m0(r,null,i,l),new bt(l)}function iS(t,e,n){let r=[];if(m0(null,t,n,r),t.depth>n){let i=dj(t,e,n+1);Vh(Gh(i,iS(t,e,n+1)),r)}return m0(e,null,n,r),new bt(r)}function yze(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)i=e.node(a).copy(bt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class cb{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)i+=r.child(a).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return mr.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let a=r.marks;for(var s=0;s<a.length;s++)a[s].type.spec.inclusive===!1&&(!i||!a[s].isInSet(i.marks))&&(a=a[s--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new aS(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,a=n;for(let s=e;;){let{index:l,offset:c}=s.content.findIndex(a),u=a-c;if(r.push(s,l,i+c),!u||(s=s.child(l),s.isText))break;a=u-1,i+=c+1}return new cb(n,r,a)}static resolveCached(e,n){let r=h7.get(e);if(r)for(let a=0;a<r.elts.length;a++){let s=r.elts[a];if(s.pos==n)return s}else h7.set(e,r=new vze);let i=r.elts[r.i]=cb.resolve(e,n);return r.i=(r.i+1)%_ze,i}}class vze{constructor(){this.elts=[],this.i=0}}const _ze=12,h7=new WeakMap;class aS{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const wze=Object.create(null);let hd=class hj{constructor(e,n,r,i=mr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||bt.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&nS(this.attrs,n||e.defaultAttrs||wze)&&mr.sameSet(this.marks,r||mr.none)}copy(e=null){return e==this.content?this:new hj(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new hj(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return Rt.empty;let i=this.resolve(e),a=this.resolve(n),s=r?0:i.sharedDepth(n),l=i.start(s),u=i.node(s).content.cut(i.pos-l,a.pos-l);return new Rt(u,i.depth-s,a.depth-s)}replace(e,n,r){return bze(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return cb.resolveCached(this,e)}resolveNoCache(e){return cb.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),BQ(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=bt.empty,i=0,a=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,a),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let c=i;c<a;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let a=this.contentMatchAt(e).matchType(r),s=a&&a.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=mr.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!mr.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=bt.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};hd.prototype.text=void 0;class sS extends hd{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):BQ(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new sS(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new sS(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function BQ(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class vf{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Sze(e,n);if(r.next==null)return vf.empty;let i=HQ(r);r.next&&r.err("Unexpected trailing text");let a=kze(Cze(i));return Pze(a,r),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let a=n;i&&a<r;a++)i=i.matchType(e.child(a).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function a(s,l){let c=s.matchFragment(e,r);if(c&&(!n||c.validEnd))return bt.from(l.map(u=>u.createAndFill()));for(let u=0;u<s.next.length;u++){let{type:d,next:f}=s.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let g=a(f,l.concat(d));if(g)return g}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let s=[];for(let l=i;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<a.next.length;s++){let{type:l,next:c}=a.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||c.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let a=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)a+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return a}).join(`
- `)}}vf.empty=new vf(!0);class Sze{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function HQ(t){let e=[];do e.push(Mze(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Mze(t){let e=[];do e.push(Eze(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Eze(t){let e=Nze(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Aze(t,e);else break;return e}function f7(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Aze(t,e){let n=f7(t),r=n;return t.eat(",")&&(t.next!="}"?r=f7(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Tze(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let s=n[a];s.isInGroup(e)&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function Nze(t){if(t.eat("(")){let e=HQ(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=Tze(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Cze(t){let e=[[]];return i(a(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,c){let u={term:c,to:l};return e[s].push(u),u}function i(s,l){s.forEach(c=>c.to=l)}function a(s,l){if(s.type=="choice")return s.exprs.reduce((c,u)=>c.concat(a(u,l)),[]);if(s.type=="seq")for(let c=0;;c++){let u=a(s.exprs[c],l);if(c==s.exprs.length-1)return u;i(u,l=n())}else if(s.type=="star"){let c=n();return r(l,c),i(a(s.expr,c),c),[r(c)]}else if(s.type=="plus"){let c=n();return i(a(s.expr,l),c),i(a(s.expr,c),c),[r(c)]}else{if(s.type=="opt")return[r(l)].concat(a(s.expr,l));if(s.type=="range"){let c=l;for(let u=0;u<s.min;u++){let d=n();i(a(s.expr,c),d),c=d}if(s.max==-1)i(a(s.expr,c),c);else for(let u=s.min;u<s.max;u++){let d=n();r(c,d),i(a(s.expr,c),d),c=d}return[r(c)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function $Q(t,e){return e-t}function m7(t,e){let n=[];return r(e),n.sort($Q);function r(i){let a=t[i];if(a.length==1&&!a[0].term)return r(a[0].to);n.push(i);for(let s=0;s<a.length;s++){let{term:l,to:c}=a[s];!l&&n.indexOf(c)==-1&&r(c)}}}function kze(t){let e=Object.create(null);return n(m7(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:l,to:c})=>{if(!l)return;let u;for(let d=0;d<i.length;d++)i[d][0]==l&&(u=i[d][1]);m7(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new vf(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort($Q);a.next.push({type:i[s][0],next:e[l.join(",")]||n(l)})}return a}}function Pze(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,s=[];for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];s.push(c.name),a&&!(c.isText||c.hasRequiredAttrs())&&(a=!1),r.indexOf(u)==-1&&r.push(u)}a&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function VQ(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function GQ(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let a=t[r];if(a.hasDefault)i=a.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function WQ(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let a=t[i];a.validate&&a.validate(e[i])}}function qQ(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new Rze(t,r,e[r]);return n}let p7=class KQ{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=qQ(e,r.attrs),this.defaultAttrs=VQ(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==vf.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:GQ(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new hd(this,this.computeAttrs(e),bt.from(n),mr.setFrom(r))}createChecked(e=null,n,r){return n=bt.from(n),this.checkContent(n),new hd(this,this.computeAttrs(e),n,mr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=bt.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let i=this.contentMatch.matchFragment(n),a=i&&i.fillBefore(bt.empty,!0);return a?new hd(this,e,n.append(a),mr.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){WQ(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:mr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,s)=>r[a]=new KQ(a,n,s));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let a in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function jze(t,e,n){let r=n.split("|");return i=>{let a=i===null?"null":typeof i;if(r.indexOf(a)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${a}`)}}class Rze{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?jze(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class cE{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=qQ(e,i.attrs),this.excluded=null;let a=VQ(this.attrs);this.instance=a?new mr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new mr(this,GQ(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,s)=>r[a]=new cE(a,i++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){WQ(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class XQ{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=na.from(e.nodes),n.marks=na.from(e.marks||{}),this.nodes=p7.compile(this.spec.nodes,this),this.marks=cE.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let a=this.nodes[i],s=a.spec.content||"",l=a.spec.marks;if(a.contentMatch=r[s]||(r[s]=vf.parse(s,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=l=="_"?null:l?g7(this,l.split(" ")):l==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],s=a.spec.excludes;a.excluded=s==null?[a]:s==""?[]:g7(this,s.split(" "))}this.nodeFromJSON=i=>hd.fromJSON(this,i),this.markFromJSON=i=>mr.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof p7){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new sS(r,r.defaultAttrs,e,mr.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function g7(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.marks[i],s=a;if(a)n.push(a);else for(let l in t.marks){let c=t.marks[l];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function Dze(t){return t.tag!=null}function Oze(t){return t.style!=null}let p0=class fj{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(Dze(i))this.tags.push(i);else if(Oze(i)){let a=/[^=]*/.exec(i.style)[0];r.indexOf(a)<0&&r.push(a),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let a=e.nodes[i.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new b7(this,n,!1);return r.addAll(e,mr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new b7(this,n,!0);return r.addAll(e,mr.none,n.from,n.to),Rt.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let a=this.tags[i];if(Fze(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let s=a.getAttrs(e);if(s===!1)continue;a.attrs=s||void 0}return a}}}matchStyle(e,n,r,i){for(let a=i?this.styles.indexOf(i)+1:0;a<this.styles.length;a++){let s=this.styles[a],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let c=s.getAttrs(n);if(c===!1)continue;s.attrs=c||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let a=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let l=n[s];if((l.priority==null?50:l.priority)<a)break}n.splice(s,0,i)}for(let i in e.marks){let a=e.marks[i].spec.parseDOM;a&&a.forEach(s=>{r(s=y7(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(s=>{r(s=y7(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new fj(e,fj.schemaRules(e)))}};const YQ={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Lze={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ZQ={ol:!0,ul:!0},ub=1,mj=2,g0=4;function x7(t,e,n){return e!=null?(e?ub:0)|(e==="full"?mj:0):t&&t.whitespace=="pre"?ub|mj:n&~g0}class X_{constructor(e,n,r,i,a,s){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=mr.none,this.match=a||(s&g0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(bt.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ub)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let a=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-i[0].length))}}let n=bt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(bt.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!YQ.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class b7{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,s=x7(null,n.preserveWhitespace,0)|(r?g0:0);i?a=new X_(i.type,i.attrs,mr.none,!0,n.topMatch||i.type.contentMatch,s):r?a=new X_(null,null,mr.none,!0,null,s):a=new X_(e.schema.topNodeType,null,mr.none,!0,null,s),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,a=i.options&mj?"full":this.localPreserveWS||(i.options&ub)>0,{schema:s}=this.parser;if(a==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(a)if(a==="full")r=r.replace(/\r\n?/g,`
- `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(s.linebreakReplacement.create(),n,!0),l[c]&&this.insertNode(s.text(l[c]),n,!/\S/.test(l[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;ZQ.hasOwnProperty(s)&&this.parser.normalizeLists&&Ize(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:Lze.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let u,d=this.needsBlock;if(YQ.hasOwnProperty(s))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),u=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=c&&c.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(a),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,c,u,c.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let a=this.parser.matchedStyles[i],s=r.getPropertyValue(a);if(s)for(let l=void 0;;){let c=this.parser.matchStyle(a,s,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return n}addElementByRule(e,n,r,i){let a,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(s,n.attrs||null,r,n.preserveWhitespace);c&&(a=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}a&&this.sync(l)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(s,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let s=this.open,l=0;s>=0;s--){let c=this.nodes[s],u=c.findWrapping(e);if(u&&(!i||i.length>u.length+l)&&(i=u,a=c,!u.length))break;if(c.solid){if(r)break;l+=2}}if(!i)return null;this.sync(a);for(let s=0;s<i.length;s++)n=this.enterInner(i[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let s=mr.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):v7(l.type,e.type))&&(s=l.addToSet(s));return a.content.push(e.mark(s)),!0}return!1}enter(e,n,r,i){let a=this.findPlace(e.create(n),r,!1);return a&&(a=this.enterInner(e,n,r,!0,i)),a}enterInner(e,n,r,i=!1,a){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=x7(e,a,s.options);s.options&g0&&s.content.length==0&&(l|=g0);let c=mr.none;return r=r.filter(u=>(s.type?s.type.allowsMarkType(u.type):v7(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new X_(e,n,c,i,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=ub)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),a=-(r?r.depth+1:0)+(i?0:1),s=(l,c)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;c>=a;c--)if(s(l-1,c))return!0;return!1}else{let d=c>0||c==0&&i?this.nodes[c].type:r&&c>=a?r.node(c-a).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function Ize(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ZQ.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Fze(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function y7(t){let e={};for(let n in t)e[n]=t[n];return e}function v7(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],s=l=>{a.push(l);for(let c=0;c<l.edgeCount;c++){let{type:u,next:d}=l.edge(c);if(u==e||a.indexOf(d)<0&&s(d))return!0}};if(s(i.contentMatch))return!0}}class kf{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=JC(n).createDocumentFragment());let i=r,a=[];return e.forEach(s=>{if(a.length||s.marks.length){let l=0,c=0;for(;l<a.length&&c<s.marks.length;){let u=s.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(a[l][0])||u.type.spec.spanning===!1)break;l++,c++}for(;l<a.length;)i=a.pop()[1];for(;c<s.marks.length;){let u=s.marks[c++],d=this.serializeMark(u,s.isInline,n);d&&(a.push([u,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=C1(JC(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let a=this.serializeMark(e.marks[i],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(r),r=a.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&C1(JC(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return C1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new kf(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=_7(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return _7(e.marks)}}function _7(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function JC(t){return t.document||window.document}const w7=new WeakMap;function Uze(t){let e=w7.get(t);return e===void 0&&w7.set(t,e=zze(t)),e}function zze(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function C1(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],a;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(a=Uze(r))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let l,c=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let g=f.indexOf(" ");g>0?c.setAttributeNS(f.slice(0,g),f.slice(g+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let g=e[f];if(g===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:p,contentDOM:x}=C1(t,g,n,r);if(c.appendChild(p),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:c,contentDOM:l}}const QQ=65535,JQ=Math.pow(2,16);function Bze(t,e){return t+e*JQ}function S7(t){return t&QQ}function Hze(t){return(t-(t&QQ))/JQ}const eJ=1,tJ=2,k1=4,nJ=8;class pj{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&nJ)>0}get deletedBefore(){return(this.delInfo&(eJ|k1))>0}get deletedAfter(){return(this.delInfo&(tJ|k1))>0}get deletedAcross(){return(this.delInfo&k1)>0}}class Es{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Es.empty)return Es.empty}recover(e){let n=0,r=S7(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+Hze(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,a=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?i:0);if(c>e)break;let u=this.ranges[l+a],d=this.ranges[l+s],f=c+u;if(e<=f){let g=u?e==c?-1:e==f?1:n:n,p=c+i+(g<0?0:d);if(r)return p;let x=e==(n<0?c:f)?null:Bze(l/3,e-c),v=e==c?tJ:e==f?eJ:k1;return(n<0?e!=c:e!=f)&&(v|=nJ),new pj(p,v,x)}i+=d-u}return r?e+i:new pj(e+i,0,null)}touches(e,n){let r=0,i=S7(n),a=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[l+a],d=c+u;if(e<=d&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,a=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?a:0),c=s+(this.inverted?0:a),u=this.ranges[i+n],d=this.ranges[i+r];e(l,l+u,c,c+d),a+=d-u}}invert(){return new Es(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Es.empty:new Es(e<0?[0,-e,0]:[0,0,e])}}Es.empty=new Es([]);class db{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new db(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new db;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let a=this.from;a<this.to;a++){let s=this._maps[a],l=s.mapResult(e,n);if(l.recover!=null){let c=this.getMirror(a);if(c!=null&&c>a&&c<this.to){a=c,e=this._maps[c].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new pj(e,i,null)}}const ek=Object.create(null);class Ma{getMap(){return Es.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ek[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in ek)throw new RangeError("Duplicate use of step JSON ID "+e);return ek[e]=n,n.prototype.jsonID=e,n}}class di{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new di(e,null)}static fail(e){return new di(null,e)}static fromReplace(e,n,r,i){try{return di.ok(e.replace(n,r,i))}catch(a){if(a instanceof rS)return di.fail(a.message);throw a}}}function YO(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(YO(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return bt.fromArray(r)}class rd extends Ma{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),a=new Rt(YO(n.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return di.fromReplace(e,this.from,this.to,a)}invert(){return new zo(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new rd(n.pos,r.pos,this.mark)}merge(e){return e instanceof rd&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rd(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new rd(n.from,n.to,e.markFromJSON(n.mark))}}Ma.jsonID("addMark",rd);class zo extends Ma{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new Rt(YO(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return di.fromReplace(e,this.from,this.to,r)}invert(){return new rd(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new zo(n.pos,r.pos,this.mark)}merge(e){return e instanceof zo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new zo(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new zo(n.from,n.to,e.markFromJSON(n.mark))}}Ma.jsonID("removeMark",zo);class id extends Ma{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return di.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return di.fromReplace(e,this.pos,this.pos+1,new Rt(bt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new id(this.pos,n.marks[i]);return new id(this.pos,this.mark)}}return new _f(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new id(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new id(n.pos,e.markFromJSON(n.mark))}}Ma.jsonID("addNodeMark",id);class _f extends Ma{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return di.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return di.fromReplace(e,this.pos,this.pos+1,new Rt(bt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new id(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new _f(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new _f(n.pos,e.markFromJSON(n.mark))}}Ma.jsonID("removeNodeMark",_f);class Bi extends Ma{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&gj(e,this.from,this.to)?di.fail("Structure replace would overwrite content"):di.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Es([this.from,this.to-this.from,this.slice.size])}invert(e){return new Bi(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Bi(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Bi)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?Rt.empty:new Rt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Bi(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?Rt.empty:new Rt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Bi(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Bi(n.from,n.to,Rt.fromJSON(e,n.slice),!!n.structure)}}Ma.jsonID("replace",Bi);class $i extends Ma{constructor(e,n,r,i,a,s,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=s,this.structure=l}apply(e){if(this.structure&&(gj(e,this.from,this.gapFrom)||gj(e,this.gapTo,this.to)))return di.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return di.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?di.fromReplace(e,this.from,this.to,r):di.fail("Content does not fit in gap")}getMap(){return new Es([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new $i(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new $i(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new $i(n.from,n.to,n.gapFrom,n.gapTo,Rt.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ma.jsonID("replaceAround",$i);function gj(t,e,n){let r=t.resolve(e),i=n-e,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let s=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function $ze(t,e,n,r){let i=[],a=[],s,l;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let g=Math.max(u,e),p=Math.min(u+c.nodeSize,n),x=r.addToSet(f);for(let v=0;v<f.length;v++)f[v].isInSet(x)||(s&&s.to==g&&s.mark.eq(f[v])?s.to=p:i.push(s=new zo(g,p,f[v])));l&&l.to==g?l.to=p:a.push(l=new rd(g,p,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function Vze(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;a++;let c=null;if(r instanceof cE){let u=s.marks,d;for(;d=r.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(s.marks)&&(c=[r]):c=s.marks;if(c&&c.length){let u=Math.min(l+s.nodeSize,n);for(let d=0;d<c.length;d++){let f=c[d],g;for(let p=0;p<i.length;p++){let x=i[p];x.step==a-1&&f.eq(i[p].style)&&(g=x)}g?(g.to=u,g.step=a):i.push({style:f,from:Math.max(l,e),to:u,step:a})}}}),i.forEach(s=>t.step(new zo(s.from,s.to,s.style)))}function ZO(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),s=[],l=e+1;for(let c=0;c<a.childCount;c++){let u=a.child(c),d=l+u.nodeSize,f=r.matchType(u.type);if(!f)s.push(new Bi(l,d,Rt.empty));else{r=f;for(let g=0;g<u.marks.length;g++)n.allowsMarkType(u.marks[g].type)||t.step(new zo(l,d,u.marks[g]));if(i&&u.isText&&n.whitespace!="pre"){let g,p=/\r?\n|\r/g,x;for(;g=p.exec(u.text);)x||(x=new Rt(bt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),s.push(new Bi(l+g.index,l+g.index+g[0].length,x))}}l=d}if(!r.validEnd){let c=r.fillBefore(bt.empty,!0);t.replace(l,l,new Rt(c,0,0))}for(let c=s.length-1;c>=0;c--)t.step(s[c])}function Gze(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Mg(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let s=t.$from.node(r),l=t.$from.index(r)+i,c=t.$to.indexAfter(r)-a;if(r<t.depth&&s.canReplace(l,c,n))return r;if(r==0||s.type.spec.isolating||!Gze(s,l,c))break;l&&(i=1),c<s.childCount&&(a=1)}return null}function Wze(t,e,n){let{$from:r,$to:i,depth:a}=e,s=r.before(a+1),l=i.after(a+1),c=s,u=l,d=bt.empty,f=0;for(let x=a,v=!1;x>n;x--)v||r.index(x)>0?(v=!0,d=bt.from(r.node(x).copy(d)),f++):c--;let g=bt.empty,p=0;for(let x=a,v=!1;x>n;x--)v||i.after(x+1)<i.end(x)?(v=!0,g=bt.from(i.node(x).copy(g)),p++):u++;t.step(new $i(c,u,s,l,new Rt(d.append(g),f,p),d.size-f,!0))}function QO(t,e,n=null,r=t){let i=qze(t,e),a=i&&Kze(r,e);return a?i.map(M7).concat({type:e,attrs:n}).concat(a.map(M7)):null}function M7(t){return{type:t,attrs:null}}function qze(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.contentMatchAt(r).findWrapping(e);if(!a)return null;let s=a.length?a[0]:e;return n.canReplaceWith(r,i,s)?a:null}function Kze(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.child(r),s=e.contentMatch.findWrapping(a.type);if(!s)return null;let c=(s.length?s[s.length-1]:e).contentMatch;for(let u=r;c&&u<i;u++)c=c.matchType(n.child(u).type);return!c||!c.validEnd?null:s}function Xze(t,e,n){let r=bt.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=bt.from(n[s].type.create(n[s].attrs,r))}let i=e.start,a=e.end;t.step(new $i(i,a,i,a,new Rt(r,0,0),n.length,!0))}function Yze(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{let c=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,c)&&Zze(t.doc,t.mapping.slice(a).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!x?u=!1:!p&&x&&(u=!0)}u===!1&&iJ(t,s,l,a),ZO(t,t.mapping.slice(a).map(l,1),r,void 0,u===null);let d=t.mapping.slice(a),f=d.map(l,1),g=d.map(l+s.nodeSize,1);return t.step(new $i(f,g,f+1,g-1,new Rt(bt.from(r.create(c,null,s.marks)),0,0),1,!0)),u===!0&&rJ(t,s,l,a),!1}})}function rJ(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let c=t.mapping.slice(r).map(n+1+a+s.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function iJ(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+a);t.replaceWith(s,s+1,e.type.schema.text(`
- `))}})}function Zze(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Qze(t,e,n,r,i){let a=t.doc.nodeAt(e);if(!a)throw new RangeError("No node at given position");n||(n=a.type);let s=n.create(r,null,i||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,s);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new $i(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Rt(bt.from(s),0,0),1,!0))}function Ic(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,s=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,d=n-2;u>a;u--,d--){let f=i.node(u),g=i.index(u);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(g,f.childCount),x=r&&r[d+1];x&&(p=p.replaceChild(0,x.type.create(x.attrs)));let v=r&&r[d]||f;if(!f.canReplace(g+1,f.childCount)||!v.type.validContent(p))return!1}let l=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(l,l,c?c.type:i.node(a+1).type)}function Jze(t,e,n=1,r){let i=t.doc.resolve(e),a=bt.empty,s=bt.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=bt.from(i.node(l).copy(a));let d=r&&r[u];s=bt.from(d?d.type.create(d.attrs,s):i.node(l).copy(s))}t.step(new Bi(e,e,new Rt(a.append(s),n,n),!0))}function Od(t,e){let n=t.resolve(e),r=n.index();return aJ(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function eBe(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let a=e.child(i),s=a.type==r?t.type.schema.nodes.text:a.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(a.marks))return!1}return n.validEnd}function aJ(t,e){return!!(t&&e&&!t.isLeaf&&eBe(t,e))}function uE(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let a,s,l=r.index(i);if(i==r.depth?(a=r.nodeBefore,s=r.nodeAfter):n>0?(a=r.node(i+1),l++,s=r.node(i).maybeChild(l)):(a=r.node(i).maybeChild(l-1),s=r.node(i+1)),a&&!a.isTextblock&&aJ(a,s)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function tBe(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,a=t.doc.resolve(e-n),s=a.node().type;if(i&&s.inlineContent){let d=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);d&&!f?r=!1:!d&&f&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);iJ(t,d.node(),d.before(),l)}s.inlineContent&&ZO(t,e+n-1,s,a.node().contentMatchAt(a.index()),r==null);let c=t.mapping.slice(l),u=c.map(e-n);if(t.step(new Bi(u,c.map(e+n,-1),Rt.empty,!0)),r===!0){let d=t.doc.resolve(u);rJ(t,d.node(),d.before(),t.steps.length)}return t}function nBe(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let a=r.index(i);if(r.node(i).canReplaceWith(a,a,n))return r.before(i+1);if(a>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let a=r.indexAfter(i);if(r.node(i).canReplaceWith(a,a,n))return r.after(i+1);if(a<r.node(i).childCount)return null}return null}function sJ(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let a=0;a<n.openStart;a++)i=i.firstChild.content;for(let a=1;a<=(n.openStart==0&&n.size?2:1);a++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,c=r.index(s)+(l>0?1:0),u=r.node(s),d=!1;if(a==1)d=u.canReplace(c,c,i);else{let f=u.contentMatchAt(c).findWrapping(i.firstChild.type);d=f&&u.canReplaceWith(c,c,f[0])}if(d)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function dE(t,e,n=e,r=Rt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return oJ(i,a,r)?new Bi(e,n,r):new rBe(i,a,r).fit()}function oJ(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class rBe{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=bt.empty;for(let i=0;i<=e.depth;i++){let a=e.node(i);this.frontier.push({type:a.type,match:a.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=bt.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let a=this.placed,s=r.depth,l=i.depth;for(;s&&l&&a.childCount==1;)a=a.firstChild.content,s--,l--;let c=new Rt(a,s,l);return e>-1?new $i(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Bi(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let a=n.firstChild;if(n.childCount>1&&(i=0),a.type.spec.isolating&&i<=r){e=r;break}n=a.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,a=null;r?(a=tk(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:u}=this.frontier[l],d,f=null;if(n==1&&(s?u.matchType(s.type)||(f=u.fillBefore(bt.from(s),!1)):a&&c.compatibleContent(a.type)))return{sliceDepth:r,frontierDepth:l,parent:a,inject:f};if(n==2&&s&&(d=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:a,wrap:d};if(a&&u.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=tk(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Rt(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=tk(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Rt(Jx(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Rt(Jx(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let v=0;v<a.length;v++)this.openFrontierNode(a[v]);let s=this.unplaced,l=r?r.content:s.content,c=s.openStart-e,u=0,d=[],{match:f,type:g}=this.frontier[n];if(i){for(let v=0;v<i.childCount;v++)d.push(i.child(v));f=f.matchFragment(i)}let p=l.size+e-(s.content.size-s.openEnd);for(;u<l.childCount;){let v=l.child(u),y=f.matchType(v.type);if(!y)break;u++,(u>1||c==0||v.content.size)&&(f=y,d.push(lJ(v.mark(g.allowedMarks(v.marks)),u==1?c:0,u==l.childCount?p:-1)))}let x=u==l.childCount;x||(p=-1),this.placed=e0(this.placed,n,bt.from(d)),this.frontier[n].match=f,x&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let v=0,y=l;v<p;v++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=x?e==0?Rt.empty:new Rt(Jx(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new Rt(Jx(s.content,e,u),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!nk(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],a=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=nk(e,n,i,r,a);if(s){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=nk(e,l,u,c,!0);if(!d||d.childCount)continue e}return{depth:n,fit:s,move:a?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=e0(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),a=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,a)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=e0(this.placed,this.depth,bt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(bt.empty,!0);n.childCount&&(this.placed=e0(this.placed,this.frontier.length,n))}}function Jx(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Jx(t.firstChild.content,e-1,n)))}function e0(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(e0(t.lastChild.content,e-1,n)))}function tk(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function lJ(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,lJ(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(bt.empty,!0)))),t.copy(r)}function nk(t,e,n,r,i){let a=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==a.childCount&&!n.compatibleContent(a.type))return null;let l=r.fillBefore(a.content,!0,s);return l&&!iBe(n,a.content,s)?l:null}function iBe(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function aBe(t){return t.spec.defining||t.spec.definingForContent}function sBe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(oJ(i,a,r))return t.step(new Bi(e,n,r));let s=uJ(i,a);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let g=i.depth,p=i.pos-1;g>0;g--,p--){let x=i.node(g).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;s.indexOf(g)>-1?l=g:i.before(g)==p&&s.splice(1,0,-g)}let c=s.indexOf(l),u=[],d=r.openStart;for(let g=r.content,p=0;;p++){let x=g.firstChild;if(u.push(x),p==r.openStart)break;g=x.content}for(let g=d-1;g>=0;g--){let p=u[g],x=aBe(p.type);if(x&&!p.sameMarkup(i.node(Math.abs(l)-1)))d=g;else if(x||!p.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let p=(g+d+1)%(r.openStart+1),x=u[p];if(x)for(let v=0;v<s.length;v++){let y=s[(v+c)%s.length],b=!0;y<0&&(b=!1,y=-y);let E=i.node(y-1),w=i.index(y-1);if(E.canReplaceWith(w,w,x.type,x.marks))return t.replace(i.before(y),b?a.after(y):n,new Rt(cJ(r.content,0,r.openStart,p),p,r.openEnd))}}let f=t.steps.length;for(let g=s.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>f));g--){let p=s[g];p<0||(e=i.before(p),n=a.after(p))}}function cJ(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(cJ(a.content,e+1,n,r,a)))}if(e>r){let a=i.contentMatchAt(0),s=a.fillBefore(t).append(t);t=s.append(a.matchFragment(s).fillBefore(bt.empty,!0))}return t}function oBe(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=nBe(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Rt(bt.from(r),0,0))}function lBe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=uJ(r,i);for(let s=0;s<a.length;s++){let l=a[s],c=s==a.length-1;if(c&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(c||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function uJ(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let a=t.start(i);if(a<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(a==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==a-1)&&n.push(i)}return n}class _p extends Ma{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return di.fail("No node at attribute step's position");let r=Object.create(null);for(let a in n.attrs)r[a]=n.attrs[a];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return di.fromReplace(e,this.pos,this.pos+1,new Rt(bt.from(i),0,n.isLeaf?0:1))}getMap(){return Es.empty}invert(e){return new _p(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new _p(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new _p(n.pos,n.attr,n.value)}}Ma.jsonID("attr",_p);class hb extends Ma{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return di.ok(r)}getMap(){return Es.empty}invert(e){return new hb(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new hb(n.attr,n.value)}}Ma.jsonID("docAttr",hb);let qp=class extends Error{};qp=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};qp.prototype=Object.create(Error.prototype);qp.prototype.constructor=qp;qp.prototype.name="TransformError";class dJ{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new db}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new qp(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=Rt.empty){let i=dE(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Rt(bt.from(r),0,0))}delete(e,n){return this.replace(e,n,Rt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return sBe(this,e,n,r),this}replaceRangeWith(e,n,r){return oBe(this,e,n,r),this}deleteRange(e,n){return lBe(this,e,n),this}lift(e,n){return Wze(this,e,n),this}join(e,n=1){return tBe(this,e,n),this}wrap(e,n){return Xze(this,e,n),this}setBlockType(e,n=e,r,i=null){return Yze(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return Qze(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new _p(e,n,r)),this}setDocAttribute(e,n){return this.step(new hb(e,n)),this}addNodeMark(e,n){return this.step(new id(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof mr)n.isInSet(r.marks)&&this.step(new _f(e,n));else{let i=r.marks,a,s=[];for(;a=n.isInSet(i);)s.push(new _f(e,a)),i=a.removeFromSet(i);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,n=1,r){return Jze(this,e,n,r),this}addMark(e,n,r){return $ze(this,e,n,r),this}removeMark(e,n,r){return Vze(this,e,n,r),this}clearIncompatible(e,n,r){return ZO(this,e,n,r),this}}const rk=Object.create(null);class mn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new cBe(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=Rt.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let a=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:c,$to:u}=s[l],d=e.mapping.slice(a);e.replaceRange(d.map(c.pos),d.map(u.pos),l?Rt.empty:n),l==0&&T7(e,a,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:s,$to:l}=i[a],c=e.mapping.slice(r),u=c.map(s.pos),d=c.map(l.pos);a?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),T7(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new Qt(e):ep(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let a=e.depth-1;a>=0;a--){let s=n<0?ep(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):ep(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new js(e.node(0))}static atStart(e){return ep(e,e,0,0,1)||new js(e)}static atEnd(e){return ep(e,e,e.content.size,e.childCount,-1)||new js(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=rk[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in rk)throw new RangeError("Duplicate use of selection JSON ID "+e);return rk[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Qt.between(this.$anchor,this.$head).getBookmark()}}mn.prototype.visible=!0;class cBe{constructor(e,n){this.$from=e,this.$to=n}}let E7=!1;function A7(t){!E7&&!t.parent.inlineContent&&(E7=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Qt extends mn{constructor(e,n=e){A7(e),A7(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return mn.near(r);let i=e.resolve(n.map(this.anchor));return new Qt(i.parent.inlineContent?i:r,r)}replace(e,n=Rt.empty){if(super.replace(e,n),n==Rt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Qt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new hE(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Qt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let a=mn.findFrom(n,r,!0)||mn.findFrom(n,-r,!0);if(a)n=a.$head;else return mn.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(mn.findFrom(e,-r,!0)||mn.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Qt(e,n)}}mn.jsonID("text",Qt);class hE{constructor(e,n){this.anchor=e,this.head=n}map(e){return new hE(e.map(this.anchor),e.map(this.head))}resolve(e){return Qt.between(e.resolve(this.anchor),e.resolve(this.head))}}class qt extends mn{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=e.resolve(i);return r?mn.near(a):new qt(a)}content(){return new Rt(bt.from(this.node),0,0)}eq(e){return e instanceof qt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new JO(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new qt(e.resolve(n.anchor))}static create(e,n){return new qt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}qt.prototype.visible=!1;mn.jsonID("node",qt);class JO{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new hE(r,r):new JO(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&qt.isSelectable(r)?new qt(n):mn.near(n)}}class js extends mn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Rt.empty){if(n==Rt.empty){e.delete(0,e.doc.content.size);let r=mn.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new js(e)}map(e){return new js(e)}eq(e){return e instanceof js}getBookmark(){return uBe}}mn.jsonID("all",js);const uBe={map(){return this},resolve(t){return new js(t)}};function ep(t,e,n,r,i,a=!1){if(e.inlineContent)return Qt.create(t,n);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!a&&qt.isSelectable(l))return qt.create(t,n-(i<0?l.nodeSize:0))}else{let c=ep(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function T7(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Bi||i instanceof $i))return;let a=t.mapping.maps[r],s;a.forEach((l,c,u,d)=>{s==null&&(s=d)}),t.setSelection(mn.near(t.doc.resolve(s),n))}const N7=1,Y_=2,C7=4;class dBe extends dJ{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|N7)&~Y_,this.storedMarks=null,this}get selectionSet(){return(this.updated&N7)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Y_,this}ensureMarks(e){return mr.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Y_)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Y_,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||mr.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let a=this.storedMarks;if(!a){let s=this.doc.resolve(n);a=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(mn.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=C7,this}get scrolledIntoView(){return(this.updated&C7)>0}}function k7(t,e){return!e||!t?t:t.bind(e)}class t0{constructor(e,n,r){this.name=e,this.init=k7(n.init,r),this.apply=k7(n.apply,r)}}const hBe=[new t0("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new t0("selection",{init(t,e){return t.selection||mn.atStart(e.doc)},apply(t){return t.selection}}),new t0("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new t0("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ik{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=hBe.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new t0(r.key,r.spec.state,r))})}}class up{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let a=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let c=i?i[s].n:0,u=i?i[s].state:this,d=c<n.length&&l.spec.appendTransaction.call(l,c?n.slice(c):n,u,r);if(d&&r.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),a=!0}i&&(i[s]={state:r,n:n.length})}}if(!a)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new up(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let a=r[i];n[a.name]=a.apply(e,this[a.name],this,n)}return n}get tr(){return new dBe(this)}static create(e){let n=new ik(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new up(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new ik(this.schema,e.plugins),r=n.fields,i=new up(n);for(let a=0;a<r.length;a++){let s=r[a].name;i[s]=this.hasOwnProperty(s)?this[s]:r[a].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],a=i.spec.state;a&&a.toJSON&&(n[r]=a.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new ik(e.schema,e.plugins),a=new up(i);return i.fields.forEach(s=>{if(s.name=="doc")a.doc=hd.fromJSON(e.schema,n.doc);else if(s.name=="selection")a.selection=mn.fromJSON(a.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let c=r[l],u=c.spec.state;if(c.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){a[s.name]=u.fromJSON.call(c,e,n[l],a);return}}a[s.name]=s.init(e,a)}}),a}}function hJ(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=hJ(i,e,{})),n[r]=i}return n}class Fr{constructor(e){this.spec=e,this.props={},e.props&&hJ(e.props,this,this.props),this.key=e.key?e.key.key:fJ("plugin")}getState(e){return e[this.key]}}const ak=Object.create(null);function fJ(t){return t in ak?t+"$"+ ++ak[t]:(ak[t]=0,t+"$")}class ki{constructor(e="key"){this.key=fJ(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const eL=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function mJ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const pJ=(t,e,n)=>{let r=mJ(t,n);if(!r)return!1;let i=tL(r);if(!i){let s=r.blockRange(),l=s&&Mg(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let a=i.nodeBefore;if(MJ(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Kp(a,"end")||qt.isSelectable(a)))for(let s=r.depth;;s--){let l=dE(t.doc,r.before(s),r.after(s),Rt.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(Kp(a,"end")?mn.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):qt.create(c.doc,i.pos-a.nodeSize)),e(c.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},fBe=(t,e,n)=>{let r=mJ(t,n);if(!r)return!1;let i=tL(r);return i?gJ(t,i,e):!1},mBe=(t,e,n)=>{let r=bJ(t,n);if(!r)return!1;let i=nL(r);return i?gJ(t,i,e):!1};function gJ(t,e,n){let r=e.nodeBefore,i=r,a=e.pos-1;for(;!i.isTextblock;a--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let s=e.nodeAfter,l=s,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let u=dE(t.doc,a,c,Rt.empty);if(!u||u.from!=a||u instanceof Bi&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(Qt.create(d.doc,a)),n(d.scrollIntoView())}return!0}function Kp(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const xJ=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;a=tL(r)}let s=a&&a.nodeBefore;return!s||!qt.isSelectable(s)?!1:(e&&e(t.tr.setSelection(qt.create(t.doc,a.pos-s.nodeSize)).scrollIntoView()),!0)};function tL(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function bJ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const yJ=(t,e,n)=>{let r=bJ(t,n);if(!r)return!1;let i=nL(r);if(!i)return!1;let a=i.nodeAfter;if(MJ(t,i,e,1))return!0;if(r.parent.content.size==0&&(Kp(a,"start")||qt.isSelectable(a))){let s=dE(t.doc,r.before(),r.after(),Rt.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=t.tr.step(s);l.setSelection(Kp(a,"start")?mn.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):qt.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},vJ=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;a=nL(r)}let s=a&&a.nodeAfter;return!s||!qt.isSelectable(s)?!1:(e&&e(t.tr.setSelection(qt.create(t.doc,a.pos)).scrollIntoView()),!0)};function nL(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const pBe=(t,e)=>{let n=t.selection,r=n instanceof qt,i;if(r){if(n.node.isTextblock||!Od(t.doc,n.from))return!1;i=n.from}else if(i=uE(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(qt.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},gBe=(t,e)=>{let n=t.selection,r;if(n instanceof qt){if(n.node.isTextblock||!Od(t.doc,n.to))return!1;r=n.to}else if(r=uE(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},xBe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&Mg(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},_J=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
- `).scrollIntoView()),!0)};function rL(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const bBe=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),s=rL(i.contentMatchAt(a));if(!s||!i.canReplaceWith(a,a,s))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,s.createAndFill());c.setSelection(mn.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},wJ=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof js||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=rL(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(s,a.createAndFill());l.setSelection(Qt.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},SJ=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let a=n.before();if(Ic(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Mg(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function yBe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof qt&&e.selection.node.isBlock)return!r.parentOffset||!Ic(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],s,l,c=!1,u=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){c=r.end(p)==r.pos+(r.depth-p),u=r.start(p)==r.pos-(r.depth-p),l=rL(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),a.unshift(c&&l?{type:l}:null),s=p;break}else{if(p==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof Qt||e.selection instanceof js)&&d.deleteSelection();let f=d.mapping.map(r.pos),g=Ic(d.doc,f,a.length,a);if(g||(a[0]=l?{type:l}:null,g=Ic(d.doc,f,a.length,a)),!g)return!1;if(d.split(f,a.length,a),!c&&u&&r.node(s).type!=l){let p=d.mapping.map(r.before(s)),x=d.doc.resolve(p);l&&r.node(s-1).canReplaceWith(x.index(),x.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(s)),l)}return n&&n(d.scrollIntoView()),!0}}const vBe=yBe(),_Be=(t,e)=>{let{$from:n,to:r}=t.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),e&&e(t.tr.setSelection(qt.create(t.doc,i))),!0)};function wBe(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,a=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(a-1,a)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(a,a+1)||!(i.isTextblock||Od(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function MJ(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,s,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&wBe(t,e,n))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&l.matchType(s[0]||a.type).validEnd){if(n){let p=e.pos+a.nodeSize,x=bt.empty;for(let b=s.length-1;b>=0;b--)x=bt.from(s[b].create(null,x));x=bt.from(i.copy(x));let v=t.tr.step(new $i(e.pos-1,p,e.pos,p,new Rt(x,1,0),s.length,!0)),y=v.doc.resolve(p+2*s.length);y.nodeAfter&&y.nodeAfter.type==i.type&&Od(v.doc,y.pos)&&v.join(y.pos),n(v.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:mn.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),g=f&&Mg(f);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(f,g).scrollIntoView()),!0;if(u&&Kp(a,"start",!0)&&Kp(i,"end")){let p=i,x=[];for(;x.push(p),!p.isTextblock;)p=p.lastChild;let v=a,y=1;for(;!v.isTextblock;v=v.firstChild)y++;if(p.canReplace(p.childCount,p.childCount,v.content)){if(n){let b=bt.empty;for(let w=x.length-1;w>=0;w--)b=bt.from(x[w].copy(b));let E=t.tr.step(new $i(e.pos-x.length,e.pos+a.nodeSize,e.pos+y,e.pos+a.nodeSize-y,new Rt(b,x.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function EJ(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(e.tr.setSelection(Qt.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const SBe=EJ(-1),MBe=EJ(1);function EBe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,s=i.blockRange(a),l=s&&QO(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function P7(t,e=null){return function(n,r){let i=!1;for(let a=0;a<n.selection.ranges.length&&!i;a++){let{$from:{pos:s},$to:{pos:l}}=n.selection.ranges[a];n.doc.nodesBetween(s,l,(c,u)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)i=!0;else{let d=n.doc.resolve(u),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let a=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[s];a.setBlockType(l,c,t,e)}r(a.scrollIntoView())}return!0}}function iL(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}iL(eL,pJ,xJ);iL(eL,yJ,vJ);iL(_J,wJ,SJ,vBe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function ABe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,s=i.blockRange(a);if(!s)return!1;let l=r?n.tr:null;return TBe(l,s,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function TBe(t,e,n,r=null){let i=!1,a=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=s.resolve(e.start-2);a=new aS(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new aS(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=QO(a,n,r,e);return l?(t&&NBe(t,e,l,i,n),!0):!1}function NBe(t,e,n,r,i){let a=bt.empty;for(let d=n.length-1;d>=0;d--)a=bt.from(n[d].type.create(n[d].attrs,a));t.step(new $i(e.start-(r?2:0),e.end,e.start,e.end,new Rt(a,0,0),n.length,!0));let s=0;for(let d=0;d<n.length;d++)n[d].type==i&&(s=d+1);let l=n.length-s,c=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,f=e.endIndex,g=!0;d<f;d++,g=!1)!g&&Ic(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function CBe(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==t);return a?n?r.node(a.depth-1).type==t?kBe(e,n,t,a):PBe(e,n,a):!0:!1}}function kBe(t,e,n,r){let i=t.tr,a=r.end,s=r.$to.end(r.depth);a<s&&(i.step(new $i(a-1,s,a,s,new Rt(bt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new aS(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const l=Mg(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return Od(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function PBe(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,x=n.endIndex-1,v=n.startIndex;x>v;x--)p-=i.child(x).nodeSize,r.delete(p-1,p+1);let a=r.doc.resolve(n.start),s=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,c=n.endIndex==i.childCount,u=a.node(-1),d=a.index(-1);if(!u.canReplace(d+(l?0:1),d+1,s.content.append(c?bt.empty:bt.from(i))))return!1;let f=a.pos,g=f+s.nodeSize;return r.step(new $i(f-(l?1:0),g+(c?1:0),f+1,g-1,new Rt((l?bt.empty:bt.from(i.copy(bt.empty))).append(c?bt.empty:bt.from(i.copy(bt.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function jBe(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==t);if(!a)return!1;let s=a.startIndex;if(s==0)return!1;let l=a.parent,c=l.child(s-1);if(c.type!=t)return!1;if(n){let u=c.lastChild&&c.lastChild.type==l.type,d=bt.from(u?t.create():null),f=new Rt(bt.from(t.create(null,bt.from(l.type.create(null,d)))),u?3:1,0),g=a.start,p=a.end;n(e.tr.step(new $i(g-(u?3:1),p,g,p,f,1,!0)).scrollIntoView())}return!0}}const sa=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Xp=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let xj=null;const bc=function(t,e,n){let r=xj||(xj=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},RBe=function(){xj=null},wf=function(t,e,n,r){return n&&(j7(t,e,n,r,-1)||j7(t,e,n,r,1))},DBe=/^(img|br|input|textarea|hr)$/i;function j7(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:ao(t))){let s=t.parentNode;if(!s||s.nodeType!=1||cy(t)||DBe.test(t.nodeName)||t.contentEditable=="false")return!1;e=sa(t)+(i<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((a=s.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=s,e=i<0?ao(t):0}else return!1}}function ao(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function OBe(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=ao(t)}else if(t.parentNode&&!cy(t))e=sa(t),t=t.parentNode;else return null}}function LBe(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!cy(t))e=sa(t)+1,t=t.parentNode;else return null}}function IBe(t,e,n){for(let r=e==0,i=e==ao(t);r||i;){if(t==n)return!0;let a=sa(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==ao(t)}}function cy(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const fE=function(t){return t.focusNode&&wf(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Mh(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function FBe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function UBe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(ao(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(ao(r.startContainer),r.startOffset)}}}const Nl=typeof navigator<"u"?navigator:null,R7=typeof document<"u"?document:null,Ld=Nl&&Nl.userAgent||"",bj=/Edge\/(\d+)/.exec(Ld),AJ=/MSIE \d/.exec(Ld),yj=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ld),is=!!(AJ||yj||bj),fd=AJ?document.documentMode:yj?+yj[1]:bj?+bj[1]:0,fo=!is&&/gecko\/(\d+)/i.test(Ld);fo&&+(/Firefox\/(\d+)/.exec(Ld)||[0,0])[1];const vj=!is&&/Chrome\/(\d+)/.exec(Ld),va=!!vj,TJ=vj?+vj[1]:0,Fa=!is&&!!Nl&&/Apple Computer/.test(Nl.vendor),Yp=Fa&&(/Mobile\/\w+/.test(Ld)||!!Nl&&Nl.maxTouchPoints>2),Js=Yp||(Nl?/Mac/.test(Nl.platform):!1),zBe=Nl?/Win/.test(Nl.platform):!1,kc=/Android \d/.test(Ld),uy=!!R7&&"webkitFontSmoothing"in R7.documentElement.style,BBe=uy?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function HBe(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function hc(t,e){return typeof t=="number"?t:t[e]}function $Be(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function D7(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=Xp(s);continue}let l=s,c=l==a.body,u=c?HBe(a):$Be(l),d=0,f=0;if(e.top<u.top+hc(r,"top")?f=-(u.top-e.top+hc(i,"top")):e.bottom>u.bottom-hc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+hc(i,"top")-u.top:e.bottom-u.bottom+hc(i,"bottom")),e.left<u.left+hc(r,"left")?d=-(u.left-e.left+hc(i,"left")):e.right>u.right-hc(r,"right")&&(d=e.right-u.right+hc(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let p=l.scrollLeft,x=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let v=l.scrollLeft-p,y=l.scrollTop-x;e={left:e.left-v,top:e.top-y,right:e.right-v,bottom:e.bottom-y}}let g=c?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(g))break;s=g=="absolute"?s.offsetParent:Xp(s)}}function VBe(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let a=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=t.root.elementFromPoint(a,s);if(!l||l==t.dom||!t.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=n-20){r=l,i=c.top;break}}return{refDOM:r,refTop:i,stack:NJ(t.dom)}}function NJ(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Xp(r));return e}function GBe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;CJ(n,r==0?0:r-e)}function CJ(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:a}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=a&&(r.scrollLeft=a)}}let qm=null;function WBe(t){if(t.setActive)return t.setActive();if(qm)return t.focus(qm);let e=NJ(t);t.focus(qm==null?{get preventScroll(){return qm={preventScroll:!0},!0}}:void 0),qm||(qm=!1,CJ(e,0))}function kJ(t,e){let n,r=2e8,i,a=0,s=e.top,l=e.top,c,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let g;if(d.nodeType==1)g=d.getClientRects();else if(d.nodeType==3)g=bc(d).getClientRects();else continue;for(let p=0;p<g.length;p++){let x=g[p];if(x.top<=s&&x.bottom>=l){s=Math.max(x.bottom,s),l=Math.min(x.top,l);let v=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(v<r){n=d,r=v,i=v&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,d.nodeType==1&&v&&(a=f+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!c&&x.left<=e.left&&x.right>=e.left&&(c=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(a=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?qBe(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:kJ(n,i)}function qBe(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let a=zu(r,1);if(a.top!=a.bottom&&aL(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function aL(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function KBe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function XBe(t,e,n){let{node:r,offset:i}=kJ(e,n),a=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();a=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,a)}function YBe(t,e,n,r){let i=-1;for(let a=e,s=!1;a!=t.dom;){let l=t.docView.nearestDesc(a,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&c.left>r.left||c.top>r.top?i=l.posBefore:(!s&&c.right<r.left||c.bottom<r.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;a=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function PJ(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let s=t.childNodes[a];if(s.nodeType==1){let l=s.getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(aL(e,u))return PJ(s,e,u)}}if((a=(a+1)%r)==i)break}return t}function ZBe(t,e){let n=t.dom.ownerDocument,r,i=0,a=UBe(n,e.left,e.top);a&&({node:r,offset:i}=a);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let u=t.dom.getBoundingClientRect();if(!aL(e,u)||(s=PJ(t.dom,e,u),!s))return null}if(Fa)for(let u=s;r&&u;u=Xp(u))u.draggable&&(r=void 0);if(s=KBe(s,e),r){if(fo&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],f;d.nodeName=="IMG"&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let u;uy&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=YBe(t,r,i,e))}l==null&&(l=XBe(t,s,e));let c=t.docView.nearestDesc(s,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function O7(t){return t.top<t.bottom||t.left<t.right}function zu(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(O7(r))return r}return Array.prototype.find.call(n,O7)||t.getBoundingClientRect()}const QBe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function jJ(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),s=uy||fo;if(r.nodeType==3)if(s&&(QBe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=zu(bc(r,i,i),n);if(fo&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=zu(bc(r,i-1,i-1),-1);if(u.top==c.top){let d=zu(bc(r,i,i+1),-1);if(d.top!=c.top)return Hx(d,d.left<u.left)}}return c}else{let c=i,u=i,d=n<0?1:-1;return n<0&&!i?(u++,d=-1):n>=0&&i==r.nodeValue.length?(c--,d=1):n<0?c--:u++,Hx(zu(bc(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==ao(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return sk(c.getBoundingClientRect(),!1)}if(a==null&&i<ao(r)){let c=r.childNodes[i];if(c.nodeType==1)return sk(c.getBoundingClientRect(),!0)}return sk(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==ao(r))){let c=r.childNodes[i-1],u=c.nodeType==3?bc(c,ao(c)-(s?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Hx(zu(u,1),!1)}if(a==null&&i<ao(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?bc(c,0,s?0:1):c.nodeType==1?c:null:null;if(u)return Hx(zu(u,-1),!0)}return Hx(zu(r.nodeType==3?bc(r):r,-n),n>=0)}function Hx(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function sk(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function RJ(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function JBe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return RJ(t,e,()=>{let{node:a}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(a,!0);if(!l)break;if(l.node.isBlock){a=l.contentDOM||l.dom;break}a=l.dom.parentNode}let s=jJ(t,i.pos,1);for(let l=a.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=bc(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;u<c.length;u++){let d=c[u];if(d.bottom>d.top+1&&(n=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}const e8e=/[\u0590-\u08ac]/;function t8e(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,s=i==r.parent.content.size,l=t.domSelection();return l?!e8e.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:s:RJ(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),g=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:v}=t.domSelectionRange(),y=x&&!p.contains(x.nodeType==1?x:x.parentNode)||c==x&&u==v;try{l.collapse(d,f),c&&(c!=d||u!=f)&&l.extend&&l.extend(c,u)}catch{}return g!=null&&(l.caretBidiLevel=g),y}):r.pos==r.start()||r.pos==r.end()}let L7=null,I7=null,F7=!1;function n8e(t,e,n){return L7==e&&I7==n?F7:(L7=e,I7=n,F7=n=="up"||n=="down"?JBe(t,e,n):t8e(t,e,n))}const mo=0,U7=1,kh=2,Cl=3;class dy{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=mo,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let a,s;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((s=a.pmViewDesc)&&s.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(s)+s.size:this.posAtStart}else{let a,s;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((s=a.pmViewDesc)&&s.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>sa(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!1;break}if(a.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!0;break}if(a.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let a=this.getDesc(i),s;if(a&&(!n||a.node))if(r&&(s=a.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return a}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let a=this.getDesc(i);if(a)return a.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],a=r+i.size;if(r==e&&a!=r){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let l=i.children[s];if(l.size){i=l;break}}return i}if(e<a)return i.descAt(e-r-i.border);r=a}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let a=0;r<this.children.length;r++){let s=this.children[r],l=a+s.size;if(l>e||s instanceof OJ){i=e-a;break}a=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let a;r&&!(a=this.children[r-1]).size&&a instanceof DJ&&a.side>=0;r--);if(n<=0){let a,s=!0;for(;a=r?this.children[r-1]:null,!(!a||a.dom.parentNode==this.contentDOM);r--,s=!1);return a&&n&&s&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?sa(a.dom)+1:0}}else{let a,s=!0;for(;a=r<this.children.length?this.children[r]:null,!(!a||a.dom.parentNode==this.contentDOM);r++,s=!1);return a&&s&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?sa(a.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,a=-1;for(let s=r,l=0;;l++){let c=this.children[l],u=s+c.size;if(i==-1&&e<=u){let d=s+c.border;if(e>=d&&n<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,n,d);e=s;for(let f=l;f>0;f--){let g=this.children[f-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){i=sa(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(u>n||l==this.children.length-1)){n=u;for(let d=l+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){a=sa(f.dom);break}n+=f.size}a==-1&&(a=this.contentDOM.childNodes.length);break}s=u}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:a}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let a=Math.min(e,n),s=Math.max(e,n);for(let p=0,x=0;p<this.children.length;p++){let v=this.children[p],y=x+v.size;if(a>x&&s<y)return v.setSelection(e-x-v.border,n-x-v.border,r,i);x=y}let l=this.domFromPos(e,e?-1:1),c=n==e?l:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((fo||Fa)&&e==n){let{node:p,offset:x}=l;if(p.nodeType==3){if(f=!!(x&&p.nodeValue[x-1]==`
- `),f&&x==p.nodeValue.length)for(let v=p,y;v;v=v.parentNode){if(y=v.nextSibling){y.nodeName=="BR"&&(l=c={node:y.parentNode,offset:sa(y)+1});break}let b=v.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let v=p.childNodes[x-1];f=v&&(v.nodeName=="BR"||v.contentEditable=="false")}}if(fo&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||f&&Fa)&&wf(l.node,l.offset,d.anchorNode,d.anchorOffset)&&wf(c.node,c.offset,d.focusNode,d.focusOffset))return;let g=!1;if((u.extend||e==n)&&!(f&&fo)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),g=!0}catch{}}if(!g){if(e>n){let x=l;l=c,c=x}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let a=this.children[i],s=r+a.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let l=r+a.border,c=s-a.border;if(e>=l&&n<=c){this.dirty=e==r||n==s?kh:U7,e==l&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=Cl:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?kh:Cl}r=s}this.dirty=kh}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?kh:U7;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class DJ extends dy{constructor(e,n,r,i){let a,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,a=this}matchesWidget(e){return this.dirty==mo&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class r8e extends dy{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Sf extends dy{constructor(e,n,r,i,a){super(e,[],r,i),this.mark=n,this.spec=a}static create(e,n,r,i){let a=i.nodeViews[n.type.name],s=a&&a(n,i,r);return(!s||!s.dom)&&(s=kf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Sf(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Cl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Cl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=mo){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=mo}}slice(e,n,r){let i=Sf.create(this.parent,this.mark,!0,r),a=this.children,s=this.size;n<s&&(a=wj(a,n,s,r)),e>0&&(a=wj(a,0,e,r));for(let l=0;l<a.length;l++)a[l].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class md extends dy{constructor(e,n,r,i,a,s,l,c,u){super(e,[],a,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,a,s){let l=a.nodeViews[n.type.name],c,u=l&&l(n,a,()=>{if(!c)return s;if(c.parent)return c.parent.posBeforeChild(c)},r,i),d=u&&u.dom,f=u&&u.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:f}=kf.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let g=d;return d=FJ(d,r,n),u?c=new i8e(e,n,r,i,d,f||null,g,u,a,s+1):n.isText?new mE(e,n,r,i,d,g,a):new md(e,n,r,i,d,f||null,g,a,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>bt.empty)}return e}matchesNode(e,n,r){return this.dirty==mo&&e.eq(this.node)&&oS(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,a=e.composing?this.localCompositionInfo(e,n):null,s=a&&a.pos>-1?a:null,l=a&&a.pos<0,c=new s8e(this,s&&s.node,e);c8e(this.node,this.innerDeco,(u,d,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&c.syncToMarks(d==this.node.childCount?mr.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,f,g)=>{c.syncToMarks(u.marks,r,e);let p;c.findNodeMatch(u,d,f,g)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(p=c.findIndexWithChild(a.node))>-1&&c.updateNodeAt(u,d,f,p,e)||c.updateNextNode(u,d,f,e,g,i)||c.addNode(u,d,f,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==kh)&&(s&&this.protectLocalComposition(e,s),LJ(this.contentDOM,this.children,e),Yp&&u8e(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Qt)||r<n||i>n+this.node.content.size)return null;let a=e.input.compositionNode;if(!a||!this.dom.contains(a.parentNode))return null;if(this.node.inlineContent){let s=a.nodeValue,l=d8e(this.node.content,s,r-n,i-n);return l<0?null:{node:a,pos:l,text:s}}else return{node:a,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let a=n;for(;a.parentNode!=this.contentDOM;a=a.parentNode){for(;a.previousSibling;)a.parentNode.removeChild(a.previousSibling);for(;a.nextSibling;)a.parentNode.removeChild(a.nextSibling);a.pmViewDesc&&(a.pmViewDesc=void 0)}let s=new r8e(this,a,n,i);e.input.compositionNodes.push(s),this.children=wj(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==Cl||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=mo}updateOuterDeco(e){if(oS(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=IJ(this.dom,this.nodeDOM,_j(this.outerDeco,this.node,n),_j(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function z7(t,e,n,r,i){FJ(r,e,t);let a=new md(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class mE extends md{constructor(e,n,r,i,a,s,l){super(e,n,r,i,a,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==Cl||this.dirty!=mo&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=mo||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=mo,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),a=document.createTextNode(i.text);return new mE(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Cl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class OJ extends dy{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==mo&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class i8e extends md{constructor(e,n,r,i,a,s,l,c,u,d){super(e,n,r,i,a,s,l,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==Cl)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let a=this.spec.update(e,n,r);return a&&this.updateInner(e,n,r,i),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function LJ(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a<e.length;a++){let s=e[a],l=s.dom;if(l.parentNode==t){for(;l!=r;)r=B7(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(s instanceof Sf){let c=r?r.previousSibling:t.lastChild;LJ(s.contentDOM,s.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=B7(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const x0=function(t){t&&(this.nodeName=t)};x0.prototype=Object.create(null);const Ph=[new x0];function _j(t,e,n){if(t.length==0)return Ph;let r=n?Ph[0]:new x0,i=[r];for(let a=0;a<t.length;a++){let s=t[a].type.attrs;if(s){s.nodeName&&i.push(r=new x0(s.nodeName));for(let l in s){let c=s[l];c!=null&&(n&&i.length==1&&i.push(r=new x0(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+c:l=="style"?r.style=(r.style?r.style+";":"")+c:l!="nodeName"&&(r[l]=c))}}}return i}function IJ(t,e,n,r){if(n==Ph&&r==Ph)return e;let i=e;for(let a=0;a<r.length;a++){let s=r[a],l=n[a];if(a){let c;l&&l.nodeName==s.nodeName&&i!=t&&(c=i.parentNode)&&c.nodeName.toLowerCase()==s.nodeName||(c=document.createElement(s.nodeName),c.pmIsDeco=!0,c.appendChild(i),l=Ph[0]),i=c}a8e(i,l||Ph[0],s)}return i}function a8e(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let a=0;a<r.length;a++)i.indexOf(r[a])==-1&&t.classList.remove(r[a]);for(let a=0;a<i.length;a++)r.indexOf(i[a])==-1&&t.classList.add(i[a]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function FJ(t,e,n){return IJ(t,t,Ph,_j(e,n,t.nodeType!=1))}function oS(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function B7(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class s8e{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=o8e(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let i=0,a=this.stack.length>>1,s=Math.min(a,e.length);for(;i<s&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=mo,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let c=this.index;c<Math.min(this.index+3,this.top.children.length);c++){let u=this.top.children[c];if(u.matchesMark(e[a])&&!this.isLocked(u.dom)){l=c;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=Sf.create(this.top,e[a],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,a++}}findNodeMatch(e,n,r,i){let a=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))a=this.top.children.indexOf(s,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let u=this.top.children[l];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){a=l;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,r,i,a){let s=this.top.children[i];return s.dirty==Cl&&s.dom==s.contentDOM&&(s.dirty=kh),s.update(e,n,r,a)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,a,s){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof md){let u=this.preMatch.matched.get(c);if(u!=null&&u!=a)return!1;let d=c.dom,f,g=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=Cl&&oS(n,c.outerDeco));if(!g&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!g&&(f=this.recreateWrapper(c,e,n,r,i,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=kh,f.updateChildren(i,s+1),f.dirty=mo),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,a,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!oS(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=md.create(this.top,n,r,i,a,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let c of l.children)c.parent=l}return e.destroy(),l}addNode(e,n,r,i,a){let s=md.create(this.top,e,n,r,i,a);s.contentDOM&&s.updateChildren(i,a+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let a=new DJ(this.top,e,n,r);this.top.children.splice(this.index++,0,a),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Sf;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof mE)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Fa||va)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new OJ(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function o8e(t,e){let n=e,r=n.children.length,i=t.childCount,a=new Map,s=[];e:for(;i>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Sf)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let c=l.node;if(c){if(c!=t.child(i-1))break;--i,a.set(l,i),s.push(l)}}return{index:i,matched:a,matches:s.reverse()}}function l8e(t,e){return t.type.side-e.type.side}function c8e(t,e,n,r){let i=e.locals(t),a=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);r(d,i,e.forChild(a,d),u),a+=d.nodeSize}return}let s=0,l=[],c=null;for(let u=0;;){let d,f;for(;s<i.length&&i[s].to==a;){let y=i[s++];y.widget&&(d?(f||(f=[d])).push(y):d=y)}if(d)if(f){f.sort(l8e);for(let y=0;y<f.length;y++)n(f[y],u,!!c)}else n(d,u,!!c);let g,p;if(c)p=-1,g=c,c=null;else if(u<t.childCount)p=u,g=t.child(u++);else break;for(let y=0;y<l.length;y++)l[y].to<=a&&l.splice(y--,1);for(;s<i.length&&i[s].from<=a&&i[s].to>a;)l.push(i[s++]);let x=a+g.nodeSize;if(g.isText){let y=x;s<i.length&&i[s].from<y&&(y=i[s].from);for(let b=0;b<l.length;b++)l[b].to<y&&(y=l[b].to);y<x&&(c=g.cut(y-a),g=g.cut(0,y-a),x=y,p=-1)}else for(;s<i.length&&i[s].to<x;)s++;let v=g.isInline&&!g.isLeaf?l.filter(y=>!y.inline):l.slice();r(g,v,e.forChild(a,g),p),a=x}}function u8e(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function d8e(t,e,n,r){for(let i=0,a=0;i<t.childCount&&a<=r;){let s=t.child(i++),l=a;if(a+=s.nodeSize,!s.isText)continue;let c=s.text;for(;i<t.childCount;){let u=t.child(i++);if(a+=u.nodeSize,!u.isText)break;c+=u.text}if(a>=n){if(a>=r&&c.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l<r?c.lastIndexOf(e,r-l-1):-1;if(u>=0&&u+e.length+l>=n)return l+u;if(n==r&&c.length>=r+e.length-l&&c.slice(r-l,r-l+e.length)==e)return r}}return-1}function wj(t,e,n,r,i){let a=[];for(let s=0,l=0;s<t.length;s++){let c=t[s],u=l,d=l+=c.size;u>=n||d<=e?a.push(c):(u<e&&a.push(c.slice(0,e-u,r)),i&&(a.push(i),i=void 0),d>n&&a.push(c.slice(n-u,c.size,r)))}return a}function sL(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),a=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),c,u;if(fE(n)){for(c=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&qt.isSelectable(f)&&i.parent&&!(f.isInline&&IBe(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;u=new qt(s==g?l:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,g=s;for(let p=0;p<n.rangeCount;p++){let x=n.getRangeAt(p);f=Math.min(f,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(f<0)return null;[c,s]=g==t.state.selection.anchor?[g,f]:[f,g],l=r.resolve(s)}else c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let d=r.resolve(c);if(!u){let f=e=="pointer"||t.state.selection.head<l.pos&&!a?1:-1;u=oL(t,d,l,f)}return u}function UJ(t){return t.editable?t.hasFocus():BJ(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Fc(t,e=!1){let n=t.state.selection;if(zJ(t,n),!!UJ(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&va){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&wf(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)f8e(t);else{let{anchor:r,head:i}=n,a,s;H7&&!(n instanceof Qt)&&(n.$from.parent.inlineContent||(a=$7(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=$7(t,n.to))),t.docView.setSelection(r,i,t,e),H7&&(a&&V7(a),s&&V7(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&h8e(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const H7=Fa||va&&TJ<63;function $7(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(Fa&&i&&i.contentEditable=="false")return ok(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return ok(i);if(a)return ok(a)}}function ok(t){return t.contentEditable="true",Fa&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function V7(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function h8e(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!UJ(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function f8e(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,sa(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&is&&fd<=11&&(n.disabled=!0,n.disabled=!1)}function zJ(t,e){if(e instanceof qt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(G7(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else G7(t)}function G7(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function oL(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Qt.between(e,n,r)}function W7(t){return t.editable&&!t.hasFocus()?!1:BJ(t)}function BJ(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function m8e(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return wf(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Sj(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return a&&mn.findFrom(a,e)}function Gu(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function q7(t,e,n){let r=t.state.selection;if(r instanceof Qt)if(n.indexOf("s")>-1){let{$head:i}=r,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let s=t.state.doc.resolve(i.pos+a.nodeSize*(e<0?-1:1));return Gu(t,new Qt(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Sj(t.state,e);return i&&i instanceof qt?Gu(t,i):!1}else if(!(Js&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!a||a.isText)return!1;let l=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?qt.isSelectable(a)?Gu(t,new qt(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):uy?Gu(t,new Qt(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof qt&&r.node.isInline)return Gu(t,new Qt(e>0?r.$to:r.$from));{let i=Sj(t.state,e);return i?Gu(t,i):!1}}}function lS(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function b0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Km(t,e){return e<0?p8e(t):g8e(t)}function p8e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,s=!1;for(fo&&n.nodeType==1&&r<lS(n)&&b0(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(b0(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(HJ(n))break;{let l=n.previousSibling;for(;l&&b0(l,-1);)i=n.parentNode,a=sa(l),l=l.previousSibling;if(l)n=l,r=lS(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?Mj(t,n,r):i&&Mj(t,i,a)}function g8e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=lS(n),a,s;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(b0(l,1))a=n,s=++r;else break}else{if(HJ(n))break;{let l=n.nextSibling;for(;l&&b0(l,1);)a=l.parentNode,s=sa(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=lS(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&Mj(t,a,s)}function HJ(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function x8e(t,e){for(;t&&e==t.childNodes.length&&!cy(t);)e=sa(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function b8e(t,e){for(;t&&!e&&!cy(t);)e=sa(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Mj(t,e,n){if(e.nodeType!=3){let a,s;(s=x8e(e,n))?(e=s,n=0):(a=b8e(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(fE(r)){let a=document.createRange();a.setEnd(e,n),a.setStart(e,n),r.removeAllRanges(),r.addRange(a)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&Fc(t)},50)}function K7(t,e){let n=t.state.doc.resolve(e);if(!(va||zBe)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),s=(a.top+a.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(a.left-i.left)>1)return a.left<i.left?"ltr":"rtl"}if(e<n.end()){let a=t.coordsAtPos(e+1),s=(a.top+a.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(a.left-i.left)>1)return a.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function X7(t,e,n){let r=t.state.selection;if(r instanceof Qt&&!r.empty||n.indexOf("s")>-1||Js&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Sj(t.state,e);if(s&&s instanceof qt)return Gu(t,s)}if(!i.parent.inlineContent){let s=e<0?i:a,l=r instanceof js?mn.near(s,e):mn.findFrom(s,e);return l?Gu(t,l):!1}return!1}function Y7(t,e){if(!(t.state.selection instanceof Qt))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let a=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let s=t.state.tr;return e<0?s.delete(n.pos-a.nodeSize,n.pos):s.delete(n.pos,n.pos+a.nodeSize),t.dispatch(s),!0}return!1}function Z7(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function y8e(t){if(!Fa||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Z7(t,r,"true"),setTimeout(()=>Z7(t,r,"false"),20)}return!1}function v8e(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function _8e(t,e){let n=e.keyCode,r=v8e(e);if(n==8||Js&&n==72&&r=="c")return Y7(t,-1)||Km(t,-1);if(n==46&&!e.shiftKey||Js&&n==68&&r=="c")return Y7(t,1)||Km(t,1);if(n==13||n==27)return!0;if(n==37||Js&&n==66&&r=="c"){let i=n==37?K7(t,t.state.selection.from)=="ltr"?-1:1:-1;return q7(t,i,r)||Km(t,i)}else if(n==39||Js&&n==70&&r=="c"){let i=n==39?K7(t,t.state.selection.from)=="ltr"?1:-1:1;return q7(t,i,r)||Km(t,i)}else{if(n==38||Js&&n==80&&r=="c")return X7(t,-1,r)||Km(t,-1);if(n==40||Js&&n==78&&r=="c")return y8e(t)||X7(t,1,r)||Km(t,1);if(r==(Js?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function lL(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:i,openEnd:a}=e;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=t.someProp("clipboardSerializer")||kf.fromSchema(t.state.schema),l=KJ(),c=l.createElement("div");c.appendChild(s.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=qJ[u.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let x=l.createElement(d[p]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
- `);return{dom:c,text:g,slice:e}}function $J(t,e,n,r,i){let a=i.parent.type.spec.code,s,l;if(!n&&!e)return null;let c=!!e&&(r||a||!n);if(c){if(t.someProp("transformPastedText",g=>{e=g(e,a||r,t)}),a)return l=new Rt(bt.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),0,0),t.someProp("transformPasted",g=>{l=g(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",g=>g(e,i,r,t));if(f)l=f;else{let g=i.marks(),{schema:p}=t.state,x=kf.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let y=s.appendChild(document.createElement("p"));v&&y.appendChild(x.serializeNode(p.text(v,g)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=E8e(n),uy&&A8e(s);let u=s&&s.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let g=s.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;s=g}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||p0.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!w8e.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)l=T8e(Q7(l,+d[1],+d[2]),d[4]);else if(l=Rt.maxOpen(S8e(l.content,i),!0),l.openStart||l.openEnd){let f=0,g=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;g<l.openEnd&&!p.type.spec.isolating;g++,p=p.lastChild);l=Q7(l,f,g)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const w8e=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function S8e(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),a,s=[];if(t.forEach(l=>{if(!s)return;let c=i.findWrapping(l.type),u;if(!c)return s=null;if(u=s.length&&a.length&&GJ(c,a,l,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=WJ(s[s.length-1],a.length));let d=VJ(l,c);s.push(d),i=i.matchType(d.type),a=c}}),s)return bt.from(s)}return t}function VJ(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,bt.from(t));return t}function GJ(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=GJ(t,e,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(bt.from(VJ(n,t,i+1))))}}function WJ(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,WJ(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(bt.empty,!0);return t.copy(n.append(r))}function Ej(t,e,n,r,i,a){let s=e<0?t.firstChild:t.lastChild,l=s.content;return t.childCount>1&&(a=0),i<r-1&&(l=Ej(l,e,n,r,i+1,a)),i>=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,a<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(bt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function Q7(t,e,n){return e<t.openStart&&(t=new Rt(Ej(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Rt(Ej(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const qJ={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let J7=null;function KJ(){return J7||(J7=document.implementation.createHTMLDocument("title"))}let lk=null;function M8e(t){let e=window.trustedTypes;return e?(lk||(lk=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),lk.createHTML(t)):t}function E8e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=KJ().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&qJ[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=M8e(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function A8e(t){let e=t.querySelectorAll(va?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function T8e(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:a,openEnd:s}=t;for(let l=r.length-2;l>=0;l-=2){let c=n.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;i=bt.from(c.create(r[l+1],i)),a++,s++}return new Rt(i,a,s)}const Ua={},za={},N8e={touchstart:!0,touchmove:!0};class C8e{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function k8e(t){for(let e in Ua){let n=Ua[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{j8e(t,r)&&!cL(t,r)&&(t.editable||!(r.type in za))&&n(t,r)},N8e[e]?{passive:!0}:void 0)}Fa&&t.dom.addEventListener("input",()=>null),Aj(t)}function ad(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function P8e(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Aj(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>cL(t,r))})}function cL(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function j8e(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function R8e(t,e){!cL(t,e)&&Ua[e.type]&&(t.editable||!(e.type in za))&&Ua[e.type](t,e)}za.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!YJ(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(kc&&va&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Yp&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,Mh(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||_8e(t,n)?n.preventDefault():ad(t,"key")};za.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};za.keypress=(t,e)=>{let n=e;if(YJ(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Js&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Qt)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function pE(t){return{left:t.clientX,top:t.clientY}}function D8e(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function uL(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let s=a.depth+1;s>0;s--)if(t.someProp(e,l=>s>a.depth?l(t,n,a.nodeAfter,a.before(s),i,!0):l(t,n,a.node(s),a.before(s),i,!1)))return!0;return!1}function wp(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function O8e(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&qt.isSelectable(r)?(wp(t,new qt(n)),!0):!1}function L8e(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof qt&&(r=n.node);let a=t.state.doc.resolve(e);for(let s=a.depth+1;s>0;s--){let l=s>a.depth?a.nodeAfter:a.node(s);if(qt.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(s);break}}return i!=null?(wp(t,qt.create(t.state.doc,i)),!0):!1}function I8e(t,e,n,r,i){return uL(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?L8e(t,n):O8e(t,n))}function F8e(t,e,n,r){return uL(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function U8e(t,e,n,r){return uL(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||z8e(t,n,r)}function z8e(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(wp(t,Qt.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let s=a>i.depth?i.nodeAfter:i.node(a),l=i.before(a);if(s.inlineContent)wp(t,Qt.create(r,l+1,l+1+s.content.size));else if(qt.isSelectable(s))wp(t,qt.create(r,l));else continue;return!0}}function dL(t){return cS(t)}const XJ=Js?"metaKey":"ctrlKey";Ua.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=dL(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&D8e(n,t.input.lastClick)&&!n[XJ]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let s=t.posAtCoords(pE(n));s&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new B8e(t,s,n,!!r)):(a=="doubleClick"?F8e:U8e)(t,s.pos,s.inside,n)?n.preventDefault():ad(t,"pointer"))};class B8e{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[XJ],this.allowDefault=r.shiftKey;let a,s;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),s=n.inside;else{let d=e.state.doc.resolve(n.pos);a=d.parent,s=d.depth?d.before():0}const l=i?null:r.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&a.type.spec.draggable&&a.type.spec.selectable!==!1||u instanceof qt&&u.from<=s&&u.to>s)&&(this.mightDrag={node:a,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&fo&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),ad(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Fc(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(pE(e))),this.updateAllowDefault(e),this.allowDefault||!n?ad(this.view,"pointer"):I8e(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Fa&&this.mightDrag&&!this.mightDrag.node.isAtom||va&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(wp(this.view,mn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):ad(this.view,"pointer")}move(e){this.updateAllowDefault(e),ad(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Ua.touchstart=t=>{t.input.lastTouch=Date.now(),dL(t),ad(t,"pointer")};Ua.touchmove=t=>{t.input.lastTouch=Date.now(),ad(t,"pointer")};Ua.contextmenu=t=>dL(t);function YJ(t,e){return t.composing?!0:Fa&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const H8e=kc?5e3:-1;za.compositionstart=za.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Qt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),cS(t,!0),t.markCursor=null;else if(cS(t,!e.selection.empty),fo&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,a=r.focusOffset;i&&i.nodeType==1&&a!=0;){let s=a<0?i.lastChild:i.childNodes[a-1];if(!s)break;if(s.nodeType==3){let l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,a=-1}}t.input.composing=!0}ZJ(t,H8e)};za.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,ZJ(t,20))};function ZJ(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>cS(t),e))}function QJ(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=V8e());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function $8e(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=OBe(e.focusNode,e.focusOffset),r=LBe(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,a=t.domObserver.lastChangedTextNode;if(n==a||r==a)return a;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function V8e(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function cS(t,e=!1){if(!(kc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),QJ(t),e||t.docView&&t.docView.dirty){let n=sL(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function G8e(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const fb=is&&fd<15||Yp&&BBe<604;Ua.copy=za.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=fb?null:n.clipboardData,s=r.content(),{dom:l,text:c}=lL(t,s);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):G8e(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function W8e(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function q8e(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?mb(t,r.value,null,i,e):mb(t,r.textContent,r.innerHTML,i,e)},50)}function mb(t,e,n,r,i){let a=$J(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||Rt.empty)))return!0;if(!a)return!1;let s=W8e(a),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(a);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function JJ(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}za.paste=(t,e)=>{let n=e;if(t.composing&&!kc)return;let r=fb?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&mb(t,JJ(r),r.getData("text/html"),i,n)?n.preventDefault():q8e(t,n)};class eee{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const K8e=Js?"altKey":"ctrlKey";function tee(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[K8e]}Ua.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,a=i.empty?null:t.posAtCoords(pE(n)),s;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof qt?i.to-1:i.to))){if(r&&r.mightDrag)s=qt.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(s=qt.create(t.state.doc,f.posBefore))}}let l=(s||t.state.selection).content(),{dom:c,text:u,slice:d}=lL(t,l);(!n.dataTransfer.files.length||!va||TJ>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(fb?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",fb||n.dataTransfer.setData("text/plain",u),t.dragging=new eee(d,tee(t,n),s)};Ua.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};za.dragover=za.dragenter=(t,e)=>e.preventDefault();za.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(pE(n));if(!i)return;let a=t.state.doc.resolve(i.pos),s=r&&r.slice;s?t.someProp("transformPasted",x=>{s=x(s,t,!1)}):s=$J(t,JJ(n.dataTransfer),fb?null:n.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&tee(t,n));if(t.someProp("handleDrop",x=>x(t,n,s||Rt.empty,l))){n.preventDefault();return}if(!s)return;n.preventDefault();let c=s?sJ(t.state.doc,a.pos,s):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(l){let{node:x}=r;x?x.replace(u):u.deleteSelection()}let d=u.mapping.map(c),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,g=u.doc;if(f?u.replaceRangeWith(d,d,s.content.firstChild):u.replaceRange(d,d,s),u.doc.eq(g))return;let p=u.doc.resolve(d);if(f&&qt.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new qt(p));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((v,y,b,E)=>x=E),u.setSelection(oL(t,p,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};Ua.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Fc(t)},20))};Ua.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Ua.beforeinput=(t,e)=>{if(va&&kc&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",a=>a(t,Mh(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in za)Ua[t]=za[t];function pb(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class uS{constructor(e,n){this.toDOM=e,this.spec=n||Wh,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new Ra(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof uS&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&pb(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class pd{constructor(e,n){this.attrs=e,this.spec=n||Wh}map(e,n,r,i){let a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=s?null:new Ra(a,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof pd&&pb(this.attrs,e.attrs)&&pb(this.spec,e.spec)}static is(e){return e.type instanceof pd}destroy(){}}class hL{constructor(e,n){this.attrs=e,this.spec=n||Wh}map(e,n,r,i){let a=e.mapResult(n.from+i,1);if(a.deleted)return null;let s=e.mapResult(n.to+i,-1);return s.deleted||s.pos<=a.pos?null:new Ra(a.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),a;return i==n.from&&!(a=e.child(r)).isText&&i+a.nodeSize==n.to}eq(e){return this==e||e instanceof hL&&pb(this.attrs,e.attrs)&&pb(this.spec,e.spec)}destroy(){}}class Ra{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ra(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Ra(e,e,new uS(n,r))}static inline(e,n,r,i){return new Ra(e,n,new pd(r,i))}static node(e,n,r,i){return new Ra(e,n,new hL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof pd}get widget(){return this.type instanceof uS}}const tp=[],Wh={};class Rr{constructor(e,n){this.local=e.length?e:tp,this.children=n.length?n:tp}static create(e,n){return n.length?dS(n,e,0,Wh):ba}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,a){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=n&&l.to>=e&&(!a||a(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,i+l,a)}}map(e,n,r){return this==ba||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Wh)}mapInner(e,n,r,i,a){let s;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,r,i);c&&c.type.valid(n,c)?(s||(s=[])).push(c):a.onRemove&&a.onRemove(this.local[l].spec)}return this.children.length?X8e(this.children,s||[],e,n,r,i,a):s?new Rr(s.sort(qh),tp):ba}add(e,n){return n.length?this==ba?Rr.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,a=0;e.forEach((l,c)=>{let u=c+r,d;if(d=ree(n,l,u)){for(i||(i=this.children.slice());a<i.length&&i[a]<c;)a+=3;i[a]==c?i[a+2]=i[a+2].addInner(l,d,u+1):i.splice(a,0,c,c+l.nodeSize,dS(d,l,u+1,Wh)),a+=3}});let s=nee(a?iee(n):n,-r);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new Rr(s.length?this.local.concat(s).sort(qh):this.local,i||this.children)}remove(e){return e.length==0||this==ba?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let a=0;a<r.length;a+=3){let s,l=r[a]+n,c=r[a+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>l&&f.to<c&&(e[d]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let u=r[a+2].removeInner(s,l+1);u!=ba?r[a+2]=u:(r.splice(a,3),a-=3)}if(i.length){for(let a=0,s;a<e.length;a++)if(s=e[a])for(let l=0;l<i.length;l++)i[l].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new Rr(i,r):ba}forChild(e,n){if(this==ba)return this;if(n.isLeaf)return Rr.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let a=e+1,s=a+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<s&&c.to>a&&c.type instanceof pd){let u=Math.max(a,c.from)-a,d=Math.min(s,c.to)-a;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let l=new Rr(i.sort(qh),tp);return r?new Zu([l,r]):l}return r||ba}eq(e){if(this==e)return!0;if(!(e instanceof Rr)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return fL(this.localsInner(e))}localsInner(e){if(this==ba)return tp;if(e.inlineContent||!this.local.some(pd.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof pd||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Rr.empty=new Rr([],[]);Rr.removeOverlap=fL;const ba=Rr.empty;class Zu{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Wh));return Zu.from(r)}forChild(e,n){if(n.isLeaf)return Rr.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=ba&&(a instanceof Zu?r=r.concat(a.members):r.push(a))}return Zu.from(r)}eq(e){if(!(e instanceof Zu)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let a=this.members[i].localsInner(e);if(a.length)if(!n)n=a;else{r&&(n=n.slice(),r=!1);for(let s=0;s<a.length;s++)n.push(a[s])}}return n?fL(r?n:n.sort(qh)):tp}static from(e){switch(e.length){case 0:return ba;case 1:return e[0];default:return new Zu(e.every(n=>n instanceof Rr)?e:e.reduce((n,r)=>n.concat(r instanceof Rr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function X8e(t,e,n,r,i,a,s){let l=t.slice();for(let u=0,d=a;u<n.maps.length;u++){let f=0;n.maps[u].forEach((g,p,x,v)=>{let y=v-x-(p-g);for(let b=0;b<l.length;b+=3){let E=l[b+1];if(E<0||g>E+d-f)continue;let w=l[b]+d-f;p>=w?l[b+1]=g<=w?-2:-1:g>=d&&y&&(l[b]+=y,l[b+1]+=y)}f+=y}),d=n.maps[u].map(d,-1)}let c=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){c=!0,l[u+1]=-1;continue}let d=n.map(t[u]+a),f=d-i;if(f<0||f>=r.content.size){c=!0;continue}let g=n.map(t[u+1]+a,-1),p=g-i,{index:x,offset:v}=r.content.findIndex(f),y=r.maybeChild(x);if(y&&v==f&&v+y.nodeSize==p){let b=l[u+2].mapInner(n,y,d+1,t[u]+a+1,s);b!=ba?(l[u]=f,l[u+1]=p,l[u+2]=b):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=Y8e(l,t,e,n,i,a,s),d=dS(u,r,0,s);e=d.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,g=0;f<d.children.length;f+=3){let p=d.children[f];for(;g<l.length&&l[g]<p;)g+=3;l.splice(g,0,d.children[f],d.children[f+1],d.children[f+2])}}return new Rr(e.sort(qh),l)}function nee(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new Ra(i.from+e,i.to+e,i.type))}return n}function Y8e(t,e,n,r,i,a,s){function l(c,u){for(let d=0;d<c.local.length;d++){let f=c.local[d].map(r,i,u);f?n.push(f):s.onRemove&&s.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)l(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&l(t[c+2],e[c]+a+1);return n}function ree(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let a=0,s;a<t.length;a++)(s=t[a])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),t[a]=null);return i}function iee(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function dS(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=ree(t,l,c+n);if(u){a=!0;let d=dS(u,l,n+c+1,r);d!=ba&&i.push(c,c+l.nodeSize,d)}});let s=nee(a?iee(t):t,-n).sort(qh);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||i.length?new Rr(s,i):ba}function qh(t,e){return t.from-e.from||t.to-e.to}function fL(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let a=e[i];if(a.from==r.from){a.to!=r.to&&(e==t&&(e=t.slice()),e[i]=a.copy(a.from,r.to),eG(e,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,a.from),eG(e,i,r.copy(a.from,r.to)));break}}}return e}function eG(t,e,n){for(;e<t.length&&qh(n,t[e])>0;)e++;t.splice(e,0,n)}function ck(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ba&&e.push(r)}),t.cursorWrapper&&e.push(Rr.create(t.state.doc,[t.cursorWrapper.deco])),Zu.from(e)}const Z8e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Q8e=is&&fd<=11;class J8e{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class e6e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new J8e,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);is&&fd<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Q8e&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Z8e)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(W7(this.view)){if(this.suppressingSelectionUpdates)return Fc(this.view);if(is&&fd<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&wf(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let a=e.focusNode;a;a=Xp(a))n.add(a);for(let a=e.anchorNode;a;a=Xp(a))if(n.has(a)){r=a;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&W7(e)&&!this.ignoreSelectionChange(r),a=-1,s=-1,l=!1,c=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],c);f&&(a=a<0?f.from:Math.min(f.from,a),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(l=!0))}if(fo&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,g]=d;f.parentNode&&f.parentNode.parentNode==g.parentNode?g.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let g of d){let p=g.parentNode;p&&p.nodeName=="LI"&&(!f||r6e(e,f)!=p)&&g.remove()}}}let u=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&fE(r)&&(u=sL(e))&&u.eq(mn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Fc(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,s),t6e(e)),this.handleDOMChange(a,s,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Fc(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,a=e.nextSibling;if(is&&fd<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:g}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(a=g)}let s=i&&i.parentNode==e.target?sa(i)+1:0,l=r.localPosFromDOM(e.target,s,-1),c=a&&a.parentNode==e.target?sa(a):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return{from:l,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let tG=new WeakMap,nG=!1;function t6e(t){if(!tG.has(t)&&(tG.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=fo,nG)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),nG=!0}}function rG(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return wf(s.node,s.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function n6e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return rG(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?rG(t,n):null}function r6e(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function i6e(t,e,n){let{node:r,fromOffset:i,toOffset:a,from:s,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],fE(c)||u.push({node:c.focusNode,offset:c.focusOffset})),va&&t.input.lastKeyCode===8)for(let y=a;y>i;y--){let b=r.childNodes[y-1],E=b.pmViewDesc;if(b.nodeName=="BR"&&!E){a=y;break}if(!E||E.size)break}let f=t.state.doc,g=t.someProp("domParser")||p0.fromSchema(t.state.schema),p=f.resolve(s),x=null,v=g.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:a6e,context:p});if(u&&u[0].pos!=null){let y=u[0].pos,b=u[1]&&u[1].pos;b==null&&(b=y),x={anchor:y+s,head:b+s}}return{doc:v,sel:x,from:s,to:l}}function a6e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Fa&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Fa&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const s6e=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function o6e(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let N=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,O=sL(t,N);if(O&&!t.state.selection.eq(O)){if(va&&kc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",j=>j(t,Mh(13,"Enter"))))return;let k=t.state.tr.setSelection(O);N=="pointer"?k.setMeta("pointer",!0):N=="key"&&k.scrollIntoView(),a&&k.setMeta("composition",a),t.dispatch(k)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let c=t.state.selection,u=i6e(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),g,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,p="end"):(g=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let x=u6e(f.content,u.doc.content,u.from,g,p);if(x&&t.input.domChangeCount++,(Yp&&t.input.lastIOSEnter>Date.now()-225||kc)&&i.some(N=>N.nodeType==1&&!s6e.test(N.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",N=>N(t,Mh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof Qt&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))x={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let N=iG(t,t.state.doc,u.sel);if(N&&!N.eq(t.state.selection)){let O=t.state.tr.setSelection(N);a&&O.setMeta("composition",a),t.dispatch(O)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof Qt&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),is&&fd<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>u.from&&u.doc.textBetween(x.start-u.from-1,x.start-u.from+1)==" "&&(x.start--,x.endA--,x.endB--);let v=u.doc.resolveNoCache(x.start-u.from),y=u.doc.resolveNoCache(x.endB-u.from),b=d.resolve(x.start),E=v.sameParent(y)&&v.parent.inlineContent&&b.end()>=x.endA;if((Yp&&t.input.lastIOSEnter>Date.now()-225&&(!E||i.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!E&&v.pos<u.doc.content.size&&(!v.sameParent(y)||!v.parent.inlineContent)&&v.pos<y.pos&&!/\S/.test(u.doc.textBetween(v.pos,y.pos,"","")))&&t.someProp("handleKeyDown",N=>N(t,Mh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&c6e(d,x.start,x.endA,v,y)&&t.someProp("handleKeyDown",N=>N(t,Mh(8,"Backspace")))){kc&&va&&t.domObserver.suppressSelectionUpdates();return}va&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),kc&&!E&&v.start()!=y.start()&&y.parentOffset==0&&v.depth==y.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==x.endA&&(x.endB-=2,y=u.doc.resolveNoCache(x.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(N){return N(t,Mh(13,"Enter"))})},20));let w=x.start,A=x.endA,T=N=>{let O=N||t.state.tr.replace(w,A,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let k=iG(t,O.doc,u.sel);k&&!(va&&t.composing&&k.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(k.head==w||k.head==O.mapping.map(A)-1)||is&&k.empty&&k.head==w)&&O.setSelection(k)}return a&&O.setMeta("composition",a),O.scrollIntoView()},C;if(E)if(v.pos==y.pos){is&&fd<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Fc(t),20));let N=T(t.state.tr.delete(w,A)),O=d.resolve(x.start).marksAcross(d.resolve(x.endA));O&&N.ensureMarks(O),t.dispatch(N)}else if(x.endA==x.endB&&(C=l6e(v.parent.content.cut(v.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,x.endA-b.start())))){let N=T(t.state.tr);C.type=="add"?N.addMark(w,A,C.mark):N.removeMark(w,A,C.mark),t.dispatch(N)}else if(v.parent.child(v.index()).isText&&v.index()==y.index()-(y.textOffset?0:1)){let N=v.parent.textBetween(v.parentOffset,y.parentOffset),O=()=>T(t.state.tr.insertText(N,w,A));t.someProp("handleTextInput",k=>k(t,w,A,N,O))||t.dispatch(O())}else t.dispatch(T());else t.dispatch(T())}function iG(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:oL(t,e.resolve(n.anchor),e.resolve(n.head))}function l6e(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,s,l,c;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)a=n[d].removeFromSet(a);if(i.length==1&&a.length==0)l=i[0],s="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&a.length==1)l=a[0],s="remove",c=d=>d.mark(l.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(bt.from(u).eq(t))return{mark:l,type:s}}function c6e(t,e,n,r,i){if(n-e<=i.pos-r.pos||uk(r,!0,!1)<i.pos)return!1;let a=t.resolve(e);if(!r.parent.isTextblock){let l=a.nodeAfter;return l!=null&&n==e+l.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let s=t.resolve(uk(a,!0,!0));return!s.parent.isTextblock||s.pos>n||uk(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function uk(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let a=t.node(r).maybeChild(t.indexAfter(r));for(;a&&!a.isLeaf;)a=a.firstChild,i++}return i}function u6e(t,e,n,r,i){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:s,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let c=Math.max(0,a-Math.min(s,l));r-=s+c-a}if(s<a&&t.size<e.size){let c=r<=a&&r>=s?a-r:0;a-=c,a&&a<e.size&&aG(e.textBetween(a-1,a+1))&&(a+=c?1:-1),l=a+(l-s),s=a}else if(l<a){let c=r<=a&&r>=l?a-r:0;a-=c,a&&a<t.size&&aG(t.textBetween(a-1,a+1))&&(a+=c?1:-1),s=a+(s-l),l=a}return{start:a,endA:s,endB:l}}function aG(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class aee{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new C8e,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(uG),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=lG(this),oG(this),this.nodeViews=cG(this),this.docView=z7(this.state.doc,sG(this),ck(this),this.dom,this),this.domObserver=new e6e(this,(r,i,a,s)=>o6e(this,r,i,a,s)),this.domObserver.start(),k8e(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Aj(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(uG),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,a=!1,s=!1;e.storedMarks&&this.composing&&(QJ(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=cG(this);h6e(p,this.nodeViews)&&(this.nodeViews=p,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Aj(this),this.editable=lG(this),oG(this);let c=ck(this),u=sG(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=a||!this.docView.matchesNode(e.doc,u,c);(f||!e.selection.eq(i.selection))&&(s=!0);let g=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&VBe(this);if(s){this.domObserver.stop();let p=f&&(is||va)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&d6e(i.selection,e.selection);if(f){let x=va?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=$8e(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=z7(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&m8e(this))?Fc(this,p):(zJ(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():g&&GBe(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof qt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&D7(this,n.getBoundingClientRect(),e)}else D7(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let a=r.from+(this.state.doc.content.size-n.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==r.node&&(i=a)}this.dragging=new eee(e.slice,e.move,i<0?void 0:qt.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(i=n?n(l):l))return i}let a=this.state.plugins;if(a)for(let s=0;s<a.length;s++){let l=a[s].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(is){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&WBe(this.dom),Fc(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return ZBe(this,e)}coordsAtPos(e,n=1){return jJ(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return n8e(this,n||this.state,e)}pasteHTML(e,n){return mb(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return mb(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return lL(this,e)}destroy(){this.docView&&(P8e(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ck(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,RBe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return R8e(this,e)}domSelectionRange(){let e=this.domSelection();return e?Fa&&this.root.nodeType===11&&FBe(this.dom.ownerDocument)==this.dom&&n6e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}aee.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function sG(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Ra.node(0,t.state.doc.content.size,e)]}function oG(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Ra.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function lG(t){return!t.someProp("editable",e=>e(t.state)===!1)}function d6e(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function cG(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function h6e(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function uG(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Nd={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},hS={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},f6e=typeof navigator<"u"&&/Mac/.test(navigator.platform),m6e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var oa=0;oa<10;oa++)Nd[48+oa]=Nd[96+oa]=String(oa);for(var oa=1;oa<=24;oa++)Nd[oa+111]="F"+oa;for(var oa=65;oa<=90;oa++)Nd[oa]=String.fromCharCode(oa+32),hS[oa]=String.fromCharCode(oa);for(var dk in Nd)hS.hasOwnProperty(dk)||(hS[dk]=Nd[dk]);function p6e(t){var e=f6e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||m6e&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?hS:Nd)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const g6e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),x6e=typeof navigator<"u"&&/Win/.test(navigator.platform);function b6e(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,s;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))g6e?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),a&&(n="Shift-"+n),n}function y6e(t){let e=Object.create(null);for(let n in t)e[b6e(n)]=t[n];return e}function hk(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function v6e(t){return new Fr({props:{handleKeyDown:see(t)}})}function see(t){let e=y6e(t);return function(n,r){let i=p6e(r),a,s=e[hk(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[hk(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(x6e&&r.ctrlKey&&r.altKey)&&(a=Nd[r.keyCode])&&a!=i){let l=e[hk(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var _6e=Object.defineProperty,mL=(t,e)=>{for(var n in e)_6e(t,n,{get:e[n],enumerable:!0})};function gE(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var xE=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([s,l])=>[s,(...u)=>{const d=l(...u)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,s=[],l=!!t,c=t||i.tr,u=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),s.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,g])=>[f,(...x)=>{const v=this.buildProps(c,e),y=g(...x)(v);return s.push(y),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...u)=>c(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,s={tr:t,editor:r,view:a,state:gE({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...u)=>c(...u)(s)]))}};return s}},oee={};mL(oee,{blur:()=>w6e,clearContent:()=>S6e,clearNodes:()=>M6e,command:()=>E6e,createParagraphNear:()=>A6e,cut:()=>T6e,deleteCurrentNode:()=>N6e,deleteNode:()=>C6e,deleteRange:()=>k6e,deleteSelection:()=>P6e,enter:()=>j6e,exitCode:()=>R6e,extendMarkRange:()=>D6e,first:()=>O6e,focus:()=>I6e,forEach:()=>F6e,insertContent:()=>U6e,insertContentAt:()=>H6e,joinBackward:()=>G6e,joinDown:()=>V6e,joinForward:()=>W6e,joinItemBackward:()=>q6e,joinItemForward:()=>K6e,joinTextblockBackward:()=>X6e,joinTextblockForward:()=>Y6e,joinUp:()=>$6e,keyboardShortcut:()=>Q6e,lift:()=>J6e,liftEmptyBlock:()=>eHe,liftListItem:()=>tHe,newlineInCode:()=>nHe,resetAttributes:()=>rHe,scrollIntoView:()=>iHe,selectAll:()=>aHe,selectNodeBackward:()=>sHe,selectNodeForward:()=>oHe,selectParentNode:()=>lHe,selectTextblockEnd:()=>cHe,selectTextblockStart:()=>uHe,setContent:()=>dHe,setMark:()=>CHe,setMeta:()=>kHe,setNode:()=>PHe,setNodeSelection:()=>jHe,setTextDirection:()=>RHe,setTextSelection:()=>DHe,sinkListItem:()=>OHe,splitBlock:()=>LHe,splitListItem:()=>IHe,toggleList:()=>FHe,toggleMark:()=>UHe,toggleNode:()=>zHe,toggleWrap:()=>BHe,undoInputRule:()=>HHe,unsetAllMarks:()=>$He,unsetMark:()=>VHe,unsetTextDirection:()=>GHe,updateAttributes:()=>WHe,wrapIn:()=>qHe,wrapInList:()=>KHe});var w6e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),S6e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),M6e=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:s})=>{t.doc.nodesBetween(a.pos,s.pos,(l,c)=>{if(l.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(c)),g=u.resolve(d.map(c+l.nodeSize)),p=f.blockRange(g);if(!p)return;const x=Mg(p);if(l.type.isTextblock){const{defaultType:v}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,v)}(x||x===0)&&e.lift(p,x)})}),!0},E6e=t=>e=>t(e),A6e=()=>({state:t,dispatch:e})=>wJ(t,e),T6e=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,a=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const s=r.mapping.map(e);return r.insert(s,a.content),r.setSelection(new Qt(r.doc.resolve(Math.max(s-1,0)))),!0},N6e=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===r.type){if(e){const l=i.before(a),c=i.after(a);t.delete(l,c).scrollIntoView()}return!0}return!1};function mi(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var C6e=t=>({tr:e,state:n,dispatch:r})=>{const i=mi(t,n.schema),a=e.selection.$anchor;for(let s=a.depth;s>0;s-=1)if(a.node(s).type===i){if(r){const c=a.before(s),u=a.after(s);e.delete(c,u).scrollIntoView()}return!0}return!1},k6e=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},P6e=()=>({state:t,dispatch:e})=>eL(t,e),j6e=()=>({commands:t})=>t.keyboardShortcut("Enter"),R6e=()=>({state:t,dispatch:e})=>bBe(t,e);function pL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function fS(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:pL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function lee(t,e,n={}){return t.find(r=>r.type===e&&fS(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function dG(t,e,n={}){return!!lee(t,e,n)}function gL(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(d=>d.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(d=>d.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!lee([...i.node.marks],e,n)))return;let s=i.index,l=t.start()+i.offset,c=s+1,u=l+i.node.nodeSize;for(;s>0&&dG([...t.parent.child(s-1).marks],e,n);)s-=1,l-=t.parent.child(s).nodeSize;for(;c<t.parent.childCount&&dG([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function tu(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var D6e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=tu(t,r.schema),{doc:s,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=gL(c,a,e);if(f&&f.from<=u&&f.to>=d){const g=Qt.create(s,f.from,f.to);n.setSelection(g)}}return!0},O6e=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function cee(t){return t instanceof Qt}function jh(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function uee(t,e=null){if(!e)return null;const n=mn.atStart(t),r=mn.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?Qt.create(t,jh(0,i,a),jh(t.content.size,i,a)):Qt.create(t,jh(e,i,a),jh(e,i,a))}function L6e(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function xL(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var I6e=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const s=()=>{(xL()||L6e())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(a&&t===null&&!cee(n.state.selection))return s(),!0;const l=uee(i.doc,t)||n.state.selection,c=n.state.selection.eq(l);return a&&(c||i.setSelection(l),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},F6e=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),U6e=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),dee=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&dee(r)}return t};function Z_(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return dee(n)}function gb(t,e,n){if(t instanceof hd||t instanceof bt)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return bt.fromArray(t.map(l=>e.nodeFromJSON(l)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(a){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:a});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",a),gb("",e,n)}if(i){if(n.errorOnInvalidContent){let s=!1,l="";const c=new XQ({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(s=!0,l=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?p0.fromSchema(c).parseSlice(Z_(t),n.parseOptions):p0.fromSchema(c).parse(Z_(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=p0.fromSchema(e);return n.slice?a.parseSlice(Z_(t),n.parseOptions).content:a.parse(Z_(t),n.parseOptions)}return gb("",e,n)}function z6e(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Bi||i instanceof $i))return;const a=t.mapping.maps[r];let s=0;a.forEach((l,c,u,d)=>{s===0&&(s=d)}),t.setSelection(mn.near(t.doc.resolve(s),n))}var B6e=t=>!("type"in t),H6e=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var s;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const c=y=>{a.emit("contentError",{editor:a,error:y,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{gb(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(y){c(y)}try{l=gb(e,a.schema,{parseOptions:u,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:a.options.enableContentCheck})}catch(y){return c(y),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,p=!0;if((B6e(l)?l:[l]).forEach(y=>{y.check(),g=g?y.isText&&y.marks.length===0:!1,p=p?y.isBlock:!1}),d===f&&p){const{parent:y}=r.doc.resolve(d);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(d-=1,f+=1)}let v;if(g){if(Array.isArray(e))v=e.map(y=>y.text||"").join("");else if(e instanceof bt){let y="";e.forEach(b=>{b.text&&(y+=b.text)}),v=y}else typeof e=="object"&&e&&e.text?v=e.text:v=e;r.insertText(v,d,f)}else{v=l;const y=r.doc.resolve(d),b=y.node(),E=y.parentOffset===0,w=b.isText||b.isTextblock,A=b.content.size>0;E&&w&&A&&(d=Math.max(0,d-1)),r.replaceWith(d,f,v)}n.updateSelection&&z6e(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:v}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:v})}return!0},$6e=()=>({state:t,dispatch:e})=>pBe(t,e),V6e=()=>({state:t,dispatch:e})=>gBe(t,e),G6e=()=>({state:t,dispatch:e})=>pJ(t,e),W6e=()=>({state:t,dispatch:e})=>yJ(t,e),q6e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=uE(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},K6e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=uE(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},X6e=()=>({state:t,dispatch:e})=>fBe(t,e),Y6e=()=>({state:t,dispatch:e})=>mBe(t,e);function hee(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Z6e(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,s;for(let l=0;l<e.length-1;l+=1){const c=e[l];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))xL()||hee()?s=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var Q6e=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=Z6e(t).split(/-(?!$)/),s=a.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,l))});return c?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function Cd(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,s=e?mi(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,g)=>{if(f.isText)return;const p=Math.max(r,g),x=Math.min(i,g+f.nodeSize);l.push({node:f,from:p,to:x})});const c=i-r,u=l.filter(f=>s?s.name===f.node.type.name:!0).filter(f=>fS(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=c}var J6e=(t,e={})=>({state:n,dispatch:r})=>{const i=mi(t,n.schema);return Cd(n,i,e)?xBe(n,r):!1},eHe=()=>({state:t,dispatch:e})=>SJ(t,e),tHe=t=>({state:e,dispatch:n})=>{const r=mi(t,e.schema);return CBe(r)(e,n)},nHe=()=>({state:t,dispatch:e})=>_J(t,e);function bE(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function hG(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var rHe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const l=bE(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=mi(t,r.schema)),l==="mark"&&(s=tu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,f)=>{a&&a===d.type&&(c=!0,i&&n.setNodeMarkup(f,void 0,hG(d.attrs,e))),s&&d.marks.length&&d.marks.forEach(g=>{s===g.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,s.create(hG(g.attrs,e))))})})}),c},iHe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),aHe=()=>({tr:t,dispatch:e})=>{if(e){const n=new js(t.doc);t.setSelection(n)}return!0},sHe=()=>({state:t,dispatch:e})=>xJ(t,e),oHe=()=>({state:t,dispatch:e})=>vJ(t,e),lHe=()=>({state:t,dispatch:e})=>_Be(t,e),cHe=()=>({state:t,dispatch:e})=>MBe(t,e),uHe=()=>({state:t,dispatch:e})=>SBe(t,e);function Tj(t,e,n={},r={}){return gb(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var dHe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:s,commands:l})=>{const{doc:c}=a;if(r.preserveWhitespace!=="full"){const u=Tj(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return s&&a.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return s&&a.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function fee(t,e){const n=tu(e,t.schema),{from:r,to:i,empty:a}=t.selection,s=[];a?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,c=>{s.push(...c.marks)});const l=s.find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function mee(t,e){const n=new dJ(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function hHe(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function fHe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function mHe(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function yE(t){return e=>mHe(e.$from,t)}function Gt(t,e,n){return t.config[e]===void 0&&t.parent?Gt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Gt(t.parent,e,n):null}):t.config[e]}function bL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Gt(e,"addExtensions",n);return r?[e,...bL(r())]:e}).flat(10)}function yL(t,e){const n=kf.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function pee(t){return typeof t=="function"}function Xn(t,e=void 0,...n){return pee(t)?e?t.bind(e)(...n):t(...n):t}function pHe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Zp(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function gee(t){const e=[],{nodeExtensions:n,markExtensions:r}=Zp(t),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{const l={name:s.name,options:s.options,storage:s.storage,extensions:i},c=Gt(s,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([g,p])=>{e.push({type:f,name:g,attribute:{...a,...p}})})})})}),i.forEach(s=>{const l={name:s.name,options:s.options,storage:s.storage},c=Gt(s,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const g={...a,...f};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:s.name,name:d,attribute:g})})}),e}function Wr(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,a])=>{if(!r[i]){r[i]=a;return}if(i==="class"){const l=a?String(a).split(" "):[],c=r[i]?r[i].split(" "):[],u=l.filter(d=>!c.includes(d));r[i]=[...c,...u].join(" ")}else if(i==="style"){const l=a?a.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[f,g]=d.split(":").map(p=>p.trim());u.set(f,g)}),l.forEach(d=>{const[f,g]=d.split(":").map(p=>p.trim());u.set(f,g)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=a}),r},{})}function mS(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>Wr(n,r),{})}function gHe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function fG(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((a,s)=>{const l=s.attribute.parseHTML?s.attribute.parseHTML(n):gHe(n.getAttribute(s.name));return l==null?a:{...a,[s.name]:l}},{});return{...r,...i}}}}function mG(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&pHe(n)?!1:n!=null))}function pG(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function xHe(t,e){var n;const r=gee(t),{nodeExtensions:i,markExtensions:a}=Zp(t),s=(n=i.find(u=>Gt(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(b=>b.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((b,E)=>{const w=Gt(E,"extendNodeSchema",f);return{...b,...w?w(u):{}}},{}),p=mG({...g,content:Xn(Gt(u,"content",f)),marks:Xn(Gt(u,"marks",f)),group:Xn(Gt(u,"group",f)),inline:Xn(Gt(u,"inline",f)),atom:Xn(Gt(u,"atom",f)),selectable:Xn(Gt(u,"selectable",f)),draggable:Xn(Gt(u,"draggable",f)),code:Xn(Gt(u,"code",f)),whitespace:Xn(Gt(u,"whitespace",f)),linebreakReplacement:Xn(Gt(u,"linebreakReplacement",f)),defining:Xn(Gt(u,"defining",f)),isolating:Xn(Gt(u,"isolating",f)),attrs:Object.fromEntries(d.map(pG))}),x=Xn(Gt(u,"parseHTML",f));x&&(p.parseDOM=x.map(b=>fG(b,d)));const v=Gt(u,"renderHTML",f);v&&(p.toDOM=b=>v({node:b,HTMLAttributes:mS(b,d)}));const y=Gt(u,"renderText",f);return y&&(p.toText=y),[u.name,p]})),c=Object.fromEntries(a.map(u=>{const d=r.filter(y=>y.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((y,b)=>{const E=Gt(b,"extendMarkSchema",f);return{...y,...E?E(u):{}}},{}),p=mG({...g,inclusive:Xn(Gt(u,"inclusive",f)),excludes:Xn(Gt(u,"excludes",f)),group:Xn(Gt(u,"group",f)),spanning:Xn(Gt(u,"spanning",f)),code:Xn(Gt(u,"code",f)),attrs:Object.fromEntries(d.map(pG))}),x=Xn(Gt(u,"parseHTML",f));x&&(p.parseDOM=x.map(y=>fG(y,d)));const v=Gt(u,"renderHTML",f);return v&&(p.toDOM=y=>v({mark:y,HTMLAttributes:mS(y,d)})),[u.name,p]}));return new XQ({topNode:s,nodes:l,marks:c})}function bHe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function vL(t){return t.sort((n,r)=>{const i=Gt(n,"priority")||100,a=Gt(r,"priority")||100;return i>a?-1:i<a?1:0})}function xee(t){const e=vL(bL(t)),n=bHe(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function bee(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
- `,textSerializers:s={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,f)=>{var g;c.isBlock&&u>r&&(l+=a);const p=s?.[c.type.name];if(p)return d&&(l+=p({node:c,pos:u,parent:d,index:f,range:e})),!1;c.isText&&(l+=(g=c?.text)==null?void 0:g.slice(Math.max(r,u)-u,i-u))}),l}function yHe(t,e){const n={from:0,to:t.content.size};return bee(t,n,e)}function yee(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function vHe(t,e){const n=mi(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,l=>{a.push(l)});const s=a.reverse().find(l=>l.type.name===n.name);return s?{...s.attrs}:{}}function vee(t,e){const n=bE(typeof e=="string"?e:e.name,t.schema);return n==="node"?vHe(t,e):n==="mark"?fee(t,e):{}}function _He(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function wHe(t){const e=_He(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,s)=>s!==r).some(a=>n.oldRange.from>=a.oldRange.from&&n.oldRange.to<=a.oldRange.to&&n.newRange.from>=a.newRange.from&&n.newRange.to<=a.newRange.to))}function _ee(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const s=[];if(i.ranges.length)i.forEach((l,c)=>{s.push({from:l,to:c})});else{const{from:l,to:c}=n[a];if(l===void 0||c===void 0)return;s.push({from:l,to:c})}s.forEach(({from:l,to:c})=>{const u=e.slice(a).map(l,-1),d=e.slice(a).map(c),f=e.invert().map(u,-1),g=e.invert().map(d);r.push({oldRange:{from:f,to:g},newRange:{from:u,to:d}})})}),wHe(r)}function _L(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),s=gL(a,i.type);s&&r.push({mark:i,...s})}):n.nodesBetween(t,e,(i,a)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(s=>({from:a,to:a+i.nodeSize,mark:s})))}),r}var SHe=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,s=null;for(;a>0&&s===null;){const l=i.node(a);l?.type.name===e?s=l:a-=1}return[s,a]};function fk(t,e){return e.nodes[t]||e.marks[t]||null}function P1(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(a=>a.type===e&&a.name===r);return i?i.attribute.keepOnSplit:!1}))}var MHe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,s,l)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{node:i,pos:a,parent:s,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-a))}),n};function Nj(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?tu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>fS(f.attrs,n,{strict:!1}));let s=0;const l=[];if(i.forEach(({$from:f,$to:g})=>{const p=f.pos,x=g.pos;t.doc.nodesBetween(p,x,(v,y)=>{if(!v.isText&&!v.marks.length)return;const b=Math.max(p,y),E=Math.min(x,y+v.nodeSize),w=E-b;s+=w,l.push(...v.marks.map(A=>({mark:A,from:b,to:E})))})}),s===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>fS(f.mark.attrs,n,{strict:!1})).reduce((f,g)=>f+g.to-g.from,0),u=l.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,g)=>f+g.to-g.from,0);return(c>0?c+u:c)>=s}function EHe(t,e,n={}){if(!e)return Cd(t,null,n)||Nj(t,null,n);const r=bE(e,t.schema);return r==="node"?Cd(t,e,n):r==="mark"?Nj(t,e,n):!1}var AHe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=yE(l=>l.type.name===e)(t.selection);if(!a)return!1;const s=t.doc.resolve(a.pos+1);return i.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},THe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function gG(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function xG(t,e){const{nodeExtensions:n}=Zp(e),r=n.find(s=>s.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=Xn(Gt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function vE(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(a=>{i!==!1&&(vE(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function wee(t){return t instanceof qt}function NHe(t,e,n){var r;const{selection:i}=e;let a=null;if(cee(i)&&(a=i.$cursor),a){const l=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(u=>u.type.excludes(n)))}const{ranges:s}=i;return s.some(({$from:l,$to:c})=>{let u=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,c.pos,(d,f,g)=>{if(u)return!1;if(d.isInline){const p=!g||g.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(v=>v.type.excludes(n));u=p&&x}return!u}),u})}var CHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:s,ranges:l}=a,c=tu(t,r.schema);if(i)if(s){const u=fee(r,c);n.addStoredMark(c.create({...u,...e}))}else l.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(d,f,(g,p)=>{const x=Math.max(p,d),v=Math.min(p+g.nodeSize,f);g.marks.find(b=>b.type===c)?g.marks.forEach(b=>{c===b.type&&n.addMark(x,v,c.create({...b.attrs,...e}))}):n.addMark(x,v,c.create(e))})});return NHe(r,n,c)},kHe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),PHe=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=mi(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:l})=>P7(a,{...s,...e})(n)?!0:l.clearNodes()).command(({state:l})=>P7(a,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},jHe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=jh(t,0,r.content.size),a=qt.create(r,i);e.setSelection(a)}return!0},RHe=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=r;let s,l;return typeof e=="number"?(s=e,l=e):e&&"from"in e&&"to"in e?(s=e.from,l=e.to):(s=a.from,l=a.to),i&&n.doc.nodesBetween(s,l,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},DHe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,s=Qt.atStart(r).from,l=Qt.atEnd(r).to,c=jh(i,s,l),u=jh(a,s,l),d=Qt.create(r,c,u);e.setSelection(d)}return!0},OHe=t=>({state:e,dispatch:n})=>{const r=mi(t,e.schema);return jBe(r)(e,n)};function bG(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e?.includes(i.type.name));t.tr.ensureMarks(r)}}var LHe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:s}=e,{$from:l,$to:c}=a,u=i.extensionManager.attributes,d=P1(u,l.node().type.name,l.node().attrs);if(a instanceof qt&&a.node.isBlock)return!l.parentOffset||!Ic(s,l.pos)?!1:(r&&(t&&bG(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,g=l.depth===0?void 0:hHe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=f&&g?[{type:g,attrs:d}]:void 0,x=Ic(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!x&&Ic(e.doc,e.mapping.map(l.pos),1,g?[{type:g}]:void 0)&&(x=!0,p=g?[{type:g,attrs:d}]:void 0),r){if(x&&(a instanceof Qt&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),g&&!f&&!l.parentOffset&&l.parent.type!==g)){const v=e.mapping.map(l.before()),y=e.doc.resolve(v);l.node(-1).canReplaceWith(y.index(),y.index()+1,g)&&e.setNodeMarkup(e.mapping.map(l.before()),g)}t&&bG(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},IHe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var s;const l=mi(t,r.schema),{$from:c,$to:u}=r.selection,d=r.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const f=c.node(-1);if(f.type!==l)return!1;const g=a.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let b=bt.empty;const E=c.index(-1)?1:c.index(-2)?2:3;for(let O=c.depth-E;O>=c.depth-3;O-=1)b=bt.from(c.node(O).copy(b));const w=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...P1(g,c.node().type.name,c.node().attrs),...e},T=((s=l.contentMatch.defaultType)==null?void 0:s.createAndFill(A))||void 0;b=b.append(bt.from(l.createAndFill(null,T)||void 0));const C=c.before(c.depth-(E-1));n.replace(C,c.after(-w),new Rt(b,4-E,0));let N=-1;n.doc.nodesBetween(C,n.doc.content.size,(O,k)=>{if(N>-1)return!1;O.isTextblock&&O.content.size===0&&(N=k+1)}),N>-1&&n.setSelection(Qt.near(n.doc.resolve(N))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...P1(g,f.type.name,f.attrs),...e},v={...P1(g,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const y=p?[{type:l,attrs:x},{type:p,attrs:v}]:[{type:l,attrs:x}];if(!Ic(n.doc,c.pos,2))return!1;if(i){const{selection:b,storedMarks:E}=r,{splittableMarks:w}=a.extensionManager,A=E||b.$to.parentOffset&&b.$from.marks();if(n.split(c.pos,2,y).scrollIntoView(),!A||!i)return!0;const T=A.filter(C=>w.includes(C.type.name));n.ensureMarks(T)}return!0},mk=(t,e)=>{const n=yE(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&Od(t.doc,n.pos)&&t.join(n.pos),!0},pk=(t,e)=>{const n=yE(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&Od(t.doc,r)&&t.join(r),!0},FHe=(t,e,n,r={})=>({editor:i,tr:a,state:s,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:g}=i.extensionManager,p=mi(t,s.schema),x=mi(e,s.schema),{selection:v,storedMarks:y}=s,{$from:b,$to:E}=v,w=b.blockRange(E),A=y||v.$to.parentOffset&&v.$from.marks();if(!w)return!1;const T=yE(C=>xG(C.type.name,f))(v);if(w.depth>=1&&T&&w.depth-T.depth<=1){if(T.node.type===p)return u.liftListItem(x);if(xG(T.node.type.name,f)&&p.validContent(T.node.content)&&l)return c().command(()=>(a.setNodeMarkup(T.pos,p),!0)).command(()=>mk(a,p)).command(()=>pk(a,p)).run()}return!n||!A||!l?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>mk(a,p)).command(()=>pk(a,p)).run():c().command(()=>{const C=d().wrapInList(p,r),N=A.filter(O=>g.includes(O.type.name));return a.ensureMarks(N),C?!0:u.clearNodes()}).wrapInList(p,r).command(()=>mk(a,p)).command(()=>pk(a,p)).run()},UHe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,s=tu(t,r.schema);return Nj(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:a}):i.setMark(s,e)},zHe=(t,e,n={})=>({state:r,commands:i})=>{const a=mi(t,r.schema),s=mi(e,r.schema),l=Cd(r,a,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),l?i.setNode(s,c):i.setNode(a,{...c,...n})},BHe=(t,e={})=>({state:n,commands:r})=>{const i=mi(t,n.schema);return Cd(n,i,e)?r.lift(i):r.wrapIn(i,e)},HHe=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let a;if(i.spec.isInputRules&&(a=i.getState(t))){if(e){const s=t.tr,l=a.transform;for(let c=l.steps.length-1;c>=0;c-=1)s.step(l.steps[c].invert(l.docs[c]));if(a.text){const c=s.doc.resolve(a.from).marks();s.replaceWith(a.from,a.to,t.schema.text(a.text,c))}else s.delete(a.from,a.to)}return!0}}return!1},$He=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},VHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:s=!1}=e,{selection:l}=n,c=tu(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&s){let{from:g,to:p}=l;const x=(a=u.marks().find(y=>y.type===c))==null?void 0:a.attrs,v=gL(u,c,x);v&&(g=v.from,p=v.to),n.removeMark(g,p,c)}else f.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,c)});return n.removeStoredMark(c),!0},GHe=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,s;return typeof t=="number"?(a=t,s=t):t&&"from"in t&&"to"in t?(a=t.from,s=t.to):(a=i.from,s=i.to),r&&e.doc.nodesBetween(a,s,(l,c)=>{if(l.isText)return;const u={...l.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},WHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const l=bE(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=mi(t,r.schema)),l==="mark"&&(s=tu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let g,p,x,v;n.selection.empty?r.doc.nodesBetween(d,f,(y,b)=>{a&&a===y.type&&(c=!0,x=Math.max(b,d),v=Math.min(b+y.nodeSize,f),g=b,p=y)}):r.doc.nodesBetween(d,f,(y,b)=>{b<d&&a&&a===y.type&&(c=!0,x=Math.max(b,d),v=Math.min(b+y.nodeSize,f),g=b,p=y),b>=d&&b<=f&&(a&&a===y.type&&(c=!0,i&&n.setNodeMarkup(b,void 0,{...y.attrs,...e})),s&&y.marks.length&&y.marks.forEach(E=>{if(s===E.type&&(c=!0,i)){const w=Math.max(b,d),A=Math.min(b+y.nodeSize,f);n.addMark(w,A,s.create({...E.attrs,...e}))}}))}),p&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...p.attrs,...e}),s&&p.marks.length&&p.marks.forEach(y=>{s===y.type&&i&&n.addMark(x,v,s.create({...y.attrs,...e}))}))}),c},qHe=(t,e={})=>({state:n,dispatch:r})=>{const i=mi(t,n.schema);return EBe(i,e)(n,r)},KHe=(t,e={})=>({state:n,dispatch:r})=>{const i=mi(t,n.schema);return ABe(i,e)(n,r)},XHe=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},_E=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},YHe=(t,e)=>{if(pL(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Q_(t){var e;const{editor:n,from:r,to:i,text:a,rules:s,plugin:l}=t,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let d=!1;const f=MHe(u)+a;return s.forEach(g=>{if(d)return;const p=YHe(f,g.find);if(!p)return;const x=c.state.tr,v=gE({state:c.state,transaction:x}),y={from:r-(p[0].length-a.length),to:i},{commands:b,chain:E,can:w}=new xE({editor:n,state:v});g.handler({state:v,range:y,match:p,commands:b,chain:E,can:w})===null||!x.steps.length||(g.undoable&&x.setMeta(l,{transform:x,from:r,to:i,text:a}),c.dispatch(x),d=!0)}),d}function ZHe(t){const{editor:e,rules:n}=t,r=new Fr({state:{init(){return null},apply(i,a,s){const l=i.getMeta(r);if(l)return l;const c=i.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=yL(bt.from(d),s.schema);const{from:f}=c,g=f+d.length;Q_({editor:e,from:f,to:g,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,s,l){return Q_({editor:e,from:a,to:s,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&Q_({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,a){if(a.key!=="Enter")return!1;const{$cursor:s}=i.state.selection;return s?Q_({editor:e,from:s.pos,to:s.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function QHe(t){return Object.prototype.toString.call(t).slice(8,-1)}function J_(t){return QHe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function See(t,e){const n={...t};return J_(t)&&J_(e)&&Object.keys(e).forEach(r=>{J_(e[r])&&J_(t[r])?n[r]=See(t[r],e[r]):n[r]=e[r]}),n}var wL=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Xn(Gt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Xn(Gt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>See(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Id=class Mee extends wL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Mee(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const s=i.marks();if(!!!s.find(u=>u?.type.name===n.name))return!1;const c=s.find(u=>u?.type.name===n.name);return c&&r.removeStoredMark(c),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function JHe(t){return typeof t=="number"}var e$e=class{constructor(t){this.find=t.find,this.handler=t.handler}},t$e=(t,e,n)=>{if(pL(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const a=[i.text];return a.index=i.index,a.input=t,a.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(i.replaceWith)),a}):[]};function n$e(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:s,dropEvent:l}=t,{commands:c,chain:u,can:d}=new xE({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(p,x)=>{var v,y,b,E,w;if((y=(v=p.type)==null?void 0:v.spec)!=null&&y.code||!(p.isText||p.isTextblock||p.isInline))return;const A=(w=(E=(b=p.content)==null?void 0:b.size)!=null?E:p.nodeSize)!=null?w:0,T=Math.max(r,x),C=Math.min(i,x+A);if(T>=C)return;const N=p.isText?p.text||"":p.textBetween(T-x,C-x,void 0,"");t$e(N,a.find,s).forEach(k=>{if(k.index===void 0)return;const j=T+k.index+1,B=j+k[0].length,L={from:n.tr.mapping.map(j),to:n.tr.mapping.map(B)},K=a.handler({state:n,range:L,match:k,commands:c,chain:u,can:d,pasteEvent:s,dropEvent:l});f.push(K)})}),f.every(p=>p!==null)}var e1=null,r$e=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function i$e(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const c=({state:d,from:f,to:g,rule:p,pasteEvt:x})=>{const v=d.tr,y=gE({state:d,transaction:v});if(!(!n$e({editor:e,state:y,from:Math.max(f-1,0),to:g.b-1,rule:p,pasteEvent:x,dropEvent:l})||!v.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,v}};return n.map(d=>new Fr({view(f){const g=x=>{var v;r=(v=f.dom.parentElement)!=null&&v.contains(x.target)?f.dom.parentElement:null,r&&(e1=e)},p=()=>{e1&&(e1=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(f,g)=>{if(a=r===f.dom.parentElement,l=g,!a){const p=e1;p?.isEditable&&setTimeout(()=>{const x=p.state.selection;x&&p.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,g)=>{var p;const x=(p=g.clipboardData)==null?void 0:p.getData("text/html");return s=g,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(f,g,p)=>{const x=f[0],v=x.getMeta("uiEvent")==="paste"&&!i,y=x.getMeta("uiEvent")==="drop"&&!a,b=x.getMeta("applyPasteRules"),E=!!b;if(!v&&!y&&!E)return;if(E){let{text:T}=b;typeof T=="string"?T=T:T=yL(bt.from(T),p.schema);const{from:C}=b,N=C+T.length,O=r$e(T);return c({rule:d,state:p,from:C,to:{b:N},pasteEvt:O})}const w=g.doc.content.findDiffStart(p.doc.content),A=g.doc.content.findDiffEnd(p.doc.content);if(!(!JHe(w)||!A||w===A.b))return c({rule:d,state:p,from:w,to:A,pasteEvt:s})}}))}var wE=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=xee(t),this.schema=xHe(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:fk(e.name,this.schema)},r=Gt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return vL([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:fk(r.name,this.schema)},a=[],s=Gt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Gt(r,"exitable",i)&&(l.ArrowRight=()=>Id.handleExit({editor:t,mark:r})),s){const g=Object.fromEntries(Object.entries(s()).map(([p,x])=>[p,()=>x({editor:t})]));l={...l,...g}}const c=v6e(l);a.push(c);const u=Gt(r,"addInputRules",i);if(gG(r,t.options.enableInputRules)&&u){const g=u();if(g&&g.length){const p=ZHe({editor:t,rules:g}),x=Array.isArray(p)?p:[p];a.push(...x)}}const d=Gt(r,"addPasteRules",i);if(gG(r,t.options.enablePasteRules)&&d){const g=d();if(g&&g.length){const p=i$e({editor:t,rules:g});a.push(...p)}}const f=Gt(r,"addProseMirrorPlugins",i);if(f){const g=f();a.push(...g)}return a})}get attributes(){return gee(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Zp(this.extensions);return Object.fromEntries(e.filter(n=>!!Gt(n,"addNodeView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:mi(n.name,this.schema)},a=Gt(n,"addNodeView",i);if(!a)return[];const s=a();if(!s)return[];const l=(c,u,d,f,g)=>{const p=mS(c,r);return s({node:c,view:u,getPos:d,decorations:f,innerDecorations:g,editor:t,extension:n,HTMLAttributes:p})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=Zp(this.extensions);return Object.fromEntries(e.filter(n=>!!Gt(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:tu(n.name,this.schema)},a=Gt(n,"addMarkView",i);if(!a)return[];const s=(l,c,u)=>{const d=mS(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{y$e(l,t,f)}})};return[n.name,s]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:fk(e.name,this.schema)};e.type==="mark"&&((n=Xn(Gt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Gt(e,"onBeforeCreate",r),a=Gt(e,"onCreate",r),s=Gt(e,"onUpdate",r),l=Gt(e,"onSelectionUpdate",r),c=Gt(e,"onTransaction",r),u=Gt(e,"onFocus",r),d=Gt(e,"onBlur",r),f=Gt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),s&&this.editor.on("update",s),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};wE.resolve=xee;wE.sort=vL;wE.flatten=bL;var a$e={};mL(a$e,{ClipboardTextSerializer:()=>Aee,Commands:()=>Tee,Delete:()=>Nee,Drop:()=>Cee,Editable:()=>kee,FocusEvents:()=>jee,Keymap:()=>Ree,Paste:()=>Dee,Tabindex:()=>Oee,TextDirection:()=>Lee,focusEventsPluginKey:()=>Pee});var dr=class Eee extends wL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Eee(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Aee=dr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Fr({key:new ki("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,s=Math.min(...a.map(d=>d.$from.pos)),l=Math.max(...a.map(d=>d.$to.pos)),c=yee(n);return bee(r,{from:s,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Tee=dr.create({name:"commands",addCommands(){return{...oee}}}),Nee=dr.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const a=()=>{var s,l,c,u;if((u=(c=(l=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:l.filterTransaction)==null?void 0:c.call(l,t))!=null?u:t.getMeta("y-sync$"))return;const d=mee(t.before,[t,...e]);_ee(d).forEach(p=>{d.mapping.mapResult(p.oldRange.from).deletedAfter&&d.mapping.mapResult(p.oldRange.to).deletedBefore&&d.before.nodesBetween(p.oldRange.from,p.oldRange.to,(x,v)=>{const y=v+x.nodeSize-2,b=p.oldRange.from<=v&&y<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:v,to:y,newFrom:d.mapping.map(v),newTo:d.mapping.map(y),deletedRange:p.oldRange,newRange:p.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:d})})});const g=d.mapping;d.steps.forEach((p,x)=>{var v,y;if(p instanceof zo){const b=g.slice(x).map(p.from,-1),E=g.slice(x).map(p.to),w=g.invert().map(b,-1),A=g.invert().map(E),T=(v=d.doc.nodeAt(b-1))==null?void 0:v.marks.some(N=>N.eq(p.mark)),C=(y=d.doc.nodeAt(E))==null?void 0:y.marks.some(N=>N.eq(p.mark));this.editor.emit("delete",{type:"mark",mark:p.mark,from:p.from,to:p.to,deletedRange:{from:w,to:A},newRange:{from:b,to:E},partial:!!(C||T),editor:this.editor,transaction:t,combinedTransform:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(a,0):a()}}),Cee=dr.create({name:"drop",addProseMirrorPlugins(){return[new Fr({key:new ki("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),kee=dr.create({name:"editable",addProseMirrorPlugins(){return[new Fr({key:new ki("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Pee=new ki("focusEvents"),jee=dr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Fr({key:Pee,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Ree=dr.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{const{selection:c,doc:u}=l,{empty:d,$anchor:f}=c,{pos:g,parent:p}=f,x=f.parent.isTextblock&&g>0?l.doc.resolve(g-1):f,v=x.parent.type.spec.isolating,y=f.pos-f.parentOffset,b=v&&x.parent.childCount===1?y===f.pos:mn.atStart(u).from===g;return!d||!p.type.isTextblock||p.textContent.length||!b||b&&f.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},a={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return xL()||hee()?a:i},addProseMirrorPlugins(){return[new Fr({key:new ki("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(v=>v.getMeta("composition")))return;const r=t.some(v=>v.docChanged)&&!e.doc.eq(n.doc),i=t.some(v=>v.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:s,to:l}=e.selection,c=mn.atStart(e.doc).from,u=mn.atEnd(e.doc).to;if(a||!(s===c&&l===u)||!vE(n.doc))return;const g=n.tr,p=gE({state:n,transaction:g}),{commands:x}=new xE({editor:this.editor,state:p});if(x.clearNodes(),!!g.steps.length)return g}})]}}),Dee=dr.create({name:"paste",addProseMirrorPlugins(){return[new Fr({key:new ki("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Oee=dr.create({name:"tabindex",addProseMirrorPlugins(){return[new Fr({key:new ki("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Lee=dr.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Zp(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Fr({key:new ki("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),s$e=class np{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new np(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new np(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new np(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,s=this.pos+r+(a?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(s);if(!i&&l.depth<=this.depth)return;const c=new np(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new np(l,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const a=i.node.attrs,s=Object.keys(n);for(let l=0;l<s.length;l+=1){const c=s[l];if(a[c]!==n[c])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const a=Object.keys(n);return this.children.forEach(s=>{r&&i.length>0||(s.node.type.name===e&&a.every(c=>n[c]===s.node.attrs[c])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},o$e=`.ProseMirror {
- position: relative;
- }
- .ProseMirror {
- word-wrap: break-word;
- white-space: pre-wrap;
- white-space: break-spaces;
- -webkit-font-variant-ligatures: none;
- font-variant-ligatures: none;
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
- }
- .ProseMirror [contenteditable="false"] {
- white-space: normal;
- }
- .ProseMirror [contenteditable="false"] [contenteditable="true"] {
- white-space: pre-wrap;
- }
- .ProseMirror pre {
- white-space: pre-wrap;
- }
- img.ProseMirror-separator {
- display: inline !important;
- border: none !important;
- margin: 0 !important;
- width: 0 !important;
- height: 0 !important;
- }
- .ProseMirror-gapcursor {
- display: none;
- pointer-events: none;
- position: absolute;
- margin: 0;
- }
- .ProseMirror-gapcursor:after {
- content: "";
- display: block;
- position: absolute;
- top: -2px;
- width: 20px;
- border-top: 1px solid black;
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
- }
- @keyframes ProseMirror-cursor-blink {
- to {
- visibility: hidden;
- }
- }
- .ProseMirror-hideselection *::selection {
- background: transparent;
- }
- .ProseMirror-hideselection *::-moz-selection {
- background: transparent;
- }
- .ProseMirror-hideselection * {
- caret-color: transparent;
- }
- .ProseMirror-focused .ProseMirror-gapcursor {
- display: block;
- }`;function l$e(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}var c$e=class extends XHe{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:a})=>this.options.onDrop(r,i,a)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=uee(e,this.options.autofocus);this.editorState=up.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=l$e(o$e,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=pee(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const a=typeof i=="string"?`${i}$`:i.key;n=n.filter(s=>!s.key.startsWith(a))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[kee,Aee.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Tee,jee,Ree,Oee,Cee,Dee,Nee,Lee.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i?.type));this.extensionManager=new wE(r,this)}createCommandManager(){this.commandManager=new xE({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Tj(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=Tj(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new aee(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),a=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const s=n.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),l=s?.getMeta("focus"),c=s?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:s}),c&&this.emit("blur",{editor:this,event:c.event,transaction:s}),!(t.getMeta("preventUpdate")||!n.some(u=>u.docChanged)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return vee(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return EHe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return yL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return yHe(this.state.doc,{blockSeparator:e,textSerializers:{...yee(this.schema),...n}})}get isEmpty(){return vE(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new s$e(e,this)}get $doc(){return this.$pos(0)}};function Qp(t){return new _E({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Xn(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:a}=e,s=r[r.length-1],l=r[0];if(s){const c=l.search(/\S/),u=n.from+l.indexOf(s),d=u+s.length;if(_L(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===t.type&&v!==p.mark.type)).filter(p=>p.to>u).length)return null;d<n.to&&a.delete(d,n.to),u>n.from&&a.delete(n.from+c,u);const g=n.from+c+s.length;a.addMark(n.from+c,g,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function Iee(t){return new _E({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Xn(t.getAttributes,void 0,r)||{},{tr:a}=e,s=n.from;let l=n.to;const c=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=s+u;d>l?d=l:l=d+r[1].length;const f=r[0][r[0].length-1];a.insertText(f,s+r[0].length-1),a.replaceWith(d,l,c)}else if(r[0]){const u=t.type.isInline?s:s-1;a.insert(u,t.type.create(i)).delete(a.mapping.map(s),a.mapping.map(l))}a.scrollIntoView()},undoable:t.undoable})}function Cj(t){return new _E({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=Xn(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,a)},undoable:t.undoable})}function Jp(t){return new _E({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=Xn(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),c=s.doc.resolve(n.from).blockRange(),u=c&&QO(c,t.type,a);if(!u)return null;if(s.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:g}=e,{splittableMarks:p}=t.editor.extensionManager,x=g||f.$to.parentOffset&&f.$from.marks();if(x){const v=x.filter(y=>p.includes(y.type.name));s.ensureMarks(v)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,a).run()}const d=s.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&Od(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&s.join(n.from-1)},undoable:t.undoable})}var u$e=t=>"touches"in t,d$e=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=s=>{if(!this.isResizing||!this.activeHandle)return;const l=s.clientX-this.startX,c=s.clientY-this.startY;this.handleResize(l,c)},this.handleTouchMove=s=>{if(!this.isResizing||!this.activeHandle)return;const l=s.touches[0];if(!l)return;const c=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const s=this.element.offsetWidth,l=this.element.offsetHeight;this.onCommit(s,l),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=s=>{s.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=s=>{s.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,a;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(a=t.options)!=null&&a.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),a&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,u$e(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const a=t.includes("right"),s=t.includes("left"),l=t.includes("bottom"),c=t.includes("top");return a?r=this.startWidth+e:s&&(r=this.startWidth-e),l?i=this.startHeight+n:c&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(a?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,a,s;if(!n){let u=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(u=Math.min(this.maxSize.width,u)),(i=this.maxSize)!=null&&i.height&&(d=Math.min(this.maxSize.height,d)),{width:u,height:d}}let l=t,c=e;return l<this.minSize.width&&(l=this.minSize.width,c=l/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,l=c*this.aspectRatio),(a=this.maxSize)!=null&&a.width&&l>this.maxSize.width&&(l=this.maxSize.width,c=l/this.aspectRatio),(s=this.maxSize)!=null&&s.height&&c>this.maxSize.height&&(c=this.maxSize.height,l=c*this.aspectRatio),{width:l,height:c}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function h$e(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof qt){const a=r.index();return r.parent.canReplaceWith(a,a+1,e)}let i=r.depth;for(;i>=0;){const a=r.index(i);if(r.node(i).contentMatchAt(a).matchType(e))return!0;i-=1}return!1}var f$e={};mL(f$e,{createAtomBlockMarkdownSpec:()=>m$e,createBlockMarkdownSpec:()=>p$e,createInlineMarkdownSpec:()=>b$e,parseAttributes:()=>SL,parseIndentedBlocks:()=>kj,renderNestedMarkdownContent:()=>EL,serializeAttributes:()=>ML});function SL(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const s=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(s)).forEach(([,u,d])=>{var f;const g=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),p=n[g];p&&(e[u]=p.slice(1,-1))});const c=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function ML(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function m$e(t){const{nodeName:e,name:n,parseAttributes:r=SL,serializeAttributes:i=ML,defaultAttributes:a={},requiredAttributes:s=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(g=>{g in d&&(f[g]=d[g])}),f};return{parseMarkdown:(d,f)=>{const g={...a,...d.attributes};return f.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const g=new RegExp(`^:::${c}(?:\\s|$)`,"m"),p=(f=d.match(g))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(d,f,g){const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(p);if(!x)return;const v=x[1]||"",y=r(v);if(!s.find(E=>!(E in y)))return{type:e,raw:x[0],attributes:y}}},renderMarkdown:d=>{const f=u(d.attrs||{}),g=i(f),p=g?` {${g}}`:"";return`:::${c}${p} :::`}}}function p$e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=SL,serializeAttributes:a=ML,defaultAttributes:s={},content:l="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const g={};return c.forEach(p=>{p in f&&(g[p]=f[p])}),g};return{parseMarkdown:(f,g)=>{let p;if(r){const v=r(f);p=typeof v=="string"?[{type:"text",text:v}]:v}else l==="block"?p=g.parseChildren(f.tokens||[]):p=g.parseInline(f.tokens||[]);const x={...s,...f.attributes};return g.createNode(e,x,p)},markdownTokenizer:{name:e,level:"block",start(f){var g;const p=new RegExp(`^:::${u}`,"m"),x=(g=f.match(p))==null?void 0:g.index;return x!==void 0?x:-1},tokenize(f,g,p){var x;const v=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=f.match(v);if(!y)return;const[b,E=""]=y,w=i(E);let A=1;const T=b.length;let C="";const N=/^:::([\w-]*)(\s.*)?/gm,O=f.slice(T);for(N.lastIndex=0;;){const k=N.exec(O);if(k===null)break;const j=k.index,B=k[1];if(!((x=k[2])!=null&&x.endsWith(":::"))){if(B)A+=1;else if(A-=1,A===0){const L=O.slice(0,j);C=L.trim();const K=f.slice(0,T+j+k[0].length);let R=[];if(C)if(l==="block")for(R=p.blockTokens(L),R.forEach(q=>{q.text&&(!q.tokens||q.tokens.length===0)&&(q.tokens=p.inlineTokens(q.text))});R.length>0;){const q=R[R.length-1];if(q.type==="paragraph"&&(!q.text||q.text.trim()===""))R.pop();else break}else R=p.inlineTokens(C);return{type:e,raw:K,attributes:w,content:C,tokens:R}}}}}},renderMarkdown:(f,g)=>{const p=d(f.attrs||{}),x=a(p),v=x?` {${x}}`:"",y=g.renderChildren(f.content||[],`
- `);return`:::${u}${v}
- ${y}
- :::`}}}function g$e(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,s]=r;e[i]=a||s,r=n.exec(t)}return e}function x$e(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function b$e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=g$e,serializeAttributes:a=x$e,defaultAttributes:s={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=g=>{if(!c)return g;const p={};return c.forEach(x=>{x in g&&(p[x]=g[x])}),p},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,p)=>{const x={...s,...g.attributes};if(l)return p.createNode(e,x);const v=r?r(g):g.content||"";return v?p.createNode(e,x,[p.createTextNode(v)]):p.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(g){const p=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),x=g.match(p),v=x?.index;return v!==void 0?v:-1},tokenize(g,p,x){const v=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),y=g.match(v);if(!y)return;let b="",E="";if(l){const[,A]=y;E=A}else{const[,A,T]=y;E=A,b=T||""}const w=i(E.trim());return{type:e,raw:y[0],content:b.trim(),attributes:w}}},renderMarkdown:g=>{let p="";r?p=r(g):g.content&&g.content.length>0&&(p=g.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const x=d(g.attrs||{}),v=a(x),y=v?` ${v}`:"";return l?`[${u}${y}]`:`[${u}${y}]${p}[/${u}]`}}}function kj(t,e,n){var r,i,a,s;const l=t.split(`
- `),c=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<l.length;){const g=l[d],p=g.match(e.itemPattern);if(!p){if(c.length>0)break;if(g.trim()===""){d+=1,u=`${u}${g}
- `;continue}else return}const x=e.extractItemData(p),{indentLevel:v,mainContent:y}=x;u=`${u}${g}
- `;const b=[y];for(d+=1;d<l.length;){const T=l[d];if(T.trim()===""){const N=l.slice(d+1).findIndex(j=>j.trim()!=="");if(N===-1)break;if((((i=(r=l[d+1+N].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>v){b.push(T),u=`${u}${T}
- `,d+=1;continue}else break}if((((s=(a=T.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:s.length)||0)>v)b.push(T),u=`${u}${T}
- `,d+=1;else break}let E;const w=b.slice(1);if(w.length>0){const T=w.map(C=>C.slice(v+f)).join(`
- `);T.trim()&&(e.customNestedParser?E=e.customNestedParser(T):E=n.blockTokens(T))}const A=e.createToken(x,E);c.push(A)}if(c.length!==0)return{items:c,raw:u}}function EL(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...s]=t.content,l=e.renderChildren([a]),c=[`${i}${l}`];return s&&s.length>0&&s.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
- `).map(g=>g?e.indent(g):"").join(`
- `);c.push(f)}}),c.join(`
- `)}function y$e(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,s=t;i.descendants((l,c)=>{const u=a.mapping.map(c),d=a.mapping.map(c)+l.nodeSize;let f=null;if(l.marks.forEach(p=>{if(p!==s)return!1;f=p}),!f)return;let g=!1;if(Object.keys(n).forEach(p=>{n[p]!==f.attrs[p]&&(g=!0)}),g){const p=t.type.create({...t.attrs,...n});a.removeMark(u,d,t.type),a.addMark(u,d,p)}}),a.docChanged&&e.view.dispatch(a)}var cs=class Fee extends wL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Fee(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Mf(t){return new e$e({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=Xn(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:s}=e,l=r[r.length-1],c=r[0];let u=n.to;if(l){const d=c.search(/\S/),f=n.from+c.indexOf(l),g=f+l.length;if(_L(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(y=>y===t.type&&y!==x.mark.type)).filter(x=>x.to>f).length)return null;g<n.to&&s.delete(g,n.to),f>n.from&&s.delete(n.from+d,f),u=n.from+d+l.length,s.addMark(n.from+d,u,t.type.create(a||{})),s.removeStoredMark(t.type)}}})}var gk,yG;function v$e(){return yG||(yG=1,gk=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(a=Object.keys(e),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var s=a[i];if(!(s==="_owner"&&e.$$typeof)&&!t(e[s],n[s]))return!1}return!0}return e!==e&&n!==n}),gk}var _$e=v$e();const w$e=yo(_$e);var S$e=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},M$e=({contentComponent:t})=>{const e=Zj.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return o.jsx(o.Fragment,{children:Object.values(e)})};function E$e(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:Fse.createPortal(r.reactElement,r.element,n)},t.forEach(i=>i())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(i=>i())}}}var A$e=class extends Cr.Component{constructor(t){var e;super(t),this.editorContentRef=Cr.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(t.view.dom),t.setOptions({element:e}),t.contentComponent=E$e(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:S$e(e,this.editorContentRef),...n}),t?.contentComponent&&o.jsx(M$e,{contentComponent:t.contentComponent})]})}},T$e=S.forwardRef((t,e)=>{const n=Cr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Cr.createElement(A$e,{key:n,innerRef:e,...t})}),N$e=Cr.memo(T$e),C$e=typeof window<"u"?S.useLayoutEffect:S.useEffect,k$e=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function P$e(t){var e;const[n]=S.useState(()=>new k$e(t.editor)),r=LW.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:w$e);return C$e(()=>n.watch(t.editor),[t.editor,n]),S.useDebugValue(r),r}var j$e=!1,Pj=typeof window>"u",R$e=Pj||!!(typeof window<"u"&&window.next),D$e=class Uee{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?Pj||R$e?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onBeforeCreate)==null?void 0:a.call(i,...r)},onBlur:(...r)=>{var i,a;return(a=(i=this.options.current).onBlur)==null?void 0:a.call(i,...r)},onCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onCreate)==null?void 0:a.call(i,...r)},onDestroy:(...r)=>{var i,a;return(a=(i=this.options.current).onDestroy)==null?void 0:a.call(i,...r)},onFocus:(...r)=>{var i,a;return(a=(i=this.options.current).onFocus)==null?void 0:a.call(i,...r)},onSelectionUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onSelectionUpdate)==null?void 0:a.call(i,...r)},onTransaction:(...r)=>{var i,a;return(a=(i=this.options.current).onTransaction)==null?void 0:a.call(i,...r)},onUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onUpdate)==null?void 0:a.call(i,...r)},onContentError:(...r)=>{var i,a;return(a=(i=this.options.current).onContentError)==null?void 0:a.call(i,...r)},onDrop:(...r)=>{var i,a;return(a=(i=this.options.current).onDrop)==null?void 0:a.call(i,...r)},onPaste:(...r)=>{var i,a;return(a=(i=this.options.current).onPaste)==null?void 0:a.call(i,...r)},onDelete:(...r)=>{var i,a;return(a=(i=this.options.current).onDelete)==null?void 0:a.call(i,...r)}};return new c$e(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,a)=>{var s;return i===((s=n.extensions)==null?void 0:s[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Uee.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,i)=>r===e[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function O$e(t={},e=[]){const n=S.useRef(t);n.current=t;const[r]=S.useState(()=>new D$e(n)),i=Zj.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return S.useDebugValue(i),S.useEffect(r.onRender(e)),P$e({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var L$e=S.createContext({editor:null});L$e.Consumer;var I$e=S.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),F$e=()=>S.useContext(I$e);Cr.forwardRef((t,e)=>{const{onDragStart:n}=F$e(),r=t.as||"div";return o.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Cr.createContext({markViewContentRef:()=>{}});var pS=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},U$e=/^\s*>\s$/,z$e=cs.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return pS("blockquote",{...Wr(this.options.HTMLAttributes,t),children:pS("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const l=e.renderChildren([i]).split(`
- `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
- `))}),r.join(`
- ${n}
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Jp({find:U$e,type:this.type})]}}),B$e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,H$e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,$$e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,V$e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,G$e=Id.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return pS("strong",{...Wr(this.options.HTMLAttributes,t),children:pS("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Qp({find:B$e,type:this.type}),Qp({find:$$e,type:this.type})]},addPasteRules(){return[Mf({find:H$e,type:this.type}),Mf({find:V$e,type:this.type})]}}),W$e=/(^|[^`])`([^`]+)`(?!`)$/,q$e=/(^|[^`])`([^`]+)`(?!`)/g,K$e=Id.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Wr(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Qp({find:W$e,type:this.type})]},addPasteRules(){return[Mf({find:q$e,type:this.type})]}}),xk=4,X$e=/^```([a-z]+)?[\s\n]$/,Y$e=/^~~~([a-z]+)?[\s\n]$/,Z$e=cs.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:xk,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const a=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Wr(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
- `):r=`\`\`\`${i}
- \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:xk,{state:r}=t,{selection:i}=r,{$from:a,empty:s}=i;if(a.parent.type!==this.type)return!1;const l=" ".repeat(n);return s?t.commands.insertContent(l):t.commands.command(({tr:c})=>{const{from:u,to:d}=i,p=r.doc.textBetween(u,d,`
- `,`
- `).split(`
- `).map(x=>l+x).join(`
- `);return c.replaceWith(u,d,r.schema.text(p)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:xk,{state:r}=t,{selection:i}=r,{$from:a,empty:s}=i;return a.parent.type!==this.type?!1:s?t.commands.command(({tr:l})=>{var c;const{pos:u}=a,d=a.start(),f=a.end(),p=r.doc.textBetween(d,f,`
- `,`
- `).split(`
- `);let x=0,v=0;const y=u-d;for(let C=0;C<p.length;C+=1){if(v+p[C].length>=y){x=C;break}v+=p[C].length+1}const E=((c=p[x].match(/^ */))==null?void 0:c[0])||"",w=Math.min(E.length,n);if(w===0)return!0;let A=d;for(let C=0;C<x;C+=1)A+=p[C].length+1;return l.delete(A,A+w),u-A<=w&&l.setSelection(Qt.create(l.doc,A)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,g=r.doc.textBetween(c,u,`
- `,`
- `).split(`
- `).map(p=>{var x;const v=((x=p.match(/^ */))==null?void 0:x[0])||"",y=Math.min(v.length,n);return p.slice(y)}).join(`
- `);return l.replaceWith(c,u,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const a=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
- `);return!a||!s?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:u})=>(u.setSelection(mn.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[Cj({find:X$e,type:this.type,getAttributes:t=>({language:t[1]})}),Cj({find:Y$e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Fr({key:new ki("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,a=i?.mode;if(!n||!a)return!1;const{tr:s,schema:l}=t.state,c=l.text(n.replace(/\r\n?/g,`
- `));return s.replaceSelectionWith(this.type.create({language:a},c)),s.selection.$from.parent.type!==this.type&&s.setSelection(Qt.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),Q$e=cs.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),J$e=cs.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Wr(this.options.HTMLAttributes,t)]},renderText(){return`
- `},renderMarkdown:()=>`
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,c=a||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&s){const f=c.filter(g=>l.includes(g.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),eVe=cs.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Wr(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,i="#".repeat(r);return t.content?`${i} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Cj({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),tVe=cs.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Wr(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!h$e(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return wee(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:a,tr:s,dispatch:l})=>{if(l){const{$to:c}=s.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(Qt.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(qt.create(s.doc,c.pos)):s.setSelection(Qt.create(s.doc,c.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=d?.create();f&&(s.insert(u,f),s.setSelection(Qt.create(s.doc,u+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Iee({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),nVe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,rVe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,iVe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,aVe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,sVe=Id.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Wr(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Qp({find:nVe,type:this.type}),Qp({find:iVe,type:this.type})]},addPasteRules(){return[Mf({find:rVe,type:this.type}),Mf({find:aVe,type:this.type})]}});const oVe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",lVe="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",jj="numeric",Rj="ascii",Dj="alpha",y0="asciinumeric",n0="alphanumeric",Oj="domain",zee="emoji",cVe="scheme",uVe="slashscheme",bk="whitespace";function dVe(t,e){return t in e||(e[t]=[]),e[t]}function Rh(t,e,n){e[jj]&&(e[y0]=!0,e[n0]=!0),e[Rj]&&(e[y0]=!0,e[Dj]=!0),e[y0]&&(e[n0]=!0),e[Dj]&&(e[n0]=!0),e[n0]&&(e[Oj]=!0),e[zee]&&(e[Oj]=!0);for(const r in e){const i=dVe(r,n);i.indexOf(t)<0&&i.push(t)}}function hVe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ja(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ja.groups={};Ja.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],a=e.jr[r][1];if(a&&i.test(t))return a}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||Ja.groups;let i;return e&&e.j?i=e:(i=new Ja(e),n&&r&&Rh(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const a=t.length;if(!a)return i;for(let s=0;s<a-1;s++)i=i.tt(t[s]);return i.tt(t[a-1],e,n,r)},tt(t,e,n,r){r=r||Ja.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const a=e;let s,l=i.go(t);if(l?(s=new Ja,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new Ja,a){if(r)if(s.t&&typeof s.t=="string"){const c=Object.assign(hVe(s.t,r),n);Rh(a,c,r)}else n&&Rh(a,n,r);s.t=a}return i.j[t]=s,s}};const un=(t,e,n,r,i)=>t.ta(e,n,r,i),Hr=(t,e,n,r,i)=>t.tr(e,n,r,i),vG=(t,e,n,r,i)=>t.ts(e,n,r,i),St=(t,e,n,r,i)=>t.tt(e,n,r,i),xc="WORD",Lj="UWORD",Bee="ASCIINUMERICAL",Hee="ALPHANUMERICAL",xb="LOCALHOST",Ij="TLD",Fj="UTLD",j1="SCHEME",rp="SLASH_SCHEME",AL="NUM",Uj="WS",TL="NL",v0="OPENBRACE",_0="CLOSEBRACE",gS="OPENBRACKET",xS="CLOSEBRACKET",bS="OPENPAREN",yS="CLOSEPAREN",vS="OPENANGLEBRACKET",_S="CLOSEANGLEBRACKET",wS="FULLWIDTHLEFTPAREN",SS="FULLWIDTHRIGHTPAREN",MS="LEFTCORNERBRACKET",ES="RIGHTCORNERBRACKET",AS="LEFTWHITECORNERBRACKET",TS="RIGHTWHITECORNERBRACKET",NS="FULLWIDTHLESSTHAN",CS="FULLWIDTHGREATERTHAN",kS="AMPERSAND",PS="APOSTROPHE",jS="ASTERISK",Wu="AT",RS="BACKSLASH",DS="BACKTICK",OS="CARET",Qu="COLON",NL="COMMA",LS="DOLLAR",sl="DOT",IS="EQUALS",CL="EXCLAMATION",Ys="HYPHEN",w0="PERCENT",FS="PIPE",US="PLUS",zS="POUND",S0="QUERY",kL="QUOTE",$ee="FULLWIDTHMIDDLEDOT",PL="SEMI",ol="SLASH",M0="TILDE",BS="UNDERSCORE",Vee="EMOJI",HS="SYM";var Gee=Object.freeze({__proto__:null,ALPHANUMERICAL:Hee,AMPERSAND:kS,APOSTROPHE:PS,ASCIINUMERICAL:Bee,ASTERISK:jS,AT:Wu,BACKSLASH:RS,BACKTICK:DS,CARET:OS,CLOSEANGLEBRACKET:_S,CLOSEBRACE:_0,CLOSEBRACKET:xS,CLOSEPAREN:yS,COLON:Qu,COMMA:NL,DOLLAR:LS,DOT:sl,EMOJI:Vee,EQUALS:IS,EXCLAMATION:CL,FULLWIDTHGREATERTHAN:CS,FULLWIDTHLEFTPAREN:wS,FULLWIDTHLESSTHAN:NS,FULLWIDTHMIDDLEDOT:$ee,FULLWIDTHRIGHTPAREN:SS,HYPHEN:Ys,LEFTCORNERBRACKET:MS,LEFTWHITECORNERBRACKET:AS,LOCALHOST:xb,NL:TL,NUM:AL,OPENANGLEBRACKET:vS,OPENBRACE:v0,OPENBRACKET:gS,OPENPAREN:bS,PERCENT:w0,PIPE:FS,PLUS:US,POUND:zS,QUERY:S0,QUOTE:kL,RIGHTCORNERBRACKET:ES,RIGHTWHITECORNERBRACKET:TS,SCHEME:j1,SEMI:PL,SLASH:ol,SLASH_SCHEME:rp,SYM:HS,TILDE:M0,TLD:Ij,UNDERSCORE:BS,UTLD:Fj,UWORD:Lj,WORD:xc,WS:Uj});const fc=/[a-z]/,$x=new RegExp("\\p{L}","u"),yk=new RegExp("\\p{Emoji}","u"),mc=/\d/,vk=/\s/,_G="\r",_k=`
- `,fVe="️",mVe="",wk="";let t1=null,n1=null;function pVe(t=[]){const e={};Ja.groups=e;const n=new Ja;t1==null&&(t1=wG(oVe)),n1==null&&(n1=wG(lVe)),St(n,"'",PS),St(n,"{",v0),St(n,"}",_0),St(n,"[",gS),St(n,"]",xS),St(n,"(",bS),St(n,")",yS),St(n,"<",vS),St(n,">",_S),St(n,"(",wS),St(n,")",SS),St(n,"「",MS),St(n,"」",ES),St(n,"『",AS),St(n,"』",TS),St(n,"<",NS),St(n,">",CS),St(n,"&",kS),St(n,"*",jS),St(n,"@",Wu),St(n,"`",DS),St(n,"^",OS),St(n,":",Qu),St(n,",",NL),St(n,"$",LS),St(n,".",sl),St(n,"=",IS),St(n,"!",CL),St(n,"-",Ys),St(n,"%",w0),St(n,"|",FS),St(n,"+",US),St(n,"#",zS),St(n,"?",S0),St(n,'"',kL),St(n,"/",ol),St(n,";",PL),St(n,"~",M0),St(n,"_",BS),St(n,"\\",RS),St(n,"・",$ee);const r=Hr(n,mc,AL,{[jj]:!0});Hr(r,mc,r);const i=Hr(r,fc,Bee,{[y0]:!0}),a=Hr(r,$x,Hee,{[n0]:!0}),s=Hr(n,fc,xc,{[Rj]:!0});Hr(s,mc,i),Hr(s,fc,s),Hr(i,mc,i),Hr(i,fc,i);const l=Hr(n,$x,Lj,{[Dj]:!0});Hr(l,fc),Hr(l,mc,a),Hr(l,$x,l),Hr(a,mc,a),Hr(a,fc),Hr(a,$x,a);const c=St(n,_k,TL,{[bk]:!0}),u=St(n,_G,Uj,{[bk]:!0}),d=Hr(n,vk,Uj,{[bk]:!0});St(n,wk,d),St(u,_k,c),St(u,wk,d),Hr(u,vk,d),St(d,_G),St(d,_k),Hr(d,vk,d),St(d,wk,d);const f=Hr(n,yk,Vee,{[zee]:!0});St(f,"#"),Hr(f,yk,f),St(f,fVe,f);const g=St(f,mVe);St(g,"#"),Hr(g,yk,f);const p=[[fc,s],[mc,i]],x=[[fc,null],[$x,l],[mc,a]];for(let v=0;v<t1.length;v++)Uu(n,t1[v],Ij,xc,p);for(let v=0;v<n1.length;v++)Uu(n,n1[v],Fj,Lj,x);Rh(Ij,{tld:!0,ascii:!0},e),Rh(Fj,{utld:!0,alpha:!0},e),Uu(n,"file",j1,xc,p),Uu(n,"mailto",j1,xc,p),Uu(n,"http",rp,xc,p),Uu(n,"https",rp,xc,p),Uu(n,"ftp",rp,xc,p),Uu(n,"ftps",rp,xc,p),Rh(j1,{scheme:!0,ascii:!0},e),Rh(rp,{slashscheme:!0,ascii:!0},e),t=t.sort((v,y)=>v[0]>y[0]?1:-1);for(let v=0;v<t.length;v++){const y=t[v][0],E=t[v][1]?{[cVe]:!0}:{[uVe]:!0};y.indexOf("-")>=0?E[Oj]=!0:fc.test(y)?mc.test(y)?E[y0]=!0:E[Rj]=!0:E[jj]=!0,vG(n,y,y,E)}return vG(n,"localhost",xb,{ascii:!0}),n.jd=new Ja(HS),{start:n,tokens:Object.assign({groups:e},Gee)}}function Wee(t,e){const n=gVe(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let a=0,s=0;for(;s<r;){let l=t,c=null,u=0,d=null,f=-1,g=-1;for(;s<r&&(c=l.go(n[s]));)l=c,l.accepts()?(f=0,g=0,d=l):f>=0&&(f+=n[s].length,g++),u+=n[s].length,a+=n[s].length,s++;a-=f,s-=g,u-=f,i.push({t:d.t,v:e.slice(a-u,a),s:a-u,e:a})}return i}function gVe(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),a,s=i<55296||i>56319||r+1===n||(a=t.charCodeAt(r+1))<56320||a>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function Uu(t,e,n,r,i){let a;const s=e.length;for(let l=0;l<s-1;l++){const c=e[l];t.j[c]?a=t.j[c]:(a=new Ja(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new Ja(n),a.jr=i.slice(),t.j[e[s-1]]=a,a}function wG(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let a=0;for(;i.indexOf(t[r+a])>=0;)a++;if(a>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+a),10);s>0;s--)n.pop();r+=a}else n.push(t[r]),r++}return e}const bb={defaultProtocol:"http",events:null,format:SG,formatHref:SG,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function jL(t,e=null){let n=Object.assign({},bb);t&&(n=Object.assign(n,t instanceof jL?t.o:t));const r=n.ignoreTags,i=[];for(let a=0;a<r.length;a++)i.push(r[a].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}jL.prototype={o:bb,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let i=this.o[t];return i&&(typeof i=="object"?(i=n.t in i?i[n.t]:bb[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function SG(t){return t}function qee(t,e){this.t="token",this.v=t,this.tk=e}qee.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=bb.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),a=this.toFormattedString(t),s={},l=t.get("className",n,e),c=t.get("target",n,e),u=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return s.href=r,l&&(s.class=l),c&&(s.target=c),u&&(s.rel=u),d&&Object.assign(s,d),{tagName:i,attributes:s,content:a,eventListeners:f}}};function SE(t,e){class n extends qee{constructor(i,a){super(i,a),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const MG=SE("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),EG=SE("text"),xVe=SE("nl"),r1=SE("url",{isLink:!0,toHref(t=bb.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==xb&&t[1].t===Qu}}),qs=t=>new Ja(t);function bVe({groups:t}){const e=t.domain.concat([kS,jS,Wu,RS,DS,OS,LS,IS,Ys,AL,w0,FS,US,zS,ol,HS,M0,BS]),n=[PS,Qu,NL,sl,CL,w0,S0,kL,PL,vS,_S,v0,_0,xS,gS,bS,yS,wS,SS,MS,ES,AS,TS,NS,CS],r=[kS,PS,jS,RS,DS,OS,LS,IS,Ys,v0,_0,w0,FS,US,zS,S0,ol,HS,M0,BS],i=qs(),a=St(i,M0);un(a,r,a),un(a,t.domain,a);const s=qs(),l=qs(),c=qs();un(i,t.domain,s),un(i,t.scheme,l),un(i,t.slashscheme,c),un(s,r,a),un(s,t.domain,s);const u=St(s,Wu);St(a,Wu,u),St(l,Wu,u),St(c,Wu,u);const d=St(a,sl);un(d,r,a),un(d,t.domain,a);const f=qs();un(u,t.domain,f),un(f,t.domain,f);const g=St(f,sl);un(g,t.domain,f);const p=qs(MG);un(g,t.tld,p),un(g,t.utld,p),St(u,xb,p);const x=St(f,Ys);St(x,Ys,x),un(x,t.domain,f),un(p,t.domain,f),St(p,sl,g),St(p,Ys,x);const v=St(p,Qu);un(v,t.numeric,MG);const y=St(s,Ys),b=St(s,sl);St(y,Ys,y),un(y,t.domain,s),un(b,r,a),un(b,t.domain,s);const E=qs(r1);un(b,t.tld,E),un(b,t.utld,E),un(E,t.domain,s),un(E,r,a),St(E,sl,b),St(E,Ys,y),St(E,Wu,u);const w=St(E,Qu),A=qs(r1);un(w,t.numeric,A);const T=qs(r1),C=qs();un(T,e,T),un(T,n,C),un(C,e,T),un(C,n,C),St(E,ol,T),St(A,ol,T);const N=St(l,Qu),O=St(c,Qu),k=St(O,ol),j=St(k,ol);un(l,t.domain,s),St(l,sl,b),St(l,Ys,y),un(c,t.domain,s),St(c,sl,b),St(c,Ys,y),un(N,t.domain,T),St(N,ol,T),St(N,S0,T),un(j,t.domain,T),un(j,e,T),St(j,ol,T);const B=[[v0,_0],[gS,xS],[bS,yS],[vS,_S],[wS,SS],[MS,ES],[AS,TS],[NS,CS]];for(let L=0;L<B.length;L++){const[K,R]=B[L],q=St(T,K);St(C,K,q),St(q,R,T);const W=qs(r1);un(q,e,W);const $=qs();un(q,n),un(W,e,W),un(W,n,$),un($,e,W),un($,n,$),St(W,R,T),St($,R,T)}return St(i,xb,E),St(i,TL,xVe),{start:i,tokens:Gee}}function yVe(t,e,n){let r=n.length,i=0,a=[],s=[];for(;i<r;){let l=t,c=null,u=null,d=0,f=null,g=-1;for(;i<r&&!(c=l.go(n[i].t));)s.push(n[i++]);for(;i<r&&(u=c||l.go(n[i].t));)c=null,l=u,l.accepts()?(g=0,f=l):g>=0&&g++,i++,d++;if(g<0)i-=d,i<r&&(s.push(n[i]),i++);else{s.length>0&&(a.push(Sk(EG,e,s)),s=[]),i-=g,d-=g;const p=f.t,x=n.slice(i-d,i);a.push(Sk(p,e,x))}}return s.length>0&&a.push(Sk(EG,e,s)),a}function Sk(t,e,n){const r=n[0].s,i=n[n.length-1].e,a=e.slice(r,i);return new t(a,n)}const vVe=typeof console<"u"&&console&&console.warn||(()=>{}),_Ve="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Sr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function wVe(){return Ja.groups={},Sr.scanner=null,Sr.parser=null,Sr.tokenQueue=[],Sr.pluginQueue=[],Sr.customSchemes=[],Sr.initialized=!1,Sr}function AG(t,e=!1){if(Sr.initialized&&vVe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${_Ve}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
- 1. Must only contain digits, lowercase ASCII letters or "-"
- 2. Cannot start or end with "-"
- 3. "-" cannot repeat`);Sr.customSchemes.push([t,e])}function SVe(){Sr.scanner=pVe(Sr.customSchemes);for(let t=0;t<Sr.tokenQueue.length;t++)Sr.tokenQueue[t][1]({scanner:Sr.scanner});Sr.parser=bVe(Sr.scanner.tokens);for(let t=0;t<Sr.pluginQueue.length;t++)Sr.pluginQueue[t][1]({scanner:Sr.scanner,parser:Sr.parser});return Sr.initialized=!0,Sr}function RL(t){return Sr.initialized||SVe(),yVe(Sr.parser.start,t,Wee(Sr.scanner.start,t))}RL.scan=Wee;function Kee(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new jL(n),i=RL(t),a=[];for(let s=0;s<i.length;s++){const l=i[s];l.isLink&&(!e||l.t===e)&&r.check(l)&&a.push(l.toFormattedObject(r))}return a}var DL="[\0- -\u2029 ]",MVe=new RegExp(DL),EVe=new RegExp(`${DL}$`),AVe=new RegExp(DL,"g");function TVe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function NVe(t){return new Fr({key:new ki("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),a=e.some(u=>u.getMeta("preventAutolink"));if(!i||a)return;const{tr:s}=r,l=mee(n.doc,[...e]);if(_ee(l).forEach(({newRange:u})=>{const d=fHe(r.doc,u,p=>p.isTextblock);let f,g;if(d.length>1)f=d[0],g=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const p=r.doc.textBetween(u.from,u.to," "," ");if(!EVe.test(p))return;f=d[0],g=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const p=g.split(MVe).filter(Boolean);if(p.length<=0)return!1;const x=p[p.length-1],v=f.pos+g.lastIndexOf(x);if(!x)return!1;const y=RL(x).map(b=>b.toObject(t.defaultProtocol));if(!TVe(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:v+b.start+1,to:v+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{_L(b.from,b.to,r.doc).some(E=>E.mark.type===t.type)||s.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!s.steps.length)return s}})}function CVe(t){return new Fr({key:new ki("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,a;if(r.button!==0||!e.editable)return!1;let s=null;if(r.target instanceof HTMLAnchorElement)s=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;s=f.find(g=>g.nodeName==="A")}if(!s)return!1;const l=vee(e.state,t.type.name),c=(i=s?.href)!=null?i:l.href,u=(a=s?.target)!=null?a:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),s&&c?(window.open(c,u),!0):!1}}})}function kVe(t){return new Fr({key:new ki("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:a}=e,{selection:s}=a,{empty:l}=s;if(l)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=Kee(c,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===c);return!c||!u||i!==void 0&&!i(u.href)?!1:t.editor.commands.setMark(t.type,{href:u.href})}}})}function dh(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(AVe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Xee=Id.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){AG(t);return}AG(t.scheme,t.optionalSlashes)})},onDestroy(){wVe()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!dh(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!dh(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!dh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Wr(this.options.HTMLAttributes,t),0]:["a",Wr(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!dh(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!dh(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Mf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Kee(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:s=>!!dh(s,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(a=>{this.options.shouldAutoLink(a.value)&&e.push({text:a.value,data:{href:a.href},index:a.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(NVe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!dh(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(CVe({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(kVe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),PVe=Xee,jVe=Object.defineProperty,RVe=(t,e)=>{for(var n in e)jVe(t,n,{get:e[n],enumerable:!0})},DVe="listItem",TG="textStyle",NG=/^\s*([-+*])\s$/,Yee=cs.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",Wr(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(DVe,this.editor.getAttributes(TG)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Jp({find:NG,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Jp({find:NG,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(TG),editor:this.editor})),[t]}}),Zee=cs.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Wr(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){const s=t.tokens.slice(1),l=e.parseChildren(s);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>EL(t,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),OVe={};RVe(OVe,{findListItemPos:()=>hy,getNextListDepth:()=>OL,handleBackspace:()=>zj,handleDelete:()=>Bj,hasListBefore:()=>Qee,hasListItemAfter:()=>LVe,hasListItemBefore:()=>Jee,listItemHasSubList:()=>ete,nextListIsDeeper:()=>tte,nextListIsHigher:()=>nte});var hy=(t,e)=>{const{$from:n}=e.selection,r=mi(t,e.schema);let i=null,a=n.depth,s=n.pos,l=null;for(;a>0&&l===null;)i=n.node(a),i.type===r?l=a:(a-=1,s-=1);return l===null?null:{$pos:e.doc.resolve(s),depth:l}},OL=(t,e)=>{const n=hy(t,e);if(!n)return!1;const[,r]=SHe(e,t,n.$pos.pos+4);return r},Qee=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),a=t.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},Jee=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((n=i.nodeBefore)==null?void 0:n.type.name)!==t)},ete=(t,e,n)=>{if(!n)return!1;const r=mi(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},zj=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Cd(t.state,e)&&Qee(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((g,p)=>{g.type.name===e&&u.push({node:g,pos:p})});const d=u.at(-1);if(!d)return!1;const f=t.state.doc.resolve(c.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},f.end()).joinForward().run()}if(!Cd(t.state,e)||!THe(t.state))return!1;const r=hy(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=ete(e,t.state,a);return Jee(e,t.state)&&!s?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},tte=(t,e)=>{const n=OL(t,e),r=hy(t,e);return!r||!n?!1:n>r.depth},nte=(t,e)=>{const n=OL(t,e),r=hy(t,e);return!r||!n?!1:n<r.depth},Bj=(t,e)=>{if(!Cd(t.state,e)||!AHe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:tte(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():nte(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},LVe=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((n=i.nodeAfter)==null?void 0:n.type.name)!==t)},rte=dr.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Bj(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Bj(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&zj(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&zj(t,n,r)&&(e=!0)}),e}}}}),CG=/^(\s*)(\d+)\.\s+(.*)$/,IVe=/^\s/;function FVe(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(CG);if(!a)break;const[,s,l,c]=a,u=s.length;let d=c,f=n+1;const g=[i];for(;f<t.length;){const p=t[f];if(p.match(CG))break;if(p.trim()==="")g.push(p),d+=`
- `,f+=1;else if(p.match(IVe))g.push(p),d+=`
- ${p.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:g.join(`
- `)}),r=f,n=f}return[e,r]}function ite(t,e,n){var r;const i=[];let a=0;for(;a<t.length;){const s=t[a];if(s.indent===e){const l=s.content.split(`
- `),c=((r=l[0])==null?void 0:r.trim())||"",u=[];c&&u.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const d=l.slice(1).join(`
- `).trim();if(d){const p=n.blockTokens(d);u.push(...p)}let f=a+1;const g=[];for(;f<t.length&&t[f].indent>e;)g.push(t[f]),f+=1;if(g.length>0){const p=Math.min(...g.map(v=>v.indent)),x=ite(g,p,n);u.push({type:"list",ordered:!0,start:g[0].number,items:x,raw:g.map(v=>v.raw).join(`
- `)})}i.push({type:"list_item",raw:s.raw,tokens:u}),a=f}else a+=1}return i}function UVe(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const a=e.parseChildren([i]);r.push({type:"paragraph",content:a})}else{const a=e.parseChildren([i]);a.length>0&&r.push(...a)}}),{type:"listItem",content:r}})}var zVe="listItem",kG="textStyle",PG=/^(\d+)\.\s$/,ate=cs.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",Wr(this.options.HTMLAttributes,n),0]:["ol",Wr(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?UVe(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(`
- `),[a,s]=FVe(i);if(a.length===0)return;const l=ite(a,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,s).join(`
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(zVe,this.editor.getAttributes(kG)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Jp({find:PG,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Jp({find:PG,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(kG)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),BVe=/^\s*(\[([( |x])?\])\s$/,HVe=cs.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Wr(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return EL(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),a=document.createElement("label"),s=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div"),u=d=>{var f,g;l.ariaLabel=((g=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:g.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),a.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const p=n();if(typeof p!="number")return!1;const x=g.doc.nodeAt(p);return g.setNodeMarkup(p,void 0,{...x?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,a.append(l,s),i.append(a,c),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)}),{dom:i,contentDOM:c,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[Jp({find:BVe,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),$Ve=cs.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Wr(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=a=>{const s=kj(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,c)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:c}),customNestedParser:r},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(a)},i=kj(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,s)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:s}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});dr.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Yee.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Zee.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(rte.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(ate.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(HVe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push($Ve.configure(this.options.taskList)),t}});var VVe=cs.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Wr(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),GVe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,WVe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,qVe=Id.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Wr(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Qp({find:GVe,type:this.type})]},addPasteRules(){return[Mf({find:WVe,type:this.type})]}}),KVe=cs.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),ste=Id.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Wr(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const a=i[2].trim();return{type:"underline",raw:i[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),XVe=ste;function YVe(t={}){return new Fr({view(e){return new ZVe(e,t)}})}class ZVe{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let a=s=>{this[i](s)};return e.dom.addEventListener(i,a),{name:i,handler:a}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,a=i.getBoundingClientRect(),s=a.width/i.offsetWidth,l=a.height/i.offsetHeight;if(n){let f=e.nodeBefore,g=e.nodeAfter;if(f||g){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let x=p.getBoundingClientRect(),v=f?x.bottom:x.top;f&&g&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:x.left,right:x.right,top:v-y,bottom:v+y}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*s;r={left:f.left-g,right:f.left+g,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=c.getBoundingClientRect(),g=f.width/c.offsetWidth,p=f.height/c.offsetHeight;u=f.left-c.scrollLeft*g,d=f.top-c.scrollTop*p}this.element.style.left=(r.left-u)/s+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=sJ(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Vr extends mn{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Vr.valid(r)?new Vr(r):mn.near(r)}content(){return Rt.empty}eq(e){return e instanceof Vr&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Vr(e.resolve(n.pos))}getBookmark(){return new LL(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!QVe(e)||!JVe(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Vr.valid(e))return e;let i=e.pos,a=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)<l.childCount:e.index(s)>0){a=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let c=e.doc.resolve(i);if(Vr.valid(c))return c}for(;;){let s=n>0?a.firstChild:a.lastChild;if(!s){if(a.isAtom&&!a.isText&&!qt.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=s,i+=n;let l=e.doc.resolve(i);if(Vr.valid(l))return l}return null}}}Vr.prototype.visible=!1;Vr.findFrom=Vr.findGapCursorFrom;mn.jsonID("gapcursor",Vr);class LL{constructor(e){this.pos=e}map(e){return new LL(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Vr.valid(n)?new Vr(n):mn.near(n)}}function ote(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function QVe(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||ote(i.type))return!0;if(i.inlineContent)return!1}}return!0}function JVe(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||ote(i.type))return!0;if(i.inlineContent)return!1}}return!0}function e7e(){return new Fr({props:{decorations:i7e,createSelectionBetween(t,e,n){return e.pos==n.pos&&Vr.valid(n)?new Vr(n):null},handleClick:n7e,handleKeyDown:t7e,handleDOMEvents:{beforeinput:r7e}}})}const t7e=see({ArrowLeft:i1("horiz",-1),ArrowRight:i1("horiz",1),ArrowUp:i1("vert",-1),ArrowDown:i1("vert",1)});function i1(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let s=r.selection,l=e>0?s.$to:s.$from,c=s.empty;if(s instanceof Qt){if(!a.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=Vr.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new Vr(u))),!0):!1}}function n7e(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Vr.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&qt.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Vr(r))),!0)}function r7e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Vr))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=bt.empty;for(let s=r.length-1;s>=0;s--)i=bt.from(r[s].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Rt(i,0,0));return a.setSelection(Qt.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function i7e(t){if(!(t.selection instanceof Vr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Rr.create(t.doc,[Ra.widget(t.selection.head,e,{key:"gapcursor"})])}var $S=200,Vi=function(){};Vi.prototype.append=function(e){return e.length?(e=Vi.from(e),!this.length&&e||e.length<$S&&this.leafAppend(e)||this.length<$S&&e.leafPrepend(this)||this.appendInner(e)):this};Vi.prototype.prepend=function(e){return e.length?Vi.from(e).append(this):this};Vi.prototype.appendInner=function(e){return new a7e(this,e)};Vi.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Vi.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Vi.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Vi.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Vi.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,s){return i.push(e(a,s))},n,r),i};Vi.from=function(e){return e instanceof Vi?e:e&&e.length?new lte(e):Vi.empty};var lte=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,a){return i==0&&a==this.length?this:new e(this.values.slice(i,a))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,a,s,l){for(var c=a;c<s;c++)if(i(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,a,s,l){for(var c=a-1;c>=s;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=$S)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=$S)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Vi);Vi.empty=new lte([]);var a7e=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,a,s){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(a,l),s)===!1||a>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,a)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(a,l)-l,s+l)===!1||a<l&&this.left.forEachInvertedInner(r,Math.min(i,l),a,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var a=this.left.length;return i<=a?this.left.slice(r,i):r>=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Vi);const s7e=500;class Io{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let s=e.tr,l,c,u=[],d=[];return this.items.forEach((f,g)=>{if(!f.step){i||(i=this.remapping(r,g+1),a=i.maps.length),a--,d.push(f);return}if(i){d.push(new ll(f.map));let p=f.step.map(i.slice(a)),x;p&&s.maybeStep(p).doc&&(x=s.mapping.maps[s.mapping.maps.length-1],u.push(new ll(x,void 0,void 0,u.length+d.length))),a--,x&&i.appendMap(x,a)}else s.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(a)):f.selection,c=new Io(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:s,selection:l}}addTransform(e,n,r,i){let a=[],s=this.eventCount,l=this.items,c=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),g=new ll(e.mapping.maps[d],f,n),p;(p=c&&c.merge(g))&&(g=p,d?a.pop():l=l.slice(0,l.length-1)),a.push(g),n&&(s++,n=void 0),i||(c=g)}let u=s-r.depth;return u>l7e&&(l=o7e(l,u),s-=u),new Io(l.append(a),s)}remapping(e,n){let r=new db;return this.items.forEach((i,a)=>{let s=i.mirrorOffset!=null&&a-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new Io(this.items.append(e.map(n=>new ll(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(g=>{g.selection&&l--},i);let c=n;this.items.forEach(g=>{let p=a.getMirror(--c);if(p==null)return;s=Math.min(s,p);let x=a.maps[p];if(g.step){let v=e.steps[p].invert(e.docs[p]),y=g.selection&&g.selection.map(a.slice(c+1,p));y&&l++,r.push(new ll(x,v,y))}else r.push(new ll(x))},i);let u=[];for(let g=n;g<s;g++)u.push(new ll(a.maps[g]));let d=this.items.slice(0,i).append(u).append(r),f=new Io(d,l);return f.emptyItemCount()>s7e&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],a=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&a++;else if(s.step){let c=s.step.map(n.slice(r)),u=c&&c.getMap();if(r--,u&&n.appendMap(u,r),c){let d=s.selection&&s.selection.map(n.slice(r));d&&a++;let f=new ll(u.invert(),c,d),g,p=i.length-1;(g=i.length&&i[p].merge(f))?i[p]=g:i.push(f)}}else s.map&&r--},this.items.length,0),new Io(Vi.from(i.reverse()),a)}}Io.empty=new Io(Vi.empty,0);function o7e(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class ll{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new ll(n.getMap().invert(),n,this.selection)}}}class qu{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const l7e=20;function c7e(t,e,n,r){let i=n.getMeta(Kh),a;if(i)return i.historyState;n.getMeta(h7e)&&(t=new qu(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Kh))return s.getMeta(Kh).redo?new qu(t.done.addTransform(n,void 0,r,R1(e)),t.undone,jG(n.mapping.maps),t.prevTime,t.prevComposition):new qu(t.done,t.undone.addTransform(n,void 0,r,R1(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),c=t.prevTime==0||!s&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!u7e(n,t.prevRanges)),u=s?Mk(t.prevRanges,n.mapping):jG(n.mapping.maps);return new qu(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,R1(e)),Io.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new qu(t.done.rebased(n,a),t.undone.rebased(n,a),Mk(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new qu(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Mk(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function u7e(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let a=0;a<e.length;a+=2)r<=e[a+1]&&i>=e[a]&&(n=!0)}),n}function jG(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,s)=>e.push(a,s));return e}function Mk(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),a=e.map(t[r+1],-1);i<=a&&n.push(i,a)}return n}function d7e(t,e,n){let r=R1(e),i=Kh.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,r);if(!a)return null;let s=a.selection.resolve(a.transform.doc),l=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),i,r),c=new qu(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(s).setMeta(Kh,{redo:n,historyState:c})}let Ek=!1,RG=null;function R1(t){let e=t.plugins;if(RG!=e){Ek=!1,RG=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Ek=!0;break}}return Ek}const Kh=new ki("history"),h7e=new ki("closeHistory");function f7e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Fr({key:Kh,state:{init(){return new qu(Io.empty,Io.empty,null,0,-1)},apply(e,n,r){return c7e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?ute:r=="historyRedo"?dte:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function cte(t,e){return(n,r)=>{let i=Kh.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=d7e(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const ute=cte(!1,!0),dte=cte(!0,!0);dr.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Fr({key:new ki("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const a=this.storage.characters({node:r.doc});if(a>i){const s=a-i,l=0,c=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(l,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=a-r,u=l-c,d=l;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var m7e=dr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[YVe(this.options)]}});dr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Fr({key:new ki("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return Rr.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(c.isText)return;if(!(i>=u&&i<=u+c.nodeSize-1))return!1;s+=1});let l=0;return t.descendants((c,u)=>{if(c.isText||!(i>=u&&i<=u+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";a.push(Ra.node(u,u+c.nodeSize,{class:this.options.className}))}),Rr.create(t,a)}}})]}});var p7e=dr.create({name:"gapCursor",addProseMirrorPlugins(){return[e7e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Xn(Gt(t,"allowGapCursor",n)))!=null?e:null}}});dr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Fr({key:new ki("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const a=this.editor.isEmpty;return t.descendants((s,l)=>{const c=r>=l&&r<=l+s.nodeSize,u=!s.isLeaf&&vE(s);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=Ra.node(l,l+s.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:l,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),Rr.create(t,i)}}})]}});dr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Fr({key:new ki("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||wee(n.selection)||t.view.dragging?null:Rr.create(n.doc,[Ra.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function DG({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var g7e=dr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ki(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new Fr({key:e,appendTransaction:(i,a,s)=>{const{doc:l,tr:c,schema:u}=s,d=e.getState(s),f=l.content.size,g=u.nodes[n];if(d)return c.insert(f,g.create())},state:{init:(i,a)=>{const s=a.tr.doc.lastChild;return!DG({node:s,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const s=i.doc.lastChild;return!DG({node:s,types:r})}}})]}}),x7e=dr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>ute(t,e),redo:()=>({state:t,dispatch:e})=>dte(t,e)}},addProseMirrorPlugins(){return[f7e(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),b7e=dr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(G$e.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(z$e.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Yee.configure(this.options.bulletList)),this.options.code!==!1&&i.push(K$e.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(Z$e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(Q$e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(m7e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(p7e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(J$e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(eVe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(x7e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(tVe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(sVe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Zee.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(rte.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Xee.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(ate.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(VVe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(qVe.configure(this.options.strike)),this.options.text!==!1&&i.push(KVe.configure(this.options.text)),this.options.underline!==!1&&i.push(ste.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(g7e.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),y7e=b7e,v7e=dr.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),_7e=v7e,w7e=20,hte=(t,e=0)=>{const n=[];return!t.children.length||e>w7e||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...hte(r,e+1))}),n},S7e=t=>{if(!t.children.length)return;const e=hte(t);e&&e.forEach(n=>{var r,i;const a=n.getAttribute("style"),s=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${s};${a}`)})},fte=Id.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&S7e(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Wr(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(a=>!!a))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),M7e=dr.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const s=a[0].trim().toLowerCase(),l=a.slice(1).join(":").trim();if(s==="background-color")return l.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),mte=dr.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const s=a[0].trim().toLowerCase(),l=a.slice(1).join(":").trim();if(s==="color")return l.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),E7e=dr.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),A7e=dr.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),T7e=dr.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});dr.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(M7e.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(mte.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(E7e.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(A7e.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(T7e.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(fte.configure(this.options.textStyle)),t}});var N7e=mte,C7e=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,k7e=cs.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Wr(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,a,s;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",c=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(s=(a=t.attrs)==null?void 0:a.title)!=null?s:"";return u?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:s})=>{const l=document.createElement("img");Object.entries(s).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,f);break}}),l.src=s.src;const c=new d$e({element:l,node:i,getPos:a,onResize:(d,f)=>{l.style.width=`${d}px`,l.style.height=`${f}px`},onCommit:(d,f)=>{const g=a();g!==void 0&&this.editor.chain().setNodeSelection(g).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,g)=>d.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),u=c.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",l.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Iee({find:C7e,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),P7e=k7e;function Hj({content:t,onChange:e,placeholder:n}){const r=O$e({extensions:[y7e.configure({heading:!1,codeBlock:!1,code:!1}),XVe,PVe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),_7e.configure({types:["paragraph"]}),fte,N7e,P7e.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:s})=>{e(s.getHTML())},editorProps:{attributes:{class:"prose prose-invert prose-sm max-w-none focus:outline-none min-h-[120px] px-3 py-2",placeholder:n||""}}});if(!r)return null;const i=({onClick:s,isActive:l=!1,children:c,title:u})=>o.jsx("button",{type:"button",onClick:s,title:u,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${l?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:c}),a=()=>{const s=window.prompt("Enter URL:");s&&r.chain().focus().setLink({href:s}).run()};return o.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[o.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[o.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:o.jsx(Ooe,{className:"w-4 h-4"})}),o.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:o.jsx(bce,{className:"w-4 h-4"})}),o.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:o.jsx(hde,{className:"w-4 h-4"})}),o.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),o.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:o.jsx(mR,{className:"w-4 h-4"})}),o.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:o.jsx(B9,{className:"w-4 h-4"})}),o.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),o.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:o.jsx(ide,{className:"w-4 h-4"})}),o.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:o.jsx(ede,{className:"w-4 h-4"})}),o.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:o.jsx(nde,{className:"w-4 h-4"})}),o.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),o.jsx(i,{onClick:a,isActive:r.isActive("link"),title:"Add Link",children:o.jsx(Cb,{className:"w-4 h-4"})}),r.isActive("link")&&o.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:o.jsx(K9,{className:"w-4 h-4"})})]}),o.jsx(N$e,{editor:r})]})}function j7e({archiveId:t,archiveName:e,onClose:n}){const r=pn(),[i,a]=S.useState(!1),[s,l]=S.useState(null),[c,u]=S.useState({}),{data:d,isLoading:f,error:g}=gt({queryKey:["archive-project-page",t],queryFn:()=>_e.getArchiveProjectPage(t)}),p=vt({mutationFn:T=>_e.updateArchiveProjectPage(t,T),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});S.useEffect(()=>{const T=C=>{C.key==="Escape"&&(s!==null?l(null):i?b():n())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[s,i,n]);const x=[...d?.model_pictures||[],...d?.profile_pictures||[]],v=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),a(!0)},y=()=>{p.mutate(c)},b=()=>{a(!1),u({})},E=T=>{const C=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],N=new DOMParser().parseFromString(T,"text/html"),O=k=>{if(k.nodeType===Node.TEXT_NODE)return k.textContent||"";if(k.nodeType===Node.ELEMENT_NODE){const j=k,B=j.tagName.toLowerCase();if(!C.includes(B))return Array.from(j.childNodes).map(O).join("");let L="";if(B==="a"&&j.getAttribute("href")){const R=j.getAttribute("href");R?.toLowerCase().startsWith("http")&&(L=` href="${R}" target="_blank" rel="noopener noreferrer"`)}if(B==="img"){const R=j.getAttribute("src");if(!R?.toLowerCase().startsWith("http"))return"";L=` src="${R}" style="max-width: 100%; height: auto;"`}const K=Array.from(j.childNodes).map(O).join("");return["br","img"].includes(B)?`<${B}${L} />`:`<${B}${L}>${K}</${B}>`}return""};return Array.from(N.body.childNodes).map(O).join("")},w=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),A=T=>{T.target===T.currentTarget&&n()};return o.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:A,children:[o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(As,{className:"w-5 h-5 text-bambu-green"}),o.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&o.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[!i&&w&&o.jsxs(ke,{variant:"ghost",size:"sm",onClick:v,children:[o.jsx(nf,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&o.jsxs(o.Fragment,{children:[o.jsx(ke,{variant:"ghost",size:"sm",onClick:b,children:"Cancel"}),o.jsxs(ke,{variant:"primary",size:"sm",onClick:y,disabled:p.isPending,children:[o.jsx(Ts,{className:"w-4 h-4 mr-1"}),"Save"]})]}),o.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),g&&o.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!w&&o.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[o.jsx(As,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),o.jsx("p",{children:"No project page data found in this 3MF file."}),o.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&w&&o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"space-y-4",children:[i?o.jsx("input",{type:"text",value:c.title||"",onChange:T=>u({...c,title:T.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&o.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),o.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(n3,{className:"w-4 h-4 text-bambu-gray"}),o.jsx("input",{type:"text",value:c.designer||"",onChange:T=>u({...c,designer:T.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[o.jsx(n3,{className:"w-4 h-4"}),o.jsx("span",{children:d.designer}),d.designer_user_id&&o.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:o.jsx(la,{className:"w-3 h-3"})})]}),d.creation_date&&o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[o.jsx(Jr,{className:"w-4 h-4"}),o.jsx("span",{children:d.creation_date})]}),i?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(As,{className:"w-4 h-4 text-bambu-gray"}),o.jsx("input",{type:"text",value:c.license||"",onChange:T=>u({...c,license:T.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[o.jsx(As,{className:"w-4 h-4"}),o.jsx("span",{children:d.license})]}),d.origin&&o.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?o.jsx(Hj,{content:c.description||"",onChange:T=>u({...c,description:T}),placeholder:"Enter description..."}):o.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&o.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[o.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?o.jsxs("div",{className:"space-y-2",children:[o.jsx("input",{type:"text",value:c.profile_title||"",onChange:T=>u({...c,profile_title:T.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),o.jsx(Hj,{content:c.profile_description||"",onChange:T=>u({...c,profile_description:T}),placeholder:"Profile description..."})]}):o.jsxs(o.Fragment,{children:[d.profile_title&&o.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&o.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.profile_description)}}),d.profile_user_name&&o.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[o.jsx(Nb,{className:"w-4 h-4"}),"Images (",x.length,")"]}),o.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((T,C)=>o.jsx("button",{onClick:()=>l(C),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:o.jsx("img",{src:T.url,alt:T.name,className:"w-full h-full object-cover"})},T.path))})]}),d.design_model_id&&o.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:o.jsxs("a",{href:`https://makerworld.com/en/models/${d.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[o.jsx(la,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),s!==null&&x[s]&&o.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>l(null),children:[o.jsx("button",{onClick:T=>{T.stopPropagation(),l(Math.max(0,s-1))},disabled:s===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:o.jsx(Jh,{className:"w-6 h-6 text-white"})}),o.jsx("img",{src:x[s].url,alt:x[s].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:T=>T.stopPropagation()}),o.jsx("button",{onClick:T=>{T.stopPropagation(),l(Math.min(x.length-1,s+1))},disabled:s===x.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:o.jsx(Ko,{className:"w-6 h-6 text-white"})}),o.jsx("button",{onClick:()=>l(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:o.jsx(Wt,{className:"w-6 h-6 text-white"})}),o.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[s+1," / ",x.length]})]})]})}const R7e=[.25,.5,.75,1,1.5,2,3,4];function Xm(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function D7e({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=Ar(),a=S.useRef(null),s=S.useRef(null),[l,c]=S.useState(!1),[u,d]=S.useState(0),[f,g]=S.useState(0),[p,x]=S.useState(0),[v,y]=S.useState(0),[b,E]=S.useState(1),[w,A]=S.useState(null),[T,C]=S.useState(null),[N,O]=S.useState(.8),[k,j]=S.useState(!1),{data:B,isLoading:L}=gt({queryKey:["timelapse-info",t],queryFn:()=>_e.getTimelapseInfo(t)}),{data:K}=gt({queryKey:["timelapse-thumbnails",t],queryFn:()=>_e.getTimelapseThumbnails(t,15)}),R=vt({mutationFn:()=>_e.processTimelapse(t,{trimStart:p,trimEnd:v,speed:b,saveMode:"replace"},w||void 0),onSuccess:z=>{i(z.message,"success"),r?.(),n()},onError:z=>{i(z.message||"Processing failed","error")}});S.useEffect(()=>{B?.duration&&v===0&&y(B.duration)},[B?.duration,v]),S.useEffect(()=>{const z=V=>{V.key==="Escape"&&n()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[n]),S.useEffect(()=>{const z=a.current;if(!z)return;const V=()=>{const le=z.currentTime;d(le),le>=v&&(z.currentTime=p)},X=()=>{g(z.duration),v===0&&y(z.duration)},te=()=>c(!0),ie=()=>c(!1);return z.addEventListener("timeupdate",V),z.addEventListener("durationchange",X),z.addEventListener("play",te),z.addEventListener("pause",ie),()=>{z.removeEventListener("timeupdate",V),z.removeEventListener("durationchange",X),z.removeEventListener("play",te),z.removeEventListener("pause",ie)}},[p,v]),S.useEffect(()=>{const z=s.current,V=a.current;!z||!V||!T||(z.currentTime=V.currentTime,z.playbackRate=V.playbackRate,l&&!k?z.play().catch(()=>{}):z.pause())},[l,T,k]),S.useEffect(()=>{s.current&&(s.current.volume=k?0:N)},[N,k]),S.useEffect(()=>{a.current&&(a.current.playbackRate=b),s.current&&(s.current.playbackRate=b)},[b]);const q=S.useCallback(()=>{const z=a.current;z&&(l?z.pause():(z.currentTime<p&&(z.currentTime=p),z.play()))},[l,p]),W=z=>{const V=a.current;V&&(V.currentTime=Math.max(p,Math.min(v,z)))},$=z=>{const V=z.target.files?.[0];V&&(T&&URL.revokeObjectURL(T),A(V),C(URL.createObjectURL(V)))},J=()=>{T&&URL.revokeObjectURL(T),A(null),C(null)};S.useEffect(()=>()=>{T&&URL.revokeObjectURL(T)},[T]);const ee=v-p,Q=ee/b;return L?o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:o.jsxs("div",{className:"flex items-center gap-3 text-white",children:[o.jsx(pt,{className:"w-6 h-6 animate-spin"}),"Loading video info..."]})}):o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:o.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-5xl w-full mx-4 max-h-[90vh] overflow-hidden flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[o.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(Oh,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ke,{variant:"primary",size:"sm",onClick:()=>R.mutate(),disabled:R.isPending,children:R.isPending?o.jsxs(o.Fragment,{children:[o.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Ts,{className:"w-4 h-4"}),"Save"]})}),o.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:o.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[o.jsxs("div",{className:"relative",children:[o.jsx("video",{ref:a,src:e,className:"w-full rounded-lg bg-black",onClick:q,muted:!!T}),!l&&o.jsx("button",{onClick:q,className:"absolute inset-0 flex items-center justify-center bg-black/30 hover:bg-black/40 transition-colors",children:o.jsx("div",{className:"p-4 bg-bambu-green rounded-full",children:o.jsx(xd,{className:"w-8 h-8 text-white"})})}),T&&o.jsx("audio",{ref:s,src:T,loop:!0})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[o.jsx(Cue,{className:"w-4 h-4"}),o.jsx("span",{children:"Trim"}),o.jsxs("span",{className:"ml-auto",children:[Xm(p)," - ",Xm(v)," (",Xm(ee),")"]})]}),o.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[o.jsx("div",{className:"absolute inset-0 flex",children:K?.thumbnails.map((z,V)=>o.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${z})`}},V))}),o.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${p/f*100}%`}}),o.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(f-v)/f*100}%`}}),o.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${p/f*100}%`,right:`${(f-v)/f*100}%`}}),o.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white shadow-lg",style:{left:`${u/f*100}%`}}),o.jsx("input",{type:"range",min:0,max:f,step:.1,value:p,onChange:z=>{const V=parseFloat(z.target.value);V<v-1&&(x(V),a.current&&a.current.currentTime<V&&(a.current.currentTime=V))},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 50% 0 0)"}}),o.jsx("input",{type:"range",min:0,max:f,step:.1,value:v,onChange:z=>{const V=parseFloat(z.target.value);V>p+1&&y(V)},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 0 0 50%)"}})]}),o.jsx("input",{type:"range",min:0,max:f,step:.1,value:u,onChange:z=>W(parseFloat(z.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),o.jsx("div",{className:"flex items-center justify-center gap-2",children:o.jsx("button",{onClick:q,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?o.jsx(gR,{className:"w-5 h-5 text-white"}):o.jsx(xd,{className:"w-5 h-5 text-white"})})})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[o.jsx(eM,{className:"w-4 h-4"}),o.jsx("span",{children:"Speed"}),o.jsxs("span",{className:"ml-auto",children:[b,"x (output: ",Xm(Q),")"]})]}),o.jsx("div",{className:"flex gap-1",children:R7e.map(z=>o.jsxs("button",{onClick:()=>E(z),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${b===z?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[z,"x"]},z))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[o.jsx(t3,{className:"w-4 h-4"}),o.jsx("span",{children:"Music Overlay"})]}),w?o.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[o.jsx(t3,{className:"w-5 h-5 text-bambu-green"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm text-white truncate",children:w.name}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[(w.size/1024/1024).toFixed(1)," MB"]})]}),o.jsx("button",{onClick:()=>j(!k),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:k?o.jsx(wde,{className:"w-4 h-4 text-bambu-gray"}):o.jsx(vde,{className:"w-4 h-4 text-bambu-green"})}),o.jsx("input",{type:"range",min:0,max:1,step:.1,value:N,onChange:z=>O(parseFloat(z.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),o.jsx("button",{onClick:J,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:o.jsx(Nn,{className:"w-4 h-4 text-red-400"})})]}):o.jsxs("label",{className:"flex flex-col items-center justify-center gap-2 p-6 border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green/50 transition-colors",children:[o.jsx(ca,{className:"w-8 h-8 text-bambu-gray"}),o.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),o.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),o.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange:$,className:"hidden"})]})]}),o.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg text-sm space-y-1",children:[o.jsxs("p",{className:"text-bambu-gray",children:[o.jsx("span",{className:"text-white",children:"Original:"})," ",Xm(f)," @ ",B?.width,"x",B?.height]}),o.jsxs("p",{className:"text-bambu-gray",children:[o.jsx("span",{className:"text-white",children:"Output:"})," ",Xm(Q)," @ ",b,"x speed",w&&" + music overlay"]})]})]}),R.isPending&&o.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[o.jsx(pt,{className:"w-12 h-12 text-bambu-green animate-spin"}),o.jsx("p",{className:"text-white text-lg",children:"Processing timelapse..."}),o.jsx("p",{className:"text-bambu-gray text-sm",children:"This may take a few moments"})]})]})})}const O7e=[.25,.5,.75,1,1.5,2,3,4];function L7e({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:a}){const s=S.useRef(null),[l,c]=S.useState(!0),[u,d]=S.useState(1),[f,g]=S.useState(0),[p,x]=S.useState(0),[v,y]=S.useState(!1);S.useEffect(()=>{const N=s.current;N&&(N.playbackRate=u)},[u]),S.useEffect(()=>{const N=O=>{O.key==="Escape"&&i()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[i]),S.useEffect(()=>{const N=s.current;if(!N)return;const O=()=>g(N.currentTime),k=()=>x(N.duration),j=()=>c(!0),B=()=>c(!1);return N.addEventListener("timeupdate",O),N.addEventListener("durationchange",k),N.addEventListener("play",j),N.addEventListener("pause",B),()=>{N.removeEventListener("timeupdate",O),N.removeEventListener("durationchange",k),N.removeEventListener("play",j),N.removeEventListener("pause",B)}},[]);const b=()=>{const N=s.current;N&&(l?N.pause():N.play())},E=N=>{const O=s.current;O&&(O.currentTime=parseFloat(N.target.value))},w=()=>{const N=s.current;N&&(N.currentTime=Math.max(0,N.currentTime-5))},A=()=>{const N=s.current;N&&(N.currentTime=Math.min(p,N.currentTime+5))},T=N=>{const O=Math.floor(N/60),k=Math.floor(N%60);return`${O}:${k.toString().padStart(2,"0")}`},C=()=>{const N=document.createElement("a");N.href=t,N.download=n,N.click()};return o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:[o.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(Oh,{className:"w-5 h-5 text-bambu-green"}),e]}),o.jsxs("div",{className:"flex items-center gap-2",children:[r&&o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>y(!0),children:[o.jsx(Bc,{className:"w-4 h-4"}),"Edit"]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:C,children:[o.jsx(as,{className:"w-4 h-4"}),"Download"]}),o.jsx("button",{onClick:i,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:o.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),o.jsxs("div",{className:"p-4",children:[o.jsx("video",{ref:s,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:b}),o.jsxs("div",{className:"mt-4 space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:T(f)}),o.jsx("input",{type:"range",min:0,max:p||100,value:f,onChange:E,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),o.jsx("span",{className:"text-xs text-bambu-gray w-12",children:T(p)})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:w,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:o.jsx(Bue,{className:"w-5 h-5 text-bambu-gray"})}),o.jsx("button",{onClick:b,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?o.jsx(gR,{className:"w-5 h-5 text-white"}):o.jsx(xd,{className:"w-5 h-5 text-white"})}),o.jsx("button",{onClick:A,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:o.jsx(V1,{className:"w-5 h-5 text-bambu-gray"})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),o.jsx("div",{className:"flex gap-1",children:O7e.map(N=>o.jsxs("button",{onClick:()=>d(N),className:`px-2 py-1 text-xs rounded transition-colors ${u===N?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[N,"x"]},N))})]})]})]})]})]}),v&&r&&o.jsx(D7e,{archiveId:r,timelapseSrc:t,onClose:()=>y(!1),onSave:a})]})}function pte({archiveId:t,archiveName:e,onClose:n}){const r=pn(),{showToast:i}=Ar(),[a,s]=S.useState(null),[l,c]=S.useState("asap"),[u,d]=S.useState(""),[f,g]=S.useState(!1),[p,x]=S.useState(!1),{data:v}=gt({queryKey:["printers"],queryFn:()=>_e.getPrinters()});S.useEffect(()=>{v?.length===1&&!a&&s(v[0].id)},[v,a]),S.useEffect(()=>{const w=A=>{A.key==="Escape"&&n()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[n]);const y=vt({mutationFn:w=>_e.addToQueue(w),onSuccess:()=>{r.invalidateQueries({queryKey:["queue"]}),i("Added to print queue"),n()},onError:w=>{i(w.message||"Failed to add to queue","error")}}),b=w=>{if(w.preventDefault(),!a){i("Please select a printer","error");return}const A={printer_id:a,archive_id:t,require_previous_success:f,auto_off_after:p};l==="scheduled"&&u&&(A.scheduled_time=new Date(u).toISOString()),y.mutate(A)},E=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:o.jsx(Mt,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:o.jsxs(At,{className:"p-0",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Jr,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),o.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),o.jsx("p",{className:"text-white font-medium truncate",children:e})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),v?.length===0?o.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[o.jsx(Oa,{className:"w-4 h-4"}),"No printers configured"]}):o.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a||"",onChange:w=>s(w.target.value?Number(w.target.value):null),required:!0,children:[o.jsx("option",{value:"",children:"Select printer..."}),v?.map(w=>o.jsx("option",{value:w.id,children:w.name},w.id))]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${l==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("asap"),children:[o.jsx(ur,{className:"w-4 h-4"}),"ASAP (when idle)"]}),o.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${l==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("scheduled"),children:[o.jsx(Jr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),l==="scheduled"&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),o.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:w=>d(w.target.value),min:E(),required:!0})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:w=>g(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),o.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:p,onChange:w=>x(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),o.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[o.jsx(jl,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:l==="asap"?"Print will start as soon as the printer is idle.":"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available."}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),o.jsx(ke,{type:"submit",className:"flex-1",disabled:y.isPending||!a||v?.length===0,children:y.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function I7e({archiveIds:t,onClose:e}){S.useEffect(()=>{const a=s=>{s.key==="Escape"&&e()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e]);const{data:n,isLoading:r,error:i}=gt({queryKey:["archive-comparison",t],queryFn:()=>_e.compareArchives(t)});return o.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col border border-bambu-dark-tertiary",onClick:a=>a.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),o.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?o.jsxs("div",{className:"text-center py-12 text-red-400",children:[o.jsx(Gn,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),o.jsx("p",{children:"Failed to load comparison"}),o.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?o.jsx(F7e,{comparison:n}):null}),o.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:o.jsx(ke,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function F7e({comparison:t}){return o.jsxs("div",{className:"space-y-6",children:[o.jsx("div",{className:"overflow-x-auto",children:o.jsxs("table",{className:"w-full",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{className:"text-left text-sm text-bambu-gray font-medium pb-2 pr-4 min-w-[150px]",children:"Setting"}),t.archives.map(e=>o.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[o.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),o.jsx("div",{className:`text-xs ${e.status==="completed"?"text-bambu-green":e.status==="failed"?"text-red-400":"text-bambu-gray"}`,children:e.status})]},e.id))]})}),o.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>o.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[o.jsx("td",{className:"py-2 pr-4 text-sm",children:o.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&o.jsx(Gn,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),o.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>o.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??o.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&o.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&o.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[o.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[o.jsx(Gn,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),o.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>o.jsxs("li",{children:[o.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&o.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?o.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[o.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[o.jsx(po,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),o.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[o.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),o.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?o.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>o.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[o.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",o.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):o.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):o.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:o.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function U7e(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function z7e(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4);if(i<1)return"Just now";if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function B7e({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:a}){const[s,l]=S.useState(!1),[c,u]=S.useState(t.tags||""),[d,f]=S.useState(t.notes||""),[g,p]=S.useState(t.project_id);return o.jsx(Mt,{children:o.jsxs(At,{className:"py-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(U9,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-white font-medium",children:t.filename}),o.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[o.jsx("span",{children:U7e(t.file_size)}),o.jsx("span",{children:"·"}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(ur,{className:"w-3 h-3"}),z7e(t.uploaded_at)]}),t.source_ip&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"·"}),o.jsxs("span",{children:["from ",t.source_ip]})]})]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:()=>l(!s),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:s?o.jsx(Tb,{className:"w-5 h-5"}):o.jsx(vo,{className:"w-5 h-5"})}),o.jsx(ke,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:g||void 0}),disabled:i,children:i?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsxs(o.Fragment,{children:[o.jsx(lo,{className:"w-4 h-4"}),"Archive"]})}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>r(t.id),disabled:a,children:a?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(Nn,{className:"w-4 h-4 text-red-400"})})]})]}),s&&o.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),o.jsx("input",{type:"text",value:c,onChange:x=>u(x.target.value),placeholder:"e.g., functional, prototype, gift",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),o.jsx("textarea",{value:d,onChange:x=>f(x.target.value),placeholder:"Add notes about this print...",rows:2,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm resize-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Project"}),o.jsxs("select",{value:g||"",onChange:x=>p(x.target.value?Number(x.target.value):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm",children:[o.jsx("option",{value:"",children:"No project"}),e.map(x=>o.jsx("option",{value:x.id,children:x.name},x.id))]})]})]})]})})}function H7e(){const t=pn(),{showToast:e}=Ar(),[n,r]=S.useState(!1),[i,a]=S.useState(!1),[s,l]=S.useState(new Set),[c,u]=S.useState(new Set),{data:d,isLoading:f}=gt({queryKey:["pending-uploads"],queryFn:yx.list,refetchInterval:1e4}),{data:g}=gt({queryKey:["projects"],queryFn:()=>_e.getProjects()}),p=vt({mutationFn:({id:b,data:E})=>yx.archive(b,E),onMutate:({id:b})=>{l(E=>new Set(E).add(b))},onSettled:(b,E,{id:w})=>{l(A=>{const T=new Set(A);return T.delete(w),T})},onSuccess:b=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${b.print_name}`)},onError:b=>{e(b.message||"Failed to archive","error")}}),x=vt({mutationFn:b=>yx.discard(b),onMutate:b=>{u(E=>new Set(E).add(b))},onSettled:(b,E,w)=>{u(A=>{const T=new Set(A);return T.delete(w),T})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:b=>{e(b.message||"Failed to discard","error")}}),v=vt({mutationFn:yx.archiveAll,onSuccess:b=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${b.archived} files${b.failed>0?`, ${b.failed} failed`:""}`)},onError:b=>{e(b.message||"Failed to archive all","error")}}),y=vt({mutationFn:yx.discardAll,onSuccess:b=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${b.discarded} files`)},onError:b=>{e(b.message||"Failed to discard all","error")}});return f?o.jsx(Mt,{children:o.jsx(At,{className:"py-8 flex justify-center",children:o.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:o.jsxs("div",{className:"mb-6",children:[o.jsxs(Mt,{className:"border-l-4 border-l-yellow-500",children:[o.jsx(Fi,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ca,{className:"w-5 h-5 text-yellow-500"}),o.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Pending Uploads (",d.length,")"]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ke,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:v.isPending,children:v.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsxs(o.Fragment,{children:[o.jsx(lo,{className:"w-4 h-4"}),"Archive All"]})}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:y.isPending,children:y.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsxs(o.Fragment,{children:[o.jsx(Nn,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),o.jsxs(At,{children:[o.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"These files were uploaded via the virtual printer. Review and archive them to add to your collection."}),o.jsx("div",{className:"space-y-3",children:d.map(b=>o.jsx(B7e,{upload:b,projects:g||[],onArchive:(E,w)=>p.mutate({id:E,data:w}),onDiscard:E=>x.mutate(E),isArchiving:s.has(b.id),isDiscarding:c.has(b.id)},b.id))})]})]}),n&&o.jsx(br,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${d.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{v.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&o.jsx(br,{title:"Discard All Uploads",message:`Are you sure you want to discard all ${d.length} pending uploads? This cannot be undone.`,confirmText:"Discard All",variant:"danger",onConfirm:()=>{y.mutate(),a(!1)},onCancel:()=>a(!1)})]})}function $j(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Vx(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function OG(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function $7e({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a}){const s=pn(),{showToast:l}=Ar(),c=Q9(),[u,d]=S.useState(!1),[f,g]=S.useState(!1),[p,x]=S.useState(!1),[v,y]=S.useState(!1),[b,E]=S.useState(!1),[w,A]=S.useState(!1),[T,C]=S.useState([]),[N,O]=S.useState(!1),[k,j]=S.useState(!1),[B,L]=S.useState(!1),[K,R]=S.useState(!1),[q,W]=S.useState(!1),[$,J]=S.useState(null),ee=S.useRef(null),Q=vt({mutationFn:de=>_e.uploadSource3mf(t.id,de),onSuccess:de=>{s.invalidateQueries({queryKey:["archives"]}),l(`Source 3MF attached: ${de.filename}`)},onError:de=>{l(de.message||"Failed to upload source 3MF","error")}}),z=vt({mutationFn:()=>_e.deleteSource3mf(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),l("Source 3MF removed")},onError:de=>{l(de.message||"Failed to remove source 3MF","error")}}),V=vt({mutationFn:()=>_e.scanArchiveTimelapse(t.id),onSuccess:de=>{de.status==="attached"?(s.invalidateQueries({queryKey:["archives"]}),l(`Timelapse attached: ${de.filename}`)):de.status==="exists"?l("Timelapse already attached"):de.status==="not_found"&&de.available_files&&de.available_files.length>0?(C(de.available_files),A(!0)):l(de.message||"No matching timelapse found","warning")},onError:de=>{l(de.message||"Failed to scan for timelapse","error")}}),X=vt({mutationFn:de=>_e.selectArchiveTimelapse(t.id,de),onSuccess:de=>{s.invalidateQueries({queryKey:["archives"]}),l(`Timelapse attached: ${de.filename}`),A(!1),C([])},onError:de=>{l(de.message||"Failed to attach timelapse","error")}}),te=vt({mutationFn:()=>_e.deleteArchive(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),l("Archive deleted")},onError:()=>{l("Failed to delete archive","error")}}),ie=vt({mutationFn:()=>_e.toggleFavorite(t.id),onSuccess:de=>{s.invalidateQueries({queryKey:["archives"]}),l(de.is_favorite?"Added to favorites":"Removed from favorites")}}),le=vt({mutationFn:de=>_e.updateArchive(t.id,{project_id:de}),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),s.invalidateQueries({queryKey:["projects"]}),l("Project updated")},onError:()=>{l("Failed to update project","error")}}),ge=de=>{de.preventDefault(),J({x:de.clientX,y:de.clientY})},pe=[...t.filename?.toLowerCase().includes(".gcode.")?[{label:"Print",icon:o.jsx(Gi,{className:"w-4 h-4"}),onClick:()=>g(!0)},{label:"Schedule",icon:o.jsx(Jr,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:"Open in Bambu Studio",icon:o.jsx(la,{className:"w-4 h-4"}),onClick:()=>{const de=t.print_name||t.filename||"model",Re=`${window.location.origin}${_e.getArchiveForSlicer(t.id,de)}`;bh(Re)}}]:[{label:"Slice",icon:o.jsx(la,{className:"w-4 h-4"}),onClick:()=>{const de=t.print_name||t.filename||"model",Re=`${window.location.origin}${_e.getArchiveForSlicer(t.id,de)}`;bh(Re)}}],{label:"View on MakerWorld",icon:o.jsx(Ap,{className:"w-4 h-4"}),onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:o.jsx(Qh,{className:"w-4 h-4"}),onClick:()=>d(!0)},{label:"View Timelapse",icon:o.jsx(Oh,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:o.jsx(Tue,{className:"w-4 h-4"}),onClick:()=>V.mutate(),disabled:!t.printer_id||!!t.timelapse_path||V.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:o.jsx(Zk,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const de=document.createElement("a");de.href=_e.getSource3mfDownloadUrl(t.id),de.download=`${t.print_name||t.filename}_source.3mf`,de.click()}else ee.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:o.jsx(ca,{className:"w-4 h-4"}),onClick:()=>ee.current?.click()},{label:"Remove Source 3MF",icon:o.jsx(Nn,{className:"w-4 h-4"}),onClick:()=>W(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:o.jsx(as,{className:"w-4 h-4"}),onClick:()=>{const de=document.createElement("a");de.href=_e.getArchiveDownload(t.id),de.download=`${t.print_name||t.filename}.3mf`,de.click()}},{label:"Copy Download Link",icon:o.jsx(vl,{className:"w-4 h-4"}),onClick:()=>{const de=`${window.location.origin}${_e.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(de).then(()=>{l("Link copied to clipboard")}).catch(()=>{l("Failed to copy link","error")})}},{label:"QR Code",icon:o.jsx(vue,{className:"w-4 h-4"}),onClick:()=>O(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:o.jsx(R0,{className:"w-4 h-4"}),onClick:()=>j(!0),disabled:!t.photos?.length},{label:"Project Page",icon:o.jsx(As,{className:"w-4 h-4"}),onClick:()=>L(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:o.jsx(Np,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>ie.mutate()},{label:"Edit",icon:o.jsx(Bc,{className:"w-4 h-4"}),onClick:()=>y(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:o.jsx(Bo,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:o.jsx(Bo,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const de=[];if(t.project_id&&de.push({label:"Remove from Project",icon:o.jsx(Wt,{className:"w-4 h-4"}),onClick:()=>le.mutate(null)}),!a)de.push({label:"Loading...",icon:o.jsx(pt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const Re=a.filter(fe=>fe.status==="active");Re.length===0?de.push({label:"No projects available",icon:o.jsx(Bo,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):Re.forEach(fe=>{de.push({label:fe.name,icon:o.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:fe.color||"#888"}}),onClick:()=>le.mutate(fe.id),disabled:t.project_id===fe.id})})}return de})()},{label:n?"Deselect":"Select",icon:n?o.jsx(rf,{className:"w-4 h-4"}):o.jsx(af,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:o.jsx(Nn,{className:"w-4 h-4"}),onClick:()=>x(!0),danger:!0}];return o.jsxs(Mt,{className:`relative flex flex-col ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,onContextMenu:ge,onClick:i?()=>r(t.id):void 0,children:[i&&o.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:de=>{de.stopPropagation(),r(t.id)},children:n?o.jsx(rf,{className:"w-5 h-5 text-bambu-green"}):o.jsx(af,{className:"w-5 h-5 text-white"})}),o.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?o.jsx("img",{src:_e.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):o.jsx("div",{className:"w-full h-full flex items-center justify-center",children:o.jsx(Nb,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),c&&o.jsx("button",{className:"absolute top-2 right-10 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:de=>{de.stopPropagation();const Re=de.currentTarget.getBoundingClientRect();J({x:Re.left,y:Re.bottom+4})},title:"Menu",children:o.jsx(o0,{className:"w-5 h-5 text-white"})}),o.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:de=>{de.stopPropagation(),ie.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:o.jsx(Np,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),(t.status==="failed"||t.status==="aborted")&&o.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-red-500/80 text-white",children:t.status==="aborted"?"cancelled":"failed"}),t.duplicate_count>0&&o.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 rounded text-xs bg-purple-500/80 text-white flex items-center gap-1",title:"This model has been printed before",children:[o.jsx(vl,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&o.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:de=>{de.stopPropagation();const Re=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",fe=`${window.location.origin}${_e.getSource3mfForSlicer(t.id,Re)}`;bh(fe)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:o.jsx(Zk,{className:"w-4 h-4 text-orange-400"})}),t.timelapse_path&&o.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:de=>{de.stopPropagation(),E(!0)},title:"View timelapse",children:o.jsx(Oh,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&o.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:de=>{de.stopPropagation(),j(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[o.jsx(R0,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&o.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 bg-blue-500 rounded-full text-[10px] text-white flex items-center justify-center",children:t.photos.length})]})]}),o.jsxs(At,{className:"p-4 flex-1 flex flex-col",children:[o.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),o.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:e}),o.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${t.filename?.toLowerCase().includes(".gcode.")?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:t.filename?.toLowerCase().includes(".gcode.")?"Sliced file - ready to print":"Source file only - no AMS mapping available",children:t.filename?.toLowerCase().includes(".gcode.")?"GCODE":"SOURCE"}),t.project_name&&o.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${a?.find(de=>de.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(de=>de.id===t.project_id)?.color||"#6b7280"},title:`Project: ${t.project_name}`,children:t.project_name})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs mb-4 min-h-[48px]",children:[(t.print_time_seconds||t.actual_time_seconds)&&o.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${Vx(t.print_time_seconds||0)}
- Actual: ${Vx(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Vx(t.actual_time_seconds)}`:`Estimated: ${Vx(t.print_time_seconds||0)}`,children:[o.jsx(ur,{className:"w-3 h-3"}),Vx(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&o.jsxs("span",{className:`text-[10px] px-1 rounded ${t.time_accuracy>=95&&t.time_accuracy<=105?"bg-bambu-green/20 text-bambu-green":t.time_accuracy>105?"bg-blue-500/20 text-blue-400":"bg-orange-500/20 text-orange-400"}`,children:[t.time_accuracy>100?"+":"",(t.time_accuracy-100).toFixed(0),"%"]})]}),t.filament_used_grams&&o.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[o.jsx(zc,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&o.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[o.jsx(gd,{className:"w-3 h-3"}),t.total_layers&&o.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&o.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&o.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.filament_type&&o.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[o.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&o.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((de,Re)=>o.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:de},title:de},Re))})]})]}),(t.tags||t.notes)&&o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&o.jsx("div",{className:"flex items-center gap-1 px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded text-xs",title:t.notes,children:o.jsx($9,{className:"w-3 h-3"})}),t.tags?.split(",").map((de,Re)=>o.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:de.trim()},Re))]}),o.jsx("div",{className:"flex-1"}),o.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[o.jsx("span",{children:OG(t.created_at)}),o.jsx("span",{children:$j(t.file_size)})]}),o.jsxs("div",{className:"flex gap-1 mt-3",children:[t.filename?.toLowerCase().includes(".gcode.")?o.jsxs(o.Fragment,{children:[o.jsxs(ke,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>g(!0),children:[o.jsx(Gi,{className:"w-3 h-3 flex-shrink-0"}),o.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),o.jsx(ke,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const de=t.print_name||t.filename||"model",Re=`${window.location.origin}${_e.getArchiveForSlicer(t.id,de)}`;bh(Re)},title:"Open in Bambu Studio",children:o.jsx(la,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):o.jsxs(ke,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const de=t.print_name||t.filename||"model",Re=`${window.location.origin}${_e.getArchiveForSlicer(t.id,de)}`;bh(Re)},title:"Open in Bambu Studio to slice",children:[o.jsx(la,{className:"w-3 h-3 flex-shrink-0"}),o.jsx("span",{className:"hidden sm:inline",children:"Slice"})]}),o.jsx(ke,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url,title:t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"Not from MakerWorld",children:o.jsx(Ap,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),o.jsx(ke,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>d(!0),title:"3D Preview",children:o.jsx(Qh,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),o.jsx(ke,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const de=document.createElement("a");de.href=_e.getArchiveDownload(t.id),de.download=`${t.print_name||t.filename}.3mf`,de.click()},title:"Download",children:o.jsx(as,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),o.jsx(ke,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>y(!0),title:"Edit",children:o.jsx(Bc,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),o.jsx(ke,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:"Delete",children:o.jsx(Nn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),v&&o.jsx(lze,{archive:t,onClose:()=>y(!1)}),u&&o.jsx(rze,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>d(!1)}),f&&o.jsx(ize,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>g(!1),onSuccess:()=>{}}),p&&o.jsx(br,{title:"Delete Archive",message:`Are you sure you want to delete "${t.print_name||t.filename}"? This action cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{te.mutate(),x(!1)},onCancel:()=>x(!1)}),q&&o.jsx(br,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"? This will delete the original slicer project file.`,confirmText:"Remove",variant:"danger",onConfirm:()=>{z.mutate(),W(!1)},onCancel:()=>W(!1)}),$&&o.jsx(cze,{x:$.x,y:$.y,items:pe,onClose:()=>J(null)}),b&&t.timelapse_path&&o.jsx(L7e,{src:_e.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>E(!1),onEdit:()=>{s.invalidateQueries({queryKey:["archives"]}),E(!1)}}),w&&T.length>0&&o.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:o.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),o.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),o.jsx("button",{onClick:()=>{A(!1),C([])},className:"text-gray-400 hover:text-white p-1",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(de=>o.jsxs("button",{onClick:()=>X.mutate(de.name),disabled:X.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[o.jsx(Oh,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-white font-medium truncate",children:de.name}),o.jsxs("p",{className:"text-sm text-gray-400",children:[$j(de.size),de.mtime&&` • ${OG(de.mtime)}`]})]})]},de.name))}),o.jsx("div",{className:"p-4 border-t border-gray-700",children:o.jsx(ke,{variant:"secondary",onClick:()=>{A(!1),C([])},className:"w-full",children:"Cancel"})})]})}),N&&o.jsx(gze,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>O(!1)}),k&&t.photos&&t.photos.length>0&&o.jsx(xze,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>j(!1),onDelete:async de=>{try{await _e.deleteArchivePhoto(t.id,de),s.invalidateQueries({queryKey:["archives"]}),l("Photo deleted")}catch{l("Failed to delete photo","error")}}}),B&&o.jsx(j7e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>L(!1)}),K&&o.jsx(pte,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),o.jsx("input",{ref:ee,type:"file",accept:".3mf",className:"hidden",onChange:de=>{const Re=de.target.files?.[0];Re&&Q.mutate(Re),de.target.value=""}})]})}const V7e=[{id:"all",label:"All Archives",icon:o.jsx(Xle,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:o.jsx(ur,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:o.jsx(Jr,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:o.jsx(Jr,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:o.jsx(Np,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:o.jsx(Oa,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:o.jsx(vl,{className:"w-4 h-4"})}];function G7e(){const t=pn(),{showToast:e}=Ar(),n=S.useRef(null),[r,i]=S.useState(""),[a,s]=S.useState(()=>{const ue=localStorage.getItem("archiveFilterPrinter");return ue?Number(ue):null}),[l,c]=S.useState(()=>localStorage.getItem("archiveFilterMaterial")),[u,d]=S.useState(()=>{const ue=localStorage.getItem("archiveFilterColors");return ue?new Set(JSON.parse(ue)):new Set}),[f,g]=S.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[p,x]=S.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[v,y]=S.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[b,E]=S.useState(()=>localStorage.getItem("archiveFilterTag")),[w,A]=S.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[T,C]=S.useState(!1),[N,O]=S.useState([]),[k,j]=S.useState(!1),[B,L]=S.useState(new Set),[K,R]=S.useState(!1),[q,W]=S.useState(!1),[$,J]=S.useState(!1),[ee,Q]=S.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[z,V]=S.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[X,te]=S.useState(()=>localStorage.getItem("archiveCollection")||"all"),[ie,le]=S.useState(!1),[ge,Ee]=S.useState(!1),[pe,de]=S.useState(!1),{data:Re,isLoading:fe}=gt({queryKey:["archives",a],queryFn:()=>_e.getArchives(a||void 0)}),{data:Fe}=gt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:U}=gt({queryKey:["projects"],queryFn:()=>_e.getProjects()}),H=vt({mutationFn:async ue=>(await Promise.all(ue.map(se=>_e.deleteArchive(se))),ue.length),onSuccess:ue=>{t.invalidateQueries({queryKey:["archives"]}),L(new Set),e(`${ue} archive${ue!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}});S.useEffect(()=>{a!==null?localStorage.setItem("archiveFilterPrinter",a.toString()):localStorage.removeItem("archiveFilterPrinter")},[a]),S.useEffect(()=>{l?localStorage.setItem("archiveFilterMaterial",l):localStorage.removeItem("archiveFilterMaterial")},[l]),S.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...u]))},[u]),S.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",f)},[f]),S.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",p.toString())},[p]),S.useEffect(()=>{localStorage.setItem("archiveHideFailed",v.toString())},[v]),S.useEffect(()=>{b?localStorage.setItem("archiveFilterTag",b):localStorage.removeItem("archiveFilterTag")},[b]),S.useEffect(()=>{localStorage.setItem("archiveFilterFileType",w)},[w]),S.useEffect(()=>{localStorage.setItem("archiveViewMode",ee)},[ee]),S.useEffect(()=>{localStorage.setItem("archiveSortBy",z)},[z]),S.useEffect(()=>{localStorage.setItem("archiveCollection",X)},[X]);const re=new Map(Fe?.map(ue=>[ue.id,ue.name])||[]),G=[...new Set(Re?.flatMap(ue=>ue.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),Z=[...new Set(Re?.flatMap(ue=>ue.filament_color?.split(",")||[]).filter(Boolean)||[])],oe=[...new Set(Re?.flatMap(ue=>ue.tags?.split(",").map(se=>se.trim())||[]).filter(Boolean)||[])].sort(),be=Re?.filter(ue=>{const se=new Date,Ve=new Date(ue.created_at);let Be=!0;switch(X){case"recent":Be=se.getTime()-Ve.getTime()<1440*60*1e3;break;case"this-week":Be=se.getTime()-Ve.getTime()<10080*60*1e3;break;case"this-month":Be=Ve.getMonth()===se.getMonth()&&Ve.getFullYear()===se.getFullYear();break;case"favorites":Be=ue.is_favorite===!0;break;case"failed":Be=ue.status==="failed"||ue.status==="aborted";break;case"duplicates":Be=ue.duplicate_count>0;break}const Ze=(ue.print_name||ue.filename).toLowerCase().includes(r.toLowerCase()),ht=!l||ue.filament_type?.split(", ").includes(l),me=ue.filament_color?.split(",")||[],nt=u.size===0||(f==="or"?me.some(_t=>u.has(_t)):[...u].every(_t=>me.includes(_t))),xe=X==="favorites"||!p||ue.is_favorite,He=X==="failed"||!v||ue.status!=="failed"&&ue.status!=="aborted",Pe=ue.tags?.split(",").map(_t=>_t.trim())||[],we=!b||Pe.includes(b),Ae=ue.filename?.toLowerCase().includes(".gcode.");return Be&&Ze&&ht&&nt&&xe&&He&&we&&(w==="all"||w==="gcode"&&Ae||w==="source"&&!Ae)}).sort((ue,se)=>{switch(z){case"date-desc":return new Date(se.created_at).getTime()-new Date(ue.created_at).getTime();case"date-asc":return new Date(ue.created_at).getTime()-new Date(se.created_at).getTime();case"name-asc":return(ue.print_name||ue.filename).localeCompare(se.print_name||se.filename);case"name-desc":return(se.print_name||se.filename).localeCompare(ue.print_name||ue.filename);case"size-desc":return se.file_size-ue.file_size;case"size-asc":return ue.file_size-se.file_size;default:return 0}}),Te=K||B.size>0,Me=ue=>{L(se=>{const Ve=new Set(se);return Ve.has(ue)?Ve.delete(ue):Ve.add(ue),Ve})},F=()=>{be&&L(new Set(be.map(ue=>ue.id)))},I=()=>{L(new Set),R(!1)},ne=ue=>{d(se=>{const Ve=new Set(se);return Ve.has(ue)?Ve.delete(ue):Ve.add(ue),Ve})},ve=()=>{d(new Set)},Se=()=>{i(""),s(null),c(null),x(!1),y(!1),E(null),A("all")},ye=r||a||l||p||v||b||w!=="all",Ke=S.useCallback(ue=>{ue.preventDefault(),ue.dataTransfer.types.includes("Files")&&j(!0)},[]),We=S.useCallback(ue=>{ue.preventDefault(),ue.currentTarget===ue.target&&j(!1)},[]),qe=S.useCallback(ue=>{ue.preventDefault(),j(!1);const se=Array.from(ue.dataTransfer.files).filter(Ve=>Ve.name.endsWith(".3mf"));se.length>0?(O(se),C(!0)):ue.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),ut=S.useCallback(ue=>{const se=ue.target;if(se.tagName==="INPUT"||se.tagName==="TEXTAREA"||se.isContentEditable){ue.key==="Escape"&&se.blur();return}switch(ue.key){case"/":ue.preventDefault(),n.current?.focus();break;case"u":case"U":!ue.metaKey&&!ue.ctrlKey&&(ue.preventDefault(),C(!0));break;case"Escape":Te&&I();break}},[Te]);return S.useEffect(()=>(document.addEventListener("keydown",ut),()=>document.removeEventListener("keydown",ut)),[ut]),o.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:Ke,onDragLeave:We,onDrop:qe,children:[k&&o.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:o.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[o.jsx(ca,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),o.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),o.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),Te&&o.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-4",children:[o.jsxs(ke,{variant:"secondary",size:"sm",onClick:I,children:[o.jsx(Wt,{className:"w-4 h-4"}),"Close"]}),o.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),o.jsxs("span",{className:"text-white font-medium",children:[B.size," selected"]}),o.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:F,children:"Select All"}),o.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>J(!0),children:[o.jsx(Cp,{className:"w-4 h-4"}),"Tags"]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>{const ue=Array.from(B);Promise.all(ue.map(se=>_e.toggleFavorite(se))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${ue.length} archive${ue.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[o.jsx(Np,{className:"w-4 h-4"}),"Favorite"]}),o.jsxs(ke,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>W(!0),children:[o.jsx(Nn,{className:"w-4 h-4"}),"Delete"]})]}),o.jsxs("div",{className:"flex items-center justify-between mb-8",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),o.jsx("select",{className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none",value:X,onChange:ue=>te(ue.target.value),children:V7e.map(ue=>o.jsx("option",{value:ue.id,children:ue.label},ue.id))})]}),o.jsxs("p",{className:"text-bambu-gray",children:[be?.length||0," of ",Re?.length||0," prints"]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"relative",children:[o.jsxs(ke,{variant:"secondary",onClick:()=>le(!ie),disabled:ge,children:[ge?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(B1,{className:"w-4 h-4"}),"Export"]}),ie&&o.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[o.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:async()=>{le(!1),Ee(!0);try{const{blob:ue,filename:se}=await _e.exportArchives({format:"csv",printerId:a||void 0,status:X==="failed"?"failed":void 0,search:r||void 0}),Ve=URL.createObjectURL(ue),Be=document.createElement("a");Be.href=Ve,Be.download=se,Be.click(),URL.revokeObjectURL(Ve),e("Export downloaded")}catch{e("Export failed","error")}finally{Ee(!1)}},children:[o.jsx(As,{className:"w-4 h-4"}),"Export as CSV"]}),o.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{le(!1),Ee(!0);try{const{blob:ue,filename:se}=await _e.exportArchives({format:"xlsx",printerId:a||void 0,status:X==="failed"?"failed":void 0,search:r||void 0}),Ve=URL.createObjectURL(ue),Be=document.createElement("a");Be.href=Ve,Be.download=se,Be.click(),URL.revokeObjectURL(Ve),e("Export downloaded")}catch{e("Export failed","error")}finally{Ee(!1)}},children:[o.jsx(B1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),B.size>=2&&B.size<=5&&o.jsxs(ke,{variant:"secondary",onClick:()=>de(!0),children:[o.jsx(dp,{className:"w-4 h-4"}),"Compare (",B.size,")"]}),!Te&&o.jsxs(ke,{variant:"secondary",onClick:()=>R(!0),children:[o.jsx(rf,{className:"w-4 h-4"}),"Select"]}),o.jsxs(ke,{onClick:()=>C(!0),children:[o.jsx(ca,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),o.jsx(Mt,{className:"mb-6",children:o.jsxs(At,{className:"py-4",children:[o.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[o.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[o.jsx(_l,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),o.jsx("input",{ref:n,type:"text",placeholder:"Search archives...",className:"w-full pl-10 pr-4 py-3 md:py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:ue=>i(ue.target.value)})]}),o.jsxs("div",{className:"flex gap-2 md:gap-4 overflow-x-auto pb-1 md:pb-0 -mx-4 px-4 md:mx-0 md:px-0 md:flex-wrap scrollbar-hide",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx(hR,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),o.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a||"",onChange:ue=>s(ue.target.value?Number(ue.target.value):null),children:[o.jsx("option",{value:"",children:"All Printers"}),Fe?.map(ue=>o.jsx("option",{value:ue.id,children:ue.name},ue.id))]})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx(zc,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),o.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:l||"",onChange:ue=>c(ue.target.value||null),children:[o.jsx("option",{value:"",children:"All Materials"}),G.map(ue=>o.jsx("option",{value:ue,children:ue},ue))]})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx(Zk,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),o.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:w,onChange:ue=>A(ue.target.value),children:[o.jsx("option",{value:"all",children:"All Files"}),o.jsx("option",{value:"gcode",children:"Sliced (GCODE)"}),o.jsx("option",{value:"source",children:"Source Only"})]})]}),o.jsxs("button",{onClick:()=>x(!p),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${p?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:p?"Show all":"Show favorites only",children:[o.jsx(Np,{className:`w-4 h-4 ${p?"fill-yellow-400":""}`}),o.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),o.jsxs("button",{onClick:()=>y(!v),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${v?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:v?"Show failed prints":"Hide failed prints",children:[o.jsx(Oa,{className:"w-4 h-4 "}),o.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),oe.length>0&&o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx(Cp,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),o.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:b||"",onChange:ue=>E(ue.target.value||null),children:[o.jsx("option",{value:"",children:"All Tags"}),oe.map(ue=>o.jsx("option",{value:ue,children:ue},ue))]})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx(Poe,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),o.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:z,onChange:ue=>V(ue.target.value),children:[o.jsx("option",{value:"date-desc",children:"Newest first"}),o.jsx("option",{value:"date-asc",children:"Oldest first"}),o.jsx("option",{value:"name-asc",children:"Name A-Z"}),o.jsx("option",{value:"name-desc",children:"Name Z-A"}),o.jsx("option",{value:"size-desc",children:"Largest first"}),o.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),o.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[o.jsx("button",{className:`p-2 ${ee==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>Q("grid"),title:"Grid view",children:o.jsx(tM,{className:"w-4 h-4"})}),o.jsx("button",{className:`p-2 ${ee==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>Q("list"),title:"List view",children:o.jsx(mR,{className:"w-4 h-4"})}),o.jsx("button",{className:`p-2 ${ee==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>Q("calendar"),title:"Calendar view",children:o.jsx(Voe,{className:"w-4 h-4"})})]})]}),ye&&o.jsxs(ke,{variant:"ghost",size:"sm",onClick:Se,className:"text-bambu-gray hover:text-white",children:[o.jsx(Wt,{className:"w-4 h-4"}),"Reset"]})]}),Z.length>0&&o.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[o.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),u.size>1&&o.jsx("button",{onClick:()=>g(ue=>ue==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${f==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:f==="or"?"Match ANY selected color":"Match ALL selected colors",children:f.toUpperCase()}),o.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:Z.map(ue=>o.jsx("button",{onClick:()=>ne(ue),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(ue)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:ue},title:ue},ue))}),u.size>0&&o.jsxs("button",{onClick:ve,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[o.jsx(Wt,{className:"w-3 h-3"}),"Clear"]})]})]})}),o.jsx(H7e,{}),fe?o.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):be?.length===0?o.jsx(Mt,{children:o.jsxs(At,{className:"text-center py-12",children:[o.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),o.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):ee==="calendar"?o.jsx(Mt,{className:"p-6",children:o.jsx(pze,{archives:be||[],onArchiveClick:ue=>{i(ue.print_name||ue.filename),Q("grid")}})}):ee==="grid"?o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:be?.map(ue=>o.jsx($7e,{archive:ue,printerName:ue.printer_id?re.get(ue.printer_id)||"Unknown":"No Printer",isSelected:B.has(ue.id),onSelect:Me,selectionMode:Te,projects:U},ue.id))}):ee==="list"?o.jsx(Mt,{children:o.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[o.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[o.jsx("div",{className:"col-span-1"}),o.jsx("div",{className:"col-span-4",children:"Name"}),o.jsx("div",{className:"col-span-2",children:"Printer"}),o.jsx("div",{className:"col-span-2",children:"Date"}),o.jsx("div",{className:"col-span-1",children:"Size"}),o.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),be?.map(ue=>o.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${B.has(ue.id)?"bg-bambu-green/10":""}`,children:[o.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[Te&&o.jsx("button",{onClick:()=>Me(ue.id),children:B.has(ue.id)?o.jsx(rf,{className:"w-4 h-4 text-bambu-green"}):o.jsx(af,{className:"w-4 h-4 text-bambu-gray"})}),ue.thumbnail_path?o.jsx("img",{src:_e.getArchiveThumbnail(ue.id),alt:"",className:"w-10 h-10 object-cover rounded"}):o.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:o.jsx(Nb,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),o.jsxs("div",{className:"col-span-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("p",{className:"text-white text-sm truncate",children:ue.print_name||ue.filename}),ue.timelapse_path&&o.jsx("span",{title:"Has timelapse",children:o.jsx(Oh,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),ue.filament_type&&o.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[o.jsx("span",{className:"text-xs text-bambu-gray",children:ue.filament_type}),ue.filament_color&&o.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:ue.filament_color.split(",").map((se,Ve)=>o.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:se},title:se},Ve))})]})]}),o.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:ue.printer_id?re.get(ue.printer_id)||"Unknown":"No Printer"}),o.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(ue.created_at).toLocaleDateString()}),o.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:$j(ue.file_size)}),o.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[o.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>{const se=ue.print_name||ue.filename||"model",Ve=`${window.location.origin}${_e.getArchiveForSlicer(ue.id,se)}`;bh(Ve)},title:"Slice",children:o.jsx(la,{className:"w-4 h-4"})}),ue.makerworld_url&&o.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>window.open(ue.makerworld_url,"_blank"),title:"MakerWorld",children:o.jsx(Ap,{className:"w-4 h-4"})}),o.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>{const se=document.createElement("a");se.href=_e.getArchiveDownload(ue.id),se.download=`${ue.print_name||ue.filename}.3mf`,se.click()},title:"Download",children:o.jsx(as,{className:"w-4 h-4"})})]})]},ue.id))]})}):null,T&&o.jsx(aze,{onClose:()=>{C(!1),O([])},initialFiles:N}),q&&o.jsx(br,{title:"Delete Archives",message:`Are you sure you want to delete ${B.size} archive${B.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${B.size}`,variant:"danger",onConfirm:()=>{H.mutate(Array.from(B)),W(!1)},onCancel:()=>W(!1)}),$&&o.jsx(uze,{selectedIds:Array.from(B),existingTags:oe,onClose:()=>J(!1)}),pe&&B.size>=2&&B.size<=5&&o.jsx(I7e,{archiveIds:Array.from(B),onClose:()=>{de(!1),L(new Set),R(!1)}})]})}function W7e(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return S.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const ME=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Eg(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function IL(t){return"nodeType"in t}function us(t){var e,n;return t?Eg(t)?t:IL(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function FL(t){const{Document:e}=us(t);return t instanceof e}function fy(t){return Eg(t)?!1:t instanceof us(t).HTMLElement}function gte(t){return t instanceof us(t).SVGElement}function Ag(t){return t?Eg(t)?t.document:IL(t)?FL(t)?t:fy(t)||gte(t)?t.ownerDocument:document:document:document}const kl=ME?S.useLayoutEffect:S.useEffect;function UL(t){const e=S.useRef(t);return kl(()=>{e.current=t}),S.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function q7e(){const t=S.useRef(null),e=S.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=S.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function yb(t,e){e===void 0&&(e=[t]);const n=S.useRef(t);return kl(()=>{n.current!==t&&(n.current=t)},e),n}function my(t,e){const n=S.useRef();return S.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function VS(t){const e=UL(t),n=S.useRef(null),r=S.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function Vj(t){const e=S.useRef();return S.useEffect(()=>{e.current=t},[t]),e.current}let Ak={};function py(t,e){return S.useMemo(()=>{if(e)return e;const n=Ak[t]==null?0:Ak[t]+1;return Ak[t]=n,t+"-"+n},[t,e])}function xte(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((a,s)=>{const l=Object.entries(s);for(const[c,u]of l){const d=a[c];d!=null&&(a[c]=d+t*u)}return a},{...e})}}const Sp=xte(1),vb=xte(-1);function K7e(t){return"clientX"in t&&"clientY"in t}function zL(t){if(!t)return!1;const{KeyboardEvent:e}=us(t.target);return e&&t instanceof e}function X7e(t){if(!t)return!1;const{TouchEvent:e}=us(t.target);return e&&t instanceof e}function Gj(t){if(X7e(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:n}=t.touches[0];return{x:e,y:n}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:n}=t.changedTouches[0];return{x:e,y:n}}}return K7e(t)?{x:t.clientX,y:t.clientY}:null}const eg=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[eg.Translate.toString(t),eg.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),LG="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Y7e(t){return t.matches(LG)?t:t.querySelector(LG)}const Z7e={display:"none"};function Q7e(t){let{id:e,value:n}=t;return Cr.createElement("div",{id:e,style:Z7e},n)}function J7e(t){let{id:e,announcement:n,ariaLiveType:r="assertive"}=t;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Cr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function eGe(){const[t,e]=S.useState("");return{announce:S.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const bte=S.createContext(null);function tGe(t){const e=S.useContext(bte);S.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function nGe(){const[t]=S.useState(()=>new Set),e=S.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[S.useCallback(r=>{let{type:i,event:a}=r;t.forEach(s=>{var l;return(l=s[i])==null?void 0:l.call(s,a)})},[t]),e]}const rGe={draggable:`
- To pick up a draggable item, press the space bar.
- While dragging, use the arrow keys to move the item.
- Press space again to drop the item in its new position, or press escape to cancel.
- `},iGe={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function aGe(t){let{announcements:e=iGe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=rGe}=t;const{announce:a,announcement:s}=eGe(),l=py("DndLiveRegion"),[c,u]=S.useState(!1);if(S.useEffect(()=>{u(!0)},[]),tGe(S.useMemo(()=>({onDragStart(f){let{active:g}=f;a(e.onDragStart({active:g}))},onDragMove(f){let{active:g,over:p}=f;e.onDragMove&&a(e.onDragMove({active:g,over:p}))},onDragOver(f){let{active:g,over:p}=f;a(e.onDragOver({active:g,over:p}))},onDragEnd(f){let{active:g,over:p}=f;a(e.onDragEnd({active:g,over:p}))},onDragCancel(f){let{active:g,over:p}=f;a(e.onDragCancel({active:g,over:p}))}}),[a,e])),!c)return null;const d=Cr.createElement(Cr.Fragment,null,Cr.createElement(Q7e,{id:r,value:i.draggable}),Cr.createElement(J7e,{id:l,announcement:s}));return n?Mc.createPortal(d,n):d}var yi;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(yi||(yi={}));function GS(){}function WS(t,e){return S.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function yte(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return S.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const Wo=Object.freeze({x:0,y:0});function vte(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function _te(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function sGe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function IG(t){let{left:e,top:n,height:r,width:i}=t;return[{x:e,y:n},{x:e+i,y:n},{x:e,y:n+r},{x:e+i,y:n+r}]}function wte(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function FG(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+t.width*.5,y:n+t.height*.5}}const Ste=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=FG(e,e.left,e.top),a=[];for(const s of r){const{id:l}=s,c=n.get(l);if(c){const u=vte(FG(c),i);a.push({id:l,data:{droppableContainer:s,value:u}})}}return a.sort(_te)},oGe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=IG(e),a=[];for(const s of r){const{id:l}=s,c=n.get(l);if(c){const u=IG(c),d=i.reduce((g,p,x)=>g+vte(u[x],p),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:s,value:f}})}}return a.sort(_te)};function lGe(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height),s=i-r,l=a-n;if(r<i&&n<a){const c=e.width*e.height,u=t.width*t.height,d=s*l,f=d/(c+u-d);return Number(f.toFixed(4))}return 0}const cGe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const a of r){const{id:s}=a,l=n.get(s);if(l){const c=lGe(l,e);c>0&&i.push({id:s,data:{droppableContainer:a,value:c}})}}return i.sort(sGe)};function uGe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function Mte(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Wo}function dGe(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return i.reduce((s,l)=>({...s,top:s.top+t*l.y,bottom:s.bottom+t*l.y,left:s.left+t*l.x,right:s.right+t*l.x}),{...n})}}const hGe=dGe(1);function fGe(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function mGe(t,e,n){const r=fGe(e);if(!r)return t;const{scaleX:i,scaleY:a,x:s,y:l}=r,c=t.left-s-(1-i)*parseFloat(n),u=t.top-l-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,f=a?t.height/a:t.height;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c}}const pGe={ignoreTransform:!1};function Tg(t,e){e===void 0&&(e=pGe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=us(t).getComputedStyle(t);u&&(n=mGe(n,u,d))}const{top:r,left:i,width:a,height:s,bottom:l,right:c}=n;return{top:r,left:i,width:a,height:s,bottom:l,right:c}}function UG(t){return Tg(t,{ignoreTransform:!0})}function gGe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function xGe(t,e){return e===void 0&&(e=us(t).getComputedStyle(t)),e.position==="fixed"}function bGe(t,e){e===void 0&&(e=us(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const a=e[i];return typeof a=="string"?n.test(a):!1})}function EE(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(FL(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!fy(i)||gte(i)||n.includes(i))return n;const a=us(t).getComputedStyle(i);return i!==t&&bGe(i,a)&&n.push(i),xGe(i,a)?n:r(i.parentNode)}return t?r(t):n}function Ete(t){const[e]=EE(t,1);return e??null}function Tk(t){return!ME||!t?null:Eg(t)?t:IL(t)?FL(t)||t===Ag(t).scrollingElement?window:fy(t)?t:null:null}function Ate(t){return Eg(t)?t.scrollX:t.scrollLeft}function Tte(t){return Eg(t)?t.scrollY:t.scrollTop}function Wj(t){return{x:Ate(t),y:Tte(t)}}var zi;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(zi||(zi={}));function Nte(t){return!ME||!t?!1:t===document.scrollingElement}function Cte(t){const e={x:0,y:0},n=Nte(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,a=t.scrollLeft<=e.x,s=t.scrollTop>=r.y,l=t.scrollLeft>=r.x;return{isTop:i,isLeft:a,isBottom:s,isRight:l,maxScroll:r,minScroll:e}}const yGe={x:.2,y:.2};function vGe(t,e,n,r,i){let{top:a,left:s,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=yGe);const{isTop:u,isBottom:d,isLeft:f,isRight:g}=Cte(t),p={x:0,y:0},x={x:0,y:0},v={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+v.height?(p.y=zi.Backward,x.y=r*Math.abs((e.top+v.height-a)/v.height)):!d&&c>=e.bottom-v.height&&(p.y=zi.Forward,x.y=r*Math.abs((e.bottom-v.height-c)/v.height)),!g&&l>=e.right-v.width?(p.x=zi.Forward,x.x=r*Math.abs((e.right-v.width-l)/v.width)):!f&&s<=e.left+v.width&&(p.x=zi.Backward,x.x=r*Math.abs((e.left+v.width-s)/v.width)),{direction:p,speed:x}}function _Ge(t){if(t===document.scrollingElement){const{innerWidth:a,innerHeight:s}=window;return{top:0,left:0,right:a,bottom:s,width:a,height:s}}const{top:e,left:n,right:r,bottom:i}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:t.clientWidth,height:t.clientHeight}}function kte(t){return t.reduce((e,n)=>Sp(e,Wj(n)),Wo)}function wGe(t){return t.reduce((e,n)=>e+Ate(n),0)}function SGe(t){return t.reduce((e,n)=>e+Tte(n),0)}function MGe(t,e){if(e===void 0&&(e=Tg),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);Ete(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const EGe=[["x",["left","right"],wGe],["y",["top","bottom"],SGe]];class BL{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=EE(n),i=kte(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,s,l]of EGe)for(const c of s)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=i[a]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class E0{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var i;(i=this.target)==null||i.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function AGe(t){const{EventTarget:e}=us(t);return t instanceof e?t:Ag(t)}function Nk(t,e){const n=Math.abs(t.x),r=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+r**2)>e:"x"in e&&"y"in e?n>e.x&&r>e.y:"x"in e?n>e.x:"y"in e?r>e.y:!1}var eo;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(eo||(eo={}));function zG(t){t.preventDefault()}function TGe(t){t.stopPropagation()}var kn;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(kn||(kn={}));const Pte={start:[kn.Space,kn.Enter],cancel:[kn.Esc],end:[kn.Space,kn.Enter,kn.Tab]},NGe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case kn.Right:return{...n,x:n.x+25};case kn.Left:return{...n,x:n.x-25};case kn.Down:return{...n,y:n.y+25};case kn.Up:return{...n,y:n.y-25}}};class AE{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new E0(Ag(n)),this.windowListeners=new E0(us(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(eo.Resize,this.handleCancel),this.windowListeners.add(eo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(eo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&MGe(r),n(Wo)}handleKeyDown(e){if(zL(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=Pte,coordinateGetter:s=NGe,scrollBehavior:l="smooth"}=i,{code:c}=e;if(a.end.includes(c)){this.handleEnd(e);return}if(a.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:Wo;this.referenceCoordinates||(this.referenceCoordinates=d);const f=s(e,{active:n,context:r.current,currentCoordinates:d});if(f){const g=vb(f,d),p={x:0,y:0},{scrollableAncestors:x}=r.current;for(const v of x){const y=e.code,{isTop:b,isRight:E,isLeft:w,isBottom:A,maxScroll:T,minScroll:C}=Cte(v),N=_Ge(v),O={x:Math.min(y===kn.Right?N.right-N.width/2:N.right,Math.max(y===kn.Right?N.left:N.left+N.width/2,f.x)),y:Math.min(y===kn.Down?N.bottom-N.height/2:N.bottom,Math.max(y===kn.Down?N.top:N.top+N.height/2,f.y))},k=y===kn.Right&&!E||y===kn.Left&&!w,j=y===kn.Down&&!A||y===kn.Up&&!b;if(k&&O.x!==f.x){const B=v.scrollLeft+g.x,L=y===kn.Right&&B<=T.x||y===kn.Left&&B>=C.x;if(L&&!g.y){v.scrollTo({left:B,behavior:l});return}L?p.x=v.scrollLeft-B:p.x=y===kn.Right?v.scrollLeft-T.x:v.scrollLeft-C.x,p.x&&v.scrollBy({left:-p.x,behavior:l});break}else if(j&&O.y!==f.y){const B=v.scrollTop+g.y,L=y===kn.Down&&B<=T.y||y===kn.Up&&B>=C.y;if(L&&!g.x){v.scrollTo({top:B,behavior:l});return}L?p.y=v.scrollTop-B:p.y=y===kn.Down?v.scrollTop-T.y:v.scrollTop-C.y,p.y&&v.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,Sp(vb(f,this.referenceCoordinates),p))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}AE.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Pte,onActivation:i}=e,{active:a}=n;const{code:s}=t.nativeEvent;if(r.start.includes(s)){const l=a.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function BG(t){return!!(t&&"distance"in t)}function HG(t){return!!(t&&"delay"in t)}class HL{constructor(e,n,r){var i;r===void 0&&(r=AGe(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:a}=e,{target:s}=a;this.props=e,this.events=n,this.document=Ag(s),this.documentListeners=new E0(this.document),this.listeners=new E0(r),this.windowListeners=new E0(us(s)),this.initialCoordinates=(i=Gj(a))!=null?i:Wo,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(eo.Resize,this.handleCancel),this.windowListeners.add(eo.DragStart,zG),this.windowListeners.add(eo.VisibilityChange,this.handleCancel),this.windowListeners.add(eo.ContextMenu,zG),this.documentListeners.add(eo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(HG(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(BG(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:r,onPending:i}=this.props;i(r,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(eo.Click,TGe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(eo.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:s,options:{activationConstraint:l}}=a;if(!i)return;const c=(n=Gj(e))!=null?n:Wo,u=vb(i,c);if(!r&&l){if(BG(l)){if(l.tolerance!=null&&Nk(u,l.tolerance))return this.handleCancel();if(Nk(u,l.distance))return this.handleStart()}if(HG(l)&&Nk(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}e.cancelable&&e.preventDefault(),s(c)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===kn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const CGe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class TE extends HL{constructor(e){const{event:n}=e,r=Ag(n.target);super(e,CGe,r)}}TE.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const kGe={move:{name:"mousemove"},end:{name:"mouseup"}};var qj;(function(t){t[t.RightClick=2]="RightClick"})(qj||(qj={}));class PGe extends HL{constructor(e){super(e,kGe,Ag(e.event.target))}}PGe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===qj.RightClick?!1:(r?.({event:n}),!0)}}];const Ck={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class jGe extends HL{constructor(e){super(e,Ck)}static setup(){return window.addEventListener(Ck.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Ck.move.name,e)};function e(){}}}jGe.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;const{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var A0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(A0||(A0={}));var qS;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(qS||(qS={}));function RGe(t){let{acceleration:e,activator:n=A0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:s=5,order:l=qS.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:g}=t;const p=OGe({delta:f,disabled:!a}),[x,v]=q7e(),y=S.useRef({x:0,y:0}),b=S.useRef({x:0,y:0}),E=S.useMemo(()=>{switch(n){case A0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case A0.DraggableRect:return i}},[n,i,c]),w=S.useRef(null),A=S.useCallback(()=>{const C=w.current;if(!C)return;const N=y.current.x*b.current.x,O=y.current.y*b.current.y;C.scrollBy(N,O)},[]),T=S.useMemo(()=>l===qS.TreeOrder?[...u].reverse():u,[l,u]);S.useEffect(()=>{if(!a||!u.length||!E){v();return}for(const C of T){if(r?.(C)===!1)continue;const N=u.indexOf(C),O=d[N];if(!O)continue;const{direction:k,speed:j}=vGe(C,O,E,e,g);for(const B of["x","y"])p[B][k[B]]||(j[B]=0,k[B]=0);if(j.x>0||j.y>0){v(),w.current=C,x(A,s),y.current=j,b.current=k;return}}y.current={x:0,y:0},b.current={x:0,y:0},v()},[e,A,r,v,a,s,JSON.stringify(E),JSON.stringify(p),x,u,T,d,JSON.stringify(g)])}const DGe={x:{[zi.Backward]:!1,[zi.Forward]:!1},y:{[zi.Backward]:!1,[zi.Forward]:!1}};function OGe(t){let{delta:e,disabled:n}=t;const r=Vj(e);return my(i=>{if(n||!r||!i)return DGe;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[zi.Backward]:i.x[zi.Backward]||a.x===-1,[zi.Forward]:i.x[zi.Forward]||a.x===1},y:{[zi.Backward]:i.y[zi.Backward]||a.y===-1,[zi.Forward]:i.y[zi.Forward]||a.y===1}}},[n,e,r])}function LGe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return my(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function IGe(t,e){return S.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,a=i.activators.map(s=>({eventName:s.eventName,handler:e(s.handler,r)}));return[...n,...a]},[]),[t,e])}var _b;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(_b||(_b={}));var Kj;(function(t){t.Optimized="optimized"})(Kj||(Kj={}));const $G=new Map;function FGe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,s]=S.useState(null),{frequency:l,measure:c,strategy:u}=i,d=S.useRef(t),f=y(),g=yb(f),p=S.useCallback(function(b){b===void 0&&(b=[]),!g.current&&s(E=>E===null?b:E.concat(b.filter(w=>!E.includes(w))))},[g]),x=S.useRef(null),v=my(b=>{if(f&&!n)return $G;if(!b||b===$G||d.current!==t||a!=null){const E=new Map;for(let w of t){if(!w)continue;if(a&&a.length>0&&!a.includes(w.id)&&w.rect.current){E.set(w.id,w.rect.current);continue}const A=w.node.current,T=A?new BL(c(A),A):null;w.rect.current=T,T&&E.set(w.id,T)}return E}return b},[t,a,n,f,c]);return S.useEffect(()=>{d.current=t},[t]),S.useEffect(()=>{f||p()},[n,f]),S.useEffect(()=>{a&&a.length>0&&s(null)},[JSON.stringify(a)]),S.useEffect(()=>{f||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{p(),x.current=null},l))},[l,f,p,...r]),{droppableRects:v,measureDroppableContainers:p,measuringScheduled:a!=null};function y(){switch(u){case _b.Always:return!1;case _b.BeforeDragging:return n;default:return!n}}}function jte(t,e){return my(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function UGe(t,e){return jte(t,e)}function zGe(t){let{callback:e,disabled:n}=t;const r=UL(e),i=S.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return S.useEffect(()=>()=>i?.disconnect(),[i]),i}function NE(t){let{callback:e,disabled:n}=t;const r=UL(e),i=S.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return S.useEffect(()=>()=>i?.disconnect(),[i]),i}function BGe(t){return new BL(Tg(t),t)}function VG(t,e,n){e===void 0&&(e=BGe);const[r,i]=S.useState(null);function a(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const s=zGe({callback(c){if(t)for(const u of c){const{type:d,target:f}=u;if(d==="childList"&&f instanceof HTMLElement&&f.contains(t)){a();break}}}}),l=NE({callback:a});return kl(()=>{a(),t?(l?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),s?.disconnect())},[t]),r}function HGe(t){const e=jte(t);return Mte(t,e)}const GG=[];function $Ge(t){const e=S.useRef(t),n=my(r=>t?r&&r!==GG&&t&&e.current&&t.parentNode===e.current.parentNode?r:EE(t):GG,[t]);return S.useEffect(()=>{e.current=t},[t]),n}function VGe(t){const[e,n]=S.useState(null),r=S.useRef(t),i=S.useCallback(a=>{const s=Tk(a.target);s&&n(l=>l?(l.set(s,Wj(s)),new Map(l)):null)},[]);return S.useEffect(()=>{const a=r.current;if(t!==a){s(a);const l=t.map(c=>{const u=Tk(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,Wj(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=t}return()=>{s(t),s(a)};function s(l){l.forEach(c=>{const u=Tk(c);u?.removeEventListener("scroll",i)})}},[i,t]),S.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,s)=>Sp(a,s),Wo):kte(t):Wo,[t,e])}function WG(t,e){e===void 0&&(e=[]);const n=S.useRef(null);return S.useEffect(()=>{n.current=null},e),S.useEffect(()=>{const r=t!==Wo;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?vb(t,n.current):Wo}function GGe(t){S.useEffect(()=>{if(!ME)return;const e=t.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of e)n?.()}},t.map(e=>{let{sensor:n}=e;return n}))}function WGe(t,e){return S.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=s=>{a(s,e)},n},{}),[t,e])}function Rte(t){return S.useMemo(()=>t?gGe(t):null,[t])}const qG=[];function qGe(t,e){e===void 0&&(e=Tg);const[n]=t,r=Rte(n?us(n):null),[i,a]=S.useState(qG);function s(){a(()=>t.length?t.map(c=>Nte(c)?r:new BL(e(c),c)):qG)}const l=NE({callback:s});return kl(()=>{l?.disconnect(),s(),t.forEach(c=>l?.observe(c))},[t]),i}function KGe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return fy(e)?e:t}function XGe(t){let{measure:e}=t;const[n,r]=S.useState(null),i=S.useCallback(u=>{for(const{target:d}of u)if(fy(d)){r(f=>{const g=e(d);return f?{...f,width:g.width,height:g.height}:g});break}},[e]),a=NE({callback:i}),s=S.useCallback(u=>{const d=KGe(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=VS(s);return S.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const YGe=[{sensor:TE,options:{}},{sensor:AE,options:{}}],ZGe={current:{}},D1={draggable:{measure:UG},droppable:{measure:UG,strategy:_b.WhileDragging,frequency:Kj.Optimized},dragOverlay:{measure:Tg}};class T0 extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,r;return(n=(r=this.get(e))==null?void 0:r.node.current)!=null?n:void 0}}const QGe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new T0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:GS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:D1,measureDroppableContainers:GS,windowRect:null,measuringScheduled:!1},JGe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:GS,draggableNodes:new Map,over:null,measureDroppableContainers:GS},CE=S.createContext(JGe),Dte=S.createContext(QGe);function e9e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new T0}}}function t9e(t,e){switch(e.type){case yi.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case yi.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case yi.DragEnd:case yi.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case yi.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new T0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case yi.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const s=new T0(t.droppable.containers);return s.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:s}}}case yi.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new T0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function n9e(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=S.useContext(CE),a=Vj(r),s=Vj(n?.id);return S.useEffect(()=>{if(!e&&!r&&a&&s!=null){if(!zL(a)||document.activeElement===a.target)return;const l=i.get(s);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const f=Y7e(d);if(f){f.focus();break}}})}},[r,e,i,s,a]),null}function r9e(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function i9e(t){return S.useMemo(()=>({draggable:{...D1.draggable,...t?.draggable},droppable:{...D1.droppable,...t?.droppable},dragOverlay:{...D1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function a9e(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=S.useRef(!1),{x:s,y:l}=typeof i=="boolean"?{x:i,y:i}:i;kl(()=>{if(!s&&!l||!e){a.current=!1;return}if(a.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),f=Mte(d,r);if(s||(f.x=0),l||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const g=Ete(u);g&&g.scrollBy({top:f.y,left:f.x})}},[e,s,l,r,n])}const Ote=S.createContext({...Wo,scaleX:1,scaleY:1});var Ku;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Ku||(Ku={}));const Lte=S.memo(function(e){var n,r,i,a;let{id:s,accessibility:l,autoScroll:c=!0,children:u,sensors:d=YGe,collisionDetection:f=cGe,measuring:g,modifiers:p,...x}=e;const v=S.useReducer(t9e,void 0,e9e),[y,b]=v,[E,w]=nGe(),[A,T]=S.useState(Ku.Uninitialized),C=A===Ku.Initialized,{draggable:{active:N,nodes:O,translate:k},droppable:{containers:j}}=y,B=N!=null?O.get(N):null,L=S.useRef({initial:null,translated:null}),K=S.useMemo(()=>{var He;return N!=null?{id:N,data:(He=B?.data)!=null?He:ZGe,rect:L}:null},[N,B]),R=S.useRef(null),[q,W]=S.useState(null),[$,J]=S.useState(null),ee=yb(x,Object.values(x)),Q=py("DndDescribedBy",s),z=S.useMemo(()=>j.getEnabled(),[j]),V=i9e(g),{droppableRects:X,measureDroppableContainers:te,measuringScheduled:ie}=FGe(z,{dragging:C,dependencies:[k.x,k.y],config:V.droppable}),le=LGe(O,N),ge=S.useMemo(()=>$?Gj($):null,[$]),Ee=xe(),pe=UGe(le,V.draggable.measure);a9e({activeNode:N!=null?O.get(N):null,config:Ee.layoutShiftCompensation,initialRect:pe,measure:V.draggable.measure});const de=VG(le,V.draggable.measure,pe),Re=VG(le?le.parentElement:null),fe=S.useRef({activatorEvent:null,active:null,activeNode:le,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:O,draggingNode:null,draggingNodeRect:null,droppableContainers:j,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Fe=j.getNodeFor((n=fe.current.over)==null?void 0:n.id),U=XGe({measure:V.dragOverlay.measure}),H=(r=U.nodeRef.current)!=null?r:le,re=C?(i=U.rect)!=null?i:de:null,G=!!(U.nodeRef.current&&U.rect),Z=HGe(G?null:de),oe=Rte(H?us(H):null),be=$Ge(C?Fe??le:null),Te=qGe(be),Me=r9e(p,{transform:{x:k.x-Z.x,y:k.y-Z.y,scaleX:1,scaleY:1},activatorEvent:$,active:K,activeNodeRect:de,containerNodeRect:Re,draggingNodeRect:re,over:fe.current.over,overlayNodeRect:U.rect,scrollableAncestors:be,scrollableAncestorRects:Te,windowRect:oe}),F=ge?Sp(ge,k):null,I=VGe(be),ne=WG(I),ve=WG(I,[de]),Se=Sp(Me,ne),ye=re?hGe(re,Me):null,Ke=K&&ye?f({active:K,collisionRect:ye,droppableRects:X,droppableContainers:z,pointerCoordinates:F}):null,We=wte(Ke,"id"),[qe,ut]=S.useState(null),ue=G?Me:Sp(Me,ve),se=uGe(ue,(a=qe?.rect)!=null?a:null,de),Ve=S.useRef(null),Be=S.useCallback((He,Pe)=>{let{sensor:we,options:Ae}=Pe;if(R.current==null)return;const lt=O.get(R.current);if(!lt)return;const _t=He.nativeEvent,Xe=new we({active:R.current,activeNode:lt,event:_t,options:Ae,context:fe,onAbort(Ct){if(!O.get(Ct))return;const{onDragAbort:gn}=ee.current,Fn={id:Ct};gn?.(Fn),E({type:"onDragAbort",event:Fn})},onPending(Ct,$t,gn,Fn){if(!O.get(Ct))return;const{onDragPending:Yt}=ee.current,Jn={id:Ct,constraint:$t,initialCoordinates:gn,offset:Fn};Yt?.(Jn),E({type:"onDragPending",event:Jn})},onStart(Ct){const $t=R.current;if($t==null)return;const gn=O.get($t);if(!gn)return;const{onDragStart:Fn}=ee.current,It={activatorEvent:_t,active:{id:$t,data:gn.data,rect:L}};Mc.unstable_batchedUpdates(()=>{Fn?.(It),T(Ku.Initializing),b({type:yi.DragStart,initialCoordinates:Ct,active:$t}),E({type:"onDragStart",event:It}),W(Ve.current),J(_t)})},onMove(Ct){b({type:yi.DragMove,coordinates:Ct})},onEnd:Ut(yi.DragEnd),onCancel:Ut(yi.DragCancel)});Ve.current=Xe;function Ut(Ct){return async function(){const{active:gn,collisions:Fn,over:It,scrollAdjustedTranslate:Yt}=fe.current;let Jn=null;if(gn&&Yt){const{cancelDrop:er}=ee.current;Jn={activatorEvent:_t,active:gn,collisions:Fn,delta:Yt,over:It},Ct===yi.DragEnd&&typeof er=="function"&&await Promise.resolve(er(Jn))&&(Ct=yi.DragCancel)}R.current=null,Mc.unstable_batchedUpdates(()=>{b({type:Ct}),T(Ku.Uninitialized),ut(null),W(null),J(null),Ve.current=null;const er=Ct===yi.DragEnd?"onDragEnd":"onDragCancel";if(Jn){const Hn=ee.current[er];Hn?.(Jn),E({type:er,event:Jn})}})}}},[O]),Ze=S.useCallback((He,Pe)=>(we,Ae)=>{const lt=we.nativeEvent,_t=O.get(Ae);if(R.current!==null||!_t||lt.dndKit||lt.defaultPrevented)return;const Xe={active:_t};He(we,Pe.options,Xe)===!0&&(lt.dndKit={capturedBy:Pe.sensor},R.current=Ae,Be(we,Pe))},[O,Be]),ht=IGe(d,Ze);GGe(d),kl(()=>{de&&A===Ku.Initializing&&T(Ku.Initialized)},[de,A]),S.useEffect(()=>{const{onDragMove:He}=ee.current,{active:Pe,activatorEvent:we,collisions:Ae,over:lt}=fe.current;if(!Pe||!we)return;const _t={active:Pe,activatorEvent:we,collisions:Ae,delta:{x:Se.x,y:Se.y},over:lt};Mc.unstable_batchedUpdates(()=>{He?.(_t),E({type:"onDragMove",event:_t})})},[Se.x,Se.y]),S.useEffect(()=>{const{active:He,activatorEvent:Pe,collisions:we,droppableContainers:Ae,scrollAdjustedTranslate:lt}=fe.current;if(!He||R.current==null||!Pe||!lt)return;const{onDragOver:_t}=ee.current,Xe=Ae.get(We),Ut=Xe&&Xe.rect.current?{id:Xe.id,rect:Xe.rect.current,data:Xe.data,disabled:Xe.disabled}:null,Ct={active:He,activatorEvent:Pe,collisions:we,delta:{x:lt.x,y:lt.y},over:Ut};Mc.unstable_batchedUpdates(()=>{ut(Ut),_t?.(Ct),E({type:"onDragOver",event:Ct})})},[We]),kl(()=>{fe.current={activatorEvent:$,active:K,activeNode:le,collisionRect:ye,collisions:Ke,droppableRects:X,draggableNodes:O,draggingNode:H,draggingNodeRect:re,droppableContainers:j,over:qe,scrollableAncestors:be,scrollAdjustedTranslate:Se},L.current={initial:re,translated:ye}},[K,le,Ke,ye,O,H,re,X,j,qe,be,Se]),RGe({...Ee,delta:k,draggingRect:ye,pointerCoordinates:F,scrollableAncestors:be,scrollableAncestorRects:Te});const me=S.useMemo(()=>({active:K,activeNode:le,activeNodeRect:de,activatorEvent:$,collisions:Ke,containerNodeRect:Re,dragOverlay:U,draggableNodes:O,droppableContainers:j,droppableRects:X,over:qe,measureDroppableContainers:te,scrollableAncestors:be,scrollableAncestorRects:Te,measuringConfiguration:V,measuringScheduled:ie,windowRect:oe}),[K,le,de,$,Ke,Re,U,O,j,X,qe,te,be,Te,V,ie,oe]),nt=S.useMemo(()=>({activatorEvent:$,activators:ht,active:K,activeNodeRect:de,ariaDescribedById:{draggable:Q},dispatch:b,draggableNodes:O,over:qe,measureDroppableContainers:te}),[$,ht,K,de,b,Q,O,qe,te]);return Cr.createElement(bte.Provider,{value:w},Cr.createElement(CE.Provider,{value:nt},Cr.createElement(Dte.Provider,{value:me},Cr.createElement(Ote.Provider,{value:se},u)),Cr.createElement(n9e,{disabled:l?.restoreFocus===!1})),Cr.createElement(aGe,{...l,hiddenTextDescribedById:Q}));function xe(){const He=q?.autoScrollEnabled===!1,Pe=typeof c=="object"?c.enabled===!1:c===!1,we=C&&!He&&!Pe;return typeof c=="object"?{...c,enabled:we}:{enabled:we}}}),s9e=S.createContext(null),KG="button",o9e="Draggable";function l9e(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=py(o9e),{activators:s,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:g}=S.useContext(CE),{role:p=KG,roleDescription:x="draggable",tabIndex:v=0}=i??{},y=c?.id===e,b=S.useContext(y?Ote:s9e),[E,w]=VS(),[A,T]=VS(),C=WGe(s,e),N=yb(n);kl(()=>(f.set(e,{id:e,key:a,node:E,activatorNode:A,data:N}),()=>{const k=f.get(e);k&&k.key===a&&f.delete(e)}),[f,e]);const O=S.useMemo(()=>({role:p,tabIndex:v,"aria-disabled":r,"aria-pressed":y&&p===KG?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,p,v,y,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:O,isDragging:y,listeners:r?void 0:C,node:E,over:g,setNodeRef:w,setActivatorNodeRef:T,transform:b}}function c9e(){return S.useContext(Dte)}const u9e="Droppable",d9e={timeout:25};function h9e(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=py(u9e),{active:s,dispatch:l,over:c,measureDroppableContainers:u}=S.useContext(CE),d=S.useRef({disabled:n}),f=S.useRef(!1),g=S.useRef(null),p=S.useRef(null),{disabled:x,updateMeasurementsFor:v,timeout:y}={...d9e,...i},b=yb(v??r),E=S.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(b.current)?b.current:[b.current]),p.current=null},y)},[y]),w=NE({callback:E,disabled:x||!s}),A=S.useCallback((O,k)=>{w&&(k&&(w.unobserve(k),f.current=!1),O&&w.observe(O))},[w]),[T,C]=VS(A),N=yb(e);return S.useEffect(()=>{!w||!T.current||(w.disconnect(),f.current=!1,w.observe(T.current))},[T,w]),S.useEffect(()=>(l({type:yi.RegisterDroppable,element:{id:r,key:a,disabled:n,node:T,rect:g,data:N}}),()=>l({type:yi.UnregisterDroppable,key:a,id:r})),[r]),S.useEffect(()=>{n!==d.current.disabled&&(l({type:yi.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,l]),{active:s,rect:g,isOver:c?.id===r,node:T,over:c,setNodeRef:C}}function kE(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function f9e(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function a1(t){return t!==null&&t>=0}function m9e(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function p9e(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const $L=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=kE(e,r,n),s=e[i],l=a[i];return!l||!s?null:{x:l.left-s.left,y:l.top-s.top,scaleX:l.width/s.width,scaleY:l.height/s.height}},s1={scaleX:1,scaleY:1},g9e=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:a,overIndex:s}=t;const l=(e=a[n])!=null?e:r;if(!l)return null;if(i===n){const u=a[s];return u?{x:0,y:n<s?u.top+u.height-(l.top+l.height):u.top-l.top,...s1}:null}const c=x9e(a,i,n);return i>n&&i<=s?{x:0,y:-l.height-c,...s1}:i<n&&i>=s?{x:0,y:l.height+c,...s1}:{x:0,y:0,...s1}};function x9e(t,e,n){const r=t[e],i=t[e-1],a=t[e+1];return r?n<e?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const Ite="Sortable",Fte=Cr.createContext({activeIndex:-1,containerId:Ite,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:$L,disabled:{draggable:!1,droppable:!1}});function Ute(t){let{children:e,id:n,items:r,strategy:i=$L,disabled:a=!1}=t;const{active:s,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=c9e(),f=py(Ite,n),g=l.rect!==null,p=S.useMemo(()=>r.map(C=>typeof C=="object"&&"id"in C?C.id:C),[r]),x=s!=null,v=s?p.indexOf(s.id):-1,y=u?p.indexOf(u.id):-1,b=S.useRef(p),E=!m9e(p,b.current),w=y!==-1&&v===-1||E,A=p9e(a);kl(()=>{E&&x&&d(p)},[E,p,x,d]),S.useEffect(()=>{b.current=p},[p]);const T=S.useMemo(()=>({activeIndex:v,containerId:f,disabled:A,disableTransforms:w,items:p,overIndex:y,useDragOverlay:g,sortedRects:f9e(p,c),strategy:i}),[v,f,A.draggable,A.droppable,w,p,y,c,g,i]);return Cr.createElement(Fte.Provider,{value:T},e)}const b9e=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return kE(n,r,i).indexOf(e)},y9e=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:a,newIndex:s,previousItems:l,previousContainerId:c,transition:u}=t;return!u||!r||l!==a&&i===s?!1:n?!0:s!==i&&e===c},v9e={duration:200,easing:"ease"},zte="transform",_9e=eg.Transition.toString({property:zte,duration:0,easing:"linear"}),w9e={roleDescription:"sortable"};function S9e(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,s]=S.useState(null),l=S.useRef(n);return kl(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=Tg(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&s(d)}}n!==l.current&&(l.current=n)},[e,n,r,i]),S.useEffect(()=>{a&&s(null)},[a]),a}function Bte(t){let{animateLayoutChanges:e=y9e,attributes:n,disabled:r,data:i,getNewIndex:a=b9e,id:s,strategy:l,resizeObserverConfig:c,transition:u=v9e}=t;const{items:d,containerId:f,activeIndex:g,disabled:p,disableTransforms:x,sortedRects:v,overIndex:y,useDragOverlay:b,strategy:E}=S.useContext(Fte),w=M9e(r,p),A=d.indexOf(s),T=S.useMemo(()=>({sortable:{containerId:f,index:A,items:d},...i}),[f,i,A,d]),C=S.useMemo(()=>d.slice(d.indexOf(s)),[d,s]),{rect:N,node:O,isOver:k,setNodeRef:j}=h9e({id:s,data:T,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:B,activatorEvent:L,activeNodeRect:K,attributes:R,setNodeRef:q,listeners:W,isDragging:$,over:J,setActivatorNodeRef:ee,transform:Q}=l9e({id:s,data:T,attributes:{...w9e,...n},disabled:w.draggable}),z=W7e(j,q),V=!!B,X=V&&!x&&a1(g)&&a1(y),te=!b&&$,ie=te&&X?Q:null,ge=X?ie??(l??E)({rects:v,activeNodeRect:K,activeIndex:g,overIndex:y,index:A}):null,Ee=a1(g)&&a1(y)?a({id:s,items:d,activeIndex:g,overIndex:y}):A,pe=B?.id,de=S.useRef({activeId:pe,items:d,newIndex:Ee,containerId:f}),Re=d!==de.current.items,fe=e({active:B,containerId:f,isDragging:$,isSorting:V,id:s,index:A,items:d,newIndex:de.current.newIndex,previousItems:de.current.items,previousContainerId:de.current.containerId,transition:u,wasDragging:de.current.activeId!=null}),Fe=S9e({disabled:!fe,index:A,node:O,rect:N});return S.useEffect(()=>{V&&de.current.newIndex!==Ee&&(de.current.newIndex=Ee),f!==de.current.containerId&&(de.current.containerId=f),d!==de.current.items&&(de.current.items=d)},[V,Ee,f,d]),S.useEffect(()=>{if(pe===de.current.activeId)return;if(pe!=null&&de.current.activeId==null){de.current.activeId=pe;return}const H=setTimeout(()=>{de.current.activeId=pe},50);return()=>clearTimeout(H)},[pe]),{active:B,activeIndex:g,attributes:R,data:T,rect:N,index:A,newIndex:Ee,items:d,isOver:k,isSorting:V,isDragging:$,listeners:W,node:O,overIndex:y,over:J,setNodeRef:z,setActivatorNodeRef:ee,setDroppableNodeRef:j,setDraggableNodeRef:q,transform:Fe??ge,transition:U()};function U(){if(Fe||Re&&de.current.newIndex===A)return _9e;if(!(te&&!zL(L)||!u)&&(V||fe))return eg.Transition.toString({...u,property:zte})}}function M9e(t,e){var n,r;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t?.draggable)!=null?n:e.draggable,droppable:(r=t?.droppable)!=null?r:e.droppable}}function KS(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const E9e=[kn.Down,kn.Right,kn.Up,kn.Left],Hte=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:s,scrollableAncestors:l}}=e;if(E9e.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const g=i.get(f.id);if(g)switch(t.code){case kn.Down:r.top<g.top&&c.push(f);break;case kn.Up:r.top>g.top&&c.push(f);break;case kn.Left:r.left>g.left&&c.push(f);break;case kn.Right:r.left<g.left&&c.push(f);break}});const u=oGe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=wte(u,"id");if(d===s?.id&&u.length>1&&(d=u[1].id),d!=null){const f=a.get(n.id),g=a.get(d),p=g?i.get(g.id):null,x=g?.node.current;if(x&&p&&f&&g){const y=EE(x).some((C,N)=>l[N]!==C),b=$te(f,g),E=A9e(f,g),w=y||!b?{x:0,y:0}:{x:E?r.width-p.width:0,y:E?r.height-p.height:0},A={x:p.left,y:p.top};return w.x&&w.y?A:vb(A,w)}}}};function $te(t,e){return!KS(t)||!KS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function A9e(t,e){return!KS(t)||!KS(e)||!$te(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function T9e({item:t,onClose:e}){const n=pn(),{showToast:r}=Ar(),[i,a]=S.useState(t.printer_id),s=t.scheduled_time&&new Date(t.scheduled_time).getTime()>Date.now()+4320*60*60*1e3,[l,c]=S.useState(t.scheduled_time&&!s?"scheduled":"asap"),[u,d]=S.useState(()=>t.scheduled_time&&!s?new Date(t.scheduled_time).toISOString().slice(0,16):""),[f,g]=S.useState(t.require_previous_success),[p,x]=S.useState(t.auto_off_after),{data:v}=gt({queryKey:["printers"],queryFn:()=>_e.getPrinters()});S.useEffect(()=>{const w=A=>{A.key==="Escape"&&e()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[e]);const y=vt({mutationFn:w=>_e.updateQueueItem(t.id,w),onSuccess:()=>{n.invalidateQueries({queryKey:["queue"]}),r("Queue item updated"),e()},onError:w=>{r(w.message||"Failed to update queue item","error")}}),b=w=>{w.preventDefault();const A={printer_id:i,require_previous_success:f,auto_off_after:p};l==="scheduled"&&u?A.scheduled_time=new Date(u).toISOString():A.scheduled_time=null,y.mutate(A)},E=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:o.jsx(Mt,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:o.jsxs(At,{className:"p-0",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Bc,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Queue Item"})]}),o.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("form",{onSubmit:b,className:"p-4 space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),o.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),v?.length===0?o.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[o.jsx(Oa,{className:"w-4 h-4"}),"No printers configured"]}):o.jsx("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:w=>a(Number(w.target.value)),required:!0,children:v?.map(w=>o.jsx("option",{value:w.id,children:w.name},w.id))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${l==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("asap"),children:[o.jsx(ur,{className:"w-4 h-4"}),"ASAP (when idle)"]}),o.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${l==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("scheduled"),children:[o.jsx(Jr,{className:"w-4 h-4"}),"Scheduled"]})]})]}),l==="scheduled"&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),o.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:w=>d(w.target.value),min:E(),required:!0})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:w=>g(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),o.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:p,onChange:w=>x(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),o.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[o.jsx(jl,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:l==="asap"?"Print will start as soon as the printer is idle.":"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available."}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsx(ke,{type:"submit",className:"flex-1",disabled:y.isPending||v?.length===0,children:y.isPending?"Saving...":"Save Changes"})]})]})]})})})}function Vte(t){if(!t)return"--";const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function N9e(t){if(!t)return"ASAP";const e=new Date(t),n=new Date,r=e.getTime()-n.getTime();return r<-6e4?"Overdue":r<0?"Now":r<6e4?"In less than a minute":r<36e5?`In ${Math.round(r/6e4)} min`:r<864e5?`In ${Math.round(r/36e5)} hours`:e.toLocaleString()}function C9e({status:t}){const e={pending:{icon:ur,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:xd,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:kr,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:Pa,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:V1,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Wt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return o.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r}`,children:[o.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function kk({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:s}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:g}=Bte({id:t.id,disabled:t.status!=="pending"}),p={transform:eg.Transform.toString(d),transition:f},x=t.status==="printing",v=t.status==="pending",y=["completed","failed","skipped","cancelled"].includes(t.status);return o.jsx("div",{ref:u,style:p,className:`
- group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
- transition-all duration-200 hover:border-bambu-dark-tertiary/80
- ${g?"opacity-50 scale-[1.02] shadow-xl z-50":""}
- ${x?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
- `,children:o.jsxs("div",{className:"flex items-center gap-4 p-4",children:[v?o.jsx("div",{...l,...c,className:"flex items-center justify-center w-10 h-10 md:w-8 md:h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation",children:o.jsx(D0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?o.jsxs("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium",children:["#",e]}):o.jsx("div",{className:"w-8"}),o.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?o.jsx("img",{src:_e.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):o.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:o.jsx(gd,{className:"w-6 h-6"})})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[o.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),o.jsx(Sc,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:o.jsx(la,{className:"w-3.5 h-3.5"})})]}),o.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(Gi,{className:"w-3.5 h-3.5"}),t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(Ju,{className:"w-3.5 h-3.5"}),Vte(t.print_time_seconds)]}),v&&o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(ur,{className:"w-3.5 h-3.5"}),N9e(t.scheduled_time)]})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.require_previous_success&&o.jsx("span",{className:"text-xs px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:"Requires previous success"}),t.auto_off_after&&o.jsxs("span",{className:"text-xs px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1",children:[o.jsx(jl,{className:"w-3 h-3"}),"Auto power off"]})]}),x&&o.jsxs("div",{className:"mt-3",children:[o.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&o.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[o.jsx(Oa,{className:"w-3 h-3"}),t.error_message]})]}),o.jsx(C9e,{status:t.status}),o.jsxs("div",{className:"flex items-center gap-1",children:[x&&o.jsx(ke,{variant:"ghost",size:"sm",onClick:a,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:o.jsx(ole,{className:"w-4 h-4"})}),v&&o.jsxs(o.Fragment,{children:[o.jsx(ke,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:o.jsx(Bc,{className:"w-4 h-4"})}),o.jsx(ke,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:o.jsx(Wt,{className:"w-4 h-4"})})]}),y&&o.jsxs(o.Fragment,{children:[o.jsx(ke,{variant:"ghost",size:"sm",onClick:s,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:o.jsx(li,{className:"w-4 h-4"})}),o.jsx(ke,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:o.jsx(Nn,{className:"w-4 h-4"})})]})]})]})})}function k9e(){const t=pn(),{showToast:e}=Ar(),[n,r]=S.useState(null),[i,a]=S.useState(""),[s,l]=S.useState(!1),[c,u]=S.useState(null),[d,f]=S.useState(null),[g,p]=S.useState(null),[x,v]=S.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[y,b]=S.useState(()=>{const Q=localStorage.getItem("queue.historySortAsc");return Q!==null?Q==="true":!1}),[E,w]=S.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[A,T]=S.useState(()=>{const Q=localStorage.getItem("queue.pendingSortAsc");return Q!==null?Q==="true":!0});S.useEffect(()=>{localStorage.setItem("queue.historySortBy",x)},[x]),S.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(y))},[y]),S.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",E)},[E]),S.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(A))},[A]);const C=yte(WS(TE,{activationConstraint:{distance:8}}),WS(AE,{coordinateGetter:Hte})),{data:N,isLoading:O}=gt({queryKey:["queue",n,i],queryFn:()=>_e.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:k}=gt({queryKey:["printers"],queryFn:()=>_e.getPrinters()}),j=vt({mutationFn:Q=>_e.cancelQueueItem(Q),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),B=vt({mutationFn:Q=>_e.removeFromQueue(Q),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),L=vt({mutationFn:Q=>_e.stopQueueItem(Q),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),K=vt({mutationFn:Q=>_e.reorderQueue(Q),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),R=vt({mutationFn:async()=>{const Q=N?.filter(z=>["completed","failed","skipped","cancelled"].includes(z.status))||[];for(const z of Q)await _e.removeFromQueue(z.id);return Q.length},onSuccess:Q=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${Q} history item${Q!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),q=S.useMemo(()=>{const Q=N?.filter(V=>V.status==="pending")||[],z=V=>{if(!V.scheduled_time)return 0;const X=new Date(V.scheduled_time).getTime(),te=Date.now()+4320*60*60*1e3;return X>te?0:X};return[...Q].sort((V,X)=>{let te;return E==="name"?te=(V.archive_name||"").localeCompare(X.archive_name||""):E==="printer"?te=(V.printer_name||"").localeCompare(X.printer_name||""):E==="time"?te=z(V)-z(X):te=V.position-X.position,A?te:-te})},[N,E,A]),W=N?.filter(Q=>Q.status==="printing")||[],$=S.useMemo(()=>[...N?.filter(z=>["completed","failed","skipped","cancelled"].includes(z.status))||[]].sort((z,V)=>{let X;return x==="name"?X=(z.archive_name||"").localeCompare(V.archive_name||""):x==="printer"?X=(z.printer_name||"").localeCompare(V.printer_name||""):X=new Date(V.completed_at||V.created_at).getTime()-new Date(z.completed_at||z.created_at).getTime(),y?-X:X}),[N,x,y]),J=S.useMemo(()=>q.reduce((Q,z)=>Q+(z.print_time_seconds||0),0),[q]),ee=Q=>{const{active:z,over:V}=Q;if(!V||z.id===V.id)return;const X=q.findIndex(ie=>ie.id===z.id),te=q.findIndex(ie=>ie.id===V.id);if(X!==-1&&te!==-1){const le=kE(q,X,te).map((ge,Ee)=>({id:ge.id,position:Ee+1}));K.mutate(le)}};return o.jsxs("div",{className:"p-4 md:p-8",children:[o.jsx("div",{className:"flex items-center justify-between mb-8",children:o.jsxs("div",{children:[o.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[o.jsx(B9,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),o.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[o.jsx(Mt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:o.jsx(At,{className:"p-4",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:o.jsx(xd,{className:"w-5 h-5 text-blue-400"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-2xl font-bold text-white",children:W.length}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),o.jsx(Mt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:o.jsx(At,{className:"p-4",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:o.jsx(ur,{className:"w-5 h-5 text-yellow-400"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-2xl font-bold text-white",children:q.length}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),o.jsx(Mt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:o.jsx(At,{className:"p-4",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:o.jsx(Ju,{className:"w-5 h-5 text-bambu-green"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-2xl font-bold text-white",children:Vte(J)}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),o.jsx(Mt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:o.jsx(At,{className:"p-4",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:o.jsx(kr,{className:"w-5 h-5 text-gray-400"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-2xl font-bold text-white",children:$.length}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),o.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[o.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n||"",onChange:Q=>r(Q.target.value?Number(Q.target.value):null),children:[o.jsx("option",{value:"",children:"All Printers"}),k?.map(Q=>o.jsx("option",{value:Q.id,children:Q.name},Q.id))]}),o.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:Q=>a(Q.target.value),children:[o.jsx("option",{value:"",children:"All Status"}),o.jsx("option",{value:"pending",children:"Pending"}),o.jsx("option",{value:"printing",children:"Printing"}),o.jsx("option",{value:"completed",children:"Completed"}),o.jsx("option",{value:"failed",children:"Failed"}),o.jsx("option",{value:"skipped",children:"Skipped"}),o.jsx("option",{value:"cancelled",children:"Cancelled"})]}),o.jsx("div",{className:"flex-1"}),$.length>0&&o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:[o.jsx(Nn,{className:"w-4 h-4"}),"Clear History"]})]}),O?o.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):N?.length===0?o.jsxs(Mt,{className:"p-12 text-center border-dashed",children:[o.jsx(Jr,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),o.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),o.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:'Schedule a print from the Archives page using the "Schedule" option in the context menu, or drag and drop files to get started.'})]}):o.jsxs("div",{className:"space-y-8",children:[W.length>0&&o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),o.jsx("div",{className:"space-y-3",children:W.map(Q=>o.jsx(kk,{item:Q,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>p({type:"stop",item:Q}),onRequeue:()=>{}},Q.id))})]}),q.length>0&&o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(ur,{className:"w-5 h-5 text-yellow-400"}),"Queued",o.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",q.length," item",q.length!==1?"s":"",")"]}),o.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:"Position only affects ASAP items. Scheduled items run at their set time.",children:"Drag to reorder (ASAP only)"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:E,onChange:Q=>w(Q.target.value),children:[o.jsx("option",{value:"position",children:"Sort by Position"}),o.jsx("option",{value:"name",children:"Sort by Name"}),o.jsx("option",{value:"printer",children:"Sort by Printer"}),o.jsx("option",{value:"time",children:"Sort by Schedule"})]}),o.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>T(!A),title:A?"Ascending":"Descending",className:"px-2",children:A?o.jsx(Mp,{className:"w-4 h-4"}):o.jsx(j0,{className:"w-4 h-4"})})]})]}),o.jsx(Lte,{sensors:C,collisionDetection:Ste,onDragEnd:ee,children:o.jsx(Ute,{items:q.map(Q=>Q.id),strategy:g9e,children:o.jsx("div",{className:"space-y-3",children:q.map((Q,z)=>o.jsx(kk,{item:Q,position:z+1,onEdit:()=>u(Q),onCancel:()=>p({type:"cancel",item:Q}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{}},Q.id))})})})]}),$.length>0&&o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(kr,{className:"w-5 h-5 text-bambu-gray"}),"History",o.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",$.length," item",$.length!==1?"s":"",")"]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:x,onChange:Q=>v(Q.target.value),children:[o.jsx("option",{value:"date",children:"Sort by Date"}),o.jsx("option",{value:"name",children:"Sort by Name"}),o.jsx("option",{value:"printer",children:"Sort by Printer"})]}),o.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>b(!y),title:y?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:y?o.jsx(Mp,{className:"w-4 h-4"}):o.jsx(j0,{className:"w-4 h-4"})})]})]}),o.jsx("div",{className:"space-y-3",children:$.slice(0,20).map((Q,z)=>o.jsx(kk,{item:Q,position:z+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>p({type:"remove",item:Q}),onStop:()=>{},onRequeue:()=>f(Q)},Q.id))})]})]}),c&&o.jsx(T9e,{item:c,onClose:()=>u(null)}),d&&o.jsx(pte,{archiveId:d.archive_id,archiveName:d.archive_name||`Archive #${d.archive_id}`,onClose:()=>f(null)}),g&&o.jsx(br,{title:g.type==="cancel"?"Cancel Scheduled Print":g.type==="stop"?"Stop Print":"Remove from History",message:g.type==="cancel"?`Are you sure you want to cancel "${g.item.archive_name||"this print"}"?`:g.type==="stop"?`Are you sure you want to stop the current print "${g.item.archive_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${g.item.archive_name||"this item"}" from the queue history?`,confirmText:g.type==="cancel"?"Cancel Print":g.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{g.type==="cancel"?j.mutate(g.item.id):g.type==="stop"?L.mutate(g.item.id):B.mutate(g.item.id),p(null)},onCancel:()=>p(null)}),s&&o.jsx(br,{title:"Clear History",message:`Are you sure you want to remove all ${$.length} item${$.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{R.mutate(),l(!1)},onCancel:()=>l(!1)})]})}function P9e({printDates:t,months:e=3}){const{weeks:n,monthLabels:r,printCounts:i}=S.useMemo(()=>{const c={};t.forEach(b=>{const E=b.split("T")[0];c[E]=(c[E]||0)+1});const u=new Date,d=new Date(u);d.setMonth(d.getMonth()-e),d.setDate(d.getDate()-d.getDay());const f=[],g=[];let p=[],x=-1;const v=new Date(d);let y=0;for(;v<=u;)v.getDay()===0&&p.length>0&&(f.push(p),p=[],y++),v.getMonth()!==x&&(g.push({month:v.toLocaleDateString("en-US",{month:"short"}),weekIndex:y}),x=v.getMonth()),p.push(new Date(v)),v.setDate(v.getDate()+1);return p.length>0&&f.push(p),{weeks:f,monthLabels:g,printCounts:c}},[t,e]),a=Math.max(1,...Object.values(i)),s=c=>{if(c===0)return"bg-bambu-dark";const u=c/a;return u<=.25?"bg-bambu-green/30":u<=.5?"bg-bambu-green/50":u<=.75?"bg-bambu-green/75":"bg-bambu-green"},l=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return o.jsxs("div",{className:"overflow-x-auto",children:[o.jsx("div",{className:"flex mb-1 ml-8",children:r.map(({month:c,weekIndex:u},d)=>o.jsx("div",{className:"text-xs text-bambu-gray",style:{marginLeft:d===0?0:`${(u-(r[d-1]?.weekIndex||0))*14-24}px`},children:c},d))}),o.jsxs("div",{className:"flex gap-0.5",children:[o.jsx("div",{className:"flex flex-col gap-0.5 mr-1",children:l.map((c,u)=>o.jsx("div",{className:"h-3 text-xs text-bambu-gray flex items-center",style:{visibility:u%2===1?"visible":"hidden"},children:c},c))}),n.map((c,u)=>o.jsx("div",{className:"flex flex-col gap-0.5",children:[0,1,2,3,4,5,6].map(d=>{const f=c.find(v=>v.getDay()===d);if(!f)return o.jsx("div",{className:"w-3 h-3"},d);const g=f.toISOString().split("T")[0],p=i[g]||0,x=g===new Date().toISOString().split("T")[0];return o.jsx("div",{className:`w-3 h-3 rounded-sm ${s(p)} ${x?"ring-1 ring-white":""}`,title:`${f.toLocaleDateString()}: ${p} print${p!==1?"s":""}`},d)})},u))]}),o.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-bambu-gray",children:[o.jsx("span",{children:"Less"}),o.jsxs("div",{className:"flex gap-0.5",children:[o.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-dark"}),o.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/30"}),o.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/50"}),o.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/75"}),o.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green"})]}),o.jsx("span",{children:"More"})]})]})}const o1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function j9e(t){const e=new Date;switch(t){case"7d":return new Date(e.getTime()-10080*60*1e3);case"30d":return new Date(e.getTime()-720*60*60*1e3);case"90d":return new Date(e.getTime()-2160*60*60*1e3);case"365d":return new Date(e.getTime()-365*24*60*60*1e3);case"all":return new Date(0)}}function R9e({archives:t,currency:e="$"}){const[n,r]=S.useState("30d"),i=S.useMemo(()=>{const g=j9e(n);return t.filter(p=>new Date(p.completed_at||p.created_at)>=g)},[t,n]),a=S.useMemo(()=>{const g=new Map;return i.forEach(p=>{const v=new Date(p.completed_at||p.created_at).toISOString().split("T")[0],y=g.get(v)||{date:v,filament:0,cost:0,prints:0};y.filament+=p.filament_used_grams||0,y.cost+=p.cost||0,y.prints+=1,g.set(v,y)}),Array.from(g.values()).sort((p,x)=>p.date.localeCompare(x.date)).map(p=>({...p,dateLabel:new Date(p.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),s=S.useMemo(()=>{if(n==="7d"||n==="30d")return a;const g=new Map;return i.forEach(p=>{const x=new Date(p.completed_at||p.created_at),v=new Date(x);v.setDate(x.getDate()-x.getDay());const y=v.toISOString().split("T")[0],b=g.get(y)||{week:y,filament:0,cost:0,prints:0};b.filament+=p.filament_used_grams||0,b.cost+=p.cost||0,b.prints+=1,g.set(y,b)}),Array.from(g.values()).sort((p,x)=>p.week.localeCompare(x.week)).map(p=>({date:p.week,dateLabel:`Week of ${new Date(p.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...p}))},[i,a,n]),l=S.useMemo(()=>{const g=new Map;return i.forEach(p=>{const v=(p.filament_type||"Unknown").split(", ");v.forEach(y=>{const b=(p.filament_used_grams||0)/v.length;g.set(y,(g.get(y)||0)+b)})}),Array.from(g.entries()).map(([p,x])=>({name:p,value:Math.round(x)})).sort((p,x)=>x.value-p.value)},[i]),c=S.useMemo(()=>{const g=new Date,p=[];for(let x=5;x>=0;x--){const v=new Date(g.getFullYear(),g.getMonth()-x,1),y=new Date(g.getFullYear(),g.getMonth()-x+1,0),b=v.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),E=t.filter(w=>{const A=new Date(w.completed_at||w.created_at);return A>=v&&A<=y});p.push({month:b,filament:Math.round(E.reduce((w,A)=>w+(A.filament_used_grams||0),0)),cost:E.reduce((w,A)=>w+(A.cost||0),0),prints:E.length})}return p},[t]),u=n==="7d"||n==="30d"?a:s,d=i.reduce((g,p)=>g+(p.filament_used_grams||0),0),f=i.reduce((g,p)=>g+(p.cost||0),0);return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),o.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>o.jsx("button",{onClick:()=>r(g),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===g?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:g==="all"?"All":g.replace("d","D")},g))})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),o.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),o.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),o.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[o.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),o.jsx(g1,{width:"100%",height:250,children:o.jsxs(WNe,{data:u,children:[o.jsx("defs",{children:o.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[o.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),o.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),o.jsx(Iw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),o.jsx(Uw,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),o.jsx(zw,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),o.jsx(b1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),o.jsx(ZY,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):o.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[o.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx(g1,{width:160,height:160,children:o.jsxs(VNe,{children:[o.jsx(_Y,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((g,p)=>o.jsx(ny,{fill:o1[p%o1.length]},`cell-${p}`))}),o.jsx(b1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),o.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((g,p)=>{const x=l.reduce((y,b)=>y+b.value,0),v=x>0?(g.value/x*100).toFixed(0):0;return o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:o1[p%o1.length]}}),o.jsx("span",{className:"text-white truncate flex-1",children:g.name}),o.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[v,"%"]})]},g.name)})})]}):o.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[o.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),o.jsx(g1,{width:"100%",height:200,children:o.jsxs(jNe,{data:c,children:[o.jsx(Iw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),o.jsx(Uw,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),o.jsx(zw,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),o.jsx(b1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(g,p)=>[p==="filament"?`${g}g`:p==="cost"?`${e}${g.toFixed(2)}`:g,p==="filament"?"Filament":p==="cost"?"Cost":"Prints"]}),o.jsx(qR,{}),o.jsx(TY,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function D9e({id:t,title:e,children:n,isHidden:r,size:i,onToggleVisibility:a,onToggleSize:s}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:g}=Bte({id:t}),p={transform:eg.Transform.toString(d),transition:f,opacity:g?.5:1};return r?null:o.jsxs("div",{ref:u,style:{...p,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${g?"ring-2 ring-bambu-green shadow-lg":""}`,children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{...l,...c,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:o.jsx(D0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),o.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?o.jsx(Xce,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):o.jsx(Bce,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),o.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:o.jsx(JS,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),o.jsx("div",{className:"p-4",children:n})]})}function O9e({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const s=()=>{const A={};return t.forEach(T=>{A[T.id]=T.defaultSize||4}),A},[l,c]=S.useState(()=>{const A=localStorage.getItem(e);if(A)try{const T=JSON.parse(A);return T.sizes||(T.sizes=s()),T}catch{}return{order:t.map(T=>T.id),hidden:t.filter(T=>T.defaultVisible===!1).map(T=>T.id),sizes:s()}}),[u,d]=S.useState(!1);S.useEffect(()=>{const A=()=>d(T=>!T);return window.addEventListener("toggle-hidden-panel",A),()=>window.removeEventListener("toggle-hidden-panel",A)},[]),S.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),S.useEffect(()=>{const T=t.map(C=>C.id).filter(C=>!l.order.includes(C));T.length>0&&c(C=>({...C,order:[...C.order,...T]}))},[t,l.order]);const f=yte(WS(TE,{activationConstraint:{distance:8}}),WS(AE,{coordinateGetter:Hte})),g=A=>{const{active:T,over:C}=A;C&&T.id!==C.id&&c(N=>{const O=N.order.indexOf(T.id),k=N.order.indexOf(C.id);return{...N,order:kE(N.order,O,k)}})},p=A=>{c(T=>({...T,hidden:T.hidden.includes(A)?T.hidden.filter(C=>C!==A):[...T.hidden,A]}))},x=A=>{c(T=>{const C=T.sizes[A]||4,N=C===1?2:C===2?4:1;return{...T,sizes:{...T.sizes,[A]:N}}})},v=()=>{const A={order:t.map(T=>T.id),hidden:t.filter(T=>T.defaultVisible===!1).map(T=>T.id),sizes:s()};c(A),i?.()},y=l.order.map(A=>t.find(T=>T.id===A)).filter(Boolean),b=y.filter(A=>!l.hidden.includes(A.id)),E=y.filter(A=>l.hidden.includes(A.id)),w=a?.({hiddenCount:E.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:v});return o.jsxs("div",{className:"space-y-4",children:[w,!r&&!a&&o.jsxs("div",{className:"flex items-center justify-end gap-2",children:[o.jsxs(ke,{variant:"secondary",size:"sm",onClick:v,children:[o.jsx(sg,{className:"w-4 h-4"}),"Reset Layout"]}),E.length>0&&o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[o.jsx(ef,{className:"w-4 h-4"}),E.length," Hidden"]})]}),u&&E.length>0&&o.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[o.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:E.map(A=>o.jsxs("button",{onClick:()=>p(A.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[o.jsx(ef,{className:"w-3 h-3"}),A.title]},A.id))})]}),o.jsx(Lte,{sensors:f,collisionDetection:Ste,onDragEnd:g,children:o.jsx(Ute,{items:b.map(A=>A.id),strategy:$L,children:o.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:b.map(A=>o.jsx(D9e,{id:A.id,title:A.title,isHidden:l.hidden.includes(A.id),size:l.sizes[A.id]||2,onToggleVisibility:()=>p(A.id),onToggleSize:()=>x(A.id),children:A.component},A.id))})})}),b.length===0&&o.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[o.jsx("p",{children:"All widgets are hidden."}),o.jsx(ke,{className:"mt-4",onClick:v,children:"Reset Layout"})]})]})}function L9e({stats:t,currency:e}){return o.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:o.jsx(zc,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),o.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:o.jsx(ur,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),o.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:o.jsx(zc,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),o.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:o.jsx(Yk,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),o.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:o.jsx(sf,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),o.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:o.jsx(Yk,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),o.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function I9e({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return o.jsxs("div",{className:"flex items-center gap-6",children:[o.jsxs("div",{className:"relative w-28 h-28",children:[o.jsxs("svg",{className:"w-full h-full -rotate-90",children:[o.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),o.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),o.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:o.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(kr,{className:"w-4 h-4 text-bambu-green"}),o.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),o.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Pa,{className:"w-4 h-4 text-red-400"}),o.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),o.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function F9e({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const i=(Math.min(150,Math.max(50,n))-50)/100*100,s=(c=>c>=95&&c<=105?"#00ae42":c>105?"#3b82f6":"#f97316")(n),l=n-100;return o.jsxs("div",{className:"flex items-center gap-6",children:[o.jsxs("div",{className:"relative w-28 h-28",children:[o.jsxs("svg",{className:"w-full h-full -rotate-90",children:[o.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),o.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:s,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i*3.02} 302`})]}),o.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[o.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),o.jsxs("span",{className:`text-xs ${l>=0?"text-blue-400":"text-orange-400"}`,children:[l>=0?"+":"",l.toFixed(0),"%"]})]})]}),o.jsxs("div",{className:"space-y-2 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[o.jsx(V9,{className:"w-3 h-3"}),o.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&o.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([c,u])=>o.jsxs("div",{className:"flex items-center justify-between text-xs",children:[o.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(c)||`Printer ${c}`}),o.jsxs("span",{className:`font-medium ${u>=95&&u<=105?"text-bambu-green":u>105?"text-blue-400":"text-orange-400"}`,children:[u.toFixed(0),"%"]})]},c))})]})]})}function U9e({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return o.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No filament data available"});const e=Object.entries(t.prints_by_filament_type).sort(([,n],[,r])=>r-n);return o.jsx("div",{className:"space-y-3",children:e.map(([n,r])=>{const i=Math.round(r/(t.total_prints||1)*100);return o.jsxs("div",{children:[o.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[o.jsx("span",{className:"text-white",children:n}),o.jsxs("span",{className:"text-bambu-gray",children:[r," prints"]})]}),o.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:o.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${i}%`}})})]},n)})})}function z9e({printDates:t}){return o.jsx(P9e,{printDates:t,months:4})}function B9e({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?o.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>o.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[o.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:o.jsx(Gi,{className:"w-4 h-4 text-bambu-green"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function H9e({archives:t,currency:e}){return!t||t.length===0?o.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):o.jsx(R9e,{archives:t,currency:e})}function $9e(){const{data:t,isLoading:e}=gt({queryKey:["failureAnalysis"],queryFn:()=>_e.getFailureAnalysis({days:30})});if(e)return o.jsx("div",{className:"flex justify-center py-4",children:o.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!t||t.total_prints===0)return o.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data in the last 30 days"});const n=Object.entries(t.failures_by_reason).sort(([,r],[,i])=>i-r).slice(0,5);return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Gn,{className:`w-5 h-5 ${t.failure_rate>20?"text-red-400":t.failure_rate>10?"text-yellow-400":"text-bambu-green"}`}),o.jsxs("span",{className:"text-2xl font-bold text-white",children:[t.failure_rate.toFixed(1),"%"]}),o.jsx("span",{className:"text-sm text-bambu-gray",children:"failure rate"})]}),o.jsxs("div",{className:"text-sm text-bambu-gray",children:[t.failed_prints," / ",t.total_prints," prints failed"]})]}),n.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-xs text-bambu-gray font-medium",children:"Top Failure Reasons"}),n.map(([r,i])=>o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("span",{className:"text-white truncate max-w-[200px]",children:r||"Unknown"}),o.jsx("span",{className:"text-bambu-gray",children:i})]},r))]}),t.trend&&t.trend.length>=2&&o.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx(W9,{className:`w-4 h-4 ${t.trend[t.trend.length-1].failure_rate<t.trend[t.trend.length-2].failure_rate?"text-bambu-green":"text-red-400"}`}),o.jsxs("span",{className:"text-bambu-gray",children:["Last week: ",t.trend[t.trend.length-1].failure_rate.toFixed(1),"%"]})]})})]})}function V9e(){const{showToast:t}=Ar(),[e,n]=S.useState(!1),[r,i]=S.useState(!1),[a,s]=S.useState(0),[l,c]=S.useState(0);S.useEffect(()=>{const w=()=>{try{const T=localStorage.getItem("bambusy-dashboard-layout");if(T){const C=JSON.parse(T);c(C.hidden?.length||0)}}catch{c(0)}};w(),window.addEventListener("storage",w);const A=setInterval(w,500);return()=>{window.removeEventListener("storage",w),clearInterval(A)}},[a]);const{data:u,isLoading:d}=gt({queryKey:["archiveStats"],queryFn:_e.getArchiveStats}),{data:f}=gt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:g}=gt({queryKey:["archives"],queryFn:()=>_e.getArchives(void 0,void 0,1e3,0)}),{data:p}=gt({queryKey:["settings"],queryFn:_e.getSettings}),x=async w=>{i(!1),n(!0);try{const{blob:A,filename:T}=await _e.exportStats({format:w,days:90}),C=URL.createObjectURL(A),N=document.createElement("a");N.href=C,N.download=T,N.click(),URL.revokeObjectURL(C),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},v=p?.currency||"$",y=new Map(f?.map(w=>[String(w.id),w.name])||[]),b=g?.map(w=>w.created_at)||[];if(d)return o.jsx("div",{className:"p-4 md:p-8",children:o.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const E=[{id:"quick-stats",title:"Quick Stats",component:o.jsx(L9e,{stats:u,currency:v}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:o.jsx(I9e,{stats:u}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:o.jsx(F9e,{stats:u,printerMap:y}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:o.jsx(U9e,{stats:u}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:o.jsx($9e,{}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:o.jsx(z9e,{printDates:b}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:o.jsx(B9e,{stats:u,printerMap:y}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:o.jsx(H9e,{archives:g||[],currency:v}),defaultSize:4}];return o.jsxs("div",{className:"p-4 md:p-8",children:[o.jsxs("div",{className:"flex items-center justify-between mb-6",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),o.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[l>0&&o.jsxs(ke,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[o.jsx(ef,{className:"w-4 h-4"}),l," Hidden"]}),o.jsxs(ke,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),s(w=>w+1),t("Layout reset")},children:[o.jsx(sg,{className:"w-4 h-4"}),"Reset Layout"]}),o.jsxs("div",{className:"relative",children:[o.jsxs(ke,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(B1,{className:"w-4 h-4"}),"Export Stats"]}),r&&o.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[o.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>x("csv"),children:[o.jsx(As,{className:"w-4 h-4"}),"Export as CSV"]}),o.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>x("xlsx"),children:[o.jsx(B1,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),o.jsx(O9e,{widgets:E,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function G9e({plug:t,onEdit:e}){const n=pn(),[r,i]=S.useState(!1),[a,s]=S.useState(!1),[l,c]=S.useState(!1),[u,d]=S.useState(!1),{data:f,isLoading:g,refetch:p}=gt({queryKey:["smart-plug-status",t.id],queryFn:()=>_e.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=gt({queryKey:["printers"],queryFn:_e.getPrinters}),v=x?.find(C=>C.id===t.printer_id),y=vt({mutationFn:C=>_e.controlSmartPlug(t.id,C),onSuccess:()=>{p()}}),b=vt({mutationFn:C=>_e.updateSmartPlug(t.id,C),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),E=vt({mutationFn:()=>_e.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=f?.state==="ON",A=f?.reachable??!1,T=y.isPending;return o.jsxs(o.Fragment,{children:[o.jsx(Mt,{className:"relative",children:o.jsxs(At,{className:"p-4",children:[o.jsxs("div",{className:"flex items-start justify-between mb-3",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:`p-2 rounded-lg ${A?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:o.jsx(co,{className:`w-5 h-5 ${A?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),o.jsxs("div",{children:[o.jsx("h3",{className:"font-medium text-white",children:t.name}),o.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),o.jsx("div",{className:"flex items-center gap-2",children:g?o.jsx(pt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):A?o.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[o.jsx(vR,{className:"w-4 h-4 text-bambu-green"}),o.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):o.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[o.jsx(kb,{className:"w-4 h-4"}),o.jsx("span",{children:"Offline"})]})})]}),v&&o.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[o.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),o.jsx("span",{className:"text-sm text-white",children:v.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&o.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&o.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[o.jsx(Dh,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&o.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[o.jsx(Jr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),o.jsxs("div",{className:"flex gap-2 mb-3",children:[o.jsxs(ke,{size:"sm",variant:w?"primary":"secondary",disabled:!A||T,onClick:()=>s(!0),className:"flex-1",children:[T?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(jl,{className:"w-4 h-4"}),"On"]}),o.jsxs(ke,{size:"sm",variant:w?"secondary":"primary",disabled:!A||T,onClick:()=>c(!0),className:"flex-1",children:[T?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(nM,{className:"w-4 h-4"}),"Off"]})]}),o.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx(rM,{className:"w-4 h-4"}),"Automation Settings"]}),o.jsx("span",{children:u?"-":"+"})]}),u&&o.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(tM,{className:"w-4 h-4 text-bambu-green"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:C=>b.mutate({show_in_switchbar:C.target.checked}),className:"sr-only peer"}),o.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Enabled"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:t.enabled,onChange:C=>b.mutate({enabled:C.target.checked}),className:"sr-only peer"}),o.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Auto On"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:C=>b.mutate({auto_on:C.target.checked}),className:"sr-only peer"}),o.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:C=>b.mutate({auto_off:C.target.checked}),className:"sr-only peer"}),o.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&o.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("button",{onClick:()=>b.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[o.jsx(ur,{className:"w-4 h-4"}),"Time"]}),o.jsxs("button",{onClick:()=>b.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[o.jsx(iM,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),o.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:C=>b.mutate({off_delay_minutes:parseInt(C.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),o.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:C=>b.mutate({off_temp_threshold:parseInt(C.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),o.jsxs("div",{className:"flex gap-2 pt-2",children:[o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[o.jsx(xR,{className:"w-4 h-4"}),"Edit"]}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:o.jsx(Nn,{className:"w-4 h-4"})})]})]})]})}),r&&o.jsx(br,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{E.mutate(),i(!1)},onCancel:()=>i(!1)}),a&&o.jsx(br,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{y.mutate("on"),s(!1)},onCancel:()=>s(!1)}),l&&o.jsx(br,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{y.mutate("off"),c(!1)},onCancel:()=>c(!1)})]})}function W9e({plug:t,onClose:e}){const n=pn(),r=!!t,[i,a]=S.useState(t?.name||""),[s,l]=S.useState(t?.ip_address||""),[c,u]=S.useState(t?.username||""),[d,f]=S.useState(t?.password||""),[g,p]=S.useState(t?.printer_id||null),[x,v]=S.useState(null),[y,b]=S.useState(null),[E,w]=S.useState(t?.power_alert_enabled||!1),[A,T]=S.useState(t?.power_alert_high?.toString()||""),[C,N]=S.useState(t?.power_alert_low?.toString()||""),[O,k]=S.useState(t?.schedule_enabled||!1),[j,B]=S.useState(t?.schedule_on_time||""),[L,K]=S.useState(t?.schedule_off_time||""),[R,q]=S.useState(t?.show_in_switchbar||!1),[W,$]=S.useState(!1),[J,ee]=S.useState({scanned:0,total:0}),[Q,z]=S.useState([]),V=S.useRef(null),{data:X}=gt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:te}=gt({queryKey:["smart-plugs"],queryFn:_e.getSmartPlugs});S.useEffect(()=>{const U=H=>{H.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>{window.removeEventListener("keydown",U),V.current&&clearInterval(V.current)}},[e]);const ie=async()=>{$(!0),z([]),ee({scanned:0,total:0}),b(null);try{await _e.startTasmotaScan();const U=async()=>{try{const H=await _e.getTasmotaScanStatus();ee({scanned:H.scanned,total:H.total});const re=await _e.getDiscoveredTasmotaDevices();z(re),H.running||($(!1),V.current&&(clearInterval(V.current),V.current=null))}catch(H){console.error("Polling error:",H)}};await U(),V.current=setInterval(U,500)}catch(U){$(!1);const H=U instanceof Error?U.message:typeof U=="string"?U:JSON.stringify(U);b(H||"Failed to start scan")}},le=async()=>{try{await _e.stopTasmotaScan()}catch{}$(!1),V.current&&(clearInterval(V.current),V.current=null)},ge=U=>{l(U.ip_address),a(U.name),v(null)},Ee=vt({mutationFn:()=>_e.testSmartPlugConnection(s,c||null,d||null),onSuccess:U=>{v(U),b(null),!i&&U.device_name&&a(U.device_name)},onError:U=>{v(null),b(U.message)}}),pe=vt({mutationFn:U=>_e.createSmartPlug(U),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:U=>{b(U.message)}}),de=vt({mutationFn:U=>_e.updateSmartPlug(t.id,U),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:U=>{b(U.message)}}),Re=X?.filter(U=>!te?.some(re=>re.printer_id===U.id&&re.id!==t?.id)),fe=U=>{if(U.preventDefault(),b(null),!i.trim()){b("Name is required");return}if(!s.trim()){b("IP address is required");return}const H={name:i.trim(),ip_address:s.trim(),username:c.trim()||null,password:d.trim()||null,printer_id:g,power_alert_enabled:E,power_alert_high:A?parseFloat(A):null,power_alert_low:C?parseFloat(C):null,schedule_enabled:O,schedule_on_time:j||null,schedule_off_time:L||null,show_in_switchbar:R};r?de.mutate(H):pe.mutate(H)},Fe=pe.isPending||de.isPending;return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:U=>U.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),o.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("form",{onSubmit:fe,className:"p-6 space-y-4 overflow-y-auto",children:[y&&o.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:y}),!r&&o.jsxs("div",{className:"space-y-3",children:[W?o.jsxs(ke,{type:"button",variant:"secondary",onClick:le,className:"w-full",children:[o.jsx(Wt,{className:"w-4 h-4"}),"Stop Scanning"]}):o.jsxs(ke,{type:"button",variant:"primary",onClick:ie,className:"w-full",children:[o.jsx(_l,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),W&&J.total>0&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[o.jsx("span",{children:"Scanning network..."}),o.jsxs("span",{children:[J.scanned," / ",J.total]})]}),o.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:o.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${J.scanned/J.total*100}%`}})})]}),Q.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",Q.length," device(s) - click to select:"]}),o.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:Q.map(U=>o.jsxs("button",{type:"button",onClick:()=>ge(U),className:"w-full flex items-center justify-between p-2 bg-bambu-dark hover:bg-bambu-dark-tertiary rounded-lg transition-colors text-left border border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(co,{className:"w-4 h-4 text-bambu-green"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:U.name}),o.jsx("p",{className:"text-xs text-bambu-gray",children:U.ip_address})]})]}),U.state&&o.jsxs("span",{className:`flex items-center gap-1 text-xs ${U.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[o.jsx(jl,{className:"w-3 h-3"}),U.state]})]},U.ip_address))})]}),!W&&Q.length===0&&J.total>0&&o.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"text",value:s,onChange:U=>{l(U.target.value),v(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),o.jsxs(ke,{type:"button",variant:"secondary",onClick:()=>Ee.mutate(),disabled:!s.trim()||Ee.isPending,children:[Ee.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(vR,{className:"w-4 h-4"}),"Test"]})]})]}),x&&o.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${x.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:x.success?o.jsxs(o.Fragment,{children:[o.jsx(kr,{className:"w-5 h-5"}),o.jsxs("div",{children:[o.jsx("p",{className:"font-medium",children:"Connected!"}),o.jsxs("p",{className:"text-sm opacity-80",children:[x.device_name&&`Device: ${x.device_name} - `,"State: ",x.state]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx(kb,{className:"w-5 h-5"}),o.jsx("span",{children:"Connection failed"})]})}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),o.jsx("input",{type:"text",value:i,onChange:U=>a(U.target.value),placeholder:"Living Room Plug",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),o.jsx("input",{type:"text",value:c,onChange:U=>u(U.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),o.jsx("input",{type:"password",value:d,onChange:U=>f(U.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),o.jsxs("select",{value:g??"",onChange:U=>p(U.target.value?Number(U.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"",children:"No printer (manual control only)"}),Re?.map(U=>o.jsx("option",{value:U.id,children:U.name},U.id))]}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),o.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Dh,{className:"w-4 h-4 text-bambu-green"}),o.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:E,onChange:U=>w(U.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),E&&o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),o.jsx("input",{type:"number",value:A,onChange:U=>T(U.target.value),placeholder:"e.g. 200",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),o.jsx("input",{type:"number",value:C,onChange:U=>N(U.target.value),placeholder:"e.g. 10",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),o.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ur,{className:"w-4 h-4 text-bambu-green"}),o.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:O,onChange:U=>k(U.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),O&&o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),o.jsx("input",{type:"time",value:j,onChange:U=>B(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),o.jsx("input",{type:"time",value:L,onChange:U=>K(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Automatically turn the plug on/off at these times daily. Leave empty to skip that action."})]})]}),o.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(tM,{className:"w-4 h-4 text-bambu-green"}),o.jsxs("div",{children:[o.jsx("span",{className:"text-white font-medium",children:"Show in Switchbar"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:R,onChange:U=>q(U.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{type:"submit",disabled:Fe,className:"flex-1",children:[Fe?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(Ts,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Bn({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return o.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:o.jsx("span",{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const q9e={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function K9e({provider:t,onEdit:e}){const n=pn(),[r,i]=S.useState(!1),[a,s]=S.useState(!1),[l,c]=S.useState(null),{data:u}=gt({queryKey:["printers"],queryFn:_e.getPrinters}),d=u?.find(v=>v.id===t.printer_id),f=vt({mutationFn:v=>_e.updateNotificationProvider(t.id,v),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=vt({mutationFn:()=>_e.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=vt({mutationFn:()=>_e.testNotificationProvider(t.id),onSuccess:v=>{c(v),n.invalidateQueries({queryKey:["notification-providers"]})},onError:v=>{c({success:!1,message:v.message})}}),x=v=>v||"";return o.jsxs(o.Fragment,{children:[o.jsx(Mt,{className:"relative",children:o.jsxs(At,{className:"p-4",children:[o.jsxs("div",{className:"flex items-start justify-between mb-3",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:o.jsx(Dh,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),o.jsxs("div",{children:[o.jsx("h3",{className:"font-medium text-white",children:t.name}),o.jsx("p",{className:"text-sm text-bambu-gray",children:q9e[t.provider_type]||t.provider_type})]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&o.jsxs("span",{className:"text-xs text-bambu-green hidden sm:inline",children:["Last: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&t.last_error_at&&(!t.last_success||new Date(t.last_error_at)>new Date(t.last_success))&&o.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"}),o.jsx(Bn,{checked:t.enabled,onChange:v=>f.mutate({enabled:v})})]})]}),d&&o.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[o.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),o.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&o.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:o.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),o.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&o.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&o.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&o.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&o.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&o.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&o.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&o.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&o.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&o.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.on_ams_humidity_high&&o.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:"AMS Humidity"}),t.on_ams_temperature_high&&o.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:"AMS Temp"}),t.on_ams_ht_humidity_high&&o.jsx("span",{className:"px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded",children:"AMS-HT Humidity"}),t.on_ams_ht_temperature_high&&o.jsx("span",{className:"px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded",children:"AMS-HT Temp"}),t.quiet_hours_enabled&&o.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[o.jsx($1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&o.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[o.jsx(Jr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),o.jsx("div",{className:"mb-3",children:o.jsxs(ke,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(bR,{className:"w-4 h-4"}),"Send Test Notification"]})}),l&&o.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${l.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[l.success?o.jsx(kr,{className:"w-4 h-4"}):o.jsx(Pa,{className:"w-4 h-4"}),o.jsx("span",{children:l.message})]}),o.jsxs("button",{onClick:()=>s(!a),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx(rM,{className:"w-4 h-4"}),"Event Settings"]}),a?o.jsx(Tb,{className:"w-4 h-4"}):o.jsx(vo,{className:"w-4 h-4"})]}),a&&o.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Enabled"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),o.jsx(Bn,{checked:t.enabled,onChange:v=>f.mutate({enabled:v})})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("p",{className:"text-sm text-white",children:"Print Started"}),o.jsx(Bn,{checked:t.on_print_start,onChange:v=>f.mutate({on_print_start:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),o.jsx(Bn,{checked:t.on_print_complete,onChange:v=>f.mutate({on_print_complete:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),o.jsx(Bn,{checked:t.on_print_failed,onChange:v=>f.mutate({on_print_failed:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),o.jsx(Bn,{checked:t.on_print_stopped,onChange:v=>f.mutate({on_print_stopped:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),o.jsx(Bn,{checked:t.on_print_progress,onChange:v=>f.mutate({on_print_progress:v})})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),o.jsx(Bn,{checked:t.on_printer_offline,onChange:v=>f.mutate({on_printer_offline:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),o.jsx(Bn,{checked:t.on_printer_error,onChange:v=>f.mutate({on_printer_error:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),o.jsx(Bn,{checked:t.on_filament_low,onChange:v=>f.mutate({on_filament_low:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),o.jsx(Bn,{checked:t.on_maintenance_due??!1,onChange:v=>f.mutate({on_maintenance_due:v})})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),o.jsx(Bn,{checked:t.on_ams_humidity_high??!1,onChange:v=>f.mutate({on_ams_humidity_high:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),o.jsx(Bn,{checked:t.on_ams_temperature_high??!1,onChange:v=>f.mutate({on_ams_temperature_high:v})})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),o.jsx(Bn,{checked:t.on_ams_ht_humidity_high??!1,onChange:v=>f.mutate({on_ams_ht_humidity_high:v})})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),o.jsx(Bn,{checked:t.on_ams_ht_temperature_high??!1,onChange:v=>f.mutate({on_ams_ht_temperature_high:v})})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx($1,{className:"w-4 h-4 text-purple-400"}),o.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),o.jsx(Bn,{checked:t.quiet_hours_enabled,onChange:v=>f.mutate({quiet_hours_enabled:v})})]}),t.quiet_hours_enabled&&o.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ur,{className:"w-4 h-4 text-bambu-gray"}),o.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Jr,{className:"w-4 h-4 text-emerald-400"}),o.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),o.jsx(Bn,{checked:t.daily_digest_enabled,onChange:v=>f.mutate({daily_digest_enabled:v})})]}),t.daily_digest_enabled&&o.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[o.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ur,{className:"w-4 h-4 text-bambu-gray"}),o.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),o.jsxs("div",{className:"flex gap-2 pt-2",children:[o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[o.jsx(xR,{className:"w-4 h-4"}),"Edit"]}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:o.jsx(Nn,{className:"w-4 h-4"})})]})]})]})}),r&&o.jsx(br,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{g.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const XG=[{value:"email",label:"Email",description:"SMTP email notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"discord",label:"Discord",description:"Send to Discord channel via webhook"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"webhook",label:"Webhook",description:"Generic HTTP POST to any URL"}];function X9e({provider:t,onClose:e}){const n=pn(),r=!!t,[i,a]=S.useState(t?.name||""),[s,l]=S.useState(t?.provider_type||"email"),[c,u]=S.useState(t?.printer_id||null),[d,f]=S.useState(t?.quiet_hours_enabled||!1),[g,p]=S.useState(t?.quiet_hours_start||"22:00"),[x,v]=S.useState(t?.quiet_hours_end||"07:00"),[y,b]=S.useState(t?.daily_digest_enabled||!1),[E,w]=S.useState(t?.daily_digest_time||"08:00"),[A,T]=S.useState(t?.on_print_start??!1),[C,N]=S.useState(t?.on_print_complete??!0),[O,k]=S.useState(t?.on_print_failed??!0),[j,B]=S.useState(t?.on_print_stopped??!0),[L,K]=S.useState(t?.on_print_progress??!1),[R,q]=S.useState(t?.on_printer_offline??!1),[W,$]=S.useState(t?.on_printer_error??!1),[J,ee]=S.useState(t?.on_filament_low??!1),[Q,z]=S.useState(t?.on_maintenance_due??!1),[V,X]=S.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([G,Z])=>[G,String(Z)])):{}),[te,ie]=S.useState(null),[le,ge]=S.useState(null),{data:Ee}=gt({queryKey:["printers"],queryFn:_e.getPrinters});S.useEffect(()=>{const G=Z=>{Z.key==="Escape"&&e()};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[e]);const pe=vt({mutationFn:()=>_e.testNotificationConfig({provider_type:s,config:V}),onSuccess:G=>{ie(G),ge(null)},onError:G=>{ie({success:!1,message:G.message})}}),de=vt({mutationFn:G=>_e.createNotificationProvider(G),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:G=>{ge(G.message)}}),Re=vt({mutationFn:G=>_e.updateNotificationProvider(t.id,G),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:G=>{ge(G.message)}}),fe=G=>{if(G.preventDefault(),ge(null),!i.trim()){ge("Name is required");return}const Z=H(s);for(const be of Z)if(!V[be.key]?.trim()){ge(`${be.label} is required`);return}const oe={name:i.trim(),provider_type:s,config:V,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?g:null,quiet_hours_end:d?x:null,daily_digest_enabled:y,daily_digest_time:y?E:null,on_print_start:A,on_print_complete:C,on_print_failed:O,on_print_stopped:j,on_print_progress:L,on_printer_offline:R,on_printer_error:W,on_filament_low:J,on_maintenance_due:Q};r?Re.mutate(oe):de.mutate(oe)},Fe=de.isPending||Re.isPending,U=G=>{switch(G){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1}];default:return[]}},H=G=>U(G).filter(Z=>Z.required),re=U(s);return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:G=>G.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),o.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("form",{onSubmit:fe,className:"p-6 space-y-4",children:[le&&o.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:le}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),o.jsx("input",{type:"text",value:i,onChange:G=>a(G.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),o.jsx("select",{value:s,onChange:G=>{l(G.target.value),X({}),ie(null)},disabled:r,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:XG.map(G=>o.jsx("option",{value:G.value,children:G.label},G.value))}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:XG.find(G=>G.value===s)?.description})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),re.map(G=>o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[G.label," ",G.required&&"*"]}),G.type==="select"&&G.options?o.jsx("select",{value:V[G.key]||G.options[0]?.value||"",onChange:Z=>{X({...V,[G.key]:Z.target.value}),ie(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:G.options.map(Z=>o.jsx("option",{value:Z.value,children:Z.label},Z.value))}):o.jsx("input",{type:G.type,value:V[G.key]||"",onChange:Z=>{X({...V,[G.key]:Z.target.value}),ie(null)},placeholder:G.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},G.key))]}),o.jsx("div",{className:"flex gap-2",children:o.jsxs(ke,{type:"button",variant:"secondary",onClick:()=>{ie(null),pe.mutate()},disabled:pe.isPending||!V[H(s)[0]?.key],className:"flex-1",children:[pe.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(bR,{className:"w-4 h-4"}),"Test Configuration"]})}),te&&o.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${te.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:te.success?o.jsxs(o.Fragment,{children:[o.jsx(kr,{className:"w-5 h-5"}),o.jsx("span",{children:te.message})]}):o.jsxs(o.Fragment,{children:[o.jsx(Pa,{className:"w-5 h-5"}),o.jsx("span",{children:te.message})]})}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),o.jsxs("select",{value:c??"",onChange:G=>u(G.target.value?Number(G.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"",children:"All printers"}),Ee?.map(G=>o.jsx("option",{value:G.id,children:G.name},G.id))]}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),o.jsx(Bn,{checked:d,onChange:f})]}),d&&o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),o.jsx("input",{type:"time",value:g,onChange:G=>p(G.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),o.jsx("input",{type:"time",value:x,onChange:G=>v(G.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),o.jsx(Bn,{checked:y,onChange:b})]}),y&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),o.jsx("input",{type:"time",value:E,onChange:G=>w(G.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),o.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Start"}),o.jsx(Bn,{checked:A,onChange:T})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Complete"}),o.jsx(Bn,{checked:C,onChange:N})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Failed"}),o.jsx(Bn,{checked:O,onChange:k})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Stopped"}),o.jsx(Bn,{checked:j,onChange:B})]}),o.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-white",children:"Progress"}),o.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),o.jsx(Bn,{checked:L,onChange:K})]})]})]}),o.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Offline"}),o.jsx(Bn,{checked:R,onChange:q})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Error"}),o.jsx(Bn,{checked:W,onChange:$})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),o.jsx(Bn,{checked:J,onChange:ee})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),o.jsx(Bn,{checked:Q,onChange:z})]})]})]})]}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{type:"submit",disabled:Fe,className:"flex-1",children:[Fe?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(Ts,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Y9e({template:t,onClose:e}){const n=pn(),r=S.useRef(null),[i,a]=S.useState(t.title_template),[s,l]=S.useState(t.body_template),[c,u]=S.useState(null),[d,f]=S.useState(!0),{data:g}=gt({queryKey:["template-variables"],queryFn:_e.getTemplateVariables}),p=g?.find(T=>T.event_type===t.event_type),{data:x,isLoading:v}=gt({queryKey:["template-preview",t.event_type,i,s],queryFn:()=>_e.previewTemplate({event_type:t.event_type,title_template:i,body_template:s}),enabled:d&&i.length>0&&s.length>0});S.useEffect(()=>{const T=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[e]);const y=vt({mutationFn:T=>_e.updateNotificationTemplate(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:T=>{u(T.message)}}),b=vt({mutationFn:()=>_e.resetNotificationTemplate(t.id),onSuccess:T=>{a(T.title_template),l(T.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:T=>{u(T.message)}}),E=T=>{if(T.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!s.trim()){u("Body is required");return}y.mutate({title_template:i,body_template:s})},w=T=>{const C=r.current;if(!C)return;const N=C.selectionStart,O=C.selectionEnd,k=s,j=k.substring(0,N),B=k.substring(O),L=j+`{${T}}`+B;l(L),setTimeout(()=>{C.focus();const K=N+T.length+2;C.setSelectionRange(K,K)},0)},A=i!==t.title_template||s!==t.body_template;return o.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),o.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:o.jsx(Wt,{className:"w-5 h-5 text-bambu-gray"})})]}),o.jsxs("form",{onSubmit:E,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&o.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),o.jsx("input",{type:"text",value:i,onChange:T=>a(T.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),o.jsx("textarea",{ref:r,value:s,onChange:T=>l(T.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),p&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:p.variables.map(T=>o.jsxs("button",{type:"button",onClick:()=>w(T),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[o.jsx(fr,{className:"w-3 h-3"}),T]},T))}),o.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[o.jsx(ef,{className:"w-4 h-4"}),"Live Preview"]}),o.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&o.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:v?o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[o.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),o.jsx("div",{className:"text-white font-medium",children:x.title})]}),o.jsxs("div",{children:[o.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),o.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):o.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),o.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[o.jsxs(ke,{type:"button",variant:"ghost",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-orange-400 hover:text-orange-300",children:[b.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(sg,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),o.jsxs(ke,{onClick:E,disabled:y.isPending||!A,children:[y.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Ts,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const Z9e={print_start:"Print Started",print_complete:"Print Complete",print_failed:"Print Failed",print_stopped:"Print Stopped",print_progress:"Progress",printer_offline:"Printer Offline",printer_error:"Printer Error",filament_low:"Low Filament",maintenance_due:"Maintenance Due",test:"Test"},Q9e={print_start:"text-blue-400",print_complete:"text-bambu-green",print_failed:"text-red-400",print_stopped:"text-orange-400",print_progress:"text-yellow-400",printer_offline:"text-gray-400",printer_error:"text-rose-400",filament_low:"text-cyan-400",maintenance_due:"text-purple-400",test:"text-bambu-gray"};function J9e({onClose:t}){const e=pn(),{showToast:n}=Ar(),[r,i]=S.useState(7),[a,s]=S.useState(null),[l,c]=S.useState(!1),{data:u,isLoading:d,refetch:f,isRefetching:g}=gt({queryKey:["notification-logs",r,l],queryFn:()=>_e.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:p}=gt({queryKey:["notification-log-stats",r],queryFn:()=>_e.getNotificationLogStats(r)}),x=vt({mutationFn:()=>_e.clearNotificationLogs(30),onSuccess:y=>{n(y.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:y=>{n(`Failed to clear logs: ${y.message}`,"error")}}),v=y=>{const b=new Date(y),w=new Date().getTime()-b.getTime();return w<6e4?"Just now":w<36e5?`${Math.floor(w/6e4)}m ago`:w<864e5?`${Math.floor(w/36e5)}h ago`:b.toLocaleDateString()+" "+b.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:o.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[o.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(H1,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),o.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),p&&o.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:o.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[o.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",o.jsx("span",{className:"text-white font-medium",children:p.total})," notifications"]}),o.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[o.jsx(kr,{className:"w-4 h-4"}),p.success_count," sent"]}),p.failure_count>0&&o.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[o.jsx(Pa,{className:"w-4 h-4"}),p.failure_count," failed"]})]})}),o.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[o.jsxs("select",{value:r,onChange:y=>i(Number(y.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[o.jsx("option",{value:1,children:"Last 24 hours"}),o.jsx("option",{value:7,children:"Last 7 days"}),o.jsx("option",{value:30,children:"Last 30 days"}),o.jsx("option",{value:90,children:"Last 90 days"})]}),o.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:l,onChange:y=>c(y.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),o.jsx("div",{className:"flex-1"}),o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>f(),disabled:g,children:[g?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(li,{className:"w-4 h-4"}),"Refresh"]}),o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-red-400 hover:text-red-300",children:[x.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(Nn,{className:"w-4 h-4"}),"Clear Old"]})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:d?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?o.jsx("div",{className:"space-y-2",children:u.map(y=>o.jsx(eWe,{log:y,isExpanded:a===y.id,onToggle:()=>s(a===y.id?null:y.id),formatDate:v},y.id))}):o.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[o.jsx(H1,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),o.jsx("p",{className:"text-sm",children:l?"No failed notifications":"No notifications logged"})]})})]})})}function eWe({log:t,isExpanded:e,onToggle:n,formatDate:r}){return o.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[o.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?o.jsx(kr,{className:"w-4 h-4 text-bambu-green shrink-0"}):o.jsx(Pa,{className:"w-4 h-4 text-red-400 shrink-0"}),o.jsx("span",{className:`text-xs font-medium ${Q9e[t.event_type]||"text-bambu-gray"}`,children:Z9e[t.event_type]||t.event_type}),o.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&o.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),o.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?o.jsx(Tb,{className:"w-4 h-4 text-bambu-gray shrink-0"}):o.jsx(vo,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&o.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),o.jsx("p",{className:"text-sm text-white",children:t.title})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),o.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),o.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),o.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[o.jsxs("span",{children:["Provider: ",t.provider_type]}),o.jsxs("span",{children:["Time: ",new Date(t.created_at).toLocaleString()]})]})]})]})}const l1=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:o.jsx(yR,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:o.jsx(Dh,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:o.jsx(As,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:o.jsx(co,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"external_links",labelKey:"backup.categories.externalLinks",defaultLabel:"External Links",icon:o.jsx(Cb,{className:"w-4 h-4"}),default:!0,description:"Sidebar links to external services"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:o.jsx(Gi,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:o.jsx(pR,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:o.jsx(bd,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:o.jsx(lo,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"},{id:"projects",labelKey:"backup.categories.projects",defaultLabel:"Projects",icon:o.jsx(Bo,{className:"w-4 h-4"}),default:!1,description:"Projects, BOM items, and attachments"},{id:"pending_uploads",labelKey:"backup.categories.pendingUploads",defaultLabel:"Pending Uploads",icon:o.jsx(ca,{className:"w-4 h-4"}),default:!1,description:"Virtual printer uploads awaiting review"}];function tWe({onClose:t,onExport:e}){const{t:n}=ng(),[r,i]=S.useState(()=>{const x={};return l1.forEach(v=>{x[v.id]=v.default}),x}),[a,s]=S.useState(!1),[l,c]=S.useState(!1);S.useEffect(()=>{const x=v=>{v.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]);const u=x=>{i(v=>({...v,[x]:!v[x]}))},d=()=>{const x={};l1.forEach(v=>{x[v.id]=!0}),i(x)},f=()=>{const x={};l1.forEach(v=>{x[v.id]=!1}),i(x)},g=Object.values(r).filter(Boolean).length,p=async()=>{c(!0);try{await e({...r,access_codes:a&&r.printers})}finally{c(!1)}};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:l?void 0:t,children:o.jsx(Mt,{className:"w-full max-w-lg",onClick:x=>x.stopPropagation(),children:o.jsxs(At,{className:"p-0",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:o.jsx(as,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),o.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),o.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[o.jsx("button",{onClick:d,disabled:l,className:"text-sm text-bambu-green hover:text-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectAll",{defaultValue:"Select All"})}),o.jsx("span",{className:"text-bambu-gray",children:"|"}),o.jsx("button",{onClick:f,disabled:l,className:"text-sm text-bambu-gray hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectNone",{defaultValue:"Select None"})})]}),o.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${l?"opacity-50 pointer-events-none":""}`,children:l1.map(x=>o.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[x.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[o.jsx("input",{type:"checkbox",checked:r[x.id],onChange:()=>u(x.id),disabled:l,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),o.jsx("div",{className:`${r[x.id]?"text-bambu-green":"text-bambu-gray"}`,children:x.icon}),o.jsxs("div",{className:"flex-1",children:[o.jsx("div",{className:"text-white text-sm font-medium",children:n(x.labelKey,{defaultValue:x.defaultLabel})}),o.jsx("div",{className:"text-xs text-bambu-gray",children:x.description})]})]},x.id))}),r.archives&&o.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:o.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[o.jsx(lo,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),o.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[o.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),o.jsx("span",{className:"text-yellow-600 dark:text-yellow-200/70",children:" Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file."})]})]})}),r.printers&&o.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(ip,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),o.jsx(Bn,{checked:a,onChange:s})]}),a&&o.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:o.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[o.jsx(Gn,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),o.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),o.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:g,defaultValue:`${g} categories selected`})}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx(ke,{variant:"secondary",onClick:t,disabled:l,children:n("common.cancel",{defaultValue:"Cancel"})}),o.jsx(ke,{onClick:p,disabled:g===0||l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:l?o.jsxs(o.Fragment,{children:[o.jsx(pt,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):o.jsxs(o.Fragment,{children:[o.jsx(as,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const YG={settings:"Settings",notification_providers:"Notification Providers",notification_templates:"Notification Templates",smart_plugs:"Smart Plugs",printers:"Printers",filaments:"Filaments",maintenance_types:"Maintenance Types",archives:"Archives",projects:"Projects",pending_uploads:"Pending Uploads",external_links:"External Links"};function nWe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=S.useState("options"),[a,s]=S.useState(!1),[l,c]=S.useState(null),[u,d]=S.useState(null),[f,g]=S.useState(new Set),p=S.useRef(null);S.useEffect(()=>{const w=A=>{A.key==="Escape"&&r!=="restoring"&&t()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[t,r]);const x=w=>{const A=w.target.files?.[0];A&&c(A)},v=async()=>{if(l){i("restoring");try{const w=await e(l,a);d(w),i("result"),w.success&&n()}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},y=w=>{g(A=>{const T=new Set(A);return T.has(w)?T.delete(w):T.add(w),T})},b=u?.restored?Object.values(u.restored).reduce((w,A)=>w+A,0)+(u.files_restored||0):0,E=u?.total_skipped||0;return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onMouseDown:w=>{w.target===w.currentTarget&&r!=="restoring"&&t()},children:o.jsx(Mt,{className:"w-full max-w-lg",children:o.jsxs(At,{className:"p-0",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:`p-2 rounded-full ${r==="result"&&u?.success?"bg-bambu-green/20 text-bambu-green":r==="result"&&!u?.success?"bg-red-500/20 text-red-500":"bg-blue-500/20 text-blue-500"}`,children:r==="result"&&u?.success?o.jsx(kr,{className:"w-5 h-5"}):r==="result"&&!u?.success?o.jsx(Gn,{className:"w-5 h-5"}):o.jsx(ca,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsxs("h3",{className:"text-lg font-semibold text-white",children:[r==="options"&&"Restore Backup",r==="restoring"&&"Restoring...",r==="result"&&(u?.success?"Restore Complete":"Restore Failed")]}),o.jsxs("p",{className:"text-sm text-bambu-gray",children:[r==="options"&&"Import settings from a backup file",r==="restoring"&&"Please wait while your data is being restored",r==="result"&&u?.message]})]})]}),r!=="restoring"&&o.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),r==="options"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"p-4 space-y-4",children:[o.jsxs("div",{children:[o.jsx("input",{ref:p,type:"file",accept:".json,.zip",className:"hidden",onChange:x}),o.jsx("button",{type:"button",onClick:()=>p.current?.click(),className:`w-full p-4 border-2 border-dashed rounded-lg transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:l?o.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[o.jsx(kr,{className:"w-5 h-5"}),o.jsx("span",{className:"font-medium",children:l.name})]}):o.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[o.jsx(ca,{className:"w-8 h-8"}),o.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),o.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:o.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[o.jsx(Gn,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 mt-0.5 flex-shrink-0"}),o.jsxs("div",{className:"text-blue-700 dark:text-blue-200",children:[o.jsx("p",{className:"font-medium mb-1",children:"How duplicate handling works:"}),o.jsxs("ul",{className:"text-blue-600 dark:text-blue-200/80 space-y-1 text-xs",children:[o.jsxs("li",{children:[o.jsx("strong",{children:"Printers"})," - matched by serial number"]}),o.jsxs("li",{children:[o.jsx("strong",{children:"Smart Plugs"})," - matched by IP address"]}),o.jsxs("li",{children:[o.jsx("strong",{children:"Notification Providers"})," - matched by name"]}),o.jsxs("li",{children:[o.jsx("strong",{children:"Filaments"})," - matched by name + type + brand"]}),o.jsxs("li",{children:[o.jsx("strong",{children:"Archives"})," - matched by content hash (always skipped)"]}),o.jsxs("li",{children:[o.jsx("strong",{children:"Pending Uploads"})," - matched by filename"]}),o.jsxs("li",{children:[o.jsx("strong",{children:"Settings & Templates"})," - always overwritten"]})]})]})]})}),o.jsx("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsxs("p",{className:"text-white font-medium flex items-center gap-2",children:[a?o.jsx(li,{className:"w-4 h-4 text-orange-400"}):o.jsx(V1,{className:"w-4 h-4 text-bambu-gray"}),a?"Replace existing data":"Keep existing data"]}),o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a?"Overwrite items that already exist with backup data":"Only restore items that don't already exist"})]}),o.jsx(Bn,{checked:a,onChange:s})]})}),a&&o.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:o.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[o.jsx(Gn,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),o.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[o.jsx("span",{className:"font-medium",children:"Caution:"})," Overwriting will replace your current configurations with data from the backup. Printer access codes are never overwritten for security."]})]})})]}),o.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),o.jsxs(ke,{type:"button",onClick:v,disabled:!l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[o.jsx(ca,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&o.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[o.jsx(pt,{className:"w-12 h-12 text-bambu-green animate-spin"}),o.jsx("p",{className:"text-bambu-gray",children:"Processing backup file..."})]}),r==="result"&&u&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"p-4 space-y-4 max-h-[400px] overflow-y-auto",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{className:"p-3 rounded-lg bg-bambu-green/10 border border-bambu-green/30",children:[o.jsx("div",{className:"text-2xl font-bold text-bambu-green",children:b}),o.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Restored"})]}),o.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[o.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:E}),o.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),u.restored&&Object.entries(u.restored).some(([,w])=>w>0)&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[o.jsx(kr,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),o.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,w])=>w>0).map(([w,A])=>o.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[o.jsx("span",{className:"text-white",children:YG[w]||w}),o.jsx("span",{className:"text-bambu-green font-medium",children:A})]},w)),(u.files_restored||0)>0&&o.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[o.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),o.jsx("span",{className:"text-bambu-green font-medium",children:u.files_restored})]})]})]}),u.skipped&&Object.entries(u.skipped).some(([,w])=>w>0)&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[o.jsx(V1,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),o.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,w])=>w>0).map(([w,A])=>{const T=u.skipped_details?.[w]||[],C=f.has(w);return o.jsxs("div",{children:[o.jsxs("button",{onClick:()=>T.length>0&&y(w),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${T.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[o.jsxs("span",{className:"text-white flex items-center gap-2",children:[YG[w]||w,T.length>0&&(C?o.jsx(Tb,{className:"w-3 h-3"}):o.jsx(vo,{className:"w-3 h-3"}))]}),o.jsx("span",{className:"text-yellow-500 font-medium",children:A})]}),C&&T.length>0&&o.jsxs("div",{className:"mt-1 ml-4 p-2 rounded bg-bambu-dark-tertiary text-xs text-bambu-gray space-y-1",children:[T.slice(0,10).map((N,O)=>o.jsx("div",{children:N},O)),T.length>10&&o.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",T.length-10," more"]})]})]},w)})})]}),b===0&&E===0&&o.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),o.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:o.jsx(ke,{onClick:t,children:"Close"})})]})]})})})}async function rWe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function iWe(t){const e=await fetch("/api/v1/settings/spoolman",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error("Failed to save Spoolman settings");return e.json()}function aWe(){const t=pn(),[e,n]=S.useState(!1),[r,i]=S.useState(""),[a,s]=S.useState("auto"),[l,c]=S.useState(!1),[u,d]=S.useState("all"),[f,g]=S.useState(!1),[p,x]=S.useState(!1),{data:v,isLoading:y}=gt({queryKey:["spoolman-settings"],queryFn:rWe}),{data:b,isLoading:E,refetch:w}=gt({queryKey:["spoolman-status"],queryFn:_e.getSpoolmanStatus,refetchInterval:3e4}),{data:A}=gt({queryKey:["printers"],queryFn:_e.getPrinters});S.useEffect(()=>{v&&(n(v.spoolman_enabled==="true"),i(v.spoolman_url||""),s(v.spoolman_sync_mode||"auto"),g(!0))},[v]),S.useEffect(()=>{if(!f||!v)return;if(v.spoolman_enabled==="true"!==e||(v.spoolman_url||"")!==r||(v.spoolman_sync_mode||"auto")!==a){const q=setTimeout(()=>{T.mutate()},500);return()=>clearTimeout(q)}},[e,r,a,f]);const T=vt({mutationFn:()=>iWe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),c(!0),setTimeout(()=>c(!1),2e3)}}),C=vt({mutationFn:_e.connectSpoolman,onSuccess:()=>{w()}}),N=vt({mutationFn:_e.disconnectSpoolman,onSuccess:()=>{w()}}),O=vt({mutationFn:_e.syncAllPrintersAms,onSuccess:R=>{R.success}}),k=vt({mutationFn:R=>_e.syncPrinterAms(R),onSuccess:R=>{R.success}}),j=()=>{u==="all"?O.mutate():k.mutate(u)},B=O.isPending||k.isPending,L=u==="all"?O.data:k.data,K=u==="all"?O.isSuccess:k.isSuccess;return y?o.jsxs(Mt,{children:[o.jsx(Fi,{children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ep,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),o.jsx(At,{children:o.jsx("div",{className:"flex justify-center py-8",children:o.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):o.jsxs(Mt,{children:[o.jsx(Fi,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ep,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),T.isPending&&o.jsx(pt,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&o.jsx(po,{className:"w-4 h-4 text-bambu-green"})]})}),o.jsxs(At,{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),o.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:o.jsxs("div",{className:"flex gap-2",children:[o.jsx(tf,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),o.jsxs("div",{className:"text-xs text-blue-300",children:[o.jsx("p",{className:"font-medium mb-1",children:"How Sync Works"}),o.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[o.jsx("li",{children:"Only official Bambu Lab spools with RFID are synced"}),o.jsx("li",{children:"New spools are auto-created in Spoolman on first sync"}),o.jsx("li",{children:"Non-Bambu Lab spools (third-party, refilled) are skipped"})]}),o.jsx("p",{className:"font-medium mt-2 mb-1",children:"Linking Existing Spools"}),o.jsx("p",{className:"text-blue-300/80",children:'To link existing Spoolman spools to your AMS, hover over an AMS slot and click "Link to Spoolman".'})]})]})}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Enable Spoolman"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:e,onChange:R=>n(R.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),o.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:R=>i(R.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),o.jsxs("select",{value:a,onChange:R=>s(R.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[o.jsx("option",{value:"auto",children:"Automatic"}),o.jsx("option",{value:"manual",children:"Manual Only"})]}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&o.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),E?o.jsx(pt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):b?.connected?o.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[o.jsx(po,{className:"w-4 h-4"}),"Connected"]}):o.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[o.jsx(Wt,{className:"w-4 h-4"}),"Disconnected"]})]}),o.jsx("div",{className:"flex gap-2",children:b?.connected?o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>N.mutate(),disabled:N.isPending,children:[N.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(Ace,{className:"w-4 h-4"}),"Disconnect"]}):o.jsxs(ke,{size:"sm",onClick:()=>C.mutate(),disabled:C.isPending||!r,children:[C.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(Tp,{className:"w-4 h-4"}),"Connect"]})})]}),C.isError&&o.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:C.error.message}),b?.connected&&o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"relative flex-1",children:[o.jsxs("select",{value:u,onChange:R=>d(R.target.value==="all"?"all":Number(R.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[o.jsx("option",{value:"all",children:"All Printers"}),A?.map(R=>o.jsx("option",{value:R.id,children:R.name},R.id))]}),o.jsx(vo,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:j,disabled:B,children:[B?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(li,{className:"w-4 h-4"}),"Sync"]})]})]}),K&&L&&o.jsxs("div",{className:"mt-3 space-y-2",children:[o.jsx("div",{className:`p-2 rounded text-sm ${L.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:L.success?`Synced ${L.synced_count} spool${L.synced_count!==1?"s":""} successfully`:`Synced ${L.synced_count} spool${L.synced_count!==1?"s":""} with ${L.errors.length} error${L.errors.length!==1?"s":""}`}),L.skipped_count>0&&o.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[o.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(Gn,{className:"w-3.5 h-3.5"}),o.jsxs("span",{className:"font-medium",children:[L.skipped_count," spool",L.skipped_count!==1?"s":""," skipped"]})]}),L.skipped_count>5&&o.jsx("button",{onClick:()=>x(!p),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:p?"Show less":"Show all"})]}),o.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(p?L.skipped:L.skipped.slice(0,5)).map((R,q)=>o.jsxs("li",{className:"flex items-center gap-2",children:[R.color&&o.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${R.color}`}}),o.jsx("span",{children:R.location}),o.jsxs("span",{className:"text-amber-300/60",children:["- ",R.reason]})]},q)),!p&&L.skipped_count>5&&o.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",L.skipped_count-5," more"]})]})]}),L.errors.length>0&&o.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[o.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),o.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:L.errors.map((R,q)=>o.jsx("li",{children:R},q))})]})]})]})]})]})}function sWe({link:t,onClose:e}){const n=pn(),{mode:r}=og(),i=!!t,a=S.useRef(null),[s,l]=S.useState(t?.name||""),[c,u]=S.useState(t?.url||""),[d,f]=S.useState(t?.icon||"link"),[g,p]=S.useState(!!t?.custom_icon),[x,v]=S.useState(t?.custom_icon?_e.getExternalLinkIconUrl(t.id):null),[y,b]=S.useState(null),[E,w]=S.useState(null);S.useEffect(()=>{const B=L=>{L.key==="Escape"&&e()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e]);const A=vt({mutationFn:async B=>{const L=await _e.createExternalLink(B);return y?await _e.uploadExternalLinkIcon(L.id,y):L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:B=>{w(B.message)}}),T=vt({mutationFn:async B=>{let L=await _e.updateExternalLink(t.id,B);return y?L=await _e.uploadExternalLinkIcon(t.id,y):!g&&t?.custom_icon&&(L=await _e.deleteExternalLinkIcon(t.id)),L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:B=>{w(B.message)}}),C=B=>{const L=B.target.files?.[0];if(L){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(L.type)){w("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(L.size>1024*1024){w("Image file must be less than 1MB");return}b(L),p(!0);const R=new FileReader;R.onload=q=>{v(q.target?.result)},R.readAsDataURL(L)}},N=()=>{b(null),v(null),p(!1),a.current&&(a.current.value="")},O=B=>{if(B.preventDefault(),w(null),!s.trim()){w("Name is required");return}if(!c.trim()){w("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){w("URL must start with http:// or https://");return}const L={name:s.trim(),url:c.trim(),icon:d};i?T.mutate(L):A.mutate(L)},k=A.isPending||T.isPending,j=aM(d);return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:B=>B.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:g&&x?o.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):o.jsx(j,{className:"w-5 h-5"})}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),o.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("form",{onSubmit:O,className:"p-6 space-y-4",children:[E&&o.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:E}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),o.jsx("input",{type:"text",value:s,onChange:B=>l(B.target.value),placeholder:"My Link",maxLength:50,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),o.jsx("input",{type:"text",value:c,onChange:B=>u(B.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),o.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),o.jsx("input",{ref:a,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:C}),g&&x?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("img",{src:x,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),o.jsx("button",{type:"button",onClick:N,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:o.jsx(Nn,{className:"w-4 h-4"})})]}):o.jsxs(ke,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[o.jsx(ca,{className:"w-4 h-4"}),"Upload"]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!g&&o.jsxs("div",{children:[o.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),o.jsx(Fde,{value:d,onChange:f})]})]}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{type:"submit",disabled:k,className:"flex-1",children:[k?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(Ts,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function oWe(){const t=pn(),[e,n]=S.useState(!1),[r,i]=S.useState(null),[a,s]=S.useState(null),[l,c]=S.useState(null),{data:u,isLoading:d}=gt({queryKey:["external-links"],queryFn:_e.getExternalLinks}),f=vt({mutationFn:E=>_e.deleteExternalLink(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),g=vt({mutationFn:E=>_e.reorderExternalLinks(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=(E,w)=>{c(w),E.dataTransfer.effectAllowed="move"},x=E=>{E.preventDefault(),E.dataTransfer.dropEffect="move"},v=(E,w)=>{if(E.preventDefault(),l===null||l===w||!u)return;const A=u.map(O=>O.id),T=A.indexOf(l),C=A.indexOf(w);if(T===-1||C===-1)return;const N=[...A];N.splice(T,1),N.splice(C,0,l),g.mutate(N),c(null)},y=E=>{s(E)},b=()=>{a&&(f.mutate(a.id),s(null))};return o.jsxs(o.Fragment,{children:[o.jsxs(Mt,{children:[o.jsx(Fi,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Tp,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),o.jsxs(ke,{size:"sm",onClick:()=>n(!0),children:[o.jsx(fr,{className:"w-4 h-4"}),"Add Link"]})]})}),o.jsxs(At,{children:[o.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?o.jsx("div",{className:"flex justify-center py-8",children:o.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?o.jsx("div",{className:"space-y-2",children:u.map(E=>{const w=aM(E.icon);return o.jsxs("div",{draggable:!0,onDragStart:A=>p(A,E.id),onDragOver:x,onDrop:A=>v(A,E.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${l===E.id?"opacity-50":""}`,children:[o.jsx(D0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),o.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:o.jsx(w,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-white font-medium truncate",children:E.name}),o.jsx(la,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),o.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:E.url})]}),o.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[o.jsx("button",{onClick:()=>i(E),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:o.jsx(Bc,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>y(E),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:"Delete",children:o.jsx(Nn,{className:"w-4 h-4"})})]})]},E.id)})}):o.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[o.jsx(Tp,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),o.jsx("p",{children:"No external links configured"}),o.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&o.jsx(sWe,{link:r,onClose:()=>{n(!1),i(null)}}),a&&o.jsx(br,{title:"Delete Link",message:`Are you sure you want to delete "${a.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:b,onCancel:()=>s(null)})]})}function lWe(){const t=pn(),{showToast:e}=Ar(),[n,r]=S.useState(!1),[i,a]=S.useState(""),[s,l]=S.useState("immediate"),[c,u]=S.useState(!1),{data:d,isLoading:f}=gt({queryKey:["virtual-printer-settings"],queryFn:r3.getSettings,refetchInterval:1e4});S.useEffect(()=>{d&&(r(d.enabled),l(d.mode))},[d]);const g=vt({mutationFn:E=>r3.updateSettings(E),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated")},onError:E=>{e(E.message||"Failed to update settings","error"),d&&(r(d.enabled),l(d.mode))}}),p=()=>{const E=!n;if(E&&!i&&!d?.access_code_set){e("Please set an access code first","error");return}r(E),g.mutate({enabled:E,access_code:i||void 0,mode:s})},x=()=>{if(!i){e("Access code cannot be empty","error");return}if(i.length!==8){e("Access code must be exactly 8 characters","error");return}g.mutate({access_code:i}),a("")},v=E=>{l(E),g.mutate({mode:E})};if(f)return o.jsx(Mt,{children:o.jsx(At,{className:"py-8 flex justify-center",children:o.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const y=d?.status,b=y?.running||!1;return o.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[o.jsx("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:o.jsxs(Mt,{children:[o.jsx(Fi,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Gi,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Virtual Printer"})]}),y&&o.jsxs("div",{className:`flex items-center gap-2 text-sm ${b?"text-green-400":"text-bambu-gray"}`,children:[o.jsx("span",{className:`w-2 h-2 rounded-full ${b?"bg-green-400 animate-pulse":"bg-gray-500"}`}),b?"Running":"Stopped"]})]})}),o.jsxs(At,{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable a virtual printer that appears in Bambu Studio and OrcaSlicer. Files sent to this printer will be archived directly without printing."}),o.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-bambu-dark-tertiary",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-white font-medium",children:"Enable Virtual Printer"}),o.jsx("div",{className:"text-sm text-bambu-gray",children:b?'Visible as "Bambuddy" in slicer discovery':"Not visible to slicers"})]}),o.jsx("button",{onClick:p,disabled:g.isPending,className:`relative w-12 h-6 rounded-full transition-colors ${n?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${g.isPending?"opacity-50":""}`,children:o.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${n?"translate-x-6":""}`})})]}),o.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[o.jsx("div",{className:"text-white font-medium mb-2",children:"Access Code"}),o.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:d?.access_code_set?o.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[o.jsx(po,{className:"w-4 h-4"}),"Access code is set"]}):o.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[o.jsx(Gn,{className:"w-4 h-4"}),"No access code set - required to enable"]})}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("div",{className:"relative flex-1",children:[o.jsx("input",{type:c?"text":"password",value:i,onChange:E=>a(E.target.value),placeholder:d?.access_code_set?"Enter new code to change":"Enter 8-char code",maxLength:8,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray pr-10 font-mono"}),o.jsx("button",{onClick:()=>u(!c),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:c?o.jsx(JS,{className:"w-4 h-4"}):o.jsx(ef,{className:"w-4 h-4"})})]}),o.jsx(ke,{onClick:x,disabled:!i||g.isPending,variant:"primary",children:g.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):"Save"})]}),o.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["Must be exactly 8 characters. Used by slicers to authenticate.",i&&o.jsxs("span",{className:i.length===8?"text-green-400":"text-yellow-400",children:[" ","(",i.length,"/8)"]})]})]}),o.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[o.jsx("div",{className:"text-white font-medium mb-2",children:"Archive Mode"}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("button",{onClick:()=>v("immediate"),disabled:g.isPending,className:`p-3 rounded-lg border text-left transition-colors ${s==="immediate"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[o.jsx("div",{className:"text-white font-medium",children:"Immediate"}),o.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive files as soon as they are uploaded"})]}),o.jsxs("button",{onClick:()=>v("queue"),disabled:g.isPending,className:`p-3 rounded-lg border text-left transition-colors ${s==="queue"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[o.jsx("div",{className:"text-white font-medium",children:"Queue for Review"}),o.jsx("div",{className:"text-xs text-bambu-gray",children:"Review and tag files before archiving"})]})]})]})]})]})}),o.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[o.jsx(Mt,{children:o.jsx(At,{className:"py-4",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(tf,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),o.jsxs("div",{className:"text-sm text-bambu-gray",children:[o.jsx("p",{className:"mb-2",children:o.jsx("strong",{className:"text-white",children:"How it works:"})}),o.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[o.jsx("li",{children:"Enable the virtual printer and set an access code"}),o.jsx("li",{children:'In Bambu Studio or OrcaSlicer, go to "Add Printer"'}),o.jsx("li",{children:'The "Bambuddy" printer should appear in the discovery list'}),o.jsx("li",{children:"Connect using the access code you set"}),o.jsx("li",{children:'When you "print" to Bambuddy, the 3MF file is archived instead'})]}),o.jsxs("p",{className:"mt-3 text-yellow-400/80",children:[o.jsx(Gn,{className:"w-4 h-4 inline mr-1"}),"Required ports: 2021 (SSDP), 8883 (MQTT), 990 (FTP)"]}),o.jsxs("div",{className:"mt-2 text-xs text-bambu-gray space-y-1",children:[o.jsx("p",{children:"Port 990 requires root or iptables redirect:"}),o.jsx("code",{className:"block bg-bambu-dark-tertiary px-2 py-1 rounded text-[10px]",children:"sudo iptables -t nat -A PREROUTING -p tcp --dport 990 -j REDIRECT --to-port 9990"}),o.jsx("code",{className:"block bg-bambu-dark-tertiary px-2 py-1 rounded text-[10px]",children:"sudo iptables -t nat -A OUTPUT -o lo -p tcp --dport 990 -j REDIRECT --to-port 9990"})]})]})]})})}),y&&b&&o.jsxs(Mt,{children:[o.jsx(Fi,{children:o.jsx("h3",{className:"text-md font-semibold text-white",children:"Status Details"})}),o.jsx(At,{children:o.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-bambu-gray",children:"Printer Name"}),o.jsx("div",{className:"text-white",children:y.name})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-bambu-gray",children:"Model"}),o.jsx("div",{className:"text-white",children:y.model?.replace("3DPrinter-","").replace("-"," ")||"X1 Carbon"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-bambu-gray",children:"Serial Number"}),o.jsx("div",{className:"text-white font-mono",children:y.serial})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-bambu-gray",children:"Mode"}),o.jsx("div",{className:"text-white capitalize",children:y.mode})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-bambu-gray",children:"Pending Files"}),o.jsx("div",{className:"text-white",children:y.pending_files})]})]})})]})]})]})}const cWe={get:"bg-blue-500/20 text-blue-400 border-blue-500/30",post:"bg-green-500/20 text-green-400 border-green-500/30",put:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",patch:"bg-orange-500/20 text-orange-400 border-orange-500/30",delete:"bg-red-500/20 text-red-400 border-red-500/30"};function uWe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function r0(t,e,n=0){if(n>5)return"...";if(e.$ref)return r0(t,uWe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const a=r0(t,i,n+1);typeof a=="object"&&a!==null&&Object.assign(r,a)}return r}if(e.example!==void 0)return e.example;if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:"string";case"integer":case"number":return 0;case"boolean":return!1;case"array":return e.items?[r0(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,a]of Object.entries(e.properties))r[i]=r0(t,a,n+1);return r}return{};default:return null}}function dWe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[a,s]=S.useState(!1),[l,c]=S.useState({}),[u,d]=S.useState(""),[f,g]=S.useState(null),[p,x]=S.useState(!1),[v,y]=S.useState(!1);S.useEffect(()=>{if(a&&n.parameters){const O={};for(const k of n.parameters)k.schema?.default!==void 0&&(O[k.name]=String(k.schema.default));c(k=>({...O,...k}))}},[a,n.parameters]),S.useEffect(()=>{if(a&&n.requestBody?.content?.["application/json"]?.schema&&!u){const O=n.requestBody.content["application/json"].schema,k=r0(r,O);d(JSON.stringify(k,null,2))}},[a,n.requestBody,r,u]);const E=(()=>{const O=[];for(const k of n.parameters||[])if(k.in==="path"||k.required){const j=l[k.name];(j===void 0||j==="")&&O.push(k.name)}return O})(),w=async()=>{if(E.length>0){g({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${E.join(", ")}`,duration:0});return}x(!0),g(null);try{let O=t;const k=new URLSearchParams;for(const Q of n.parameters||[]){const z=l[Q.name];z!==void 0&&z!==""&&(Q.in==="path"?O=O.replace(`{${Q.name}}`,encodeURIComponent(z)):Q.in==="query"&&k.append(Q.name,z))}const j=k.toString(),B=`${O}${j?`?${j}`:""}`,L={"Content-Type":"application/json"};i&&(L["X-API-Key"]=i);const K={method:e.toUpperCase(),headers:L};["post","put","patch"].includes(e)&&u&&(K.body=u);const R=performance.now(),q=await fetch(B,K),W=Math.round(performance.now()-R),$={};q.headers.forEach((Q,z)=>{$[z]=Q});let J;q.headers.get("content-type")?.includes("application/json")?J=await q.json():J=await q.text(),g({status:q.status,statusText:q.statusText,headers:$,body:J,duration:W})}catch(O){g({status:0,statusText:"Network Error",headers:{},body:O instanceof Error?O.message:"Unknown error",duration:0})}finally{x(!1)}},A=async()=>{if(f){const O=typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2);try{await navigator.clipboard.writeText(O),y(!0),setTimeout(()=>y(!1),2e3)}catch{const k=document.createElement("textarea");k.value=O,k.style.position="fixed",k.style.left="-999999px",document.body.appendChild(k),k.select(),document.execCommand("copy"),document.body.removeChild(k),y(!0),setTimeout(()=>y(!1),2e3)}}},T=(n.parameters||[]).filter(O=>O.in==="path"),C=(n.parameters||[]).filter(O=>O.in==="query"),N=["post","put","patch"].includes(e)&&n.requestBody;return o.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[o.jsxs("button",{onClick:()=>s(!a),className:"w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left",children:[a?o.jsx(vo,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):o.jsx(Ko,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),o.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${cWe[e]||"bg-gray-500/20 text-gray-400"}`,children:e}),o.jsx("code",{className:"text-sm text-white font-mono flex-1 truncate",children:t}),n.summary&&o.jsx("span",{className:"text-sm text-bambu-gray truncate max-w-[40%]",children:n.summary})]}),a&&o.jsxs("div",{className:"border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50",children:[n.description&&o.jsx("p",{className:"text-sm text-bambu-gray",children:n.description}),T.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("h4",{className:"text-sm font-medium text-white",children:"Path Parameters"}),o.jsx("div",{className:"space-y-2",children:T.map(O=>o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[O.name,O.required&&o.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),o.jsx("input",{type:"text",value:l[O.name]||"",onChange:k=>c(j=>({...j,[O.name]:k.target.value})),placeholder:O.description||O.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},O.name))})]}),C.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("h4",{className:"text-sm font-medium text-white",children:"Query Parameters"}),o.jsx("div",{className:"space-y-2",children:C.map(O=>o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[O.name,O.required&&o.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),O.schema?.enum?o.jsxs("select",{value:l[O.name]||"",onChange:k=>c(j=>({...j,[O.name]:k.target.value})),className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"",children:"-- Select --"}),O.schema.enum.map(k=>o.jsx("option",{value:k,children:k},k))]}):o.jsx("input",{type:"text",value:l[O.name]||"",onChange:k=>c(j=>({...j,[O.name]:k.target.value})),placeholder:O.description||O.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},O.name))})]}),N&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("h4",{className:"text-sm font-medium text-white",children:"Request Body"}),o.jsx("textarea",{value:u,onChange:O=>d(O.target.value),rows:8,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono focus:border-bambu-green focus:outline-none resize-y",placeholder:"JSON request body..."})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(ke,{onClick:w,disabled:p,children:[p?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(xd,{className:"w-4 h-4"}),"Execute"]}),E.length>0&&o.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[o.jsx(Oa,{className:"w-3 h-3"}),"Fill in: ",E.join(", ")]})]}),f&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("h4",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Response",o.jsxs("span",{className:`px-2 py-0.5 text-xs rounded ${f.status>=200&&f.status<300?"bg-green-500/20 text-green-400":f.status>=400?"bg-red-500/20 text-red-400":"bg-yellow-500/20 text-yellow-400"}`,children:[f.status," ",f.statusText]}),o.jsxs("span",{className:"text-xs text-bambu-gray",children:[f.duration,"ms"]})]}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:A,children:v?o.jsx(kr,{className:"w-3 h-3 text-green-400"}):o.jsx(vl,{className:"w-3 h-3"})})]}),o.jsx("pre",{className:"p-3 bg-bambu-dark rounded-lg text-sm font-mono text-white overflow-auto max-h-96 border border-bambu-dark-tertiary",children:typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2)})]})]})]})}function hWe({apiKey:t=""}){const[e,n]=S.useState(null),[r,i]=S.useState(!0),[a,s]=S.useState(null),[l,c]=S.useState(new Set),[u,d]=S.useState("");if(S.useEffect(()=>{async function y(){try{const b=await fetch("/openapi.json");if(!b.ok)throw new Error("Failed to fetch OpenAPI schema");const E=await b.json();n(E)}catch(b){s(b instanceof Error?b.message:"Unknown error")}finally{i(!1)}}y()},[]),r)return o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(a||!e)return o.jsx(Mt,{children:o.jsx(At,{className:"py-8",children:o.jsxs("div",{className:"text-center text-red-400",children:[o.jsx(Oa,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),o.jsx("p",{children:"Failed to load API schema"}),o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a})]})})});const f={};for(const[y,b]of Object.entries(e.paths))for(const[E,w]of Object.entries(b)){if(E==="parameters")continue;const A=w.tags||["Other"];for(const T of A)f[T]||(f[T]=[]),f[T].push({path:y,method:E,spec:w})}const g=Object.entries(f).map(([y,b])=>{if(!u)return{tag:y,endpoints:b};const E=b.filter(({path:w,method:A,spec:T})=>{const C=u.toLowerCase();return w.toLowerCase().includes(C)||A.toLowerCase().includes(C)||(T.summary?.toLowerCase()||"").includes(C)||(T.description?.toLowerCase()||"").includes(C)});return{tag:y,endpoints:E}}).filter(({endpoints:y})=>y.length>0).sort((y,b)=>y.tag.localeCompare(b.tag)),p=y=>{c(b=>{const E=new Set(b);return E.has(y)?E.delete(y):E.add(y),E})},x=()=>{c(new Set(g.map(y=>y.tag)))},v=()=>{c(new Set)};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx("div",{className:"flex-1",children:o.jsx("input",{type:"text",value:u,onChange:y=>d(y.target.value),placeholder:"Search endpoints...",className:"w-full max-w-md px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ke,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:v,children:"Collapse All"}),o.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[o.jsx(la,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),o.jsxs("p",{className:"text-sm text-bambu-gray",children:[g.reduce((y,b)=>y+b.endpoints.length,0)," endpoints in ",g.length," categories"]}),o.jsx("div",{className:"space-y-3",children:g.map(({tag:y,endpoints:b})=>o.jsxs(Mt,{children:[o.jsx("button",{onClick:()=>p(y),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left",children:o.jsxs("div",{className:"flex items-center gap-2",children:[l.has(y)?o.jsx(vo,{className:"w-5 h-5 text-bambu-gray"}):o.jsx(Ko,{className:"w-5 h-5 text-bambu-gray"}),o.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:y.replace(/-/g," ")}),o.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:b.length})]})}),l.has(y)&&o.jsx(At,{className:"pt-0 space-y-2",children:b.map(({path:E,method:w,spec:A})=>o.jsx(dWe,{path:E,method:w,spec:A,schema:e,apiKey:t},`${w}-${E}`))})]},y))})]})}function fWe(){const t=pn(),{t:e,i18n:n}=ng(),{showToast:r,showPersistentToast:i,dismissToast:a}=Ar(),{mode:s,darkStyle:l,darkBackground:c,darkAccent:u,lightStyle:d,lightBackground:f,lightAccent:g,setDarkStyle:p,setDarkBackground:x,setDarkAccent:v,setLightStyle:y,setLightBackground:b,setLightAccent:E}=og(),[w,A]=S.useState(null),[T,C]=S.useState(!1),[N,O]=S.useState(null),[k,j]=S.useState(!1),[B,L]=S.useState(null),[K,R]=S.useState(null),[q,W]=S.useState(!1),[$,J]=S.useState(J9()),[ee,Q]=S.useState("general"),[z,V]=S.useState(!1),[X,te]=S.useState(""),[ie,le]=S.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[ge,Ee]=S.useState(null),[pe,de]=S.useState(null),[Re,fe]=S.useState(""),[Fe,U]=S.useState(!1),[H,re]=S.useState(!1),[G,Z]=S.useState(null),[oe,be]=S.useState(!1),[Te,Me]=S.useState(!1),[F,I]=S.useState(!1),[ne,ve]=S.useState(!1),Se=Le=>{J(Le),Bde(Le)},ye=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:Ke,isLoading:We}=gt({queryKey:["settings"],queryFn:_e.getSettings}),{data:qe,isLoading:ut}=gt({queryKey:["smart-plugs"],queryFn:_e.getSmartPlugs}),{data:ue,isLoading:se}=gt({queryKey:["smart-plugs-energy",qe?.map(Le=>Le.id)],queryFn:async()=>{if(!qe||qe.length===0)return null;const Le=await Promise.all(qe.filter(yt=>yt.enabled).map(async yt=>{try{const ae=await _e.getSmartPlugStatus(yt.id);return{plug:yt,status:ae}}catch{return{plug:yt,status:null}}}));let he=0,ze=0,et=0,st=0,rt=0;for(const{status:yt}of Le)yt?.reachable&&yt.energy&&(rt++,yt.energy.power!=null&&(he+=yt.energy.power),yt.energy.today!=null&&(ze+=yt.energy.today),yt.energy.yesterday!=null&&(et+=yt.energy.yesterday),yt.energy.total!=null&&(st+=yt.energy.total));return{totalPower:he,totalToday:ze,totalYesterday:et,totalLifetime:st,reachableCount:rt,totalPlugs:qe.filter(yt=>yt.enabled).length}},enabled:ee==="plugs"&&!!qe&&qe.length>0,refetchInterval:ee==="plugs"?1e4:!1}),{data:Ve,isLoading:Be}=gt({queryKey:["notification-providers"],queryFn:_e.getNotificationProviders}),{data:Ze,isLoading:ht}=gt({queryKey:["api-keys"],queryFn:_e.getAPIKeys}),me=vt({mutationFn:Le=>_e.createAPIKey(Le),onSuccess:Le=>{Ee(Le.key||null),V(!1),te(""),t.invalidateQueries({queryKey:["api-keys"]}),r("API key created")},onError:Le=>{r(`Failed to create API key: ${Le.message}`,"error")}}),nt=vt({mutationFn:Le=>_e.deleteAPIKey(Le),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),r("API key deleted")},onError:Le=>{r(`Failed to delete API key: ${Le.message}`,"error")}}),{data:xe}=gt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:He,isLoading:Pe}=gt({queryKey:["notification-templates"],queryFn:_e.getNotificationTemplates}),{data:we}=gt({queryKey:["virtual-printer-settings"],queryFn:r3.getSettings,refetchInterval:1e4}),Ae=we?.status?.running??!1,{data:lt}=gt({queryKey:["ffmpeg-status"],queryFn:_e.checkFfmpeg}),{data:_t}=gt({queryKey:["version"],queryFn:_e.getVersion}),{data:Xe,refetch:Ut,isRefetching:Ct}=gt({queryKey:["updateCheck"],queryFn:_e.checkForUpdates,staleTime:300*1e3}),{data:$t,refetch:gn}=gt({queryKey:["updateStatus"],queryFn:_e.getUpdateStatus,refetchInterval:Le=>{const he=Le.state.data;return he?.status==="downloading"||he?.status==="installing"?1e3:!1}}),Fn=vt({mutationFn:_e.applyUpdate,onSuccess:Le=>{Le.is_docker?r(Le.message,"error"):gn()}}),[It,Yt]=S.useState(null),Jn=vt({mutationFn:_e.testAllNotificationProviders,onSuccess:Le=>{Yt(Le),t.invalidateQueries({queryKey:["notification-providers"]}),Le.failed===0?r(`All ${Le.tested} providers tested successfully!`,"success"):r(`${Le.success}/${Le.tested} providers succeeded`,Le.failed>0?"error":"success")},onError:Le=>{r(`Failed to test providers: ${Le.message}`,"error")}}),er=vt({mutationFn:async Le=>{if(!qe)return{success:0,failed:0};const he=qe.filter(et=>et.enabled),ze=await Promise.all(he.map(async et=>{try{return await _e.controlSmartPlug(et.id,Le),{success:!0}}catch{return{success:!1}}}));return{success:ze.filter(et=>et.success).length,failed:ze.filter(et=>!et.success).length}},onSuccess:(Le,he)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),Le.failed===0?r(`All ${Le.success} plugs turned ${he}`,"success"):r(`${Le.success} plugs turned ${he}, ${Le.failed} failed`,"error")},onError:Le=>{r(`Failed: ${Le.message}`,"error")}}),Hn=S.useRef(null),Un=S.useRef(!0);S.useEffect(()=>{Ke&&!w&&(A(Ke),setTimeout(()=>{Un.current=!1},100))},[Ke,w]);const jn=vt({mutationFn:_e.updateSettings,onSuccess:Le=>{t.setQueryData(["settings"],Le),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:Le=>{r(`Failed to save: ${Le.message}`,"error")}});S.useEffect(()=>{if(!(Un.current||!w||!Ke||!(Ke.auto_archive!==w.auto_archive||Ke.save_thumbnails!==w.save_thumbnails||Ke.capture_finish_photo!==w.capture_finish_photo||Ke.default_filament_cost!==w.default_filament_cost||Ke.currency!==w.currency||Ke.energy_cost_per_kwh!==w.energy_cost_per_kwh||Ke.energy_tracking_mode!==w.energy_tracking_mode||Ke.check_updates!==w.check_updates||Ke.notification_language!==w.notification_language||Ke.telemetry_enabled!==w.telemetry_enabled||Ke.ams_humidity_good!==w.ams_humidity_good||Ke.ams_humidity_fair!==w.ams_humidity_fair||Ke.ams_temp_good!==w.ams_temp_good||Ke.ams_temp_fair!==w.ams_temp_fair||Ke.ams_history_retention_days!==w.ams_history_retention_days||Ke.date_format!==w.date_format||Ke.time_format!==w.time_format||Ke.default_printer_id!==w.default_printer_id)))return Hn.current&&clearTimeout(Hn.current),Hn.current=setTimeout(()=>{const he={auto_archive:w.auto_archive,save_thumbnails:w.save_thumbnails,capture_finish_photo:w.capture_finish_photo,default_filament_cost:w.default_filament_cost,currency:w.currency,energy_cost_per_kwh:w.energy_cost_per_kwh,energy_tracking_mode:w.energy_tracking_mode,check_updates:w.check_updates,notification_language:w.notification_language,telemetry_enabled:w.telemetry_enabled,ams_humidity_good:w.ams_humidity_good,ams_humidity_fair:w.ams_humidity_fair,ams_temp_good:w.ams_temp_good,ams_temp_fair:w.ams_temp_fair,ams_history_retention_days:w.ams_history_retention_days,date_format:w.date_format,time_format:w.time_format,default_printer_id:w.default_printer_id};jn.mutate(he)},500),()=>{Hn.current&&clearTimeout(Hn.current)}},[w,Ke,jn]);const sn=S.useCallback((Le,he)=>{A(ze=>ze?{...ze,[Le]:he}:null)},[]);return We||!w?o.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):o.jsxs("div",{className:"p-4 md:p-8",children:[o.jsxs("div",{className:"mb-8",children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),o.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),o.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[o.jsx("button",{onClick:()=>Q("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${ee==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:"General"}),o.jsxs("button",{onClick:()=>Q("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ee==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[o.jsx(co,{className:"w-4 h-4"}),"Smart Plugs",qe&&qe.length>0&&o.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:qe.length})]}),o.jsxs("button",{onClick:()=>Q("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ee==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[o.jsx(Dh,{className:"w-4 h-4"}),"Notifications",Ve&&Ve.length>0&&o.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ve.length})]}),o.jsxs("button",{onClick:()=>Q("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ee==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[o.jsx(Mle,{className:"w-4 h-4"}),"Filament"]}),o.jsxs("button",{onClick:()=>Q("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ee==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[o.jsx(ip,{className:"w-4 h-4"}),"API Keys",Ze&&Ze.length>0&&o.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ze.length})]}),o.jsxs("button",{onClick:()=>Q("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ee==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[o.jsx(Gi,{className:"w-4 h-4"}),"Virtual Printer",o.jsx("span",{className:`w-2 h-2 rounded-full ${Ae?"bg-green-400":"bg-gray-500"}`})]})]}),ee==="general"&&o.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[o.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[o.jsxs(Mt,{children:[o.jsx(Fi,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),o.jsxs(At,{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[o.jsx(Ap,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),o.jsx("select",{value:n.language,onChange:Le=>n.changeLanguage(Le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:nU.map(Le=>o.jsxs("option",{value:Le.code,children:[Le.nativeName," (",Le.name,")"]},Le.code))}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),o.jsx("select",{value:$,onChange:Le=>Se(Le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:L0.map(Le=>o.jsx("option",{value:Le.to,children:e(Le.labelKey)},Le.id))}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),o.jsxs("select",{value:w.date_format||"system",onChange:Le=>sn("date_format",Le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"system",children:"System Default"}),o.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),o.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),o.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),o.jsxs("select",{value:w.time_format||"system",onChange:Le=>sn("time_format",Le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"system",children:"System Default"}),o.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),o.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),o.jsxs("select",{value:w.default_printer_id??"",onChange:Le=>sn("default_printer_id",Le.target.value?Number(Le.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"",children:"No default (ask each time)"}),xe?.map(Le=>o.jsx("option",{value:Le.id,children:Le.name},Le.id))]}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Sidebar order"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:ye,children:[o.jsx(sg,{className:"w-4 h-4"}),"Reset"]})]})]})]}),o.jsxs(Mt,{children:[o.jsx(Fi,{children:o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(pR,{className:"w-5 h-5"}),"Appearance"]})}),o.jsxs(At,{className:"space-y-6",children:[o.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${s==="dark"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[o.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Dark Mode",s==="dark"&&o.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),o.jsxs("select",{value:c,onChange:Le=>{x(Le.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"neutral",children:"Neutral"}),o.jsx("option",{value:"warm",children:"Warm"}),o.jsx("option",{value:"cool",children:"Cool"}),o.jsx("option",{value:"oled",children:"OLED Black"}),o.jsx("option",{value:"slate",children:"Slate Blue"}),o.jsx("option",{value:"forest",children:"Forest Green"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),o.jsxs("select",{value:u,onChange:Le=>{v(Le.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"green",children:"Green"}),o.jsx("option",{value:"teal",children:"Teal"}),o.jsx("option",{value:"blue",children:"Blue"}),o.jsx("option",{value:"orange",children:"Orange"}),o.jsx("option",{value:"purple",children:"Purple"}),o.jsx("option",{value:"red",children:"Red"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),o.jsxs("select",{value:l,onChange:Le=>{p(Le.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"classic",children:"Classic"}),o.jsx("option",{value:"glow",children:"Glow"}),o.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),o.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${s==="light"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[o.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Light Mode",s==="light"&&o.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),o.jsxs("select",{value:f,onChange:Le=>{b(Le.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"neutral",children:"Neutral"}),o.jsx("option",{value:"warm",children:"Warm"}),o.jsx("option",{value:"cool",children:"Cool"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),o.jsxs("select",{value:g,onChange:Le=>{E(Le.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"green",children:"Green"}),o.jsx("option",{value:"teal",children:"Teal"}),o.jsx("option",{value:"blue",children:"Blue"}),o.jsx("option",{value:"orange",children:"Orange"}),o.jsx("option",{value:"purple",children:"Purple"}),o.jsx("option",{value:"red",children:"Red"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),o.jsxs("select",{value:d,onChange:Le=>{y(Le.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"classic",children:"Classic"}),o.jsx("option",{value:"glow",children:"Glow"}),o.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Toggle between dark and light mode using the sun/moon icon in the sidebar."})]})]}),o.jsxs(Mt,{children:[o.jsx(Fi,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),o.jsxs(At,{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Auto-archive prints"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:w.auto_archive,onChange:Le=>sn("auto_archive",Le.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Save thumbnails"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:w.save_thumbnails,onChange:Le=>sn("save_thumbnails",Le.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Capture finish photo"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:w.capture_finish_photo,onChange:Le=>sn("capture_finish_photo",Le.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),w.capture_finish_photo&<&&!lt.installed&&o.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[o.jsx(Gn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),o.jsxs("div",{className:"text-sm",children:[o.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),o.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",o.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",o.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]})]}),o.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[o.jsxs(Mt,{children:[o.jsx(Fi,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),o.jsxs(At,{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),o.jsx("input",{type:"number",step:"0.01",min:"0",value:w.default_filament_cost,onChange:Le=>sn("default_filament_cost",parseFloat(Le.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),o.jsxs("select",{value:w.currency,onChange:Le=>sn("currency",Le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"USD",children:"USD ($)"}),o.jsx("option",{value:"EUR",children:"EUR (€)"}),o.jsx("option",{value:"GBP",children:"GBP (£)"}),o.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),o.jsx("option",{value:"JPY",children:"JPY (¥)"}),o.jsx("option",{value:"CNY",children:"CNY (¥)"}),o.jsx("option",{value:"CAD",children:"CAD ($)"}),o.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),o.jsx("input",{type:"number",step:"0.01",min:"0",value:w.energy_cost_per_kwh,onChange:Le=>sn("energy_cost_per_kwh",parseFloat(Le.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),o.jsxs("select",{value:w.energy_tracking_mode||"total",onChange:Le=>sn("energy_tracking_mode",Le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"print",children:"Prints Only"}),o.jsx("option",{value:"total",children:"Total Consumption"})]}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:w.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),o.jsxs(Mt,{children:[o.jsx(Fi,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),o.jsxs(At,{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-white",children:[o.jsx(uR,{className:"w-4 h-4 text-blue-400"}),o.jsx("span",{className:"font-medium",children:"Humidity"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"number",min:"0",max:"100",value:w.ams_humidity_good??40,onChange:Le=>sn("ams_humidity_good",parseInt(Le.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),o.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"number",min:"0",max:"100",value:w.ams_humidity_fair??60,onChange:Le=>sn("ams_humidity_fair",parseInt(Le.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),o.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),o.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2 text-white",children:[o.jsx(iM,{className:"w-4 h-4 text-orange-400"}),o.jsx("span",{className:"font-medium",children:"Temperature"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:w.ams_temp_good??28,onChange:Le=>sn("ams_temp_good",parseFloat(Le.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),o.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:w.ams_temp_fair??35,onChange:Le=>sn("ams_temp_fair",parseFloat(Le.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),o.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]}),o.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-2 text-white",children:[o.jsx(Ep,{className:"w-4 h-4 text-purple-400"}),o.jsx("span",{className:"font-medium",children:"History Retention"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Keep sensor history for"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"number",min:"1",max:"365",value:w.ams_history_retention_days??30,onChange:Le=>sn("ams_history_retention_days",parseInt(Le.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),o.jsx("span",{className:"text-bambu-gray",children:"days"})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Older humidity and temperature data will be automatically deleted"})]})]})]})]}),o.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[o.jsx(oWe,{}),o.jsxs(Mt,{children:[o.jsx(Fi,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),o.jsxs(At,{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Check for updates"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:w.check_updates,onChange:Le=>sn("check_updates",Le.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("p",{className:"text-white",children:e("settings.telemetry")}),o.jsxs("button",{onClick:()=>I(!0),className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs bg-bambu-dark rounded-full text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary transition-colors",children:[o.jsx(tf,{className:"w-3 h-3"}),e("settings.telemetryLearnMore")]})]}),o.jsx("p",{className:"text-sm text-bambu-gray",children:e("settings.telemetryDescription")})]}),o.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:w.telemetry_enabled,onChange:Le=>sn("telemetry_enabled",Le.target.checked),className:"sr-only peer"}),o.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),o.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Current version"}),o.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",_t?.version||"..."]})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>Ut(),disabled:Ct,children:[Ct?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(li,{className:"w-4 h-4"}),"Check now"]})]}),Xe?.update_available?o.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[o.jsxs("div",{className:"flex items-start justify-between",children:[o.jsxs("div",{children:[o.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",Xe.latest_version]}),Xe.release_name&&Xe.release_name!==Xe.latest_version&&o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:Xe.release_name})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[Xe.release_notes&&o.jsx("button",{onClick:()=>ve(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),Xe.release_url&&o.jsx("a",{href:Xe.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:o.jsx(la,{className:"w-4 h-4"})})]})]}),$t?.status==="downloading"||$t?.status==="installing"?o.jsxs("div",{className:"mt-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[o.jsx(pt,{className:"w-4 h-4 animate-spin"}),o.jsx("span",{children:$t.message})]}),o.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:o.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${$t.progress}%`}})})]}):$t?.status==="complete"?o.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:$t.message}):$t?.status==="error"?o.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:$t.error||$t.message}):Xe?.is_docker?o.jsxs("div",{className:"mt-3 p-3 bg-bambu-dark-tertiary rounded-lg",children:[o.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Update via Docker Compose:"}),o.jsx("code",{className:"block text-xs bg-bambu-dark p-2 rounded text-bambu-green font-mono",children:"docker compose pull && docker compose up -d"})]}):o.jsxs(ke,{className:"mt-3",onClick:()=>Fn.mutate(),disabled:Fn.isPending,children:[Fn.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(as,{className:"w-4 h-4"}),"Install Update"]})]}):Xe?.error?o.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:["Failed to check for updates: ",Xe.error]}):Xe&&!Xe.update_available?o.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),o.jsxs(Mt,{children:[o.jsx(Fi,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),o.jsxs(At,{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Backup Data"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>be(!0),children:[o.jsx(as,{className:"w-4 h-4"}),"Export"]})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Restore Backup"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>Me(!0),children:[o.jsx(ca,{className:"w-4 h-4"}),"Restore"]})]}),o.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>U(!0),children:[o.jsx(Nn,{className:"w-4 h-4"}),"Clear"]})]})}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected."})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>re(!0),children:[o.jsx(Nn,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),ee==="plugs"&&o.jsxs("div",{className:"max-w-4xl",children:[o.jsxs("div",{className:"flex items-start justify-between mb-6",children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(co,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect Tasmota-based smart plugs to automate power control and track energy usage for your printers."})]}),o.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[qe&&qe.filter(Le=>Le.enabled).length>1&&o.jsxs(o.Fragment,{children:[o.jsxs(ke,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>Z("on"),disabled:er.isPending,title:"Turn all plugs on",children:[er.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(jl,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),o.jsxs(ke,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>Z("off"),disabled:er.isPending,title:"Turn all plugs off",children:[er.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(nM,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),o.jsxs(ke,{className:"whitespace-nowrap",onClick:()=>{O(null),C(!0)},children:[o.jsx(fr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),qe&&qe.length>0&&o.jsxs(Mt,{className:"mb-6",children:[o.jsx(Fi,{children:o.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[o.jsx(sf,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",se&&o.jsx(pt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),o.jsx(At,{children:ue?o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[o.jsx(sf,{className:"w-3 h-3"}),"Current Power"]}),o.jsxs("div",{className:"text-xl font-bold text-white",children:[ue.totalPower.toFixed(1),o.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),o.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[ue.reachableCount,"/",ue.totalPlugs," plugs online"]})]}),o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[o.jsx(Jr,{className:"w-3 h-3"}),"Today"]}),o.jsxs("div",{className:"text-xl font-bold text-white",children:[ue.totalToday.toFixed(2),o.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),w&&w.energy_cost_per_kwh>0&&o.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ue.totalToday*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]}),o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[o.jsx(q9,{className:"w-3 h-3"}),"Yesterday"]}),o.jsxs("div",{className:"text-xl font-bold text-white",children:[ue.totalYesterday.toFixed(2),o.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),w&&w.energy_cost_per_kwh>0&&o.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ue.totalYesterday*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]}),o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[o.jsx(Yk,{className:"w-3 h-3"}),"Total"]}),o.jsxs("div",{className:"text-xl font-bold text-white",children:[ue.totalLifetime.toFixed(1),o.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),w&&w.energy_cost_per_kwh>0&&o.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(ue.totalLifetime*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]})]}):se?null:o.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),ut?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):qe&&qe.length>0?o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:qe.map(Le=>o.jsx(G9e,{plug:Le,onEdit:he=>{O(he),C(!0)}},Le.id))}):o.jsx(Mt,{children:o.jsx(At,{className:"py-12",children:o.jsxs("div",{className:"text-center text-bambu-gray",children:[o.jsx(co,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),o.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),o.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),o.jsxs(ke,{onClick:()=>{O(null),C(!0)},children:[o.jsx(fr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),ee==="notifications"&&o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(Dh,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>W(!0),children:[o.jsx(H1,{className:"w-4 h-4"}),"Log"]}),Ve&&Ve.length>0&&o.jsxs(ke,{size:"sm",variant:"secondary",onClick:()=>{Yt(null),Jn.mutate()},disabled:Jn.isPending,children:[Jn.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(bR,{className:"w-4 h-4"}),"Test All"]}),o.jsxs(ke,{size:"sm",onClick:()=>{L(null),j(!0)},children:[o.jsx(fr,{className:"w-4 h-4"}),"Add"]})]})]}),o.jsx(Mt,{className:"mb-4",children:o.jsx(At,{className:"py-3",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-white text-sm font-medium",children:e("settings.notificationLanguage")}),o.jsx("p",{className:"text-xs text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),o.jsx("select",{value:w.notification_language||"en",onChange:Le=>sn("notification_language",Le.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:nU.map(Le=>o.jsx("option",{value:Le.code,children:Le.nativeName},Le.code))})]})})}),It&&o.jsx(Mt,{className:"mb-4",children:o.jsxs(At,{className:"py-3",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),o.jsx("button",{onClick:()=>Yt(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),o.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[o.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[o.jsx(kr,{className:"w-4 h-4"}),It.success," passed"]}),It.failed>0&&o.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[o.jsx(Pa,{className:"w-4 h-4"}),It.failed," failed"]})]}),It.results.filter(Le=>!Le.success).length>0&&o.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:It.results.filter(Le=>!Le.success).map(Le=>o.jsxs("div",{className:"text-xs text-red-400",children:[o.jsxs("span",{className:"font-medium",children:[Le.provider_name,":"]})," ",Le.message]},Le.provider_id))})]})}),Be?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Ve&&Ve.length>0?o.jsx("div",{className:"space-y-3",children:Ve.map(Le=>o.jsx(K9e,{provider:Le,onEdit:he=>{L(he),j(!0)}},Le.id))}):o.jsx(Mt,{children:o.jsx(At,{className:"py-8",children:o.jsxs("div",{className:"text-center text-bambu-gray",children:[o.jsx(Dh,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),o.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),o.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),o.jsxs(ke,{size:"sm",onClick:()=>{L(null),j(!0)},children:[o.jsx(fr,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[o.jsx(As,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),o.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),Pe?o.jsx("div",{className:"flex justify-center py-8",children:o.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):He&&He.length>0?o.jsx("div",{className:"space-y-2",children:He.map(Le=>o.jsx(Mt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>R(Le),children:o.jsx(At,{className:"py-2.5 px-3",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"text-white font-medium text-sm truncate",children:Le.name}),o.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:Le.title_template})]}),o.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:he=>{he.stopPropagation(),R(Le)},children:o.jsx(xR,{className:"w-4 h-4 text-bambu-gray"})})]})})},Le.id))}):o.jsx(Mt,{children:o.jsx(At,{className:"py-8",children:o.jsxs("div",{className:"text-center text-bambu-gray",children:[o.jsx(As,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),o.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),ee==="apikeys"&&o.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[o.jsxs("div",{className:"flex-1",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(ip,{className:"w-5 h-5 text-bambu-green"}),"API Keys"]}),o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Create API keys for external integrations and webhooks."})]}),o.jsxs(ke,{size:"sm",onClick:()=>V(!0),className:"flex-shrink-0",children:[o.jsx(fr,{className:"w-4 h-4"}),"Create Key"]})]}),ge&&o.jsx(Mt,{className:"mb-6 border-bambu-green",children:o.jsx(At,{className:"py-4",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(kr,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),o.jsxs("div",{className:"flex-1",children:[o.jsx("p",{className:"text-white font-medium mb-1",children:"API Key Created Successfully"}),o.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Copy this key now - it won't be shown again!"}),o.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[o.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:ge}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(ge);else{const Le=document.createElement("textarea");Le.value=ge,Le.style.position="fixed",Le.style.left="-999999px",document.body.appendChild(Le),Le.select(),document.execCommand("copy"),document.body.removeChild(Le)}r("Key copied to clipboard")}catch{r("Failed to copy key","error")}},children:o.jsx(vl,{className:"w-4 h-4"})})]}),o.jsxs("div",{className:"flex gap-2 mt-3",children:[o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>{fe(ge),r("Key added to API Browser")},children:"Use in API Browser"}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>Ee(null),children:"Dismiss"})]})]})]})})}),z&&o.jsxs(Mt,{className:"mb-6",children:[o.jsx(Fi,{children:o.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),o.jsxs(At,{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Key Name"}),o.jsx("input",{type:"text",value:X,onChange:Le=>te(Le.target.value),placeholder:"e.g., Home Assistant, OctoPrint",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Permissions"}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:ie.can_read_status,onChange:Le=>le(he=>({...he,can_read_status:Le.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),o.jsxs("div",{children:[o.jsx("span",{className:"text-white",children:"Read Status"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"View printer status and queue"})]})]}),o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:ie.can_queue,onChange:Le=>le(he=>({...he,can_queue:Le.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),o.jsxs("div",{children:[o.jsx("span",{className:"text-white",children:"Manage Queue"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Add and remove items from print queue"})]})]}),o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:ie.can_control_printer,onChange:Le=>le(he=>({...he,can_control_printer:Le.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),o.jsxs("div",{children:[o.jsx("span",{className:"text-white",children:"Control Printer"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Pause, resume, and stop prints"})]})]})]})]}),o.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[o.jsxs(ke,{onClick:()=>me.mutate({name:X||"Unnamed Key",...ie}),disabled:me.isPending,children:[me.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(fr,{className:"w-4 h-4"}),"Create Key"]}),o.jsx(ke,{variant:"secondary",onClick:()=>V(!1),children:"Cancel"})]})]})]}),ht?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Ze&&Ze.length>0?o.jsx("div",{className:"space-y-3",children:Ze.map(Le=>o.jsx(Mt,{children:o.jsx(At,{className:"py-3",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(ip,{className:`w-5 h-5 ${Le.enabled?"text-bambu-green":"text-bambu-gray"}`}),o.jsxs("div",{children:[o.jsx("p",{className:"text-white font-medium",children:Le.name}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[Le.key_prefix,"••••••••",Le.last_used&&` · Last used: ${new Date(Le.last_used).toLocaleDateString()}`]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex gap-1 text-xs",children:[Le.can_read_status&&o.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),Le.can_queue&&o.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),Le.can_control_printer&&o.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:"Control"})]}),o.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>de(Le.id),children:o.jsx(Nn,{className:"w-4 h-4 text-red-400"})})]})]})})},Le.id))}):o.jsx(Mt,{children:o.jsx(At,{className:"py-12",children:o.jsxs("div",{className:"text-center text-bambu-gray",children:[o.jsx(ip,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),o.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No API keys"}),o.jsx("p",{className:"text-sm mb-4",children:"Create an API key to integrate with external services."}),o.jsxs(ke,{onClick:()=>V(!0),children:[o.jsx(fr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),o.jsxs(Mt,{className:"mt-6",children:[o.jsx(Fi,{children:o.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),o.jsxs(At,{className:"space-y-3 text-sm",children:[o.jsxs("p",{className:"text-bambu-gray",children:["Use your API key in the ",o.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header."]}),o.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[o.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[o.jsx("span",{className:"text-blue-400",children:"GET"})," ",o.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),o.jsx("span",{className:"text-bambu-gray",children:" - Get all printer status"})]}),o.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[o.jsx("span",{className:"text-blue-400",children:"GET"})," ",o.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),o.jsx("span",{className:"text-bambu-gray",children:" - Get specific printer status"})]}),o.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[o.jsx("span",{className:"text-green-400",children:"POST"})," ",o.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),o.jsx("span",{className:"text-bambu-gray",children:" - Add to print queue"})]}),o.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[o.jsx("span",{className:"text-orange-400",children:"POST"})," ",o.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),o.jsx("span",{className:"text-bambu-gray",children:" - Pause print"})]}),o.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[o.jsx("span",{className:"text-orange-400",children:"POST"})," ",o.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),o.jsx("span",{className:"text-bambu-gray",children:" - Resume print"})]}),o.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[o.jsx("span",{className:"text-red-400",children:"POST"})," ",o.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),o.jsx("span",{className:"text-bambu-gray",children:" - Stop print"})]})]})]})]})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"mb-6",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(Ap,{className:"w-5 h-5 text-bambu-green"}),"API Browser"]}),o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Explore and test all available API endpoints."})]}),o.jsx(Mt,{className:"mb-4",children:o.jsxs(At,{className:"py-3",children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"API Key for Testing"}),o.jsx("input",{type:"text",value:Re,onChange:Le=>fe(Le.target.value),placeholder:"Paste your API key here to test authenticated endpoints...",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm focus:border-bambu-green focus:outline-none"}),o.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["This key will be sent as ",o.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header with requests."]})]})}),o.jsx(hWe,{apiKey:Re})]})]}),ee==="virtual-printer"&&o.jsx(lWe,{}),ee==="filament"&&o.jsx("div",{className:"max-w-2xl",children:o.jsx(aWe,{})}),pe!==null&&o.jsx(br,{title:"Delete API Key",message:"Are you sure you want to delete this API key? Any integrations using this key will stop working.",confirmText:"Delete Key",variant:"danger",onConfirm:()=>{nt.mutate(pe),de(null)},onCancel:()=>de(null)}),T&&o.jsx(W9e,{plug:N,onClose:()=>{C(!1),O(null)}}),k&&o.jsx(X9e,{provider:B,onClose:()=>{j(!1),L(null)}}),K&&o.jsx(Y9e,{template:K,onClose:()=>R(null)}),q&&o.jsx(J9e,{onClose:()=>W(!1)}),Fe&&o.jsx(br,{title:"Clear Notification Logs",message:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",confirmText:"Clear Logs",variant:"warning",onConfirm:async()=>{U(!1);try{const Le=await _e.clearNotificationLogs(30);r(Le.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>U(!1)}),H&&o.jsx(br,{title:"Reset UI Preferences",message:"This will reset all UI preferences to defaults: sidebar order, theme, dashboard layout, view modes, and sorting preferences. Your printers, archives, and server settings will NOT be affected. The page will reload after clearing.",confirmText:"Reset Preferences",variant:"default",onConfirm:()=>{re(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>re(!1)}),G&&o.jsx(br,{title:`Turn All Plugs ${G==="on"?"On":"Off"}`,message:`This will turn ${G==="on"?"ON":"OFF"} all ${qe?.filter(Le=>Le.enabled).length||0} enabled smart plugs. ${G==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${G==="on"?"On":"Off"}`,variant:G==="off"?"danger":"warning",onConfirm:()=>{const Le=G;Z(null),er.mutate(Le)},onCancel:()=>Z(null)}),oe&&o.jsx(tWe,{onClose:()=>be(!1),onExport:async Le=>{be(!1);const he="backup-progress",ze=Le.archives;ze&&i(he,e("backup.preparing",{defaultValue:"Preparing backup..."}),"loading");try{const{blob:et,filename:st}=await _e.exportBackup(Le);ze&&a(he);const rt=URL.createObjectURL(et),yt=document.createElement("a");yt.href=rt,yt.download=st,yt.click(),URL.revokeObjectURL(rt),r(e("backup.downloaded",{defaultValue:"Backup downloaded"}),"success")}catch{ze&&a(he),r(e("backup.failed",{defaultValue:"Failed to create backup"}),"error")}}}),Te&&o.jsx(nWe,{onClose:()=>Me(!1),onRestore:async(Le,he)=>await _e.importBackup(Le,he),onSuccess:()=>{A(null),Un.current=!0,t.invalidateQueries()}}),F&&o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>I(!1),children:o.jsxs(Mt,{className:"w-full max-w-lg",onClick:Le=>Le.stopPropagation(),children:[o.jsxs(Fi,{className:"flex flex-row items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Lue,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.telemetryInfoTitle")})]}),o.jsx("button",{onClick:()=>I(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs(At,{className:"space-y-4",children:[o.jsx("p",{className:"text-bambu-gray text-sm",children:e("settings.telemetryInfoIntro")}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoCollected")}),o.jsxs("ul",{className:"space-y-2 text-sm",children:[o.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[o.jsx(kr,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoItem1")})]}),o.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[o.jsx(kr,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoItem2")})]}),o.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[o.jsx(kr,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoItem3")})]})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoNotCollected")}),o.jsxs("ul",{className:"space-y-2 text-sm",children:[o.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[o.jsx(Pa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoNotItem1")})]}),o.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[o.jsx(Pa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoNotItem2")})]}),o.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[o.jsx(Pa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoNotItem3")})]}),o.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[o.jsx(Pa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoNotItem4")})]})]})]}),o.jsx("p",{className:"text-bambu-gray text-xs border-t border-bambu-dark-tertiary pt-4",children:e("settings.telemetryInfoFooter")}),o.jsx(ke,{onClick:()=>I(!1),className:"w-full",children:e("common.close")})]})]})}),ne&&Xe?.release_notes&&o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>ve(!1),children:o.jsxs(Mt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:Le=>Le.stopPropagation(),children:[o.jsxs(Fi,{className:"flex flex-row items-center justify-between shrink-0",children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",Xe.latest_version]}),Xe.release_name&&Xe.release_name!==Xe.latest_version&&o.jsx("p",{className:"text-sm text-bambu-gray",children:Xe.release_name})]}),o.jsx("button",{onClick:()=>ve(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsx(At,{className:"overflow-y-auto flex-1",children:o.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:Xe.release_notes})}),o.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[Xe.release_url&&o.jsx("a",{href:Xe.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:o.jsxs(ke,{variant:"secondary",className:"w-full",children:[o.jsx(la,{className:"w-4 h-4"}),"View on GitHub"]})}),o.jsx(ke,{onClick:()=>ve(!1),className:"flex-1",children:"Close"})]})]})})]})}const Gte=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},mWe=t=>t.startsWith("HH")?"HF":"S",pWe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},Xj=t=>{const e=["High Flow_","High Flow ","Standard_","Standard ","HF_","HF ","S_","S "];for(const r of e)if(t.startsWith(r))return t.slice(r.length);const n=t.indexOf("_");return n>0?t.slice(n+1):t};function Pk({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:s}){const l=mWe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&a?a():e()};return o.jsxs("div",{className:"flex items-center gap-2",children:[r&&o.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?o.jsx(rf,{className:"w-4 h-4 text-bambu-green"}):o.jsx(af,{className:"w-4 h-4"})}),o.jsxs("button",{onClick:u,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:Gte(t.k_value)}),o.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),s&&o.jsx("span",{title:"Has note",children:o.jsx($9,{className:"w-3 h-3 text-yellow-500"})}),o.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[l," ",c]})]}),s&&o.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:s,children:["Note: ",s.length>50?s.substring(0,50)+"...":s]})]}),!r&&n&&o.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:o.jsx(vl,{className:"w-4 h-4"})})]})}function jk({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:a="",initialNoteKey:s=null,onClose:l,onSave:c,onSaveNote:u}){const{showToast:d}=Ar(),[f,g]=S.useState(t?.name||""),[p,x]=S.useState(t?.k_value?Gte(t.k_value):"0.020"),[v,y]=S.useState(t?.filament_id||""),[b,E]=S.useState(t?.nozzle_id?pWe(t.nozzle_id):"HH00"),[w,A]=S.useState(t?.nozzle_diameter||n),[T,C]=S.useState(t?[t.extruder_id]:i?[0,1]:[0]),[N,O]=S.useState(!1),[k,j]=S.useState({current:0,total:0}),[B,L]=S.useState(a),K=Cr.useMemo(()=>{const Q=new Map;for(const z of r)if(z.filament_id&&!Q.has(z.filament_id)){const V=Xj(z.name||"");Q.set(z.filament_id,{id:z.filament_id,name:V||z.filament_id})}return Array.from(Q.values()).sort((z,V)=>z.name.localeCompare(V.name))},[r]),R=vt({mutationFn:Q=>(console.log("[KProfile] Calling API..."),_e.setKProfile(e,Q)),onSuccess:Q=>{if(console.log("[KProfile] Save success:",Q),d("K-profile saved"),u&&B!==a){let z;B===""&&s?z=s:t&&t.slot_id>0?z=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:z=`name_${f}_${v}`,u(z,B)}O(!0),setTimeout(()=>{O(!1),c()},2500)},onError:Q=>{console.error("[KProfile] Save error:",Q),d(Q.message,"error"),O(!1)}}),q=vt({mutationFn:Q=>(console.log("[KProfile] Deleting profile..."),_e.deleteKProfile(e,Q)),onSuccess:Q=>{console.log("[KProfile] Delete success:",Q),d("K-profile deleted"),O(!0),setTimeout(()=>{O(!1),l()},4e3)},onError:Q=>{console.error("[KProfile] Delete error:",Q),d(Q.message,"error"),O(!1)}}),[W,$]=S.useState(!1),J=()=>{t&&q.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},ee=async Q=>{if(Q.preventDefault(),i&&!t&&T.length===0){d("Please select at least one extruder","error");return}const z=parseFloat(p).toFixed(6),V=`${b}-${w}`;if(t||T.length===1){const te={name:f,k_value:z,filament_id:v,nozzle_id:V,nozzle_diameter:w,extruder_id:t?t.extruder_id:T[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",te),R.mutate(te);return}O(!0),j({current:1,total:T.length});const X=T.map(te=>({name:f,k_value:z,filament_id:v,nozzle_id:V,nozzle_diameter:w,extruder_id:te,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${X.length} profiles in batch:`,X);try{if(await _e.setKProfilesBatch(e,X),d(`K-profile saved to ${T.length} extruders`),u&&B){const te=`name_${f}_${v}`;u(te,B)}}catch(te){console.error("[KProfile] Failed to save batch:",te),d("Failed to save K-profiles","error"),O(!1),j({current:0,total:0});return}j({current:T.length,total:T.length}),setTimeout(()=>{O(!1),j({current:0,total:0}),c()},3e3)};return o.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[o.jsxs(Mt,{className:"w-full max-w-md relative",children:[N&&o.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),o.jsx("p",{className:"text-white font-medium",children:k.total>1?`Saving to extruder ${k.current}/${k.total}...`:"Syncing with printer..."}),o.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),o.jsxs(At,{className:"p-0",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),o.jsx("button",{onClick:l,className:"text-bambu-gray hover:text-white transition-colors",disabled:N,children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("form",{onSubmit:ee,className:"p-4 space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),o.jsx("input",{type:"text",value:f,onChange:Q=>g(Q.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:"My PLA Profile",required:!t})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),o.jsx("input",{type:"text",inputMode:"decimal",value:p,onChange:Q=>{const z=Q.target.value;(z===""||/^\d*\.?\d*$/.test(z))&&x(z)},onBlur:Q=>{const z=parseFloat(Q.target.value);isNaN(z)||x((Math.trunc(z*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),o.jsxs("select",{value:v,onChange:Q=>{const z=Q.target.value;if(y(z),!t&&z&&!f){const V=K.find(X=>X.id===z);V&&g(`${b==="HH00"?"HF":"S"} ${V.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[o.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&o.jsx("option",{value:t.filament_id,children:K.find(Q=>Q.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&K.map(Q=>o.jsx("option",{value:Q.id,children:Q.name},Q.id))]}),!t&&K.length===0&&o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),o.jsxs("select",{value:b,onChange:Q=>{const z=Q.target.value;if(E(z),!t&&v&&!f){const V=K.find(X=>X.id===v);V&&g(`${z==="HS00"?"HF":"S"} ${V.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[o.jsx("option",{value:"HH00",children:"High Flow"}),o.jsx("option",{value:"HS00",children:"Standard"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),o.jsxs("select",{value:w,onChange:Q=>A(Q.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[o.jsx("option",{value:"0.2",children:"0.2mm"}),o.jsx("option",{value:"0.4",children:"0.4mm"}),o.jsx("option",{value:"0.6",children:"0.6mm"}),o.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?o.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?"Left":"Right"}):o.jsxs("div",{className:"flex gap-4",children:[o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:T.includes(1),onChange:Q=>{Q.target.checked?C([...T,1]):C(T.filter(z=>z!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),o.jsx("span",{className:"text-white",children:"Left"})]}),o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:T.includes(0),onChange:Q=>{Q.target.checked?C([...T,0]):C(T.filter(z=>z!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),o.jsx("span",{className:"text-white",children:"Right"})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),o.jsx("textarea",{value:B,onChange:Q=>L(Q.target.value),placeholder:"Add notes about this profile...",rows:2,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none"}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),o.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&o.jsx(ke,{type:"button",variant:"secondary",onClick:()=>$(!0),disabled:q.isPending||N,className:"text-red-500 hover:bg-red-500/10",children:q.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(Nn,{className:"w-4 h-4"})}),o.jsx(ke,{type:"button",variant:"secondary",onClick:l,disabled:N,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{type:"submit",disabled:R.isPending||N,className:"flex-1",children:[R.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(eM,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),W&&o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:o.jsx(Mt,{className:"w-full max-w-sm",children:o.jsxs(At,{className:"p-6",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:o.jsx(Nn,{className:"w-5 h-5 text-red-500"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),o.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",o.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx(ke,{variant:"secondary",onClick:()=>$(!1),className:"flex-1",children:"Cancel"}),o.jsxs(ke,{onClick:()=>{$(!1),J()},disabled:q.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[q.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(Nn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const c1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function gWe(){const{showToast:t}=Ar(),[e,n]=S.useState(null),[r,i]=S.useState(()=>localStorage.getItem(c1.NOZZLE_DIAMETER)||"0.4"),[a,s]=S.useState(null),[l,c]=S.useState(!1),[u,d]=S.useState(null),[f,g]=S.useState(""),[p,x]=S.useState("all"),[v,y]=S.useState("all"),[b,E]=S.useState(()=>localStorage.getItem(c1.SORT_OPTION)||"name"),[w,A]=S.useState(!1),[T,C]=S.useState(new Set),[N,O]=S.useState(!1),[k,j]=S.useState(!1),B=G=>`${G.slot_id}_${G.extruder_id}`;S.useEffect(()=>{localStorage.setItem(c1.NOZZLE_DIAMETER,r)},[r]),S.useEffect(()=>{localStorage.setItem(c1.SORT_OPTION,b)},[b]);const{data:L,isLoading:K}=gt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:R,isLoading:q,isFetching:W,error:$,refetch:J}=gt({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const G=await _e.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",G?.profiles?.length||0,"profiles"),G},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:ee}=gt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>_e.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:Q,refetch:z}=gt({queryKey:["kprofile-notes",e],queryFn:()=>_e.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),V=$?.message?.includes("not connected");S.useEffect(()=>{if(!e&&L&&L.length>0){const G=L.find(Z=>Z.is_active);G&&n(G.id)}},[e,L]),S.useEffect(()=>{if(e){const G=setTimeout(()=>{J()},150);return()=>clearTimeout(G)}},[e,r]);const X=L?.filter(G=>G.is_active)||[],te=Cr.useMemo(()=>R?.profiles?R.profiles.filter(Z=>{const oe=f.toLowerCase(),be=!oe||Z.name.toLowerCase().includes(oe)||Z.filament_id.toLowerCase().includes(oe),Te=p==="all"||p==="left"&&Z.extruder_id===1||p==="right"&&Z.extruder_id===0,Me=v==="all"||v==="hf"&&Z.nozzle_id.startsWith("HH")||v==="s"&&Z.nozzle_id.startsWith("HS");return be&&Te&&Me}).sort((Z,oe)=>{switch(b){case"k_value":return parseFloat(Z.k_value)-parseFloat(oe.k_value);case"filament":return Xj(Z.name).localeCompare(Xj(oe.name));case"name":default:return Z.name.localeCompare(oe.name)}}):[],[R?.profiles,f,p,v,b]),ie=L?.find(G=>G.id===e),le=ie?.nozzle_count===2;S.useEffect(()=>{const G=Z=>{Z.target instanceof HTMLInputElement||Z.target instanceof HTMLTextAreaElement||Z.target instanceof HTMLSelectElement||a||l||u||(Z.key==="r"||Z.key==="R"?(Z.preventDefault(),J()):Z.key==="n"||Z.key==="N"?(Z.preventDefault(),c(!0)):Z.key==="Escape"&&w&&(Z.preventDefault(),A(!1),C(new Set)))};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[a,l,u,w,J]);const ge=S.useCallback(()=>{if(!R?.profiles||R.profiles.length===0){t("No profiles to export","error");return}const G={version:1,exported_at:new Date().toISOString(),printer:ie?.name||"Unknown",nozzle_diameter:r,profiles:R.profiles.map(Te=>({name:Te.name,k_value:Te.k_value,filament_id:Te.filament_id,nozzle_id:Te.nozzle_id,nozzle_diameter:Te.nozzle_diameter,extruder_id:Te.extruder_id}))},Z=new Blob([JSON.stringify(G,null,2)],{type:"application/json"}),oe=URL.createObjectURL(Z),be=document.createElement("a");be.href=oe,be.download=`kprofiles_${ie?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(be),be.click(),document.body.removeChild(be),URL.revokeObjectURL(oe),t(`Exported ${R.profiles.length} profiles`)},[R?.profiles,ie,r,t]),Ee=S.useCallback(()=>{const G=document.createElement("input");G.type="file",G.accept=".json",G.onchange=async Z=>{const oe=Z.target.files?.[0];if(oe)try{const be=await oe.text(),Te=JSON.parse(be);if(!Te.profiles||!Array.isArray(Te.profiles)){t("Invalid file format","error");return}let Me=0;for(const F of Te.profiles)if(!(!F.name||!F.k_value||!F.filament_id))try{await _e.setKProfile(e,{name:F.name,k_value:parseFloat(F.k_value).toFixed(6),filament_id:F.filament_id,nozzle_id:F.nozzle_id||`HH00-${r}`,nozzle_diameter:F.nozzle_diameter||r,extruder_id:F.extruder_id??0,slot_id:0}),Me++,await new Promise(I=>setTimeout(I,500))}catch(I){console.error("Failed to import profile:",F.name,I)}t(`Imported ${Me} of ${Te.profiles.length} profiles`),J()}catch(be){console.error("Import error:",be),t("Failed to parse import file","error")}},G.click()},[e,r,t,J]),pe=S.useCallback(G=>{C(Z=>{const oe=new Set(Z);return oe.has(G)?oe.delete(G):oe.add(G),oe})},[]),de=S.useCallback(()=>{C(new Set(te.map(G=>B(G))))},[te,B]),Re=S.useCallback(()=>{T.size!==0&&O(!0)},[T.size]),fe=S.useCallback(async()=>{const G=te.filter(oe=>T.has(B(oe)));j(!0);let Z=0;for(const oe of G)try{await _e.deleteKProfile(e,{slot_id:oe.slot_id,extruder_id:oe.extruder_id,nozzle_id:oe.nozzle_id,nozzle_diameter:oe.nozzle_diameter,filament_id:oe.filament_id,setting_id:oe.setting_id}),Z++,await new Promise(be=>setTimeout(be,300))}catch(be){console.error("Failed to delete profile:",oe.name,be)}t(`Deleted ${Z} profiles`),j(!1),O(!1),A(!1),C(new Set),J()},[e,T,te,t,J,B]),Fe=S.useCallback(G=>{const Z=[];return G.setting_id&&Z.push(G.setting_id),Z.push(`slot_${G.slot_id}_${G.filament_id}_${G.extruder_id}`),Z.push(`name_${G.name}_${G.filament_id}`),Z},[]),U=S.useCallback(async(G,Z)=>{if(e)try{await _e.setKProfileNote(e,G,Z),z()}catch(oe){console.error("Failed to save note:",oe),t("Failed to save note","error")}},[e,z,t]),H=S.useCallback(G=>{if(!Q?.notes)return{note:"",key:null};const Z=Fe(G);for(const oe of Z)if(Q.notes[oe])return{note:Q.notes[oe],key:oe};return{note:"",key:null}},[Q,Fe]),re=S.useCallback(G=>H(G).note,[H]);return K?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!L||L.length===0?o.jsx(Mt,{children:o.jsxs(At,{className:"py-12 text-center",children:[o.jsx(Oa,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),o.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),o.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):X.length===0?o.jsx(Mt,{children:o.jsxs(At,{className:"py-12 text-center",children:[o.jsx(Gi,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),o.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),o.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):o.jsxs(o.Fragment,{children:[W&&!q&&o.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[o.jsx(pt,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),o.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),o.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[o.jsxs("div",{className:"flex-1 min-w-48",children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),o.jsx("select",{value:e||"",onChange:G=>n(parseInt(G.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:X.map(G=>o.jsx("option",{value:G.id,children:G.name},G.id))})]}),o.jsxs("div",{className:"w-32",children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),o.jsxs("select",{value:r,onChange:G=>i(G.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"0.2",children:"0.2mm"}),o.jsx("option",{value:"0.4",children:"0.4mm"}),o.jsx("option",{value:"0.6",children:"0.6mm"}),o.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),o.jsxs("div",{className:"flex items-end gap-2",children:[o.jsxs(ke,{variant:"secondary",onClick:()=>J(),disabled:W,children:[o.jsx(li,{className:`w-4 h-4 ${W?"animate-spin":""}`}),"Refresh"]}),o.jsxs(ke,{onClick:()=>c(!0),children:[o.jsx(fr,{className:"w-4 h-4"}),"Add Profile"]})]})]}),o.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[o.jsxs("div",{className:"flex-1 min-w-48 relative",children:[o.jsx(_l,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),o.jsx("input",{type:"text",value:f,onChange:G=>g(G.target.value),placeholder:"Search by name or filament...",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),le&&o.jsx("div",{className:"w-36",children:o.jsxs("select",{value:p,onChange:G=>x(G.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"all",children:"All Extruders"}),o.jsx("option",{value:"left",children:"Left Only"}),o.jsx("option",{value:"right",children:"Right Only"})]})}),o.jsx("div",{className:"w-32",children:o.jsxs("select",{value:v,onChange:G=>y(G.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"all",children:"All Flow"}),o.jsx("option",{value:"hf",children:"HF Only"}),o.jsx("option",{value:"s",children:"S Only"})]})}),o.jsx("div",{className:"w-32",children:o.jsxs("select",{value:b,onChange:G=>E(G.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"name",children:"Sort: Name"}),o.jsx("option",{value:"k_value",children:"Sort: K-Value"}),o.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),o.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[o.jsxs(ke,{variant:"secondary",onClick:ge,disabled:!R?.profiles?.length,title:"Export profiles to JSON",children:[o.jsx(as,{className:"w-4 h-4"}),"Export"]}),o.jsxs(ke,{variant:"secondary",onClick:Ee,title:"Import profiles from JSON",children:[o.jsx(ca,{className:"w-4 h-4"}),"Import"]}),o.jsx("div",{className:"flex-1"}),w?o.jsxs(o.Fragment,{children:[o.jsxs(ke,{variant:"secondary",onClick:de,title:"Select all visible profiles",children:[o.jsx(rf,{className:"w-4 h-4"}),"Select All"]}),o.jsxs(ke,{variant:"secondary",onClick:Re,disabled:T.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${T.size} selected profiles`,children:[o.jsx(Nn,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),o.jsxs(ke,{variant:"secondary",onClick:()=>{A(!1),C(new Set)},children:[o.jsx(Wt,{className:"w-4 h-4"}),"Cancel"]})]}):o.jsxs(ke,{variant:"secondary",onClick:()=>A(!0),disabled:!te.length,title:"Enter selection mode for bulk delete",children:[o.jsx(rf,{className:"w-4 h-4"}),"Select"]})]}),q?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):V?o.jsx(Mt,{children:o.jsxs(At,{className:"py-12 text-center",children:[o.jsx(kb,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),o.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),o.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),o.jsxs(ke,{variant:"secondary",onClick:()=>J(),children:[o.jsx(li,{className:"w-4 h-4"}),"Retry"]})]})}):te.length>0?le?o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),o.jsx("div",{className:"space-y-1",children:te.filter(G=>G.extruder_id===1).map(G=>o.jsx(Pk,{profile:G,onEdit:()=>s(G),onCopy:()=>d(G),selectionMode:w,isSelected:T.has(B(G)),onToggleSelect:()=>pe(B(G)),note:re(G)},B(G)))})]}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),o.jsx("div",{className:"space-y-1",children:te.filter(G=>G.extruder_id===0).map(G=>o.jsx(Pk,{profile:G,onEdit:()=>s(G),onCopy:()=>d(G),selectionMode:w,isSelected:T.has(B(G)),onToggleSelect:()=>pe(B(G)),note:re(G)},B(G)))})]})]}):o.jsx("div",{className:"space-y-1",children:te.map(G=>o.jsx(Pk,{profile:G,onEdit:()=>s(G),onCopy:()=>d(G),selectionMode:w,isSelected:T.has(B(G)),onToggleSelect:()=>pe(B(G)),note:re(G)},B(G)))}):f||p!=="all"||v!=="all"?o.jsx(Mt,{children:o.jsxs(At,{className:"py-12 text-center",children:[o.jsx(_l,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),o.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),o.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):o.jsx(Mt,{children:o.jsxs(At,{className:"py-12 text-center",children:[o.jsx(eM,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),o.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),o.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),o.jsxs(ke,{onClick:()=>c(!0),children:[o.jsx(fr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:G,key:Z}=H(a);return o.jsx(jk,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:ee?.profiles||R?.profiles,isDualNozzle:le,initialNote:G,initialNoteKey:Z,onSaveNote:U,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),s(null),J()},onSave:()=>{s(null),J()}})})(),l&&e&&o.jsx(jk,{printerId:e,nozzleDiameter:r,existingProfiles:ee?.profiles||R?.profiles,isDualNozzle:le,onSaveNote:U,onClose:()=>{c(!1),J()},onSave:()=>{c(!1),J()}}),u&&e&&o.jsx(jk,{printerId:e,nozzleDiameter:r,existingProfiles:ee?.profiles||R?.profiles,isDualNozzle:le,onSaveNote:U,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),J()},onSave:()=>{d(null),J()}}),N&&o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:o.jsx(Mt,{className:"w-full max-w-sm",children:o.jsxs(At,{className:"p-6",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:o.jsx(Nn,{className:"w-5 h-5 text-red-500"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),o.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",o.jsx("span",{className:"text-white font-medium",children:T.size})," selected profiles from the printer?"]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx(ke,{variant:"secondary",onClick:()=>O(!1),disabled:k,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{onClick:fe,disabled:k,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[k?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(Nn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function VL(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,a=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),s=a?(a[1]||a[2])+"mm":null,l=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=l?l[1]+"mm":null,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:i,nozzle:s,layerHeight:c,filamentType:d}}function wb(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function xWe(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),a=Math.floor(r/36e5),s=Math.floor(r/864e5);return i<1?"Just now":i<60?`${i}m ago`:a<24?`${a}h ago`:s<7?`${s}d ago`:e.toLocaleDateString()}function bWe({onSuccess:t}){const{showToast:e}=Ar(),[n,r]=S.useState("email"),[i,a]=S.useState(""),[s,l]=S.useState(""),[c,u]=S.useState(""),[d,f]=S.useState(""),[g,p]=S.useState("global"),x=vt({mutationFn:()=>_e.cloudLogin(i,s,g),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):w.needs_verification?(e("Verification code sent to your email"),r("code")):e(w.message,"error")},onError:w=>e(w.message,"error")}),v=vt({mutationFn:()=>_e.cloudVerify(i,c),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>e(w.message,"error")}),y=vt({mutationFn:()=>_e.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>e(w.message,"error")}),b=w=>{w.preventDefault(),n==="email"?x.mutate():n==="code"?v.mutate():n==="token"&&y.mutate()},E=x.isPending||v.isPending||y.isPending;return o.jsx(Mt,{className:"max-w-md mx-auto",children:o.jsxs(At,{children:[o.jsxs("div",{className:"text-center mb-6",children:[o.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:o.jsx(QS,{className:"w-6 h-6 text-bambu-green"})}),o.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),o.jsxs("form",{onSubmit:b,className:"space-y-4",children:[n==="email"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),o.jsx("input",{type:"email",value:i,onChange:w=>a(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),o.jsx("input",{type:"password",value:s,onChange:w=>l(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),o.jsxs("select",{value:g,onChange:w=>p(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"global",children:"Global"}),o.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),o.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),o.jsx("input",{type:"text",value:c,onChange:w=>u(w.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),o.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),o.jsx("textarea",{value:d,onChange:w=>f(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),o.jsxs("div",{className:"flex gap-2",children:[n==="code"&&o.jsx(ke,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),o.jsxs(ke,{type:"submit",disabled:E,className:"flex-1",children:[E?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(SU,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&o.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:o.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[o.jsx(ip,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&o.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:o.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[o.jsx(SU,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Ym({label:t,value:e,options:n,onChange:r}){const[i,a]=S.useState(!1),s=n.find(l=>l.value===e);return o.jsxs("div",{className:"relative",children:[o.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[o.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),o.jsx("span",{children:s?.label||"All"}),o.jsx(vo,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),o.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(l=>o.jsxs("button",{onClick:()=>{r(l.value),a(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===l.value?"text-bambu-green":"text-white"}`,children:[o.jsx("span",{children:l.label}),l.count!==void 0&&o.jsx("span",{className:"text-bambu-gray text-xs",children:l.count})]},l.value))})]})]})}function yWe(){const[t,e]=S.useState(!1);S.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?o.jsx("button",{onClick:n,className:"fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40","aria-label":"Scroll to top",children:o.jsx(Mp,{className:"w-5 h-5"})}):null}function Rk({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:s}){const l=VL(t.name),c=wb(t.setting_id);return o.jsxs("div",{className:"flex items-center gap-2 group",children:[o.jsx("button",{onClick:e,disabled:s,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":s?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!s?"cursor-pointer":""}`,children:o.jsxs("div",{className:"flex items-center gap-2",children:[i&&a!==void 0&&o.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:a+1}),!i&&c&&o.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),o.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),l.filamentType&&t.type==="filament"&&o.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.filamentType}),l.layerHeight&&t.type==="process"&&o.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.layerHeight}),l.printer&&o.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.printer})]})}),o.jsx("button",{onClick:u=>{u.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:o.jsx(vl,{className:"w-4 h-4"})})]})}function Yj(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(`
- `)){const i=t.replace(/\\n/g,`
- `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
- `);if(i.length>1)return`"""
- `+i.map(a=>n+" "+a).join(`
- `)+`
- `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
- `+t.map(i=>n+" "+Yj(i,e+1)).join(`,
- `)+`
- `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
- `+r.map(([a,s])=>n+" "+JSON.stringify(a)+": "+Yj(s,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function vWe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=Ar(),s=pn(),[l,c]=S.useState(!1),{data:u,isLoading:d}=gt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>_e.getCloudSettingDetail(t.setting_id)}),f=vt({mutationFn:()=>_e.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),s.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:x=>a(x.message,"error")}),g=wb(t.setting_id),p=VL(t.name,u?.setting?.inherits);return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:o.jsx(Mt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:o.jsxs(At,{className:"p-0 flex flex-col min-h-0 flex-1",children:[o.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),g&&o.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[o.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),p.printer&&o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"•"}),o.jsx("span",{children:p.printer})]})]})]}),o.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:d?o.jsx("div",{className:"flex items-center justify-center py-16",children:o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?o.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:Yj(u)}):o.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),l?o.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[o.jsx(Gn,{className:"w-5 h-5"}),o.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),o.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(ke,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):o.jsx(Nn,{className:"w-4 h-4"}),"Delete"]})]})]}):o.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:o.jsxs("div",{className:"flex gap-2",children:[o.jsx(ke,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),o.jsxs(ke,{variant:"secondary",onClick:r,children:[o.jsx(vl,{className:"w-4 h-4"}),"Duplicate"]}),g&&o.jsxs(o.Fragment,{children:[o.jsxs(ke,{variant:"secondary",onClick:i,disabled:d||!u,children:[o.jsx(Bc,{className:"w-4 h-4"}),"Edit"]}),o.jsx(ke,{variant:"danger",onClick:()=>c(!0),children:o.jsx(Nn,{className:"w-4 h-4"})})]})]})})]})})})}function Wte(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function qte(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function _We({onClose:t,onApply:e}){const{showToast:n}=Ar(),[r,i]=S.useState(Wte),[a,s]=S.useState("all"),[l,c]=S.useState(null),[u,d]=S.useState(""),[f,g]=S.useState(""),[p,x]=S.useState("{}"),[v,y]=S.useState(null),[b,E]=S.useState(null),w=a==="all"?r:r.filter(L=>L.type===a),A=L=>{i(L),qte(L)},T=L=>{const K=r.filter(R=>R.id!==L);A(K),E(null),n("Template deleted")},C=L=>{c(L.id),d(L.name),g(L.description),x(JSON.stringify(L.settings,null,2)),y(null)},N=()=>{if(!(!l||!u.trim()))try{const L=JSON.parse(p),K=r.map(R=>R.id===l?{...R,name:u.trim(),description:f.trim(),settings:L}:R);A(K),c(null),n("Template updated")}catch(L){y(L.message)}},O=()=>{c(null),d(""),g(""),x("{}"),y(null)},k=L=>{const K=r.map(R=>R.id===L?{...R,showInModal:!R.showInModal}:R);A(K)},j={filament:{label:"Filament",icon:cR,color:"text-amber-400"},print:{label:"Process",icon:rM,color:"text-blue-400"},printer:{label:"Printer",icon:Gi,color:"text-purple-400"}},B=b?r.find(L=>L.id===b):null;return S.useEffect(()=>{const L=K=>{K.key==="Escape"&&(b?E(null):l?O():t())};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[b,l,t]),o.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[B&&o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:o.jsx(Mt,{className:"w-full max-w-md",children:o.jsxs(At,{className:"p-6",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[o.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:o.jsx(Gn,{className:"w-6 h-6 text-red-400"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),o.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',o.jsx("span",{className:"font-medium",children:B.name}),'"?']}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(ke,{variant:"secondary",onClick:()=>E(null),className:"flex-1",children:"Cancel"}),o.jsxs(ke,{onClick:()=>T(b),className:"flex-1 bg-red-500 hover:bg-red-600",children:[o.jsx(Nn,{className:"w-4 h-4"}),"Delete"]})]})]})})}),o.jsx(Mt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:o.jsxs(At,{className:"p-0 flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(O0,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),o.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(L=>o.jsx("button",{onClick:()=>s(L),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:L==="all"?"All":j[L].label},L))]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:w.length===0?o.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[o.jsx(O0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),o.jsx("p",{children:"No templates yet"}),o.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):o.jsx("div",{className:"space-y-2",children:w.map(L=>{const K=j[L.type],R=K.icon;return l===L.id?o.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[o.jsx("input",{type:"text",value:u,onChange:q=>d(q.target.value),placeholder:"Template name",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),o.jsx("input",{type:"text",value:f,onChange:q=>g(q.target.value),placeholder:"Description",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{className:"mb-3",children:[o.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),o.jsx("textarea",{value:p,onChange:q=>{x(q.target.value),y(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${v?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),v&&o.jsx("p",{className:"text-xs text-red-400 mt-1",children:v})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(ke,{size:"sm",onClick:N,disabled:!u.trim(),children:[o.jsx(Ts,{className:"w-4 h-4"}),"Save"]}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:O,children:"Cancel"})]})]},L.id):o.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[o.jsx(R,{className:`w-5 h-5 ${K.color} flex-shrink-0`}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm font-medium text-white",children:L.name}),o.jsx("p",{className:"text-xs text-bambu-gray truncate",children:L.description})]}),o.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(L.settings).length," fields"]}),o.jsx("button",{onClick:()=>k(L.id),className:`p-1 transition-colors ${L.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:L.showInModal?"Shown in modals":"Hidden in modals",children:L.showInModal?o.jsx(ef,{className:"w-4 h-4"}):o.jsx(JS,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>e(L),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),o.jsx("button",{onClick:()=>C(L),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:o.jsx(Bc,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>E(L.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:o.jsx(Nn,{className:"w-4 h-4"})})]},L.id)})})})]})})]})}function Kte({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[a,s]=S.useState("changes"),[l,c]=S.useState(""),u=S.useMemo(()=>{const p=new Set([...Object.keys(e),...Object.keys(n)]),x=[];for(const v of p){if(v==="inherits"||v==="version")continue;const y=e[v],b=n[v],E=v in e,w=v in n;let A;!E&&w?A="added":E&&!w?A="removed":JSON.stringify(y)!==JSON.stringify(b)?A="changed":A="same",x.push({key:v,left:y,right:b,status:A})}return x.sort((v,y)=>{const b={changed:0,added:1,removed:2,same:3};return b[v.status]!==b[y.status]?b[v.status]-b[y.status]:v.key.localeCompare(y.key)})},[e,n]),d=S.useMemo(()=>{let p=[...u];if(a==="changes"&&(p=p.filter(x=>x.status!=="same")),l){const x=l.toLowerCase();p=p.filter(v=>v.key.toLowerCase().includes(x)||String(v.left).toLowerCase().includes(x)||String(v.right).toLowerCase().includes(x))}return p},[u,a,l]),f=S.useMemo(()=>({added:u.filter(p=>p.status==="added").length,removed:u.filter(p=>p.status==="removed").length,changed:u.filter(p=>p.status==="changed").length,same:u.filter(p=>p.status==="same").length}),[u]),g=p=>{if(p===void 0)return"—";if(p===null)return"null";if(Array.isArray(p))return p.length===0?"[]":p.length===1?String(p[0]):p.join(", ");if(typeof p=="object")return JSON.stringify(p);const x=String(p);if(x.includes("\\n")||x.length>100){const v=x.split("\\n").length;if(v>1)return`[${v} lines of G-code/script]`;if(x.length>100)return x.substring(0,100)+"…"}return x};return S.useEffect(()=>{const p=x=>{x.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:o.jsx(Mt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:o.jsxs(At,{className:"p-0 flex flex-col min-h-0 flex-1",children:[o.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(dp,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),o.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:o.jsx(Wt,{className:"w-5 h-5"})})]}),o.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),o.jsx("p",{className:"text-white font-medium truncate",children:r})]}),o.jsxs("div",{className:"text-center",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),o.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),o.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[o.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[o.jsx(fr,{className:"w-3.5 h-3.5"}),f.added," added"]}),o.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[o.jsx(e3,{className:"w-3.5 h-3.5"}),f.removed," removed"]}),o.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[o.jsx(Xk,{className:"w-3.5 h-3.5"}),f.changed," changed"]}),o.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[o.jsx(KA,{className:"w-3.5 h-3.5"}),f.same," same"]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"relative",children:[o.jsx(_l,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),o.jsx("input",{type:"text",value:l,onChange:p=>c(p.target.value),placeholder:"Search fields...",className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),f.same>0&&o.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[o.jsx("button",{onClick:()=>s("changes"),className:`px-3 py-1.5 text-sm transition-colors ${a==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"Changes"}),o.jsx("button",{onClick:()=>s("all"),className:`px-3 py-1.5 text-sm transition-colors ${a==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"All"})]})]})]}),o.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?o.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[o.jsx(KA,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),o.jsx("p",{children:a==="changes"?"No differences found":"No fields match the search"})]}):o.jsxs("table",{className:"w-full",children:[o.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:o.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[o.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),o.jsx("th",{className:"text-left p-3 w-1/3",children:r}),o.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),o.jsx("tbody",{children:d.map(p=>{const x={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[p.status],v={added:o.jsx(fr,{className:"w-3.5 h-3.5 text-green-400"}),removed:o.jsx(e3,{className:"w-3.5 h-3.5 text-red-400"}),changed:o.jsx(Xk,{className:"w-3.5 h-3.5 text-amber-400"}),same:o.jsx(KA,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[p.status];return o.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${x}`,children:[o.jsx("td",{className:"p-3",children:o.jsxs("div",{className:"flex items-center gap-2",children:[v,o.jsx("span",{className:"text-sm text-white font-mono",children:p.key})]})}),o.jsx("td",{className:"p-3",children:o.jsx("span",{className:`text-sm font-mono break-all ${p.status==="removed"?"text-red-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(p.left)})}),o.jsx("td",{className:"p-3",children:o.jsx("span",{className:`text-sm font-mono break-all ${p.status==="added"?"text-green-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(p.right)})})]},p.key)})})]})})]})})})}function wWe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=Ar(),i=pn(),a=!!e?.setting_id,[s,l]=S.useState("common"),[c,u]=S.useState(e?.type||"filament"),[d,f]=S.useState(e?.name?a?e.name:`${e.name} (Copy)`:""),[g,p]=S.useState(e?.base_id||""),[x,v]=S.useState(""),[y,b]=S.useState(e?.setting||{inherits:""}),[E,w]=S.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[A,T]=S.useState(null),[C,N]=S.useState(""),[O,k]=S.useState(!1),[j,B]=S.useState(""),[L,K]=S.useState(!1),[R,q]=S.useState(Wte),[W,$]=S.useState(!1),[J,ee]=S.useState(""),[Q,z]=S.useState(""),[V,X]=S.useState(!0),[te,ie]=S.useState(null),[le,ge]=S.useState(!1),Ee=S.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),pe=S.useMemo(()=>Ee.filter(se=>wb(se.setting_id)),[Ee]),{data:de}=gt({queryKey:["cloudFields",c],queryFn:()=>_e.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:Re}=gt({queryKey:["allPresetDetails",c,pe.map(se=>se.setting_id).join(",")],queryFn:async()=>{const se={};for(let Be=0;Be<pe.length;Be+=5){const Ze=pe.slice(Be,Be+5);(await Promise.all(Ze.map(async me=>{try{const nt=await _e.getCloudSettingDetail(me.setting_id);return{id:me.setting_id,detail:nt}}catch{return null}}))).forEach(me=>{me&&(se[me.id]=me.detail)})}return se},enabled:pe.length>0,staleTime:1e3*60*10}),{data:fe,isLoading:Fe}=gt({queryKey:["cloudSettingDetail",g],queryFn:()=>_e.getCloudSettingDetail(g),enabled:!!g});S.useEffect(()=>{s!=="json"&&w(JSON.stringify(y,null,2))},[y,s]);const U=S.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(Ve=>!wb(Ve.setting_id)).sort((Ve,Be)=>Ve.name.localeCompare(Be.name)),[n,c]);S.useEffect(()=>{if(!g)return;const se=U.find(Ve=>Ve.setting_id===g);se&&(v(se.name),a||(b({inherits:se.name}),w(JSON.stringify({inherits:se.name},null,2))))},[g,U,a]);const H=S.useMemo(()=>{const se=de?.fields||[],Ve=new Set(se.map(me=>me.key)),Be=new Set,Ze=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);Re&&Object.values(Re).forEach(me=>{me?.setting&&Object.keys(me.setting).forEach(nt=>{!Ve.has(nt)&&!Ze.has(nt)&&Be.add(nt)})}),Object.keys(y).forEach(me=>{!Ve.has(me)&&!Ze.has(me)&&Be.add(me)});const ht=Array.from(Be).sort().map(me=>({key:me,label:me.replace(/_/g," ").replace(/\b\w/g,nt=>nt.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...se,...ht]},[de,Re,y]),re=H.filter(se=>se.label.toLowerCase().includes(C.toLowerCase())||se.key.toLowerCase().includes(C.toLowerCase())),G=()=>{if(j.trim()){const se=j.trim().toLowerCase().replace(/\s+/g,"_");Z(se,""),B(""),K(!1),r(`Field "${se}" added`)}},Z=(se,Ve)=>{b(Be=>{const Ze={...Be};return Ve===""||Ve===void 0?delete Ze[se]:Ze[se]=Ve,Ze})},oe=se=>{b(Ve=>({...Ve,...se.settings})),ie(se.name),r("Template applied")},be=()=>{if(!J.trim())return;const se={...y};if(delete se.inherits,Object.keys(se).length===0){r("No overrides to save","error");return}const Ve={id:Date.now().toString(),name:J.trim(),description:Q.trim()||"Custom template",type:c,settings:se,showInModal:V},Be=[...R,Ve];q(Be),qte(Be),$(!1),ee(""),z(""),X(!0),r("Template saved")},Te=S.useMemo(()=>R.filter(se=>se.type===c&&se.showInModal),[c,R]),Me=se=>{w(se);try{const Ve=JSON.parse(se);b(Ve),T(null)}catch(Ve){T(Ve.message)}},F=se=>{se.preventDefault(),k(!1);const Ve=se.dataTransfer.files[0];if(Ve&&Ve.name.endsWith(".json")){const Be=new FileReader;Be.onload=Ze=>{try{const ht=Ze.target?.result,me=JSON.parse(ht),nt=me.setting||me;b(xe=>({...xe,...nt})),w(JSON.stringify({...y,...nt},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},Be.readAsText(Ve)}},I=vt({mutationFn:()=>{const se={...y},Ve=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";se[Ve]=`"${d}"`;const Be={type:c,name:d,base_id:g,setting:se};return _e.createCloudSetting(Be)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:se=>r(se.message,"error")}),ne=vt({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return _e.updateCloudSetting(e.setting_id,{name:d,setting:y})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:se=>r(se.message,"error")}),ve=a?ne:I,Se=fe?.setting?.inherits,ye=Se?U.find(se=>se.name===Se):void 0,{data:Ke}=gt({queryKey:["cloudSettingDetail",ye?.setting_id],queryFn:()=>_e.getCloudSettingDetail(ye.setting_id),enabled:!!ye?.setting_id}),We=S.useMemo(()=>{const se=Ke?.setting||{},Ve=fe?.setting||{},Be=g&&Re?.[g]?.setting?Re[g].setting:{};return{...se,...Ve,...Be}},[g,fe,Ke,Re]),qe=se=>{if(se==null)return"";if(Array.isArray(se)){const Ve=[...new Set(se.map(Be=>String(Be)))];return Ve.length===1?Ve[0]:se.join(", ")}return String(se)},ut=se=>{const Ve=y[se.key],Be=We[se.key],Ze=qe(Be),ht=Fe?"Loading...":Ze||"",me="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(se.type==="boolean"){const nt=Ve==="1"||Ve===void 0&&Be==="1";return o.jsx("button",{type:"button",onClick:()=>Z(se.key,Ve==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${nt?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:o.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${nt?"translate-x-3.5":"translate-x-0.5"}`})})}return se.type==="select"?o.jsxs("select",{value:Ve||"",onChange:nt=>Z(se.key,nt.target.value),className:me,children:[o.jsx("option",{value:"",children:ht}),se.options?.map(nt=>o.jsx("option",{value:nt.value,children:nt.label},nt.value))]}):o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:se.type==="number"?"number":"text",value:Ve!==void 0?String(Ve):"",onChange:nt=>Z(se.key,nt.target.value),step:se.step,min:se.min,max:se.max,placeholder:ht,className:me}),se.unit&&o.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:se.unit})]})},ue=S.useMemo(()=>fe?.setting?fe.setting:{},[fe]);return o.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:se=>{se.preventDefault(),k(!0)},onDragLeave:()=>k(!1),onDrop:F,children:[le&&g&&o.jsx(Kte,{onClose:()=>ge(!1),leftPreset:ue,rightPreset:y,leftLabel:`Base: ${x||g}`,rightLabel:`Current: ${d||"New Preset"}`}),o.jsx(Mt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:o.jsxs(At,{className:"p-0 flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-xl font-semibold text-white",children:a?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[g&&o.jsxs("button",{onClick:()=>ge(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Compare with base preset",children:[o.jsx(dp,{className:"w-4 h-4"}),"Compare"]}),o.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:o.jsx(Wt,{className:"w-5 h-5"})})]})]}),O&&o.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:o.jsxs("div",{className:"text-center",children:[o.jsx(ca,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),o.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),o.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[o.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),o.jsxs("select",{value:c,onChange:se=>{u(se.target.value),p("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"filament",children:"Filament"}),o.jsx("option",{value:"print",children:"Process"}),o.jsx("option",{value:"printer",children:"Printer"})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),o.jsxs("select",{value:g,onChange:se=>p(se.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"",children:"Select base preset..."}),U.map(se=>o.jsx("option",{value:se.setting_id,children:se.name},se.setting_id))]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),o.jsx("input",{type:"text",value:d,onChange:se=>f(se.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),x&&o.jsx("div",{className:"text-xs text-bambu-gray",children:o.jsxs("p",{className:"flex items-center gap-1",children:[o.jsx(po,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",o.jsx("span",{className:"text-white",children:x}),Fe&&o.jsx(pt,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),o.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[o.jsxs("button",{onClick:()=>l("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[o.jsx(MU,{className:"w-4 h-4"}),"Common"]}),o.jsxs("button",{onClick:()=>l("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[o.jsx(mR,{className:"w-4 h-4"}),"All Fields"]}),o.jsxs("button",{onClick:()=>l("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[o.jsx(F9,{className:"w-4 h-4"}),"JSON",A&&o.jsx(Oa,{className:"w-3 h-3 text-red-400"})]}),o.jsx("div",{className:"flex-1"}),o.jsxs("button",{onClick:()=>{const se={name:d,type:c,base_id:g,setting:y},Ve=new Blob([JSON.stringify(se,null,2)],{type:"application/json"}),Be=URL.createObjectURL(Ve),Ze=document.createElement("a");Ze.href=Be,Ze.download=`${d||"preset"}.json`,document.body.appendChild(Ze),Ze.click(),document.body.removeChild(Ze),URL.revokeObjectURL(Be),r("Preset exported")},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Export current settings to JSON file",children:[o.jsx(as,{className:"w-4 h-4"}),"Export"]}),o.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Import settings from JSON file",children:[o.jsx(ca,{className:"w-4 h-4"}),"Import"]}),o.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:se=>{const Ve=se.target.files?.[0];if(Ve){const Be=new FileReader;Be.onload=Ze=>{try{const ht=JSON.parse(Ze.target?.result),me=ht.setting||ht;b(nt=>({...nt,...me})),r("File imported")}catch{r("Invalid JSON","error")}},Be.readAsText(Ve)}}})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[s==="common"&&o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[o.jsx(O0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(y).filter(se=>se!=="inherits").length>0&&o.jsxs("button",{onClick:()=>$(!W),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[o.jsx(Ts,{className:"w-3 h-3"}),"Save as template"]})]}),W&&o.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[o.jsx("input",{type:"text",value:J,onChange:se=>ee(se.target.value),placeholder:"Template name",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),o.jsx("input",{type:"text",value:Q,onChange:se=>z(se.target.value),placeholder:"Description (optional)",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(ke,{size:"sm",onClick:be,disabled:!J.trim(),children:[o.jsx(Ts,{className:"w-3 h-3"}),"Save"]}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>$(!1),children:"Cancel"})]}),o.jsxs("button",{onClick:()=>X(!V),className:`flex items-center gap-1.5 text-xs transition-colors ${V?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[V?o.jsx(ef,{className:"w-3.5 h-3.5"}):o.jsx(JS,{className:"w-3.5 h-3.5"}),V?"Show in modals":"Hidden in modals"]})]})]}),te&&o.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[o.jsx(po,{className:"w-4 h-4 text-bambu-green"}),o.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",o.jsx("span",{className:"font-medium",children:te})]}),o.jsx("button",{onClick:()=>ie(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:o.jsx(Wt,{className:"w-4 h-4"})})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Te.map(se=>o.jsxs("button",{onClick:()=>oe(se),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[o.jsx("p",{className:"text-sm font-medium text-white",children:se.name}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:se.description})]},se.id)),Te.length===0&&o.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:"No templates selected. Use the Templates button to enable templates for quick access."})]}),o.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),o.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:H.slice(0,10).map(se=>o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:se.label}),o.jsx("div",{className:"w-48",children:ut(se)})]},se.key))})]}),Object.keys(y).length>1&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(y).filter(([se])=>se!=="inherits").map(([se,Ve])=>o.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[se,": ",String(Ve).slice(0,20),o.jsx("button",{onClick:()=>Z(se,void 0),className:"hover:text-white",children:o.jsx(Wt,{className:"w-3 h-3"})})]},se))})]})]}),s==="fields"&&o.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[o.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[o.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),o.jsx("span",{className:"text-xs text-bambu-gray",children:Re?`${H.length} fields`:"Loading..."})]}),o.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[o.jsx(_l,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),o.jsx("input",{type:"text",value:C,onChange:se=>N(se.target.value),placeholder:"Search fields...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[re.filter(se=>!(se.key in y)).map(se=>{const Ve=We[se.key],Be=qe(Ve);return o.jsxs("div",{onClick:()=>{b(Ze=>({...Ze,[se.key]:Be||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"text-sm text-white truncate",children:se.label}),o.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:se.key})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Be&&o.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Be,children:[Be.slice(0,20),Be.length>20?"...":""]}),o.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:o.jsx(fr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},se.key)}),re.filter(se=>!(se.key in y)).length===0&&o.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:C?"No matching fields":"All fields added"})]}),o.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:L?o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"text",value:j,onChange:se=>B(se.target.value),onKeyDown:se=>se.key==="Enter"&&G(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),o.jsx(ke,{size:"sm",onClick:G,disabled:!j.trim(),children:o.jsx(fr,{className:"w-4 h-4"})}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>{K(!1),B("")},children:o.jsx(Wt,{className:"w-4 h-4"})})]}):o.jsxs("button",{onClick:()=>K(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[o.jsx(fr,{className:"w-4 h-4"}),"Add custom field"]})})]}),o.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[o.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),o.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(y).filter(se=>se!=="inherits").length," fields"]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(y).filter(([se])=>se!=="inherits").map(([se,Ve])=>{const Be=H.find(Ze=>Ze.key===se);return o.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium text-white",children:Be?.label||se}),o.jsx("p",{className:"text-xs text-bambu-gray-dark",children:se})]}),o.jsx("button",{onClick:()=>Z(se,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:o.jsx(Wt,{className:"w-4 h-4"})})]}),Be?ut(Be):o.jsx("input",{type:"text",value:String(Ve),onChange:Ze=>Z(se,Ze.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},se)}),Object.keys(y).filter(se=>se!=="inherits").length===0&&o.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[o.jsx(MU,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),o.jsx("p",{className:"text-sm",children:"No overrides yet"}),o.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(y).filter(se=>se!=="inherits").length>0&&o.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:o.jsxs("button",{onClick:()=>{$(!0),l("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[o.jsx(Ts,{className:"w-4 h-4"}),"Save as template"]})})]})]}),s==="json"&&o.jsxs("div",{className:"space-y-2",children:[A&&o.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[o.jsx(Oa,{className:"w-4 h-4"}),A]}),o.jsx("textarea",{value:E,onChange:se=>Me(se.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${A?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),o.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[o.jsx(ke,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),o.jsxs(ke,{onClick:()=>ve.mutate(),disabled:ve.isPending||!d.trim()||!a&&!g||!!A,className:"flex-1",children:[ve.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):a?o.jsx(Ts,{className:"w-4 h-4"}):o.jsx(fr,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function SWe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[a,s]=S.useState(""),[l,c]=S.useState("all"),[u,d]=S.useState("all"),[f,g]=S.useState("all"),[p,x]=S.useState("all"),[v,y]=S.useState("all"),[b,E]=S.useState("all"),[w,A]=S.useState(null),[T,C]=S.useState(!1),[N,O]=S.useState(!1),[k,j]=S.useState(null),[B,L]=S.useState(null),[K,R]=S.useState(null),[q,W]=S.useState(!1),[$,J]=S.useState([null,null]),[ee,Q]=S.useState(!1),[z,V]=S.useState(null),X=pn(),te=S.useMemo(()=>[...t.filament.map(re=>({...re,type:"filament"})),...t.printer.map(re=>({...re,type:"printer"})),...t.process.map(re=>({...re,type:"process"}))].map(re=>({...re,meta:VL(re.name)})),[t]),ie=S.useMemo(()=>{const H=new Set,re=new Set,G=new Set;return te.forEach(Z=>{Z.meta.nozzle&&H.add(Z.meta.nozzle),Z.meta.filamentType&&re.add(Z.meta.filamentType),Z.meta.layerHeight&&G.add(Z.meta.layerHeight)}),{printers:i.map(Z=>({id:Z.id.toString(),name:Z.name})),nozzles:Array.from(H).sort((Z,oe)=>parseFloat(Z)-parseFloat(oe)),filaments:Array.from(re).sort(),layerHeights:Array.from(G).sort((Z,oe)=>parseFloat(Z)-parseFloat(oe))}},[te,i]),le=S.useMemo(()=>f==="all"?null:i.find(re=>re.id.toString()===f)?.model||null,[f,i]),ge=S.useMemo(()=>te.filter(H=>l==="all"||H.type===l).filter(H=>{if(u==="all")return!0;const re=wb(H.setting_id);return u==="custom"?re:!re}).filter(H=>{if(f==="all"||!le)return!0;const re=H.meta.printer?.toLowerCase()||"",G=le.toLowerCase();return re.includes(G)||G.includes(re)}).filter(H=>p==="all"||H.meta.nozzle===p).filter(H=>v==="all"||H.meta.filamentType===v).filter(H=>b==="all"||H.meta.layerHeight===b).filter(H=>a===""||H.name.toLowerCase().includes(a.toLowerCase())).sort((H,re)=>H.name.localeCompare(re.name)),[te,l,u,f,le,p,v,b,a]),Ee=H=>{if(q){const re=$[0]?.setting_id===H.setting_id,G=$[1]?.setting_id===H.setting_id;if(re)J([$[1],null]);else if(G)J([$[0],null]);else if(!$[0])J([H,null]);else if($[1]){if($[0].type!==H.type)return;J([$[0],H])}else{if($[0].type!==H.type)return;J([$[0],H])}}else A(H)},pe=H=>{if($[0]?.setting_id===H.setting_id)return 0;if($[1]?.setting_id===H.setting_id)return 1},de=async H=>{try{const re=await _e.getCloudSettingDetail(H.setting_id),G=H.type==="process"?"print":H.type;j({type:G,name:H.name,base_id:re.base_id||"GFSA00",setting:re.setting||{}}),A(null)}catch(re){console.error("Failed to fetch preset details for duplication:",re)}},Re=async H=>{try{X.removeQueries({queryKey:["cloudSettingDetail",H.setting_id]});const re=await _e.getCloudSettingDetail(H.setting_id),G=H.type==="process"?"print":H.type;L({type:G,name:H.name,base_id:re.base_id||"GFSA00",setting:re.setting||{},setting_id:H.setting_id}),A(null)}catch(re){console.error("Failed to fetch preset details for editing:",re)}},fe=()=>{c("all"),d("all"),g("all"),x("all"),y("all"),E("all"),s("")},Fe=l!=="all"||u!=="all"||f!=="all"||p!=="all"||v!=="all"||b!=="all"||a!=="",U=t.filament.length+t.printer.length+t.process.length;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-4 mb-6",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[o.jsxs("div",{className:"relative flex-1",children:[o.jsx(_l,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),o.jsx("input",{type:"text",value:a,onChange:H=>s(H.target.value),placeholder:"Search presets...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(ke,{variant:q?"primary":"secondary",onClick:()=>{q?(W(!1),J([null,null])):W(!0)},children:[o.jsx(dp,{className:"w-4 h-4"}),q?"Cancel":"Compare"]}),o.jsxs(ke,{variant:"secondary",onClick:()=>O(!0),children:[o.jsx(O0,{className:"w-4 h-4"}),"Templates"]}),o.jsxs(ke,{variant:"secondary",onClick:n,disabled:r,children:[o.jsx(li,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),o.jsxs(ke,{onClick:()=>C(!0),children:[o.jsx(fr,{className:"w-4 h-4"}),"New Preset"]})]})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx(hR,{className:"w-4 h-4 text-bambu-gray"}),o.jsx(Ym,{label:"Type",value:l,options:[{value:"all",label:"All",count:U},{value:"filament",label:"Filament",count:t.filament.length},{value:"printer",label:"Printer",count:t.printer.length},{value:"process",label:"Process",count:t.process.length}],onChange:H=>c(H)}),o.jsx(Ym,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:H=>d(H)}),ie.printers.length>0&&o.jsx(Ym,{label:"Printer",value:f,options:[{value:"all",label:"All"},...ie.printers.map(H=>({value:H.id,label:H.name}))],onChange:g}),ie.nozzles.length>0&&o.jsx(Ym,{label:"Nozzle",value:p,options:[{value:"all",label:"All"},...ie.nozzles.map(H=>({value:H,label:H}))],onChange:x}),ie.filaments.length>0&&(l==="all"||l==="filament")&&o.jsx(Ym,{label:"Filament",value:v,options:[{value:"all",label:"All"},...ie.filaments.map(H=>({value:H,label:H}))],onChange:y}),ie.layerHeights.length>0&&(l==="all"||l==="process")&&o.jsx(Ym,{label:"Layer",value:b,options:[{value:"all",label:"All"},...ie.layerHeights.map(H=>({value:H,label:H}))],onChange:E}),Fe&&o.jsx("button",{onClick:fe,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),q&&o.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx(dp,{className:"w-5 h-5 text-blue-400"}),o.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),o.jsx("span",{className:"text-bambu-gray",children:$[0]?`Select another ${$[0].type} preset`:"Click two presets of the same type to compare"})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${$[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:$[0]?$[0].name:"1. Select first"}),o.jsx(Xk,{className:"w-4 h-4 text-bambu-gray"}),o.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${$[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:$[1]?$[1].name:"2. Select second"})]}),$[0]&&$[1]&&o.jsxs(ke,{size:"sm",onClick:async()=>{try{const[H,re]=await Promise.all([_e.getCloudSettingDetail($[0].setting_id),_e.getCloudSettingDetail($[1].setting_id)]);V([H.setting||{},re.setting||{}]),Q(!0)}catch{}},children:[o.jsx(dp,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),o.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(ur,{className:"w-3 h-3"}),"Last synced: ",xWe(e.toISOString())]}),o.jsxs("span",{children:["Showing ",ge.length," of ",U," presets"]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),o.jsx("span",{children:"= My preset (editable)"})]})]}),ge.length===0?o.jsxs("div",{className:"text-center py-16",children:[o.jsx(gd,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),o.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),Fe&&o.jsx("button",{onClick:fe,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[o.jsx(cR,{className:"w-4 h-4 text-amber-400"}),o.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),o.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ge.filter(H=>H.type==="filament").length,")"]})]}),o.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ge.filter(H=>H.type==="filament").map(H=>o.jsx(Rk,{setting:H,onClick:()=>Ee(H),onDuplicate:()=>de(H),compareMode:q,isCompareSelected:pe(H)!==void 0,compareIndex:pe(H),compareDisabled:q&&!!$[0]&&$[0].type!==H.type},H.setting_id)),ge.filter(H=>H.type==="filament").length===0&&o.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[o.jsx(rM,{className:"w-4 h-4 text-blue-400"}),o.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),o.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ge.filter(H=>H.type==="process").length,")"]})]}),o.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ge.filter(H=>H.type==="process").map(H=>o.jsx(Rk,{setting:H,onClick:()=>Ee(H),onDuplicate:()=>de(H),compareMode:q,isCompareSelected:pe(H)!==void 0,compareIndex:pe(H),compareDisabled:q&&!!$[0]&&$[0].type!==H.type},H.setting_id)),ge.filter(H=>H.type==="process").length===0&&o.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[o.jsx(Gi,{className:"w-4 h-4 text-purple-400"}),o.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),o.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ge.filter(H=>H.type==="printer").length,")"]})]}),o.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ge.filter(H=>H.type==="printer").map(H=>o.jsx(Rk,{setting:H,onClick:()=>Ee(H),onDuplicate:()=>de(H),compareMode:q,isCompareSelected:pe(H)!==void 0,compareIndex:pe(H),compareDisabled:q&&!!$[0]&&$[0].type!==H.type},H.setting_id)),ge.filter(H=>H.type==="printer").length===0&&o.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),w&&o.jsx(vWe,{setting:w,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>de(w),onEdit:()=>Re(w)}),(T||k||B||K)&&o.jsx(wWe,{onClose:()=>{C(!1),j(null),L(null),R(null)},initialData:B||k||(K?{type:K.type,name:"",base_id:"",setting:K.setting}:void 0),allPresets:t}),N&&o.jsx(_We,{onClose:()=>O(!1),onApply:H=>{R({type:H.type,setting:H.settings}),O(!1)}}),ee&&z&&$[0]&&$[1]&&o.jsx(Kte,{onClose:()=>{Q(!1),V(null)},leftPreset:z[0],rightPreset:z[1],leftLabel:$[0].name,rightLabel:$[1].name})]})}function MWe(){const t=pn(),{showToast:e}=Ar(),[n,r]=S.useState("cloud"),[i,a]=S.useState(),{data:s,isLoading:l}=gt({queryKey:["cloudStatus"],queryFn:_e.getCloudStatus}),{data:c=[]}=gt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:g}=gt({queryKey:["cloudSettings"],queryFn:()=>_e.getCloudSettings(),enabled:!!s?.is_authenticated,retry:!1,staleTime:1e3*60*5});S.useEffect(()=>{g&&a(new Date(g))},[g]);const p=vt({mutationFn:_e.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),x=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return l?o.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):o.jsxs("div",{className:"p-6 lg:p-8",children:[o.jsxs("div",{className:"mb-6",children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),o.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),o.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[o.jsxs("button",{onClick:()=>r("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[o.jsx(QS,{className:"w-4 h-4"}),"Cloud Profiles"]}),o.jsxs("button",{onClick:()=>r("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[o.jsx(eM,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&o.jsxs(o.Fragment,{children:[s?.is_authenticated&&o.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),o.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",o.jsx("span",{className:"text-white",children:s.email})]})]}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[o.jsx(Oce,{className:"w-4 h-4"}),"Logout"]})]}),s?.is_authenticated?d?o.jsx("div",{className:"flex items-center justify-center py-16",children:o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?o.jsx(SWe,{settings:u,lastSyncTime:i,onRefresh:()=>f(),isRefreshing:d,printers:c}):o.jsxs("div",{className:"text-center py-16",children:[o.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),o.jsx(ke,{onClick:()=>f(),children:"Retry"})]}):o.jsx(bWe,{onSuccess:x})]}),n==="kprofiles"&&o.jsx(gWe,{}),o.jsx(yWe,{})]})}const i0={Droplet:cR,Flame:Wle,Ruler:Mue,Sparkles:O0,Square:af,Cable:Hoe,Wrench:bd,Calendar:Jr,Timer:Ju,Cog:ble,Fan:Lle,Zap:sf,Wind:Ade,Thermometer:iM,Layers:gd,Box:Qh,Target:V9,RefreshCw:li,Settings:yR,Filter:hR,CircleDot:ale};function N0(t){return t&&i0[t]||bd}function Zm(t,e){if(e==="days")return t<1?"Today":t===1?"1 day":t<7?`${Math.round(t)} days`:t<180?`${Math.round(t/7)} weeks`:`${Math.round(t/30)} months`;{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const n=t/24;if(n<7)return`${n<2?n.toFixed(1):Math.round(n)}d`;const r=n/7;return r<12?`${r<2?r.toFixed(1):Math.round(r)}w`:`${Math.round(r/4)}mo`}}function Dk(t,e){return e==="days"?t===1?"1 day":t===7?"1 week":t===14?"2 weeks":t===30?"1 month":t===60?"2 months":t===90?"3 months":t===180?"6 months":t===365?"1 year":`${t} days`:`${t}h`}function EWe({item:t,onPerform:e,onToggle:n}){const r=N0(t.maintenance_type_icon),i=t.interval_type||"hours",s=(()=>{if(i==="days"){const f=t.days_since_maintenance??0;return Math.max(0,Math.min(100,f/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),l=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",c=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",u=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",d=()=>{if(!t.enabled)return"Disabled";if(i==="days"){const f=t.days_until_due??0;return t.is_due?`Overdue by ${Zm(Math.abs(f),"days")}`:t.is_warning?`Due in ${Zm(f,"days")}`:`${Zm(f,"days")} left`}else return t.is_due?`Overdue by ${Zm(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${Zm(t.hours_until_due,"hours")}`:`${Zm(t.hours_until_due,"hours")} left`};return o.jsx("div",{className:`rounded-xl border p-4 transition-all ${u()}`,children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsxs("div",{className:`relative p-2.5 rounded-lg ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[o.jsx(r,{className:`w-5 h-5 ${l()}`}),t.enabled&&(t.is_due||t.is_warning)&&o.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),i==="days"&&o.jsx("span",{title:"Time-based interval",children:o.jsx(Jr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})})]}),o.jsx("div",{className:"mt-2 mb-1.5",children:o.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:o.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${c()}`,style:{width:`${s}%`}})})}),o.jsxs("div",{className:`text-xs flex items-center gap-1 ${l()}`,children:[t.is_due&&o.jsx(Gn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&o.jsx(ur,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&o.jsx(po,{className:"w-3 h-3"}),d()]})]}),o.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o.jsx(Bn,{checked:t.enabled,onChange:f=>n(t.id,f)}),o.jsxs(ke,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[o.jsx(sg,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function AWe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,a]=S.useState(!0),[s,l]=S.useState(!1),[c,u]=S.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((p,x)=>p.is_due&&!x.is_due?-1:!p.is_due&&x.is_due?1:p.is_warning&&!x.is_warning?-1:!p.is_warning&&x.is_warning?1:p.maintenance_type_id-x.maintenance_type_id),f=d.find(p=>p.enabled&&(p.is_due||p.is_warning)),g=()=>{const p=parseFloat(c);!isNaN(p)&&p>=0&&(r(t.printer_id,p),l(!1))};return o.jsxs(Mt,{className:"overflow-hidden",children:[o.jsxs("div",{className:"p-5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),o.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&o.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[o.jsx(Gn,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&o.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[o.jsx(ur,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&o.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[o.jsx(po,{className:"w-3 h-3"}),"All good"]})]})]}),o.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[i?o.jsx(Tb,{className:"w-4 h-4"}):o.jsx(vo,{className:"w-4 h-4"}),i?"Collapse":"Expand"]})]}),o.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:o.jsx(Ju,{className:"w-4 h-4 text-bambu-gray"})}),s?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"number",value:c,onChange:p=>u(p.target.value),onKeyDown:p=>{p.key==="Enter"&&g(),p.key==="Escape"&&l(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),o.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),o.jsx(ke,{size:"sm",onClick:g,children:"Save"}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>l(!1),children:"Cancel"})]}):o.jsxs("button",{onClick:()=>{u(Math.round(t.total_print_hours).toString()),l(!0)},className:"group",children:[o.jsxs("div",{className:"text-sm font-medium text-white group-hover:text-bambu-green transition-colors flex items-center gap-1",children:[Math.round(t.total_print_hours)," hours",o.jsx(nf,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),o.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),o.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const p=N0(f.maintenance_type_icon);return o.jsx(p,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),o.jsxs("div",{children:[o.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),o.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&o.jsx(At,{className:"pt-0 border-t border-bambu-dark-tertiary",children:o.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:d.map(p=>o.jsx(EWe,{item:p,onPerform:e,onToggle:n},p.id))})})]})}function TWe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a,onAssignType:s,onRemoveItem:l}){const[c,u]=S.useState(null),[d,f]=S.useState(""),[g,p]=S.useState("hours"),[x,v]=S.useState(!1),[y,b]=S.useState(""),[E,w]=S.useState("100"),[A,T]=S.useState("hours"),[C,N]=S.useState("Wrench"),[O,k]=S.useState(new Set),[j,B]=S.useState(null),L=S.useMemo(()=>t?t.map(Fe=>({id:Fe.printer_id,name:Fe.printer_name})):[],[t]),K=Fe=>t?t.filter(U=>U.maintenance_items.some(H=>H.maintenance_type_id===Fe)).map(U=>({printerId:U.printer_id,printerName:U.printer_name,itemId:U.maintenance_items.find(H=>H.maintenance_type_id===Fe)?.id})):[],R=Fe=>{if(!t)return[];const U=new Set(K(Fe).map(H=>H.printerId));return L.filter(H=>!U.has(H.id))},[q,W]=S.useState(null),[$,J]=S.useState(""),[ee,Q]=S.useState(""),[z,V]=S.useState("hours"),[X,te]=S.useState("Wrench"),ie=Fe=>{W(Fe),J(Fe.name),Q(Fe.default_interval_hours.toString()),V(Fe.interval_type||"hours"),te(Fe.icon||"Wrench")},le=()=>{q&&$.trim()&&parseFloat(ee)>0&&(i(q.id,{name:$.trim(),default_interval_hours:parseFloat(ee),interval_type:z,icon:X}),W(null))},ge=(Fe,U,H)=>{const re=parseFloat(d);if(!isNaN(re)&&re>0){const G=Math.abs(re-U)<.01?null:re;n(Fe,{custom_interval_hours:G,custom_interval_type:g!==H?g:null})}u(null)},Ee=Fe=>{Fe.preventDefault(),y.trim()&&parseFloat(E)>0&&O.size>0&&(r({name:y.trim(),default_interval_hours:parseFloat(E),interval_type:A,icon:C},Array.from(O)),b(""),w("100"),T("hours"),k(new Set),v(!1))},pe=Fe=>{k(U=>{const H=new Set(U);return H.has(Fe)?H.delete(Fe):H.add(Fe),H})},de=t?.map(Fe=>({printerId:Fe.printer_id,printerName:Fe.printer_name,items:Fe.maintenance_items.sort((U,H)=>U.maintenance_type_id-H.maintenance_type_id)})).sort((Fe,U)=>Fe.printerName.localeCompare(U.printerName))||[],Re=e.filter(Fe=>Fe.is_system),fe=e.filter(Fe=>!Fe.is_system);return o.jsxs("div",{className:"space-y-8",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),o.jsxs(ke,{onClick:()=>v(!x),children:[o.jsx(fr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),x&&o.jsx(Mt,{className:"mb-6",children:o.jsx(At,{className:"py-4",children:o.jsxs("form",{onSubmit:Ee,children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[o.jsxs("div",{className:"lg:col-span-2",children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Name"}),o.jsx("input",{type:"text",value:y,onChange:Fe=>b(Fe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"e.g., Replace HEPA Filter",autoFocus:!0})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),o.jsxs("select",{value:A,onChange:Fe=>{T(Fe.target.value),Fe.target.value==="days"?w("30"):w("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"hours",children:"Print Hours"}),o.jsx("option",{value:"days",children:"Calendar Days"})]})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",A==="days"?"days":"hours",")"]}),o.jsx("input",{type:"number",value:E,onChange:Fe=>w(Fe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),o.jsx("div",{className:"mt-4 flex items-end justify-between",children:o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),o.jsx("div",{className:"flex gap-1",children:Object.keys(i0).map(Fe=>{const U=i0[Fe];return o.jsx("button",{type:"button",onClick:()=>N(Fe),className:`p-2 rounded-lg transition-colors ${C===Fe?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:o.jsx(U,{className:"w-4 h-4"})},Fe)})})]})}),o.jsxs("div",{className:"mt-4",children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Assign to Printers"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:L.map(Fe=>o.jsx("button",{type:"button",onClick:()=>pe(Fe.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${O.has(Fe.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:Fe.name},Fe.id))}),O.size===0&&o.jsx("p",{className:"text-xs text-orange-400 mt-1",children:"Select at least one printer"})]}),o.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:()=>{v(!1),k(new Set)},children:"Cancel"}),o.jsx(ke,{type:"submit",disabled:!y.trim()||O.size===0,children:"Add Type"})]})]})})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[Re.map(Fe=>{const U=N0(Fe.icon),H=Fe.interval_type||"hours";return o.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:o.jsx(U,{className:"w-5 h-5 text-bambu-gray"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-white truncate",children:Fe.name}),o.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[H==="days"?o.jsx(Jr,{className:"w-3 h-3"}):o.jsx(Ju,{className:"w-3 h-3"}),Dk(Fe.default_interval_hours,H)]})]})]})},Fe.id)}),fe.map(Fe=>{const U=N0(Fe.icon),H=Fe.interval_type||"hours";if(q?.id===Fe.id)return o.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:o.jsxs("div",{className:"space-y-3",children:[o.jsx("input",{type:"text",value:$,onChange:be=>J(be.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Name",autoFocus:!0}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("select",{value:z,onChange:be=>V(be.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[o.jsx("option",{value:"hours",children:"Print Hours"}),o.jsx("option",{value:"days",children:"Calendar Days"})]}),o.jsx("input",{type:"number",value:ee,onChange:be=>Q(be.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),o.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(i0).map(be=>{const Te=i0[be];return o.jsx("button",{type:"button",onClick:()=>te(be),className:`p-1.5 rounded transition-colors ${X===be?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:o.jsx(Te,{className:"w-3.5 h-3.5"})},be)})}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(ke,{size:"sm",onClick:le,disabled:!$.trim(),children:"Save"}),o.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>W(null),children:"Cancel"})]})]})},Fe.id);const G=K(Fe.id),Z=R(Fe.id),oe=j===Fe.id;return o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:o.jsx(U,{className:"w-5 h-5 text-bambu-green"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm font-medium text-white truncate",children:Fe.name}),o.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),o.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[H==="days"?o.jsx(Jr,{className:"w-3 h-3"}):o.jsx(Ju,{className:"w-3 h-3"}),Dk(Fe.default_interval_hours,H)]})]}),o.jsxs("button",{onClick:()=>B(oe?null:Fe.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${G.length>0?"border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20":"border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20"}`,title:`${G.length} printer(s) assigned - click to manage`,children:[o.jsx(Gi,{className:"w-3 h-3"}),o.jsx("span",{className:"text-xs font-medium",children:G.length}),o.jsx(vo,{className:`w-3 h-3 transition-transform ${oe?"rotate-180":""}`})]}),o.jsx("button",{onClick:()=>ie(Fe),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:o.jsx(nf,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>{confirm(`Delete "${Fe.name}"?`)&&a(Fe.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:o.jsx(Nn,{className:"w-4 h-4"})})]}),oe&&o.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[o.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Assigned to printers:"}),G.length===0?o.jsx("p",{className:"text-xs text-orange-400",children:"No printers assigned"}):o.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:G.map(be=>o.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[be.printerName,o.jsx("button",{onClick:()=>be.itemId&&l(be.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},be.printerId))}),Z.length>0&&o.jsxs("div",{className:"flex flex-wrap gap-1",children:[o.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:"Add:"}),Z.map(be=>o.jsxs("button",{onClick:()=>s(be.id,Fe.id),className:"px-2 py-1 bg-bambu-dark hover:bg-bambu-green/20 rounded text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:["+ ",be.name]},be.id))]})]})]},Fe.id)})]})]}),de.length>0&&o.jsxs("div",{children:[o.jsxs("div",{className:"mb-4",children:[o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),o.jsx("div",{className:"space-y-4",children:de.map(Fe=>o.jsx(Mt,{children:o.jsxs(At,{className:"py-4",children:[o.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:Fe.printerName}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:Fe.items.map(U=>{const H=N0(U.maintenance_type_icon),re=e.find(Te=>Te.id===U.maintenance_type_id),G=re?.default_interval_hours||U.interval_hours,Z=re?.interval_type||"hours",oe=U.interval_type||"hours",be=c===U.id;return o.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[o.jsx(H,{className:"w-4 h-4 text-bambu-gray shrink-0"}),o.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:U.maintenance_type_name}),be?o.jsxs("div",{className:"flex items-center gap-1",children:[g==="days"?o.jsx(Jr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):o.jsx(Ju,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),o.jsxs("select",{value:g,onChange:Te=>p(Te.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[o.jsx("option",{value:"hours",children:"Print Hours"}),o.jsx("option",{value:"days",children:"Calendar Days"})]}),o.jsx("input",{type:"number",value:d,onChange:Te=>f(Te.target.value),onKeyDown:Te=>{Te.key==="Enter"&&ge(U.id,G,Z),Te.key==="Escape"&&u(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),o.jsx(ke,{size:"sm",onClick:()=>ge(U.id,G,Z),children:"OK"})]}):o.jsxs("button",{onClick:()=>{u(U.id),f(U.interval_hours.toString()),p(oe)},className:"px-2 py-1 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary border border-bambu-dark-tertiary hover:border-bambu-green rounded text-xs font-medium text-white transition-colors flex items-center gap-1",children:[oe==="days"?o.jsx(Jr,{className:"w-3 h-3"}):o.jsx(Ju,{className:"w-3 h-3"}),Dk(U.interval_hours,oe),o.jsx(nf,{className:"w-3 h-3 text-bambu-gray"})]})]},U.id)})})]})},Fe.printerId))})]}),de.length===0&&o.jsx(Mt,{children:o.jsxs(At,{className:"text-center py-12",children:[o.jsx(ur,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),o.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),o.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function NWe(){const t=pn(),{showToast:e}=Ar(),[n,r]=S.useState("status"),{data:i,isLoading:a}=gt({queryKey:["maintenanceOverview"],queryFn:_e.getMaintenanceOverview}),{data:s}=gt({queryKey:["maintenanceTypes"],queryFn:_e.getMaintenanceTypes}),l=vt({mutationFn:({id:w,notes:A})=>_e.performMaintenance(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:w=>{e(w.message,"error")}}),c=vt({mutationFn:({id:w,data:A})=>_e.updateMaintenanceItem(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:w=>{e(w.message,"error")}}),u=vt({mutationFn:({id:w,data:A})=>_e.updateMaintenanceType(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:w=>{e(w.message,"error")}}),d=vt({mutationFn:_e.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:w=>{e(w.message,"error")}}),f=vt({mutationFn:({printerId:w,hours:A})=>_e.setPrinterHours(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:w=>{e(w.message,"error")}}),g=vt({mutationFn:({printerId:w,typeId:A})=>_e.assignMaintenanceType(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:w=>{e(w.message,"error")}}),p=vt({mutationFn:_e.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:w=>{e(w.message,"error")}}),x=w=>{l.mutate({id:w})},v=(w,A)=>{c.mutate({id:w,data:{enabled:A}})},y=(w,A)=>{f.mutate({printerId:w,hours:A})};if(a)return o.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const b=i?.reduce((w,A)=>w+A.due_count,0)||0,E=i?.reduce((w,A)=>w+A.warning_count,0)||0;return o.jsxs("div",{className:"p-4 md:p-8",children:[o.jsxs("div",{className:"mb-6",children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),o.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?o.jsxs(o.Fragment,{children:[b>0&&o.jsxs("span",{className:"text-red-400",children:[b," task",b!==1?"s":""," overdue"]}),b>0&&E>0&&" · ",E>0&&o.jsxs("span",{className:"text-amber-400",children:[E," due soon"]}),b===0&&E===0&&o.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),o.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[o.jsx("button",{onClick:()=>r("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Status"}),o.jsx("button",{onClick:()=>r("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Settings"})]}),n==="status"?o.jsx("div",{className:"space-y-6",children:i&&i.length>0?[...i].sort((w,A)=>{const T=w.due_count*10+w.warning_count,C=A.due_count*10+A.warning_count;return T!==C?C-T:w.printer_name.localeCompare(A.printer_name)}).map(w=>o.jsx(AWe,{overview:w,onPerform:x,onToggle:v,onSetHours:y},w.printer_id)):o.jsx(Mt,{children:o.jsxs(At,{className:"text-center py-16",children:[o.jsx(bd,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),o.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No printers configured"}),o.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):o.jsx(TWe,{overview:i,types:s||[],onUpdateInterval:(w,A)=>c.mutate({id:w,data:A}),onAddType:async(w,A)=>{const T=await _e.createMaintenanceType(w);for(const C of A)await _e.assignMaintenanceType(C,T.id);t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onUpdateType:(w,A)=>u.mutate({id:w,data:A}),onDeleteType:w=>d.mutate(w),onAssignType:(w,A)=>g.mutate({printerId:w,typeId:A}),onRemoveItem:w=>p.mutate(w)})]})}const ZG=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Xte({project:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=S.useState(t?.name||""),[s,l]=S.useState(t?.description||""),[c,u]=S.useState(t?.color||ZG[0]),[d,f]=S.useState(t?.target_count?.toString()||""),[g,p]=S.useState(t?.status||"active"),[x,v]=S.useState(t?.tags||""),[y,b]=S.useState(t?.due_date?.split("T")[0]||""),[E,w]=S.useState(t?.priority||"normal"),A=T=>{T.preventDefault(),n({name:i.trim(),description:s.trim()||void 0,color:c,target_count:d?parseInt(d,10):void 0,tags:x.trim()||void 0,due_date:y||void 0,priority:E,...t&&{status:g}})};return o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:o.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[o.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:t?"Edit Project":"New Project"})}),o.jsxs("form",{onSubmit:A,className:"p-4 space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Name"}),o.jsx("input",{type:"text",value:i,onChange:T=>a(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., Voron 2.4 Build",required:!0})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Description"}),o.jsx("textarea",{value:s,onChange:T=>l(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green resize-none",placeholder:"Optional description...",rows:2})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Color"}),o.jsx("div",{className:"flex gap-2 flex-wrap",children:ZG.map(T=>o.jsx("button",{type:"button",onClick:()=>u(T),className:`w-8 h-8 rounded-full transition-transform ${c===T?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:T}},T))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Print Count (optional)"}),o.jsx("input",{type:"number",value:d,onChange:T=>f(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., 50 parts to print",min:"1"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Tags (comma-separated)"}),o.jsx("input",{type:"text",value:x,onChange:T=>v(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., voron, functional, gift"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Due Date"}),o.jsx("input",{type:"date",value:y,onChange:T=>b(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Priority"}),o.jsxs("select",{value:E,onChange:T=>w(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[o.jsx("option",{value:"low",children:"Low"}),o.jsx("option",{value:"normal",children:"Normal"}),o.jsx("option",{value:"high",children:"High"}),o.jsx("option",{value:"urgent",children:"Urgent"})]})]})]}),t&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Status"}),o.jsxs("select",{value:g,onChange:T=>p(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[o.jsx("option",{value:"active",children:"Active"}),o.jsx("option",{value:"completed",children:"Completed"}),o.jsx("option",{value:"archived",children:"Archived"})]})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o.jsx(ke,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(ke,{type:"submit",disabled:!i.trim()||r,children:r?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function CWe({project:t,onClick:e,onEdit:n,onDelete:r}){const i=t.progress_percent??0,a=t.status==="completed",s=t.status==="archived",[l,c]=S.useState(!1),d=a?{icon:lR,color:"text-bambu-green",bg:"bg-bambu-green/10"}:s?{icon:lo,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:ur,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:Bo,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return o.jsxs("div",{className:"group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden",onClick:e,children:[o.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full",style:{backgroundColor:t.color||"#6b7280",boxShadow:`0 0 12px ${t.color||"#6b7280"}40`}}),o.jsxs("div",{className:"p-5 pl-6",children:[o.jsxs("div",{className:"flex items-start justify-between mb-4",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[o.jsx("div",{className:`p-2 rounded-lg ${d.bg} flex-shrink-0`,children:o.jsx(d.icon,{className:`w-5 h-5 ${d.color}`})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_count?o.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${i>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.total_items,"/",t.target_count," items"]}):t.total_items>0?o.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray",children:[t.total_items," item",t.total_items!==1?"s":""]}):null,a&&o.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:"Done"}),s&&o.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:"Archived"})]}),t.description&&o.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const f=[...new Set(t.archives.map(p=>p.filament_type).filter(Boolean))],g=[...new Set(t.archives.map(p=>p.filament_color).filter(Boolean))];return f.length===0&&g.length===0?null:o.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[f.slice(0,3).map(p=>o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:p},p)),g.length>0&&o.jsxs("div",{className:"flex items-center gap-0.5",children:[g.slice(0,5).map(p=>o.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:p.startsWith("#")?p:`#${p}`},title:p},p)),g.length>5&&o.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",g.length-5]})]})]})})()]})]}),o.jsxs("div",{className:"relative",onClick:f=>f.stopPropagation(),children:[o.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>c(!l),children:o.jsx(o0,{className:"w-4 h-4"})}),l&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>c(!1)}),o.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[o.jsxs("button",{className:"w-full px-3 py-2 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{n(),c(!1)},children:[o.jsx(nf,{className:"w-4 h-4"}),"Edit"]}),o.jsxs("button",{className:"w-full px-3 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(),c(!1)},children:[o.jsx(Nn,{className:"w-4 h-4"}),"Delete"]})]})]})]})]}),o.jsx("div",{className:"mb-4",children:t.target_count?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between text-xs mb-2",children:[o.jsx("span",{className:"text-bambu-gray",children:"Progress"}),o.jsxs("span",{className:i>=100?"text-bambu-green font-medium":"text-white",children:[t.total_items," / ",t.target_count]})]}),o.jsx("div",{className:"h-2.5 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:o.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(i,100)}%`,background:i>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${i>=100?"#22c55e":t.color||"#6b7280"}60`}})}),o.jsxs("div",{className:"text-right text-xs text-bambu-gray/60 mt-1",children:[i.toFixed(0),"% complete"]})]}):t.total_items>0?o.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[o.jsx(lo,{className:"w-3.5 h-3.5"}),o.jsxs("span",{children:[t.total_items," item",t.total_items!==1?"s":""," completed"]})]}),t.queue_count>0&&o.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[o.jsx(ur,{className:"w-3.5 h-3.5"}),o.jsxs("span",{children:[t.queue_count," in queue"]})]})]}):o.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:"No prints yet"})}),t.archives&&t.archives.length>0&&o.jsxs("div",{className:"mb-4",children:[o.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(f=>o.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:f.print_name||"Unknown",children:[f.thumbnail_path?o.jsx("img",{src:_e.getArchiveThumbnail(f.id),alt:f.print_name||"",className:"w-full h-full object-cover"}):o.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:o.jsx(zc,{className:"w-6 h-6"})}),f.status==="failed"&&o.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:o.jsx(Gn,{className:"w-4 h-4 text-white"})})]},f.id))}),t.archive_count>4&&o.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:["+",t.archive_count-4," more"]})]}),o.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[o.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[o.jsxs("div",{className:"flex items-center gap-1.5",title:"Total items printed",children:[o.jsx(lo,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:t.total_items})]}),t.queue_count>0&&o.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",title:"In queue",children:[o.jsx(Jk,{className:"w-3.5 h-3.5"}),o.jsx("span",{children:t.queue_count})]})]}),o.jsx(Ko,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function kWe(){const t=Eb(),e=pn(),{showToast:n}=Ar(),[r,i]=S.useState(!1),[a,s]=S.useState(),[l,c]=S.useState("active"),[u,d]=S.useState(null),{data:f,isLoading:g}=gt({queryKey:["projects",l==="all"?void 0:l],queryFn:()=>_e.getProjects(l==="all"?void 0:l)}),p=vt({mutationFn:C=>_e.createProject(C),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),n("Project created","success")},onError:C=>{n(C.message,"error")}}),x=vt({mutationFn:({id:C,data:N})=>_e.updateProject(C,N),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),s(void 0),n("Project updated","success")},onError:C=>{n(C.message,"error")}}),v=vt({mutationFn:C=>_e.deleteProject(C),onSuccess:()=>{d(null),n("Project deleted","success"),setTimeout(()=>window.location.reload(),100)},onError:C=>{d(null),n(C.message,"error")}}),y=C=>{a?x.mutate({id:a.id,data:C}):p.mutate(C)},b=C=>{s(C),i(!0)},E=C=>{t(`/projects/${C.id}`)},w=C=>{d(C)},A=()=>{u!==null&&v.mutate(u)},T=f?.reduce((C,N)=>(C[N.status]=(C[N.status]||0)+1,C.all=(C.all||0)+1,C),{})||{};return o.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[o.jsxs("div",{children:[o.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[o.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:o.jsx(Bo,{className:"w-6 h-6 text-bambu-green"})}),"Projects"]}),o.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and track your 3D printing projects"})]}),o.jsxs(ke,{onClick:()=>i(!0),className:"sm:w-auto w-full",children:[o.jsx(fr,{className:"w-4 h-4 mr-2"}),"New Project"]})]}),o.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:"Active",icon:ur},{key:"completed",label:"Completed",icon:lR},{key:"archived",label:"Archived",icon:lo},{key:"all",label:"All",icon:Bo}].map(({key:C,label:N,icon:O})=>o.jsxs("button",{onClick:()=>c(C),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${l===C?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[o.jsx(O,{className:"w-4 h-4"}),o.jsx("span",{children:N}),T[C]>0&&o.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${l===C?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:T[C]})]},C))}),g?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsxs("div",{className:"flex flex-col items-center gap-3",children:[o.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading projects..."})]})}):f?.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[o.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:o.jsx(Bo,{className:"w-12 h-12 text-bambu-gray/50"})}),o.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:l==="all"?"No projects yet":`No ${l} projects`}),o.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:l==="all"?"Create your first project to start organizing related prints, tracking progress, and managing your builds.":`You don't have any ${l} projects. Projects will appear here when their status changes.`}),l==="all"&&o.jsxs(ke,{onClick:()=>i(!0),children:[o.jsx(fr,{className:"w-4 h-4 mr-2"}),"Create Your First Project"]})]}):o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:f?.map(C=>o.jsx(CWe,{project:C,onClick:()=>E(C),onEdit:()=>b(C),onDelete:()=>w(C.id)},C.id))}),u!==null&&o.jsx(br,{title:"Delete Project",message:"Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.",confirmText:"Delete Project",variant:"danger",onConfirm:A,onCancel:()=>d(null)}),r&&o.jsx(Xte,{project:a,onClose:()=>{i(!1),s(void 0)},onSave:y,isLoading:p.isPending||x.isPending})]})}function PWe(t){if(t<1)return`${Math.round(t*60)}m`;const e=Math.floor(t),n=Math.round((t-e)*60);return n>0?`${e}h ${n}m`:`${e}h`}function jWe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function RWe({status:t}){const e={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},n=e[t]||e.active;return o.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${n}`,children:t.charAt(0).toUpperCase()+t.slice(1)})}function u1({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-gray"}){return o.jsx(Mt,{children:o.jsx(At,{className:"p-4",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${i}`,children:o.jsx(t,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:e}),o.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&o.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function DWe({archives:t}){return t.length===0?o.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[o.jsx(zc,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),o.jsx("p",{children:"No prints in this project yet"})]}):o.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(e=>o.jsxs(Sc,{to:`/archives?search=${encodeURIComponent(e.print_name||"")}`,className:"group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors",children:[e.thumbnail_path?o.jsx("img",{src:_e.getArchiveThumbnail(e.id),alt:e.print_name||"Print",className:"w-full h-full object-cover"}):o.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:o.jsx(zc,{className:"w-8 h-8"})}),e.status==="failed"&&o.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:o.jsx(Pa,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&o.jsx("div",{className:"absolute top-1 right-1",children:o.jsx(kr,{className:"w-4 h-4 text-bambu-green"})}),o.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx("p",{className:"text-xs text-white truncate",children:e.print_name||"Unknown"})})]},e.id))})}function OWe({priority:t}){const e={low:{color:"bg-gray-500/20 text-gray-400",label:"Low"},normal:{color:"bg-blue-500/20 text-blue-400",label:"Normal"},high:{color:"bg-orange-500/20 text-orange-400",label:"High"},urgent:{color:"bg-red-500/20 text-red-400",label:"Urgent"}},{color:n,label:r}=e[t]||e.normal;return o.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${n}`,children:[t==="urgent"&&o.jsx(Gn,{className:"w-3 h-3"}),r]})}function LWe(t){return t?new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):""}function Ok(t){if(!t)return null;const e=new Date(t),n=new Date,r=Math.ceil((e.getTime()-n.getTime())/(1e3*60*60*24));return r<0?{color:"text-red-400",label:"Overdue"}:r===0?{color:"text-orange-400",label:"Due today"}:r<=3?{color:"text-yellow-400",label:`${r} days left`}:{color:"text-bambu-gray",label:`${r} days left`}}function IWe(){const{id:t}=Jj(),e=Eb(),n=pn(),{showToast:r}=Ar(),[i,a]=S.useState(!1),[s,l]=S.useState(!1),[c,u]=S.useState(""),[d,f]=S.useState(!1),g=S.useRef(null),p=parseInt(t||"0",10),{data:x,isLoading:v,error:y}=gt({queryKey:["project",p],queryFn:()=>_e.getProject(p),enabled:p>0}),{data:b,isLoading:E}=gt({queryKey:["project-archives",p],queryFn:()=>_e.getProjectArchives(p),enabled:p>0}),{data:w,isLoading:A}=gt({queryKey:["project-bom",p],queryFn:()=>_e.getProjectBOM(p),enabled:p>0}),{data:T,isLoading:C}=gt({queryKey:["project-timeline",p],queryFn:()=>_e.getProjectTimeline(p,20),enabled:p>0}),{data:N}=gt({queryKey:["settings"],queryFn:_e.getSettings}),O=N?.currency||"$",k=vt({mutationFn:F=>_e.updateProject(p,F),onSuccess:()=>{n.invalidateQueries({queryKey:["project",p]}),n.invalidateQueries({queryKey:["projects"]}),a(!1),l(!1),r("Project updated","success")},onError:F=>{r(F.message,"error")}}),j=()=>{u(x?.notes||""),l(!0)},B=()=>{k.mutate({notes:c})},L=()=>{l(!1),u("")},K=async F=>{const I=F.target.files?.[0];if(I){f(!0);try{const ne=await _e.uploadProjectAttachment(p,I);n.invalidateQueries({queryKey:["project",p]}),r(`Uploaded: ${ne.original_name}`,"success")}catch(ne){r(ne.message,"error")}finally{f(!1),g.current&&(g.current.value="")}}},R=(F,I)=>{Re({isOpen:!0,title:"Delete Attachment",message:`Are you sure you want to delete "${I}"?`,onConfirm:async()=>{Re(ne=>({...ne,isOpen:!1}));try{await _e.deleteProjectAttachment(p,F),n.invalidateQueries({queryKey:["project",p]}),r("Attachment deleted","success")}catch(ne){r(ne.message,"error")}}})},q=F=>F<1024?`${F} B`:F<1024*1024?`${(F/1024).toFixed(1)} KB`:`${(F/(1024*1024)).toFixed(1)} MB`,[W,$]=S.useState(""),[J,ee]=S.useState(1),[Q,z]=S.useState(""),[V,X]=S.useState(""),[te,ie]=S.useState(""),[le,ge]=S.useState(!1),[Ee,pe]=S.useState(!1),[de,Re]=S.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),fe=vt({mutationFn:F=>_e.createBOMItem(p,F),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]}),$(""),ee(1),z(""),X(""),ie(""),ge(!1),r("Part added","success")},onError:F=>r(F.message,"error")}),Fe=vt({mutationFn:({itemId:F,data:I})=>_e.updateBOMItem(p,F,I),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]})},onError:F=>r(F.message,"error")}),U=vt({mutationFn:F=>_e.deleteBOMItem(p,F),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]}),r("Part removed","success")},onError:F=>r(F.message,"error")}),H=F=>{F.preventDefault(),W.trim()&&fe.mutate({name:W.trim(),quantity_needed:J,unit_price:Q?parseFloat(Q):void 0,sourcing_url:V.trim()||void 0,remarks:te.trim()||void 0})},re=F=>{const I=F.is_complete?0:F.quantity_needed;Fe.mutate({itemId:F.id,data:{quantity_acquired:I}})},G=(F,I)=>{Re({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${I}"?`,onConfirm:()=>{Re(ne=>({...ne,isOpen:!1})),U.mutate(F)}})},Z=vt({mutationFn:()=>_e.createTemplateFromProject(p),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:F=>r(F.message,"error")}),oe=F=>new Date(F).toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(v)return o.jsx("div",{className:"flex items-center justify-center py-24",children:o.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(y||!x)return o.jsxs("div",{className:"text-center py-24",children:[o.jsx("p",{className:"text-bambu-gray",children:y?`Error: ${y.message}`:"Project not found"}),o.jsx(ke,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const be=x.stats,Te=be?.progress_percent??0,Me=be&&be.total_items>0?(be.completed_prints/be.total_items*100).toFixed(0):null;return o.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[o.jsx(Sc,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),o.jsx(Ko,{className:"w-4 h-4"}),o.jsx("span",{className:"text-white",children:x.name})]}),o.jsxs("div",{className:"flex items-start justify-between",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:o.jsx(Noe,{className:"w-5 h-5 text-bambu-gray"})}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:x.color||"#6b7280"}}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:x.name}),x.description&&o.jsx("p",{className:"text-bambu-gray mt-1",children:x.description})]})]}),o.jsx(RWe,{status:x.status})]}),o.jsxs(ke,{onClick:()=>a(!0),children:[o.jsx(nf,{className:"w-4 h-4 mr-2"}),"Edit"]})]}),x.target_count&&o.jsx(Mt,{children:o.jsxs(At,{className:"p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("span",{className:"text-sm text-bambu-gray",children:"Progress"}),o.jsxs("span",{className:"text-sm font-medium text-white",children:[be?.completed_prints||0," / ",x.target_count," items"]})]}),o.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:o.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Te,100)}%`,backgroundColor:Te>=100?"#22c55e":x.color||"#6b7280"}})}),o.jsxs("div",{className:"flex justify-between mt-1",children:[o.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Te.toFixed(0),"% complete"]}),x.target_count-(be?.completed_prints||0)>0&&o.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[x.target_count-(be?.completed_prints||0)," remaining"]})]})]})}),be&&o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsx(u1,{icon:zc,label:"Total Items",value:be.total_items,subValue:`${be.total_archives} print job${be.total_archives!==1?"s":""}`,color:"text-bambu-green"}),o.jsx(u1,{icon:kr,label:"Completed",value:be.completed_prints,subValue:be.failed_prints>0?`${be.failed_prints} failed`:Me?`${Me}% success`:void 0,color:"text-blue-400"}),o.jsx(u1,{icon:ur,label:"Print Time",value:PWe(be.total_print_time_hours),color:"text-yellow-400"}),o.jsx(u1,{icon:Gi,label:"Filament Used",value:jWe(be.total_filament_grams),color:"text-purple-400"})]}),be&&(be.estimated_cost>0||x.budget)&&o.jsx(Mt,{children:o.jsxs(At,{className:"p-4",children:[o.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:"Cost Tracking"}),o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Filament Cost"}),o.jsxs("p",{className:"text-lg font-semibold text-white",children:[O,be.estimated_cost.toFixed(2)]})]}),be.total_energy_kwh>0&&o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Energy"}),o.jsxs("p",{className:"text-lg font-semibold text-white",children:[be.total_energy_kwh.toFixed(2)," kWh",be.total_energy_cost>0&&o.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",O,be.total_energy_cost.toFixed(2),")"]})]})]}),x.budget&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Budget"}),o.jsxs("p",{className:"text-lg font-semibold text-white",children:[O,x.budget.toFixed(2)]})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Remaining"}),o.jsxs("p",{className:`text-lg font-semibold ${x.budget-be.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[O,(x.budget-be.estimated_cost).toFixed(2)]})]})]})]})]})}),x.children&&x.children.length>0&&o.jsx(Mt,{children:o.jsxs(At,{className:"p-4",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[o.jsx(Zle,{className:"w-5 h-5"}),"Sub-projects (",x.children.length,")"]}),o.jsx("div",{className:"space-y-2",children:x.children.map(F=>o.jsxs(Sc,{to:`/projects/${F.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:F.color||"#6b7280"}}),o.jsx("span",{className:"text-white",children:F.name}),o.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${F.status==="completed"?"bg-bambu-green/20 text-bambu-green":F.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:F.status})]}),F.progress_percent!==null&&o.jsxs("span",{className:"text-sm text-bambu-gray",children:[F.progress_percent.toFixed(0),"%"]})]},F.id))})]})}),x.parent_id&&x.parent_name&&o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx(gd,{className:"w-4 h-4 text-bambu-gray"}),o.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),o.jsx(Sc,{to:`/projects/${x.parent_id}`,className:"text-bambu-green hover:underline",children:x.parent_name})]}),(x.tags||x.due_date||x.priority!=="normal")&&o.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[x.priority&&x.priority!=="normal"&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:"Priority:"}),o.jsx(OWe,{priority:x.priority})]}),x.due_date&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Jr,{className:"w-4 h-4 text-bambu-gray"}),o.jsx("span",{className:"text-sm text-white",children:LWe(x.due_date)}),Ok(x.due_date)&&o.jsxs("span",{className:`text-xs ${Ok(x.due_date).color}`,children:["(",Ok(x.due_date).label,")"]})]}),x.tags&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Cp,{className:"w-4 h-4 text-bambu-gray"}),o.jsx("div",{className:"flex flex-wrap gap-1",children:x.tags.split(",").map((F,I)=>o.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:F.trim()},I))})]})]}),o.jsx(Mt,{children:o.jsxs(At,{className:"p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(As,{className:"w-5 h-5"}),"Notes"]}),s?o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(ke,{variant:"secondary",size:"sm",onClick:L,disabled:k.isPending,children:[o.jsx(Wt,{className:"w-4 h-4 mr-1"}),"Cancel"]}),o.jsxs(ke,{size:"sm",onClick:B,disabled:k.isPending,children:[k.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin mr-1"}):o.jsx(Ts,{className:"w-4 h-4 mr-1"}),"Save"]})]}):o.jsxs(ke,{variant:"secondary",size:"sm",onClick:j,children:[o.jsx(nf,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),s?o.jsx(Hj,{content:c,onChange:u,placeholder:"Add notes about this project..."}):x.notes?o.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:x.notes}}):o.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No notes yet. Click Edit to add notes."})]})}),o.jsx(Mt,{children:o.jsxs(At,{className:"p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(sue,{className:"w-5 h-5"}),"Attachments (",x.attachments?.length||0,")"]}),o.jsxs("div",{children:[o.jsx("input",{ref:g,type:"file",onChange:K,className:"hidden"}),o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>g.current?.click(),disabled:d,children:[d?o.jsx(pt,{className:"w-4 h-4 animate-spin mr-1"}):o.jsx(ca,{className:"w-4 h-4 mr-1"}),"Upload"]})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Upload any file: images (PNG, JPG), PDFs, STL files, or documents."}),x.attachments&&x.attachments.length>0?o.jsx("div",{className:"space-y-2",children:x.attachments.map(F=>o.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx(dR,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-sm text-white truncate",children:F.original_name}),o.jsx("p",{className:"text-xs text-bambu-gray",children:q(F.size)})]})]}),o.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[o.jsx("a",{href:_e.getProjectAttachmentUrl(p,F.filename),download:F.original_name,className:"p-2 rounded hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",title:"Download",children:o.jsx(as,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>R(F.filename,F.original_name),className:"p-2 rounded hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-red-400",title:"Delete",children:o.jsx(Nn,{className:"w-4 h-4"})})]})]},F.filename))}):o.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No attachments yet. Click Upload to add files."})]})}),o.jsx(Mt,{children:o.jsxs(At,{className:"p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(H9,{className:"w-5 h-5"}),"Bill of Materials",be&&be.bom_total_items>0&&o.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",be.bom_completed_items,"/",be.bom_total_items," acquired)"]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[w&&w.some(F=>F.is_complete)&&o.jsx("button",{onClick:()=>pe(!Ee),className:`text-xs px-2 py-1 rounded transition-colors ${Ee?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:Ee?"Show all":"Hide done"}),!le&&o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>ge(!0),children:[o.jsx(fr,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),le&&o.jsxs("form",{onSubmit:H,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[o.jsx("input",{type:"text",value:W,onChange:F=>$(F.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Part name (e.g., M3x8 screws)",autoFocus:!0}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"number",value:J,onChange:F=>ee(parseInt(F.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:"Qty"}),o.jsx("input",{type:"number",step:"0.01",value:Q,onChange:F=>z(F.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:`Price (${O})`})]})]}),o.jsx("input",{type:"url",value:V,onChange:F=>X(F.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Sourcing URL (optional)"}),o.jsx("input",{type:"text",value:te,onChange:F=>ie(F.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Remarks (optional)"}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(ke,{type:"button",variant:"secondary",size:"sm",onClick:()=>ge(!1),children:"Cancel"}),o.jsx(ke,{type:"submit",size:"sm",disabled:!W.trim()||fe.isPending,children:fe.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin"}):"Add Part"})]})]}),A?o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):w&&w.length>0?o.jsxs("div",{className:"space-y-2",children:[w.filter(F=>!Ee||!F.is_complete).map(F=>o.jsx("div",{className:`p-3 rounded-lg transition-colors ${F.is_complete?"bg-bambu-green/10":"bg-bambu-dark"}`,children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("button",{onClick:()=>re(F),disabled:Fe.isPending,className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${F.is_complete?"bg-bambu-green border-bambu-green text-white":"border-bambu-gray hover:border-bambu-green"}`,children:F.is_complete&&o.jsx(kr,{className:"w-3 h-3"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsxs("p",{className:`text-sm font-medium ${F.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[F.name,o.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",F.quantity_needed]})]}),F.unit_price!==null&&o.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[O,(F.unit_price*F.quantity_needed).toFixed(2)]})]}),o.jsx("button",{onClick:()=>G(F.id,F.name),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400 transition-colors flex-shrink-0",title:"Delete",children:o.jsx(Nn,{className:"w-4 h-4"})})]}),F.sourcing_url&&o.jsxs("a",{href:F.sourcing_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-1 text-xs text-blue-400 hover:text-blue-300 transition-colors",onClick:I=>I.stopPropagation(),children:[o.jsx(la,{className:"w-3 h-3 flex-shrink-0"}),o.jsx("span",{className:"truncate",children:(()=>{try{return new URL(F.sourcing_url).hostname.replace("www.","")}catch{return F.sourcing_url}})()})]}),F.remarks&&o.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:F.remarks})]})]})},F.id)),w.some(F=>F.unit_price!==null)&&o.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[o.jsx("span",{className:"text-bambu-gray",children:"Total cost:"}),o.jsxs("span",{className:"text-white font-medium",children:[O,w.reduce((F,I)=>F+(I.unit_price||0)*I.quantity_needed,0).toFixed(2)]})]})]}):o.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No parts in the bill of materials. Add hardware, electronics, or other components to track what needs to be sourced."})]})}),o.jsx(Mt,{children:o.jsxs(At,{className:"p-4",children:[o.jsx("div",{className:"flex items-center justify-between mb-3",children:o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(H1,{className:"w-5 h-5"}),"Activity Timeline"]})}),C?o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):T&&T.length>0?o.jsx("div",{className:"space-y-3",children:T.slice(0,10).map((F,I)=>o.jsxs("div",{className:"flex gap-3",children:[o.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${F.event_type==="print_completed"?"bg-bambu-green/20 text-bambu-green":F.event_type==="print_failed"?"bg-red-500/20 text-red-400":F.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[F.event_type==="print_completed"&&o.jsx(kr,{className:"w-4 h-4"}),F.event_type==="print_failed"&&o.jsx(Pa,{className:"w-4 h-4"}),F.event_type==="print_started"&&o.jsx(Gi,{className:"w-4 h-4"}),F.event_type==="queued"&&o.jsx(Jk,{className:"w-4 h-4"}),F.event_type==="project_created"&&o.jsx(fr,{className:"w-4 h-4"})]}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm text-white",children:F.title}),F.description&&o.jsx("p",{className:"text-xs text-bambu-gray truncate",children:F.description}),o.jsx("p",{className:"text-xs text-bambu-gray/70",children:oe(F.timestamp)})]})]},I))}):o.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No activity yet."})]})}),!x.is_template&&o.jsx("div",{className:"flex justify-end",children:o.jsxs(ke,{variant:"secondary",size:"sm",onClick:()=>Z.mutate(),disabled:Z.isPending,children:[Z.isPending?o.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(vl,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),be&&(be.queued_prints>0||be.in_progress_prints>0)&&o.jsx(Mt,{children:o.jsxs(At,{className:"p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(Jk,{className:"w-5 h-5"}),"Queue"]}),o.jsx(Sc,{to:`/queue?project=${p}`,className:"text-sm text-bambu-green hover:underline",children:"View all"})]}),o.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[be.in_progress_prints>0&&o.jsxs("span",{className:"text-yellow-400",children:[be.in_progress_prints," printing"]}),be.queued_prints>0&&o.jsxs("span",{className:"text-bambu-gray",children:[be.queued_prints," queued"]})]})]})}),o.jsxs("div",{children:[o.jsx("div",{className:"flex items-center justify-between mb-4",children:o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(zc,{className:"w-5 h-5"}),"Prints (",b?.length||0,")"]})}),E?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):o.jsx(DWe,{archives:b||[]})]}),i&&o.jsx(Xte,{project:{...x,archive_count:be?.total_archives||0,total_items:be?.total_items||0,queue_count:be?.queued_prints||0,progress_percent:be?.progress_percent||null,archives:[]},onClose:()=>a(!1),onSave:F=>k.mutate(F),isLoading:k.isPending}),de.isOpen&&o.jsx(br,{title:de.title,message:de.message,confirmText:"Delete",variant:"danger",onConfirm:de.onConfirm,onCancel:()=>Re(F=>({...F,isOpen:!1}))})]})}const Lk=5,FWe=2e3,UWe=3e4;function zWe(){const{printerId:t}=Jj(),e=parseInt(t||"0",10),[n,r]=S.useState("stream"),[i,a]=S.useState(!1),[s,l]=S.useState(!0),[c,u]=S.useState(Date.now()),[d,f]=S.useState(!1),[g,p]=S.useState(!1),[x,v]=S.useState(0),[y,b]=S.useState(!1),[E,w]=S.useState(0),A=S.useRef(null),T=S.useRef(null),C=S.useRef(null),N=S.useRef(null),{data:O}=gt({queryKey:["printer",e],queryFn:()=>_e.getPrinter(e),enabled:e>0});S.useEffect(()=>(O&&(document.title=`${O.name} - Camera`),()=>{document.title="Bambuddy"}),[O]),S.useEffect(()=>{const J=`/api/v1/printers/${e}/camera/stop`,ee=()=>{e>0&&navigator.sendBeacon(J)},Q=()=>{document.visibilityState==="hidden"&&e>0&&navigator.sendBeacon(J)};return window.addEventListener("beforeunload",ee),document.addEventListener("visibilitychange",Q),()=>{window.removeEventListener("beforeunload",ee),document.removeEventListener("visibilitychange",Q),A.current&&(A.current.src=""),e>0&&navigator.sendBeacon(J)}},[e]),S.useEffect(()=>{if(s&&!d){const ee=setTimeout(()=>{l(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(ee)}},[n,s,c,d]),S.useEffect(()=>{const J=()=>{p(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",J),()=>document.removeEventListener("fullscreenchange",J)},[]),S.useEffect(()=>{if(!window.opener)return;let J;const ee=()=>{clearTimeout(J),J=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};window.addEventListener("resize",ee);const Q=setInterval(()=>{const z=localStorage.getItem("cameraWindowState");if(z){const V=JSON.parse(z);(V.left!==window.screenX||V.top!==window.screenY)&&ee()}},1e3);return()=>{clearTimeout(J),clearInterval(Q),window.removeEventListener("resize",ee)}},[]),S.useEffect(()=>()=>{C.current&&clearTimeout(C.current),N.current&&clearInterval(N.current)},[]);const k=S.useCallback(()=>{if(x>=Lk){b(!1),a(!0);return}const J=Math.min(FWe*Math.pow(2,x),UWe);b(!0),w(Math.ceil(J/1e3)),N.current=setInterval(()=>{w(ee=>ee<=1?(N.current&&clearInterval(N.current),0):ee-1)},1e3),C.current=setTimeout(()=>{v(ee=>ee+1),b(!1),l(!0),a(!1),A.current&&(A.current.src=""),u(Date.now())},J)},[x]),j=()=>{l(!1),n==="stream"&&x<Lk?k():a(!0)},B=()=>{if(l(!1),a(!1),v(0),b(!1),C.current&&clearTimeout(C.current),N.current&&clearInterval(N.current),window.opener&&A.current&&!localStorage.getItem("cameraWindowState")){const J=A.current,ee=J.naturalWidth,Q=J.naturalHeight;if(ee>0&&Q>0){const X=window.outerWidth-window.innerWidth,te=window.outerHeight-window.innerHeight,ie=ee+16+X,le=Q+45+16+te;window.resizeTo(ie,le)}}},L=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},K=J=>{n===J||d||(f(!0),l(!0),a(!1),v(0),b(!1),C.current&&clearTimeout(C.current),N.current&&clearInterval(N.current),A.current&&(A.current.src=""),n==="stream"&&L(),setTimeout(()=>{r(J),u(Date.now()),f(!1)},100))},R=()=>{d||(f(!0),l(!0),a(!1),v(0),b(!1),C.current&&clearTimeout(C.current),N.current&&clearInterval(N.current),A.current&&(A.current.src=""),n==="stream"&&L(),setTimeout(()=>{u(Date.now()),f(!1)},100))},q=()=>{T.current&&(document.fullscreenElement?document.exitFullscreen():T.current.requestFullscreen())},W=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,$=s||d||y;return e?o.jsxs("div",{ref:T,className:"min-h-screen bg-black flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[o.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[o.jsx(R0,{className:"w-4 h-4"}),O?.name||`Printer ${e}`]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[o.jsx("button",{onClick:()=>K("stream"),disabled:$,className:`px-3 py-1 text-xs rounded transition-colors ${n==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Live"}),o.jsx("button",{onClick:()=>K("snapshot"),disabled:$,className:`px-3 py-1 text-xs rounded transition-colors ${n==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Snapshot"})]}),o.jsx("button",{onClick:R,disabled:$,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:o.jsx(li,{className:`w-4 h-4 text-bambu-gray ${$?"animate-spin":""}`})}),o.jsx("button",{onClick:q,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:g?"Exit fullscreen":"Fullscreen",children:g?o.jsx(Zce,{className:"w-4 h-4 text-bambu-gray"}):o.jsx($ce,{className:"w-4 h-4 text-bambu-gray"})})]})]}),o.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:o.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(s||d)&&!y&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:o.jsxs("div",{className:"text-center",children:[o.jsx(li,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),o.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),y&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:o.jsxs("div",{className:"text-center p-4",children:[o.jsx(kb,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),o.jsx("p",{className:"text-white mb-2",children:"Connection lost"}),o.jsxs("p",{className:"text-sm text-bambu-gray mb-3",children:["Reconnecting in ",E,"s... (attempt ",x+1,"/",Lk,")"]}),o.jsx("button",{onClick:R,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:"Reconnect now"})]})}),i&&!y&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:o.jsxs("div",{className:"text-center p-4",children:[o.jsx(Gn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),o.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),o.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),o.jsx("button",{onClick:R,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),o.jsx("img",{ref:A,src:W,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:W?j:void 0,onLoad:W?B:void 0},c)]})})]}):o.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:o.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function BWe(){const{id:t}=Jj(),{mode:e}=og(),{data:n,isLoading:r,error:i}=gt({queryKey:["external-link",t],queryFn:()=>_e.getExternalLink(Number(t)),enabled:!!t});return r?o.jsx("div",{className:"flex items-center justify-center h-full",children:o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i||!n?o.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[o.jsx(Gn,{className:"w-12 h-12"}),o.jsx("p",{children:"Link not found"})]}):o.jsx("iframe",{src:n.url,className:"h-full w-full border-0",style:{colorScheme:e},title:n.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}function Yr({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return o.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[o.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:o.jsx(t,{className:"w-5 h-5"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:e}),o.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&o.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function QG({percent:t,color:e="bg-bambu-green"}){return o.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:o.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function hh({title:t,icon:e,children:n}){return o.jsxs(Mt,{className:"p-6",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[o.jsx(e,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function HWe(){const{t}=ng(),{data:e,isLoading:n,refetch:r,isFetching:i}=gt({queryKey:["systemInfo"],queryFn:_e.getSystemInfo,refetchInterval:3e4});if(n)return o.jsx("div",{className:"flex items-center justify-center h-64",children:o.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!e)return o.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const a=e.storage.disk_percent_used>90?"bg-red-500":e.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",s=e.memory.percent_used>90?"bg-red-500":e.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return o.jsxs("div",{className:"p-6 space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),o.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),o.jsxs("button",{onClick:()=>r(),disabled:i,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[o.jsx(li,{className:`w-4 h-4 ${i?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),o.jsx(hh,{title:t("system.application","Application"),icon:fh,children:o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[o.jsx(Yr,{icon:fh,label:t("system.version","Version"),value:`v${e.app.version}`}),o.jsx(Yr,{icon:ur,label:t("system.uptime","System Uptime"),value:e.system.uptime_formatted}),o.jsx(Yr,{icon:fh,label:t("system.hostname","Hostname"),value:e.system.hostname})]})}),o.jsxs(hh,{title:t("system.database","Database"),icon:Ep,children:[o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[o.jsx(Yr,{icon:lo,label:t("system.totalArchives","Total Archives"),value:e.database.archives}),o.jsx(Yr,{icon:lR,label:t("system.completed","Completed"),value:e.database.archives_completed,color:"text-green-500"}),o.jsx(Yr,{icon:Pa,label:t("system.failed","Failed"),value:e.database.archives_failed,color:"text-red-500"}),o.jsx(Yr,{icon:pt,label:t("system.printing","Printing"),value:e.database.archives_printing,color:"text-yellow-500"})]}),o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsx(Yr,{icon:Gi,label:t("system.printers","Printers"),value:e.database.printers}),o.jsx(Yr,{icon:pR,label:t("system.filaments","Filaments"),value:e.database.filaments}),o.jsx(Yr,{icon:Bo,label:t("system.projects","Projects"),value:e.database.projects}),o.jsx(Yr,{icon:co,label:t("system.smartPlugs","Smart Plugs"),value:e.database.smart_plugs})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[o.jsx(Yr,{icon:ur,label:t("system.totalPrintTime","Total Print Time"),value:e.database.total_print_time_formatted}),o.jsx(Yr,{icon:lo,label:t("system.totalFilament","Total Filament Used"),value:`${e.database.total_filament_kg} kg`,subValue:`${e.database.total_filament_grams.toLocaleString()} g`})]})]}),o.jsxs(hh,{title:t("system.connectedPrinters","Connected Printers"),icon:Gi,children:[o.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[o.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:e.printers.connected}),o.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:e.printers.total})})]}),e.printers.connected_list.length>0?o.jsx("div",{className:"space-y-2",children:e.printers.connected_list.map(l=>o.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),o.jsx("span",{className:"font-medium text-white",children:l.name})]}),o.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[o.jsx("span",{children:l.model}),o.jsx("span",{className:`px-2 py-0.5 rounded ${l.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":l.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:l.state})]})]},l.id))}):o.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),o.jsx(hh,{title:t("system.storage","Storage"),icon:fR,children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[o.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),o.jsxs("span",{className:"text-white",children:[e.storage.disk_used_formatted," / ",e.storage.disk_total_formatted]})]}),o.jsx(QG,{percent:e.storage.disk_percent_used,color:a}),o.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[e.storage.disk_free_formatted," ",t("system.free","free")," (",(100-e.storage.disk_percent_used).toFixed(1),"%)"]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsx(Yr,{icon:lo,label:t("system.archiveStorage","Archive Storage"),value:e.storage.archive_size_formatted}),o.jsx(Yr,{icon:Ep,label:t("system.databaseSize","Database Size"),value:e.storage.database_size_formatted})]})]})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsx(hh,{title:t("system.memory","Memory"),icon:Gce,children:o.jsx("div",{className:"space-y-4",children:o.jsxs("div",{children:[o.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[o.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),o.jsxs("span",{className:"text-white",children:[e.memory.used_formatted," / ",e.memory.total_formatted]})]}),o.jsx(QG,{percent:e.memory.percent_used,color:s}),o.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[e.memory.available_formatted," ",t("system.available","available")]})]})})}),o.jsx(hh,{title:t("system.cpu","CPU"),icon:Cv,children:o.jsx("div",{className:"space-y-4",children:o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsx(Yr,{icon:Cv,label:t("system.cores","Cores"),value:e.cpu.count,subValue:`${e.cpu.count_logical} logical`}),o.jsx(Yr,{icon:Cv,label:t("system.usage","Usage"),value:`${e.cpu.percent}%`})]})})})]}),o.jsx(hh,{title:t("system.systemDetails","System Details"),icon:fh,children:o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsx(Yr,{icon:fh,label:t("system.os","Operating System"),value:e.system.platform,subValue:e.system.platform_release}),o.jsx(Yr,{icon:Cv,label:t("system.architecture","Architecture"),value:e.system.architecture}),o.jsx(Yr,{icon:fh,label:t("system.python","Python"),value:e.system.python_version}),o.jsx(Yr,{icon:ur,label:t("system.bootTime","Boot Time"),value:new Date(e.system.boot_time).toLocaleString()})]})})]})}function $We(){const t=S.useRef(null),e=S.useRef(null),n=pn(),[r,i]=S.useState(!1),a=S.useRef(new Set),s=S.useRef(null),l=S.useRef(new Map),c=S.useRef(null),u=S.useRef([]),d=S.useRef(!1),f=S.useRef(()=>{}),g=S.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const E=()=>{const w=u.current.shift();w?requestAnimationFrame(()=>{f.current(w),u.current.length>0?setTimeout(E,16):d.current=!1}):d.current=!1};E()},[]),p=S.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const w=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,A=new WebSocket(w);let T=null;A.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),T=window.setInterval(()=>{A.readyState===WebSocket.OPEN&&A.send(JSON.stringify({type:"ping"}))},3e4)},A.onmessage=C=>{try{const N=JSON.parse(C.data);N.type==="printer_status"&&N.printer_id!==void 0&&N.data?f.current(N):(u.current.push(N),g())}catch{}},A.onclose=C=>{console.log("[WebSocket] Closed",C.code,C.reason),T&&(clearInterval(T),T=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{p()},3e3)},A.onerror=C=>{console.error("[WebSocket] Error",C),A.close()},t.current=A},[]),x=S.useCallback((E,w)=>{const A=l.current.get(E)||{};l.current.set(E,{...A,...w}),c.current||(c.current=window.setTimeout(()=>{const T=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{T.forEach((C,N)=>{n.setQueryData(["printerStatus",N],O=>{const k={...O,...C};return k.wifi_signal==null&&O?.wifi_signal!=null&&(k.wifi_signal=O.wifi_signal),k})})})},100))},[n]),v=S.useCallback(E=>{a.current.add(E),s.current&&clearTimeout(s.current),s.current=window.setTimeout(()=>{const w=Array.from(a.current);a.current.clear(),s.current=null;let A=0;w.forEach(T=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[T]})})},A),A+=500})},3e3)},[n]),y=S.useCallback(E=>{switch(E.type){case"printer_status":E.printer_id!==void 0&&E.data&&x(E.printer_id,E.data);break;case"print_start":E.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",E.printer_id]});break;case"print_complete":E.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",E.printer_id]}),v("archives"),v("archiveStats");break;case"archive_created":v("archives"),v("archiveStats");break;case"archive_updated":v("archives");break}},[n,v,x]);S.useEffect(()=>{f.current=y},[y]),S.useEffect(()=>(p(),()=>{e.current&&clearTimeout(e.current),s.current&&clearTimeout(s.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[p]);const b=S.useCallback(E=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(E))},[]);return{isConnected:r,sendMessage:b}}const VWe=new ooe({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function GWe({children:t}){return $We(),o.jsx(o.Fragment,{children:t})}function WWe(){return o.jsx(Dde,{children:o.jsx(Gde,{children:o.jsx(loe,{client:VWe,children:o.jsx(GWe,{children:o.jsx(Cse,{children:o.jsxs(sse,{children:[o.jsx(Ya,{path:"/camera/:printerId",element:o.jsx(zWe,{})}),o.jsxs(Ya,{path:"/",element:o.jsx(Hde,{}),children:[o.jsx(Ya,{index:!0,element:o.jsx(dCe,{})}),o.jsx(Ya,{path:"archives",element:o.jsx(G7e,{})}),o.jsx(Ya,{path:"queue",element:o.jsx(k9e,{})}),o.jsx(Ya,{path:"stats",element:o.jsx(V9e,{})}),o.jsx(Ya,{path:"profiles",element:o.jsx(MWe,{})}),o.jsx(Ya,{path:"maintenance",element:o.jsx(NWe,{})}),o.jsx(Ya,{path:"projects",element:o.jsx(kWe,{})}),o.jsx(Ya,{path:"projects/:id",element:o.jsx(IWe,{})}),o.jsx(Ya,{path:"settings",element:o.jsx(fWe,{})}),o.jsx(Ya,{path:"system",element:o.jsx(HWe,{})}),o.jsx(Ya,{path:"external/:id",element:o.jsx(BWe,{})})]})]})})})})})})}uie.createRoot(document.getElementById("root")).render(o.jsx(S.StrictMode,{children:o.jsx(WWe,{})}));
|