index-CLcf9MNg.js 3.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663
  1. function sie(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 vo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var IA={exports:{}},px={};var NF;function oie(){if(NF)return px;NF=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 CF;function lie(){return CF||(CF=1,IA.exports=oie()),IA.exports}var o=lie(),FA={exports:{}},ln={};var kF;function cie(){if(kF)return ln;kF=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(F){return F===null||typeof F!="object"?null:(F=g&&F[g]||F["@@iterator"],typeof F=="function"?F:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,x={};function y(F,V,ne){this.props=F,this.context=V,this.refs=x,this.updater=ne||b}y.prototype.isReactComponent={},y.prototype.setState=function(F,V){if(typeof F!="object"&&typeof F!="function"&&F!=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,F,V,"setState")},y.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function E(){}E.prototype=y.prototype;function w(F,V,ne){this.props=F,this.context=V,this.refs=x,this.updater=ne||b}var A=w.prototype=new E;A.constructor=w,v(A,y.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(F,V,ne){var le=ne.ref;return{$$typeof:t,type:F,key:V,ref:le!==void 0?le:null,props:ne}}function j(F,V){return k(F.type,V,F.props)}function z(F){return typeof F=="object"&&F!==null&&F.$$typeof===t}function I(F){var V={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(ne){return V[ne]})}var q=/\/+/g;function R(F,V){return typeof F=="object"&&F!==null&&F.key!=null?I(""+F.key):V.toString(36)}function W(F){switch(F.status){case"fulfilled":return F.value;case"rejected":throw F.reason;default:switch(typeof F.status=="string"?F.then(C,C):(F.status="pending",F.then(function(V){F.status==="pending"&&(F.status="fulfilled",F.value=V)},function(V){F.status==="pending"&&(F.status="rejected",F.reason=V)})),F.status){case"fulfilled":return F.value;case"rejected":throw F.reason}}throw F}function K(F,V,ne,le,oe){var pe=typeof F;(pe==="undefined"||pe==="boolean")&&(F=null);var Q=!1;if(F===null)Q=!0;else switch(pe){case"bigint":case"string":case"number":Q=!0;break;case"object":switch(F.$$typeof){case t:case e:Q=!0;break;case d:return Q=F._init,K(Q(F._payload),V,ne,le,oe)}}if(Q)return oe=oe(F),Q=le===""?"."+R(F,0):le,T(oe)?(ne="",Q!=null&&(ne=Q.replace(q,"$&/")+"/"),K(oe,V,ne,"",function(ue){return ue})):oe!=null&&(z(oe)&&(oe=j(oe,ne+(oe.key==null||F&&F.key===oe.key?"":(""+oe.key).replace(q,"$&/")+"/")+Q)),V.push(oe)),1;Q=0;var Ee=le===""?".":le+":";if(T(F))for(var he=0;he<F.length;he++)le=F[he],pe=Ee+R(le,he),Q+=K(le,V,ne,pe,oe);else if(he=p(F),typeof he=="function")for(F=he.call(F),he=0;!(le=F.next()).done;)le=le.value,pe=Ee+R(le,he++),Q+=K(le,V,ne,pe,oe);else if(pe==="object"){if(typeof F.then=="function")return K(W(F),V,ne,le,oe);throw V=String(F),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return Q}function G(F,V,ne){if(F==null)return F;var le=[],oe=0;return K(F,le,"","",function(pe){return V.call(ne,pe,oe++)}),le}function J(F){if(F._status===-1){var V=F._result;V=V(),V.then(function(ne){(F._status===0||F._status===-1)&&(F._status=1,F._result=ne)},function(ne){(F._status===0||F._status===-1)&&(F._status=2,F._result=ne)}),F._status===-1&&(F._status=0,F._result=V)}if(F._status===1)return F._result.default;throw F._result}var ee=typeof reportError=="function"?reportError:function(F){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof F=="object"&&F!==null&&typeof F.message=="string"?String(F.message):String(F),error:F});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",F);return}console.error(F)},Z={map:G,forEach:function(F,V,ne){G(F,function(){V.apply(this,arguments)},ne)},count:function(F){var V=0;return G(F,function(){V++}),V},toArray:function(F){return G(F,function(V){return V})||[]},only:function(F){if(!z(F))throw Error("React.Children.only expected to receive a single React element child.");return F}};return ln.Activity=f,ln.Children=Z,ln.Component=y,ln.Fragment=n,ln.Profiler=i,ln.PureComponent=w,ln.StrictMode=r,ln.Suspense=c,ln.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,ln.__COMPILER_RUNTIME={__proto__:null,c:function(F){return N.H.useMemoCache(F)}},ln.cache=function(F){return function(){return F.apply(null,arguments)}},ln.cacheSignal=function(){return null},ln.cloneElement=function(F,V,ne){if(F==null)throw Error("The argument must be a React element, but you passed "+F+".");var le=v({},F.props),oe=F.key;if(V!=null)for(pe in V.key!==void 0&&(oe=""+V.key),V)!O.call(V,pe)||pe==="key"||pe==="__self"||pe==="__source"||pe==="ref"&&V.ref===void 0||(le[pe]=V[pe]);var pe=arguments.length-2;if(pe===1)le.children=ne;else if(1<pe){for(var Q=Array(pe),Ee=0;Ee<pe;Ee++)Q[Ee]=arguments[Ee+2];le.children=Q}return k(F.type,oe,le)},ln.createContext=function(F){return F={$$typeof:s,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null},F.Provider=F,F.Consumer={$$typeof:a,_context:F},F},ln.createElement=function(F,V,ne){var le,oe={},pe=null;if(V!=null)for(le in V.key!==void 0&&(pe=""+V.key),V)O.call(V,le)&&le!=="key"&&le!=="__self"&&le!=="__source"&&(oe[le]=V[le]);var Q=arguments.length-2;if(Q===1)oe.children=ne;else if(1<Q){for(var Ee=Array(Q),he=0;he<Q;he++)Ee[he]=arguments[he+2];oe.children=Ee}if(F&&F.defaultProps)for(le in Q=F.defaultProps,Q)oe[le]===void 0&&(oe[le]=Q[le]);return k(F,pe,oe)},ln.createRef=function(){return{current:null}},ln.forwardRef=function(F){return{$$typeof:l,render:F}},ln.isValidElement=z,ln.lazy=function(F){return{$$typeof:d,_payload:{_status:-1,_result:F},_init:J}},ln.memo=function(F,V){return{$$typeof:u,type:F,compare:V===void 0?null:V}},ln.startTransition=function(F){var V=N.T,ne={};N.T=ne;try{var le=F(),oe=N.S;oe!==null&&oe(ne,le),typeof le=="object"&&le!==null&&typeof le.then=="function"&&le.then(C,ee)}catch(pe){ee(pe)}finally{V!==null&&ne.types!==null&&(V.types=ne.types),N.T=V}},ln.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},ln.use=function(F){return N.H.use(F)},ln.useActionState=function(F,V,ne){return N.H.useActionState(F,V,ne)},ln.useCallback=function(F,V){return N.H.useCallback(F,V)},ln.useContext=function(F){return N.H.useContext(F)},ln.useDebugValue=function(){},ln.useDeferredValue=function(F,V){return N.H.useDeferredValue(F,V)},ln.useEffect=function(F,V){return N.H.useEffect(F,V)},ln.useEffectEvent=function(F){return N.H.useEffectEvent(F)},ln.useId=function(){return N.H.useId()},ln.useImperativeHandle=function(F,V,ne){return N.H.useImperativeHandle(F,V,ne)},ln.useInsertionEffect=function(F,V){return N.H.useInsertionEffect(F,V)},ln.useLayoutEffect=function(F,V){return N.H.useLayoutEffect(F,V)},ln.useMemo=function(F,V){return N.H.useMemo(F,V)},ln.useOptimistic=function(F,V){return N.H.useOptimistic(F,V)},ln.useReducer=function(F,V,ne){return N.H.useReducer(F,V,ne)},ln.useRef=function(F){return N.H.useRef(F)},ln.useState=function(F){return N.H.useState(F)},ln.useSyncExternalStore=function(F,V,ne){return N.H.useSyncExternalStore(F,V,ne)},ln.useTransition=function(){return N.H.useTransition()},ln.version="19.2.0",ln}var PF;function tg(){return PF||(PF=1,FA.exports=cie()),FA.exports}var S=tg();const kr=vo(S),uie=sie({__proto__:null,default:kr},[S]);var UA={exports:{}},gx={},zA={exports:{}},BA={};var jF;function die(){return jF||(jF=1,(function(t){function e(K,G){var J=K.length;K.push(G);e:for(;0<J;){var ee=J-1>>>1,Z=K[ee];if(0<i(Z,G))K[ee]=G,K[J]=Z,J=ee;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var G=K[0],J=K.pop();if(J!==G){K[0]=J;e:for(var ee=0,Z=K.length,F=Z>>>1;ee<F;){var V=2*(ee+1)-1,ne=K[V],le=V+1,oe=K[le];if(0>i(ne,J))le<Z&&0>i(oe,ne)?(K[ee]=oe,K[le]=J,ee=le):(K[ee]=ne,K[V]=J,ee=V);else if(le<Z&&0>i(oe,J))K[ee]=oe,K[le]=J,ee=le;else break e}}return G}function i(K,G){var J=K.sortIndex-G.sortIndex;return J!==0?J:K.id-G.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,b=!1,v=!1,x=!1,y=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function A(K){for(var G=n(u);G!==null;){if(G.callback===null)r(u);else if(G.startTime<=K)r(u),G.sortIndex=G.expirationTime,e(c,G);else break;G=n(u)}}function T(K){if(v=!1,A(K),!b)if(n(c)!==null)b=!0,C||(C=!0,I());else{var G=n(u);G!==null&&W(T,G.startTime-K)}}var C=!1,N=-1,O=5,k=-1;function j(){return x?!0:!(t.unstable_now()-k<O)}function z(){if(x=!1,C){var K=t.unstable_now();k=K;var G=!0;try{e:{b=!1,v&&(v=!1,E(N),N=-1),p=!0;var J=g;try{t:{for(A(K),f=n(c);f!==null&&!(f.expirationTime>K&&j());){var ee=f.callback;if(typeof ee=="function"){f.callback=null,g=f.priorityLevel;var Z=ee(f.expirationTime<=K);if(K=t.unstable_now(),typeof Z=="function"){f.callback=Z,A(K),G=!0;break t}f===n(c)&&r(c),A(K)}else r(c);f=n(c)}if(f!==null)G=!0;else{var F=n(u);F!==null&&W(T,F.startTime-K),G=!1}}break e}finally{f=null,g=J,p=!1}G=void 0}}finally{G?I():C=!1}}}var I;if(typeof w=="function")I=function(){w(z)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,R=q.port2;q.port1.onmessage=z,I=function(){R.postMessage(null)}}else I=function(){y(z,0)};function W(K,G){N=y(function(){K(t.unstable_now())},G)}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(K){K.callback=null},t.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<K?Math.floor(1e3/K):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_next=function(K){switch(g){case 1:case 2:case 3:var G=3;break;default:G=g}var J=g;g=G;try{return K()}finally{g=J}},t.unstable_requestPaint=function(){x=!0},t.unstable_runWithPriority=function(K,G){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var J=g;g=K;try{return G()}finally{g=J}},t.unstable_scheduleCallback=function(K,G,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,K){case 1:var Z=-1;break;case 2:Z=250;break;case 5:Z=1073741823;break;case 4:Z=1e4;break;default:Z=5e3}return Z=J+Z,K={id:d++,callback:G,priorityLevel:K,startTime:J,expirationTime:Z,sortIndex:-1},J>ee?(K.sortIndex=J,e(u,K),n(c)===null&&K===n(u)&&(v?(E(N),N=-1):v=!0,W(T,J-ee))):(K.sortIndex=Z,e(c,K),b||p||(b=!0,C||(C=!0,I()))),K},t.unstable_shouldYield=j,t.unstable_wrapCallback=function(K){var G=g;return function(){var J=g;g=G;try{return K.apply(this,arguments)}finally{g=J}}}})(BA)),BA}var RF;function hie(){return RF||(RF=1,zA.exports=die()),zA.exports}var HA={exports:{}},ha={};var DF;function fie(){if(DF)return ha;DF=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 ha.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,ha.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)},ha.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()}},ha.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))},ha.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},ha.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})}},ha.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)},ha.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})}},ha.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)},ha.requestFormReset=function(c){r.d.r(c)},ha.unstable_batchedUpdates=function(c,u){return c(u)},ha.useFormState=function(c,u,d){return s.H.useFormState(c,u,d)},ha.useFormStatus=function(){return s.H.useHostTransitionStatus()},ha.version="19.2.0",ha}var OF;function n9(){if(OF)return HA.exports;OF=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(),HA.exports=fie(),HA.exports}var LF;function mie(){if(LF)return gx;LF=1;var t=hie(),e=tg(),n=n9();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 X=!1,de=P.child;de;){if(de===_){X=!0,_=P,M=D;break}if(de===M){X=!0,M=P,_=D;break}de=de.sibling}if(!X){for(de=D.child;de;){if(de===_){X=!0,_=D,M=P;break}if(de===M){X=!0,M=D,_=P;break}de=de.sibling}if(!X)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"),b=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),y=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"),z=Symbol.iterator;function I(h){return h===null||typeof h!="object"?null:(h=z&&h[z]||h["@@iterator"],typeof h=="function"?h:null)}var q=Symbol.for("react.client.reference");function R(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===q?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case v:return"Fragment";case y:return"Profiler";case x:return"StrictMode";case T:return"Suspense";case C:return"SuspenseList";case k:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case b: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 W=Array.isArray,K=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J={pending:!1,data:null,method:null,action:null},ee=[],Z=-1;function F(h){return{current:h}}function V(h){0>Z||(h.current=ee[Z],ee[Z]=null,Z--)}function ne(h,m){Z++,ee[Z]=h.current,h.current=m}var le=F(null),oe=F(null),pe=F(null),Q=F(null);function Ee(h,m){switch(ne(pe,m),ne(oe,h),ne(le,null),m.nodeType){case 9:case 11:h=(h=m.documentElement)&&(h=h.namespaceURI)?Z5(h):0;break;default:if(h=m.tagName,m=m.namespaceURI)m=Z5(m),h=Q5(m,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}V(le),ne(le,h)}function he(){V(le),V(oe),V(pe)}function ue(h){h.memoizedState!==null&&ne(Q,h);var m=le.current,_=Q5(m,h.type);m!==_&&(ne(oe,h),ne(le,_))}function Ae(h){oe.current===h&&(V(le),V(oe)),Q.current===h&&(V(Q),dx._currentValue=J)}var fe,at;function B(h){if(fe===void 0)try{throw Error()}catch(_){var m=_.stack.trim().match(/\n( *(at )?)/);fe=m&&m[1]||"",at=-1<_.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+fe+h+at}var $=!1;function ie(h,m){if(!h||$)return"";$=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var M={DetermineComponentFrameRoot:function(){try{if(m){var ht=function(){throw Error()};if(Object.defineProperty(ht.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ht,[])}catch(st){var tt=st}Reflect.construct(h,[],ht)}else{try{ht.call()}catch(st){tt=st}h.call(ht.prototype)}}else{try{throw Error()}catch(st){tt=st}(ht=h())&&typeof ht.catch=="function"&&ht.catch(function(){})}}catch(st){if(st&&tt&&typeof st.stack=="string")return[st.stack,tt.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(),X=D[0],de=D[1];if(X&&de){var ke=X.split(`
  4. `),Je=de.split(`
  5. `);for(P=M=0;M<ke.length&&!ke[M].includes("DetermineComponentFrameRoot");)M++;for(;P<Je.length&&!Je[P].includes("DetermineComponentFrameRoot");)P++;if(M===ke.length||P===Je.length)for(M=ke.length-1,P=Je.length-1;1<=M&&0<=P&&ke[M]!==Je[P];)P--;for(;1<=M&&0<=P;M--,P--)if(ke[M]!==Je[P]){if(M!==1||P!==1)do if(M--,P--,0>P||ke[M]!==Je[P]){var ut=`
  6. `+ke[M].replace(" at new "," at ");return h.displayName&&ut.includes("<anonymous>")&&(ut=ut.replace("<anonymous>",h.displayName)),ut}while(1<=M&&0<=P);break}}}finally{$=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?B(_):""}function H(h,m){switch(h.tag){case 26:case 27:case 5:return B(h.type);case 16:return B("Lazy");case 13:return h.child!==m&&m!==null?B("Suspense Fallback"):B("Suspense");case 19:return B("SuspenseList");case 0:case 15:return ie(h.type,!1);case 11:return ie(h.type.render,!1);case 1:return ie(h.type,!0);case 31:return B("Activity");default:return""}}function Y(h){try{var m="",_=null;do m+=H(h,_),_=h,h=h.return;while(h);return m}catch(M){return`
  7. Error generating stack: `+M.message+`
  8. `+M.stack}}var se=Object.prototype.hasOwnProperty,ve=t.unstable_scheduleCallback,Ne=t.unstable_cancelCallback,Se=t.unstable_shouldYield,U=t.unstable_requestPaint,L=t.unstable_now,te=t.unstable_getCurrentPriorityLevel,ye=t.unstable_ImmediatePriority,Me=t.unstable_UserBlockingPriority,be=t.unstable_NormalPriority,qe=t.unstable_LowPriority,Ve=t.unstable_IdlePriority,We=t.log,lt=t.unstable_setDisableYieldValue,me=null,ae=null;function He(h){if(typeof We=="function"&&lt(h),ae&&typeof ae.setStrictMode=="function")try{ae.setStrictMode(me,h)}catch{}}var Be=Math.clz32?Math.clz32:ge,Ye=Math.log,ot=Math.LN2;function ge(h){return h>>>=0,h===0?32:31-(Ye(h)/ot|0)|0}var nt=256,xe=262144,ze=4194304;function Re(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,X=h.pingedLanes;h=h.warmLanes;var de=M&134217727;return de!==0?(M=de&~D,M!==0?P=Re(M):(X&=de,X!==0?P=Re(X):_||(_=de&~h,_!==0&&(P=Re(_))))):(de=M&~D,de!==0?P=Re(de):X!==0?P=Re(X):_||(_=M&~h,_!==0&&(P=Re(_)))),P===0?0:m!==0&&m!==P&&(m&D)===0&&(D=P&-P,_=m&-m,D>=_||D===32&&(_&4194048)!==0)?m:P}function Ke(h,m){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&m)===0}function ft(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 Et(){var h=ze;return ze<<=1,(ze&62914560)===0&&(ze=4194304),h}function wt(h){for(var m=[],_=0;31>_;_++)m.push(h);return m}function Qt(h,m){h.pendingLanes|=m,m!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Ft(h,m,_,M,P,D){var X=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var de=h.entanglements,ke=h.expirationTimes,Je=h.hiddenUpdates;for(_=X&~_;0<_;){var ut=31-Be(_),ht=1<<ut;de[ut]=0,ke[ut]=-1;var tt=Je[ut];if(tt!==null)for(Je[ut]=null,ut=0;ut<tt.length;ut++){var st=tt[ut];st!==null&&(st.lane&=-536870913)}_&=~ht}M!==0&&hn(h,M,0),D!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=D&~(X&~m))}function hn(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 Hn(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 bt(h,m){var _=m&-m;return _=(_&42)!==0?1:Ht(_),(_&(h.suspendedLanes|m))!==0?0:_}function Ht(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 an(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function mt(){var h=G.p;return h!==0?h:(h=window.event,h===void 0?32:_F(h.type))}function Zt(h,m){var _=G.p;try{return G.p=h,m()}finally{G.p=_}}var sn=Math.random().toString(36).slice(2),Yt="__reactFiber$"+sn,_n="__reactProps$"+sn,wn="__reactContainer$"+sn,Ce="__reactEvents$"+sn,ce="__reactListeners$"+sn,Ue="__reactHandles$"+sn,Xe="__reactResources$"+sn,rt="__reactMarker$"+sn;function et(h){delete h[Yt],delete h[_n],delete h[Ce],delete h[ce],delete h[Ue]}function gt(h){var m=h[Yt];if(m)return m;for(var _=h.parentNode;_;){if(m=_[wn]||_[Yt]){if(_=m.alternate,m.child!==null||_!==null&&_.child!==null)for(h=aF(h);h!==null;){if(_=h[Yt])return _;h=aF(h)}return m}h=_,_=h.parentNode}return null}function re(h){if(h=h[Yt]||h[wn]){var m=h.tag;if(m===5||m===6||m===13||m===31||m===26||m===27||m===3)return h}return null}function Te(h){var m=h.tag;if(m===5||m===26||m===27||m===6)return h.stateNode;throw Error(r(33))}function Ie(h){var m=h[Xe];return m||(m=h[Xe]={hoistableStyles:new Map,hoistableScripts:new Map}),m}function De(h){h[rt]=!0}var je=new Set,ct={};function yt(h,m){Ct(h,m),Ct(h+"Capture",m)}function Ct(h,m){for(ct[h]=m,h=0;h<m.length;h++)je.add(m[h])}var Nt=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]*$"),Ut={},jt={};function St(h){return se.call(jt,h)?!0:se.call(Ut,h)?!1:Nt.test(h)?jt[h]=!0:(Ut[h]=!0,!1)}function tn(h,m,_){if(St(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 $t(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 mn(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 Sn(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function kn(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(X){_=""+X,D.call(this,X)}}),Object.defineProperty(h,m,{enumerable:M.enumerable}),{getValue:function(){return _},setValue:function(X){_=""+X},stopTracking:function(){h._valueTracker=null,delete h[m]}}}}function on(h){if(!h._valueTracker){var m=kn(h)?"checked":"value";h._valueTracker=Bt(h,m,""+h[m])}}function cn(h){if(!h)return!1;var m=h._valueTracker;if(!m)return!0;var _=m.getValue(),M="";return h&&(M=kn(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 Gn(h){return h.replace(qr,function(m){return"\\"+m.charCodeAt(0).toString(16)+" "})}function wo(h,m,_,M,P,D,X,de){h.name="",X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"?h.type=X:h.removeAttribute("type"),m!=null?X==="number"?(m===0&&h.value===""||h.value!=m)&&(h.value=""+Sn(m)):h.value!==""+Sn(m)&&(h.value=""+Sn(m)):X!=="submit"&&X!=="reset"||h.removeAttribute("value"),m!=null?ji(h,X,Sn(m)):_!=null?ji(h,X,Sn(_)):M!=null&&h.removeAttribute("value"),P==null&&D!=null&&(h.defaultChecked=!!D),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),de!=null&&typeof de!="function"&&typeof de!="symbol"&&typeof de!="boolean"?h.name=""+Sn(de):h.removeAttribute("name")}function Kn(h,m,_,M,P,D,X,de){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)){on(h);return}_=_!=null?""+Sn(_):"",m=m!=null?""+Sn(m):_,de||m===h.value||(h.value=m),h.defaultValue=m}M=M??P,M=typeof M!="function"&&typeof M!="symbol"&&!!M,h.checked=de?h.checked:!!M,h.defaultChecked=!!M,X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"&&(h.name=X),on(h)}function ji(h,m,_){m==="number"&&Ur(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function gi(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(_=""+Sn(_),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 Ri(h,m,_){if(m!=null&&(m=""+Sn(m),m!==h.value&&(h.value=m),_==null)){h.defaultValue!==m&&(h.defaultValue=m);return}h.defaultValue=_!=null?""+Sn(_):""}function Xi(h,m,_,M){if(m==null){if(M!=null){if(_!=null)throw Error(r(92));if(W(M)){if(1<M.length)throw Error(r(93));M=M[0]}_=M}_==null&&(_=""),m=_}_=Sn(m),h.defaultValue=_,M=h.textContent,M===_&&M!==""&&M!==null&&(h.value=M),on(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 KL(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 XL(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&&KL(h,P,M)}else for(var D in m)m.hasOwnProperty(D)&&KL(h,D,m[D])}function RE(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 nne=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"]]),rne=/^[\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 rne.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function Fl(){}var DE=null;function OE(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 YL(h){var m=re(h);if(m&&(h=m.stateNode)){var _=h[_n]||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="'+Gn(""+m)+'"][type="radio"]'),m=0;m<_.length;m++){var M=_[m];if(M!==h&&M.form===h.form){var P=M[_n]||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&&cn(M)}break e;case"textarea":Ri(h,_.value,_.defaultValue);break e;case"select":m=_.value,m!=null&&gi(h,!!_.multiple,m,!1)}}}var LE=!1;function ZL(h,m,_){if(LE)return h(m,_);LE=!0;try{var M=h(m);return M}finally{if(LE=!1,(Pf!==null||jf!==null)&&(rv(),Pf&&(m=Pf,h=jf,jf=Pf=null,YL(m),h)))for(m=0;m<h.length;m++)YL(h[m])}}function Ng(h,m){var _=h.stateNode;if(_===null)return null;var M=_[_n]||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"),IE=!1;if(Ul)try{var Cg={};Object.defineProperty(Cg,"passive",{get:function(){IE=!0}}),window.addEventListener("test",Cg,Cg),window.removeEventListener("test",Cg,Cg)}catch{IE=!1}var ru=null,FE=null,xy=null;function QL(){if(xy)return xy;var h,m=FE,_=m.length,M,P="value"in ru?ru.value:ru.textContent,D=P.length;for(h=0;h<_&&m[h]===P[h];h++);var X=_-h;for(M=1;M<=X&&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 JL(){return!1}function $a(h){function m(_,M,P,D,X){this._reactName=_,this._targetInst=P,this.type=M,this.nativeEvent=D,this.target=X,this.currentTarget=null;for(var de in h)h.hasOwnProperty(de)&&(_=h[de],this[de]=_?_(D):D[de]);return this.isDefaultPrevented=(D.defaultPrevented!=null?D.defaultPrevented:D.returnValue===!1)?yy:JL,this.isPropagationStopped=JL,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 Bd={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},vy=$a(Bd),kg=f({},Bd,{view:0,detail:0}),ine=$a(kg),UE,zE,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:HE,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"?(UE=h.screenX-Pg.screenX,zE=h.screenY-Pg.screenY):zE=UE=0,Pg=h),UE)},movementY:function(h){return"movementY"in h?h.movementY:zE}}),e4=$a(_y),ane=f({},_y,{dataTransfer:0}),sne=$a(ane),one=f({},kg,{relatedTarget:0}),BE=$a(one),lne=f({},Bd,{animationName:0,elapsedTime:0,pseudoElement:0}),cne=$a(lne),une=f({},Bd,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),dne=$a(une),hne=f({},Bd,{data:0}),t4=$a(hne),fne={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},mne={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"},pne={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function gne(h){var m=this.nativeEvent;return m.getModifierState?m.getModifierState(h):(h=pne[h])?!!m[h]:!1}function HE(){return gne}var xne=f({},kg,{key:function(h){if(h.key){var m=fne[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"?mne[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:HE,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}}),bne=$a(xne),yne=f({},_y,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),n4=$a(yne),vne=f({},kg,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:HE}),_ne=$a(vne),wne=f({},Bd,{propertyName:0,elapsedTime:0,pseudoElement:0}),Sne=$a(wne),Mne=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}),Ene=$a(Mne),Ane=f({},Bd,{newState:0,oldState:0}),Tne=$a(Ane),Nne=[9,13,27,32],$E=Ul&&"CompositionEvent"in window,jg=null;Ul&&"documentMode"in document&&(jg=document.documentMode);var Cne=Ul&&"TextEvent"in window&&!jg,r4=Ul&&(!$E||jg&&8<jg&&11>=jg),i4=" ",a4=!1;function s4(h,m){switch(h){case"keyup":return Nne.indexOf(m.keyCode)!==-1;case"keydown":return m.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function o4(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var Rf=!1;function kne(h,m){switch(h){case"compositionend":return o4(m);case"keypress":return m.which!==32?null:(a4=!0,i4);case"textInput":return h=m.data,h===i4&&a4?null:h;default:return null}}function Pne(h,m){if(Rf)return h==="compositionend"||!$E&&s4(h,m)?(h=QL(),xy=FE=ru=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 r4&&m.locale!=="ko"?null:m.data;default:return null}}var jne={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 l4(h){var m=h&&h.nodeName&&h.nodeName.toLowerCase();return m==="input"?!!jne[h.type]:m==="textarea"}function c4(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 Rne(h){G5(h,0)}function wy(h){var m=Te(h);if(cn(m))return h}function u4(h,m){if(h==="change")return m}var d4=!1;if(Ul){var VE;if(Ul){var GE="oninput"in document;if(!GE){var h4=document.createElement("div");h4.setAttribute("oninput","return;"),GE=typeof h4.oninput=="function"}VE=GE}else VE=!1;d4=VE&&(!document.documentMode||9<document.documentMode)}function f4(){Rg&&(Rg.detachEvent("onpropertychange",m4),Dg=Rg=null)}function m4(h){if(h.propertyName==="value"&&wy(Dg)){var m=[];c4(m,Dg,h,OE(h)),ZL(Rne,m)}}function Dne(h,m,_){h==="focusin"?(f4(),Rg=m,Dg=_,Rg.attachEvent("onpropertychange",m4)):h==="focusout"&&f4()}function One(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return wy(Dg)}function Lne(h,m){if(h==="click")return wy(m)}function Ine(h,m){if(h==="input"||h==="change")return wy(m)}function Fne(h,m){return h===m&&(h!==0||1/h===1/m)||h!==h&&m!==m}var ds=typeof Object.is=="function"?Object.is:Fne;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(!se.call(m,P)||!ds(h[P],m[P]))return!1}return!0}function p4(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function g4(h,m){var _=p4(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}_=p4(_)}}function x4(h,m){return h&&m?h===m?!0:h&&h.nodeType===3?!1:m&&m.nodeType===3?x4(h,m.parentNode):"contains"in h?h.contains(m):h.compareDocumentPosition?!!(h.compareDocumentPosition(m)&16):!1:!1}function b4(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 WE(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 Une=Ul&&"documentMode"in document&&11>=document.documentMode,Df=null,qE=null,Lg=null,KE=!1;function y4(h,m,_){var M=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;KE||Df==null||Df!==Ur(M)||(M=Df,"selectionStart"in M&&WE(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(qE,"onSelect"),0<M.length&&(m=new vy("onSelect","select",null,m,_),h.push({event:m,listeners:M}),m.target=Df)))}function Hd(h,m){var _={};return _[h.toLowerCase()]=m.toLowerCase(),_["Webkit"+h]="webkit"+m,_["Moz"+h]="moz"+m,_}var Of={animationend:Hd("Animation","AnimationEnd"),animationiteration:Hd("Animation","AnimationIteration"),animationstart:Hd("Animation","AnimationStart"),transitionrun:Hd("Transition","TransitionRun"),transitionstart:Hd("Transition","TransitionStart"),transitioncancel:Hd("Transition","TransitionCancel"),transitionend:Hd("Transition","TransitionEnd")},XE={},v4={};Ul&&(v4=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 $d(h){if(XE[h])return XE[h];if(!Of[h])return h;var m=Of[h],_;for(_ in m)if(m.hasOwnProperty(_)&&_ in v4)return XE[h]=m[_];return h}var _4=$d("animationend"),w4=$d("animationiteration"),S4=$d("animationstart"),zne=$d("transitionrun"),Bne=$d("transitionstart"),Hne=$d("transitioncancel"),M4=$d("transitionend"),E4=new Map,YE="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(" ");YE.push("scrollEnd");function So(h,m){E4.set(h,m),yt(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)},Ls=[],Lf=0,ZE=0;function My(){for(var h=Lf,m=ZE=Lf=0;m<h;){var _=Ls[m];Ls[m++]=null;var M=Ls[m];Ls[m++]=null;var P=Ls[m];Ls[m++]=null;var D=Ls[m];if(Ls[m++]=null,M!==null&&P!==null){var X=M.pending;X===null?P.next=P:(P.next=X.next,X.next=P),M.pending=P}D!==0&&A4(_,P,D)}}function Ey(h,m,_,M){Ls[Lf++]=h,Ls[Lf++]=m,Ls[Lf++]=_,Ls[Lf++]=M,ZE|=M,h.lanes|=M,h=h.alternate,h!==null&&(h.lanes|=M)}function QE(h,m,_,M){return Ey(h,m,_,M),Ay(h)}function Vd(h,m){return Ey(h,null,null,m),Ay(h)}function A4(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,oA=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 $ne(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 $ne(h,m,_,M)}function JE(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 T4(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 X=0;if(M=h,typeof h=="function")JE(h)&&(X=1);else if(typeof h=="string")X=Kre(h,_,le.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 Gd(_.children,P,D,m);case x:X=8,P|=24;break;case y:return h=hs(12,_,m,P|2),h.elementType=y,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:X=10;break e;case E:X=9;break e;case A:X=11;break e;case N:X=14;break e;case O:X=16,M=null;break e}X=29,_=Error(r(130,h===null?"null":typeof h,"")),M=null}return m=hs(X,_,m,P),m.elementType=h,m.type=M,m.lanes=D,m}function Gd(h,m,_,M){return h=hs(7,h,M,m),h.lanes=_,h}function e2(h,m,_){return h=hs(6,h,null,m),h.lanes=_,h}function N4(h){var m=hs(18,null,null,0);return m.stateNode=h,m}function t2(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 C4=new WeakMap;function Is(h,m){if(typeof h=="object"&&h!==null){var _=C4.get(h);return _!==void 0?_:(m={value:h,source:m,stack:Y(m)},C4.set(h,m),m)}return{value:h,source:m,stack:Y(m)}}var Ff=[],Uf=0,Ny=null,Ig=0,Fs=[],Us=0,iu=null,Qo=1,Jo="";function Bl(h,m){Ff[Uf++]=Ig,Ff[Uf++]=Ny,Ny=h,Ig=m}function k4(h,m,_){Fs[Us++]=Qo,Fs[Us++]=Jo,Fs[Us++]=iu,iu=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 X=P-P%5;D=(M&(1<<X)-1).toString(32),M>>=X,P-=X,Qo=1<<32-Be(m)+P|_<<P|M,Jo=D+h}else Qo=1<<D|_<<P|M,Jo=h}function n2(h){h.return!==null&&(Bl(h,1),k4(h,1,0))}function r2(h){for(;h===Ny;)Ny=Ff[--Uf],Ff[Uf]=null,Ig=Ff[--Uf],Ff[Uf]=null;for(;h===iu;)iu=Fs[--Us],Fs[Us]=null,Jo=Fs[--Us],Fs[Us]=null,Qo=Fs[--Us],Fs[Us]=null}function P4(h,m){Fs[Us++]=Qo,Fs[Us++]=Jo,Fs[Us++]=iu,Qo=m.id,Jo=m.overflow,iu=h}var Yi=null,_r=null,Dn=!1,au=null,zs=!1,i2=Error(r(519));function su(h){var m=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Fg(Is(m,h)),i2}function j4(h){var m=h.stateNode,_=h.type,M=h.memoizedProps;switch(m[Yt]=h,m[_n]=M,_){case"dialog":An("cancel",m),An("close",m);break;case"iframe":case"object":case"embed":An("load",m);break;case"video":case"audio":for(_=0;_<sx.length;_++)An(sx[_],m);break;case"source":An("error",m);break;case"img":case"image":case"link":An("error",m),An("load",m);break;case"details":An("toggle",m);break;case"input":An("invalid",m),Kn(m,M.value,M.defaultValue,M.checked,M.defaultChecked,M.type,M.name,!0);break;case"select":An("invalid",m);break;case"textarea":An("invalid",m),Xi(m,M.value,M.defaultValue,M.children)}_=M.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||m.textContent===""+_||M.suppressHydrationWarning===!0||X5(m.textContent,_)?(M.popover!=null&&(An("beforetoggle",m),An("toggle",m)),M.onScroll!=null&&An("scroll",m),M.onScrollEnd!=null&&An("scrollend",m),M.onClick!=null&&(m.onclick=Fl),m=!0):m=!1,m||su(h,!0)}function R4(h){for(Yi=h.return;Yi;)switch(Yi.tag){case 5:case 31:case 13:zs=!1;return;case 27:case 3:zs=!0;return;default:Yi=Yi.return}}function zf(h){if(h!==Yi)return!1;if(!Dn)return R4(h),Dn=!0,!1;var m=h.tag,_;if((_=m!==3&&m!==27)&&((_=m===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||wA(h.type,h.memoizedProps)),_=!_),_&&_r&&su(h),R4(h),m===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));_r=iF(h)}else if(m===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));_r=iF(h)}else m===27?(m=_r,vu(h.type)?(h=TA,TA=null,_r=h):_r=m):_r=Yi?Hs(h.stateNode.nextSibling):null;return!0}function Wd(){_r=Yi=null,Dn=!1}function a2(){var h=au;return h!==null&&(qa===null?qa=h:qa.push.apply(qa,h),au=null),h}function Fg(h){au===null?au=[h]:au.push(h)}var s2=F(null),qd=null,Hl=null;function ou(h,m,_){ne(s2,m._currentValue),m._currentValue=_}function $l(h){h._currentValue=s2.current,V(s2)}function o2(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 l2(h,m,_,M){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var D=P.dependencies;if(D!==null){var X=P.child;D=D.firstContext;e:for(;D!==null;){var de=D;D=P;for(var ke=0;ke<m.length;ke++)if(de.context===m[ke]){D.lanes|=_,de=D.alternate,de!==null&&(de.lanes|=_),o2(D.return,_,h),M||(X=null);break e}D=de.next}}else if(P.tag===18){if(X=P.return,X===null)throw Error(r(341));X.lanes|=_,D=X.alternate,D!==null&&(D.lanes|=_),o2(X,_,h),X=null}else X=P.child;if(X!==null)X.return=P;else for(X=P;X!==null;){if(X===h){X=null;break}if(P=X.sibling,P!==null){P.return=X.return,X=P;break}X=X.return}P=X}}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 X=P.alternate;if(X===null)throw Error(r(387));if(X=X.memoizedProps,X!==null){var de=P.type;ds(P.pendingProps.value,X.value)||(h!==null?h.push(de):h=[de])}}else if(P===Q.current){if(X=P.alternate,X===null)throw Error(r(387));X.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(dx):h=[dx])}P=P.return}h!==null&&l2(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 Kd(h){qd=h,Hl=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function Zi(h){return D4(qd,h)}function ky(h,m){return qd===null&&Kd(h),D4(h,m)}function D4(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 Vne=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 _()})}},Gne=t.unstable_scheduleCallback,Wne=t.unstable_NormalPriority,ti={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function c2(){return{controller:new Vne,data:new Map,refCount:0}}function Ug(h){h.refCount--,h.refCount===0&&Gne(Wne,function(){h.controller.abort()})}var zg=null,u2=0,Hf=0,$f=null;function qne(h,m){if(zg===null){var _=zg=[];u2=0,Hf=fA(),$f={status:"pending",value:void 0,then:function(M){_.push(M)}}}return u2++,m.then(O4,O4),m}function O4(){if(--u2===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 Kne(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 L4=K.S;K.S=function(h,m){y5=L(),typeof m=="object"&&m!==null&&typeof m.then=="function"&&qne(h,m),L4!==null&&L4(h,m)};var Xd=F(null);function d2(){var h=Xd.current;return h!==null?h:hr.pooledCache}function Py(h,m){m===null?ne(Xd,Xd.current):ne(Xd,m.pool)}function I4(){var h=d2();return h===null?null:{parent:ti._currentValue,pool:h}}var Vf=Error(r(460)),h2=Error(r(474)),jy=Error(r(542)),Ry={then:function(){}};function F4(h){return h=h.status,h==="fulfilled"||h==="rejected"}function U4(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,B4(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,B4(h),h}throw Zd=m,Vf}}function Yd(h){try{var m=h._init;return m(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Zd=_,Vf):_}}var Zd=null;function z4(){if(Zd===null)throw Error(r(459));var h=Zd;return Zd=null,h}function B4(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=[]),U4(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 H4(h){function m($e,Oe){if(h){var Qe=$e.deletions;Qe===null?($e.deletions=[Oe],$e.flags|=16):Qe.push(Oe)}}function _($e,Oe){if(!h)return null;for(;Oe!==null;)m($e,Oe),Oe=Oe.sibling;return null}function M($e){for(var Oe=new Map;$e!==null;)$e.key!==null?Oe.set($e.key,$e):Oe.set($e.index,$e),$e=$e.sibling;return Oe}function P($e,Oe){return $e=zl($e,Oe),$e.index=0,$e.sibling=null,$e}function D($e,Oe,Qe){return $e.index=Qe,h?(Qe=$e.alternate,Qe!==null?(Qe=Qe.index,Qe<Oe?($e.flags|=67108866,Oe):Qe):($e.flags|=67108866,Oe)):($e.flags|=1048576,Oe)}function X($e){return h&&$e.alternate===null&&($e.flags|=67108866),$e}function de($e,Oe,Qe,dt){return Oe===null||Oe.tag!==6?(Oe=e2(Qe,$e.mode,dt),Oe.return=$e,Oe):(Oe=P(Oe,Qe),Oe.return=$e,Oe)}function ke($e,Oe,Qe,dt){var Vt=Qe.type;return Vt===v?ut($e,Oe,Qe.props.children,dt,Qe.key):Oe!==null&&(Oe.elementType===Vt||typeof Vt=="object"&&Vt!==null&&Vt.$$typeof===O&&Yd(Vt)===Oe.type)?(Oe=P(Oe,Qe.props),Hg(Oe,Qe),Oe.return=$e,Oe):(Oe=Ty(Qe.type,Qe.key,Qe.props,null,$e.mode,dt),Hg(Oe,Qe),Oe.return=$e,Oe)}function Je($e,Oe,Qe,dt){return Oe===null||Oe.tag!==4||Oe.stateNode.containerInfo!==Qe.containerInfo||Oe.stateNode.implementation!==Qe.implementation?(Oe=t2(Qe,$e.mode,dt),Oe.return=$e,Oe):(Oe=P(Oe,Qe.children||[]),Oe.return=$e,Oe)}function ut($e,Oe,Qe,dt,Vt){return Oe===null||Oe.tag!==7?(Oe=Gd(Qe,$e.mode,dt,Vt),Oe.return=$e,Oe):(Oe=P(Oe,Qe),Oe.return=$e,Oe)}function ht($e,Oe,Qe){if(typeof Oe=="string"&&Oe!==""||typeof Oe=="number"||typeof Oe=="bigint")return Oe=e2(""+Oe,$e.mode,Qe),Oe.return=$e,Oe;if(typeof Oe=="object"&&Oe!==null){switch(Oe.$$typeof){case p:return Qe=Ty(Oe.type,Oe.key,Oe.props,null,$e.mode,Qe),Hg(Qe,Oe),Qe.return=$e,Qe;case b:return Oe=t2(Oe,$e.mode,Qe),Oe.return=$e,Oe;case O:return Oe=Yd(Oe),ht($e,Oe,Qe)}if(W(Oe)||I(Oe))return Oe=Gd(Oe,$e.mode,Qe,null),Oe.return=$e,Oe;if(typeof Oe.then=="function")return ht($e,Dy(Oe),Qe);if(Oe.$$typeof===w)return ht($e,ky($e,Oe),Qe);Oy($e,Oe)}return null}function tt($e,Oe,Qe,dt){var Vt=Oe!==null?Oe.key:null;if(typeof Qe=="string"&&Qe!==""||typeof Qe=="number"||typeof Qe=="bigint")return Vt!==null?null:de($e,Oe,""+Qe,dt);if(typeof Qe=="object"&&Qe!==null){switch(Qe.$$typeof){case p:return Qe.key===Vt?ke($e,Oe,Qe,dt):null;case b:return Qe.key===Vt?Je($e,Oe,Qe,dt):null;case O:return Qe=Yd(Qe),tt($e,Oe,Qe,dt)}if(W(Qe)||I(Qe))return Vt!==null?null:ut($e,Oe,Qe,dt,null);if(typeof Qe.then=="function")return tt($e,Oe,Dy(Qe),dt);if(Qe.$$typeof===w)return tt($e,Oe,ky($e,Qe),dt);Oy($e,Qe)}return null}function st($e,Oe,Qe,dt,Vt){if(typeof dt=="string"&&dt!==""||typeof dt=="number"||typeof dt=="bigint")return $e=$e.get(Qe)||null,de(Oe,$e,""+dt,Vt);if(typeof dt=="object"&&dt!==null){switch(dt.$$typeof){case p:return $e=$e.get(dt.key===null?Qe:dt.key)||null,ke(Oe,$e,dt,Vt);case b:return $e=$e.get(dt.key===null?Qe:dt.key)||null,Je(Oe,$e,dt,Vt);case O:return dt=Yd(dt),st($e,Oe,Qe,dt,Vt)}if(W(dt)||I(dt))return $e=$e.get(Qe)||null,ut(Oe,$e,dt,Vt,null);if(typeof dt.then=="function")return st($e,Oe,Qe,Dy(dt),Vt);if(dt.$$typeof===w)return st($e,Oe,Qe,ky(Oe,dt),Vt);Oy(Oe,dt)}return null}function It($e,Oe,Qe,dt){for(var Vt=null,Fn=null,zt=Oe,fn=Oe=0,jn=null;zt!==null&&fn<Qe.length;fn++){zt.index>fn?(jn=zt,zt=null):jn=zt.sibling;var Un=tt($e,zt,Qe[fn],dt);if(Un===null){zt===null&&(zt=jn);break}h&&zt&&Un.alternate===null&&m($e,zt),Oe=D(Un,Oe,fn),Fn===null?Vt=Un:Fn.sibling=Un,Fn=Un,zt=jn}if(fn===Qe.length)return _($e,zt),Dn&&Bl($e,fn),Vt;if(zt===null){for(;fn<Qe.length;fn++)zt=ht($e,Qe[fn],dt),zt!==null&&(Oe=D(zt,Oe,fn),Fn===null?Vt=zt:Fn.sibling=zt,Fn=zt);return Dn&&Bl($e,fn),Vt}for(zt=M(zt);fn<Qe.length;fn++)jn=st(zt,$e,fn,Qe[fn],dt),jn!==null&&(h&&jn.alternate!==null&&zt.delete(jn.key===null?fn:jn.key),Oe=D(jn,Oe,fn),Fn===null?Vt=jn:Fn.sibling=jn,Fn=jn);return h&&zt.forEach(function(Eu){return m($e,Eu)}),Dn&&Bl($e,fn),Vt}function Xt($e,Oe,Qe,dt){if(Qe==null)throw Error(r(151));for(var Vt=null,Fn=null,zt=Oe,fn=Oe=0,jn=null,Un=Qe.next();zt!==null&&!Un.done;fn++,Un=Qe.next()){zt.index>fn?(jn=zt,zt=null):jn=zt.sibling;var Eu=tt($e,zt,Un.value,dt);if(Eu===null){zt===null&&(zt=jn);break}h&&zt&&Eu.alternate===null&&m($e,zt),Oe=D(Eu,Oe,fn),Fn===null?Vt=Eu:Fn.sibling=Eu,Fn=Eu,zt=jn}if(Un.done)return _($e,zt),Dn&&Bl($e,fn),Vt;if(zt===null){for(;!Un.done;fn++,Un=Qe.next())Un=ht($e,Un.value,dt),Un!==null&&(Oe=D(Un,Oe,fn),Fn===null?Vt=Un:Fn.sibling=Un,Fn=Un);return Dn&&Bl($e,fn),Vt}for(zt=M(zt);!Un.done;fn++,Un=Qe.next())Un=st(zt,$e,fn,Un.value,dt),Un!==null&&(h&&Un.alternate!==null&&zt.delete(Un.key===null?fn:Un.key),Oe=D(Un,Oe,fn),Fn===null?Vt=Un:Fn.sibling=Un,Fn=Un);return h&&zt.forEach(function(aie){return m($e,aie)}),Dn&&Bl($e,fn),Vt}function rr($e,Oe,Qe,dt){if(typeof Qe=="object"&&Qe!==null&&Qe.type===v&&Qe.key===null&&(Qe=Qe.props.children),typeof Qe=="object"&&Qe!==null){switch(Qe.$$typeof){case p:e:{for(var Vt=Qe.key;Oe!==null;){if(Oe.key===Vt){if(Vt=Qe.type,Vt===v){if(Oe.tag===7){_($e,Oe.sibling),dt=P(Oe,Qe.props.children),dt.return=$e,$e=dt;break e}}else if(Oe.elementType===Vt||typeof Vt=="object"&&Vt!==null&&Vt.$$typeof===O&&Yd(Vt)===Oe.type){_($e,Oe.sibling),dt=P(Oe,Qe.props),Hg(dt,Qe),dt.return=$e,$e=dt;break e}_($e,Oe);break}else m($e,Oe);Oe=Oe.sibling}Qe.type===v?(dt=Gd(Qe.props.children,$e.mode,dt,Qe.key),dt.return=$e,$e=dt):(dt=Ty(Qe.type,Qe.key,Qe.props,null,$e.mode,dt),Hg(dt,Qe),dt.return=$e,$e=dt)}return X($e);case b:e:{for(Vt=Qe.key;Oe!==null;){if(Oe.key===Vt)if(Oe.tag===4&&Oe.stateNode.containerInfo===Qe.containerInfo&&Oe.stateNode.implementation===Qe.implementation){_($e,Oe.sibling),dt=P(Oe,Qe.children||[]),dt.return=$e,$e=dt;break e}else{_($e,Oe);break}else m($e,Oe);Oe=Oe.sibling}dt=t2(Qe,$e.mode,dt),dt.return=$e,$e=dt}return X($e);case O:return Qe=Yd(Qe),rr($e,Oe,Qe,dt)}if(W(Qe))return It($e,Oe,Qe,dt);if(I(Qe)){if(Vt=I(Qe),typeof Vt!="function")throw Error(r(150));return Qe=Vt.call(Qe),Xt($e,Oe,Qe,dt)}if(typeof Qe.then=="function")return rr($e,Oe,Dy(Qe),dt);if(Qe.$$typeof===w)return rr($e,Oe,ky($e,Qe),dt);Oy($e,Qe)}return typeof Qe=="string"&&Qe!==""||typeof Qe=="number"||typeof Qe=="bigint"?(Qe=""+Qe,Oe!==null&&Oe.tag===6?(_($e,Oe.sibling),dt=P(Oe,Qe),dt.return=$e,$e=dt):(_($e,Oe),dt=e2(Qe,$e.mode,dt),dt.return=$e,$e=dt),X($e)):_($e,Oe)}return function($e,Oe,Qe,dt){try{Bg=0;var Vt=rr($e,Oe,Qe,dt);return Gf=null,Vt}catch(zt){if(zt===Vf||zt===jy)throw zt;var Fn=hs(29,zt,null,$e.mode);return Fn.lanes=dt,Fn.return=$e,Fn}finally{}}}var Qd=H4(!0),$4=H4(!1),lu=!1;function f2(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function m2(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 cu(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function uu(h,m,_){var M=h.updateQueue;if(M===null)return null;if(M=M.shared,($n&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),A4(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=_,Hn(h,_)}}function p2(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 X={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};D===null?P=D=X:D=D.next=X,_=_.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 g2=!1;function Vg(){if(g2){var h=$f;if(h!==null)throw h}}function Gg(h,m,_,M){g2=!1;var P=h.updateQueue;lu=!1;var D=P.firstBaseUpdate,X=P.lastBaseUpdate,de=P.shared.pending;if(de!==null){P.shared.pending=null;var ke=de,Je=ke.next;ke.next=null,X===null?D=Je:X.next=Je,X=ke;var ut=h.alternate;ut!==null&&(ut=ut.updateQueue,de=ut.lastBaseUpdate,de!==X&&(de===null?ut.firstBaseUpdate=Je:de.next=Je,ut.lastBaseUpdate=ke))}if(D!==null){var ht=P.baseState;X=0,ut=Je=ke=null,de=D;do{var tt=de.lane&-536870913,st=tt!==de.lane;if(st?(Pn&tt)===tt:(M&tt)===tt){tt!==0&&tt===Hf&&(g2=!0),ut!==null&&(ut=ut.next={lane:0,tag:de.tag,payload:de.payload,callback:null,next:null});e:{var It=h,Xt=de;tt=m;var rr=_;switch(Xt.tag){case 1:if(It=Xt.payload,typeof It=="function"){ht=It.call(rr,ht,tt);break e}ht=It;break e;case 3:It.flags=It.flags&-65537|128;case 0:if(It=Xt.payload,tt=typeof It=="function"?It.call(rr,ht,tt):It,tt==null)break e;ht=f({},ht,tt);break e;case 2:lu=!0}}tt=de.callback,tt!==null&&(h.flags|=64,st&&(h.flags|=8192),st=P.callbacks,st===null?P.callbacks=[tt]:st.push(tt))}else st={lane:tt,tag:de.tag,payload:de.payload,callback:de.callback,next:null},ut===null?(Je=ut=st,ke=ht):ut=ut.next=st,X|=tt;if(de=de.next,de===null){if(de=P.shared.pending,de===null)break;st=de,de=st.next,st.next=null,P.lastBaseUpdate=st,P.shared.pending=null}}while(!0);ut===null&&(ke=ht),P.baseState=ke,P.firstBaseUpdate=Je,P.lastBaseUpdate=ut,D===null&&(P.shared.lanes=0),pu|=X,h.lanes=X,h.memoizedState=ht}}function V4(h,m){if(typeof h!="function")throw Error(r(191,h));h.call(m)}function G4(h,m){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)V4(_[h],m)}var Wf=F(null),Ly=F(0);function W4(h,m){h=Ql,ne(Ly,h),ne(Wf,m),Ql=h|m.baseLanes}function x2(){ne(Ly,Ql),ne(Wf,Wf.current)}function b2(){Ql=Ly.current,V(Wf),V(Ly)}var fs=F(null),Bs=null;function du(h){var m=h.alternate;ne(Kr,Kr.current&1),ne(fs,h),Bs===null&&(m===null||Wf.current!==null||m.memoizedState!==null)&&(Bs=h)}function y2(h){ne(Kr,Kr.current),ne(fs,h),Bs===null&&(Bs=h)}function q4(h){h.tag===22?(ne(Kr,Kr.current),ne(fs,h),Bs===null&&(Bs=h)):hu()}function hu(){ne(Kr,Kr.current),ne(fs,fs.current)}function ms(h){V(fs),Bs===h&&(Bs=null),V(Kr)}var Kr=F(0);function Iy(h){for(var m=h;m!==null;){if(m.tag===13){var _=m.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||EA(_)||AA(_)))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,un=null,tr=null,ni=null,Fy=!1,qf=!1,Jd=!1,Uy=0,Wg=0,Kf=null,Xne=0;function zr(){throw Error(r(321))}function v2(h,m){if(m===null)return!1;for(var _=0;_<m.length&&_<h.length;_++)if(!ds(h[_],m[_]))return!1;return!0}function _2(h,m,_,M,P,D){return Vl=D,un=m,m.memoizedState=null,m.updateQueue=null,m.lanes=0,K.H=h===null||h.memoizedState===null?kI:L2,Jd=!1,D=_(M,P),Jd=!1,qf&&(D=X4(m,_,M,P)),K4(h),D}function K4(h){K.H=Xg;var m=tr!==null&&tr.next!==null;if(Vl=0,ni=tr=un=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 X4(h,m,_,M){un=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)}K.H=PI,D=m(_,M)}while(qf);return D}function Yne(){var h=K.H,m=h.useState()[0];return m=typeof m.then=="function"?qg(m):m,h=h.useState()[0],(tr!==null?tr.memoizedState:null)!==h&&(un.flags|=1024),m}function w2(){var h=Uy!==0;return Uy=0,h}function S2(h,m,_){m.updateQueue=h.updateQueue,m.flags&=-2053,h.lanes&=~_}function M2(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=un=null,qf=!1,Wg=Uy=0,Kf=null}function Ta(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ni===null?un.memoizedState=ni=h:ni=ni.next=h,ni}function Xr(){if(tr===null){var h=un.alternate;h=h!==null?h.memoizedState:null}else h=tr.next;var m=ni===null?un.memoizedState:ni.next;if(m!==null)ni=m,tr=h;else{if(h===null)throw un.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?un.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=U4(Kf,h,m),m=un,(ni===null?m.memoizedState:ni.next)===null&&(m=m.alternate,K.H=m===null||m.memoizedState===null?kI:L2),h}function By(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return qg(h);if(h.$$typeof===w)return Zi(h)}throw Error(r(438,String(h)))}function E2(h){var m=null,_=un.updateQueue;if(_!==null&&(m=_.memoCache),m==null){var M=un.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(),un.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 A2(m,tr,h)}function A2(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 X=P.next;P.next=D.next,D.next=X}m.baseQueue=P=D,M.pending=null}if(D=h.baseState,P===null)h.memoizedState=D;else{m=P.next;var de=X=null,ke=null,Je=m,ut=!1;do{var ht=Je.lane&-536870913;if(ht!==Je.lane?(Pn&ht)===ht:(Vl&ht)===ht){var tt=Je.revertLane;if(tt===0)ke!==null&&(ke=ke.next={lane:0,revertLane:0,gesture:null,action:Je.action,hasEagerState:Je.hasEagerState,eagerState:Je.eagerState,next:null}),ht===Hf&&(ut=!0);else if((Vl&tt)===tt){Je=Je.next,tt===Hf&&(ut=!0);continue}else ht={lane:0,revertLane:Je.revertLane,gesture:null,action:Je.action,hasEagerState:Je.hasEagerState,eagerState:Je.eagerState,next:null},ke===null?(de=ke=ht,X=D):ke=ke.next=ht,un.lanes|=tt,pu|=tt;ht=Je.action,Jd&&_(D,ht),D=Je.hasEagerState?Je.eagerState:_(D,ht)}else tt={lane:ht,revertLane:Je.revertLane,gesture:Je.gesture,action:Je.action,hasEagerState:Je.hasEagerState,eagerState:Je.eagerState,next:null},ke===null?(de=ke=tt,X=D):ke=ke.next=tt,un.lanes|=ht,pu|=ht;Je=Je.next}while(Je!==null&&Je!==m);if(ke===null?X=D:ke.next=de,!ds(D,h.memoizedState)&&(ri=!0,ut&&(_=$f,_!==null)))throw _;h.memoizedState=D,h.baseState=X,h.baseQueue=ke,M.lastRenderedState=D}return P===null&&(M.lanes=0),[h.memoizedState,M.dispatch]}function T2(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 X=P=P.next;do D=h(D,X.action),X=X.next;while(X!==P);ds(D,m.memoizedState)||(ri=!0),m.memoizedState=D,m.baseQueue===null&&(m.baseState=D),_.lastRenderedState=D}return[D,M]}function Y4(h,m,_){var M=un,P=Xr(),D=Dn;if(D){if(_===void 0)throw Error(r(407));_=_()}else _=m();var X=!ds((tr||P).memoizedState,_);if(X&&(P.memoizedState=_,ri=!0),P=P.queue,k2(J4.bind(null,M,P,h),[h]),P.getSnapshot!==m||X||ni!==null&&ni.memoizedState.tag&1){if(M.flags|=2048,Xf(9,{destroy:void 0},Q4.bind(null,M,P,_,m),null),hr===null)throw Error(r(349));D||(Vl&127)!==0||Z4(M,m,_)}return _}function Z4(h,m,_){h.flags|=16384,h={getSnapshot:m,value:_},m=un.updateQueue,m===null?(m=zy(),un.updateQueue=m,m.stores=[h]):(_=m.stores,_===null?m.stores=[h]:_.push(h))}function Q4(h,m,_,M){m.value=_,m.getSnapshot=M,eI(m)&&tI(h)}function J4(h,m,_){return _(function(){eI(m)&&tI(h)})}function eI(h){var m=h.getSnapshot;h=h.value;try{var _=m();return!ds(h,_)}catch{return!0}}function tI(h){var m=Vd(h,2);m!==null&&Ka(m,h,2)}function N2(h){var m=Ta();if(typeof h=="function"){var _=h;if(h=_(),Jd){He(!0);try{_()}finally{He(!1)}}}return m.memoizedState=m.baseState=h,m.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Gl,lastRenderedState:h},m}function nI(h,m,_,M){return h.baseState=_,A2(h,tr,typeof M=="function"?M:Gl)}function Zne(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(X){D.listeners.push(X)}};K.T!==null?_(!0):D.isTransition=!1,M(D),_=m.pending,_===null?(D.next=m.pending=D,rI(m,D)):(D.next=_.next,m.pending=_.next=D)}}function rI(h,m){var _=m.action,M=m.payload,P=h.state;if(m.isTransition){var D=K.T,X={};K.T=X;try{var de=_(P,M),ke=K.S;ke!==null&&ke(X,de),iI(h,m,de)}catch(Je){C2(h,m,Je)}finally{D!==null&&X.types!==null&&(D.types=X.types),K.T=D}}else try{D=_(P,M),iI(h,m,D)}catch(Je){C2(h,m,Je)}}function iI(h,m,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(M){aI(h,m,M)},function(M){return C2(h,m,M)}):aI(h,m,_)}function aI(h,m,_){m.status="fulfilled",m.value=_,sI(m),h.state=_,m=h.pending,m!==null&&(_=m.next,_===m?h.pending=null:(_=_.next,m.next=_,rI(h,_)))}function C2(h,m,_){var M=h.pending;if(h.pending=null,M!==null){M=M.next;do m.status="rejected",m.reason=_,sI(m),m=m.next;while(m!==M)}h.action=null}function sI(h){h=h.listeners;for(var m=0;m<h.length;m++)(0,h[m])()}function oI(h,m){return m}function lI(h,m){if(Dn){var _=hr.formState;if(_!==null){e:{var M=un;if(Dn){if(_r){t:{for(var P=_r,D=zs;P.nodeType!==8;){if(!D){P=null;break t}if(P=Hs(P.nextSibling),P===null){P=null;break t}}D=P.data,P=D==="F!"||D==="F"?P:null}if(P){_r=Hs(P.nextSibling),M=P.data==="F!";break e}}su(M)}M=!1}M&&(m=_[0])}}return _=Ta(),_.memoizedState=_.baseState=m,M={pending:null,lanes:0,dispatch:null,lastRenderedReducer:oI,lastRenderedState:m},_.queue=M,_=TI.bind(null,un,M),M.dispatch=_,M=N2(!1),D=O2.bind(null,un,!1,M.queue),M=Ta(),P={state:m,dispatch:null,action:h,pending:null},M.queue=P,_=Zne.bind(null,un,P,D,_),P.dispatch=_,M.memoizedState=h,[m,_,!1]}function cI(h){var m=Xr();return uI(m,tr,h)}function uI(h,m,_){if(m=A2(h,m,oI)[0],h=Hy(Gl)[0],typeof m=="object"&&m!==null&&typeof m.then=="function")try{var M=qg(m)}catch(X){throw X===Vf?jy:X}else M=m;m=Xr();var P=m.queue,D=P.dispatch;return _!==m.memoizedState&&(un.flags|=2048,Xf(9,{destroy:void 0},Qne.bind(null,P,_),null)),[M,D,h]}function Qne(h,m){h.action=m}function dI(h){var m=Xr(),_=tr;if(_!==null)return uI(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=un.updateQueue,m===null&&(m=zy(),un.updateQueue=m),_=m.lastEffect,_===null?m.lastEffect=h.next=h:(M=_.next,_.next=h,h.next=M,m.lastEffect=h),h}function hI(){return Xr().memoizedState}function $y(h,m,_,M){var P=Ta();un.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&&v2(M,tr.memoizedState.deps)?P.memoizedState=Xf(m,D,_,M):(un.flags|=h,P.memoizedState=Xf(1|m,D,_,M))}function fI(h,m){$y(8390656,8,h,m)}function k2(h,m){Vy(2048,8,h,m)}function Jne(h){un.flags|=4;var m=un.updateQueue;if(m===null)m=zy(),un.updateQueue=m,m.events=[h];else{var _=m.events;_===null?m.events=[h]:_.push(h)}}function mI(h){var m=Xr().memoizedState;return Jne({ref:m,nextImpl:h}),function(){if(($n&2)!==0)throw Error(r(440));return m.impl.apply(void 0,arguments)}}function pI(h,m){return Vy(4,2,h,m)}function gI(h,m){return Vy(4,4,h,m)}function xI(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 bI(h,m,_){_=_!=null?_.concat([h]):null,Vy(4,4,xI.bind(null,m,h),_)}function P2(){}function yI(h,m){var _=Xr();m=m===void 0?null:m;var M=_.memoizedState;return m!==null&&v2(m,M[1])?M[0]:(_.memoizedState=[h,m],h)}function vI(h,m){var _=Xr();m=m===void 0?null:m;var M=_.memoizedState;if(m!==null&&v2(m,M[1]))return M[0];if(M=h(),Jd){He(!0);try{h()}finally{He(!1)}}return _.memoizedState=[M,m],M}function j2(h,m,_){return _===void 0||(Vl&1073741824)!==0&&(Pn&261930)===0?h.memoizedState=m:(h.memoizedState=_,h=_5(),un.lanes|=h,pu|=h,_)}function _I(h,m,_,M){return ds(_,m)?_:Wf.current!==null?(h=j2(h,_,M),ds(h,m)||(ri=!0),h):(Vl&42)===0||(Vl&1073741824)!==0&&(Pn&261930)===0?(ri=!0,h.memoizedState=_):(h=_5(),un.lanes|=h,pu|=h,m)}function wI(h,m,_,M,P){var D=G.p;G.p=D!==0&&8>D?D:8;var X=K.T,de={};K.T=de,O2(h,!1,m,_);try{var ke=P(),Je=K.S;if(Je!==null&&Je(de,ke),ke!==null&&typeof ke=="object"&&typeof ke.then=="function"){var ut=Kne(ke,M);Kg(h,m,ut,xs(h))}else Kg(h,m,M,xs(h))}catch(ht){Kg(h,m,{then:function(){},status:"rejected",reason:ht},xs())}finally{G.p=D,X!==null&&de.types!==null&&(X.types=de.types),K.T=X}}function ere(){}function R2(h,m,_,M){if(h.tag!==5)throw Error(r(476));var P=SI(h).queue;wI(h,P,m,J,_===null?ere:function(){return MI(h),_(M)})}function SI(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 MI(h){var m=SI(h);m.next===null&&(m=h.alternate.memoizedState),Kg(h,m.next.queue,{},xs())}function D2(){return Zi(dx)}function EI(){return Xr().memoizedState}function AI(){return Xr().memoizedState}function tre(h){for(var m=h.return;m!==null;){switch(m.tag){case 24:case 3:var _=xs();h=cu(_);var M=uu(m,h,_);M!==null&&(Ka(M,m,_),$g(M,m,_)),m={cache:c2()},h.payload=m;return}m=m.return}}function nre(h,m,_){var M=xs();_={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Gy(h)?NI(m,_):(_=QE(h,m,_,M),_!==null&&(Ka(_,h,M),CI(_,m,M)))}function TI(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))NI(m,P);else{var D=h.alternate;if(h.lanes===0&&(D===null||D.lanes===0)&&(D=m.lastRenderedReducer,D!==null))try{var X=m.lastRenderedState,de=D(X,_);if(P.hasEagerState=!0,P.eagerState=de,ds(de,X))return Ey(h,m,P,0),hr===null&&My(),!1}catch{}finally{}if(_=QE(h,m,P,M),_!==null)return Ka(_,h,M),CI(_,m,M),!0}return!1}function O2(h,m,_,M){if(M={lane:2,revertLane:fA(),gesture:null,action:M,hasEagerState:!1,eagerState:null,next:null},Gy(h)){if(m)throw Error(r(479))}else m=QE(h,_,M,2),m!==null&&Ka(m,h,2)}function Gy(h){var m=h.alternate;return h===un||m!==null&&m===un}function NI(h,m){qf=Fy=!0;var _=h.pending;_===null?m.next=m:(m.next=_.next,_.next=m),h.pending=m}function CI(h,m,_){if((_&4194048)!==0){var M=m.lanes;M&=h.pendingLanes,_|=M,m.lanes=_,Hn(h,_)}}var Xg={readContext:Zi,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 kI={readContext:Zi,use:By,useCallback:function(h,m){return Ta().memoizedState=[h,m===void 0?null:m],h},useContext:Zi,useEffect:fI,useImperativeHandle:function(h,m,_){_=_!=null?_.concat([h]):null,$y(4194308,4,xI.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 _=Ta();m=m===void 0?null:m;var M=h();if(Jd){He(!0);try{h()}finally{He(!1)}}return _.memoizedState=[M,m],M},useReducer:function(h,m,_){var M=Ta();if(_!==void 0){var P=_(m);if(Jd){He(!0);try{_(m)}finally{He(!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=nre.bind(null,un,h),[M.memoizedState,h]},useRef:function(h){var m=Ta();return h={current:h},m.memoizedState=h},useState:function(h){h=N2(h);var m=h.queue,_=TI.bind(null,un,m);return m.dispatch=_,[h.memoizedState,_]},useDebugValue:P2,useDeferredValue:function(h,m){var _=Ta();return j2(_,h,m)},useTransition:function(){var h=N2(!1);return h=wI.bind(null,un,h.queue,!0,!1),Ta().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,m,_){var M=un,P=Ta();if(Dn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=m(),hr===null)throw Error(r(349));(Pn&127)!==0||Z4(M,m,_)}P.memoizedState=_;var D={value:_,getSnapshot:m};return P.queue=D,fI(J4.bind(null,M,D,h),[h]),M.flags|=2048,Xf(9,{destroy:void 0},Q4.bind(null,M,D,_,m),null),_},useId:function(){var h=Ta(),m=hr.identifierPrefix;if(Dn){var _=Jo,M=Qo;_=(M&~(1<<32-Be(M)-1)).toString(32)+_,m="_"+m+"R_"+_,_=Uy++,0<_&&(m+="H"+_.toString(32)),m+="_"}else _=Xne++,m="_"+m+"r_"+_.toString(32)+"_";return h.memoizedState=m},useHostTransitionStatus:D2,useFormState:lI,useActionState:lI,useOptimistic:function(h){var m=Ta();m.memoizedState=m.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return m.queue=_,m=O2.bind(null,un,!0,_),_.dispatch=m,[h,m]},useMemoCache:E2,useCacheRefresh:function(){return Ta().memoizedState=tre.bind(null,un)},useEffectEvent:function(h){var m=Ta(),_={impl:h};return m.memoizedState=_,function(){if(($n&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},L2={readContext:Zi,use:By,useCallback:yI,useContext:Zi,useEffect:k2,useImperativeHandle:bI,useInsertionEffect:pI,useLayoutEffect:gI,useMemo:vI,useReducer:Hy,useRef:hI,useState:function(){return Hy(Gl)},useDebugValue:P2,useDeferredValue:function(h,m){var _=Xr();return _I(_,tr.memoizedState,h,m)},useTransition:function(){var h=Hy(Gl)[0],m=Xr().memoizedState;return[typeof h=="boolean"?h:qg(h),m]},useSyncExternalStore:Y4,useId:EI,useHostTransitionStatus:D2,useFormState:cI,useActionState:cI,useOptimistic:function(h,m){var _=Xr();return nI(_,tr,h,m)},useMemoCache:E2,useCacheRefresh:AI};L2.useEffectEvent=mI;var PI={readContext:Zi,use:By,useCallback:yI,useContext:Zi,useEffect:k2,useImperativeHandle:bI,useInsertionEffect:pI,useLayoutEffect:gI,useMemo:vI,useReducer:T2,useRef:hI,useState:function(){return T2(Gl)},useDebugValue:P2,useDeferredValue:function(h,m){var _=Xr();return tr===null?j2(_,h,m):_I(_,tr.memoizedState,h,m)},useTransition:function(){var h=T2(Gl)[0],m=Xr().memoizedState;return[typeof h=="boolean"?h:qg(h),m]},useSyncExternalStore:Y4,useId:EI,useHostTransitionStatus:D2,useFormState:dI,useActionState:dI,useOptimistic:function(h,m){var _=Xr();return tr!==null?nI(_,tr,h,m):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:E2,useCacheRefresh:AI};PI.useEffectEvent=mI;function I2(h,m,_,M){m=h.memoizedState,_=_(M,m),_=_==null?m:f({},m,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var F2={enqueueSetState:function(h,m,_){h=h._reactInternals;var M=xs(),P=cu(M);P.payload=m,_!=null&&(P.callback=_),m=uu(h,P,M),m!==null&&(Ka(m,h,M),$g(m,h,M))},enqueueReplaceState:function(h,m,_){h=h._reactInternals;var M=xs(),P=cu(M);P.tag=1,P.payload=m,_!=null&&(P.callback=_),m=uu(h,P,M),m!==null&&(Ka(m,h,M),$g(m,h,M))},enqueueForceUpdate:function(h,m){h=h._reactInternals;var _=xs(),M=cu(_);M.tag=2,m!=null&&(M.callback=m),m=uu(h,M,_),m!==null&&(Ka(m,h,_),$g(m,h,_))}};function jI(h,m,_,M,P,D,X){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(M,D,X):m.prototype&&m.prototype.isPureReactComponent?!Og(_,M)||!Og(P,D):!0}function RI(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&&F2.enqueueReplaceState(m,m.state,null)}function eh(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 DI(h){Sy(h)}function OI(h){console.error(h)}function LI(h){Sy(h)}function Wy(h,m){try{var _=h.onUncaughtError;_(m.value,{componentStack:m.stack})}catch(M){setTimeout(function(){throw M})}}function II(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 U2(h,m,_){return _=cu(_),_.tag=3,_.payload={element:null},_.callback=function(){Wy(h,m)},_}function FI(h){return h=cu(h),h.tag=3,h}function UI(h,m,_,M){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var D=M.value;h.payload=function(){return P(D)},h.callback=function(){II(m,_,M)}}var X=_.stateNode;X!==null&&typeof X.componentDidCatch=="function"&&(h.callback=function(){II(m,_,M),typeof P!="function"&&(gu===null?gu=new Set([this]):gu.add(this));var de=M.stack;this.componentDidCatch(M.value,{componentStack:de!==null?de:""})})}function rre(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 Bs===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),uA(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)),uA(h,M,P)),!1}throw Error(r(435,_.tag))}return uA(h,M,P),iv(),!1}if(Dn)return m=fs.current,m!==null?((m.flags&65536)===0&&(m.flags|=256),m.flags|=65536,m.lanes=P,M!==i2&&(h=Error(r(422),{cause:M}),Fg(Is(h,_)))):(M!==i2&&(m=Error(r(423),{cause:M}),Fg(Is(m,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,M=Is(M,_),P=U2(h.stateNode,M,P),p2(h,P),Br!==4&&(Br=2)),!1;var D=Error(r(520),{cause:M});if(D=Is(D,_),rx===null?rx=[D]:rx.push(D),Br!==4&&(Br=2),m===null)return!0;M=Is(M,_),_=m;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=U2(_.stateNode,M,h),p2(_,h),!1;case 1:if(m=_.type,D=_.stateNode,(_.flags&128)===0&&(typeof m.getDerivedStateFromError=="function"||D!==null&&typeof D.componentDidCatch=="function"&&(gu===null||!gu.has(D))))return _.flags|=65536,P&=-P,_.lanes|=P,P=FI(P),UI(P,h,_,M),p2(_,P),!1}_=_.return}while(_!==null);return!1}var z2=Error(r(461)),ri=!1;function Qi(h,m,_,M){m.child=h===null?$4(m,null,_,M):Qd(m,h.child,_,M)}function zI(h,m,_,M,P){_=_.render;var D=m.ref;if("ref"in M){var X={};for(var de in M)de!=="ref"&&(X[de]=M[de])}else X=M;return Kd(m),M=_2(h,m,_,X,D,P),de=w2(),h!==null&&!ri?(S2(h,m,P),Wl(h,m,P)):(Dn&&de&&n2(m),m.flags|=1,Qi(h,m,M,P),m.child)}function BI(h,m,_,M,P){if(h===null){var D=_.type;return typeof D=="function"&&!JE(D)&&D.defaultProps===void 0&&_.compare===null?(m.tag=15,m.type=D,HI(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,!K2(h,P)){var X=D.memoizedProps;if(_=_.compare,_=_!==null?_:Og,_(X,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 HI(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,K2(h,P))(h.flags&131072)!==0&&(ri=!0);else return m.lanes=h.lanes,Wl(h,m,P)}return B2(h,m,_,M,P)}function $I(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 VI(h,m,D,_,M)}if((_&536870912)!==0)m.memoizedState={baseLanes:0,cachePool:null},h!==null&&Py(m,D!==null?D.cachePool:null),D!==null?W4(m,D):x2(),q4(m);else return M=m.lanes=536870912,VI(h,m,D!==null?D.baseLanes|_:_,_,M)}else D!==null?(Py(m,D.cachePool),W4(m,D),hu(),m.memoizedState=null):(h!==null&&Py(m,null),x2(),hu());return Qi(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 VI(h,m,_,M,P){var D=d2();return D=D===null?null:{parent:ti._currentValue,pool:D},m.memoizedState={baseLanes:_,cachePool:D},h!==null&&Py(m,null),x2(),q4(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 GI(h,m,_){return Qd(m,h.child,null,_),h=qy(m,m.pendingProps),h.flags|=2,ms(m),m.memoizedState=null,h}function ire(h,m,_){var M=m.pendingProps,P=(m.flags&128)!==0;if(m.flags&=-129,h===null){if(Dn){if(M.mode==="hidden")return h=qy(m,M),m.lanes=536870912,Yg(null,h);if(y2(m),(h=_r)?(h=rF(h,zs),h=h!==null&&h.data==="&"?h:null,h!==null&&(m.memoizedState={dehydrated:h,treeContext:iu!==null?{id:Qo,overflow:Jo}:null,retryLane:536870912,hydrationErrors:null},_=N4(h),_.return=m,m.child=_,Yi=m,_r=null)):h=null,h===null)throw su(m);return m.lanes=536870912,null}return qy(m,M)}var D=h.memoizedState;if(D!==null){var X=D.dehydrated;if(y2(m),P)if(m.flags&256)m.flags&=-257,m=GI(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&&(X=bt(M,_),X!==0&&X!==D.retryLane))throw D.retryLane=X,Vd(h,X),Ka(M,h,X),z2;iv(),m=GI(h,m,_)}else h=D.treeContext,_r=Hs(X.nextSibling),Yi=m,Dn=!0,au=null,zs=!1,h!==null&&P4(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 B2(h,m,_,M,P){return Kd(m),_=_2(h,m,_,M,void 0,P),M=w2(),h!==null&&!ri?(S2(h,m,P),Wl(h,m,P)):(Dn&&M&&n2(m),m.flags|=1,Qi(h,m,_,P),m.child)}function WI(h,m,_,M,P,D){return Kd(m),m.updateQueue=null,_=X4(m,M,_,P),K4(h),M=w2(),h!==null&&!ri?(S2(h,m,D),Wl(h,m,D)):(Dn&&M&&n2(m),m.flags|=1,Qi(h,m,_,D),m.child)}function qI(h,m,_,M,P){if(Kd(m),m.stateNode===null){var D=If,X=_.contextType;typeof X=="object"&&X!==null&&(D=Zi(X)),D=new _(M,D),m.memoizedState=D.state!==null&&D.state!==void 0?D.state:null,D.updater=F2,m.stateNode=D,D._reactInternals=m,D=m.stateNode,D.props=M,D.state=m.memoizedState,D.refs={},f2(m),X=_.contextType,D.context=typeof X=="object"&&X!==null?Zi(X):If,D.state=m.memoizedState,X=_.getDerivedStateFromProps,typeof X=="function"&&(I2(m,_,X,M),D.state=m.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof D.getSnapshotBeforeUpdate=="function"||typeof D.UNSAFE_componentWillMount!="function"&&typeof D.componentWillMount!="function"||(X=D.state,typeof D.componentWillMount=="function"&&D.componentWillMount(),typeof D.UNSAFE_componentWillMount=="function"&&D.UNSAFE_componentWillMount(),X!==D.state&&F2.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 de=m.memoizedProps,ke=eh(_,de);D.props=ke;var Je=D.context,ut=_.contextType;X=If,typeof ut=="object"&&ut!==null&&(X=Zi(ut));var ht=_.getDerivedStateFromProps;ut=typeof ht=="function"||typeof D.getSnapshotBeforeUpdate=="function",de=m.pendingProps!==de,ut||typeof D.UNSAFE_componentWillReceiveProps!="function"&&typeof D.componentWillReceiveProps!="function"||(de||Je!==X)&&RI(m,D,M,X),lu=!1;var tt=m.memoizedState;D.state=tt,Gg(m,M,D,P),Vg(),Je=m.memoizedState,de||tt!==Je||lu?(typeof ht=="function"&&(I2(m,_,ht,M),Je=m.memoizedState),(ke=lu||jI(m,_,ke,M,tt,Je,X))?(ut||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=Je),D.props=M,D.state=Je,D.context=X,M=ke):(typeof D.componentDidMount=="function"&&(m.flags|=4194308),M=!1)}else{D=m.stateNode,m2(h,m),X=m.memoizedProps,ut=eh(_,X),D.props=ut,ht=m.pendingProps,tt=D.context,Je=_.contextType,ke=If,typeof Je=="object"&&Je!==null&&(ke=Zi(Je)),de=_.getDerivedStateFromProps,(Je=typeof de=="function"||typeof D.getSnapshotBeforeUpdate=="function")||typeof D.UNSAFE_componentWillReceiveProps!="function"&&typeof D.componentWillReceiveProps!="function"||(X!==ht||tt!==ke)&&RI(m,D,M,ke),lu=!1,tt=m.memoizedState,D.state=tt,Gg(m,M,D,P),Vg();var st=m.memoizedState;X!==ht||tt!==st||lu||h!==null&&h.dependencies!==null&&Cy(h.dependencies)?(typeof de=="function"&&(I2(m,_,de,M),st=m.memoizedState),(ut=lu||jI(m,_,ut,M,tt,st,ke)||h!==null&&h.dependencies!==null&&Cy(h.dependencies))?(Je||typeof D.UNSAFE_componentWillUpdate!="function"&&typeof D.componentWillUpdate!="function"||(typeof D.componentWillUpdate=="function"&&D.componentWillUpdate(M,st,ke),typeof D.UNSAFE_componentWillUpdate=="function"&&D.UNSAFE_componentWillUpdate(M,st,ke)),typeof D.componentDidUpdate=="function"&&(m.flags|=4),typeof D.getSnapshotBeforeUpdate=="function"&&(m.flags|=1024)):(typeof D.componentDidUpdate!="function"||X===h.memoizedProps&&tt===h.memoizedState||(m.flags|=4),typeof D.getSnapshotBeforeUpdate!="function"||X===h.memoizedProps&&tt===h.memoizedState||(m.flags|=1024),m.memoizedProps=M,m.memoizedState=st),D.props=M,D.state=st,D.context=ke,M=ut):(typeof D.componentDidUpdate!="function"||X===h.memoizedProps&&tt===h.memoizedState||(m.flags|=4),typeof D.getSnapshotBeforeUpdate!="function"||X===h.memoizedProps&&tt===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=Qd(m,h.child,null,P),m.child=Qd(m,null,_,P)):Qi(h,m,_,P),m.memoizedState=D.state,h=m.child):h=Wl(h,m,P),h}function KI(h,m,_,M){return Wd(),m.flags|=256,Qi(h,m,_,M),m.child}var H2={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function $2(h){return{baseLanes:h,cachePool:I4()}}function V2(h,m,_){return h=h!==null?h.childLanes&~_:0,m&&(h|=gs),h}function XI(h,m,_){var M=m.pendingProps,P=!1,D=(m.flags&128)!==0,X;if((X=D)||(X=h!==null&&h.memoizedState===null?!1:(Kr.current&2)!==0),X&&(P=!0,m.flags&=-129),X=(m.flags&32)!==0,m.flags&=-33,h===null){if(Dn){if(P?du(m):hu(),(h=_r)?(h=rF(h,zs),h=h!==null&&h.data!=="&"?h:null,h!==null&&(m.memoizedState={dehydrated:h,treeContext:iu!==null?{id:Qo,overflow:Jo}:null,retryLane:536870912,hydrationErrors:null},_=N4(h),_.return=m,m.child=_,Yi=m,_r=null)):h=null,h===null)throw su(m);return AA(h)?m.lanes=32:m.lanes=536870912,null}var de=M.children;return M=M.fallback,P?(hu(),P=m.mode,de=Xy({mode:"hidden",children:de},P),M=Gd(M,P,_,null),de.return=m,M.return=m,de.sibling=M,m.child=de,M=m.child,M.memoizedState=$2(_),M.childLanes=V2(h,X,_),m.memoizedState=H2,Yg(null,M)):(du(m),G2(m,de))}var ke=h.memoizedState;if(ke!==null&&(de=ke.dehydrated,de!==null)){if(D)m.flags&256?(du(m),m.flags&=-257,m=W2(h,m,_)):m.memoizedState!==null?(hu(),m.child=h.child,m.flags|=128,m=null):(hu(),de=M.fallback,P=m.mode,M=Xy({mode:"visible",children:M.children},P),de=Gd(de,P,_,null),de.flags|=2,M.return=m,de.return=m,M.sibling=de,m.child=M,Qd(m,h.child,null,_),M=m.child,M.memoizedState=$2(_),M.childLanes=V2(h,X,_),m.memoizedState=H2,m=Yg(null,M));else if(du(m),AA(de)){if(X=de.nextSibling&&de.nextSibling.dataset,X)var Je=X.dgst;X=Je,M=Error(r(419)),M.stack="",M.digest=X,Fg({value:M,source:null,stack:null}),m=W2(h,m,_)}else if(ri||Bf(h,m,_,!1),X=(_&h.childLanes)!==0,ri||X){if(X=hr,X!==null&&(M=bt(X,_),M!==0&&M!==ke.retryLane))throw ke.retryLane=M,Vd(h,M),Ka(X,h,M),z2;EA(de)||iv(),m=W2(h,m,_)}else EA(de)?(m.flags|=192,m.child=h.child,m=null):(h=ke.treeContext,_r=Hs(de.nextSibling),Yi=m,Dn=!0,au=null,zs=!1,h!==null&&P4(m,h),m=G2(m,M.children),m.flags|=4096);return m}return P?(hu(),de=M.fallback,P=m.mode,ke=h.child,Je=ke.sibling,M=zl(ke,{mode:"hidden",children:M.children}),M.subtreeFlags=ke.subtreeFlags&65011712,Je!==null?de=zl(Je,de):(de=Gd(de,P,_,null),de.flags|=2),de.return=m,M.return=m,M.sibling=de,m.child=M,Yg(null,M),M=m.child,de=h.child.memoizedState,de===null?de=$2(_):(P=de.cachePool,P!==null?(ke=ti._currentValue,P=P.parent!==ke?{parent:ke,pool:ke}:P):P=I4(),de={baseLanes:de.baseLanes|_,cachePool:P}),M.memoizedState=de,M.childLanes=V2(h,X,_),m.memoizedState=H2,Yg(h.child,M)):(du(m),_=h.child,h=_.sibling,_=zl(_,{mode:"visible",children:M.children}),_.return=m,_.sibling=null,h!==null&&(X=m.deletions,X===null?(m.deletions=[h],m.flags|=16):X.push(h)),m.child=_,m.memoizedState=null,_)}function G2(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 W2(h,m,_){return Qd(m,h.child,null,_),h=G2(m,m.pendingProps.children),h.flags|=2,m.memoizedState=null,h}function YI(h,m,_){h.lanes|=m;var M=h.alternate;M!==null&&(M.lanes|=m),o2(h.return,m,_)}function q2(h,m,_,M,P,D){var X=h.memoizedState;X===null?h.memoizedState={isBackwards:m,rendering:null,renderingStartTime:0,last:M,tail:_,tailMode:P,treeForkCount:D}:(X.isBackwards=m,X.rendering=null,X.renderingStartTime=0,X.last=M,X.tail=_,X.tailMode=P,X.treeForkCount=D)}function ZI(h,m,_){var M=m.pendingProps,P=M.revealOrder,D=M.tail;M=M.children;var X=Kr.current,de=(X&2)!==0;if(de?(X=X&1|2,m.flags|=128):X&=1,ne(Kr,X),Qi(h,m,M,_),M=Dn?Ig:0,!de&&h!==null&&(h.flags&128)!==0)e:for(h=m.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&YI(h,_,m);else if(h.tag===19)YI(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),q2(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}q2(m,!0,_,null,D,M);break;case"together":q2(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),pu|=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 K2(h,m){return(h.lanes&m)!==0?!0:(h=h.dependencies,!!(h!==null&&Cy(h)))}function are(h,m,_){switch(m.tag){case 3:Ee(m,m.stateNode.containerInfo),ou(m,ti,h.memoizedState.cache),Wd();break;case 27:case 5:ue(m);break;case 4:Ee(m,m.stateNode.containerInfo);break;case 10:ou(m,m.type,m.memoizedProps.value);break;case 31:if(m.memoizedState!==null)return m.flags|=128,y2(m),null;break;case 13:var M=m.memoizedState;if(M!==null)return M.dehydrated!==null?(du(m),m.flags|=128,null):(_&m.child.childLanes)!==0?XI(h,m,_):(du(m),h=Wl(h,m,_),h!==null?h.sibling:null);du(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 ZI(h,m,_);m.flags|=128}if(P=m.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),ne(Kr,Kr.current),M)break;return null;case 22:return m.lanes=0,$I(h,m,_,m.pendingProps);case 24:ou(m,ti,h.memoizedState.cache)}return Wl(h,m,_)}function QI(h,m,_){if(h!==null)if(h.memoizedProps!==m.pendingProps)ri=!0;else{if(!K2(h,_)&&(m.flags&128)===0)return ri=!1,are(h,m,_);ri=(h.flags&131072)!==0}else ri=!1,Dn&&(m.flags&1048576)!==0&&k4(m,Ig,m.index);switch(m.lanes=0,m.tag){case 16:e:{var M=m.pendingProps;if(h=Yd(m.elementType),m.type=h,typeof h=="function")JE(h)?(M=eh(h,M),m.tag=1,m=qI(null,m,h,M,_)):(m.tag=0,m=B2(null,m,h,M,_));else{if(h!=null){var P=h.$$typeof;if(P===A){m.tag=11,m=zI(null,m,h,M,_);break e}else if(P===N){m.tag=14,m=BI(null,m,h,M,_);break e}}throw m=R(h)||h,Error(r(306,m,""))}}return m;case 0:return B2(h,m,m.type,m.pendingProps,_);case 1:return M=m.type,P=eh(M,m.pendingProps),qI(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,m2(h,m),Gg(m,M,null,_);var X=m.memoizedState;if(M=X.cache,ou(m,ti,M),M!==D.cache&&l2(m,[ti],_,!0),Vg(),M=X.element,D.isDehydrated)if(D={element:M,isDehydrated:!1,cache:X.cache},m.updateQueue.baseState=D,m.memoizedState=D,m.flags&256){m=KI(h,m,M,_);break e}else if(M!==P){P=Is(Error(r(424)),m),Fg(P),m=KI(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(_r=Hs(h.firstChild),Yi=m,Dn=!0,au=null,zs=!0,_=$4(m,null,M,_),m.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(Wd(),M===P){m=Wl(h,m,_);break e}Qi(h,m,M,_)}m=m.child}return m;case 26:return Ky(h,m),h===null?(_=cF(m.type,null,m.pendingProps,null))?m.memoizedState=_:Dn||(_=m.type,h=m.pendingProps,M=dv(pe.current).createElement(_),M[Yt]=m,M[_n]=h,Ji(M,_,h),De(M),m.stateNode=M):m.memoizedState=cF(m.type,h.memoizedProps,m.pendingProps,h.memoizedState),null;case 27:return ue(m),h===null&&Dn&&(M=m.stateNode=sF(m.type,m.pendingProps,pe.current),Yi=m,zs=!0,P=_r,vu(m.type)?(TA=P,_r=Hs(M.firstChild)):_r=P),Qi(h,m,m.pendingProps.children,_),Ky(h,m),h===null&&(m.flags|=4194304),m.child;case 5:return h===null&&Dn&&((P=M=_r)&&(M=Ore(M,m.type,m.pendingProps,zs),M!==null?(m.stateNode=M,Yi=m,_r=Hs(M.firstChild),zs=!1,P=!0):P=!1),P||su(m)),ue(m),P=m.type,D=m.pendingProps,X=h!==null?h.memoizedProps:null,M=D.children,wA(P,D)?M=null:X!==null&&wA(P,X)&&(m.flags|=32),m.memoizedState!==null&&(P=_2(h,m,Yne,null,null,_),dx._currentValue=P),Ky(h,m),Qi(h,m,M,_),m.child;case 6:return h===null&&Dn&&((h=_=_r)&&(_=Lre(_,m.pendingProps,zs),_!==null?(m.stateNode=_,Yi=m,_r=null,h=!0):h=!1),h||su(m)),null;case 13:return XI(h,m,_);case 4:return Ee(m,m.stateNode.containerInfo),M=m.pendingProps,h===null?m.child=Qd(m,null,M,_):Qi(h,m,M,_),m.child;case 11:return zI(h,m,m.type,m.pendingProps,_);case 7:return Qi(h,m,m.pendingProps,_),m.child;case 8:return Qi(h,m,m.pendingProps.children,_),m.child;case 12:return Qi(h,m,m.pendingProps.children,_),m.child;case 10:return M=m.pendingProps,ou(m,m.type,M.value),Qi(h,m,M.children,_),m.child;case 9:return P=m.type._context,M=m.pendingProps.children,Kd(m),P=Zi(P),M=M(P),m.flags|=1,Qi(h,m,M,_),m.child;case 14:return BI(h,m,m.type,m.pendingProps,_);case 15:return HI(h,m,m.type,m.pendingProps,_);case 19:return ZI(h,m,_);case 31:return ire(h,m,_);case 22:return $I(h,m,_,m.pendingProps);case 24:return Kd(m),M=Zi(ti),h===null?(P=d2(),P===null&&(P=hr,D=c2(),P.pooledCache=D,D.refCount++,D!==null&&(P.pooledCacheLanes|=_),P=D),m.memoizedState={parent:M,cache:P},f2(m),ou(m,ti,P)):((h.lanes&_)!==0&&(m2(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),ou(m,ti,M)):(M=D.cache,ou(m,ti,M),M!==P.cache&&l2(m,[ti],_,!0))),Qi(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 X2(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(E5())h.flags|=8192;else throw Zd=Ry,h2}else h.flags&=-16777217}function JI(h,m){if(m.type!=="stylesheet"||(m.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!mF(m))if(E5())h.flags|=8192;else throw Zd=Ry,h2}function Yy(h,m){m!==null&&(h.flags|=4),h.flags&16384&&(m=h.tag!==22?Et():536870912,h.lanes|=m,Jf|=m)}function Zg(h,m){if(!Dn)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 wr(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 sre(h,m,_){var M=m.pendingProps;switch(r2(m),m.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return wr(m),null;case 1:return wr(m),null;case 3:return _=m.stateNode,M=null,h!==null&&(M=h.memoizedState.cache),m.memoizedState.cache!==M&&(m.flags|=2048),$l(ti),he(),_.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,a2())),wr(m),null;case 26:var P=m.type,D=m.memoizedState;return h===null?(ql(m),D!==null?(wr(m),JI(m,D)):(wr(m),X2(m,P,null,M,_))):D?D!==h.memoizedState?(ql(m),wr(m),JI(m,D)):(wr(m),m.flags&=-16777217):(h=h.memoizedProps,h!==M&&ql(m),wr(m),X2(m,P,h,M,_)),null;case 27:if(Ae(m),_=pe.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 wr(m),null}h=le.current,zf(m)?j4(m):(h=sF(P,M,_),m.stateNode=h,ql(m))}return wr(m),null;case 5:if(Ae(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 wr(m),null}if(D=le.current,zf(m))j4(m);else{var X=dv(pe.current);switch(D){case 1:D=X.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:D=X.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":D=X.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":D=X.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":D=X.createElement("div"),D.innerHTML="<script><\/script>",D=D.removeChild(D.firstChild);break;case"select":D=typeof M.is=="string"?X.createElement("select",{is:M.is}):X.createElement("select"),M.multiple?D.multiple=!0:M.size&&(D.size=M.size);break;default:D=typeof M.is=="string"?X.createElement(P,{is:M.is}):X.createElement(P)}}D[Yt]=m,D[_n]=M;e:for(X=m.child;X!==null;){if(X.tag===5||X.tag===6)D.appendChild(X.stateNode);else if(X.tag!==4&&X.tag!==27&&X.child!==null){X.child.return=X,X=X.child;continue}if(X===m)break e;for(;X.sibling===null;){if(X.return===null||X.return===m)break e;X=X.return}X.sibling.return=X.return,X=X.sibling}m.stateNode=D;e:switch(Ji(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 wr(m),X2(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=pe.current,zf(m)){if(h=m.stateNode,_=m.memoizedProps,M=null,P=Yi,P!==null)switch(P.tag){case 27:case 5:M=P.memoizedProps}h[Yt]=m,h=!!(h.nodeValue===_||M!==null&&M.suppressHydrationWarning===!0||X5(h.nodeValue,_)),h||su(m,!0)}else h=dv(h).createTextNode(M),h[Yt]=m,m.stateNode=h}return wr(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[Yt]=m}else Wd(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;wr(m),h=!1}else _=a2(),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 wr(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[Yt]=m}else Wd(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;wr(m),P=!1}else P=a2(),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),wr(m),null);case 4:return he(),h===null&&xA(m.stateNode.containerInfo),wr(m),null;case 10:return $l(m.type),wr(m),null;case 19:if(V(Kr),M=m.memoizedState,M===null)return wr(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;)T4(_,h),_=_.sibling;return ne(Kr,Kr.current&1|2),Dn&&Bl(m,M.treeForkCount),m.child}h=h.sibling}M.tail!==null&&L()>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&&!Dn)return wr(m),null}else 2*L()-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=L(),h.sibling=null,_=Kr.current,ne(Kr,P?_&1|2:_&1),Dn&&Bl(m,M.treeForkCount),h):(wr(m),null);case 22:case 23:return ms(m),b2(),M=m.memoizedState!==null,h!==null?h.memoizedState!==null!==M&&(m.flags|=8192):M&&(m.flags|=8192),M?(_&536870912)!==0&&(m.flags&128)===0&&(wr(m),m.subtreeFlags&6&&(m.flags|=8192)):wr(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(Xd),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),m.memoizedState.cache!==_&&(m.flags|=2048),$l(ti),wr(m),null;case 25:return null;case 30:return null}throw Error(r(156,m.tag))}function ore(h,m){switch(r2(m),m.tag){case 1:return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 3:return $l(ti),he(),h=m.flags,(h&65536)!==0&&(h&128)===0?(m.flags=h&-65537|128,m):null;case 26:case 27:case 5:return Ae(m),null;case 31:if(m.memoizedState!==null){if(ms(m),m.alternate===null)throw Error(r(340));Wd()}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));Wd()}return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 19:return V(Kr),null;case 4:return he(),null;case 10:return $l(m.type),null;case 22:case 23:return ms(m),b2(),h!==null&&V(Xd),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 e5(h,m){switch(r2(m),m.tag){case 3:$l(ti),he();break;case 26:case 27:case 5:Ae(m);break;case 4:he();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),b2(),h!==null&&V(Xd);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,X=_.inst;M=D(),X.destroy=M}_=_.next}while(_!==P)}}catch(de){Yn(m,m.return,de)}}function fu(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 X=M.inst,de=X.destroy;if(de!==void 0){X.destroy=void 0,P=m;var ke=_,Je=de;try{Je()}catch(ut){Yn(P,ke,ut)}}}M=M.next}while(M!==D)}}catch(ut){Yn(m,m.return,ut)}}function t5(h){var m=h.updateQueue;if(m!==null){var _=h.stateNode;try{G4(m,_)}catch(M){Yn(h,h.return,M)}}}function n5(h,m,_){_.props=eh(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(M){Yn(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){Yn(h,m,P)}}function el(h,m){var _=h.ref,M=h.refCleanup;if(_!==null)if(typeof M=="function")try{M()}catch(P){Yn(h,m,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){Yn(h,m,P)}else _.current=null}function r5(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){Yn(h,h.return,P)}}function Y2(h,m,_){try{var M=h.stateNode;Cre(M,h.type,_,m),M[_n]=m}catch(P){Yn(h,h.return,P)}}function i5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&vu(h.type)||h.tag===4}function Z2(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||i5(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&&vu(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 Q2(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&&vu(h.type)&&(_=h.stateNode,m=null),h=h.child,h!==null))for(Q2(h,m,_),h=h.sibling;h!==null;)Q2(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&&vu(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 a5(h){var m=h.stateNode,_=h.memoizedProps;try{for(var M=h.type,P=m.attributes;P.length;)m.removeAttributeNode(P[0]);Ji(m,M,_),m[Yt]=h,m[_n]=_}catch(D){Yn(h,h.return,D)}}var Kl=!1,ii=!1,J2=!1,s5=typeof WeakSet=="function"?WeakSet:Set,Di=null;function lre(h,m){if(h=h.containerInfo,vA=bv,h=b4(h),WE(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 X=0,de=-1,ke=-1,Je=0,ut=0,ht=h,tt=null;t:for(;;){for(var st;ht!==_||P!==0&&ht.nodeType!==3||(de=X+P),ht!==D||M!==0&&ht.nodeType!==3||(ke=X+M),ht.nodeType===3&&(X+=ht.nodeValue.length),(st=ht.firstChild)!==null;)tt=ht,ht=st;for(;;){if(ht===h)break t;if(tt===_&&++Je===P&&(de=X),tt===D&&++ut===M&&(ke=X),(st=ht.nextSibling)!==null)break;ht=tt,tt=ht.parentNode}ht=st}_=de===-1||ke===-1?null:{start:de,end:ke}}else _=null}_=_||{start:0,end:0}}else _=null;for(_A={focusedElem:h,selectionRange:_},bv=!1,Di=m;Di!==null;)if(m=Di,h=m.child,(m.subtreeFlags&1028)!==0&&h!==null)h.return=m,Di=h;else for(;Di!==null;){switch(m=Di,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 It=eh(_.type,P);h=M.getSnapshotBeforeUpdate(It,D),M.__reactInternalSnapshotBeforeUpdate=h}catch(Xt){Yn(_,_.return,Xt)}}break;case 3:if((h&1024)!==0){if(h=m.stateNode.containerInfo,_=h.nodeType,_===9)MA(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":MA(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,Di=h;break}Di=m.return}}function o5(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(X){Yn(_,_.return,X)}else{var P=eh(_.type,m.memoizedProps);m=m.memoizedState;try{h.componentDidUpdate(P,m,h.__reactInternalSnapshotBeforeUpdate)}catch(X){Yn(_,_.return,X)}}M&64&&t5(_),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{G4(h,m)}catch(X){Yn(_,_.return,X)}}break;case 27:m===null&&M&4&&a5(_);case 26:case 5:Yl(h,_),m===null&&M&4&&r5(_),M&512&&Jg(_,_.return);break;case 12:Yl(h,_);break;case 31:Yl(h,_),M&4&&u5(h,_);break;case 13:Yl(h,_),M&4&&d5(h,_),M&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=xre.bind(null,_),Ire(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 l5(h){var m=h.alternate;m!==null&&(h.alternate=null,l5(m)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(m=h.stateNode,m!==null&&et(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 Nr=null,Va=!1;function Xl(h,m,_){for(_=_.child;_!==null;)c5(h,m,_),_=_.sibling}function c5(h,m,_){if(ae&&typeof ae.onCommitFiberUnmount=="function")try{ae.onCommitFiberUnmount(me,_)}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=Nr,P=Va;vu(_.type)&&(Nr=_.stateNode,Va=!1),Xl(h,m,_),lx(_.stateNode),Nr=M,Va=P;break;case 5:ii||el(_,m);case 6:if(M=Nr,P=Va,Nr=null,Xl(h,m,_),Nr=M,Va=P,Nr!==null)if(Va)try{(Nr.nodeType===9?Nr.body:Nr.nodeName==="HTML"?Nr.ownerDocument.body:Nr).removeChild(_.stateNode)}catch(D){Yn(_,m,D)}else try{Nr.removeChild(_.stateNode)}catch(D){Yn(_,m,D)}break;case 18:Nr!==null&&(Va?(h=Nr,tF(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),om(h)):tF(Nr,_.stateNode));break;case 4:M=Nr,P=Va,Nr=_.stateNode.containerInfo,Va=!0,Xl(h,m,_),Nr=M,Va=P;break;case 0:case 11:case 14:case 15:fu(2,_,m),ii||fu(4,_,m),Xl(h,m,_);break;case 1:ii||(el(_,m),M=_.stateNode,typeof M.componentWillUnmount=="function"&&n5(_,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 u5(h,m){if(m.memoizedState===null&&(h=m.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{om(h)}catch(_){Yn(m,m.return,_)}}}function d5(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(_){Yn(m,m.return,_)}}function cre(h){switch(h.tag){case 31:case 13:case 19:var m=h.stateNode;return m===null&&(m=h.stateNode=new s5),m;case 22:return h=h.stateNode,m=h._retryCache,m===null&&(m=h._retryCache=new s5),m;default:throw Error(r(435,h.tag))}}function Qy(h,m){var _=cre(h);m.forEach(function(M){if(!_.has(M)){_.add(M);var P=bre.bind(null,h,M);M.then(P,P)}})}function Ga(h,m){var _=m.deletions;if(_!==null)for(var M=0;M<_.length;M++){var P=_[M],D=h,X=m,de=X;e:for(;de!==null;){switch(de.tag){case 27:if(vu(de.type)){Nr=de.stateNode,Va=!1;break e}break;case 5:Nr=de.stateNode,Va=!1;break e;case 3:case 4:Nr=de.stateNode.containerInfo,Va=!0;break e}de=de.return}if(Nr===null)throw Error(r(160));c5(D,X,P),Nr=null,Va=!1,D=P.alternate,D!==null&&(D.return=null),P.return=null}if(m.subtreeFlags&13886)for(m=m.child;m!==null;)h5(m,h),m=m.sibling}var Mo=null;function h5(h,m){var _=h.alternate,M=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:Ga(m,h),Wa(h),M&4&&(fu(3,h,h.return),Qg(3,h),fu(5,h,h.return));break;case 1:Ga(m,h),Wa(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(Ga(m,h),Wa(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[rt]||D[Yt]||D.namespaceURI==="http://www.w3.org/2000/svg"||D.hasAttribute("itemprop"))&&(D=P.createElement(M),P.head.insertBefore(D,P.querySelector("head > title"))),Ji(D,M,_),D[Yt]=h,De(D),M=D;break e;case"link":var X=hF("link","href",P).get(M+(_.href||""));if(X){for(var de=0;de<X.length;de++)if(D=X[de],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)){X.splice(de,1);break t}}D=P.createElement(M),Ji(D,M,_),P.head.appendChild(D);break;case"meta":if(X=hF("meta","content",P).get(M+(_.content||""))){for(de=0;de<X.length;de++)if(D=X[de],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)){X.splice(de,1);break t}}D=P.createElement(M),Ji(D,M,_),P.head.appendChild(D);break;default:throw Error(r(468,M))}D[Yt]=h,De(D),M=D}h.stateNode=M}else fF(P,h.type,h.stateNode);else h.stateNode=dF(P,M,h.memoizedProps);else D!==M?(D===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):D.count--,M===null?fF(P,h.type,h.stateNode):dF(P,M,h.memoizedProps)):M===null&&h.stateNode!==null&&Y2(h,h.memoizedProps,_.memoizedProps)}break;case 27:Ga(m,h),Wa(h),M&512&&(ii||_===null||el(_,_.return)),_!==null&&M&4&&Y2(h,h.memoizedProps,_.memoizedProps);break;case 5:if(Ga(m,h),Wa(h),M&512&&(ii||_===null||el(_,_.return)),h.flags&32){P=h.stateNode;try{Zo(P,"")}catch(It){Yn(h,h.return,It)}}M&4&&h.stateNode!=null&&(P=h.memoizedProps,Y2(h,P,_!==null?_.memoizedProps:P)),M&1024&&(J2=!0);break;case 6:if(Ga(m,h),Wa(h),M&4){if(h.stateNode===null)throw Error(r(162));M=h.memoizedProps,_=h.stateNode;try{_.nodeValue=M}catch(It){Yn(h,h.return,It)}}break;case 3:if(mv=null,P=Mo,Mo=hv(m.containerInfo),Ga(m,h),Mo=P,Wa(h),M&4&&_!==null&&_.memoizedState.isDehydrated)try{om(m.containerInfo)}catch(It){Yn(h,h.return,It)}J2&&(J2=!1,f5(h));break;case 4:M=Mo,Mo=hv(h.stateNode.containerInfo),Ga(m,h),Wa(h),Mo=M;break;case 12:Ga(m,h),Wa(h);break;case 31:Ga(m,h),Wa(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,Qy(h,M)));break;case 13:Ga(m,h),Wa(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(ev=L()),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,Qy(h,M)));break;case 22:P=h.memoizedState!==null;var ke=_!==null&&_.memoizedState!==null,Je=Kl,ut=ii;if(Kl=Je||P,ii=ut||ke,Ga(m,h),ii=ut,Kl=Je,Wa(h),M&8192)e:for(m=h.stateNode,m._visibility=P?m._visibility&-2:m._visibility|1,P&&(_===null||ke||Kl||ii||th(h)),_=null,m=h;;){if(m.tag===5||m.tag===26){if(_===null){ke=_=m;try{if(D=ke.stateNode,P)X=D.style,typeof X.setProperty=="function"?X.setProperty("display","none","important"):X.display="none";else{de=ke.stateNode;var ht=ke.memoizedProps.style,tt=ht!=null&&ht.hasOwnProperty("display")?ht.display:null;de.style.display=tt==null||typeof tt=="boolean"?"":(""+tt).trim()}}catch(It){Yn(ke,ke.return,It)}}}else if(m.tag===6){if(_===null){ke=m;try{ke.stateNode.nodeValue=P?"":ke.memoizedProps}catch(It){Yn(ke,ke.return,It)}}}else if(m.tag===18){if(_===null){ke=m;try{var st=ke.stateNode;P?nF(st,!0):nF(ke.stateNode,!1)}catch(It){Yn(ke,ke.return,It)}}}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:Ga(m,h),Wa(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,Qy(h,M)));break;case 30:break;case 21:break;default:Ga(m,h),Wa(h)}}function Wa(h){var m=h.flags;if(m&2){try{for(var _,M=h.return;M!==null;){if(i5(M)){_=M;break}M=M.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,D=Z2(h);Zy(h,D,P);break;case 5:var X=_.stateNode;_.flags&32&&(Zo(X,""),_.flags&=-33);var de=Z2(h);Zy(h,de,X);break;case 3:case 4:var ke=_.stateNode.containerInfo,Je=Z2(h);Q2(h,Je,ke);break;default:throw Error(r(161))}}catch(ut){Yn(h,h.return,ut)}h.flags&=-3}m&4096&&(h.flags&=-4097)}function f5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var m=h;f5(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;)o5(h,m.alternate,m),m=m.sibling}function th(h){for(h=h.child;h!==null;){var m=h;switch(m.tag){case 0:case 11:case 14:case 15:fu(4,m,m.return),th(m);break;case 1:el(m,m.return);var _=m.stateNode;typeof _.componentWillUnmount=="function"&&n5(m,m.return,_),th(m);break;case 27:lx(m.stateNode);case 26:case 5:el(m,m.return),th(m);break;case 22:m.memoizedState===null&&th(m);break;case 30:th(m);break;default:th(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,X=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(Je){Yn(M,M.return,Je)}if(M=D,P=M.updateQueue,P!==null){var de=M.stateNode;try{var ke=P.shared.hiddenCallbacks;if(ke!==null)for(P.shared.hiddenCallbacks=null,P=0;P<ke.length;P++)V4(ke[P],de)}catch(Je){Yn(M,M.return,Je)}}_&&X&64&&t5(D),Jg(D,D.return);break;case 27:a5(D);case 26:case 5:Zl(P,D,_),_&&M===null&&X&4&&r5(D),Jg(D,D.return);break;case 12:Zl(P,D,_);break;case 31:Zl(P,D,_),_&&X&4&&u5(P,D);break;case 13:Zl(P,D,_),_&&X&4&&d5(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 eA(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 tA(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;)m5(h,m,_,M),m=m.sibling}function m5(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,X=D.id,de=D.onPostCommit;typeof de=="function"&&de(X,m.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(ke){Yn(m,m.return,ke)}}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,X=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&&eA(X,m);break;case 24:Eo(h,m,_,M),P&2048&&tA(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,X=m,de=_,ke=M,Je=X.flags;switch(X.tag){case 0:case 11:case 15:Yf(D,X,de,ke,P),Qg(8,X);break;case 23:break;case 22:var ut=X.stateNode;X.memoizedState!==null?ut._visibility&2?Yf(D,X,de,ke,P):ex(D,X):(ut._visibility|=2,Yf(D,X,de,ke,P)),P&&Je&2048&&eA(X.alternate,X);break;case 24:Yf(D,X,de,ke,P),P&&Je&2048&&tA(X.alternate,X);break;default:Yf(D,X,de,ke,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&&eA(M.alternate,M);break;case 24:ex(_,M),P&2048&&tA(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;)p5(h,m,_),h=h.sibling}function p5(h,m,_){switch(h.tag){case 26:Zf(h,m,_),h.flags&tx&&h.memoizedState!==null&&Xre(_,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 g5(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[_];Di=M,b5(M,h)}g5(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)x5(h),h=h.sibling}function x5(h){switch(h.tag){case 0:case 11:case 15:nx(h),h.flags&2048&&fu(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[_];Di=M,b5(M,h)}g5(h)}for(h=h.child;h!==null;){switch(m=h,m.tag){case 0:case 11:case 15:fu(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 b5(h,m){for(;Di!==null;){var _=Di;switch(_.tag){case 0:case 11:case 15:fu(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=_,Di=M;else e:for(_=h;Di!==null;){M=Di;var P=M.sibling,D=M.return;if(l5(M),M===_){Di=null;break e}if(P!==null){P.return=D,Di=P;break e}Di=D}}}var ure={getCacheForType:function(h){var m=Zi(ti),_=m.data.get(h);return _===void 0&&(_=h(),m.data.set(h,_)),_},cacheSignal:function(){return Zi(ti).controller.signal}},dre=typeof WeakMap=="function"?WeakMap:Map,$n=0,hr=null,En=null,Pn=0,Xn=0,ps=null,mu=!1,Qf=!1,nA=!1,Ql=0,Br=0,pu=0,nh=0,rA=0,gs=0,Jf=0,rx=null,qa=null,iA=!1,ev=0,y5=0,tv=1/0,nv=null,gu=null,xi=0,xu=null,em=null,Jl=0,aA=0,sA=null,v5=null,ix=0,oA=null;function xs(){return($n&2)!==0&&Pn!==0?Pn&-Pn:K.T!==null?fA():mt()}function _5(){if(gs===0)if((Pn&536870912)===0||Dn){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 Ka(h,m,_){(h===hr&&(Xn===2||Xn===9)||h.cancelPendingCommit!==null)&&(tm(h,0),bu(h,Pn,gs,!1)),Qt(h,_),(($n&2)===0||h!==hr)&&(h===hr&&(($n&2)===0&&(nh|=_),Br===4&&bu(h,Pn,gs,!1)),tl(h))}function w5(h,m,_){if(($n&6)!==0)throw Error(r(327));var M=!_&&(m&127)===0&&(m&h.expiredLanes)===0||Ke(h,m),P=M?mre(h,m):cA(h,m,!0),D=M;do{if(P===0){Qf&&!M&&bu(h,m,0,!1);break}else{if(_=h.current.alternate,D&&!hre(_)){P=cA(h,m,!1),D=!1;continue}if(P===2){if(D=m,h.errorRecoveryDisabledLanes&D)var X=0;else X=h.pendingLanes&-536870913,X=X!==0?X:X&536870912?536870912:0;if(X!==0){m=X;e:{var de=h;P=rx;var ke=de.current.memoizedState.isDehydrated;if(ke&&(tm(de,X).flags|=256),X=cA(de,X,!1),X!==2){if(nA&&!ke){de.errorRecoveryDisabledLanes|=D,nh|=D,P=4;break e}D=qa,qa=P,D!==null&&(qa===null?qa=D:qa.push.apply(qa,D))}P=X}if(D=!1,P!==2)continue}}if(P===1){tm(h,0),bu(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:bu(M,m,gs,!mu);break e;case 2:qa=null;break;case 3:case 5:break;default:throw Error(r(329))}if((m&62914560)===m&&(P=ev+300-L(),10<P)){if(bu(M,m,gs,!mu),we(M,0,!0)!==0)break e;Jl=m,M.timeoutHandle=J5(S5.bind(null,M,_,qa,nv,iA,m,gs,nh,Jf,mu,D,"Throttled",-0,0),P);break e}S5(M,_,qa,nv,iA,m,gs,nh,Jf,mu,D,null,-0,0)}}break}while(!0);tl(h)}function S5(h,m,_,M,P,D,X,de,ke,Je,ut,ht,tt,st){if(h.timeoutHandle=-1,ht=m.subtreeFlags,ht&8192||(ht&16785408)===16785408){ht={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Fl},p5(m,D,ht);var It=(D&62914560)===D?ev-L():(D&4194048)===D?y5-L():0;if(It=Yre(ht,It),It!==null){Jl=D,h.cancelPendingCommit=It(P5.bind(null,h,m,D,_,M,P,X,de,ke,ut,ht,null,tt,st)),bu(h,D,X,!Je);return}}P5(h,m,D,_,M,P,X,de,ke)}function hre(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 bu(h,m,_,M){m&=~rA,m&=~nh,h.suspendedLanes|=m,h.pingedLanes&=~m,M&&(h.warmLanes|=m),M=h.expirationTimes;for(var P=m;0<P;){var D=31-Be(P),X=1<<D;M[D]=-1,P&=~X}_!==0&&hn(h,_,m)}function rv(){return($n&6)===0?(ax(0),!1):!0}function lA(){if(En!==null){if(Xn===0)var h=En.return;else h=En,Hl=qd=null,M2(h),Gf=null,Bg=0,h=En;for(;h!==null;)e5(h.alternate,h),h=h.return;En=null}}function tm(h,m){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,jre(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),Jl=0,lA(),hr=h,En=_=zl(h.current,null),Pn=m,Xn=0,ps=null,mu=!1,Qf=Ke(h,m),nA=!1,Jf=gs=rA=nh=pu=Br=0,qa=rx=null,iA=!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 M5(h,m){un=null,K.H=Xg,m===Vf||m===jy?(m=z4(),Xn=3):m===h2?(m=z4(),Xn=4):Xn=m===z2?8:m!==null&&typeof m=="object"&&typeof m.then=="function"?6:1,ps=m,En===null&&(Br=1,Wy(h,Is(m,h.current)))}function E5(){var h=fs.current;return h===null?!0:(Pn&4194048)===Pn?Bs===null:(Pn&62914560)===Pn||(Pn&536870912)!==0?h===Bs:!1}function A5(){var h=K.H;return K.H=Xg,h===null?Xg:h}function T5(){var h=K.A;return K.A=ure,h}function iv(){Br=4,mu||(Pn&4194048)!==Pn&&fs.current!==null||(Qf=!0),(pu&134217727)===0&&(nh&134217727)===0||hr===null||bu(hr,Pn,gs,!1)}function cA(h,m,_){var M=$n;$n|=2;var P=A5(),D=T5();(hr!==h||Pn!==m)&&(nv=null,tm(h,m)),m=!1;var X=Br;e:do try{if(Xn!==0&&En!==null){var de=En,ke=ps;switch(Xn){case 8:lA(),X=6;break e;case 3:case 2:case 9:case 6:fs.current===null&&(m=!0);var Je=Xn;if(Xn=0,ps=null,nm(h,de,ke,Je),_&&Qf){X=0;break e}break;default:Je=Xn,Xn=0,ps=null,nm(h,de,ke,Je)}}fre(),X=Br;break}catch(ut){M5(h,ut)}while(!0);return m&&h.shellSuspendCounter++,Hl=qd=null,$n=M,K.H=P,K.A=D,En===null&&(hr=null,Pn=0,My()),X}function fre(){for(;En!==null;)N5(En)}function mre(h,m){var _=$n;$n|=2;var M=A5(),P=T5();hr!==h||Pn!==m?(nv=null,tv=L()+500,tm(h,m)):Qf=Ke(h,m);e:do try{if(Xn!==0&&En!==null){m=En;var D=ps;t:switch(Xn){case 1:Xn=0,ps=null,nm(h,m,D,1);break;case 2:case 9:if(F4(D)){Xn=0,ps=null,C5(m);break}m=function(){Xn!==2&&Xn!==9||hr!==h||(Xn=7),tl(h)},D.then(m,m);break e;case 3:Xn=7;break e;case 4:Xn=5;break e;case 7:F4(D)?(Xn=0,ps=null,C5(m)):(Xn=0,ps=null,nm(h,m,D,7));break;case 5:var X=null;switch(En.tag){case 26:X=En.memoizedState;case 5:case 27:var de=En;if(X?mF(X):de.stateNode.complete){Xn=0,ps=null;var ke=de.sibling;if(ke!==null)En=ke;else{var Je=de.return;Je!==null?(En=Je,av(Je)):En=null}break t}}Xn=0,ps=null,nm(h,m,D,5);break;case 6:Xn=0,ps=null,nm(h,m,D,6);break;case 8:lA(),Br=6;break e;default:throw Error(r(462))}}pre();break}catch(ut){M5(h,ut)}while(!0);return Hl=qd=null,K.H=M,K.A=P,$n=_,En!==null?0:(hr=null,Pn=0,My(),Br)}function pre(){for(;En!==null&&!Se();)N5(En)}function N5(h){var m=QI(h.alternate,h,Ql);h.memoizedProps=h.pendingProps,m===null?av(h):En=m}function C5(h){var m=h,_=m.alternate;switch(m.tag){case 15:case 0:m=WI(_,m,m.pendingProps,m.type,void 0,Pn);break;case 11:m=WI(_,m,m.pendingProps,m.type.render,m.ref,Pn);break;case 5:M2(m);default:e5(_,m),m=En=T4(m,Ql),m=QI(_,m,Ql)}h.memoizedProps=h.pendingProps,m===null?av(h):En=m}function nm(h,m,_,M){Hl=qd=null,M2(m),Gf=null,Bg=0;var P=m.return;try{if(rre(h,P,m,_,Pn)){Br=1,Wy(h,Is(_,h.current)),En=null;return}}catch(D){if(P!==null)throw En=P,D;Br=1,Wy(h,Is(_,h.current)),En=null;return}m.flags&32768?(Dn||M===1?h=!0:Qf||(Pn&536870912)!==0?h=!1:(mu=h=!0,(M===2||M===9||M===3||M===6)&&(M=fs.current,M!==null&&M.tag===13&&(M.flags|=16384))),k5(m,h)):av(m)}function av(h){var m=h;do{if((m.flags&32768)!==0){k5(m,mu);return}h=m.return;var _=sre(m.alternate,m,Ql);if(_!==null){En=_;return}if(m=m.sibling,m!==null){En=m;return}En=m=h}while(m!==null);Br===0&&(Br=5)}function k5(h,m){do{var _=ore(h.alternate,h);if(_!==null){_.flags&=32767,En=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!m&&(h=h.sibling,h!==null)){En=h;return}En=h=_}while(h!==null);Br=6,En=null}function P5(h,m,_,M,P,D,X,de,ke){h.cancelPendingCommit=null;do sv();while(xi!==0);if(($n&6)!==0)throw Error(r(327));if(m!==null){if(m===h.current)throw Error(r(177));if(D=m.lanes|m.childLanes,D|=ZE,Ft(h,_,D,X,de,ke),h===hr&&(En=hr=null,Pn=0),em=m,xu=h,Jl=_,aA=D,sA=P,v5=M,(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,yre(be,function(){return L5(),null})):(h.callbackNode=null,h.callbackPriority=0),M=(m.flags&13878)!==0,(m.subtreeFlags&13878)!==0||M){M=K.T,K.T=null,P=G.p,G.p=2,X=$n,$n|=4;try{lre(h,m,_)}finally{$n=X,G.p=P,K.T=M}}xi=1,j5(),R5(),D5()}}function j5(){if(xi===1){xi=0;var h=xu,m=em,_=(m.flags&13878)!==0;if((m.subtreeFlags&13878)!==0||_){_=K.T,K.T=null;var M=G.p;G.p=2;var P=$n;$n|=4;try{h5(m,h);var D=_A,X=b4(h.containerInfo),de=D.focusedElem,ke=D.selectionRange;if(X!==de&&de&&de.ownerDocument&&x4(de.ownerDocument.documentElement,de)){if(ke!==null&&WE(de)){var Je=ke.start,ut=ke.end;if(ut===void 0&&(ut=Je),"selectionStart"in de)de.selectionStart=Je,de.selectionEnd=Math.min(ut,de.value.length);else{var ht=de.ownerDocument||document,tt=ht&&ht.defaultView||window;if(tt.getSelection){var st=tt.getSelection(),It=de.textContent.length,Xt=Math.min(ke.start,It),rr=ke.end===void 0?Xt:Math.min(ke.end,It);!st.extend&&Xt>rr&&(X=rr,rr=Xt,Xt=X);var $e=g4(de,Xt),Oe=g4(de,rr);if($e&&Oe&&(st.rangeCount!==1||st.anchorNode!==$e.node||st.anchorOffset!==$e.offset||st.focusNode!==Oe.node||st.focusOffset!==Oe.offset)){var Qe=ht.createRange();Qe.setStart($e.node,$e.offset),st.removeAllRanges(),Xt>rr?(st.addRange(Qe),st.extend(Oe.node,Oe.offset)):(Qe.setEnd(Oe.node,Oe.offset),st.addRange(Qe))}}}}for(ht=[],st=de;st=st.parentNode;)st.nodeType===1&&ht.push({element:st,left:st.scrollLeft,top:st.scrollTop});for(typeof de.focus=="function"&&de.focus(),de=0;de<ht.length;de++){var dt=ht[de];dt.element.scrollLeft=dt.left,dt.element.scrollTop=dt.top}}bv=!!vA,_A=vA=null}finally{$n=P,G.p=M,K.T=_}}h.current=m,xi=2}}function R5(){if(xi===2){xi=0;var h=xu,m=em,_=(m.flags&8772)!==0;if((m.subtreeFlags&8772)!==0||_){_=K.T,K.T=null;var M=G.p;G.p=2;var P=$n;$n|=4;try{o5(h,m.alternate,m)}finally{$n=P,G.p=M,K.T=_}}xi=3}}function D5(){if(xi===4||xi===3){xi=0,U();var h=xu,m=em,_=Jl,M=v5;(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?xi=5:(xi=0,em=xu=null,O5(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(gu=null),an(_),m=m.stateNode,ae&&typeof ae.onCommitFiberRoot=="function")try{ae.onCommitFiberRoot(me,m,void 0,(m.current.flags&128)===128)}catch{}if(M!==null){m=K.T,P=G.p,G.p=2,K.T=null;try{for(var D=h.onRecoverableError,X=0;X<M.length;X++){var de=M[X];D(de.value,{componentStack:de.stack})}}finally{K.T=m,G.p=P}}(Jl&3)!==0&&sv(),tl(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===oA?ix++:(ix=0,oA=h):ix=0,ax(0)}}function O5(h,m){(h.pooledCacheLanes&=m)===0&&(m=h.pooledCache,m!=null&&(h.pooledCache=null,Ug(m)))}function sv(){return j5(),R5(),D5(),L5()}function L5(){if(xi!==5)return!1;var h=xu,m=aA;aA=0;var _=an(Jl),M=K.T,P=G.p;try{G.p=32>_?32:_,K.T=null,_=sA,sA=null;var D=xu,X=Jl;if(xi=0,em=xu=null,Jl=0,($n&6)!==0)throw Error(r(331));var de=$n;if($n|=4,x5(D.current),m5(D,D.current,X,_),$n=de,ax(0,!1),ae&&typeof ae.onPostCommitFiberRoot=="function")try{ae.onPostCommitFiberRoot(me,D)}catch{}return!0}finally{G.p=P,K.T=M,O5(h,m)}}function I5(h,m,_){m=Is(_,m),m=U2(h.stateNode,m,2),h=uu(h,m,2),h!==null&&(Qt(h,2),tl(h))}function Yn(h,m,_){if(h.tag===3)I5(h,h,_);else for(;m!==null;){if(m.tag===3){I5(m,h,_);break}else if(m.tag===1){var M=m.stateNode;if(typeof m.type.getDerivedStateFromError=="function"||typeof M.componentDidCatch=="function"&&(gu===null||!gu.has(M))){h=Is(_,h),_=FI(2),M=uu(m,_,2),M!==null&&(UI(_,M,m,h),Qt(M,2),tl(M));break}}m=m.return}}function uA(h,m,_){var M=h.pingCache;if(M===null){M=h.pingCache=new dre;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(_)||(nA=!0,P.add(_),h=gre.bind(null,h,m,_),m.then(h,h))}function gre(h,m,_){var M=h.pingCache;M!==null&&M.delete(m),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,hr===h&&(Pn&_)===_&&(Br===4||Br===3&&(Pn&62914560)===Pn&&300>L()-ev?($n&2)===0&&tm(h,0):rA|=_,Jf===Pn&&(Jf=0)),tl(h)}function F5(h,m){m===0&&(m=Et()),h=Vd(h,m),h!==null&&(Qt(h,m),tl(h))}function xre(h){var m=h.memoizedState,_=0;m!==null&&(_=m.retryLane),F5(h,_)}function bre(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),F5(h,_)}function yre(h,m){return ve(h,m)}var ov=null,rm=null,dA=!1,lv=!1,hA=!1,yu=0;function tl(h){h!==rm&&h.next===null&&(rm===null?ov=rm=h:rm=rm.next=h),lv=!0,dA||(dA=!0,_re())}function ax(h,m){if(!hA&&lv){hA=!0;do for(var _=!1,M=ov;M!==null;){if(h!==0){var P=M.pendingLanes;if(P===0)var D=0;else{var X=M.suspendedLanes,de=M.pingedLanes;D=(1<<31-Be(42|h)+1)-1,D&=P&~(X&~de),D=D&201326741?D&201326741|1:D?D|2:0}D!==0&&(_=!0,H5(M,D))}else D=Pn,D=we(M,M===hr?D:0,M.cancelPendingCommit!==null||M.timeoutHandle!==-1),(D&3)===0||Ke(M,D)||(_=!0,H5(M,D));M=M.next}while(_);hA=!1}}function vre(){U5()}function U5(){lv=dA=!1;var h=0;yu!==0&&Pre()&&(h=yu);for(var m=L(),_=null,M=ov;M!==null;){var P=M.next,D=z5(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}xi!==0&&xi!==5||ax(h),yu!==0&&(yu=0)}function z5(h,m){for(var _=h.suspendedLanes,M=h.pingedLanes,P=h.expirationTimes,D=h.pendingLanes&-62914561;0<D;){var X=31-Be(D),de=1<<X,ke=P[X];ke===-1?((de&_)===0||(de&M)!==0)&&(P[X]=ft(de,m)):ke<=m&&(h.expiredLanes|=de),D&=~de}if(m=hr,_=Pn,_=we(h,h===m?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M=h.callbackNode,_===0||h===m&&(Xn===2||Xn===9)||h.cancelPendingCommit!==null)return M!==null&&M!==null&&Ne(M),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||Ke(h,_)){if(m=_&-_,m===h.callbackPriority)return m;switch(M!==null&&Ne(M),an(_)){case 2:case 8:_=Me;break;case 32:_=be;break;case 268435456:_=Ve;break;default:_=be}return M=B5.bind(null,h),_=ve(_,M),h.callbackPriority=m,h.callbackNode=_,m}return M!==null&&M!==null&&Ne(M),h.callbackPriority=2,h.callbackNode=null,2}function B5(h,m){if(xi!==0&&xi!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(sv()&&h.callbackNode!==_)return null;var M=Pn;return M=we(h,h===hr?M:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M===0?null:(w5(h,M,m),z5(h,L()),h.callbackNode!=null&&h.callbackNode===_?B5.bind(null,h):null)}function H5(h,m){if(sv())return null;w5(h,m,!0)}function _re(){Rre(function(){($n&6)!==0?ve(ye,vre):U5()})}function fA(){if(yu===0){var h=Hf;h===0&&(h=nt,nt<<=1,(nt&261888)===0&&(nt=256)),yu=h}return yu}function $5(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:gy(""+h)}function V5(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 wre(h,m,_,M,P){if(m==="submit"&&_&&_.stateNode===P){var D=$5((P[_n]||null).action),X=M.submitter;X&&(m=(m=X[_n]||null)?$5(m.formAction):X.getAttribute("formAction"),m!==null&&(D=m,X=null));var de=new vy("action","action",null,M,P);h.push({event:de,listeners:[{instance:null,listener:function(){if(M.defaultPrevented){if(yu!==0){var ke=X?V5(P,X):new FormData(P);R2(_,{pending:!0,data:ke,method:P.method,action:D},null,ke)}}else typeof D=="function"&&(de.preventDefault(),ke=X?V5(P,X):new FormData(P),R2(_,{pending:!0,data:ke,method:P.method,action:D},D,ke))},currentTarget:P}]})}}for(var mA=0;mA<YE.length;mA++){var pA=YE[mA],Sre=pA.toLowerCase(),Mre=pA[0].toUpperCase()+pA.slice(1);So(Sre,"on"+Mre)}So(_4,"onAnimationEnd"),So(w4,"onAnimationIteration"),So(S4,"onAnimationStart"),So("dblclick","onDoubleClick"),So("focusin","onFocus"),So("focusout","onBlur"),So(zne,"onTransitionRun"),So(Bne,"onTransitionStart"),So(Hne,"onTransitionCancel"),So(M4,"onTransitionEnd"),Ct("onMouseEnter",["mouseout","mouseover"]),Ct("onMouseLeave",["mouseout","mouseover"]),Ct("onPointerEnter",["pointerout","pointerover"]),Ct("onPointerLeave",["pointerout","pointerover"]),yt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),yt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),yt("onBeforeInput",["compositionend","keypress","textInput","paste"]),yt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),yt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),yt("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(" "),Ere=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(sx));function G5(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 X=M.length-1;0<=X;X--){var de=M[X],ke=de.instance,Je=de.currentTarget;if(de=de.listener,ke!==D&&P.isPropagationStopped())break e;D=de,P.currentTarget=Je;try{D(P)}catch(ut){Sy(ut)}P.currentTarget=null,D=ke}else for(X=0;X<M.length;X++){if(de=M[X],ke=de.instance,Je=de.currentTarget,de=de.listener,ke!==D&&P.isPropagationStopped())break e;D=de,P.currentTarget=Je;try{D(P)}catch(ut){Sy(ut)}P.currentTarget=null,D=ke}}}}function An(h,m){var _=m[Ce];_===void 0&&(_=m[Ce]=new Set);var M=h+"__bubble";_.has(M)||(W5(m,h,2,!1),_.add(M))}function gA(h,m,_){var M=0;m&&(M|=4),W5(_,h,M,m)}var cv="_reactListening"+Math.random().toString(36).slice(2);function xA(h){if(!h[cv]){h[cv]=!0,je.forEach(function(_){_!=="selectionchange"&&(Ere.has(_)||gA(_,!1,h),gA(_,!0,h))});var m=h.nodeType===9?h:h.ownerDocument;m===null||m[cv]||(m[cv]=!0,gA("selectionchange",!1,m))}}function W5(h,m,_,M){switch(_F(m)){case 2:var P=Jre;break;case 8:P=eie;break;default:P=jA}_=P.bind(null,m,_,h),P=void 0,!IE||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 bA(h,m,_,M,P){var D=M;if((m&1)===0&&(m&2)===0&&M!==null)e:for(;;){if(M===null)return;var X=M.tag;if(X===3||X===4){var de=M.stateNode.containerInfo;if(de===P)break;if(X===4)for(X=M.return;X!==null;){var ke=X.tag;if((ke===3||ke===4)&&X.stateNode.containerInfo===P)return;X=X.return}for(;de!==null;){if(X=gt(de),X===null)return;if(ke=X.tag,ke===5||ke===6||ke===26||ke===27){M=D=X;continue e}de=de.parentNode}}M=M.return}ZL(function(){var Je=D,ut=OE(_),ht=[];e:{var tt=E4.get(h);if(tt!==void 0){var st=vy,It=h;switch(h){case"keypress":if(by(_)===0)break e;case"keydown":case"keyup":st=bne;break;case"focusin":It="focus",st=BE;break;case"focusout":It="blur",st=BE;break;case"beforeblur":case"afterblur":st=BE;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":st=e4;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":st=sne;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":st=_ne;break;case _4:case w4:case S4:st=cne;break;case M4:st=Sne;break;case"scroll":case"scrollend":st=ine;break;case"wheel":st=Ene;break;case"copy":case"cut":case"paste":st=dne;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":st=n4;break;case"toggle":case"beforetoggle":st=Tne}var Xt=(m&4)!==0,rr=!Xt&&(h==="scroll"||h==="scrollend"),$e=Xt?tt!==null?tt+"Capture":null:tt;Xt=[];for(var Oe=Je,Qe;Oe!==null;){var dt=Oe;if(Qe=dt.stateNode,dt=dt.tag,dt!==5&&dt!==26&&dt!==27||Qe===null||$e===null||(dt=Ng(Oe,$e),dt!=null&&Xt.push(ox(Oe,dt,Qe))),rr)break;Oe=Oe.return}0<Xt.length&&(tt=new st(tt,It,null,_,ut),ht.push({event:tt,listeners:Xt}))}}if((m&7)===0){e:{if(tt=h==="mouseover"||h==="pointerover",st=h==="mouseout"||h==="pointerout",tt&&_!==DE&&(It=_.relatedTarget||_.fromElement)&&(gt(It)||It[wn]))break e;if((st||tt)&&(tt=ut.window===ut?ut:(tt=ut.ownerDocument)?tt.defaultView||tt.parentWindow:window,st?(It=_.relatedTarget||_.toElement,st=Je,It=It?gt(It):null,It!==null&&(rr=a(It),Xt=It.tag,It!==rr||Xt!==5&&Xt!==27&&Xt!==6)&&(It=null)):(st=null,It=Je),st!==It)){if(Xt=e4,dt="onMouseLeave",$e="onMouseEnter",Oe="mouse",(h==="pointerout"||h==="pointerover")&&(Xt=n4,dt="onPointerLeave",$e="onPointerEnter",Oe="pointer"),rr=st==null?tt:Te(st),Qe=It==null?tt:Te(It),tt=new Xt(dt,Oe+"leave",st,_,ut),tt.target=rr,tt.relatedTarget=Qe,dt=null,gt(ut)===Je&&(Xt=new Xt($e,Oe+"enter",It,_,ut),Xt.target=Qe,Xt.relatedTarget=rr,dt=Xt),rr=dt,st&&It)t:{for(Xt=Are,$e=st,Oe=It,Qe=0,dt=$e;dt;dt=Xt(dt))Qe++;dt=0;for(var Vt=Oe;Vt;Vt=Xt(Vt))dt++;for(;0<Qe-dt;)$e=Xt($e),Qe--;for(;0<dt-Qe;)Oe=Xt(Oe),dt--;for(;Qe--;){if($e===Oe||Oe!==null&&$e===Oe.alternate){Xt=$e;break t}$e=Xt($e),Oe=Xt(Oe)}Xt=null}else Xt=null;st!==null&&q5(ht,tt,st,Xt,!1),It!==null&&rr!==null&&q5(ht,rr,It,Xt,!0)}}e:{if(tt=Je?Te(Je):window,st=tt.nodeName&&tt.nodeName.toLowerCase(),st==="select"||st==="input"&&tt.type==="file")var Fn=u4;else if(l4(tt))if(d4)Fn=Ine;else{Fn=One;var zt=Dne}else st=tt.nodeName,!st||st.toLowerCase()!=="input"||tt.type!=="checkbox"&&tt.type!=="radio"?Je&&RE(Je.elementType)&&(Fn=u4):Fn=Lne;if(Fn&&(Fn=Fn(h,Je))){c4(ht,Fn,_,ut);break e}zt&&zt(h,tt,Je),h==="focusout"&&Je&&tt.type==="number"&&Je.memoizedProps.value!=null&&ji(tt,"number",tt.value)}switch(zt=Je?Te(Je):window,h){case"focusin":(l4(zt)||zt.contentEditable==="true")&&(Df=zt,qE=Je,Lg=null);break;case"focusout":Lg=qE=Df=null;break;case"mousedown":KE=!0;break;case"contextmenu":case"mouseup":case"dragend":KE=!1,y4(ht,_,ut);break;case"selectionchange":if(Une)break;case"keydown":case"keyup":y4(ht,_,ut)}var fn;if($E)e:{switch(h){case"compositionstart":var jn="onCompositionStart";break e;case"compositionend":jn="onCompositionEnd";break e;case"compositionupdate":jn="onCompositionUpdate";break e}jn=void 0}else Rf?s4(h,_)&&(jn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(jn="onCompositionStart");jn&&(r4&&_.locale!=="ko"&&(Rf||jn!=="onCompositionStart"?jn==="onCompositionEnd"&&Rf&&(fn=QL()):(ru=ut,FE="value"in ru?ru.value:ru.textContent,Rf=!0)),zt=uv(Je,jn),0<zt.length&&(jn=new t4(jn,h,null,_,ut),ht.push({event:jn,listeners:zt}),fn?jn.data=fn:(fn=o4(_),fn!==null&&(jn.data=fn)))),(fn=Cne?kne(h,_):Pne(h,_))&&(jn=uv(Je,"onBeforeInput"),0<jn.length&&(zt=new t4("onBeforeInput","beforeinput",null,_,ut),ht.push({event:zt,listeners:jn}),zt.data=fn)),wre(ht,h,Je,_,ut)}G5(ht,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 Are(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function q5(h,m,_,M,P){for(var D=m._reactName,X=[];_!==null&&_!==M;){var de=_,ke=de.alternate,Je=de.stateNode;if(de=de.tag,ke!==null&&ke===M)break;de!==5&&de!==26&&de!==27||Je===null||(ke=Je,P?(Je=Ng(_,D),Je!=null&&X.unshift(ox(_,Je,ke))):P||(Je=Ng(_,D),Je!=null&&X.push(ox(_,Je,ke)))),_=_.return}X.length!==0&&h.push({event:m,listeners:X})}var Tre=/\r\n?/g,Nre=/\u0000|\uFFFD/g;function K5(h){return(typeof h=="string"?h:""+h).replace(Tre,`
  9. `).replace(Nre,"")}function X5(h,m){return m=K5(m),K5(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":$t(h,"class",M);break;case"tabIndex":$t(h,"tabindex",M);break;case"dir":case"role":case"viewBox":case"width":case"height":$t(h,_,M);break;case"style":XL(h,M,D);break;case"data":if(m!=="object"){$t(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&&An("scroll",h);break;case"onScrollEnd":M!=null&&An("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":An("beforetoggle",h),An("toggle",h),tn(h,"popover",M);break;case"xlinkActuate":mn(h,"http://www.w3.org/1999/xlink","xlink:actuate",M);break;case"xlinkArcrole":mn(h,"http://www.w3.org/1999/xlink","xlink:arcrole",M);break;case"xlinkRole":mn(h,"http://www.w3.org/1999/xlink","xlink:role",M);break;case"xlinkShow":mn(h,"http://www.w3.org/1999/xlink","xlink:show",M);break;case"xlinkTitle":mn(h,"http://www.w3.org/1999/xlink","xlink:title",M);break;case"xlinkType":mn(h,"http://www.w3.org/1999/xlink","xlink:type",M);break;case"xmlBase":mn(h,"http://www.w3.org/XML/1998/namespace","xml:base",M);break;case"xmlLang":mn(h,"http://www.w3.org/XML/1998/namespace","xml:lang",M);break;case"xmlSpace":mn(h,"http://www.w3.org/XML/1998/namespace","xml:space",M);break;case"is":tn(h,"is",M);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=nne.get(_)||_,tn(h,_,M))}}function yA(h,m,_,M,P,D){switch(_){case"style":XL(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&&An("scroll",h);break;case"onScrollEnd":M!=null&&An("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[_n]||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(_,""):tn(h,_,M)}}}function Ji(h,m,_){switch(m){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":An("error",h),An("load",h);var M=!1,P=!1,D;for(D in _)if(_.hasOwnProperty(D)){var X=_[D];if(X!=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,X,_,null)}}P&&nr(h,m,"srcSet",_.srcSet,_,null),M&&nr(h,m,"src",_.src,_,null);return;case"input":An("invalid",h);var de=D=X=P=null,ke=null,Je=null;for(M in _)if(_.hasOwnProperty(M)){var ut=_[M];if(ut!=null)switch(M){case"name":P=ut;break;case"type":X=ut;break;case"checked":ke=ut;break;case"defaultChecked":Je=ut;break;case"value":D=ut;break;case"defaultValue":de=ut;break;case"children":case"dangerouslySetInnerHTML":if(ut!=null)throw Error(r(137,m));break;default:nr(h,m,M,ut,_,null)}}Kn(h,D,de,ke,Je,X,P,!1);return;case"select":An("invalid",h),M=X=D=null;for(P in _)if(_.hasOwnProperty(P)&&(de=_[P],de!=null))switch(P){case"value":D=de;break;case"defaultValue":X=de;break;case"multiple":M=de;default:nr(h,m,P,de,_,null)}m=D,_=X,h.multiple=!!M,m!=null?gi(h,!!M,m,!1):_!=null&&gi(h,!!M,_,!0);return;case"textarea":An("invalid",h),D=P=M=null;for(X in _)if(_.hasOwnProperty(X)&&(de=_[X],de!=null))switch(X){case"value":M=de;break;case"defaultValue":P=de;break;case"children":D=de;break;case"dangerouslySetInnerHTML":if(de!=null)throw Error(r(91));break;default:nr(h,m,X,de,_,null)}Xi(h,M,P,D);return;case"option":for(ke in _)if(_.hasOwnProperty(ke)&&(M=_[ke],M!=null))switch(ke){case"selected":h.selected=M&&typeof M!="function"&&typeof M!="symbol";break;default:nr(h,m,ke,M,_,null)}return;case"dialog":An("beforetoggle",h),An("toggle",h),An("cancel",h),An("close",h);break;case"iframe":case"object":An("load",h);break;case"video":case"audio":for(M=0;M<sx.length;M++)An(sx[M],h);break;case"image":An("error",h),An("load",h);break;case"details":An("toggle",h);break;case"embed":case"source":case"link":An("error",h),An("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(Je in _)if(_.hasOwnProperty(Je)&&(M=_[Je],M!=null))switch(Je){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,m));default:nr(h,m,Je,M,_,null)}return;default:if(RE(m)){for(ut in _)_.hasOwnProperty(ut)&&(M=_[ut],M!==void 0&&yA(h,m,ut,M,_,void 0));return}}for(de in _)_.hasOwnProperty(de)&&(M=_[de],M!=null&&nr(h,m,de,M,_,null))}function Cre(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,X=null,de=null,ke=null,Je=null,ut=null;for(st in _){var ht=_[st];if(_.hasOwnProperty(st)&&ht!=null)switch(st){case"checked":break;case"value":break;case"defaultValue":ke=ht;default:M.hasOwnProperty(st)||nr(h,m,st,null,M,ht)}}for(var tt in M){var st=M[tt];if(ht=_[tt],M.hasOwnProperty(tt)&&(st!=null||ht!=null))switch(tt){case"type":D=st;break;case"name":P=st;break;case"checked":Je=st;break;case"defaultChecked":ut=st;break;case"value":X=st;break;case"defaultValue":de=st;break;case"children":case"dangerouslySetInnerHTML":if(st!=null)throw Error(r(137,m));break;default:st!==ht&&nr(h,m,tt,st,M,ht)}}wo(h,X,de,ke,Je,ut,D,P);return;case"select":st=X=de=tt=null;for(D in _)if(ke=_[D],_.hasOwnProperty(D)&&ke!=null)switch(D){case"value":break;case"multiple":st=ke;default:M.hasOwnProperty(D)||nr(h,m,D,null,M,ke)}for(P in M)if(D=M[P],ke=_[P],M.hasOwnProperty(P)&&(D!=null||ke!=null))switch(P){case"value":tt=D;break;case"defaultValue":de=D;break;case"multiple":X=D;default:D!==ke&&nr(h,m,P,D,M,ke)}m=de,_=X,M=st,tt!=null?gi(h,!!_,tt,!1):!!M!=!!_&&(m!=null?gi(h,!!_,m,!0):gi(h,!!_,_?[]:"",!1));return;case"textarea":st=tt=null;for(de in _)if(P=_[de],_.hasOwnProperty(de)&&P!=null&&!M.hasOwnProperty(de))switch(de){case"value":break;case"children":break;default:nr(h,m,de,null,M,P)}for(X in M)if(P=M[X],D=_[X],M.hasOwnProperty(X)&&(P!=null||D!=null))switch(X){case"value":tt=P;break;case"defaultValue":st=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==D&&nr(h,m,X,P,M,D)}Ri(h,tt,st);return;case"option":for(var It in _)if(tt=_[It],_.hasOwnProperty(It)&&tt!=null&&!M.hasOwnProperty(It))switch(It){case"selected":h.selected=!1;break;default:nr(h,m,It,null,M,tt)}for(ke in M)if(tt=M[ke],st=_[ke],M.hasOwnProperty(ke)&&tt!==st&&(tt!=null||st!=null))switch(ke){case"selected":h.selected=tt&&typeof tt!="function"&&typeof tt!="symbol";break;default:nr(h,m,ke,tt,M,st)}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 _)tt=_[Xt],_.hasOwnProperty(Xt)&&tt!=null&&!M.hasOwnProperty(Xt)&&nr(h,m,Xt,null,M,tt);for(Je in M)if(tt=M[Je],st=_[Je],M.hasOwnProperty(Je)&&tt!==st&&(tt!=null||st!=null))switch(Je){case"children":case"dangerouslySetInnerHTML":if(tt!=null)throw Error(r(137,m));break;default:nr(h,m,Je,tt,M,st)}return;default:if(RE(m)){for(var rr in _)tt=_[rr],_.hasOwnProperty(rr)&&tt!==void 0&&!M.hasOwnProperty(rr)&&yA(h,m,rr,void 0,M,tt);for(ut in M)tt=M[ut],st=_[ut],!M.hasOwnProperty(ut)||tt===st||tt===void 0&&st===void 0||yA(h,m,ut,tt,M,st);return}}for(var $e in _)tt=_[$e],_.hasOwnProperty($e)&&tt!=null&&!M.hasOwnProperty($e)&&nr(h,m,$e,null,M,tt);for(ht in M)tt=M[ht],st=_[ht],!M.hasOwnProperty(ht)||tt===st||tt==null&&st==null||nr(h,m,ht,tt,M,st)}function Y5(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function kre(){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,X=P.initiatorType,de=P.duration;if(D&&de&&Y5(X)){for(X=0,de=P.responseEnd,M+=1;M<_.length;M++){var ke=_[M],Je=ke.startTime;if(Je>de)break;var ut=ke.transferSize,ht=ke.initiatorType;ut&&Y5(ht)&&(ke=ke.responseEnd,X+=ut*(ke<de?1:(de-Je)/(ke-Je)))}if(--M,m+=8*(D+X)/(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 vA=null,_A=null;function dv(h){return h.nodeType===9?h:h.ownerDocument}function Z5(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 Q5(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 wA(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 SA=null;function Pre(){var h=window.event;return h&&h.type==="popstate"?h===SA?!1:(SA=h,!0):(SA=null,!1)}var J5=typeof setTimeout=="function"?setTimeout:void 0,jre=typeof clearTimeout=="function"?clearTimeout:void 0,eF=typeof Promise=="function"?Promise:void 0,Rre=typeof queueMicrotask=="function"?queueMicrotask:typeof eF<"u"?function(h){return eF.resolve(null).then(h).catch(Dre)}:J5;function Dre(h){setTimeout(function(){throw h})}function vu(h){return h==="head"}function tF(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 X=D.nextSibling,de=D.nodeName;D[rt]||de==="SCRIPT"||de==="STYLE"||de==="LINK"&&D.rel.toLowerCase()==="stylesheet"||_.removeChild(D),D=X}}else _==="body"&&lx(h.ownerDocument.body);_=P}while(_);om(m)}function nF(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 MA(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":MA(_),et(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function Ore(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[rt])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=Hs(h.nextSibling),h===null)break}return null}function Lre(h,m,_){if(m==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=Hs(h.nextSibling),h===null))return null;return h}function rF(h,m){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!m||(h=Hs(h.nextSibling),h===null))return null;return h}function EA(h){return h.data==="$?"||h.data==="$~"}function AA(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function Ire(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 Hs(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 TA=null;function iF(h){h=h.nextSibling;for(var m=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(m===0)return Hs(h.nextSibling);m--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||m++}h=h.nextSibling}return null}function aF(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 sF(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]);et(h)}var $s=new Map,oF=new Set;function hv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var ec=G.d;G.d={f:Fre,r:Ure,D:zre,C:Bre,L:Hre,m:$re,X:Gre,S:Vre,M:Wre};function Fre(){var h=ec.f(),m=rv();return h||m}function Ure(h){var m=re(h);m!==null&&m.tag===5&&m.type==="form"?MI(m):ec.r(h)}var im=typeof document>"u"?null:document;function lF(h,m,_){var M=im;if(M&&typeof m=="string"&&m){var P=Gn(m);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),oF.has(P)||(oF.add(P),h={rel:h,crossOrigin:_,href:m},M.querySelector(P)===null&&(m=M.createElement("link"),Ji(m,"link",h),De(m),M.head.appendChild(m)))}}function zre(h){ec.D(h),lF("dns-prefetch",h,null)}function Bre(h,m){ec.C(h,m),lF("preconnect",h,m)}function Hre(h,m,_){ec.L(h,m,_);var M=im;if(M&&h&&m){var P='link[rel="preload"][as="'+Gn(m)+'"]';m==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+Gn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+Gn(_.imageSizes)+'"]')):P+='[href="'+Gn(h)+'"]';var D=P;switch(m){case"style":D=am(h);break;case"script":D=sm(h)}$s.has(D)||(h=f({rel:"preload",href:m==="image"&&_&&_.imageSrcSet?void 0:h,as:m},_),$s.set(D,h),M.querySelector(P)!==null||m==="style"&&M.querySelector(cx(D))||m==="script"&&M.querySelector(ux(D))||(m=M.createElement("link"),Ji(m,"link",h),De(m),M.head.appendChild(m)))}}function $re(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="'+Gn(M)+'"][href="'+Gn(h)+'"]',D=P;switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":D=sm(h)}if(!$s.has(D)&&(h=f({rel:"modulepreload",href:h},m),$s.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"),Ji(M,"link",h),De(M),_.head.appendChild(M)}}}function Vre(h,m,_){ec.S(h,m,_);var M=im;if(M&&h){var P=Ie(M).hoistableStyles,D=am(h);m=m||"default";var X=P.get(D);if(!X){var de={loading:0,preload:null};if(X=M.querySelector(cx(D)))de.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":m},_),(_=$s.get(D))&&NA(h,_);var ke=X=M.createElement("link");De(ke),Ji(ke,"link",h),ke._p=new Promise(function(Je,ut){ke.onload=Je,ke.onerror=ut}),ke.addEventListener("load",function(){de.loading|=1}),ke.addEventListener("error",function(){de.loading|=2}),de.loading|=4,fv(X,m,M)}X={type:"stylesheet",instance:X,count:1,state:de},P.set(D,X)}}}function Gre(h,m){ec.X(h,m);var _=im;if(_&&h){var M=Ie(_).hoistableScripts,P=sm(h),D=M.get(P);D||(D=_.querySelector(ux(P)),D||(h=f({src:h,async:!0},m),(m=$s.get(P))&&CA(h,m),D=_.createElement("script"),De(D),Ji(D,"link",h),_.head.appendChild(D)),D={type:"script",instance:D,count:1,state:null},M.set(P,D))}}function Wre(h,m){ec.M(h,m);var _=im;if(_&&h){var M=Ie(_).hoistableScripts,P=sm(h),D=M.get(P);D||(D=_.querySelector(ux(P)),D||(h=f({src:h,async:!0,type:"module"},m),(m=$s.get(P))&&CA(h,m),D=_.createElement("script"),De(D),Ji(D,"link",h),_.head.appendChild(D)),D={type:"script",instance:D,count:1,state:null},M.set(P,D))}}function cF(h,m,_,M){var P=(P=pe.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),_=Ie(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=Ie(P).hoistableStyles,X=D.get(h);if(X||(P=P.ownerDocument||P,X={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},D.set(h,X),(D=P.querySelector(cx(h)))&&!D._p&&(X.instance=D,X.state.loading=5),$s.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},$s.set(h,_),D||qre(P,h,_,X.state))),m&&M===null)throw Error(r(528,""));return X}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(_),_=Ie(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="'+Gn(h)+'"'}function cx(h){return'link[rel="stylesheet"]['+h+"]"}function uF(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function qre(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}),Ji(m,"link",_),De(m),h.head.appendChild(m))}function sm(h){return'[src="'+Gn(h)+'"]'}function ux(h){return"script[async]"+h}function dF(h,m,_){if(m.count++,m.instance===null)switch(m.type){case"style":var M=h.querySelector('style[data-href~="'+Gn(_.href)+'"]');if(M)return m.instance=M,De(M),M;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return M=(h.ownerDocument||h).createElement("style"),De(M),Ji(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,De(D),D;M=uF(_),(P=$s.get(P))&&NA(M,P),D=(h.ownerDocument||h).createElement("link"),De(D);var X=D;return X._p=new Promise(function(de,ke){X.onload=de,X.onerror=ke}),Ji(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,De(P),P):(M=_,(P=$s.get(D))&&(M=f({},_),CA(M,P)),h=h.ownerDocument||h,P=h.createElement("script"),De(P),Ji(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,X=0;X<M.length;X++){var de=M[X];if(de.dataset.precedence===m)D=de;else if(D!==P)break}D?D.parentNode.insertBefore(h,D.nextSibling):(m=_.nodeType===9?_.head:_,m.insertBefore(h,m.firstChild))}function NA(h,m){h.crossOrigin==null&&(h.crossOrigin=m.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=m.referrerPolicy),h.title==null&&(h.title=m.title)}function CA(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 hF(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[rt]||D[Yt]||h==="link"&&D.getAttribute("rel")==="stylesheet")&&D.namespaceURI!=="http://www.w3.org/2000/svg"){var X=D.getAttribute(m)||"";X=h+X;var de=M.get(X);de?de.push(D):M.set(X,[D])}}return M}function fF(h,m,_){h=h.ownerDocument||h,h.head.insertBefore(_,m==="title"?h.querySelector("head > title"):null)}function Kre(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 mF(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function Xre(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,De(D);return}D=m.ownerDocument||m,M=uF(M),(P=$s.get(P))&&NA(M,P),D=D.createElement("link"),De(D);var X=D;X._p=new Promise(function(de,ke){X.onload=de,X.onerror=ke}),Ji(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 kA=0;function Yre(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&&kA===0&&(kA=62500*kre());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>kA?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(Zre,h),gv=null,pv.call(h))}function Zre(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 X=P[D];(X.nodeName==="LINK"||X.getAttribute("media")!=="not all")&&(_.set(X.dataset.precedence,X),M=X)}M&&_.set(null,M)}P=m.instance,X=P.getAttribute("data-precedence"),D=_.get(X)||M,D===M&&_.set(null,P),_.set(X,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 Qre(h,m,_,M,P,D,X,de,ke){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=wt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=wt(0),this.hiddenUpdates=wt(null),this.identifierPrefix=M,this.onUncaughtError=P,this.onCaughtError=D,this.onRecoverableError=X,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ke,this.incompleteTransitions=new Map}function pF(h,m,_,M,P,D,X,de,ke,Je,ut,ht){return h=new Qre(h,m,_,X,ke,Je,ut,ht,de),m=1,D===!0&&(m|=24),D=hs(3,null,null,m),h.current=D,D.stateNode=h,m=c2(),m.refCount++,h.pooledCache=m,m.refCount++,D.memoizedState={element:M,isDehydrated:_,cache:m},f2(D),h}function gF(h){return h?(h=If,h):If}function xF(h,m,_,M,P,D){P=gF(P),M.context===null?M.context=P:M.pendingContext=P,M=cu(m),M.payload={element:_},D=D===void 0?null:D,D!==null&&(M.callback=D),_=uu(h,M,m),_!==null&&(Ka(_,h,m),$g(_,h,m))}function bF(h,m){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<m?_:m}}function PA(h,m){bF(h,m),(h=h.alternate)&&bF(h,m)}function yF(h){if(h.tag===13||h.tag===31){var m=Vd(h,67108864);m!==null&&Ka(m,h,67108864),PA(h,67108864)}}function vF(h){if(h.tag===13||h.tag===31){var m=xs();m=Ht(m);var _=Vd(h,m);_!==null&&Ka(_,h,m),PA(h,m)}}var bv=!0;function Jre(h,m,_,M){var P=K.T;K.T=null;var D=G.p;try{G.p=2,jA(h,m,_,M)}finally{G.p=D,K.T=P}}function eie(h,m,_,M){var P=K.T;K.T=null;var D=G.p;try{G.p=8,jA(h,m,_,M)}finally{G.p=D,K.T=P}}function jA(h,m,_,M){if(bv){var P=RA(M);if(P===null)bA(h,m,M,yv,_),wF(h,M);else if(nie(P,h,m,_,M))M.stopPropagation();else if(wF(h,M),m&4&&-1<tie.indexOf(h)){for(;P!==null;){var D=re(P);if(D!==null)switch(D.tag){case 3:if(D=D.stateNode,D.current.memoizedState.isDehydrated){var X=Re(D.pendingLanes);if(X!==0){var de=D;for(de.pendingLanes|=2,de.entangledLanes|=2;X;){var ke=1<<31-Be(X);de.entanglements[1]|=ke,X&=~ke}tl(D),($n&6)===0&&(tv=L()+500,ax(0))}}break;case 31:case 13:de=Vd(D,2),de!==null&&Ka(de,D,2),rv(),PA(D,2)}if(D=RA(M),D===null&&bA(h,m,M,yv,_),D===P)break;P=D}P!==null&&M.stopPropagation()}else bA(h,m,M,null,_)}}function RA(h){return h=OE(h),DA(h)}var yv=null;function DA(h){if(yv=null,h=gt(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 _F(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(te()){case ye:return 2;case Me:return 8;case be:case qe:return 32;case Ve:return 268435456;default:return 32}default:return 32}}var OA=!1,_u=null,wu=null,Su=null,hx=new Map,fx=new Map,Mu=[],tie="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 wF(h,m){switch(h){case"focusin":case"focusout":_u=null;break;case"dragenter":case"dragleave":wu=null;break;case"mouseover":case"mouseout":Su=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=re(m),m!==null&&yF(m)),h):(h.eventSystemFlags|=M,m=h.targetContainers,P!==null&&m.indexOf(P)===-1&&m.push(P),h)}function nie(h,m,_,M,P){switch(m){case"focusin":return _u=mx(_u,h,m,_,M,P),!0;case"dragenter":return wu=mx(wu,h,m,_,M,P),!0;case"mouseover":return Su=mx(Su,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 SF(h){var m=gt(h.target);if(m!==null){var _=a(m);if(_!==null){if(m=_.tag,m===13){if(m=s(_),m!==null){h.blockedOn=m,Zt(h.priority,function(){vF(_)});return}}else if(m===31){if(m=l(_),m!==null){h.blockedOn=m,Zt(h.priority,function(){vF(_)});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 _=RA(h.nativeEvent);if(_===null){_=h.nativeEvent;var M=new _.constructor(_.type,_);DE=M,_.target.dispatchEvent(M),DE=null}else return m=re(_),m!==null&&yF(m),h.blockedOn=_,!1;m.shift()}return!0}function MF(h,m,_){vv(h)&&_.delete(m)}function rie(){OA=!1,_u!==null&&vv(_u)&&(_u=null),wu!==null&&vv(wu)&&(wu=null),Su!==null&&vv(Su)&&(Su=null),hx.forEach(MF),fx.forEach(MF)}function _v(h,m){h.blockedOn===m&&(h.blockedOn=null,OA||(OA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,rie)))}var wv=null;function EF(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(DA(M||_)===null)continue;break}var D=re(_);D!==null&&(h.splice(m,3),m-=3,R2(D,{pending:!0,data:P,method:_.method,action:M},M,P))}}))}function om(h){function m(ke){return _v(ke,h)}_u!==null&&_v(_u,h),wu!==null&&_v(wu,h),Su!==null&&_v(Su,h),hx.forEach(m),fx.forEach(m);for(var _=0;_<Mu.length;_++){var M=Mu[_];M.blockedOn===h&&(M.blockedOn=null)}for(;0<Mu.length&&(_=Mu[0],_.blockedOn===null);)SF(_),_.blockedOn===null&&Mu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(M=0;M<_.length;M+=3){var P=_[M],D=_[M+1],X=P[_n]||null;if(typeof D=="function")X||EF(_);else if(X){var de=null;if(D&&D.hasAttribute("formAction")){if(P=D,X=D[_n]||null)de=X.formAction;else if(DA(P)!==null)continue}else de=X.action;typeof de=="function"?_[M+1]=de:(_.splice(M,3),M-=3),EF(_)}}}function AF(){function h(D){D.canIntercept&&D.info==="react-transition"&&D.intercept({handler:function(){return new Promise(function(X){return P=X})},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 LA(h){this._internalRoot=h}Sv.prototype.render=LA.prototype.render=function(h){var m=this._internalRoot;if(m===null)throw Error(r(409));var _=m.current,M=xs();xF(_,M,h,m,null,null)},Sv.prototype.unmount=LA.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var m=h.containerInfo;xF(h.current,2,null,h,null,null),rv(),m[wn]=null}};function Sv(h){this._internalRoot=h}Sv.prototype.unstable_scheduleHydration=function(h){if(h){var m=mt();h={blockedOn:null,target:h,priority:m};for(var _=0;_<Mu.length&&m!==0&&m<Mu[_].priority;_++);Mu.splice(_,0,h),_===0&&SF(h)}};var TF=e.version;if(TF!=="19.2.0")throw Error(r(527,TF,"19.2.0"));G.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 iie={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Mv=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Mv.isDisabled&&Mv.supportsFiber)try{me=Mv.inject(iie),ae=Mv}catch{}}return gx.createRoot=function(h,m){if(!i(h))throw Error(r(299));var _=!1,M="",P=DI,D=OI,X=LI;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&&(X=m.onRecoverableError)),m=pF(h,1,!1,null,null,_,M,null,P,D,X,AF),h[wn]=m.current,xA(h),new LA(m)},gx.hydrateRoot=function(h,m,_){if(!i(h))throw Error(r(299));var M=!1,P="",D=DI,X=OI,de=LI,ke=null;return _!=null&&(_.unstable_strictMode===!0&&(M=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(D=_.onUncaughtError),_.onCaughtError!==void 0&&(X=_.onCaughtError),_.onRecoverableError!==void 0&&(de=_.onRecoverableError),_.formState!==void 0&&(ke=_.formState)),m=pF(h,1,!0,m,_??null,M,P,ke,D,X,de,AF),m.context=gF(null),_=m.current,M=xs(),M=Ht(M),P=cu(M),P.callback=null,uu(_,P,M),_=M,m.current.lanes=_,Qt(m,_),tl(m),h[wn]=m.current,xA(h),new Sv(m)},gx.version="19.2.0",gx}var IF;function pie(){if(IF)return UA.exports;IF=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(),UA.exports=mie(),UA.exports}var gie=pie();const Jt=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},FF=t=>t==null?"":""+t,xie=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},bie=/###/g,UF=t=>t&&t.indexOf("###")>-1?t.replace(bie,"."):t,zF=t=>!t||Jt(t),a0=(t,e,n)=>{const r=Jt(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(zF(t))return{};const a=UF(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return zF(t)?{}:{obj:t,k:UF(r[i])}},BF=(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},yie=(t,e,n,r)=>{const{obj:i,k:a}=a0(t,e,Object);i[a]=i[a]||[],i[a].push(n)},F1=(t,e)=>{const{obj:n,k:r}=a0(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},vie=(t,e,n)=>{const r=F1(t,n);return r!==void 0?r:F1(e,n)},r9=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?Jt(t[r])||t[r]instanceof String||Jt(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):r9(t[r],e[r],n):t[r]=e[r]);return t},lm=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var _ie={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const wie=t=>Jt(t)?t.replace(/[&<>"'\/]/g,e=>_ie[e]):t;class Sie{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 Mie=[" ",",","?","!",";"],Eie=new Sie(20),Aie=(t,e,n)=>{e=e||"",n=n||"";const r=Mie.filter(s=>e.indexOf(s)<0&&n.indexOf(s)<0);if(r.length===0)return!0;const i=Eie.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},Uk=(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("_","-"),Tie={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 U1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Tie,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:(Jt(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new U1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new U1(this.logger,e)}}var fl=new U1;let QS=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 HF extends QS{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):Jt(r)&&a?l.push(...r.split(a)):l.push(r)));const c=F1(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!s||!Jt(r)?c:Uk(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),BF(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)(Jt(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=F1(this.data,l)||{};s.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?r9(c,r,a):c={...c,...r},BF(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 i9={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 a9=Symbol("i18next/PATH_KEY");function Nie(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===a9?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function zk(t,e){const{[a9]:n}=t(Nie());return n.join(e?.keySeparator??".")}const $F={},$A=t=>!Jt(t)&&typeof t!="boolean"&&typeof t!="number";class z1 extends QS{constructor(e,n={}){super(),xie(["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=$A(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&&!Aie(e,r,i);if(s&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:Jt(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:Jt(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=zk(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 b=p?.res;const v=p?.usedKey||l,x=p?.exactUsedKey||l,y=["[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&&!Jt(i.count),T=z1.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=b;w&&!b&&T&&(j=k);const z=$A(j),I=Object.prototype.toString.apply(j);if(w&&j&&z&&y.indexOf(I)<0&&!(Jt(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 q=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=q,p.usedParams=this.getUsedParamsDetails(i),p):q}if(s){const q=Array.isArray(j),R=q?[]:{},W=q?x:v;for(const K in j)if(Object.prototype.hasOwnProperty.call(j,K)){const G=`${W}${s}${K}`;T&&!b?R[K]=this.translate(G,{...i,defaultValue:$A(k)?k[K]:void 0,joinArrays:!1,ns:c}):R[K]=this.translate(G,{...i,joinArrays:!1,ns:c}),R[K]===G&&(R[K]=j[K])}b=R}}else if(w&&Jt(E)&&Array.isArray(b))b=b.join(E),b&&(b=this.extendTranslation(b,e,i,r));else{let q=!1,R=!1;!this.isValidLookup(b)&&T&&(q=!0,b=k),this.isValidLookup(b)||(R=!0,b=l);const K=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&R?void 0:b,G=T&&k!==b&&this.options.updateMissing;if(R||q||G){if(this.logger.log(G?"updateKey":"missingKey",f,u,l,G?k:b),s){const F=this.resolve(l,{...i,keySeparator:!1});F&&F.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 F=0;F<ee.length;F++)J.push(ee[F]);else this.options.saveMissingTo==="all"?J=this.languageUtils.toResolveHierarchy(i.lng||this.language):J.push(i.lng||this.language);const Z=(F,V,ne)=>{const le=T&&ne!==b?ne:K;this.options.missingKeyHandler?this.options.missingKeyHandler(F,u,V,le,G,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(F,u,V,le,G,i),this.emit("missingKey",F,u,V,b)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?J.forEach(F=>{const V=this.pluralResolver.getSuffixes(F,i);O&&i[`defaultValue${this.options.pluralSeparator}zero`]&&V.indexOf(`${this.options.pluralSeparator}zero`)<0&&V.push(`${this.options.pluralSeparator}zero`),V.forEach(ne=>{Z([F],l+ne,i[`defaultValue${ne}`]||k)})}):Z(J,l,k))}b=this.extendTranslation(b,e,i,p,r),R&&b===l&&this.options.appendNamespaceToMissingKey&&(b=`${u}${d}${l}`),(R||q)&&this.options.parseMissingKeyHandler&&(b=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,q?b:void 0,i))}return a?(p.res=b,p.usedParams=this.getUsedParamsDetails(i),p):b}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=Jt(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&&!Jt(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=Jt(s)?[s]:s;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=i9.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 Jt(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&&!Jt(n.count),p=g&&!n.ordinal&&n.count===0,b=n.context!==void 0&&(Jt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(x=>{this.isValidLookup(r)||(l=x,!$F[`${v[0]}-${x}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&($F[`${v[0]}-${x}`]=!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(y=>{if(this.isValidLookup(r))return;s=y;const E=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(E,d,y,x,n);else{let A;g&&(A=this.pluralResolver.getSuffix(y,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)),b){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(y,x,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&&!Jt(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 VF{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(Jt(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)),Jt(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 Jt(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))):Jt(e)&&a(this.formatLanguageCode(e)),r.forEach(s=>{i.indexOf(s)<0&&a(this.formatLanguageCode(s))}),i}}const GF={zero:0,one:1,two:2,few:3,many:4,other:5},WF={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Cie{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!"),WF;if(!e.match(/-|_/))return WF;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)=>GF[i]-GF[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 qF=(t,e,n,r=".",i=!0)=>{let a=vie(t,e,n);return!a&&i&&Jt(n)&&(a=Uk(t,n,r),a===void 0&&(a=Uk(e,n,r))),a},VA=t=>t.replace(/\$/g,"$$$$");class kie{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:b,nestingSuffixEscaped:v,nestingOptionsSeparator:x,maxReplaces:y,alwaysFormat:E}=e.interpolation;this.escape=n!==void 0?n:wie,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=b?lm(b):v||lm(")"),this.nestingOptionsSeparator=x||",",this.maxReplaces=y||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 y=qF(n,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,r,{...i,...n,interpolationkey:p}):y}const b=p.split(this.formatSeparator),v=b.shift().trim(),x=b.join(this.formatSeparator).trim();return this.format(qF(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),x,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=>VA(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?VA(this.escape(p)):VA(p)}].forEach(p=>{for(l=0;a=p.regex.exec(e);){const b=a[1].trim();if(s=u(b),s===void 0)if(typeof d=="function"){const x=d(e,a,i);s=Jt(x)?x:""}else if(i&&Object.prototype.hasOwnProperty.call(i,b))s="";else if(f){s=a[0];continue}else this.logger.warn(`missed to pass in variable ${b} for interpolating ${e}`),s="";else!Jt(s)&&!this.useRawValueToEscape&&(s=FF(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),b=g.match(/"/g);((p?.length??0)%2===0&&!b||b.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&&!Jt(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&&!Jt(a))return a;Jt(a)||(a=FF(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 Pie=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}},KF=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)}},jie=t=>(e,n,r)=>t(C0(n),r)(e);class Rie{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?KF:jie;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()]=KF(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}=Pie(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 Die=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Oie extends QS{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=>{yie(c.loaded,[a],s),Die(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();Jt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Jt(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 XF=()=>({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]),Jt(t[1])&&(e.defaultValue=t[1]),Jt(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}),YF=t=>(Jt(t.ns)&&(t.ns=[t.ns]),Jt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),Jt(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=()=>{},Lie=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class s0 extends QS{constructor(e={},n){if(super(),this.options=YF(e),this.services={},this.logger=fl,this.modules={external:[]},Lie(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&&(Jt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=XF();this.options={...r,...this.options,...YF(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=Rie;const d=new VF(this.options);this.store=new HF(this.options.resources,this.options);const f=this.services;f.logger=fl,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new Cie(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 kie(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Oie(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(p,...b)=>{this.emit(p,...b)}),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 z1(this.services,this.options),this.translator.on("*",(p,...b)=>{this.emit(p,...b)}),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=Jt(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"&&i9.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=Jt(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(Jt(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=zk(f,{...this.options,...s})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=zk(a,{...this.options,...s})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return Jt(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?(Jt(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();Jt(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 VF(XF());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 HF(l,i),a.services.resourceStore=a.store}return a.translator=new z1(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 Ha=s0.createInstance();Ha.createInstance;Ha.dir;Ha.init;Ha.loadResources;Ha.reloadResources;Ha.use;Ha.changeLanguage;Ha.getFixedT;Ha.t;Ha.exists;Ha.setDefaultNamespace;Ha.hasLoadedNamespace;Ha.loadNamespaces;Ha.loadLanguages;const Iie=(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);Zh(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},ZF={},s9=(t,e,n,r)=>{Zh(n)&&ZF[n]||(Zh(n)&&(ZF[n]=new Date),Iie(t,e,n,r))},o9=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},Bk=(t,e,n)=>{t.loadNamespaces(e,o9(t,n))},QF=(t,e,n,r)=>{if(Zh(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return Bk(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,o9(t,r))},Fie=(t,e,n={})=>!e.languages||!e.languages.length?(s9(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}}),Zh=t=>typeof t=="string",Uie=t=>typeof t=="object"&&t!==null,zie=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Bie={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},Hie=t=>Bie[t],$ie=t=>t.replace(zie,Hie);let Hk={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:$ie};const Vie=(t={})=>{Hk={...Hk,...t}},Gie=()=>Hk;let l9;const Wie=t=>{l9=t},qie=()=>l9,Kie={type:"3rdParty",init(t){Vie(t.options.react),Wie(t)}},Xie=S.createContext();class Yie{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var GA={exports:{}},WA={};var JF;function Zie(){if(JF)return WA;JF=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(),b=r({inst:{value:p,getSnapshot:g}}),v=b[0].inst,x=b[1];return a(function(){v.value=p,v.getSnapshot=g,c(v)&&x({inst:v})},[f,p,g]),i(function(){return c(v)&&x({inst:v}),f(function(){c(v)&&x({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 WA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,WA}var eU;function c9(){return eU||(eU=1,GA.exports=Zie()),GA.exports}var Qj=c9();const Qie=(t,e)=>Zh(e)?e:Uie(e)&&Zh(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,Jie={t:Qie,ready:!1},eae=()=>()=>{},ng=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=S.useContext(Xie)||{},a=n||r||qie();a&&!a.reportNamespaces&&(a.reportNamespaces=new Yie),a||s9(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const s=S.useMemo(()=>({...Gie(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=s,u=i||a?.options?.defaultNS,d=Zh(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 eae;const{bindI18n:j,bindI18nStore:z}=s,I=()=>{g.current+=1,k()};return j&&a.on(j,I),z&&a.store.on(z,I),()=>{j&&j.split(" ").forEach(q=>a.off(q,I)),z&&z.split(" ").forEach(q=>a.store.off(q,I))}},[a,s]),b=S.useRef(),v=S.useCallback(()=>{if(!a)return Jie;const k=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(W=>Fie(W,a,s)),j=e.lng||a.language,z=g.current,I=b.current;if(I&&I.ready===k&&I.lng===j&&I.keyPrefix===c&&I.revision===z)return I;const R={t:a.getFixedT(j,s.nsMode==="fallback"?f:f[0],c),ready:k,lng:j,keyPrefix:c,revision:z};return b.current=R,R},[a,f,c,s,e.lng]),[x,y]=S.useState(0),{t:E,ready:w}=Qj.useSyncExternalStore(p,v,v);S.useEffect(()=>{if(a&&!w&&!l){const k=()=>y(j=>j+1);e.lng?QF(a,e.lng,f,k):Bk(a,f,k)}},[a,e.lng,f,w,l,x]);const A=a||{},T=S.useRef(null),C=S.useRef(),N=k=>{const j=Object.getOwnPropertyDescriptors(k);j.__original&&delete j.__original;const z=Object.create(Object.getPrototypeOf(k),j);if(!Object.prototype.hasOwnProperty.call(z,"__original"))try{Object.defineProperty(z,"__original",{value:k,writable:!1,enumerable:!1,configurable:!1})}catch{}return z},O=S.useMemo(()=>{const k=A,j=k?.language;let z=k;k&&(T.current&&T.current.__original===k?C.current!==j?(z=N(k),T.current=z,C.current=j):z=T.current:(z=N(k),T.current=z,C.current=j));const I=[E,z,w];return I.t=E,I.i18n=z,I.ready=w,I},[E,A,w,A.resolvedLanguage,A.language,A.languages]);if(a&&l&&!w)throw new Promise(k=>{const j=()=>k();e.lng?QF(a,e.lng,f,j):Bk(a,f,j)});return O},{slice:tae,forEach:nae}=[];function rae(t){return nae.call(tae.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function iae(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 tU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,aae=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(!tU.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!tU.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},nU={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=aae(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 sae={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return nU.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&nU.create(n,t,r,i,a)}},oae={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}},lae={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 rU=()=>{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 cae={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&rU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&rU()&&window.localStorage.setItem(n,t)}};let um=null;const iU=()=>{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 uae={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&iU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&iU()&&window.sessionStorage.setItem(n,t)}},dae={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}},hae={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}},fae={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}},mae={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 u9=!1;try{document.cookie,u9=!0}catch{}const d9=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];u9||d9.splice(1,1);const pae=()=>({order:d9,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class h9{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=rae(n,this.options||{},pae()),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(sae),this.addDetector(oae),this.addDetector(cae),this.addDetector(uae),this.addDetector(dae),this.addDetector(hae),this.addDetector(fae),this.addDetector(mae),this.addDetector(lae)}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&&!iae(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)}))}}h9.type="languageDetector";const gae={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, which versions and printer models 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:"Printer model types (e.g., X1C, P1S) - not names or serial numbers",telemetryInfoItem4:"A timestamp (to count daily/weekly active users)",telemetryInfoNotCollected:"What we do NOT collect:",telemetryInfoNotItem1:"Your IP address is hashed and cannot be reversed",telemetryInfoNotItem2:"Printer names, serial numbers, or access codes",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?"}},xae={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?"}},bae={en:{translation:gae},de:{translation:xae}};Ha.use(h9).use(Kie).init({resources:bae,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const aU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var sU="popstate";function yae(t={}){function e(r,i){let{pathname:a,search:s,hash:l}=r.location;return $k("",{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 _ae(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 vae(){return Math.random().toString(36).substring(2,10)}function oU(t,e){return{usr:t.state,key:t.key,idx:e}}function $k(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||vae()}}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 _ae(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 x=d(),y=x==null?null:x-u;u=x,c&&c({action:l,location:v.location,delta:y})}function g(x,y){l="PUSH";let E=$k(v.location,x,y);u=d()+1;let w=oU(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(x,y){l="REPLACE";let E=$k(v.location,x,y);u=d();let w=oU(E,u),A=v.createHref(E);s.replaceState(w,"",A),a&&c&&c({action:l,location:v.location,delta:0})}function b(x){return wae(x)}let v={get action(){return l},get location(){return t(i,s)},listen(x){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(sU,f),c=x,()=>{i.removeEventListener(sU,f),c=null}},createHref(x){return e(i,x)},createURL:b,encodeLocation(x){let y=b(x);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:g,replace:p,go(x){return s.go(x)}};return v}function wae(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 f9(t,e,n="/"){return Sae(t,e,n,!1)}function Sae(t,e,n,r){let i=typeof e=="string"?rg(e):e,a=Uc(i.pathname||"/",n);if(a==null)return null;let s=m9(t);Mae(s);let l=null;for(let c=0;l==null&&c<s.length;++c){let u=Oae(a);l=Rae(s[c],u,r)}return l}function m9(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}".`),m9(s.children,e,g,f,c)),!(s.path==null&&!s.index)&&e.push({path:f,score:Pae(f,s.index),routesMeta:g})};return t.forEach((s,l)=>{if(s.path===""||!s.path?.includes("?"))a(s,l);else for(let c of p9(s.path))a(s,l,!0,c)}),e}function p9(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=p9(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 Mae(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:jae(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Eae=/^:[\w-]+$/,Aae=3,Tae=2,Nae=1,Cae=10,kae=-2,lU=t=>t==="*";function Pae(t,e){let n=t.split("/"),r=n.length;return n.some(lU)&&(r+=kae),e&&(r+=Tae),n.filter(i=>!lU(i)).reduce((i,a)=>i+(Eae.test(a)?Aae:a===""?Nae:Cae),r)}function jae(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 Rae(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=B1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),g=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=B1({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:zae(Pc([a,f.pathnameBase])),route:g}),f.pathnameBase!=="/"&&(a=Pc([a,f.pathnameBase]))}return s}function B1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Dae(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 b=l[g]||"";s=a.slice(0,a.length-b.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 Dae(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 Oae(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 Lae=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Iae=t=>Lae.test(t);function Fae(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?rg(t):t,a;if(n)if(Iae(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=cU(n.substring(1),"/"):a=cU(n,e)}else a=e;return{pathname:a,search:Bae(r),hash:Hae(i)}}function cU(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 qA(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 Uae(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function g9(t){let e=Uae(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function x9(t,e,n,r=!1){let i;typeof t=="string"?i=rg(t):(i={...t},Dr(!i.pathname||!i.pathname.includes("?"),qA("?","pathname","search",i)),Dr(!i.pathname||!i.pathname.includes("#"),qA("#","pathname","hash",i)),Dr(!i.search||!i.search.includes("#"),qA("#","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=Fae(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,"/"),zae=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Bae=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Hae=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function $ae(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 b9=["POST","PUT","PATCH","DELETE"];new Set(b9);var Vae=["GET",...b9];new Set(Vae);var ig=S.createContext(null);ig.displayName="DataRouter";var JS=S.createContext(null);JS.displayName="DataRouterState";S.createContext(!1);var y9=S.createContext({isTransitioning:!1});y9.displayName="ViewTransition";var Gae=S.createContext(new Map);Gae.displayName="Fetchers";var Wae=S.createContext(null);Wae.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 Jj=S.createContext(null);Jj.displayName="RouteError";function qae(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 Rd(){return Dr(Mb(),"useLocation() may be used only in the context of a <Router> component."),S.useContext(Sb).location}var v9="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function _9(t){S.useContext(Pl).static||S.useLayoutEffect(t)}function Eb(){let{isDataRoute:t}=S.useContext(qo);return t?lse():Kae()}function Kae(){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}=Rd(),a=JSON.stringify(g9(r)),s=S.useRef(!1);return _9(()=>{s.current=!0}),S.useCallback((c,u={})=>{if(Vo(s.current,v9),!s.current)return;if(typeof c=="number"){n.go(c);return}let d=x9(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 Xae=S.createContext(null);function Yae(t){let e=S.useContext(qo).outlet;return S.useMemo(()=>e&&S.createElement(Xae.Provider,{value:t},e),[e,t])}function eR(){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}=Rd(),i=JSON.stringify(g9(n));return S.useMemo(()=>x9(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Zae(t,e){return w9(t,e)}function w9(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||"";S9(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.
  10. Please change the parent <Route path="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let g=Rd(),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 b=p.pathname||"/",v=b;if(d!=="/"){let E=d.replace(/^\//,"").split("/");v="/"+b.replace(/^\//,"").split("/").slice(E.length).join("/")}let x=f9(t,{pathname:v});Vo(f||x!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Vo(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.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 y=nse(x&&x.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&&y?S.createElement(Sb.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},y):y}function Qae(){let t=ose(),e=$ae(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 Jae=S.createElement(Qae,null),ese=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(Jj.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function tse({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 nse(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,b=f.route.loader&&!g.hasOwnProperty(f.route.id)&&(!p||p[f.route.id]===void 0);if(f.route.lazy||b){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,b=!1,v=null,x=null;n&&(p=s&&f.route.id?s[f.route.id]:void 0,v=f.route.errorElement||Jae,l&&(c<0&&g===0?(S9("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,x=null):c===g&&(b=!0,x=f.route.hydrateFallbackElement||null)));let y=e.concat(a.slice(0,g+1)),E=()=>{let w;return p?w=v:b?w=x:f.route.Component?w=S.createElement(f.route.Component,null):f.route.element?w=f.route.element:w=d,S.createElement(tse,{match:f,routeContext:{outlet:d,matches:y,isDataRoute:n!=null},children:w})};return n&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?S.createElement(ese,{location:n.location,revalidation:n.revalidation,component:v,error:p,children:E(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:u}):E()},null)}function tR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function rse(t){let e=S.useContext(ig);return Dr(e,tR(t)),e}function ise(t){let e=S.useContext(JS);return Dr(e,tR(t)),e}function ase(t){let e=S.useContext(qo);return Dr(e,tR(t)),e}function nR(t){let e=ase(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 sse(){return nR("useRouteId")}function ose(){let t=S.useContext(Jj),e=ise("useRouteError"),n=nR("useRouteError");return t!==void 0?t:e.errors?.[n]}function lse(){let{router:t}=rse("useNavigate"),e=nR("useNavigate"),n=S.useRef(!1);return _9(()=>{n.current=!0}),S.useCallback(async(i,a={})=>{Vo(n.current,v9),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var uU={};function S9(t,e,n){!e&&!uU[t]&&(uU[t]=!0,Vo(!1,n))}S.memo(cse);function cse({routes:t,future:e,state:n,unstable_onError:r}){return w9(t,void 0,n,r,e)}function use(t){return Yae(t.context)}function Za(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 dse({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 b=Uc(c,s);return b==null?null:{location:{pathname:b,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 hse({children:t,location:e}){return Zae(Vk(t),e)}function Vk(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,Vk(r.props.children,a));return}Dr(r.type===Za,`[${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=Vk(r.props.children,a)),n.push(s)}),n}var d1="get",h1="application/x-www-form-urlencoded";function eM(t){return t!=null&&typeof t.tagName=="string"}function fse(t){return eM(t)&&t.tagName.toLowerCase()==="button"}function mse(t){return eM(t)&&t.tagName.toLowerCase()==="form"}function pse(t){return eM(t)&&t.tagName.toLowerCase()==="input"}function gse(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function xse(t,e){return t.button===0&&(!e||e==="_self")&&!gse(t)}var Tv=null;function bse(){if(Tv===null)try{new FormData(document.createElement("form"),0),Tv=!1}catch{Tv=!0}return Tv}var yse=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function KA(t){return t!=null&&!yse.has(t)?(Vo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${h1}"`),null):t}function vse(t,e){let n,r,i,a,s;if(mse(t)){let l=t.getAttribute("action");r=l?Uc(l,e):null,n=t.getAttribute("method")||d1,i=KA(t.getAttribute("enctype"))||h1,a=new FormData(t)}else if(fse(t)||pse(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=KA(t.getAttribute("formenctype"))||KA(l.getAttribute("enctype"))||h1,a=new FormData(l,t),!bse()){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(eM(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 rR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function _se(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 wse(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 Sse(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 Mse(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let s=await wse(a,n);return s.links?s.links():[]}return[]}));return Nse(r.flat(1).filter(Sse).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function dU(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 Ese(t,e,{includeHydrateFallback:n}={}){return Ase(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 Ase(t){return[...new Set(t)]}function Tse(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function Nse(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(Tse(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function M9(){let t=S.useContext(ig);return rR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Cse(){let t=S.useContext(JS);return rR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var iR=S.createContext(void 0);iR.displayName="FrameworkContext";function E9(){let t=S.useContext(iR);return rR(t,"You must render this element inside a <HydratedRouter> element"),t}function kse(t,e){let n=S.useContext(iR),[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=y=>{y.forEach(E=>{s(E.isIntersecting)})},x=new IntersectionObserver(v,{threshold:.5});return g.current&&x.observe(g.current),()=>{x.disconnect()}}},[t]),S.useEffect(()=>{if(r){let v=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(v)}}},[r]);let p=()=>{i(!0)},b=()=>{i(!1),s(!1)};return n?t!=="intent"?[a,g,{}]:[a,g,{onFocus:bx(l,p),onBlur:bx(c,b),onMouseEnter:bx(u,p),onMouseLeave:bx(d,b),onTouchStart:bx(f,p)}]:[!1,g,{}]}function bx(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Pse({page:t,...e}){let{router:n}=M9(),r=S.useMemo(()=>f9(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?S.createElement(Rse,{page:t,matches:r,...e}):null}function jse(t){let{manifest:e,routeModules:n}=E9(),[r,i]=S.useState([]);return S.useEffect(()=>{let a=!1;return Mse(t,e,n).then(s=>{a||i(s)}),()=>{a=!0}},[t,e,n]),r}function Rse({page:t,matches:e,...n}){let r=Rd(),{manifest:i,routeModules:a}=E9(),{basename:s}=M9(),{loaderData:l,matches:c}=Cse(),u=S.useMemo(()=>dU(t,e,c,i,r,"data"),[t,e,c,i,r]),d=S.useMemo(()=>dU(t,e,c,i,r,"assets"),[t,e,c,i,r]),f=S.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let b=new Set,v=!1;if(e.forEach(y=>{let E=i.routes[y.route.id];!E||!E.hasLoader||(!u.some(w=>w.route.id===y.route.id)&&y.route.id in l&&a[y.route.id]?.shouldRevalidate||E.hasClientLoader?v=!0:b.add(y.route.id))}),b.size===0)return[];let x=_se(t,s,"data");return v&&b.size>0&&x.searchParams.set("_routes",e.filter(y=>b.has(y.route.id)).map(y=>y.route.id).join(",")),[x.pathname+x.search]},[s,l,r,i,u,e,t,a]),g=S.useMemo(()=>Ese(d,i),[d,i]),p=jse(d);return S.createElement(S.Fragment,null,f.map(b=>S.createElement("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),g.map(b=>S.createElement("link",{key:b,rel:"modulepreload",href:b,...n})),p.map(({key:b,link:v})=>S.createElement("link",{key:b,nonce:n.nonce,...v})))}function Dse(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var A9=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{A9&&(window.__reactRouterVersion="7.9.6")}catch{}function Ose({basename:t,children:e,window:n}){let r=S.useRef();r.current==null&&(r.current=yae({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(dse,{basename:t,children:e,location:a.location,navigationType:a.action,navigator:i})}var T9=/^(?:[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:b}=S.useContext(Pl),v=typeof u=="string"&&T9.test(u),x,y=!1;if(typeof u=="string"&&v&&(x=u,A9))try{let k=new URL(window.location.href),j=u.startsWith("//")?new URL(k.protocol+u):new URL(u),z=Uc(j.pathname,b);j.origin===k.origin&&z!=null?u=z+j.search+j.hash:y=!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=qae(u,{relative:i}),[w,A,T]=kse(r,g),C=Fse(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:x||E,onClick:y||a?e:N,ref:Dse(p,A),target:c,"data-discover":!v&&n==="render"?"true":void 0});return w&&!v?S.createElement(S.Fragment,null,O,S.createElement(Pse,{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=Rd(),p=S.useContext(JS),{navigator:b,basename:v}=S.useContext(Pl),x=p!=null&&$se(f)&&l===!0,y=b.encodeLocation?b.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,y=y.toLowerCase()),w&&v&&(w=Uc(w,v)||w);const A=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let T=E===y||!i&&E.startsWith(y)&&E.charAt(A)==="/",C=w!=null&&(w===y||!i&&w.startsWith(y)&&w.charAt(y.length)==="/"),N={isActive:T,isPending:C,isTransitioning:x},O=T?e:void 0,k;typeof r=="function"?k=r(N):k=[r,T?"active":null,C?"pending":null,x?"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 Lse=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 b=Bse(),v=Hse(l,{relative:u}),x=s.toLowerCase()==="get"?"get":"post",y=typeof l=="string"&&T9.test(l),E=w=>{if(c&&c(w),w.defaultPrevented)return;w.preventDefault();let A=w.nativeEvent.submitter,T=A?.getAttribute("formmethod")||s;b(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:x,action:v,onSubmit:r?c:E,...g,"data-discover":!y&&t==="render"?"true":void 0})});Lse.displayName="Form";function Ise(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function N9(t){let e=S.useContext(ig);return Dr(e,Ise(t)),e}function Fse(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:s}={}){let l=Eb(),c=Rd(),u=Ab(t,{relative:a});return S.useCallback(d=>{if(xse(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 Use=0,zse=()=>`__${String(++Use)}__`;function Bse(){let{router:t}=N9("useSubmit"),{basename:e}=S.useContext(Pl),n=sse();return S.useCallback(async(r,i={})=>{let{action:a,method:s,encType:l,formData:c,body:u}=vse(r,e);if(i.navigate===!1){let d=i.fetcherKey||zse();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 Hse(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=Rd();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 $se(t,{relative:e}={}){let n=S.useContext(y9);Dr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=N9("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 B1(i.pathname,s)!=null||B1(i.pathname,a)!=null}var Mc=n9();const Vse=vo(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(){}},Gse={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Wse=class{#e=Gse;#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)}},Th=new Wse;function qse(t){setTimeout(t,0)}var Qh=typeof window>"u"||"Deno"in globalThis;function Pa(){}function Kse(t,e){return typeof t=="function"?t(e):t}function Gk(t){return typeof t=="number"&&t>=0&&t!==1/0}function C9(t,e){return Math.max(t+(e||0)-Date.now(),0)}function ld(t,e){return typeof t=="function"?t(e):t}function Qs(t,e){return typeof t=="function"?t(e):t}function hU(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:s,stale:l}=t;if(s){if(r){if(e.queryHash!==aR(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 fU(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(Jh(e.options.mutationKey)!==Jh(a))return!1}else if(!P0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function aR(t,e){return(e?.queryKeyHashFn||Jh)(t)}function Jh(t){return JSON.stringify(t,(e,n)=>Wk(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 Xse=Object.prototype.hasOwnProperty;function k9(t,e){if(t===e)return t;const n=mU(t)&&mU(e);if(!n&&!(Wk(t)&&Wk(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:Xse.call(t,d))&&c++;continue}if(f===null||g===null||typeof f!="object"||typeof g!="object"){l[d]=g;continue}const p=k9(f,g);l[d]=p,p===f&&c++}return i===s&&c===i?t:l}function H1(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 mU(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Wk(t){if(!pU(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!pU(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function pU(t){return Object.prototype.toString.call(t)==="[object Object]"}function Yse(t){return new Promise(e=>{Th.setTimeout(e,t)})}function qk(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?k9(t,e):e}function Zse(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function Qse(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var sR=Symbol();function P9(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===sR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function j9(t,e){return typeof t=="function"?t(...e):!!t}var Jse=class extends ag{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!Qh&&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"}},oR=new Jse;function Kk(){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 eoe=qse;function toe(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=eoe;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 _i=toe(),noe=class extends ag{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!Qh&&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}},$1=new noe;function roe(t){return Math.min(1e3*2**t,3e4)}function R9(t){return(t??"online")==="online"?$1.isOnline():!0}var Xk=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function D9(t){let e=!1,n=0,r;const i=Kk(),a=()=>i.status!=="pending",s=v=>{if(!a()){const x=new Xk(v);g(x),t.onCancel?.(x)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>oR.isFocused()&&(t.networkMode==="always"||$1.isOnline())&&t.canRun(),d=()=>R9(t.networkMode)&&t.canRun(),f=v=>{a()||(r?.(),i.resolve(v))},g=v=>{a()||(r?.(),i.reject(v))},p=()=>new Promise(v=>{r=x=>{(a()||u())&&v(x)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),b=()=>{if(a())return;let v;const x=n===0?t.initialPromise:void 0;try{v=x??t.fn()}catch(y){v=Promise.reject(y)}Promise.resolve(v).then(f).catch(y=>{if(a())return;const E=t.retry??(Qh?0:3),w=t.retryDelay??roe,A=typeof w=="function"?w(n,y):w,T=E===!0||typeof E=="number"&&n<E||typeof E=="function"&&E(n,y);if(e||!T){g(y);return}n++,t.onFail?.(n,y),Yse(A).then(()=>u()?void 0:p()).then(()=>{e?g(y):b()})})};return{promise:i,status:()=>i.status,cancel:s,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?b():p().then(b),i)}}var O9=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Gk(this.gcTime)&&(this.#e=Th.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Qh?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Th.clearTimeout(this.#e),this.#e=void 0)}},ioe=class extends O9{#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=xU(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=xU(this.options);e.data!==void 0&&(this.setState(gU(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=qk(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(Pa).catch(Pa):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Qs(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===sR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>ld(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:!C9(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=P9(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=D9({initialPromise:e?.initialPromise,fn:s.fetchFn,onCancel:l=>{l instanceof Xk&&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 Xk){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,...L9(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...gU(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),_i.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function L9(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:R9(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function gU(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function xU(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 aoe=class extends ag{constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=Kk(),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),bU(this.#t,this.options)?this.#d():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Yk(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Yk(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 Qs(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&&!H1(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&yU(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||Qs(this.options.enabled,this.#t)!==Qs(e.enabled,this.#t)||ld(this.options.staleTime,this.#t)!==ld(e.staleTime,this.#t))&&this.#g();const i=this.#x();r&&(this.#t!==n||Qs(this.options.enabled,this.#t)!==Qs(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 ooe(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(Pa)),e}#g(){this.#v();const t=ld(this.options.staleTime,this.#t);if(Qh||this.#i.isStale||!Gk(t))return;const n=C9(this.#i.dataUpdatedAt,t)+1;this.#c=Th.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,!(Qh||Qs(this.options.enabled,this.#t)===!1||!Gk(this.#l)||this.#l===0)&&(this.#u=Th.setInterval(()=>{(this.options.refetchIntervalInBackground||oR.isFocused())&&this.#d()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(Th.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(Th.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&&bU(t,e),j=O&&yU(t,n,e,r);(k||j)&&(d={...d,...L9(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:b,status:v}=d;g=d.data;let x=!1;if(e.placeholderData!==void 0&&g===void 0&&v==="pending"){let O;i?.isPlaceholderData&&e.placeholderData===s?.placeholderData?(O=i.data,x=!0):O=typeof e.placeholderData=="function"?e.placeholderData(this.#f?.state.data,this.#f):e.placeholderData,O!==void 0&&(v="success",g=qk(i?.data,O,e),f=!0)}if(e.select&&g!==void 0&&!x)if(i&&g===a?.data&&e.select===this.#p)g=this.#h;else try{this.#p=e.select,g=e.select(g),g=qk(i?.data,g,e),this.#h=g,this.#a=null}catch(O){this.#a=O}this.#a&&(p=this.#a,g=this.#h,b=Date.now(),v="error");const y=d.fetchStatus==="fetching",E=v==="pending",w=v==="error",A=E&&y,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:b,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:y,isRefetching:y&&!E,isLoadingError:w&&!T,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&T,isStale:lR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Qs(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=z=>{N.status==="error"?z.reject(N.error):N.data!==void 0&&z.resolve(N.data)},k=()=>{const z=this.#o=N.promise=Kk();O(z)},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),H1(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){_i.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function soe(t,e){return Qs(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function bU(t,e){return soe(t,e)||t.state.data!==void 0&&Yk(t,e,e.refetchOnMount)}function Yk(t,e,n){if(Qs(e.enabled,t)!==!1&&ld(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&lR(t,e)}return!1}function yU(t,e,n,r){return(t!==e||Qs(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&lR(t,n)}function lR(t,e){return Qs(e.enabled,t)!==!1&&t.isStaleByTime(ld(e.staleTime,t))}function ooe(t,e){return!H1(t.getCurrentResult(),e)}function vU(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=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},g=P9(e.options,e.fetchOptions),p=async(b,v,x)=>{if(d)return Promise.reject();if(v==null&&b.pages.length)return Promise.resolve(b);const E=(()=>{const C={client:e.client,queryKey:e.queryKey,pageParam:v,direction:x?"backward":"forward",meta:e.options.meta};return f(C),C})(),w=await g(E),{maxPages:A}=e.options,T=x?Qse:Zse;return{pages:T(b.pages,w,A),pageParams:T(b.pageParams,v,A)}};if(i&&a.length){const b=i==="backward",v=b?loe:_U,x={pages:a,pageParams:s},y=v(r,x);l=await p(x,y,b)}else{const b=t??a.length;do{const v=c===0?s[0]??r.initialPageParam:_U(r,l);if(c>0&&v==null)break;l=await p(l,v),c++}while(c<b)}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 _U(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 loe(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var coe=class extends O9{#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||I9(),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=D9({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),_i.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function I9(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var uoe=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 coe({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(){_i.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=>fU(e,n))}findAll(t={}){return this.getAll().filter(e=>fU(t,e))}notify(t){_i.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return _i.batch(()=>Promise.all(t.map(e=>e.continue().catch(Pa))))}};function Nv(t){return t.options.scope?.id}var doe=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),H1(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Jh(n.mutationKey)!==Jh(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??I9();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){_i.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)})})}},hoe=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??aR(r,e);let a=this.get(i);return a||(a=new ioe({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(){_i.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=>hU(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>hU(t,n)):e}notify(t){_i.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){_i.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){_i.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},foe=class{#e;#t;#n;#i;#r;#s;#o;#a;constructor(t={}){this.#e=t.queryCache||new hoe,this.#t=t.mutationCache||new uoe,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=oR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=$1.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(ld(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=Kse(e,a);if(s!==void 0)return this.#e.build(this,r).setData(s,{...n,manual:!0})}setQueriesData(t,e,n){return _i.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;_i.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return _i.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=_i.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Pa).catch(Pa)}invalidateQueries(t,e={}){return _i.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=_i.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(Pa)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Pa)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(ld(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Pa).catch(Pa)}fetchInfiniteQuery(t){return t.behavior=vU(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Pa).catch(Pa)}ensureInfiniteQueryData(t){return t.behavior=vU(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return $1.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(Jh(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(Jh(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=aR(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===sR&&(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()}},F9=S.createContext(void 0),dn=t=>{const e=S.useContext(F9);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},moe=({client:t,children:e})=>(S.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),o.jsx(F9.Provider,{value:t,children:e})),U9=S.createContext(!1),poe=()=>S.useContext(U9);U9.Provider;function goe(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var xoe=S.createContext(goe()),boe=()=>S.useContext(xoe),yoe=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},voe=t=>{S.useEffect(()=>{t.clearReset()},[t])},_oe=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||j9(n,[t.error,r])),woe=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))}},Soe=(t,e)=>t.isLoading&&t.isFetching&&!e,Moe=(t,e)=>t?.suspense&&e.isPending,wU=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Eoe(t,e,n){const r=poe(),i=boe(),a=dn(),s=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(s),s._optimisticResults=r?"isRestoring":"optimistic",woe(s),yoe(s,i),voe(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(_i.batchCalls(f)):Pa;return c.updateResult(),g},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),S.useEffect(()=>{c.setOptions(s)},[s,c]),Moe(s,u))throw wU(s,c,i);if(_oe({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&&!Qh&&Soe(u,r)&&(l?wU(s,c,i):a.getQueryCache().get(s.queryHash)?.promise)?.catch(Pa).finally(()=>{c.updateResult()}),s.notifyOnChangeProps?u:c.trackResult(u)}function pt(t,e){return Eoe(t,aoe)}function _t(t,e){const n=dn(),[r]=S.useState(()=>new doe(n,t));S.useEffect(()=>{r.setOptions(t)},[r,t]);const i=S.useSyncExternalStore(S.useCallback(s=>r.subscribe(_i.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=S.useCallback((s,l)=>{r.mutate(s,l).catch(Pa)},[r]);if(i.error&&j9(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const Aoe=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Toe=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),SU=t=>{const e=Toe(t);return e.charAt(0).toUpperCase()+e.slice(1)},z9=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),Noe=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Coe={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 koe=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,...Coe,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:z9("lucide",i),...!a&&!Noe(l)&&{"aria-hidden":"true"},...l},[...s.map(([u,d])=>S.createElement(u,d)),...Array.isArray(a)?a:[a]]));const Ge=(t,e)=>{const n=S.forwardRef(({className:r,...i},a)=>S.createElement(koe,{ref:a,iconNode:e,className:z9(`lucide-${Aoe(SU(t))}`,`lucide-${t}`,r),...i}));return n.displayName=SU(t),n};const Poe=[["path",{d:"M18 17.5a2.5 2.5 0 1 1-4 2.03V12",key:"yd12zl"}],["path",{d:"M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"larmp2"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"M6.6 15.572A2 2 0 1 0 10 17v-5",key:"1x1kqn"}]],joe=Ge("air-vent",Poe);const Roe=[["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"}]],co=Ge("archive",Roe);const Doe=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],j0=Ge("arrow-down",Doe);const Ooe=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Loe=Ge("arrow-left",Ooe);const Ioe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Zk=Ge("arrow-right",Ioe);const Foe=[["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"}]],Uoe=Ge("arrow-up-down",Foe);const zoe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Mp=Ge("arrow-up",zoe);const Boe=[["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"}]],Lh=Ge("bell",Boe);const Hoe=[["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"}]],$oe=Ge("bold",Hoe);const Voe=[["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"}]],Goe=Ge("book",Voe);const Woe=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],qoe=Ge("bookmark",Woe);const Koe=[["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"}]],bd=Ge("box",Koe);const Xoe=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],B9=Ge("bug",Xoe);const Yoe=[["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"}]],Zoe=Ge("cable",Yoe);const Qoe=[["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"}]],Joe=Ge("calendar-days",Qoe);const ele=[["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=Ge("calendar",ele);const tle=[["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=Ge("camera",tle);const nle=[["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"}]],rle=Ge("chart-column",nle);const ile=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],go=Ge("check",ile);const ale=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Os=Ge("chevron-down",ale);const sle=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ko=Ge("chevron-right",sle);const ole=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ef=Ge("chevron-left",ole);const lle=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Tb=Ge("chevron-up",lle);const cle=[["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"}]],Sa=Ge("circle-alert",cle);const ule=[["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"}]],XA=Ge("circle-arrow-up",ule);const dle=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ar=Ge("circle-check-big",dle);const hle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],cR=Ge("circle-check",hle);const fle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],mle=Ge("circle-dot",fle);const ple=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],gle=Ge("circle-stop",ple);const xle=[["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"}]],Ra=Ge("circle-x",xle);const ble=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],MU=Ge("circle",ble);const yle=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ur=Ge("clock",yle);const vle=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],tM=Ge("cloud",vle);const _le=[["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"}]],wle=Ge("code-xml",_le);const Sle=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],H9=Ge("code",Sle);const Mle=[["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"}]],Ele=Ge("coffee",Mle);const Ale=[["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"}]],Tle=Ge("cog",Ale);const Nle=[["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"}]],Cle=Ge("compass",Nle);const kle=[["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=Ge("copy",kle);const Ple=[["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=Ge("cpu",Ple);const jle=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],Rle=Ge("cylinder",jle);const Dle=[["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=Ge("database",Dle);const Ole=[["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"}]],Qk=Ge("dollar-sign",Ole);const Lle=[["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"}]],Wi=Ge("download",Lle);const Ile=[["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"}]],uR=Ge("droplet",Ile);const Fle=[["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"}]],dR=Ge("droplets",Fle);const Ule=[["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=Ge("ellipsis-vertical",Ule);const zle=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],YA=Ge("equal",zle);const Ble=[["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"}]],ui=Ge("external-link",Ble);const Hle=[["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"}]],nM=Ge("eye-off",Hle);const $le=[["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"}]],tf=Ge("eye",$le);const Vle=[["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"}]],$9=Ge("fan",Vle);const Gle=[["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"}]],V9=Ge("file-box",Gle);const Wle=[["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"}]],Jk=Ge("file-code",Wle);const qle=[["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"}]],Kle=Ge("file-exclamation-point",qle);const Xle=[["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"}]],V1=Ge("file-spreadsheet",Xle);const Yle=[["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=Ge("file-text",Yle);const Zle=[["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"}]],hR=Ge("file",Zle);const Qle=[["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"}]],Ih=Ge("film",Qle);const Jle=[["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"}]],ece=Ge("flame",Jle);const tce=[["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=Ge("folder-kanban",tce);const nce=[["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"}]],rce=Ge("folder-open",nce);const ice=[["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"}]],ace=Ge("folder-tree",ice);const sce=[["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"}]],G9=Ge("folder",sce);const oce=[["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"}]],fR=Ge("funnel",oce);const lce=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],rM=Ge("gauge",lce);const cce=[["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"}]],uce=Ge("gift",cce);const dce=[["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=Ge("git-compare",dce);const hce=[["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"}]],EU=Ge("github",hce);const fce=[["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=Ge("globe",fce);const mce=[["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=Ge("grip-vertical",mce);const pce=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],mR=Ge("hand",pce);const gce=[["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"}]],pR=Ge("hard-drive",gce);const xce=[["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"}]],bce=Ge("hash",xce);const yce=[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]],vce=Ge("headphones",yce);const _ce=[["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"}]],wce=Ge("heart",_ce);const Sce=[["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"}]],G1=Ge("history",Sce);const Mce=[["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"}]],Ece=Ge("house",Mce);const Ace=[["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=Ge("image",Ace);const Tce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],yd=Ge("info",Tce);const Nce=[["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"}]],Cce=Ge("italic",Nce);const kce=[["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=Ge("key",kce);const Pce=[["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"}]],e3=Ge("keyboard",Pce);const jce=[["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"}]],vd=Ge("layers",jce);const Rce=[["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"}]],gR=Ge("layout-grid",Rce);const Dce=[["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"}]],Oce=Ge("link-2-off",Dce);const Lce=[["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=Ge("link-2",Lce);const Ice=[["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=Ge("link",Ice);const Fce=[["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"}]],W9=Ge("list-ordered",Fce);const Uce=[["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"}]],t3=Ge("list-todo",Uce);const zce=[["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"}]],xR=Ge("list",zce);const Bce=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],xt=Ge("loader-circle",Bce);const Hce=[["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"}]],AU=Ge("log-in",Hce);const $ce=[["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"}]],Vce=Ge("log-out",$ce);const Gce=[["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"}]],Wce=Ge("mail",Gce);const qce=[["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"}]],Kce=Ge("map",qce);const Xce=[["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"}]],Yce=Ge("maximize-2",Xce);const Zce=[["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"}]],Qce=Ge("maximize",Zce);const Jce=[["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"}]],eue=Ge("memory-stick",Jce);const tue=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],nue=Ge("menu",tue);const rue=[["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"}]],iue=Ge("minimize-2",rue);const aue=[["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"}]],sue=Ge("minimize",aue);const oue=[["path",{d:"M5 12h14",key:"1ays0h"}]],n3=Ge("minus",oue);const lue=[["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"}]],cue=Ge("monitor",lue);const uue=[["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"}]],W1=Ge("moon",uue);const due=[["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"}]],r3=Ge("music",due);const hue=[["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=Ge("package",hue);const fue=[["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"}]],bR=Ge("palette",fue);const mue=[["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"}]],pue=Ge("paperclip",mue);const gue=[["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"}]],yR=Ge("pause",gue);const xue=[["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=Ge("pen-line",xue);const bue=[["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"}]],vR=Ge("pen",bue);const yue=[["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=Ge("pencil",yue);const vue=[["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"}]],_ue=Ge("phone",vue);const wue=[["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"}]],Hc=Ge("play",wue);const Sue=[["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"}]],uo=Ge("plug",Sue);const Mue=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],fr=Ge("plus",Mue);const Eue=[["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"}]],iM=Ge("power-off",Eue);const Aue=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],jl=Ge("power",Aue);const Tue=[["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"}]],qi=Ge("printer",Tue);const Nue=[["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"}]],Cue=Ge("qr-code",Nue);const kue=[["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=Ge("refresh-cw",kue);const Pue=[["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=Ge("rotate-ccw",Pue);const jue=[["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"}]],Rue=Ge("ruler",jue);const Due=[["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=Ge("save",Due);const Oue=[["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"}]],Lue=Ge("scan-search",Oue);const Iue=[["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"}]],Fue=Ge("scissors",Iue);const Uue=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],_l=Ge("search",Uue);const zue=[["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"}]],_R=Ge("send",zue);const Bue=[["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"}]],ph=Ge("server",Bue);const Hue=[["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"}]],aM=Ge("settings-2",Hue);const $ue=[["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"}]],wR=Ge("settings",$ue);const Vue=[["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"}]],Gue=Ge("shield",Vue);const Wue=[["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"}]],q9=Ge("shopping-cart",Wue);const que=[["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"}]],Kue=Ge("signal",que);const Xue=[["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"}]],Yue=Ge("skip-back",Xue);const Zue=[["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"}]],q1=Ge("skip-forward",Zue);const Que=[["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"}]],TU=Ge("sliders-vertical",Que);const Jue=[["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=Ge("sparkles",Jue);const ede=[["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=Ge("square-check-big",ede);const tde=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],af=Ge("square",tde);const nde=[["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=Ge("star",nde);const rde=[["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"}]],K9=Ge("sticky-note",rde);const ide=[["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"}]],NU=Ge("sun",ide);const ade=[["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=Ge("tag",ade);const sde=[["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"}]],X9=Ge("target",sde);const ode=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Y9=Ge("terminal",ode);const lde=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],cde=Ge("text-align-center",lde);const ude=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],dde=Ge("text-align-end",ude);const hde=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],fde=Ge("text-align-start",hde);const mde=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],sM=Ge("thermometer",mde);const pde=[["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"}]],td=Ge("timer",pde);const gde=[["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"}]],Rn=Ge("trash-2",gde);const xde=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],Z9=Ge("trending-down",xde);const bde=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Q9=Ge("trending-up",bde);const yde=[["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"}]],qn=Ge("triangle-alert",yde);const vde=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],_de=Ge("underline",vde);const wde=[["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"}]],J9=Ge("unlink",wde);const Sde=[["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"}]],ua=Ge("upload",Sde);const Mde=[["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"}]],i3=Ge("user",Mde);const Ede=[["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"}]],Ade=Ge("users",Ede);const Tde=[["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"}]],eW=Ge("video",Tde);const Nde=[["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"}]],Cde=Ge("volume-2",Nde);const kde=[["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"}]],Pde=Ge("volume-x",kde);const jde=[["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=Ge("wifi-off",jde);const Rde=[["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"}]],SR=Ge("wifi",Rde);const Dde=[["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"}]],tW=Ge("wind",Dde);const Ode=[["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"}]],_d=Ge("wrench",Ode);const Lde=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Wt=Ge("x",Lde);const Ide=[["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"}]],Fde=Ge("zoom-in",Ide);const Ude=[["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=Ge("zap",Ude);const zde=[["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"}]],Bde=Ge("zoom-out",zde),Ln="/api/v1";async function Fe(t,e={}){const n=await fetch(`${Ln}${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:()=>Fe("/printers/"),getPrinter:t=>Fe(`/printers/${t}`),createPrinter:t=>Fe("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Fe(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Fe(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>Fe(`/printers/${t}/status`),refreshPrinterStatus:t=>Fe(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Fe(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Fe(`/printers/${t}/disconnect`,{method:"POST"}),stopPrint:t=>Fe(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Fe(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Fe(`/printers/${t}/print/resume`,{method:"POST"}),getPrintableObjects:t=>Fe(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Fe(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>Fe(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Fe(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Fe(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Fe(`/printers/${t}/logging`),clearMQTTLogs:t=>Fe(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Fe(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${Ln}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>Fe(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Fe(`/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)),Fe(`/archives/?${i}`)},getArchive:t=>Fe(`/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)),Fe(`/archives/search?${n}`)},rebuildSearchIndex:()=>Fe("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Fe(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Fe(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Fe(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Fe("/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)),Fe(`/archives/analysis/failures?${e}`)},compareArchives:t=>Fe(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Fe(`/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(`${Ln}/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(`${Ln}/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=>Fe(`/archives/${t}/duplicates`),backfillContentHashes:()=>Fe("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${Ln}/archives/${t}/thumbnail?v=${Date.now()}`,getArchiveDownload:t=>`${Ln}/archives/${t}/download`,getArchiveGcode:t=>`${Ln}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${Ln}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${Ln}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Fe(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Fe(`/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(`${Ln}/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=>Fe(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Fe(`/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(`${Ln}/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)=>`${Ln}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${Ln}/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)=>Fe(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${Ln}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${Ln}/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(`${Ln}/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=>Fe(`/archives/${t}/source`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${Ln}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Fe(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Fe(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Fe(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${Ln}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${Ln}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchiveFilamentRequirements:t=>Fe(`/archives/${t}/filament-requirements`),reprintArchive:(t,e)=>Fe(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST"}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${Ln}/archives/upload?printer_id=${e}`:`${Ln}/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?`${Ln}/archives/upload-bulk?printer_id=${e}`:`${Ln}/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:()=>Fe("/settings/"),updateSettings:t=>Fe("/settings/",{method:"PUT",body:JSON.stringify(t)}),resetSettings:()=>Fe("/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=`${Ln}/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=`${Ln}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>Fe("/settings/check-ffmpeg"),getCloudStatus:()=>Fe("/cloud/status"),cloudLogin:(t,e,n="global")=>Fe("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>Fe("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>Fe("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Fe("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Fe(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Fe(`/cloud/settings/${t}`),createCloudSetting:t=>Fe("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Fe(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Fe(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Fe("/cloud/devices"),getCloudFields:t=>Fe(`/cloud/fields/${t}`),getAllCloudFields:()=>Fe("/cloud/fields"),getFilamentInfo:t=>Fe("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Fe("/smart-plugs/"),getSmartPlug:t=>Fe(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Fe(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>Fe("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Fe(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Fe(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Fe(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Fe(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Fe("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${Ln}/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:()=>Fe("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${Ln}/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:()=>Fe("/smart-plugs/discover/devices"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Fe(`/queue/?${n}`)},getQueueItem:t=>Fe(`/queue/${t}`),addToQueue:t=>Fe("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Fe(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Fe(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Fe("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Fe(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Fe(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Fe(`/queue/${t}/start`,{method:"POST"}),getKProfiles:(t,e="0.4")=>Fe(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Fe(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Fe(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Fe(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Fe(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Fe(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Fe(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Fe(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Fe(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>Fe(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Fe(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),listFilaments:()=>Fe("/filaments/"),getFilament:t=>Fe(`/filaments/${t}`),getFilamentsByType:t=>Fe(`/filaments/by-type/${t}`),getNotificationProviders:()=>Fe("/notifications/"),getNotificationProvider:t=>Fe(`/notifications/${t}`),createNotificationProvider:t=>Fe("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Fe(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Fe(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Fe(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Fe("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Fe("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Fe("/notification-templates"),getNotificationTemplate:t=>Fe(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Fe(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Fe(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Fe("/notification-templates/variables"),previewTemplate:t=>Fe("/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)),Fe(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Fe(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Fe(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Fe("/spoolman/status"),connectSpoolman:()=>Fe("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Fe("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Fe(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Fe("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Fe("/spoolman/spools"),getSpoolmanFilaments:()=>Fe("/spoolman/filaments"),getUnlinkedSpools:()=>Fe("/spoolman/spools/unlinked"),linkSpool:(t,e)=>Fe(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>Fe("/updates/version"),checkForUpdates:()=>Fe("/updates/check"),applyUpdate:()=>Fe("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Fe("/updates/status"),getMaintenanceTypes:()=>Fe("/maintenance/types"),createMaintenanceType:t=>Fe("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Fe(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Fe(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Fe("/maintenance/overview"),getPrinterMaintenance:t=>Fe(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Fe(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Fe(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Fe(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Fe("/maintenance/summary"),setPrinterHours:(t,e)=>Fe(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Fe(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Fe(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${Ln}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${Ln}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Fe(`/printers/${t}/camera/test`),getExternalLinks:()=>Fe("/external-links/"),getExternalLink:t=>Fe(`/external-links/${t}`),createExternalLink:t=>Fe("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Fe(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Fe(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Fe("/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(`${Ln}/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=>Fe(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${Ln}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Fe(`/projects/?${e}`)},getProject:t=>Fe(`/projects/${t}`),createProject:t=>Fe("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Fe(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Fe(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Fe(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Fe(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Fe(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Fe(`/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(`${Ln}/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)=>`${Ln}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Fe(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Fe(`/projects/${t}/bom`),createBOMItem:(t,e)=>Fe(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Fe(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Fe(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Fe("/projects/templates/"),createTemplateFromProject:t=>Fe(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Fe(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Fe(`/projects/${t}/timeline?limit=${e}`),getAPIKeys:()=>Fe("/api-keys/"),createAPIKey:t=>Fe("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Fe(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Fe(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Fe(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Fe("/system/info")},nl={getInfo:()=>Fe("/discovery/info"),getStatus:()=>Fe("/discovery/status"),startDiscovery:(t=10)=>Fe(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Fe("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Fe("/discovery/printers"),startSubnetScan:(t,e=1)=>Fe("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Fe("/discovery/scan/status"),stopSubnetScan:()=>Fe("/discovery/scan/stop",{method:"POST"})},f1={getSettings:()=>Fe("/settings/virtual-printer"),getModels:()=>Fe("/settings/virtual-printer/models"),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),t.model!==void 0&&e.set("model",t.model),Fe(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},yx={list:()=>Fe("/pending-uploads/"),getCount:()=>Fe("/pending-uploads/count"),get:t=>Fe(`/pending-uploads/${t}`),archive:(t,e)=>Fe(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Fe(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Fe("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Fe("/pending-uploads/discard-all",{method:"DELETE"})},m1={checkUpdates:()=>Fe("/firmware/updates"),checkPrinterUpdate:t=>Fe(`/firmware/updates/${t}`),prepareUpload:t=>Fe(`/firmware/updates/${t}/prepare`),startUpload:t=>Fe(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Fe(`/firmware/updates/${t}/upload/status`)},p1={getDebugLoggingState:()=>Fe("/support/debug-logging"),setDebugLogging:t=>Fe("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t=await fetch(`${Ln}/support/bundle`);if(!t.ok){const l=await t.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${t.status}`)}const n=t.headers.get("Content-Disposition")?.match(/filename=(.+)/),r=n?n[1]:"bambuddy-support.zip",i=await t.blob(),a=window.URL.createObjectURL(i),s=document.createElement("a");s.href=a,s.download=r,document.body.appendChild(s),s.click(),document.body.removeChild(s),window.URL.revokeObjectURL(a)}},nW=S.createContext(void 0);function Hde({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,b]=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&&(b(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"),x=N=>n(N),y=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=>{b(N),localStorage.setItem("light-accent",N),_e.updateSettings({light_accent:N}).catch(()=>{})};return o.jsx(nW.Provider,{value:{mode:e,darkStyle:r,darkBackground:a,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:p,toggleMode:v,setMode:x,setDarkStyle:y,setDarkBackground:E,setDarkAccent:w,setLightStyle:A,setLightBackground:T,setLightAccent:C},children:t})}function og(){const t=S.useContext(nW);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function At({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 Ui({children:t,className:e=""}){return o.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Tt({children:t,className:e=""}){return o.jsx("div",{className:`p-6 ${e}`,children:t})}function $de(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 CU({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 Vde({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=ng(),i=$de(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(At,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:o.jsxs(Tt,{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(e3,{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(ui,{className:"w-3 h-3 text-bambu-gray"})]}),o.jsx("div",{className:"flex gap-1",children:s.keys.map(l=>o.jsx(CU,{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(CU,{children:"Esc"})," or click outside to close"]})})]})})})}function Pe({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 mr({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(At,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:o.jsxs(Tt,{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(qn,{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(Pe,{variant:"secondary",onClick:s,className:"flex-1",children:r}),o.jsx(Pe,{onClick:a,className:`flex-1 ${c.button}`,children:n})]})]})})})}function Gde({plug:t}){const e=dn(),[n,r]=S.useState(null),{data:i,isLoading:a}=pt({queryKey:["smart-plug-status",t.id],queryFn:()=>_e.getSmartPlugStatus(t.id),refetchInterval:1e4}),s=_t({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(uo,{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(xt,{className:"w-3 h-3 text-bambu-gray animate-spin"}):c?o.jsxs(o.Fragment,{children:[o.jsx(SR,{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(xt,{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(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(iM,{className:"w-4 h-4"})})]})]}),n&&o.jsx(mr,{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 kU({onClose:t}){const{data:e,isLoading:n}=pt({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(uo,{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(xt,{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(uo,{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(Gde,{plug:i},i.id))})})]})}const rW=[{name:"globe",icon:Ap},{name:"link",icon:Cb},{name:"external-link",icon:ui},{name:"book",icon:Goe},{name:"file-text",icon:As},{name:"home",icon:Ece},{name:"star",icon:Np},{name:"heart",icon:wce},{name:"bookmark",icon:qoe},{name:"shopping-cart",icon:q9},{name:"music",icon:r3},{name:"video",icon:eW},{name:"image",icon:Nb},{name:"camera",icon:R0},{name:"map",icon:Kce},{name:"compass",icon:Cle},{name:"coffee",icon:Ele},{name:"gift",icon:uce},{name:"wrench",icon:_d},{name:"zap",icon:sf},{name:"cloud",icon:tM},{name:"database",icon:Ep},{name:"folder",icon:G9},{name:"mail",icon:Wce},{name:"phone",icon:_ue},{name:"user",icon:i3},{name:"users",icon:Ade},{name:"server",icon:ph},{name:"terminal",icon:Y9},{name:"code",icon:H9}];function oM(t){return rW.find(n=>n.name===t)?.icon||Cb}function Wde({value:t,onChange:e}){const[n,r]=S.useState(!1),i=oM(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:rW.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 PU=768;function iW(){const[t,e]=S.useState(()=>typeof window<"u"?window.innerWidth<PU:!1);return S.useEffect(()=>{const n=window.matchMedia(`(max-width: ${PU-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:qi,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:co,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:Jr,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:rle,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:tM,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:_d,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:Bo,labelKey:"nav.projects"},{id:"settings",to:"/settings",icon:wR,labelKey:"nav.settings"}];function qde(){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 Kde(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function ZA(t){return t.startsWith("ext-")}function aW(){return localStorage.getItem("defaultView")||"/"}function Xde(t){localStorage.setItem("defaultView",t)}function Yde(){const t=Eb(),e=Rd(),{mode:n,toggleMode:r}=og(),{t:i}=ng(),a=iW(),[s,l]=S.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[c,u]=S.useState(!1),[d,f]=S.useState(!1),[g,p]=S.useState(!1),[b,v]=S.useState(qde),[x,y]=S.useState(null),[E,w]=S.useState(null),A=S.useRef(!1),[T,C]=S.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),{data:N}=pt({queryKey:["version"],queryFn:_e.getVersion,staleTime:1/0}),{data:O}=pt({queryKey:["settings"],queryFn:_e.getSettings,staleTime:300*1e3}),{data:k}=pt({queryKey:["updateCheck"],queryFn:_e.checkForUpdates,enabled:O?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:j}=pt({queryKey:["external-links"],queryFn:_e.getExternalLinks}),{data:z}=pt({queryKey:["smart-plugs"],queryFn:_e.getSmartPlugs,staleTime:30*1e3}),I=z?.some(Q=>Q.show_in_switchbar)??!1,{data:q}=pt({queryKey:["debugLogging"],queryFn:p1.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),[R,W]=S.useState(null);S.useEffect(()=>{if(!q?.enabled||!q.enabled_at){W(null);return}const Q=new Date(q.enabled_at).getTime(),Ee=()=>{W(Math.floor((Date.now()-Q)/1e3))};Ee();const he=setInterval(Ee,1e3);return()=>clearInterval(he)},[q?.enabled,q?.enabled_at]);const K=new Map(L0.map(Q=>[Q.id,Q])),G=new Map((j||[]).map(Q=>[`ext-${Q.id}`,Q])),J=(()=>{const Q=[],Ee=new Set;for(const he of b)(K.has(he)||G.has(he))&&(Q.push(he),Ee.add(he));for(const he of L0)Ee.has(he.id)||(Q.push(he.id),Ee.add(he.id));for(const he of j||[]){const ue=`ext-${he.id}`;Ee.has(ue)||(Q.push(ue),Ee.add(ue))}return Q})(),ee=(Q,Ee)=>{y(Ee),Q.dataTransfer.effectAllowed="move",Q.dataTransfer.setData("text/plain",Ee)},Z=(Q,Ee)=>{Q.preventDefault(),Q.dataTransfer.dropEffect="move",w(Ee)},F=()=>{w(null)},V=(Q,Ee)=>{if(Q.preventDefault(),x===null||x===Ee){y(null),w(null);return}const he=[...J],ue=he.indexOf(x),Ae=he.indexOf(Ee);if(ue===-1||Ae===-1){y(null),w(null);return}he.splice(ue,1),he.splice(Ae,0,x),v(he),Kde(he),y(null),w(null)},ne=()=>{y(null),w(null)},le=k?.update_available&&k.latest_version&&k.latest_version!==T,oe=()=>{k?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",k.latest_version),C(k.latest_version))};S.useEffect(()=>{if(!A.current&&e.pathname==="/"){const Q=aW();Q!=="/"&&(A.current=!0,t(Q,{replace:!0}))}},[e.pathname,t]),S.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(s))},[s]),S.useEffect(()=>{a&&u(!1)},[e.pathname,a]);const pe=S.useCallback(Q=>{const Ee=Q.target;if(!(Ee.tagName==="INPUT"||Ee.tagName==="TEXTAREA"||Ee.isContentEditable)&&!Q.metaKey&&!Q.ctrlKey&&!Q.altKey){const he=parseInt(Q.key);if(he>=1&&he<=J.length&&he<=9){const ue=J[he-1];if(Q.preventDefault(),ZA(ue)){const Ae=ue.replace("ext-","");t(`/external/${Ae}`)}else{const Ae=K.get(ue);Ae&&t(Ae.to)}return}switch(Q.key){case"?":Q.preventDefault(),f(!0);break;case"Escape":f(!1);break}}},[t,J,K]);return S.useEffect(()=>(document.addEventListener("keydown",pe),()=>document.removeEventListener("keydown",pe)),[pe]),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(nue,{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:J.map(Q=>{if(ZA(Q)){const he=G.get(Q);if(!he)return null;const ue=he.custom_icon?null:oM(he.icon);return o.jsx("li",{draggable:!0,onDragStart:Ae=>ee(Ae,Q),onDragOver:Ae=>Z(Ae,Q),onDragLeave:F,onDrop:Ae=>V(Ae,Q),onDragEnd:ne,className:`relative ${x===Q?"opacity-50":""} ${E===Q&&x!==Q?"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/${he.id}`,className:({isActive:Ae})=>`flex items-center ${a||s?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${Ae?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!s?he.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"}),he.custom_icon?o.jsx("img",{src:`/api/v1/external-links/${he.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):ue&&o.jsx(ue,{className:"w-5 h-5 flex-shrink-0"}),(a||s)&&o.jsx("span",{children:he.name})]})},Q)}else{const he=K.get(Q);if(!he)return null;const{to:ue,icon:Ae,labelKey:fe}=he;return o.jsx("li",{draggable:!0,onDragStart:at=>ee(at,Q),onDragOver:at=>Z(at,Q),onDragLeave:F,onDrop:at=>V(at,Q),onDragEnd:ne,className:`relative ${x===Q?"opacity-50":""} ${E===Q&&x!==Q?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:o.jsxs(Gx,{to:ue,className:({isActive:at})=>`flex items-center ${a||s?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${at?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!s?i(fe):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(Ae,{className:"w-5 h-5 flex-shrink-0"}),(a||s)&&o.jsx("span",{children:i(fe)})]})},Q)}})})}),!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(ef,{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:[I&&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(uo,{className:"w-5 h-5"})}),g&&o.jsx(kU,{onClose:()=>p(!1)})]}),o.jsx(Gx,{to:"/system",className:({isActive:Q})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${Q?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:o.jsx(yd,{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(EU,{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(e3,{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(NU,{className:"w-5 h-5"}):o.jsx(W1,{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(XA,{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(XA,{className:"w-5 h-5"})}),I&&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(uo,{className:"w-5 h-5"})}),g&&o.jsx(kU,{onClose:()=>p(!1)})]}),o.jsx(Gx,{to:"/system",className:({isActive:Q})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${Q?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:o.jsx(yd,{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(EU,{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(e3,{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(NU,{className:"w-5 h-5"}):o.jsx(W1,{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:[q?.enabled&&o.jsx("div",{className:"bg-amber-500/20 border-b border-amber-500/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(B9,{className:"w-4 h-4 text-amber-500 animate-pulse"}),o.jsxs("span",{className:"text-amber-200",children:[i("support.debugLoggingActive",{defaultValue:"Debug logging is active"}),R!==null&&o.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(R/60),"m ",R%60,"s)"]})]}),o.jsx("button",{onClick:()=>t("/system"),className:"text-amber-400 hover:text-amber-300 font-medium underline ml-2",children:i("support.manageLogs",{defaultValue:"Manage"})})]})}),le&&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(XA,{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:oe,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(use,{})]}),d&&o.jsx(Vde,{onClose:()=>f(!1),sidebarItems:J.map(Q=>{if(ZA(Q)){const Ee=G.get(Q);return Ee?{type:"external",label:Ee.name}:null}else{const Ee=K.get(Q);return Ee?{type:"nav",label:Ee.labelKey,labelKey:Ee.labelKey}:null}}).filter(Boolean)})]})}const sW=S.createContext(void 0);function vr(){const t=S.useContext(sW);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Zde={success:o.jsx(Ar,{className:"w-5 h-5 text-green-400"}),error:o.jsx(Ra,{className:"w-5 h-5 text-red-400"}),warning:o.jsx(Sa,{className:"w-5 h-5 text-yellow-400"}),info:o.jsx(yd,{className:"w-5 h-5 text-blue-400"}),loading:o.jsx(xt,{className:"w-5 h-5 text-bambu-green animate-spin"})},Qde={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 Jde({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(sW.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 ${Qde[s.type]}`,children:[Zde[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 ehe(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 jU(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 the(t,e){if(e)return G9;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return V9;case"gcode":return As;case"mp4":case"avi":return Ih;case"png":case"jpg":case"jpeg":return Nb;default:return hR}}function nhe({printerId:t,printerName:e,onClose:n}){const{showToast:r}=vr(),i=dn(),[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:b,refetch:v}=pt({queryKey:["printerFiles",t,a],queryFn:()=>_e.getPrinterFiles(t,a)}),{data:x}=pt({queryKey:["printerStorage",t],queryFn:()=>_e.getPrinterStorage(t),staleTime:3e4}),y=_t({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(pR,{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:[x&&(x.used_bytes!=null||x.free_bytes!=null)&&o.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[x.used_bytes!=null&&o.jsxs("span",{children:["Used: ",jU(x.used_bytes)]}),x.used_bytes!=null&&x.free_bytes!=null&&o.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),x.free_bytes!=null&&o.jsxs("span",{children:["Free: ",jU(x.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(Pe,{variant:"secondary",size:"sm",onClick:()=>v(),disabled:b,children:o.jsx(li,{className:`w-4 h-4 ${b?"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(ef,{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:b?o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(xt,{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=the(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:ehe(N.size)}),N.is_directory&&o.jsx(ef,{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(Pe,{variant:"secondary",disabled:!l,onClick:()=>l&&A(l),children:[o.jsx(Wi,{className:"w-4 h-4"}),"Download"]}),o.jsxs(Pe,{variant:"secondary",disabled:!l||y.isPending,onClick:()=>l&&T(l),className:"text-red-400 hover:text-red-300",children:[y.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&o.jsx(mr,{title:"Delete File",message:`Delete "${f.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{y.mutate(f),g(null)},onCancel:()=>g(null)})]})}function rhe({printerId:t,printerName:e,onClose:n}){const r=dn(),[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:b,refetch:v}=pt({queryKey:["mqtt-logs",t],queryFn:()=>_e.getMQTTLogs(t),refetchInterval:1e3}),x=_t({mutationFn:()=>_e.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),y=_t({mutationFn:()=>_e.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),E=_t({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 z=new Set(j);return z.has(k)?z.delete(k):z.add(k),z})},A=k=>new Date(k).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),T=(k,j)=>{if(k==null)return"<empty>";const z=typeof k=="string"?JSON.parse(k):k,I=JSON.stringify(z,null,j?2:0);return!j&&I.length>100?I.substring(0,100)+"...":I},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(),z=k.topic.toLowerCase().includes(j),q=JSON.stringify(k.payload).toLowerCase().includes(j);return z||q}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(Pe,{size:"sm",variant:"secondary",onClick:()=>y.mutate(),disabled:y.isPending,children:[o.jsx(af,{className:"w-4 h-4"}),"Stop"]}):o.jsxs(Pe,{size:"sm",onClick:()=>x.mutate(),disabled:x.isPending,children:[o.jsx(Hc,{className:"w-4 h-4"}),"Start Logging"]}),o.jsxs(Pe,{size:"sm",variant:"secondary",onClick:()=>E.mutate(),disabled:E.isPending||N.length===0,children:[o.jsx(Rn,{className:"w-4 h-4"}),"Clear"]}),o.jsx(Pe,{size:"sm",variant:"secondary",onClick:()=>v(),disabled:b,children:o.jsx(li,{className:`w-4 h-4 ${b?"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 z=s.has(j),I=k.direction==="in";return o.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${z?"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 ${I?"text-blue-400":"text-green-400"}`,title:I?"Incoming":"Outgoing",children:I?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})]}),z?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(Pe,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const a3={"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 ihe(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:qn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:qn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:Sa};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:yd}}}function s3(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 ahe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=s3(e.attr,n);return a3[r]!==void 0})}function she(){return"https://wiki.bambulab.com/en/hms/home"}function ohe({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=s3(i.attr,a);return a3[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(qn,{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(Sa,{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}=ihe(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=s3(i.attr,d),g=a3[f],p=she(),b=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:["[",b,"]"]}),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(ui,{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 lhe(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 che({printerId:t}){const{data:e}=pt({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"}),lhe(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 oW(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=oW(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function In(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=oW(t))&&(r&&(r+=" "),r+=e);return r}var uhe=["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 MR(t){if(typeof t!="string")return!1;var e=uhe;return e.includes(t)}var dhe=["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"],hhe=new Set(dhe);function lW(t){return typeof t!="string"?!1:hhe.has(t)}function cW(t){return typeof t=="string"&&t.startsWith("data-")}function Ia(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(lW(n)||cW(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 Ia(e)}return typeof t=="object"&&!Array.isArray(t)?Ia(t):null}function da(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(lW(n)||cW(n)||MR(n))&&(e[n]=t[n]);return e}function fhe(t){return t==null?null:S.isValidElement(t)?da(t.props):typeof t=="object"&&!Array.isArray(t)?da(t):null}var mhe=["children","width","height","viewBox","className","style","title","desc"];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 phe(t,e){if(t==null)return{};var n,r,i=ghe(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 ghe(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 ER=S.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:s,style:l,title:c,desc:u}=t,d=phe(t,mhe),f=a||{width:r,height:i,x:0,y:0},g=In("recharts-surface",s);return S.createElement("svg",o3({},da(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)}),xhe=["children","className"];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)}function bhe(t,e){if(t==null)return{};var n,r,i=yhe(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 yhe(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=bhe(t,xhe),a=In("recharts-layer",r);return S.createElement("g",l3({className:a},da(i),{ref:e}),n)}),uW=S.createContext(null),vhe=()=>S.useContext(uW);function br(t){return function(){return t}}const dW=Math.cos,K1=Math.sin,Xo=Math.sqrt,X1=Math.PI,lM=2*X1,c3=Math.PI,u3=2*c3,gh=1e-6,_he=u3-gh;function hW(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function whe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return hW;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 She{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?hW:whe(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>gh)if(!(Math.abs(f*c-u*d)>gh)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let p=r-s,b=i-l,v=c*c+u*u,x=p*p+b*b,y=Math.sqrt(v),E=Math.sqrt(g),w=a*Math.tan((c3-Math.acos((v+g-x)/(2*y*E)))/2),A=w/E,T=w/y;Math.abs(A-1)>gh&&this._append`L${e+A*d},${n+A*f}`,this._append`A${a},${a},0,0,${+(f*p>d*b)},${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)>gh||Math.abs(this._y1-d)>gh)&&this._append`L${u},${d}`,r&&(g<0&&(g=g%u3+u3),g>_he?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>gh&&this._append`A${r},${r},0,${+(g>=c3)},${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 AR(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 She(e)}function TR(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function fW(t){this._context=t}fW.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 cM(t){return new fW(t)}function mW(t){return t[0]}function pW(t){return t[1]}function gW(t,e){var n=br(!0),r=null,i=cM,a=null,s=AR(l);t=typeof t=="function"?t:t===void 0?mW:br(t),e=typeof e=="function"?e:e===void 0?pW:br(e);function l(c){var u,d=(c=TR(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:br(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:br(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:br(!!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=br(!0),a=null,s=cM,l=null,c=AR(u);t=typeof t=="function"?t:t===void 0?mW:br(+t),e=typeof e=="function"?e:br(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?pW:br(+n);function u(f){var g,p,b,v=(f=TR(f)).length,x,y=!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(x=f[g],g,f))===y)if(y=!y)p=g,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),b=g-1;b>=p;--b)l.point(w[b],A[b]);l.lineEnd(),l.areaEnd()}y&&(w[g]=+t(x,g,f),A[g]=+e(x,g,f),l.point(r?+r(x,g,f):w[g],n?+n(x,g,f):A[g]))}if(E)return l=null,E+""||null}function d(){return gW().defined(i).curve(s).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:br(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:br(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:br(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:br(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:br(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:br(+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:br(!!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 xW{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 Mhe(t){return new xW(t,!0)}function Ehe(t){return new xW(t,!1)}const NR={draw(t,e){const n=Xo(e/X1);t.moveTo(n,0),t.arc(0,0,n,0,lM)}},Ahe={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()}},bW=Xo(1/3),The=bW*2,Nhe={draw(t,e){const n=Xo(e/The),r=n*bW;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},Che={draw(t,e){const n=Xo(e),r=-n/2;t.rect(r,r,n,n)}},khe=.8908130915292852,yW=K1(X1/10)/K1(7*X1/10),Phe=K1(lM/10)*yW,jhe=-dW(lM/10)*yW,Rhe={draw(t,e){const n=Xo(e*khe),r=Phe*n,i=jhe*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const s=lM*a/5,l=dW(s),c=K1(s);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},QA=Xo(3),Dhe={draw(t,e){const n=-Xo(e/(QA*3));t.moveTo(0,n*2),t.lineTo(-QA*n,-n),t.lineTo(QA*n,-n),t.closePath()}},Vs=-.5,Gs=Xo(3)/2,d3=1/Xo(12),Ohe=(d3/2+1)*3,Lhe={draw(t,e){const n=Xo(e/Ohe),r=n/2,i=n*d3,a=r,s=n*d3+n,l=-a,c=s;t.moveTo(r,i),t.lineTo(a,s),t.lineTo(l,c),t.lineTo(Vs*r-Gs*i,Gs*r+Vs*i),t.lineTo(Vs*a-Gs*s,Gs*a+Vs*s),t.lineTo(Vs*l-Gs*c,Gs*l+Vs*c),t.lineTo(Vs*r+Gs*i,Vs*i-Gs*r),t.lineTo(Vs*a+Gs*s,Vs*s-Gs*a),t.lineTo(Vs*l+Gs*c,Vs*c-Gs*l),t.closePath()}};function Ihe(t,e){let n=null,r=AR(i);t=typeof t=="function"?t:br(t||NR),e=typeof e=="function"?e:br(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:br(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:br(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function Y1(){}function Z1(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 vW(t){this._context=t}vW.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:Z1(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:Z1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Fhe(t){return new vW(t)}function _W(t){this._context=t}_W.prototype={areaStart:Y1,areaEnd:Y1,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:Z1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Uhe(t){return new _W(t)}function wW(t){this._context=t}wW.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:Z1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function zhe(t){return new wW(t)}function SW(t){this._context=t}SW.prototype={areaStart:Y1,areaEnd:Y1,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 Bhe(t){return new SW(t)}function RU(t){return t<0?-1:1}function DU(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(RU(a)+RU(s))*Math.min(Math.abs(a),Math.abs(s),.5*Math.abs(l))||0}function OU(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function JA(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 Q1(t){this._context=t}Q1.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:JA(this,this._t0,OU(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,JA(this,OU(this,n=DU(this,t,e)),n);break;default:JA(this,this._t0,n=DU(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function MW(t){this._context=new EW(t)}(MW.prototype=Object.create(Q1.prototype)).point=function(t,e){Q1.prototype.point.call(this,e,t)};function EW(t){this._context=t}EW.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 Hhe(t){return new Q1(t)}function $he(t){return new MW(t)}function AW(t){this._context=t}AW.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=LU(t),i=LU(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 LU(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 Vhe(t){return new AW(t)}function uM(t,e){this._context=t,this._t=e}uM.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 Ghe(t){return new uM(t,.5)}function Whe(t){return new uM(t,0)}function qhe(t){return new uM(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 h3(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Khe(t,e){return t[e]}function Xhe(t){const e=[];return e.key=t,e}function Yhe(){var t=br([]),e=h3,n=kp,r=Khe;function i(a){var s=Array.from(t.apply(this,arguments),Xhe),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=TR(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:br(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:br(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?h3:typeof a=="function"?a:br(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??kp,i):n},i}function Zhe(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 Qhe(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 Jhe(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,b=0;b<l;++b){var v=t[e[b]],x=v[r][1]||0,y=v[r-1][1]||0;p+=x-y}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 eT={},tT={},IU;function efe(){return IU||(IU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(tT)),tT}var nT={},FU;function TW(){return FU||(FU=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})(nT)),nT}var rT={},UU;function CR(){return UU||(UU=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})(rT)),rT}var iT={},aT={},zU;function tfe(){return zU||(zU=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})(aT)),aT}var BU;function kR(){return BU||(BU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tfe(),n=CR();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})(iT)),iT}var HU;function PR(){return HU||(HU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=efe(),n=TW(),r=CR(),i=kR();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})(eT)),eT}var sT,$U;function nfe(){return $U||($U=1,sT=PR().get),sT}var rfe=nfe();const lf=vo(rfe);var $i=t=>t===0?0:t>0?1:-1,ss=t=>typeof t=="number"&&t!=+t,$c=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Ot=t=>(typeof t=="number"||t instanceof Number)&&!ss(t),xo=t=>Ot(t)||typeof t=="string",ife=0,I0=t=>{var e=++ife;return"".concat(t||"").concat(e)},wa=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(!Ot(e)&&typeof e!="string")return r;var a;if($c(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},NW=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 Wn(t,e,n){return Ot(t)&&Ot(e)?t+n*(e-t):e}function CW(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):lf(r,e))===n)}var Tr=t=>t===null||typeof t>"u",Pb=t=>Tr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function afe(t){return t!=null}function jb(){}var sfe=["type","size","sizeType"];function f3(){return f3=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},f3.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 GU(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){ofe(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 ofe(t,e,n){return(e=lfe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lfe(t){var e=cfe(t,"string");return typeof e=="symbol"?e:e+""}function cfe(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 ufe(t,e){if(t==null)return{};var n,r,i=dfe(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 dfe(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 kW={symbolCircle:NR,symbolCross:Ahe,symbolDiamond:Nhe,symbolSquare:Che,symbolStar:Rhe,symbolTriangle:Dhe,symbolWye:Lhe},hfe=Math.PI/180,ffe=t=>{var e="symbol".concat(Pb(t));return kW[e]||NR},mfe=(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*hfe;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}},pfe=(t,e)=>{kW["symbol".concat(Pb(t))]=e},jR=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=ufe(t,sfe),a=GU(GU({},i),{},{type:e,size:n,sizeType:r}),s="circle";typeof e=="string"&&(s=e);var l=()=>{var g=ffe(s),p=Ihe().type(g).size(mfe(n,r,s)),b=p();if(b!==null)return b},{className:c,cx:u,cy:d}=a,f=da(a);return Ot(u)&&Ot(d)&&Ot(n)?S.createElement("path",f3({},f,{className:In("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};jR.registerSymbol=pfe;var PW=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,RR=(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=>{MR(i)&&(r[i]=(a=>n[i](n,a)))}),r},gfe=(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];MR(i)&&typeof a=="function"&&(r||(r={}),r[i]=gfe(a,e,n))}),r};function WU(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 xfe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?WU(Object(n),!0).forEach(function(r){bfe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):WU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bfe(t,e,n){return(e=yfe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yfe(t){var e=vfe(t,"string");return typeof e=="symbol"?e:e+""}function vfe(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=xfe({},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 J1(){return J1=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},J1.apply(null,arguments)}function qU(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 _fe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qU(Object(n),!0).forEach(function(r){wfe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wfe(t,e,n){return(e=Sfe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sfe(t){var e=Mfe(t,"string");return typeof e=="symbol"?e:e+""}function Mfe(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 Ys=32,Efe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function Afe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Ys/2,a=Ys/6,s=Ys/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:Ys,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,`
  11. A`).concat(a,",").concat(a,",0,1,1,").concat(2*s,",").concat(i,`
  12. H`).concat(Ys,"M").concat(2*s,",").concat(i,`
  13. 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(Ys/8,"h").concat(Ys,"v").concat(Ys*3/4,"h").concat(-Ys,"z"),className:"recharts-legend-icon"});if(S.isValidElement(e.legendIcon)){var d=_fe({},e);return delete d.legendIcon,S.cloneElement(e.legendIcon,d)}return S.createElement(jR,{fill:l,cx:i,cy:i,size:Ys,sizeType:"diameter",type:c})}function Tfe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:s}=t,l={x:0,y:0,width:Ys,height:Ys},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=In({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var b=d.inactive?a:d.color,v=g?g(d.value,d,f):d.value;return S.createElement("li",J1({className:p,style:c,key:"legend-item-".concat(f)},Rb(t,d,f)),S.createElement(ER,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(v," legend icon")},S.createElement(Afe,{data:d,iconType:s,inactiveColor:a})),S.createElement("span",{className:"recharts-legend-item-text",style:{color:b}},v))})}var Nfe=t=>{var e=Lr(t,Efe),{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(Tfe,J1({},e,{payload:n})))},oT={},lT={},KU;function Cfe(){return KU||(KU=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})(lT)),lT}var cT={},XU;function jW(){return XU||(XU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(cT)),cT}var uT={},dT={},hT={},YU;function kfe(){return YU||(YU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(hT)),hT}var ZU;function DR(){return ZU||(ZU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=kfe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(dT)),dT}var fT={},QU;function Pfe(){return QU||(QU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(fT)),fT}var JU;function jfe(){return JU||(JU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=DR(),n=Pfe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(uT)),uT}var mT={},pT={},ez;function Rfe(){return ez||(ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=PR();function n(r){return function(i){return e.get(i,r)}}t.property=n})(pT)),pT}var gT={},xT={},bT={},yT={},tz;function RW(){return tz||(tz=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})(yT)),yT}var vT={},nz;function DW(){return nz||(nz=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})(vT)),vT}var _T={},rz;function OW(){return rz||(rz=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})(_T)),_T}var iz;function Dfe(){return iz||(iz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=RW(),n=DW(),r=OW();function i(d,f,g){return typeof g!="function"?i(d,f,()=>{}):a(d,f,function p(b,v,x,y,E,w){const A=g(b,v,x,y,E,w);return A!==void 0?!!A:a(b,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 b=Object.keys(f);if(d==null)return b.length===0;if(b.length===0)return!0;if(p?.has(f))return p.get(f)===d;p?.set(f,d);try{for(let v=0;v<b.length;v++){const x=b[v];if(!n.isPrimitive(d)&&!(x in d)||f[x]===void 0&&d[x]!==void 0||f[x]===null&&d[x]!==null||!g(d[x],f[x],x,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[b,v]of f.entries()){const x=d.get(b);if(g(x,v,b,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 b=new Set;for(let v=0;v<f.length;v++){const x=f[v];let y=!1;for(let E=0;E<d.length;E++){if(b.has(E))continue;const w=d[E];let A=!1;if(g(w,x,v,d,f,p)&&(A=!0),A){b.add(E),y=!0;break}}if(!y)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})(bT)),bT}var az;function LW(){return az||(az=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Dfe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(xT)),xT}var wT={},ST={},MT={},sz;function Ofe(){return sz||(sz=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})(MT)),MT}var ET={},oz;function IW(){return oz||(oz=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})(ET)),ET}var AT={},lz;function FW(){return lz||(lz=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]",b="[object Error]",v="[object DataView]",x="[object Uint8Array]",y="[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=b,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=x,t.uint8ClampedArrayTag=y})(AT)),AT}var TT={},cz;function Lfe(){return cz||(cz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(TT)),TT}var uz;function UW(){return uz||(uz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ofe(),n=IW(),r=FW(),i=DW(),a=Lfe();function s(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,g,p=new Map,b=void 0){const v=b?.(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 x=new Array(d.length);p.set(d,x);for(let y=0;y<d.length;y++)x[y]=l(d[y],y,g,p,b);return Object.hasOwn(d,"index")&&(x.index=d.index),Object.hasOwn(d,"input")&&(x.input=d.input),x}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const x=new RegExp(d.source,d.flags);return x.lastIndex=d.lastIndex,x}if(d instanceof Map){const x=new Map;p.set(d,x);for(const[y,E]of d)x.set(y,l(E,y,g,p,b));return x}if(d instanceof Set){const x=new Set;p.set(d,x);for(const y of d)x.add(l(y,void 0,g,p,b));return x}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const x=new(Object.getPrototypeOf(d)).constructor(d.length);p.set(d,x);for(let y=0;y<d.length;y++)x[y]=l(d[y],y,g,p,b);return x}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const x=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return p.set(d,x),c(x,d,g,p,b),x}if(typeof File<"u"&&d instanceof File){const x=new File([d],d.name,{type:d.type});return p.set(d,x),c(x,d,g,p,b),x}if(typeof Blob<"u"&&d instanceof Blob){const x=new Blob([d],{type:d.type});return p.set(d,x),c(x,d,g,p,b),x}if(d instanceof Error){const x=new d.constructor;return p.set(d,x),x.message=d.message,x.name=d.name,x.stack=d.stack,x.cause=d.cause,c(x,d,g,p,b),x}if(d instanceof Boolean){const x=new Boolean(d.valueOf());return p.set(d,x),c(x,d,g,p,b),x}if(d instanceof Number){const x=new Number(d.valueOf());return p.set(d,x),c(x,d,g,p,b),x}if(d instanceof String){const x=new String(d.valueOf());return p.set(d,x),c(x,d,g,p,b),x}if(typeof d=="object"&&u(d)){const x=Object.create(Object.getPrototypeOf(d));return p.set(d,x),c(x,d,g,p,b),x}return d}function c(d,f,g=d,p,b){const v=[...Object.keys(f),...e.getSymbols(f)];for(let x=0;x<v.length;x++){const y=v[x],E=Object.getOwnPropertyDescriptor(d,y);(E==null||E.writable)&&(d[y]=l(f[y],y,g,p,b))}}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})(ST)),ST}var dz;function Ife(){return dz||(dz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UW();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(wT)),wT}var hz;function Ffe(){return hz||(hz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LW(),n=Ife();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(gT)),gT}var NT={},CT={},kT={},fz;function Ufe(){return fz||(fz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UW(),n=FW();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})(kT)),kT}var mz;function zfe(){return mz||(mz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ufe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(CT)),CT}var PT={},jT={},pz;function zW(){return pz||(pz=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})(jT)),jT}var RT={},gz;function Bfe(){return gz||(gz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=IW();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(RT)),RT}var xz;function Hfe(){return xz||(xz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=TW(),n=zW(),r=Bfe(),i=kR();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})(PT)),PT}var bz;function $fe(){return bz||(bz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LW(),n=CR(),r=zfe(),i=PR(),a=Hfe();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})(NT)),NT}var yz;function Vfe(){return yz||(yz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=jW(),n=Rfe(),r=Ffe(),i=$fe();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})(mT)),mT}var vz;function Gfe(){return vz||(vz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Cfe(),n=jW(),r=jfe(),i=Vfe();function a(s,l=n.identity){return r.isArrayLikeObject(s)?e.uniqBy(Array.from(s),i.iteratee(l)):[]}t.uniqBy=a})(oT)),oT}var DT,_z;function Wfe(){return _z||(_z=1,DT=Gfe().uniqBy),DT}var qfe=Wfe();const wz=vo(qfe);function BW(t,e,n){return e===!0?wz(t,n):typeof e=="function"?wz(t,e):t}var OT={exports:{}},LT={};var Sz;function Kfe(){if(Sz)return LT;Sz=1;var t=tg(),e=c9();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 LT.useSyncExternalStoreWithSelector=function(u,d,f,g,p){var b=a(null);if(b.current===null){var v={hasValue:!1,value:null};b.current=v}else v=b.current;b=l(function(){function y(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 y(d())},T===null?void 0:function(){return y(T())}]},[d,f,g,p]);var x=i(u,b[0],b[1]);return s(function(){v.hasValue=!0,v.value=x},[x]),c(x),x},LT}var Mz;function Xfe(){return Mz||(Mz=1,OT.exports=Kfe()),OT.exports}var HW=Xfe(),OR=S.createContext(null),Yfe=t=>t,xr=()=>{var t=S.useContext(OR);return t?t.store.dispatch:Yfe},g1=()=>{},Zfe=()=>g1,Qfe=(t,e)=>t===e;function Rt(t){var e=S.useContext(OR);return HW.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:Zfe,e?e.store.getState:g1,e?e.store.getState:g1,e?t:g1,Qfe)}function Jfe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function eme(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function tme(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 Ez=t=>Array.isArray(t)?t:[t];function nme(t){const e=Array.isArray(t[0])?t[0]:t;return tme(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function rme(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var ime=class{constructor(t){this.value=t}deref(){return this.value}},ame=typeof WeakRef<"u"?WeakRef:ime,sme=0,Az=1;function Pv(){return{s:sme,v:void 0,o:null,p:null}}function $W(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 b=l.o;b===null&&(l.o=b=new WeakMap);const v=b.get(p);v===void 0?(l=Pv(),b.set(p,l)):l=v}else{let b=l.p;b===null&&(l.p=b=new Map);const v=b.get(p);v===void 0?(l=Pv(),b.set(p,l)):l=v}}const u=l;let d;if(l.s===Az)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 ame(d):d}return u.s=Az,u.v=d,d}return s.clearCache=()=>{n=Pv(),s.resetResultsCount()},s.resultsCount=()=>a,s.resetResultsCount=()=>{a=0},s}function ome(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()),Jfe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:g=[],argsMemoize:p=$W,argsMemoizeOptions:b=[]}=d,v=Ez(g),x=Ez(b),y=nme(i),E=f(function(){return a++,u.apply(null,arguments)},...v),w=p(function(){s++;const T=rme(y,arguments);return l=E.apply(null,T),l},...x);return Object.assign(w,{resultFunc:u,memoizedResultFunc:E,dependencies:y,dependencyRecomputations:()=>s,resetDependencyRecomputations:()=>{s=0},lastResult:()=>l,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var Ze=ome($W),lme=Object.assign((t,e=Ze)=>{eme(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:()=>lme}),IT={},FT={},UT={},Tz;function cme(){return Tz||(Tz=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})(UT)),UT}var zT={},BT={},Nz;function VW(){return Nz||(Nz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(BT)),BT}var Cz;function ume(){return Cz||(Cz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=VW(),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})(zT)),zT}var kz;function dme(){return kz||(kz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=cme(),n=ume(),r=kR();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,b)=>{let v=p;for(let x=0;x<b.length&&v!=null;++x)v=v[b[x]];return v},d=(p,b)=>b==null||p==null?b:typeof p=="object"&&"key"in p?Object.hasOwn(b,p.key)?b[p.key]:u(b,p.path):typeof p=="function"?p(b):Array.isArray(p)?u(b,p):typeof b=="object"?b[p]:b,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(b=>d(b,p))})).slice().sort((p,b)=>{for(let v=0;v<f.length;v++){const x=e.compareValues(p.criteria[v],b.criteria[v],l[v]);if(x!==0)return x}return 0}).map(p=>p.original)}t.orderBy=i})(FT)),FT}var HT={},Pz;function hme(){return Pz||(Pz=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})(HT)),HT}var $T={},jz;function GW(){return jz||(jz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=zW(),n=DR(),r=RW(),i=OW();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})($T)),$T}var Rz;function fme(){return Rz||(Rz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dme(),n=hme(),r=GW();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})(IT)),IT}var VT,Dz;function mme(){return Dz||(Dz=1,VT=fme().sortBy),VT}var pme=mme();const dM=vo(pme);var WW=t=>t.legend.settings,gme=t=>t.legend.size,xme=t=>t.legend.payload,bme=Ze([xme,WW],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?dM(r,n):r});function yme(){return Rt(bme)}var jv=1;function qW(){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 ra(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 vme=typeof Symbol=="function"&&Symbol.observable||"@@observable",Oz=vme,GT=()=>Math.random().toString(36).substring(7).split("").join("."),_me={INIT:`@@redux/INIT${GT()}`,REPLACE:`@@redux/REPLACE${GT()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${GT()}`},ew=_me;function LR(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 KW(t,e,n){if(typeof t!="function")throw new Error(ra(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(ra(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(ra(1));return n(KW)(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((x,y)=>{s.set(y,x)}))}function d(){if(c)throw new Error(ra(3));return i}function f(x){if(typeof x!="function")throw new Error(ra(4));if(c)throw new Error(ra(5));let y=!0;u();const E=l++;return s.set(E,x),function(){if(y){if(c)throw new Error(ra(6));y=!1,u(),s.delete(E),a=null}}}function g(x){if(!LR(x))throw new Error(ra(7));if(typeof x.type>"u")throw new Error(ra(8));if(typeof x.type!="string")throw new Error(ra(17));if(c)throw new Error(ra(9));try{c=!0,i=r(i,x)}finally{c=!1}return(a=s).forEach(E=>{E()}),x}function p(x){if(typeof x!="function")throw new Error(ra(10));r=x,g({type:ew.REPLACE})}function b(){const x=f;return{subscribe(y){if(typeof y!="object"||y===null)throw new Error(ra(11));function E(){const A=y;A.next&&A.next(d())}return E(),{unsubscribe:x(E)}},[Oz](){return this}}}return g({type:ew.INIT}),{dispatch:g,subscribe:f,getState:d,replaceReducer:p,[Oz]:b}}function wme(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:ew.INIT})>"u")throw new Error(ra(12));if(typeof n(void 0,{type:ew.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(ra(13))})}function XW(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{wme(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],b=g(p,l);if(typeof b>"u")throw l&&l.type,new Error(ra(14));u[f]=b,c=c||b!==p}return c=c||r.length!==Object.keys(s).length,c?u:s}}function tw(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function Sme(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(ra(15))};const s={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(s));return a=tw(...l)(i.dispatch),{...i,dispatch:a}}}function YW(t){return LR(t)&&"type"in t&&typeof t.type=="string"}var ZW=Symbol.for("immer-nothing"),Lz=Symbol.for("immer-draftable"),Fa=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,nw="constructor",hM="prototype",m3="configurable",rw="enumerable",x1="writable",F0="value",Vc=t=>!!t&&!!t[Fa];function Go(t){return t?QW(t)||fM(t)||!!t[Lz]||!!t[nw]?.[Lz]||mM(t)||pM(t):!1}var Mme=Ns[hM][nw].toString(),Iz=new WeakMap;function QW(t){if(!t||!IR(t))return!1;const e=Pp(t);if(e===null||e===Ns[hM])return!0;const n=Ns.hasOwnProperty.call(e,nw)&&e[nw];if(n===Object)return!0;if(!Qm(n))return!1;let r=Iz.get(n);return r===void 0&&(r=Function.toString.call(n),Iz.set(n,r)),r===Mme}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[Fa];return e?e.type_:fM(t)?1:mM(t)?2:pM(t)?3:0}var Fz=(t,e,n=Ob(t))=>n===2?t.has(e):Ns[hM].hasOwnProperty.call(t,e),p3=(t,e,n=Ob(t))=>n===2?t.get(e):t[e],iw=(t,e,n,r=Ob(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function Eme(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var fM=Array.isArray,mM=t=>t instanceof Map,pM=t=>t instanceof Set,IR=t=>typeof t=="object",Qm=t=>typeof t=="function",WT=t=>typeof t=="boolean",yc=t=>t.copy_||t.base_,FR=t=>t.modified_?t.copy_:t.base_;function g3(t,e){if(mM(t))return new Map(t);if(pM(t))return new Set(t);if(fM(t))return Array[hM].slice.call(t);const n=QW(t);if(e===!0||e==="class_only"&&!n){const r=Ns.getOwnPropertyDescriptors(t);delete r[Fa];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const s=i[a],l=r[s];l[x1]===!1&&(l[x1]=!0,l[m3]=!0),(l.get||l.set)&&(r[s]={[m3]:!0,[x1]:!0,[rw]:l[rw],[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 UR(t,e=!1){return gM(t)||Vc(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)=>{UR(r,!0)},!1)),t}function Ame(){Ro(2)}var Rv={[F0]:Ame};function gM(t){return t===null||!IR(t)?!0:Ns.isFrozen(t)}var aw="MapSet",x3="Patches",JW={};function jp(t){const e=JW[t];return e||Ro(0,t),e}var Tme=t=>!!JW[t],U0,eq=()=>U0,Nme=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Tme(aw)?jp(aw):void 0});function Uz(t,e){e&&(t.patchPlugin_=jp(x3),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function b3(t){y3(t),t.drafts_.forEach(Cme),t.drafts_=null}function y3(t){t===U0&&(U0=t.parent_)}var zz=t=>U0=Nme(U0,t);function Cme(t){const e=t[Fa];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Bz(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Fa].modified_&&(b3(e),Ro(4)),Go(t)&&(t=Hz(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Fa].base_,t,e)}else t=Hz(e,n);return kme(e,t,!0),b3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==ZW?t:void 0}function Hz(t,e){if(gM(e))return e;const n=e[Fa];if(!n)return zR(e,t.handledSet_,t);if(!xM(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);rq(n,t)}return n.copy_}function kme(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&UR(e,n)}function tq(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var xM=(t,e)=>t.scope_===e,Pme=[];function nq(t,e,n,r){const i=yc(t),a=t.type_;if(r!==void 0&&p3(i,r,a)===e){iw(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;Db(i,(c,u)=>{if(Vc(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const s=t.draftLocations_.get(e)??Pme;for(const l of s)iw(i,l,n,a)}function jme(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!xM(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const s=FR(a);nq(t,a.draft_??a,s,n),rq(a,i)})}function rq(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)}tq(t)}}function Rme(t,e,n){const{scope_:r}=t;if(Vc(n)){const i=n[Fa];xM(i,r)&&i.callbacks_.push(function(){b1(t);const s=FR(i);nq(t,n,s,e)})}else Go(n)&&t.callbacks_.push(function(){const a=yc(t);p3(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&zR(p3(t.copy_,e,t.type_),r.handledSet_,r)})}function zR(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Vc(t)||e.has(t)||!Go(t)||gM(t)||(e.add(t),Db(t,(r,i)=>{if(Vc(i)){const a=i[Fa];if(xM(a,n)){const s=FR(a);iw(t,r,s,t.type_),tq(a)}}else Go(i)&&zR(i,e,n)})),t}function Dme(t,e){const n=fM(t),r={type_:n?1:0,scope_:e?e.scope_:eq(),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=BR;n&&(i=[r],a=z0);const{revoke:s,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=s,[l,r]}var BR={get(t,e){if(e===Fa)return t;const n=yc(t);if(!Fz(n,e,t.type_))return Ome(t,n,e);const r=n[e];if(t.finalized_||!Go(r))return r;if(r===qT(t.base_,e)){b1(t);const i=t.type_===1?+e:e,a=_3(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=iq(yc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=qT(yc(t),e),a=i?.[Fa];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(Eme(n,i)&&(n!==void 0||Fz(t.base_,e,t.type_)))return!0;b1(t),v3(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),Rme(t,e,n)),!0},deleteProperty(t,e){return b1(t),qT(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),v3(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&&{[x1]:!0,[m3]:t.type_!==1||e!=="length",[rw]:r[rw],[F0]:n[e]}},defineProperty(){Ro(11)},getPrototypeOf(t){return Pp(t.base_)},setPrototypeOf(){Ro(12)}},z0={};Db(BR,(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 BR.set.call(this,t[0],e,n,t[0])};function qT(t,e){const n=t[Fa];return(n?yc(n):t)[e]}function Ome(t,e,n){const r=iq(e,n);return r?F0 in r?r[F0]:r.get?.call(t.draft_):void 0}function iq(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 v3(t){t.modified_||(t.modified_=!0,t.parent_&&v3(t.parent_))}function b1(t){t.copy_||(t.assigned_=new Map,t.copy_=g3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Lme=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=zz(this),l=_3(s,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?b3(s):y3(s)}return Uz(s,i),Bz(a,s)}else if(!n||!IR(n)){if(a=r(n),a===void 0&&(a=n),a===ZW&&(a=void 0),this.autoFreeze_&&UR(a,!0),i){const s=[],l=[];jp(x3).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]},WT(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),WT(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),WT(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Go(e)||Ro(8),Vc(e)&&(e=Ho(e));const n=zz(this),r=_3(n,e,void 0);return r[Fa].isManual_=!0,y3(n),r}finishDraft(e,n){const r=e&&e[Fa];(!r||!r.isManual_)&&Ro(9);const{scope_:i}=r;return Uz(i,n),Bz(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(x3).applyPatches_;return Vc(e)?i(e,n):this.produce(e,a=>i(a,n))}};function _3(t,e,n,r){const[i,a]=mM(e)?jp(aw).proxyMap_(e,n):pM(e)?jp(aw).proxySet_(e,n):Dme(e,n);return(n?.scope_??eq()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?jme(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 Vc(t)||Ro(10,t),aq(t)}function aq(t){if(!Go(t)||gM(t))return t;const e=t[Fa];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=g3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=g3(t,!0);return Db(n,(i,a)=>{iw(n,i,aq(a))},r),e&&(e.finalized_=!1),n}var Ime=new Lme,sq=Ime.produce;function oq(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var Fme=oq(),Ume=oq,zme=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?tw:tw.apply(null,arguments)};function bo(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=>YW(r)&&r.type===t,n}var lq=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 $z(t){return Go(t)?sq(t,()=>{}):t}function Dv(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Bme(t){return typeof t=="boolean"}var Hme=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let s=new lq;return n&&(Bme(n)?s.push(Fme):s.push(Ume(n.extraArgument))),s},cq="RTK_autoBatch",Cr=()=>t=>({payload:t,meta:{[cq]:!0}}),Vz=t=>e=>{setTimeout(e,t)},uq=(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:Vz(10):t.type==="callback"?t.queueNotification:Vz(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?.[cq],a=!i,a&&(s||(s=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},$me=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new lq(t);return r&&i.push(uq(typeof r=="object"?r:void 0)),i};function Vme(t){const e=Hme(),{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(LR(n))l=XW(n);else throw new Error(Cs(1));let c;typeof r=="function"?c=r(e):c=e();let u=tw;i&&(u=zme({trace:!1,...typeof i=="object"&&i}));const d=Sme(...c),f=$me(d);let g=typeof s=="function"?s(f):f();const p=u(...g);return KW(l,a,p)}function dq(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 Gme(t){return typeof t=="function"}function Wme(t,e){let[n,r,i]=dq(e),a;if(Gme(t))a=()=>$z(t());else{const l=$z(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(Vc(d)){const p=f(d,c);return p===void 0?d:p}else{if(Go(d))return sq(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 qme="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Kme=(t=21)=>{let e="",n=t;for(;n--;)e+=qme[Math.random()*64|0];return e},Xme=Symbol.for("rtk-slice-createasyncthunk");function Yme(t,e){return`${t}/${e}`}function Zme({creators:t}={}){const e=t?.asyncThunk?.[Xme];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(Jme()):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:Yme(i,w),createNotation:typeof r.reducers=="function"};tpe(A)?rpe(T,A,u,e):epe(T,A,u)});function d(){const[w={},A=[],T=void 0]=typeof r.extraReducers=="function"?dq(r.extraReducers):[r.extraReducers],C={...w,...c.sliceCaseReducersByType};return Wme(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 b;function v(w,A){return b||(b=d()),b(w,A)}function x(){return b||(b=d()),b.getInitialState()}function y(w,A=!1){function T(N){let O=N[w];return typeof O>"u"&&A&&(O=Dv(p,T,x)),O}function C(N=f){const O=Dv(g,A,()=>new WeakMap);return Dv(O,N,()=>{const k={};for(const[j,z]of Object.entries(r.selectors??{}))k[j]=Qme(z,N,()=>Dv(p,N,x),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:x,...y(a),injectInto(w,{reducerPath:A,...T}={}){const C=A??a;return w.inject({reducerPath:C,reducer:v},T),{...E,...y(C,!0)}}};return E}}function Qme(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=Zme();function Jme(){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 epe({type:t,reducerName:e,createNotation:n},r,i){let a,s;if("reducer"in r){if(n&&!npe(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?bo(t,s):bo(t))}function tpe(t){return t._reducerDefinitionType==="asyncThunk"}function npe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function rpe({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 ipe="task",hq="listener",fq="completed",HR="cancelled",ape=`task-${HR}`,spe=`task-${fq}`,w3=`${hq}-${HR}`,ope=`${hq}-${fq}`,bM=class{constructor(t){this.code=t,this.message=`${ipe} ${HR} (reason: ${t})`}name="TaskAbortError";message},$R=(t,e)=>{if(typeof t!="function")throw new TypeError(Cs(32))},sw=()=>{},mq=(t,e=sw)=>(t.catch(e),t),pq=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Fh=(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))},Uh=t=>{if(t.aborted){const{reason:e}=t;throw new bM(e)}};function gq(t,e){let n=sw;return new Promise((r,i)=>{const a=()=>i(new bM(t.reason));if(t.aborted){a();return}n=pq(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=sw})}var lpe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof bM?"cancelled":"rejected",error:n}}finally{e?.()}},ow=t=>e=>mq(gq(t,e).then(n=>(Uh(t),n))),xq=t=>{const e=ow(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:hp}=Object,Gz={},yM="listenerMiddleware",cpe=(t,e)=>{const n=r=>pq(t,()=>Fh(r,t.reason));return(r,i)=>{$R(r);const a=new AbortController;n(a);const s=lpe(async()=>{Uh(t),Uh(a.signal);const l=await r({pause:ow(a.signal),delay:xq(a.signal),signal:a.signal});return Uh(a.signal),l},()=>Fh(a,spe));return i?.autoJoin&&e.push(s.catch(sw)),{result:ow(t)(s),cancel(){Fh(a,ape)}}}},upe=(t,e)=>{const n=async(r,i)=>{Uh(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 gq(e,Promise.race(l));return Uh(e),c}finally{a()}};return(r,i)=>mq(n(r,i))},bq=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=bo(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 $R(a),{predicate:i,type:e,effect:a}},yq=hp(t=>{const{type:e,predicate:n,effect:r}=bq(t);return{id:Kme(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Cs(22))}}},{withTypes:()=>yq}),Wz=(t,e)=>{const{type:n,effect:r,predicate:i}=bq(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},S3=t=>{t.pending.forEach(e=>{Fh(e,w3)})},dpe=(t,e)=>()=>{for(const n of e.keys())S3(n);t.clear()},qz=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},vq=hp(bo(`${yM}/add`),{withTypes:()=>vq}),hpe=bo(`${yM}/removeAll`),_q=hp(bo(`${yM}/remove`),{withTypes:()=>_q}),fpe=(...t)=>{console.error(`${yM}/error`,...t)},Lb=(t={})=>{const e=new Map,n=new Map,r=p=>{const b=n.get(p)??0;n.set(p,b+1)},i=p=>{const b=n.get(p)??1;b===1?n.delete(p):n.set(p,b-1)},{extra:a,onError:s=fpe}=t;$R(s);const l=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),b=>{p.unsubscribe(),b?.cancelActive&&S3(p)}),c=p=>{const b=Wz(e,p)??yq(p);return l(b)};hp(c,{withTypes:()=>c});const u=p=>{const b=Wz(e,p);return b&&(b.unsubscribe(),p.cancelActive&&S3(b)),!!b};hp(u,{withTypes:()=>u});const d=async(p,b,v,x)=>{const y=new AbortController,E=upe(c,y.signal),w=[];try{p.pending.add(y),r(p),await Promise.resolve(p.effect(b,hp({},v,{getOriginalState:x,condition:(A,T)=>E(A,T).then(Boolean),take:E,delay:xq(y.signal),pause:ow(y.signal),extra:a,signal:y.signal,fork:cpe(y.signal,w),unsubscribe:p.unsubscribe,subscribe:()=>{e.set(p.id,p)},cancelActiveListeners:()=>{p.pending.forEach((A,T,C)=>{A!==y&&(Fh(A,w3),C.delete(A))})},cancel:()=>{Fh(y,w3),p.pending.delete(y)},throwIfCancelled:()=>{Uh(y.signal)}})))}catch(A){A instanceof bM||qz(s,A,{raisedBy:"effect"})}finally{await Promise.all(w),Fh(y,ope),i(p),p.pending.delete(y)}},f=dpe(e,n);return{middleware:p=>b=>v=>{if(!YW(v))return b(v);if(vq.match(v))return c(v.payload);if(hpe.match(v)){f();return}if(_q.match(v))return u(v.payload);let x=p.getState();const y=()=>{if(x===Gz)throw new Error(Cs(23));return x};let E;try{if(E=b(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,x)}catch(N){C=!1,qz(s,N,{raisedBy:"predicate"})}C&&d(T,v,p,y)}}}finally{x=Gz}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 mpe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},wq=ls({name:"chartLayout",initialState:mpe,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:ppe,setLayout:gpe,setChartSize:xpe,setScale:bpe}=wq.actions,ype=wq.reducer;function Sq(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function Kz(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?Kz(Object(n),!0).forEach(function(r){vpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Kz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vpe(t,e,n){return(e=_pe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _pe(t){var e=wpe(t,"string");return typeof e=="symbol"?e:e+""}function wpe(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 Jn(t,e,n){return Tr(t)||Tr(e)?n:xo(e)?lf(t,e,n):typeof e=="function"?e(t):n}var Spe=(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"&&Ot(t[a]))return ap(ap({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&s!=="middle"&&Ot(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",Mq=(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},Eq=(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 b=l==="scaleBand"&&s.bandwidth?s.bandwidth()/2:2,v=i==="category"&&s.bandwidth?s.bandwidth()/b:0;if(v=p==="angleAxis"&&a&&a.length>=2?$i(a[0]-a[1])*2*v:v,f||g){var x=(f||g||[]).map((y,E)=>{var w=r?r.indexOf(y):y;return{coordinate:s(w)+v,value:y,offset:v,index:E}});return x.filter(y=>!ss(y.coordinate))}return c&&u?u.map((y,E)=>({coordinate:s(y)+v,value:y,index:E,offset:v})):s.ticks&&d!=null?s.ticks(d).map((y,E)=>({coordinate:s(y)+v,value:y,offset:v,index:E})):s.domain().map((y,E)=>({coordinate:s(y)+v,value:r?r[y]:y,index:E,offset:v}))},Xz=1e-4,Mpe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-Xz,a=Math.max(r[0],r[1])+Xz,s=t(e[0]),l=t(e[n-1]);(s<i||s>a||l<i||l>a)&&t.domain([e[0],e[n-1]])}},Epe=(t,e)=>{if(!e||e.length!==2||!Ot(e[0])||!Ot(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(!Ot(t[0])||t[0]<n)&&(i[0]=n),(!Ot(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},Ape=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])}},Tpe=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)}},Npe={sign:Ape,expand:Zhe,none:kp,silhouette:Qhe,wiggle:Jhe,positive:Tpe},Cpe=(t,e,n)=>{var r=Npe[n],i=Yhe().keys(e).value((a,s)=>Number(Jn(a,s,0))).order(h3).offset(r);return i(t)};function Aq(t){return t==null?void 0:String(t)}function lw(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:s}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Tr(i[e.dataKey])){var l=CW(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var c=Jn(i,Tr(s)?e.dataKey:s);return Tr(c)?null:e.scale(c)}var Yz=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=Jn(a,e.dataKey,e.scale.domain()[s]);return Tr(l)?null:e.scale(l)-i/2+r},kpe=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]},Ppe=t=>{var e=t.flat(2).filter(Ot);return[Math.min(...e),Math.max(...e)]},jpe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],Rpe=(t,e,n)=>{if(t!=null)return jpe(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:s}=a,l=s.reduce((c,u)=>{var d=Sq(u,e,n),f=Ppe(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]))},Zz=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Qz=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,wd=(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=dM(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 Jz(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 Dd(t,e){if(t)return String(t);if(typeof e=="string")return e}var Dpe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Ope=(t,e)=>e==="centric"?t.angle:t.radius,Qc=t=>t.layout.width,Jc=t=>t.layout.height,Lpe=t=>t.layout.scale,Tq=t=>t.layout.margin,vM=Ze(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),_M=Ze(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),Nq="data-recharts-item-index",Cq="data-recharts-item-data-key",Ib=60;function eB(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?eB(Object(n),!0).forEach(function(r){Ipe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):eB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ipe(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=Upe(t,"string");return typeof e=="symbol"?e:e+""}function Upe(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 zpe=t=>t.brush.height;function Bpe(t){var e=_M(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 Hpe(t){var e=_M(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 $pe(t){var e=vM(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Vpe(t){var e=vM(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var Ai=Ze([Qc,Jc,Tq,zpe,Bpe,Hpe,$pe,Vpe,WW,gme],(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=Spe(g,c,u);var b=t-g.left-g.right,v=e-g.top-g.bottom;return Lv(Lv({brushBottom:p},g),{},{width:Math.max(b,0),height:Math.max(v,0)})}),Gpe=Ze(Ai,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),VR=Ze(Qc,Jc,(t,e)=>({x:0,y:0,width:t,height:e})),Wpe=S.createContext(null),Ti=()=>S.useContext(Wpe)!=null,wM=t=>t.brush,SM=Ze([wM,Ai,Tq],(t,e,n)=>({height:t.height,x:Ot(t.x)?t.x:e.left,y:Ot(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Ot(t.width)?t.width:e.width})),KT={},XT={},YT={},tB;function qpe(){return tB||(tB=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)},b=()=>{g!==null&&(clearTimeout(g),g=null)},v=()=>{b(),s=void 0,l=null},x=()=>{d()},y=function(...E){if(i?.aborted)return;s=this,l=E;const w=g==null;p(),c&&w&&d()};return y.schedule=p,y.cancel=v,y.flush=x,i?.addEventListener("abort",v,{once:!0}),y}t.debounce=e})(YT)),YT}var nB;function Kpe(){return nB||(nB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qpe();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)},b=()=>(g.flush(),d);return p.cancel=g.cancel,p.flush=b,p}t.debounce=n})(XT)),XT}var rB;function Xpe(){return rB||(rB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Kpe();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})(KT)),KT}var ZT,iB;function Ype(){return iB||(iB=1,ZT=Xpe().throttle),ZT}var Zpe=Ype();const Qpe=vo(Zpe);var cw=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++]))}},kq=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:s}=n,l=$c(r)?t:Number(r),c=$c(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}},Jpe={width:0,height:0,overflow:"visible"},ege={width:0,overflowX:"visible"},tge={height:0,overflowY:"visible"},nge={},rge=t=>{var{width:e,height:n}=t,r=$c(e),i=$c(n);return r&&i?Jpe:r?ege:i?tge:nge};function ige(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 er(t){return Number.isFinite(t)}function wl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function M3(){return M3=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},M3.apply(null,arguments)}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 sB(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){age(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 age(t,e,n){return(e=sge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sge(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)}var Pq=S.createContext({width:-1,height:-1});function lge(t){return wl(t.width)&&wl(t.height)}function jq(t){var{children:e,width:n,height:r}=t,i=S.useMemo(()=>({width:n,height:r}),[n,r]);return lge(i)?S.createElement(Pq.Provider,{value:i},e):null}var GR=()=>S.useContext(Pq),cge=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:b={}}=t,v=S.useRef(null),x=S.useRef();x.current=p,S.useImperativeHandle(e,()=>v.current);var[y,E]=S.useState({containerWidth:r.width,containerHeight:r.height}),w=S.useCallback((O,k)=>{E(j=>{var z=Math.round(O),I=Math.round(k);return j.containerWidth===z&&j.containerHeight===I?j:{containerWidth:z,containerHeight:I}})},[]);S.useEffect(()=>{if(v.current==null||typeof ResizeObserver>"u")return jb;var O=I=>{var q,{width:R,height:W}=I[0].contentRect;w(R,W),(q=x.current)===null||q===void 0||q.call(x,R,W)};d>0&&(O=Qpe(O,d,{trailing:!0,leading:!1}));var k=new ResizeObserver(O),{width:j,height:z}=v.current.getBoundingClientRect();return w(j,z),k.observe(v.current),()=>{k.disconnect()}},[w,d]);var{containerWidth:A,containerHeight:T}=y;cw(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:C,calculatedHeight:N}=kq(A,T,{width:i,height:a,aspect:n,maxHeight:c});return cw(C!=null&&C>0||N!=null&&N>0,`The width(%s) and height(%s) of chart should be greater than 0,
  14. please check the style of container, or the props width(%s) and height(%s),
  15. or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
  16. height and width.`,C,N,i,a,s,l,n),S.createElement("div",{id:f?"".concat(f):void 0,className:In("recharts-responsive-container",g),style:sB(sB({},b),{},{width:i,height:a,minWidth:s,minHeight:l,maxHeight:c}),ref:v},S.createElement("div",{style:rge({width:i,height:a})},S.createElement(jq,{width:C,height:N},u)))}),y1=S.forwardRef((t,e)=>{var n=GR();if(wl(n.width)&&wl(n.height))return t.children;var{width:r,height:i}=ige({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:s}=kq(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Ot(a)&&Ot(s)?S.createElement(jq,{width:a,height:s},t.children):S.createElement(cge,M3({},t,{width:r,height:i,ref:e}))});function Rq(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=Ti(),n=Rt(Gpe),r=Rt(SM),i=(t=Rt(wM))===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}},uge={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},Dq=()=>{var t;return(t=Rt(Ai))!==null&&t!==void 0?t:uge},WR=()=>Rt(Qc),qR=()=>Rt(Jc),dge=()=>Rt(t=>t.layout.margin),Cn=t=>t.layout.layoutType,Ef=()=>Rt(Cn),hge=()=>{var t=Ef();if(t==="horizontal"||t==="vertical")return t},fge=()=>{var t=Ef();return t!==void 0},MM=t=>{var e=xr(),n=Ti(),{width:r,height:i}=t,a=GR(),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(xpe({width:s,height:l}))},[e,n,s,l]),null},Oq=Symbol.for("immer-nothing"),oB=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?Lq(t)||Array.isArray(t)||!!t[oB]||!!t.constructor?.[oB]||Ub(t)||AM(t):!1}var mge=Object.prototype.constructor.toString(),lB=new WeakMap;function Lq(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=lB.get(n);return r===void 0&&(r=Function.toString.call(n),lB.set(n,r)),r===mge}function uw(t,e,n=!0){EM(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 EM(t){const e=t[Rs];return e?e.type_:Array.isArray(t)?1:Ub(t)?2:AM(t)?3:0}function E3(t,e){return EM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Iq(t,e,n){const r=EM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function pge(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Ub(t){return t instanceof Map}function AM(t){return t instanceof Set}function xh(t){return t.copy_||t.base_}function A3(t,e){if(Ub(t))return new Map(t);if(AM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=Lq(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 KR(t,e=!1){return TM(t)||Rp(t)||!cf(t)||(EM(t)>1&&Object.defineProperties(t,{set:Iv,add:Iv,clear:Iv,delete:Iv}),Object.freeze(t),e&&Object.values(t).forEach(n=>KR(n,!0))),t}function gge(){Do(2)}var Iv={value:gge};function TM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var xge={};function uf(t){const e=xge[t];return e||Do(0,t),e}var H0;function Fq(){return H0}function bge(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function cB(t,e){e&&(uf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function T3(t){N3(t),t.drafts_.forEach(yge),t.drafts_=null}function N3(t){t===H0&&(H0=t.parent_)}function uB(t){return H0=bge(H0,t)}function yge(t){const e=t[Rs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function dB(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Rs].modified_&&(T3(e),Do(4)),cf(t)&&(t=dw(e,t),e.parent_||hw(e,t)),e.patches_&&uf("Patches").generateReplacementPatches_(n[Rs].base_,t,e.patches_,e.inversePatches_)):t=dw(e,n,[]),T3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==Oq?t:void 0}function dw(t,e,n){if(TM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Rs];if(!i)return uw(e,(a,s)=>hB(t,i,e,a,s,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return hw(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),uw(s,(c,u)=>hB(t,i,a,c,u,n,l),r),hw(t,a,!1),n&&t.patches_&&uf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function hB(t,e,n,r,i,a,s){if(i==null||typeof i!="object"&&!s)return;const l=TM(i);if(!(l&&!s)){if(Rp(i)){const c=a&&e&&e.type_!==3&&!E3(e.assigned_,r)?a.concat(r):void 0,u=dw(t,i,c);if(Iq(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;dw(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Ub(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&hw(t,i)}}}function hw(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&KR(e,n)}function vge(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:Fq(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=XR;n&&(i=[r],a=$0);const{revoke:s,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=s,l}var XR={get(t,e){if(e===Rs)return t;const n=xh(t);if(!E3(n,e))return _ge(t,n,e);const r=n[e];return t.finalized_||!cf(r)?r:r===QT(t.base_,e)?(JT(t),t.copy_[e]=k3(r,t)):r},has(t,e){return e in xh(t)},ownKeys(t){return Reflect.ownKeys(xh(t))},set(t,e,n){const r=Uq(xh(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=QT(xh(t),e),a=i?.[Rs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(pge(n,i)&&(n!==void 0||E3(t.base_,e)))return!0;JT(t),C3(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 QT(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,JT(t),C3(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=xh(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={};uw(XR,(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 XR.set.call(this,t[0],e,n,t[0])};function QT(t,e){const n=t[Rs];return(n?xh(n):t)[e]}function _ge(t,e,n){const r=Uq(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function Uq(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 C3(t){t.modified_||(t.modified_=!0,t.parent_&&C3(t.parent_))}function JT(t){t.copy_||(t.copy_=A3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var wge=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=uB(this),s=k3(e,void 0);let l=!0;try{i=n(s),l=!1}finally{l?T3(a):N3(a)}return cB(a,r),dB(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===Oq&&(i=void 0),this.autoFreeze_&&KR(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=Sge(t));const e=uB(this),n=k3(t,void 0);return n[Rs].isManual_=!0,N3(e),n}finishDraft(t,e){const n=t&&t[Rs];(!n||!n.isManual_)&&Do(9);const{scope_:r}=n;return cB(r,e),dB(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 k3(t,e){const n=Ub(t)?uf("MapSet").proxyMap_(t,e):AM(t)?uf("MapSet").proxySet_(t,e):vge(t,e);return(e?e.scope_:Fq()).drafts_.push(n),n}function Sge(t){return Rp(t)||Do(10,t),zq(t)}function zq(t){if(!cf(t)||TM(t))return t;const e=t[Rs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=A3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=A3(t,!0);return uw(n,(i,a)=>{Iq(n,i,zq(a))},r),e&&(e.finalized_=!1),n}var Mge=new wge;Mge.produce;var Ege={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},Bq=ls({name:"legend",initialState:Ege,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:Cr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ho(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Cr()},removeLegendPayload:{reducer(t,e){var n=Ho(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Cr()}}}),{setLegendSize:fB,setLegendSettings:Age,addLegendPayload:Hq,replaceLegendPayload:$q,removeLegendPayload:Vq}=Bq.actions,Tge=Bq.reducer,Nge=["contextPayload"];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 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 Dp(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){Cge(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 Cge(t,e,n){return(e=kge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kge(t){var e=Pge(t,"string");return typeof e=="symbol"?e:e+""}function Pge(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 jge(t,e){if(t==null)return{};var n,r,i=Rge(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 Rge(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 Dge(t){return t.value}function Oge(t){var{contextPayload:e}=t,n=jge(t,Nge),r=BW(e,t.payloadUniqBy,Dge),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(Nfe,i)}function Lge(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 Ige(t){var e=xr();return S.useEffect(()=>{e(Age(t))},[e,t]),null}function Fge(t){var e=xr();return S.useEffect(()=>(e(fB(t)),()=>{e(fB({width:0,height:0}))}),[e,t]),null}function Uge(t,e,n,r){return t==="vertical"&&Ot(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var zge={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function YR(t){var e=Lr(t,zge),n=yme(),r=vhe(),i=dge(),{width:a,height:s,wrapperStyle:l,portal:c}=e,[u,d]=qW([n]),f=WR(),g=qR();if(f==null||g==null)return null;var p=f-(i?.left||0)-(i?.right||0),b=Uge(e.layout,s,a,p),v=c?l:Dp(Dp({position:"absolute",width:b?.width||a||"auto",height:b?.height||s||"auto"},Lge(l,e,i,f,g,u)),l),x=c??r;if(x==null||n==null)return null;var y=S.createElement("div",{className:"recharts-legend-wrapper",style:v,ref:d},S.createElement(Ige,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&S.createElement(Fge,{width:u.width,height:u.height}),S.createElement(Oge,P3({},e,b,{margin:i,chartWidth:f,chartHeight:g,contextPayload:n})));return Mc.createPortal(y,x)}YR.displayName="Legend";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)}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 eN(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){Bge(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 Bge(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)}function Vge(t){return Array.isArray(t)&&xo(t[0])&&xo(t[1])?t.join(" ~ "):t}var Gge=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?dM(a,l):a).map((N,O)=>{if(N.type==="none")return null;var k=N.formatter||s||Vge,{value:j,name:z}=N,I=j,q=z;if(k){var R=k(j,z,N,O,a);if(Array.isArray(R))[I,q]=R;else if(R!=null)I=R;else return null}var W=eN({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:W},xo(q)?S.createElement("span",{className:"recharts-tooltip-item-name"},q):null,xo(q)?S.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,S.createElement("span",{className:"recharts-tooltip-item-value"},I),S.createElement("span",{className:"recharts-tooltip-item-unit"},N.unit||""))});return S.createElement("ul",{className:"recharts-tooltip-item-list",style:T},C)}return null},b=eN({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),v=eN({margin:0},i),x=!Tr(d),y=x?d:"",E=In("recharts-default-tooltip",c),w=In("recharts-tooltip-label",u);x&&f&&a!==void 0&&a!==null&&(y=f(d,a));var A=g?{role:"status","aria-live":"assertive"}:{};return S.createElement("div",j3({className:E,style:b},A),S.createElement("p",{className:w,style:v},S.isValidElement(y)?y:"".concat(y)),p())},vx="recharts-tooltip-wrapper",Wge={visibility:"hidden"};function qge(t){var{coordinate:e,translateX:n,translateY:r}=t;return In(vx,{["".concat(vx,"-right")]:Ot(n)&&e&&Ot(e.x)&&n>=e.x,["".concat(vx,"-left")]:Ot(n)&&e&&Ot(e.x)&&n<e.x,["".concat(vx,"-bottom")]:Ot(r)&&e&&Ot(e.y)&&r>=e.y,["".concat(vx,"-top")]:Ot(r)&&e&&Ot(e.y)&&r<e.y})}function gB(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:s,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&Ot(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,b=g;return p<b?Math.max(f,g):Math.max(d,g)}if(u==null)return 0;var v=f+l,x=g+u;return v>x?Math.max(d,g):Math.max(f,g)}function Kge(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 Xge(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=gB({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.width,viewBox:c,viewBoxDimension:c.width}),f=gB({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:s.height,viewBox:c,viewBoxDimension:c.height}),u=Kge({translateX:d,translateY:f,useTranslate3d:l})):u=Wge,{cssProperties:u,cssClasses:qge({translateX:d,translateY:f,coordinate:n})}}function xB(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?xB(Object(n),!0).forEach(function(r){R3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):xB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function R3(t,e,n){return(e=Yge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Yge(t){var e=Zge(t,"string");return typeof e=="symbol"?e:e+""}function Zge(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 Qge extends S.PureComponent{constructor(){super(...arguments),R3(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),R3(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:b,lastBoundingBox:v,innerRef:x,hasPortalFromProps:y}=this.props,{cssClasses:E,cssProperties:w}=Xge({allowEscapeViewBox:n,coordinate:s,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:v.height,width:v.width},useTranslate3d:g,viewBox:p}),A=y?{}: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"},b);return S.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:E,style:T,ref:x},a)}}var Gq=()=>{var t;return(t=Rt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};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 bB(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 yB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?bB(Object(n),!0).forEach(function(r){Jge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Jge(t,e,n){return(e=exe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function exe(t){var e=txe(t,"string");return typeof e=="symbol"?e:e+""}function txe(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 vB={curveBasisClosed:Uhe,curveBasisOpen:zhe,curveBasis:Fhe,curveBumpX:Mhe,curveBumpY:Ehe,curveLinearClosed:Bhe,curveLinear:cM,curveMonotoneX:Hhe,curveMonotoneY:$he,curveNatural:Vhe,curveStep:Ghe,curveStepAfter:qhe,curveStepBefore:Whe},fw=t=>er(t.x)&&er(t.y),_B=t=>t.base!=null&&fw(t.base)&&fw(t),_x=t=>t.x,wx=t=>t.y,nxe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Pb(t));return(n==="curveMonotone"||n==="curveBump")&&e?vB["".concat(n).concat(e==="vertical"?"Y":"X")]:vB[n]||cM},rxe=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,s=nxe(e,i),l=a?n.filter(fw):n,c;if(Array.isArray(r)){var u=n.map((p,b)=>yB(yB({},p),{},{base:r[b]}));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(_B).curve(s),f=a?u.filter(_B):u;return d(f)}i==="vertical"&&Ot(r)?c=kv().y(wx).x1(_x).x0(r):Ot(r)?c=kv().x(_x).y1(wx).y0(r):c=gW().x(_x).y(wx);var g=c.defined(fw).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?rxe(t):r;return S.createElement("path",D3({},Ia(t),RR(t),{className:In("recharts-curve",e),d:a===null?void 0:a,ref:i}))},ixe=["x","y","top","left","width","height","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 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 axe(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){sxe(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 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)}function cxe(t,e){if(t==null)return{};var n,r,i=uxe(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 uxe(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 dxe=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),hxe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:s=0,className:l}=t,c=cxe(t,ixe),u=axe({x:e,y:n,top:r,left:i,width:a,height:s},c);return!Ot(e)||!Ot(n)||!Ot(a)||!Ot(s)||!Ot(r)||!Ot(i)?null:S.createElement("path",O3({},da(u),{className:In("recharts-cross",l),d:dxe(e,n,a,s,r,i)}))};function fxe(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 SB(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 MB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?SB(Object(n),!0).forEach(function(r){mxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):SB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mxe(t,e,n){return(e=pxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pxe(t){var e=gxe(t,"string");return typeof e=="symbol"?e:e+""}function gxe(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 xxe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),Wq=(t,e,n)=>t.map(r=>"".concat(xxe(r)," ").concat(e,"ms ").concat(n)).join(","),bxe=(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)=>MB(MB({},n),{},{[r]:t(r,e[r])}),{});function EB(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 yi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?EB(Object(n),!0).forEach(function(r){yxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):EB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function yxe(t,e,n){return(e=vxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vxe(t){var e=_xe(t,"string");return typeof e=="symbol"?e:e+""}function _xe(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=(t,e,n)=>t+(e-t)*n,L3=t=>{var{from:e,to:n}=t;return e!==n},qq=(t,e,n)=>{var r=V0((i,a)=>{if(L3(a)){var[s,l]=t(a.from,a.to,a.velocity);return yi(yi({},a),{},{from:s,velocity:l})}return a},e);return n<1?V0((i,a)=>L3(a)?yi(yi({},a),{},{velocity:mw(a.velocity,r[i].velocity,n),from:mw(a.from,r[i].from,n)}):a,e):qq(t,r,n-1)};function wxe(t,e,n,r,i,a){var s,l=r.reduce((g,p)=>yi(yi({},g),{},{[p]:{from:t[p],velocity:0,to:e[p]}}),{}),c=()=>V0((g,p)=>p.from,l),u=()=>!Object.values(l).filter(L3).length,d=null,f=g=>{s||(s=g);var p=g-s,b=p/n.dt;l=qq(n,l,b),i(yi(yi(yi({},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 Sxe(t,e,n,r,i,a,s){var l=null,c=i.reduce((f,g)=>yi(yi({},f),{},{[g]:[t[g],e[g]]}),{}),u,d=f=>{u||(u=f);var g=(f-u)/r,p=V0((v,x)=>mw(...x,n(g)),c);if(a(yi(yi(yi({},t),e),p)),g<1)l=s.setTimeout(d);else{var b=V0((v,x)=>mw(...x,n(1)),c);a(yi(yi(yi({},t),e),b))}};return()=>(l=s.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const Mxe=(t,e,n,r,i,a)=>{var s=bxe(t,e);return n==null?()=>(i(yi(yi({},t),e)),()=>{}):n.isStepper===!0?wxe(t,e,n,s,i,a):Sxe(t,e,n,r,s,i,a)};var pw=1e-4,Kq=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],Xq=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),AB=(t,e)=>n=>{var r=Kq(t,e);return Xq(r,n)},Exe=(t,e)=>n=>{var r=Kq(t,e),i=[...r.map((a,s)=>a*s).slice(1),0];return Xq(i,n)},Axe=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]},Txe=(t,e,n,r)=>{var i=AB(t,n),a=AB(e,r),s=Exe(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,b=s(f);if(Math.abs(p-d)<pw||b<pw)return a(f);f=l(f-p/b)}return a(f)};return c.isStepper=!1,c},TB=function(){return Txe(...Axe(...arguments))},Nxe=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)<pw&&Math.abs(f)<pw?[l,0]:[g,f]};return a.isStepper=!0,a.dt=i,a},Cxe=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return TB(t);case"spring":return Nxe();default:if(t.split("(")[0]==="cubic-bezier")return TB(t)}return typeof t=="function"?t:null};function kxe(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 Pxe{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 jxe(){return kxe(new Pxe)}var Rxe=S.createContext(jxe);function Dxe(t,e){var n=S.useContext(Rxe);return S.useMemo(()=>e??n(t),[t,e,n])}var Oxe=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),lg={devToolsEnabled:!1,isSsr:Oxe()},Lxe={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},NB={t:0},tN={t:1};function cg(t){var e=Lr(t,Lxe),{isActive:n,canBegin:r,duration:i,easing:a,begin:s,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!lg.isSsr:n,f=Dxe(e.animationId,e.animationManager),[g,p]=S.useState(d?NB:tN),b=S.useRef(null);return S.useEffect(()=>{d||p(tN)},[d]),S.useEffect(()=>{if(!d||!r)return jb;var v=Mxe(NB,tN,Cxe(a),i,p,f.getTimeoutController()),x=()=>{b.current=v()};return f.start([c,s,x,i,l]),()=>{f.stop(),b.current&&b.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 Ixe=["radius"],Fxe=["radius"];function CB(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 kB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?CB(Object(n),!0).forEach(function(r){Uxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):CB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Uxe(t,e,n){return(e=zxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zxe(t){var e=Bxe(t,"string");return typeof e=="symbol"?e:e+""}function Bxe(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 gw(){return gw=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},gw.apply(null,arguments)}function PB(t,e){if(t==null)return{};var n,r,i=Hxe(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 Hxe(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 jB=(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,`,
  17. `).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,`,
  18. `).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,`,
  19. `).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,`
  20. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+l*p,",").concat(e,`
  21. L `).concat(t+n-l*p,",").concat(e,`
  22. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n,",").concat(e+s*p,`
  23. L `).concat(t+n,",").concat(e+r-s*p,`
  24. A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n-l*p,",").concat(e+r,`
  25. L `).concat(t+l*p,",").concat(e+r,`
  26. 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},RB={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Yq=t=>{var e=Lr(t,RB),n=S.useRef(null),[r,i]=S.useState(-1);S.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var G=n.current.getTotalLength();G&&i(G)}catch{}},[]);var{x:a,y:s,width:l,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:g,animationBegin:p,isAnimationActive:b,isUpdateAnimationActive:v}=e,x=S.useRef(l),y=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=In("recharts-rectangle",d);if(!v){var N=da(e),{radius:O}=N,k=PB(N,Ixe);return S.createElement("path",gw({},k,{radius:typeof u=="number"?u:void 0,className:C,d:jB(a,s,l,c,u)}))}var j=x.current,z=y.current,I=E.current,q=w.current,R="0px ".concat(r===-1?1:r,"px"),W="".concat(r,"px 0px"),K=Wq(["strokeDasharray"],g,typeof f=="string"?f:RB.animationEasing);return S.createElement(cg,{animationId:T,key:T,canBegin:r>0,duration:g,easing:f,isActive:v,begin:p},G=>{var J=Wn(j,l,G),ee=Wn(z,c,G),Z=Wn(I,a,G),F=Wn(q,s,G);n.current&&(x.current=J,y.current=ee,E.current=Z,w.current=F);var V;b?G>0?V={transition:K,strokeDasharray:W}:V={strokeDasharray:R}:V={strokeDasharray:W};var ne=da(e),{radius:le}=ne,oe=PB(ne,Fxe);return S.createElement("path",gw({},oe,{radius:typeof u=="number"?u:void 0,className:C,d:jB(Z,F,J,ee,u),ref:n,style:kB(kB({},V),e.style)}))})};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 OB(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){$xe(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 $xe(t,e,n){return(e=Vxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Vxe(t){var e=Gxe(t,"string");return typeof e=="symbol"?e:e+""}function Gxe(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 xw=Math.PI/180,Wxe=t=>t*180/Math.PI,di=(t,e,n,r)=>({x:t+Math.cos(-xw*r)*n,y:e+Math.sin(-xw*r)*n}),Zq=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},qxe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},Kxe=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,s=qxe({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:Wxe(c),angleInRadian:c}},Xxe=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}},Yxe=(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},Zxe=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=Kxe({x:n,y:r},e),{innerRadius:s,outerRadius:l}=e;if(i<s||i>l||i===0)return null;var{startAngle:c,endAngle:u}=Xxe(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?OB(OB({},e),{},{radius:i,angle:Yxe(d,e)}):null};function Qq(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,s=di(e,n,r,i),l=di(e,n,r,a);return{points:[s,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}function I3(){return I3=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},I3.apply(null,arguments)}var Qxe=(t,e)=>{var n=$i(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)/xw,f=c?i:i+a*d,g=di(e,n,u,f),p=di(e,n,r,f),b=c?i-a*d:i,v=di(e,n,u*Math.cos(d*xw),b);return{center:g,circleTangency:p,lineTangency:v,theta:d}},Jq=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:s}=t,l=Qxe(a,s),c=a+l,u=di(e,n,i,a),d=di(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
  27. A `).concat(i,",").concat(i,`,0,
  28. `).concat(+(Math.abs(l)>180),",").concat(+(a>c),`,
  29. `).concat(d.x,",").concat(d.y,`
  30. `);if(r>0){var g=di(e,n,r,a),p=di(e,n,r,c);f+="L ".concat(p.x,",").concat(p.y,`
  31. A `).concat(r,",").concat(r,`,0,
  32. `).concat(+(Math.abs(l)>180),",").concat(+(a<=c),`,
  33. `).concat(g.x,",").concat(g.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},Jxe=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:s,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=$i(u-c),{circleTangency:f,lineTangency:g,theta:p}=Uv({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:b,lineTangency:v,theta:x}=Uv({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:l}),y=l?Math.abs(c-u):Math.abs(c-u)-p-x;if(y<0)return s?"M ".concat(g.x,",").concat(g.y,`
  34. a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
  35. a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
  36. `):Jq({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var E="M ".concat(g.x,",").concat(g.y,`
  37. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
  38. A`).concat(i,",").concat(i,",0,").concat(+(y>180),",").concat(+(d<0),",").concat(b.x,",").concat(b.y,`
  39. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(v.x,",").concat(v.y,`
  40. `);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,`
  41. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(C.x,",").concat(C.y,`
  42. A`).concat(r,",").concat(r,",0,").concat(+(k>180),",").concat(+(d>0),",").concat(w.x,",").concat(w.y,`
  43. 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},e0e={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},eK=t=>{var e=Lr(t,e0e),{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=In("recharts-sector",f),p=a-i,b=wa(s,p,0,!0),v;return b>0&&Math.abs(u-d)<360?v=Jxe({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(b,p/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):v=Jq({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),S.createElement("path",I3({},da(e),{className:g,d:v}))};function t0e(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(PW(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:s,angle:l}=e,c=di(r,i,a,l),u=di(r,i,s,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return Qq(e)}}var nN={},rN={},iN={},LB;function n0e(){return LB||(LB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=VW();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(iN)),iN}var IB;function r0e(){return IB||(IB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=n0e();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})(rN)),rN}var FB;function i0e(){return FB||(FB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=GW(),n=r0e();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})(nN)),nN}var aN,UB;function a0e(){return UB||(UB=1,aN=i0e().range),aN}var s0e=a0e();const tK=vo(s0e);function cd(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function o0e(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function ZR(t){let e,n,r;t.length!==2?(e=cd,n=(l,c)=>cd(t(l),c),r=(l,c)=>t(l)-c):(e=t===cd||t===o0e?t:l0e,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 l0e(){return 0}function nK(t){return t===null?NaN:+t}function*c0e(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const u0e=ZR(cd),zb=u0e.right;ZR(nK).center;class zB extends Map{constructor(e,n=f0e){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(BB(this,e))}has(e){return super.has(BB(this,e))}set(e,n){return super.set(d0e(this,e),n)}delete(e){return super.delete(h0e(this,e))}}function BB({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function d0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function h0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function f0e(t){return t!==null&&typeof t=="object"?t.valueOf():t}function m0e(t=cd){if(t===cd)return rK;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 rK(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const p0e=Math.sqrt(50),g0e=Math.sqrt(10),x0e=Math.sqrt(2);function bw(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>=p0e?10:a>=g0e?5:a>=x0e?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?bw(t,e,n*2):[l,c,u]}function F3(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?bw(e,t,n):bw(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 U3(t,e,n){return e=+e,t=+t,n=+n,bw(t,e,n)[2]}function z3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?U3(e,t,n):U3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function HB(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function $B(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function iK(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?rK:m0e(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)),b=Math.min(r,Math.floor(e+(c-u)*f/c+g));iK(t,e,p,b,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 b0e(t,e,n){if(t=Float64Array.from(c0e(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return $B(t);if(e>=1)return HB(t);var r,i=(r-1)*e,a=Math.floor(i),s=HB(iK(t,a).subarray(0,a+1)),l=$B(t.subarray(a+1));return s+(l-s)*(i-a)}}function y0e(t,e,n=nK){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 v0e(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 eu(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 B3=Symbol("implicit");function QR(){var t=new zB,e=[],n=[],r=B3;function i(a){let s=t.get(a);if(s===void 0){if(r!==B3)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 zB;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 QR(e,n).unknown(r)},_o.apply(i,arguments),i}function JR(){var t=QR().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,b=p?i:r,v=p?r:i;a=(v-b)/Math.max(1,g-c+u*2),l&&(a=Math.floor(a)),b+=(v-b-a*(g-c))*d,s=a*(1-c),l&&(b=Math.round(b),s=Math.round(s));var x=v0e(g).map(function(y){return b+a*y});return n(p?x.reverse():x)}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 JR(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},_o.apply(f(),arguments)}function aK(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return aK(e())},t}function _0e(){return aK(JR.apply(null,arguments).paddingInner(1))}function eD(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function sK(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Bb(){}var G0=.7,yw=1/G0,mp="\\s*([+-]?\\d+)\\s*",W0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",xl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",w0e=/^#([0-9a-f]{3,8})$/,S0e=new RegExp(`^rgb\\(${mp},${mp},${mp}\\)$`),M0e=new RegExp(`^rgb\\(${xl},${xl},${xl}\\)$`),E0e=new RegExp(`^rgba\\(${mp},${mp},${mp},${W0}\\)$`),A0e=new RegExp(`^rgba\\(${xl},${xl},${xl},${W0}\\)$`),T0e=new RegExp(`^hsl\\(${W0},${xl},${xl}\\)$`),N0e=new RegExp(`^hsla\\(${W0},${xl},${xl},${W0}\\)$`),VB={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};eD(Bb,q0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:GB,formatHex:GB,formatHex8:C0e,formatHsl:k0e,formatRgb:WB,toString:WB});function GB(){return this.rgb().formatHex()}function C0e(){return this.rgb().formatHex8()}function k0e(){return oK(this).formatHsl()}function WB(){return this.rgb().formatRgb()}function q0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=w0e.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?qB(e):n===3?new ts(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=S0e.exec(t))?new ts(e[1],e[2],e[3],1):(e=M0e.exec(t))?new ts(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=E0e.exec(t))?zv(e[1],e[2],e[3],e[4]):(e=A0e.exec(t))?zv(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=T0e.exec(t))?YB(e[1],e[2]/100,e[3]/100,1):(e=N0e.exec(t))?YB(e[1],e[2]/100,e[3]/100,e[4]):VB.hasOwnProperty(t)?qB(VB[t]):t==="transparent"?new ts(NaN,NaN,NaN,0):null}function qB(t){return new ts(t>>16&255,t>>8&255,t&255,1)}function zv(t,e,n,r){return r<=0&&(t=e=n=NaN),new ts(t,e,n,r)}function P0e(t){return t instanceof Bb||(t=q0(t)),t?(t=t.rgb(),new ts(t.r,t.g,t.b,t.opacity)):new ts}function H3(t,e,n,r){return arguments.length===1?P0e(t):new ts(t,e,n,r??1)}function ts(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}eD(ts,H3,sK(Bb,{brighter(t){return t=t==null?yw:Math.pow(yw,t),new ts(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?G0:Math.pow(G0,t),new ts(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new ts(zh(this.r),zh(this.g),zh(this.b),vw(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:KB,formatHex:KB,formatHex8:j0e,formatRgb:XB,toString:XB}));function KB(){return`#${Nh(this.r)}${Nh(this.g)}${Nh(this.b)}`}function j0e(){return`#${Nh(this.r)}${Nh(this.g)}${Nh(this.b)}${Nh((isNaN(this.opacity)?1:this.opacity)*255)}`}function XB(){const t=vw(this.opacity);return`${t===1?"rgb(":"rgba("}${zh(this.r)}, ${zh(this.g)}, ${zh(this.b)}${t===1?")":`, ${t})`}`}function vw(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function zh(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Nh(t){return t=zh(t),(t<16?"0":"")+t.toString(16)}function YB(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 oK(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 R0e(t,e,n,r){return arguments.length===1?oK(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}eD(Oo,R0e,sK(Bb,{brighter(t){return t=t==null?yw:Math.pow(yw,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 ts(sN(t>=240?t-240:t+120,i,r),sN(t,i,r),sN(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Oo(ZB(this.h),Bv(this.s),Bv(this.l),vw(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=vw(this.opacity);return`${t===1?"hsl(":"hsla("}${ZB(this.h)}, ${Bv(this.s)*100}%, ${Bv(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ZB(t){return t=(t||0)%360,t<0?t+360:t}function Bv(t){return Math.max(0,Math.min(1,t||0))}function sN(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 tD=t=>()=>t;function D0e(t,e){return function(n){return t+n*e}}function O0e(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 L0e(t){return(t=+t)==1?lK:function(e,n){return n-e?O0e(e,n,t):tD(isNaN(e)?n:e)}}function lK(t,e){var n=e-t;return n?D0e(t,n):tD(isNaN(t)?e:t)}const QB=(function t(e){var n=L0e(e);function r(i,a){var s=n((i=H3(i)).r,(a=H3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=lK(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 I0e(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 F0e(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function U0e(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 z0e(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function _w(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function B0e(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 $3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,oN=new RegExp($3.source,"g");function H0e(t){return function(){return t}}function $0e(t){return function(e){return t(e)+""}}function V0e(t,e){var n=$3.lastIndex=oN.lastIndex=0,r,i,a,s=-1,l=[],c=[];for(t=t+"",e=e+"";(r=$3.exec(t))&&(i=oN.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:_w(r,i)})),n=oN.lastIndex;return n<e.length&&(a=e.slice(n),l[s]?l[s]+=a:l[++s]=a),l.length<2?c[0]?$0e(c[0].x):H0e(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"?tD(e):(n==="number"?_w:n==="string"?(r=q0(e))?(e=r,QB):V0e:e instanceof q0?QB:e instanceof Date?z0e:F0e(e)?I0e:Array.isArray(e)?U0e:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?B0e:_w)(t,e)}function nD(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function G0e(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 W0e(t){return function(){return t}}function ww(t){return+t}var JB=[0,1];function Da(t){return t}function V3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:W0e(isNaN(e)?NaN:.5)}function q0e(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function K0e(t,e,n){var r=t[0],i=t[1],a=e[0],s=e[1];return i<r?(r=V3(i,r),a=n(s,a)):(r=V3(r,i),a=n(a,s)),function(l){return a(r(l))}}function X0e(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]=V3(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 NM(){var t=JB,e=JB,n=dg,r,i,a,s=Da,l,c,u;function d(){var g=Math.min(t.length,e.length);return s!==Da&&(s=q0e(t[0],t[g-1])),l=g>2?X0e:K0e,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),_w)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,ww),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=nD,d()},f.clamp=function(g){return arguments.length?(s=g?!0:Da,d()):s!==Da},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 rD(){return NM()(Da,Da)}function Y0e(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Sw(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=Sw(Math.abs(t)),t?t[1]:NaN}function Z0e(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 Q0e(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var J0e=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function K0(t){if(!(e=J0e.exec(t)))throw new Error("invalid format: "+t);var e;return new iD({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=iD.prototype;function iD(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+""}iD.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 ebe(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 cK;function tbe(t,e){var n=Sw(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(cK=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")+Sw(t,Math.max(0,e+a-1))[0]}function e8(t,e){var n=Sw(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 t8={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Y0e,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)=>e8(t*100,e),r:e8,s:tbe,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function n8(t){return t}var r8=Array.prototype.map,i8=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function nbe(t){var e=t.grouping===void 0||t.thousands===void 0?n8:Z0e(r8.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?n8:Q0e(r8.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,b=f.sign,v=f.symbol,x=f.zero,y=f.width,E=f.comma,w=f.precision,A=f.trim,T=f.type;T==="n"?(E=!0,T="g"):t8[T]||(w===void 0&&(w=12),A=!0,T="g"),(x||g==="0"&&p==="=")&&(x=!0,g="0",p="=");var C=v==="$"?n:v==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",N=v==="$"?r:/[%p]/.test(T)?s:"",O=t8[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(z){var I=C,q=N,R,W,K;if(T==="c")q=O(z)+q,z="";else{z=+z;var G=z<0||1/z<0;if(z=isNaN(z)?c:O(Math.abs(z),w),A&&(z=ebe(z)),G&&+z==0&&b!=="+"&&(G=!1),I=(G?b==="("?b:l:b==="-"||b==="("?"":b)+I,q=(T==="s"?i8[8+cK/3]:"")+q+(G&&b==="("?")":""),k){for(R=-1,W=z.length;++R<W;)if(K=z.charCodeAt(R),48>K||K>57){q=(K===46?i+z.slice(R+1):z.slice(R))+q,z=z.slice(0,R);break}}}E&&!x&&(z=e(z,1/0));var J=I.length+z.length+q.length,ee=J<y?new Array(y-J+1).join(g):"";switch(E&&x&&(z=e(ee+z,ee.length?y-q.length:1/0),ee=""),p){case"<":z=I+z+q+ee;break;case"=":z=I+ee+z+q;break;case"^":z=ee.slice(0,J=ee.length>>1)+I+z+q+ee.slice(J);break;default:z=ee+I+z+q;break}return a(z)}return j.toString=function(){return f+""},j}function d(f,g){var p=u((f=K0(f),f.type="f",f)),b=Math.max(-8,Math.min(8,Math.floor(Op(g)/3)))*3,v=Math.pow(10,-b),x=i8[8+b/3];return function(y){return p(v*y)+x}}return{format:u,formatPrefix:d}}var Hv,aD,uK;rbe({thousands:",",grouping:[3],currency:["$",""]});function rbe(t){return Hv=nbe(t),aD=Hv.format,uK=Hv.formatPrefix,Hv}function ibe(t){return Math.max(0,-Op(Math.abs(t)))}function abe(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Op(e)/3)))*3-Op(Math.abs(t)))}function sbe(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Op(e)-Op(t))+1}function dK(t,e,n,r){var i=z3(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=abe(i,s))&&(r.precision=a),uK(r,s)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=sbe(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=ibe(i))&&(r.precision=a-(r.type==="%")*2);break}}return aD(r)}function Od(t){var e=t.domain;return t.ticks=function(n){var r=e();return F3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return dK(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=U3(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 hK(){var t=rD();return t.copy=function(){return Hb(t,hK())},_o.apply(t,arguments),Od(t)}function fK(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,ww),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return fK(t).unknown(e)},t=arguments.length?Array.from(t,ww):[0,1],Od(n)}function mK(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 a8(t){return Math.log(t)}function s8(t){return Math.exp(t)}function obe(t){return-Math.log(-t)}function lbe(t){return-Math.exp(-t)}function cbe(t){return isFinite(t)?+("1e"+t):t<0?0:t}function ube(t){return t===10?cbe:t===Math.E?Math.exp:e=>Math.pow(t,e)}function dbe(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 o8(t){return(e,n)=>-t(-e,n)}function sD(t){const e=t(a8,s8),n=e.domain;let r=10,i,a;function s(){return i=dbe(r),a=ube(r),n()[0]<0?(i=o8(i),a=o8(a),t(obe,lbe)):t(a8,s8),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),b,v;const x=l==null?10:+l;let y=[];if(!(r%1)&&p-g<x){if(g=Math.floor(g),p=Math.ceil(p),u>0){for(;g<=p;++g)for(b=1;b<r;++b)if(v=g<0?b/a(-g):b*a(g),!(v<u)){if(v>d)break;y.push(v)}}else for(;g<=p;++g)for(b=r-1;b>=1;--b)if(v=g>0?b/a(-g):b*a(g),!(v<u)){if(v>d)break;y.push(v)}y.length*2<x&&(y=F3(u,d,x))}else y=F3(g,p,Math.min(p-g,x)).map(a);return f?y.reverse():y},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=aD(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(mK(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function pK(){const t=sD(NM()).domain([1,10]);return t.copy=()=>Hb(t,pK()).base(t.base()),_o.apply(t,arguments),t}function l8(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function c8(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function oD(t){var e=1,n=t(l8(e),c8(e));return n.constant=function(r){return arguments.length?t(l8(e=+r),c8(e)):e},Od(n)}function gK(){var t=oD(NM());return t.copy=function(){return Hb(t,gK()).constant(t.constant())},_o.apply(t,arguments)}function u8(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function hbe(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function fbe(t){return t<0?-t*t:t*t}function lD(t){var e=t(Da,Da),n=1;function r(){return n===1?t(Da,Da):n===.5?t(hbe,fbe):t(u8(n),u8(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Od(e)}function cD(){var t=lD(NM());return t.copy=function(){return Hb(t,cD()).exponent(t.exponent())},_o.apply(t,arguments),t}function mbe(){return cD.apply(null,arguments).exponent(.5)}function d8(t){return Math.sign(t)*t*t}function pbe(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function xK(){var t=rD(),e=[0,1],n=!1,r;function i(a){var s=pbe(t(a));return isNaN(s)?r:n?Math.round(s):s}return i.invert=function(a){return t.invert(d8(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,ww)).map(d8)),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 xK(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},_o.apply(i,arguments),Od(i)}function bK(){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]=y0e(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(cd),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 bK().domain(t).range(e).unknown(r)},_o.apply(a,arguments)}function yK(){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 yK().domain([t,e]).range(i).unknown(a)},_o.apply(Od(s),arguments)}function vK(){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 vK().domain(t).range(e).unknown(n)},_o.apply(i,arguments)}const lN=new Date,cN=new Date;function Ni(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=>Ni(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)=>(lN.setTime(+a),cN.setTime(+s),t(lN),t(cN),Math.floor(n(lN,cN))),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 Mw=Ni(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);Mw.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Ni(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):Mw);Mw.range;const Ec=1e3,oo=Ec*60,Ac=oo*60,Gc=Ac*24,uD=Gc*7,h8=Gc*30,uN=Gc*365,Ch=Ni(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Ec)},(t,e)=>(e-t)/Ec,t=>t.getUTCSeconds());Ch.range;const dD=Ni(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Ec)},(t,e)=>{t.setTime(+t+e*oo)},(t,e)=>(e-t)/oo,t=>t.getMinutes());dD.range;const hD=Ni(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*oo)},(t,e)=>(e-t)/oo,t=>t.getUTCMinutes());hD.range;const fD=Ni(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Ec-t.getMinutes()*oo)},(t,e)=>{t.setTime(+t+e*Ac)},(t,e)=>(e-t)/Ac,t=>t.getHours());fD.range;const mD=Ni(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Ac)},(t,e)=>(e-t)/Ac,t=>t.getUTCHours());mD.range;const $b=Ni(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*oo)/Gc,t=>t.getDate()-1);$b.range;const CM=Ni(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Gc,t=>t.getUTCDate()-1);CM.range;const _K=Ni(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Gc,t=>Math.floor(t/Gc));_K.range;function Af(t){return Ni(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())*oo)/uD)}const kM=Af(0),Ew=Af(1),gbe=Af(2),xbe=Af(3),Lp=Af(4),bbe=Af(5),ybe=Af(6);kM.range;Ew.range;gbe.range;xbe.range;Lp.range;bbe.range;ybe.range;function Tf(t){return Ni(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)/uD)}const PM=Tf(0),Aw=Tf(1),vbe=Tf(2),_be=Tf(3),Ip=Tf(4),wbe=Tf(5),Sbe=Tf(6);PM.range;Aw.range;vbe.range;_be.range;Ip.range;wbe.range;Sbe.range;const pD=Ni(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());pD.range;const gD=Ni(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());gD.range;const Wc=Ni(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());Wc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ni(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)});Wc.range;const qc=Ni(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());qc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ni(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)});qc.range;function wK(t,e,n,r,i,a){const s=[[Ch,1,Ec],[Ch,5,5*Ec],[Ch,15,15*Ec],[Ch,30,30*Ec],[a,1,oo],[a,5,5*oo],[a,15,15*oo],[a,30,30*oo],[i,1,Ac],[i,3,3*Ac],[i,6,6*Ac],[i,12,12*Ac],[r,1,Gc],[r,2,2*Gc],[n,1,uD],[e,1,h8],[e,3,3*h8],[t,1,uN]];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),b=p?p.range(u,+d+1):[];return g?b.reverse():b}function c(u,d,f){const g=Math.abs(d-u)/f,p=ZR(([,,x])=>x).right(s,g);if(p===s.length)return t.every(z3(u/uN,d/uN,f));if(p===0)return Mw.every(Math.max(z3(u,d,f),1));const[b,v]=s[g/s[p-1][2]<s[p][2]/g?p-1:p];return b.every(v)}return[l,c]}const[Mbe,Ebe]=wK(qc,gD,PM,_K,mD,hD),[Abe,Tbe]=wK(Wc,pD,kM,$b,fD,dD);function dN(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 hN(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 Nbe(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),b=Ax(s),v=Ex(l),x=Ax(l),y=Ex(c),E=Ax(c),w={a:G,A:J,b:ee,B:Z,c:null,d:b8,e:b8,f:Zbe,g:oye,G:cye,H:Kbe,I:Xbe,j:Ybe,L:SK,m:Qbe,M:Jbe,p:F,q:V,Q:_8,s:w8,S:eye,u:tye,U:nye,V:rye,w:iye,W:aye,x:null,X:null,y:sye,Y:lye,Z:uye,"%":v8},A={a:ne,A:le,b:oe,B:pe,c:null,d:y8,e:y8,f:mye,g:Mye,G:Aye,H:dye,I:hye,j:fye,L:EK,m:pye,M:gye,p:Q,q:Ee,Q:_8,s:w8,S:xye,u:bye,U:yye,V:vye,w:_ye,W:wye,x:null,X:null,y:Sye,Y:Eye,Z:Tye,"%":v8},T={a:j,A:z,b:I,B:q,c:R,d:g8,e:g8,f:Vbe,g:p8,G:m8,H:x8,I:x8,j:zbe,L:$be,m:Ube,M:Bbe,p:k,q:Fbe,Q:Wbe,s:qbe,S:Hbe,u:Rbe,U:Dbe,V:Obe,w:jbe,W:Lbe,x:W,X:K,y:p8,Y:m8,Z:Ibe,"%":Gbe};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(he,ue){return function(Ae){var fe=[],at=-1,B=0,$=he.length,ie,H,Y;for(Ae instanceof Date||(Ae=new Date(+Ae));++at<$;)he.charCodeAt(at)===37&&(fe.push(he.slice(B,at)),(H=f8[ie=he.charAt(++at)])!=null?ie=he.charAt(++at):H=ie==="e"?" ":"0",(Y=ue[ie])&&(ie=Y(Ae,H)),fe.push(ie),B=at+1);return fe.push(he.slice(B,at)),fe.join("")}}function N(he,ue){return function(Ae){var fe=Mx(1900,void 0,1),at=O(fe,he,Ae+="",0),B,$;if(at!=Ae.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(ue&&!("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?(B=hN(Mx(fe.y,0,1)),$=B.getUTCDay(),B=$>4||$===0?Aw.ceil(B):Aw(B),B=CM.offset(B,(fe.V-1)*7),fe.y=B.getUTCFullYear(),fe.m=B.getUTCMonth(),fe.d=B.getUTCDate()+(fe.w+6)%7):(B=dN(Mx(fe.y,0,1)),$=B.getDay(),B=$>4||$===0?Ew.ceil(B):Ew(B),B=$b.offset(B,(fe.V-1)*7),fe.y=B.getFullYear(),fe.m=B.getMonth(),fe.d=B.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),$="Z"in fe?hN(Mx(fe.y,0,1)).getUTCDay():dN(Mx(fe.y,0,1)).getDay(),fe.m=0,fe.d="W"in fe?(fe.w+6)%7+fe.W*7-($+5)%7:fe.w+fe.U*7-($+6)%7);return"Z"in fe?(fe.H+=fe.Z/100|0,fe.M+=fe.Z%100,hN(fe)):dN(fe)}}function O(he,ue,Ae,fe){for(var at=0,B=ue.length,$=Ae.length,ie,H;at<B;){if(fe>=$)return-1;if(ie=ue.charCodeAt(at++),ie===37){if(ie=ue.charAt(at++),H=T[ie in f8?ue.charAt(at++):ie],!H||(fe=H(he,Ae,fe))<0)return-1}else if(ie!=Ae.charCodeAt(fe++))return-1}return fe}function k(he,ue,Ae){var fe=u.exec(ue.slice(Ae));return fe?(he.p=d.get(fe[0].toLowerCase()),Ae+fe[0].length):-1}function j(he,ue,Ae){var fe=p.exec(ue.slice(Ae));return fe?(he.w=b.get(fe[0].toLowerCase()),Ae+fe[0].length):-1}function z(he,ue,Ae){var fe=f.exec(ue.slice(Ae));return fe?(he.w=g.get(fe[0].toLowerCase()),Ae+fe[0].length):-1}function I(he,ue,Ae){var fe=y.exec(ue.slice(Ae));return fe?(he.m=E.get(fe[0].toLowerCase()),Ae+fe[0].length):-1}function q(he,ue,Ae){var fe=v.exec(ue.slice(Ae));return fe?(he.m=x.get(fe[0].toLowerCase()),Ae+fe[0].length):-1}function R(he,ue,Ae){return O(he,e,ue,Ae)}function W(he,ue,Ae){return O(he,n,ue,Ae)}function K(he,ue,Ae){return O(he,r,ue,Ae)}function G(he){return s[he.getDay()]}function J(he){return a[he.getDay()]}function ee(he){return c[he.getMonth()]}function Z(he){return l[he.getMonth()]}function F(he){return i[+(he.getHours()>=12)]}function V(he){return 1+~~(he.getMonth()/3)}function ne(he){return s[he.getUTCDay()]}function le(he){return a[he.getUTCDay()]}function oe(he){return c[he.getUTCMonth()]}function pe(he){return l[he.getUTCMonth()]}function Q(he){return i[+(he.getUTCHours()>=12)]}function Ee(he){return 1+~~(he.getUTCMonth()/3)}return{format:function(he){var ue=C(he+="",w);return ue.toString=function(){return he},ue},parse:function(he){var ue=N(he+="",!1);return ue.toString=function(){return he},ue},utcFormat:function(he){var ue=C(he+="",A);return ue.toString=function(){return he},ue},utcParse:function(he){var ue=N(he+="",!0);return ue.toString=function(){return he},ue}}}var f8={"-":"",_:" ",0:"0"},Ki=/^\s*\d+/,Cbe=/^%/,kbe=/[\\^$*+?|[\]().{}]/g;function Bn(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 Pbe(t){return t.replace(kbe,"\\$&")}function Ex(t){return new RegExp("^(?:"+t.map(Pbe).join("|")+")","i")}function Ax(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function jbe(t,e,n){var r=Ki.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Rbe(t,e,n){var r=Ki.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Dbe(t,e,n){var r=Ki.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Obe(t,e,n){var r=Ki.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Lbe(t,e,n){var r=Ki.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function m8(t,e,n){var r=Ki.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function p8(t,e,n){var r=Ki.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Ibe(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 Fbe(t,e,n){var r=Ki.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Ube(t,e,n){var r=Ki.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function g8(t,e,n){var r=Ki.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function zbe(t,e,n){var r=Ki.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function x8(t,e,n){var r=Ki.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Bbe(t,e,n){var r=Ki.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Hbe(t,e,n){var r=Ki.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function $be(t,e,n){var r=Ki.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Vbe(t,e,n){var r=Ki.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Gbe(t,e,n){var r=Cbe.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Wbe(t,e,n){var r=Ki.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function qbe(t,e,n){var r=Ki.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function b8(t,e){return Bn(t.getDate(),e,2)}function Kbe(t,e){return Bn(t.getHours(),e,2)}function Xbe(t,e){return Bn(t.getHours()%12||12,e,2)}function Ybe(t,e){return Bn(1+$b.count(Wc(t),t),e,3)}function SK(t,e){return Bn(t.getMilliseconds(),e,3)}function Zbe(t,e){return SK(t,e)+"000"}function Qbe(t,e){return Bn(t.getMonth()+1,e,2)}function Jbe(t,e){return Bn(t.getMinutes(),e,2)}function eye(t,e){return Bn(t.getSeconds(),e,2)}function tye(t){var e=t.getDay();return e===0?7:e}function nye(t,e){return Bn(kM.count(Wc(t)-1,t),e,2)}function MK(t){var e=t.getDay();return e>=4||e===0?Lp(t):Lp.ceil(t)}function rye(t,e){return t=MK(t),Bn(Lp.count(Wc(t),t)+(Wc(t).getDay()===4),e,2)}function iye(t){return t.getDay()}function aye(t,e){return Bn(Ew.count(Wc(t)-1,t),e,2)}function sye(t,e){return Bn(t.getFullYear()%100,e,2)}function oye(t,e){return t=MK(t),Bn(t.getFullYear()%100,e,2)}function lye(t,e){return Bn(t.getFullYear()%1e4,e,4)}function cye(t,e){var n=t.getDay();return t=n>=4||n===0?Lp(t):Lp.ceil(t),Bn(t.getFullYear()%1e4,e,4)}function uye(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Bn(e/60|0,"0",2)+Bn(e%60,"0",2)}function y8(t,e){return Bn(t.getUTCDate(),e,2)}function dye(t,e){return Bn(t.getUTCHours(),e,2)}function hye(t,e){return Bn(t.getUTCHours()%12||12,e,2)}function fye(t,e){return Bn(1+CM.count(qc(t),t),e,3)}function EK(t,e){return Bn(t.getUTCMilliseconds(),e,3)}function mye(t,e){return EK(t,e)+"000"}function pye(t,e){return Bn(t.getUTCMonth()+1,e,2)}function gye(t,e){return Bn(t.getUTCMinutes(),e,2)}function xye(t,e){return Bn(t.getUTCSeconds(),e,2)}function bye(t){var e=t.getUTCDay();return e===0?7:e}function yye(t,e){return Bn(PM.count(qc(t)-1,t),e,2)}function AK(t){var e=t.getUTCDay();return e>=4||e===0?Ip(t):Ip.ceil(t)}function vye(t,e){return t=AK(t),Bn(Ip.count(qc(t),t)+(qc(t).getUTCDay()===4),e,2)}function _ye(t){return t.getUTCDay()}function wye(t,e){return Bn(Aw.count(qc(t)-1,t),e,2)}function Sye(t,e){return Bn(t.getUTCFullYear()%100,e,2)}function Mye(t,e){return t=AK(t),Bn(t.getUTCFullYear()%100,e,2)}function Eye(t,e){return Bn(t.getUTCFullYear()%1e4,e,4)}function Aye(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Ip(t):Ip.ceil(t),Bn(t.getUTCFullYear()%1e4,e,4)}function Tye(){return"+0000"}function v8(){return"%"}function _8(t){return+t}function w8(t){return Math.floor(+t/1e3)}var dm,TK,NK;Nye({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 Nye(t){return dm=Nbe(t),TK=dm.format,dm.parse,NK=dm.utcFormat,dm.utcParse,dm}function Cye(t){return new Date(t)}function kye(t){return t instanceof Date?+t:+new Date(+t)}function xD(t,e,n,r,i,a,s,l,c,u){var d=rD(),f=d.invert,g=d.domain,p=u(".%L"),b=u(":%S"),v=u("%I:%M"),x=u("%I %p"),y=u("%a %d"),E=u("%b %d"),w=u("%B"),A=u("%Y");function T(C){return(c(C)<C?p:l(C)<C?b:s(C)<C?v:a(C)<C?x:r(C)<C?i(C)<C?y: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,kye)):g().map(Cye)},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(mK(N,C)):d},d.copy=function(){return Hb(d,xD(t,e,n,r,i,a,s,l,c,u))},d}function Pye(){return _o.apply(xD(Abe,Tbe,Wc,pD,kM,$b,fD,dD,Ch,TK).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function jye(){return _o.apply(xD(Mbe,Ebe,qc,gD,PM,CM,mD,hD,Ch,NK).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function jM(){var t=0,e=1,n,r,i,a,s=Da,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,b;return arguments.length?([p,b]=g,s=f(p,b),u):[s(0),s(1)]}}return u.range=d(dg),u.rangeRound=d(nD),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 Ld(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function CK(){var t=Od(jM()(Da));return t.copy=function(){return Ld(t,CK())},eu.apply(t,arguments)}function kK(){var t=sD(jM()).domain([1,10]);return t.copy=function(){return Ld(t,kK()).base(t.base())},eu.apply(t,arguments)}function PK(){var t=oD(jM());return t.copy=function(){return Ld(t,PK()).constant(t.constant())},eu.apply(t,arguments)}function bD(){var t=lD(jM());return t.copy=function(){return Ld(t,bD()).exponent(t.exponent())},eu.apply(t,arguments)}function Rye(){return bD.apply(null,arguments).exponent(.5)}function jK(){var t=[],e=Da;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(cd),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)=>b0e(t,a/r))},n.copy=function(){return jK(e).domain(t)},eu.apply(n,arguments)}function RM(){var t=0,e=.5,n=1,r=1,i,a,s,l,c,u=Da,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 b(v){return function(x){var y,E,w;return arguments.length?([y,E,w]=x,u=G0e(v,[y,E,w]),p):[u(0),u(.5),u(1)]}}return p.range=b(dg),p.rangeRound=b(nD),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 RK(){var t=Od(RM()(Da));return t.copy=function(){return Ld(t,RK())},eu.apply(t,arguments)}function DK(){var t=sD(RM()).domain([.1,1,10]);return t.copy=function(){return Ld(t,DK()).base(t.base())},eu.apply(t,arguments)}function OK(){var t=oD(RM());return t.copy=function(){return Ld(t,OK()).constant(t.constant())},eu.apply(t,arguments)}function yD(){var t=lD(RM());return t.copy=function(){return Ld(t,yD()).exponent(t.exponent())},eu.apply(t,arguments)}function Dye(){return yD.apply(null,arguments).exponent(.5)}const qx=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:JR,scaleDiverging:RK,scaleDivergingLog:DK,scaleDivergingPow:yD,scaleDivergingSqrt:Dye,scaleDivergingSymlog:OK,scaleIdentity:fK,scaleImplicit:B3,scaleLinear:hK,scaleLog:pK,scaleOrdinal:QR,scalePoint:_0e,scalePow:cD,scaleQuantile:bK,scaleQuantize:yK,scaleRadial:xK,scaleSequential:CK,scaleSequentialLog:kK,scaleSequentialPow:bD,scaleSequentialQuantile:jK,scaleSequentialSqrt:Rye,scaleSequentialSymlog:PK,scaleSqrt:mbe,scaleSymlog:gK,scaleThreshold:vK,scaleTime:Pye,scaleUtc:jye,tickFormat:dK},Symbol.toStringTag,{value:"Module"}));var Id=t=>t.chartData,vD=Ze([Id],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?vD(t):Id(t);function Sd(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(er(e)&&er(n))return!0}return!1}function S8(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function LK(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(er(n))i=n;else if(typeof n=="function")return;if(er(r))a=r;else if(typeof r=="function")return;var s=[i,a];if(Sd(s))return s}}function Oye(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(Sd(r))return S8(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(Ot(i))s=i;else if(typeof i=="function")try{e!=null&&(s=i(e?.[0]))}catch{}else if(typeof i=="string"&&Zz.test(i)){var c=Zz.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(Ot(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&Qz.test(a)){var d=Qz.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(Sd(g))return e==null?g:S8(g,e,n)}}}var hg=1e9,Lye={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},wD,Pr=!0,yo="[DecimalError] ",Bh=yo+"Invalid argument: ",_D=yo+"Exponent out of range: ",fg=Math.floor,bh=Math.pow,Iye=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ms,zi=1e7,Er=7,IK=9007199254740991,Tw=fg(IK/Er),Lt={};Lt.absoluteValue=Lt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Lt.comparedTo=Lt.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};Lt.decimalPlaces=Lt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*Er;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Lt.dividedBy=Lt.div=function(t){return jc(this,new this.constructor(t))};Lt.dividedToIntegerBy=Lt.idiv=function(t){var e=this,n=e.constructor;return gr(jc(e,new n(t),0,1),n.precision)};Lt.equals=Lt.eq=function(t){return!this.cmp(t)};Lt.exponent=function(){return fi(this)};Lt.greaterThan=Lt.gt=function(t){return this.cmp(t)>0};Lt.greaterThanOrEqualTo=Lt.gte=function(t){return this.cmp(t)>=0};Lt.isInteger=Lt.isint=function(){return this.e>this.d.length-2};Lt.isNegative=Lt.isneg=function(){return this.s<0};Lt.isPositive=Lt.ispos=function(){return this.s>0};Lt.isZero=function(){return this.s===0};Lt.lessThan=Lt.lt=function(t){return this.cmp(t)<0};Lt.lessThanOrEqualTo=Lt.lte=function(t){return this.cmp(t)<1};Lt.logarithm=Lt.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(yo+"NaN");if(n.s<1)throw Error(yo+(n.s?"NaN":"-Infinity"));return n.eq(Ms)?new r(0):(Pr=!1,e=jc(X0(n,a),X0(t,a),a),Pr=!0,gr(e,i))};Lt.minus=Lt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?zK(e,t):FK(e,(t.s=-t.s,t))};Lt.modulo=Lt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(yo+"NaN");return n.s?(Pr=!1,e=jc(n,t,0,1).times(t),Pr=!0,n.minus(e)):gr(new r(n),i)};Lt.naturalExponential=Lt.exp=function(){return UK(this)};Lt.naturalLogarithm=Lt.ln=function(){return X0(this)};Lt.negated=Lt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Lt.plus=Lt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?FK(e,t):zK(e,(t.s=-t.s,t))};Lt.precision=Lt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Bh+t);if(e=fi(i)+1,r=i.d.length-1,n=r*Er+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};Lt.squareRoot=Lt.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(yo+"NaN")}for(t=fi(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(gr(a,n+1,0),a.times(a).eq(l)){r=a;break}}else if(e!="9999")break;s+=4}return Pr=!0,gr(r,n)};Lt.times=Lt.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%zi|0,e=l/zi|0;a[i]=(a[i]+e)%zi|0}for(;!a[--s];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,Pr?gr(t,f.precision):t};Lt.toDecimalPlaces=Lt.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),gr(n,t+fi(n)+1,e))};Lt.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=gr(new i(r),t+1,e),n=df(r,!0,t+1)),n};Lt.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=gr(new a(i),t+fi(i)+1,e),n=df(r.abs(),!1,t+fi(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Lt.toInteger=Lt.toint=function(){var t=this,e=t.constructor;return gr(new e(t),fi(t)+1,e.rounding)};Lt.toNumber=function(){return+this};Lt.toPower=Lt.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(yo+"Infinity");return l}if(l.eq(Ms))return l;if(r=c.precision,t.eq(Ms))return gr(l,r);if(e=t.e,n=t.d.length-1,s=e>=n,a=l.s,s){if((n=d<0?-d:d)<=IK){for(i=new c(Ms),e=Math.ceil(r/Er+4),Pr=!1;n%2&&(i=i.times(l),E8(i.d,e)),n=fg(n/2),n!==0;)l=l.times(l),E8(l.d,e);return Pr=!0,t.s<0?new c(Ms).div(i):gr(i,r)}}else if(a<0)throw Error(yo+"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=UK(i),i.s=a,i};Lt.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=fi(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=gr(new a(i),t,e),n=fi(i),r=df(i,t<=n||n<=a.toExpNeg,t)),r};Lt.toSignificantDigits=Lt.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)),gr(new r(n),t,e)};Lt.toString=Lt.valueOf=Lt.val=Lt.toJSON=Lt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=fi(t),n=t.constructor;return df(t,e<=n.toExpNeg||e>=n.toExpPos)};function FK(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?gr(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/Er),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)/zi|0,c[a]%=zi;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,Pr?gr(e,f):e}function Sl(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Bh+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=Er-r.length,n&&(a+=$u(n)),a+=r;s=t[e],r=s+"",n=Er-r.length,n&&(a+=$u(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%zi|0,s=a/zi|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*zi+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,b,v,x,y,E,w,A,T,C,N,O,k=r.constructor,j=r.s==i.s?1:-1,z=r.d,I=i.d;if(!r.s)return new k(r);if(!i.s)throw Error(yo+"Division by zero");for(c=r.e-i.e,N=I.length,T=z.length,p=new k(j),b=p.d=[],u=0;I[u]==(z[u]||0);)++u;if(I[u]>(z[u]||0)&&--c,a==null?E=a=k.precision:s?E=a+(fi(r)-fi(i))+1:E=a,E<0)return new k(0);if(E=E/Er+2|0,u=0,N==1)for(d=0,I=I[0],E++;(u<T||d)&&E--;u++)w=d*zi+(z[u]||0),b[u]=w/I|0,d=w%I|0;else{for(d=zi/(I[0]+1)|0,d>1&&(I=t(I,d),z=t(z,d),N=I.length,T=z.length),A=N,v=z.slice(0,N),x=v.length;x<N;)v[x++]=0;O=I.slice(),O.unshift(0),C=I[0],I[1]>=zi/2&&++C;do d=0,l=e(I,v,N,x),l<0?(y=v[0],N!=x&&(y=y*zi+(v[1]||0)),d=y/C|0,d>1?(d>=zi&&(d=zi-1),f=t(I,d),g=f.length,x=v.length,l=e(f,v,g,x),l==1&&(d--,n(f,N<g?O:I,g))):(d==0&&(l=d=1),f=I.slice()),g=f.length,g<x&&f.unshift(0),n(v,f,x),l==-1&&(x=v.length,l=e(I,v,N,x),l<1&&(d++,n(v,N<x?O:I,x))),x=v.length):l===0&&(d++,v=[0]),b[u++]=d,l&&v[0]?v[x++]=z[A]||0:(v=[z[A]],x=1);while((A++<T||v[0]!==void 0)&&E--)}return b[0]||b.shift(),p.e=c,gr(p,s?a+fi(p)+1:a)}})();function UK(t,e){var n,r,i,a,s,l,c=0,u=0,d=t.constructor,f=d.precision;if(fi(t)>16)throw Error(_D+fi(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(bh(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d(Ms),d.precision=l;;){if(i=gr(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=gr(a.times(a),l);return d.precision=f,e==null?(Pr=!0,gr(a,f)):a}a=s}}function fi(t){for(var e=t.e*Er,n=t.d[0];n>=10;n/=10)e++;return e}function fN(t,e,n){if(e>t.LN10.sd())throw Pr=!0,n&&(t.precision=n),Error(yo+"LN10 precision limit exceeded");return gr(new t(t.LN10),e)}function $u(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,b=p.d,v=p.constructor,x=v.precision;if(p.s<1)throw Error(yo+(p.s?"NaN":"-Infinity"));if(p.eq(Ms))return new v(0);if(e==null?(Pr=!1,u=x):u=e,p.eq(10))return e==null&&(Pr=!0),fN(v,u);if(u+=g,v.precision=u,n=ml(b),r=n.charAt(0),a=fi(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=fi(p),r>1?(p=new v("0."+n),a++):p=new v(r+"."+n.slice(1))}else return c=fN(v,u+2,x).times(a+""),p=X0(new v(r+"."+n.slice(1)),u-g).plus(c),v.precision=x,e==null?(Pr=!0,gr(p,x)):p;for(l=s=p=jc(p.minus(Ms),p.plus(Ms),u),d=gr(p.times(p),u),i=3;;){if(s=gr(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(fN(v,u+2,x).times(a+""))),l=jc(l,new v(f),u),v.precision=x,e==null?(Pr=!0,gr(l,x)):l;l=c,i+=2}}function M8(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/Er),t.d=[],r=(n+1)%Er,n<0&&(r+=Er),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=Er;r<i;)t.d.push(+e.slice(r,r+=Er));e=e.slice(r),r=Er-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),Pr&&(t.e>Tw||t.e<-Tw))throw Error(_D+n)}else t.s=0,t.e=0,t.d=[0];return t}function gr(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+=Er,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/Er),a=f.length,d>=a)return t;for(u=a=f[d],s=1;a>=10;a/=10)s++;r%=Er,i=r-Er+s}if(n!==void 0&&(a=bh(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/bh(10,s-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=fi(t),f.length=1,e=e-a-1,f[0]=bh(10,(Er-e%Er)%Er),t.e=fg(-e/Er)||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=bh(10,Er-r),f[d]=i>0?(u/bh(10,s-i)%bh(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==zi&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=zi)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(Pr&&(t.e>Tw||t.e<-Tw))throw Error(_D+fi(t));return t}function zK(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?gr(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/Er),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]=zi-1;--c[a],c[i]+=zi}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?gr(e,p):e):new g(0)}function df(t,e,n){var r,i=fi(t),a=ml(t.d),s=a.length;return e?(n&&(r=n-s)>0?a=a.charAt(0)+"."+a.slice(1)+$u(r):s>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+$u(-i-1)+a,n&&(r=n-s)>0&&(a+=$u(r))):i>=s?(a+=$u(i+1-s),n&&(r=n-i-1)>0&&(a=a+"."+$u(r))):((r=i+1)<s&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-s)>0&&(i+1===s&&(a+="."),a+=$u(r))),t.s<0?"-"+a:a}function E8(t,e){if(t.length>e)return t.length=e,!0}function BK(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(Bh+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 M8(s,a.toString())}else if(typeof a!="string")throw Error(Bh+a);if(a.charCodeAt(0)===45?(a=a.slice(1),s.s=-1):s.s=1,Iye.test(a))M8(s,a);else throw Error(Bh+a)}if(i.prototype=Lt,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=BK,i.config=i.set=Fye,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 Fye(t){if(!t||typeof t!="object")throw Error(yo+"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(Bh+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Bh+n+": "+r);return this}var wD=BK(Lye);Ms=new wD(1);const Qn=wD;var Uye=t=>t,HK={},$K=t=>t===HK,A8=t=>function e(){return arguments.length===0||arguments.length===1&&$K(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},VK=(t,e)=>t===1?e:A8(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!==HK).length;return a>=t?e(...r):VK(t-a,A8(function(){for(var s=arguments.length,l=new Array(s),c=0;c<s;c++)l[c]=arguments[c];var u=r.map(d=>$K(d)?l.shift():d);return e(...u,...l)}))}),zye=t=>VK(t.length,t),G3=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},Bye=zye((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),Hye=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return Uye;var i=n.reverse(),a=i[0],s=i.slice(1);return function(){return s.reduce((l,c)=>c(l),a(...arguments))}},W3=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function GK(t){var e;return t===0?e=1:e=Math.floor(new Qn(t).abs().log(10).toNumber())+1,e}function WK(t,e,n){for(var r=new Qn(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var qK=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},KK=(t,e,n)=>{if(t.lte(0))return new Qn(0);var r=GK(t.toNumber()),i=new Qn(10).pow(r),a=t.div(i),s=r!==1?.05:.1,l=new Qn(Math.ceil(a.div(s).toNumber())).add(n).mul(s),c=l.mul(i);return e?new Qn(c.toNumber()):new Qn(Math.ceil(c.toNumber()))},$ye=(t,e,n)=>{var r=new Qn(1),i=new Qn(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new Qn(10).pow(GK(t)-1),i=new Qn(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new Qn(Math.floor(t)))}else t===0?i=new Qn(Math.floor((e-1)/2)):n||(i=new Qn(Math.floor(t)));var s=Math.floor((e-1)/2),l=Hye(Bye(c=>i.add(new Qn(c-s).mul(r)).toNumber()),G3);return l(0,e)},XK=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 Qn(0),tickMin:new Qn(0),tickMax:new Qn(0)};var s=KK(new Qn(n).sub(e).div(r-1),i,a),l;e<=0&&n>=0?l=new Qn(0):(l=new Qn(e).add(n).div(2),l=l.sub(new Qn(l).mod(s)));var c=Math.ceil(l.sub(e).div(s).toNumber()),u=Math.ceil(new Qn(n).sub(l).div(s).toNumber()),d=c+u+1;return d>r?XK(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 Qn(c).mul(s)),tickMax:l.add(new Qn(u).mul(s))})},Vye=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]=qK([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...G3(0,i-1).map(()=>1/0)]:[...G3(0,i-1).map(()=>-1/0),c];return n>r?W3(u):u}if(l===c)return $ye(l,i,a);var{step:d,tickMin:f,tickMax:g}=XK(l,c,s,a,0),p=WK(f,g.add(new Qn(.1).mul(d)),d);return n>r?W3(p):p},Gye=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[s,l]=qK([r,i]);if(s===-1/0||l===1/0)return[r,i];if(s===l)return[s];var c=Math.max(n,2),u=KK(new Qn(l).sub(s).div(c-1),a,0),d=[...WK(new Qn(s),new Qn(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?W3(d):d},YK=t=>t.rootProps.maxBarSize,Wye=t=>t.rootProps.barGap,ZK=t=>t.rootProps.barCategoryGap,qye=t=>t.rootProps.barSize,Gb=t=>t.rootProps.stackOffset,QK=t=>t.rootProps.reverseStackOrder,SD=t=>t.options.chartName,MD=t=>t.rootProps.syncId,JK=t=>t.rootProps.syncMethod,ED=t=>t.options.eventEmitter,Kye=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"},DM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},Xye={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},Yye={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},Zye={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},Qye={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},AD=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?Zye:Xye,TD=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?Qye:Yye,OM=t=>t.polarOptions,ND=Ze([Qc,Jc,Ai],Zq),eX=Ze([OM,ND],(t,e)=>{if(t!=null)return wa(t.innerRadius,e,0)}),tX=Ze([OM,ND],(t,e)=>{if(t!=null)return wa(t.outerRadius,e,e*.8)}),Jye=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},nX=Ze([OM],Jye);Ze([AD,nX],DM);var rX=Ze([ND,eX,tX],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});Ze([TD,rX],DM);var iX=Ze([Cn,OM,eX,tX,Qc,Jc],(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:wa(s,i,i/2),cy:wa(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),jr=(t,e)=>e,Wb=(t,e,n)=>n;function LM(t){return t?.id}function aX(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=LM(l);u.forEach((f,g)=>{var p=a==null||i?g:String(Jn(f,a,null)),b=Jn(f,l.dataKey,0),v;s.has(p)?v=s.get(p):v={},Object.assign(v,{[d]:b}),s.set(p,v)})}}),Array.from(s.values())}function IM(t){return t.stackId!=null&&t.dataKey!=null}var FM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function UM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function eve(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 Ci=t=>{var e=Cn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},mg=t=>t.tooltip.settings.axisId;function T8(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 Nw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?T8(Object(n),!0).forEach(function(r){tve(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tve(t,e,n){return(e=nve(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nve(t){var e=rve(t,"string");return typeof e=="symbol"?e:e+""}function rve(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 q3=[0,"auto"],Ii={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},sX=(t,e)=>t.cartesianAxis.xAxis[e],Dl=(t,e)=>{var n=sX(t,e);return n??Ii},Fi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:q3,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},oX=(t,e)=>t.cartesianAxis.yAxis[e],Ol=(t,e)=>{var n=oX(t,e);return n??Fi},ive={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:""},CD=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??ive},Ir=(t,e,n)=>{switch(e){case"xAxis":return Dl(t,n);case"yAxis":return Ol(t,n);case"zAxis":return CD(t,n);case"angleAxis":return AD(t,n);case"radiusAxis":return TD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},ave=(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 AD(t,n);case"radiusAxis":return TD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},lX=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function kD(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,sve=Ze([jr,Wb],kD),PD=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Xb=Ze([Kb,Ir,sve],PD,{memoizeOptions:{resultEqualityCheck:UM}}),cX=Ze([Xb],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(IM)),uX=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),ove=Ze([Xb],uX),jD=t=>t.map(e=>e.data).filter(Boolean).flat(1),lve=Ze([Xb],jD,{memoizeOptions:{resultEqualityCheck:UM}}),RD=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},DD=Ze([lve,Vb],RD),OD=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:Jn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:Jn(i,r)}))):t.map(r=>({value:r})),zM=Ze([DD,Ir,Xb],OD);function dX(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function v1(t){if(xo(t)||t instanceof Date){var e=Number(t);if(er(e))return e}}function N8(t){if(Array.isArray(t)){var e=[v1(t[0]),v1(t[1])];return Sd(e)?e:void 0}var n=v1(t);if(n!=null)return[n,n]}function Kc(t){return t.map(v1).filter(afe)}function cve(t,e,n){return!n||typeof e!="number"||ss(e)?[]:n.length?Kc(n.flatMap(r=>{var i=Jn(t,r.dataKey),a,s;if(Array.isArray(i)?[a,s]=i:a=s=i,!(!er(a)||!er(s)))return[e-a,e+s]})):[]}var ki=t=>{var e=Ci(t),n=mg(t);return qb(t,e,n)},Yb=Ze([ki],t=>t?.dataKey),uve=Ze([cX,Vb,ki],aX),hX=(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(LM);return[l,{stackedData:Cpe(t,d,n),graphicalItems:u}]}))},Y0=Ze([uve,cX,Gb,QK],hX),fX=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var s=Rpe(t,i,a);if(!(s!=null&&s[0]===0&&s[1]===0))return s}},dve=Ze([Ir],t=>t.allowDataOverflow),LD=t=>{var e;if(t==null||!("domain"in t))return q3;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Kc(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:q3},ID=Ze([Ir],LD),FD=Ze([ID,dve],LK),hve=Ze([Y0,Id,jr,FD],fX,{memoizeOptions:{resultEqualityCheck:FM}}),BM=t=>t.errorBars,fve=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>dX(n,r)),Cw=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]}},UD=(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(y=>dX(i,y)),g=Jn(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),p=cve(l,g,f);if(p.length>=2){var b=Math.min(...p),v=Math.max(...p);(a==null||b<a)&&(a=b),(s==null||v>s)&&(s=v)}var x=N8(g);x!=null&&(a=a==null?x[0]:Math.min(a,x[0]),s=s==null?x[1]:Math.max(s,x[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=N8(Jn(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]))}),er(a)&&er(s))return[a,s]},mve=Ze([DD,Ir,ove,BM,jr],UD,{memoizeOptions:{resultEqualityCheck:FM}});function pve(t){var{value:e}=t;if(xo(e)||e instanceof Date)return e}var gve=(t,e,n)=>{var r=t.map(pve).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&NW(r))?tK(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},mX=t=>t.referenceElements.dots,pg=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),xve=Ze([mX,jr,Wb],pg),pX=t=>t.referenceElements.areas,bve=Ze([pX,jr,Wb],pg),gX=t=>t.referenceElements.lines,yve=Ze([gX,jr,Wb],pg),xX=(t,e)=>{var n=Kc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},vve=Ze(xve,jr,xX),bX=(t,e)=>{var n=Kc(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)]},_ve=Ze([bve,jr],bX);function wve(t){var e;if(t.x!=null)return Kc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Kc(n)}function Sve(t){var e;if(t.y!=null)return Kc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Kc(n)}var yX=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?wve(r):Sve(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},Mve=Ze([yve,jr],yX),Eve=Ze(vve,Mve,_ve,(t,e,n)=>Cw(t,n,e)),zD=(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?Cw(r,a,i):Cw(a,i);return Oye(e,u,t.allowDataOverflow)},Ave=Ze([Ir,ID,FD,hve,mve,Eve,Cn,jr],zD,{memoizeOptions:{resultEqualityCheck:FM}}),Tve=[0,1],BD=(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 tK(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?gve(r,t,u):i==="expand"?Tve:s}},HD=Ze([Ir,Cn,DD,zM,Gb,jr,Ave],BD),vX=(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=Ze([Ir,Cn,lX,SD,jr],vX);function Nve(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 $D(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=Nve(e);if(i!=null){var a=i.domain(n).range(r);return Mpe(a),a}}}var VD=(t,e,n)=>{var r=LD(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&Sd(t))return Vye(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&Sd(t))return Gye(t,e.tickCount,e.allowDecimals)}},GD=Ze([HD,qb,gg],VD),WD=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&Sd(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},Cve=Ze([Ir,HD,GD,jr],WD),kve=Ze(zM,Ir,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Kc(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}}),_X=Ze(kve,Cn,ZK,Ai,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!er(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var s=wa(n,t*a),l=t*a/2;return l-s-(l-s)/a*s}return 0}),Pve=(t,e)=>{var n=Dl(t,e);return n==null||typeof n.padding!="string"?0:_X(t,"xAxis",e,n.padding)},jve=(t,e)=>{var n=Ol(t,e);return n==null||typeof n.padding!="string"?0:_X(t,"yAxis",e,n.padding)},Rve=Ze(Dl,Pve,(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}}),Dve=Ze(Ol,jve,(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}}),Ove=Ze([Ai,Rve,SM,wM,(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]}),Lve=Ze([Ai,Cn,Dve,SM,wM,(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 Ove(t,n,r);case"yAxis":return Lve(t,n,r);case"zAxis":return(i=CD(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return nX(t);case"radiusAxis":return rX(t,n);default:return}},wX=Ze([Ir,Zb],DM),Md=Ze([Ir,gg,Cve,wX],$D);Ze([Xb,BM,jr],fve);function SX(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var HM=(t,e)=>e,$M=(t,e,n)=>n,Ive=Ze(vM,HM,$M,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(SX)),Fve=Ze(_M,HM,$M,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(SX)),MX=(t,e)=>({width:t.width,height:e.height}),Uve=(t,e)=>{var n=typeof e.width=="number"?e.width:Ib;return{width:n,height:t.height}},EX=Ze(Ai,Dl,MX),zve=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},Bve=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},Hve=Ze(Jc,Ai,Ive,HM,$M,(t,e,n,r,i)=>{var a={},s;return n.forEach(l=>{var c=MX(e,l);s==null&&(s=zve(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}),$ve=Ze(Qc,Ai,Fve,HM,$M,(t,e,n,r,i)=>{var a={},s;return n.forEach(l=>{var c=Uve(e,l);s==null&&(s=Bve(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}),Vve=(t,e)=>{var n=Dl(t,e);if(n!=null)return Hve(t,n.orientation,n.mirror)},Gve=Ze([Ai,Dl,Vve,(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}}}),Wve=(t,e)=>{var n=Ol(t,e);if(n!=null)return $ve(t,n.orientation,n.mirror)},qve=Ze([Ai,Ol,Wve,(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}}}),AX=Ze(Ai,Ol,(t,e)=>{var n=typeof e.width=="number"?e.width:Ib;return{width:n,height:t.height}}),C8=(t,e,n)=>{switch(e){case"xAxis":return EX(t,n).width;case"yAxis":return AX(t,n).height;default:return}},TX=(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&&NW(c))return c}},qD=Ze([Cn,zM,Ir,jr],TX),NX=(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)}},KD=Ze([Cn,zM,qb,jr],NX),k8=Ze([Cn,ave,gg,Md,qD,KD,Zb,GD,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}}}),Kve=(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,b=d==="category"&&r.bandwidth?r.bandwidth()/p:0;b=c==="angleAxis"&&a!=null&&a.length>=2?$i(a[0]-a[1])*2*b:b;var v=f||i;if(v){var x=v.map((y,E)=>{var w=s?s.indexOf(y):y;return{index:E,coordinate:r(w)+b,value:y,offset:b}});return x.filter(y=>er(y.coordinate))}return u&&l?l.map((y,E)=>({coordinate:r(y)+b,value:y,index:E,offset:b})).filter(y=>er(y.coordinate)):r.ticks?r.ticks(g).map(y=>({coordinate:r(y)+b,value:y,offset:b})):r.domain().map((y,E)=>({coordinate:r(y)+b,value:s?s[y]:y,index:E,offset:b}))}},CX=Ze([Cn,qb,gg,Md,GD,Zb,qD,KD,jr],Kve),Xve=(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?$i(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=Ze([Cn,qb,Md,Zb,qD,KD,jr],Xve),El=Ze(Ir,Md,(t,e)=>{if(!(t==null||e==null))return Nw(Nw({},t),{},{scale:e})}),Yve=Ze([Ir,gg,HD,wX],$D);Ze((t,e,n)=>CD(t,n),Yve,(t,e)=>{if(!(t==null||e==null))return Nw(Nw({},t),{},{scale:e})});var Zve=Ze([Cn,vM,_M],(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}}),kX=t=>t.options.defaultTooltipEventType,PX=t=>t.options.validateTooltipEventTypes;function jX(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function XD(t,e){var n=kX(t),r=PX(t);return jX(e,n,r)}function Qve(t){return Rt(e=>XD(e,t))}var RX=(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},Jve=t=>t.tooltip.settings,Zu={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},e_e={itemInteraction:{click:Zu,hover:Zu},axisInteraction:{click:Zu,hover:Zu},keyboardInteraction:Zu,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}},DX=ls({name:"tooltip",initialState:e_e,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:Cr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ho(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Cr()},removeTooltipEntrySettings:{reducer(t,e){var n=Ho(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:Cr()},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:t_e,replaceTooltipEntrySettings:n_e,removeTooltipEntrySettings:r_e,setTooltipSettingsState:i_e,setActiveMouseOverItemIndex:OX,mouseLeaveItem:a_e,mouseLeaveChart:LX,setActiveClickItemIndex:s_e,setMouseOverAxisIndex:IX,setMouseClickAxisIndex:o_e,setSyncInteraction:K3,setKeyboardInteraction:X3}=DX.actions,l_e=DX.reducer;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 $v(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){c_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 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,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function f_e(t){return t.index!=null}var FX=(t,e,n,r)=>{if(e==null)return Zu;var i=h_e(t,e,n);if(i==null)return Zu;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(f_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({},Zu),{},{coordinate:i.coordinate})};function m_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 p_e(t,e){var n=m_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 g_e(t,e,n){if(n==null||e==null)return!0;var r=Jn(t,e);return r==null||!Sd(n)?!0:p_e(r,n)}var YD=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!er(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||g_e(u,n,r)?String(c):null},UX=(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}}}},zX=(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 j8(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 R8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?j8(Object(n),!0).forEach(function(r){x_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):j8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function x_e(t,e,n){return(e=b_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function b_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)}function v_e(t,e){return t??e}var BX=(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 b,{dataDefinedOnItem:v,settings:x}=p,y=v_e(v,l),E=Array.isArray(y)?Sq(y,u,d):y,w=(b=x?.dataKey)!==null&&b!==void 0?b:r,A=x?.nameKey,T;if(r&&Array.isArray(E)&&!Array.isArray(E[0])&&s==="axis"?T=CW(E,r,i):T=a(E,e,c,A),Array.isArray(T))T.forEach(N=>{var O=R8(R8({},x),{},{name:N.name,unit:N.unit,color:void 0,fill:void 0});g.push(Jz({tooltipEntrySettings:O,dataKey:N.dataKey,payload:N.payload,value:Jn(N.payload,N.dataKey),name:N.name}))});else{var C;g.push(Jz({tooltipEntrySettings:x,dataKey:w,payload:T,value:Jn(T,w),name:(C=Jn(T,A))!==null&&C!==void 0?C:x?.name}))}return g},f)}},ZD=Ze([ki,Cn,lX,SD,Ci],vX),__e=Ze([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),w_e=Ze([Ci,mg],kD),Jb=Ze([__e,ki,w_e],PD,{memoizeOptions:{resultEqualityCheck:UM}}),S_e=Ze([Jb],t=>t.filter(IM)),M_e=Ze([Jb],jD,{memoizeOptions:{resultEqualityCheck:UM}}),bg=Ze([M_e,Id],RD),E_e=Ze([S_e,Id,ki],aX),QD=Ze([bg,ki,Jb],OD),HX=Ze([ki],LD),A_e=Ze([ki],t=>t.allowDataOverflow),$X=Ze([HX,A_e],LK),T_e=Ze([Jb],t=>t.filter(IM)),N_e=Ze([E_e,T_e,Gb,QK],hX),C_e=Ze([N_e,Id,Ci,$X],fX),k_e=Ze([Jb],uX),P_e=Ze([bg,ki,k_e,BM,Ci],UD,{memoizeOptions:{resultEqualityCheck:FM}}),j_e=Ze([mX,Ci,mg],pg),R_e=Ze([j_e,Ci],xX),D_e=Ze([pX,Ci,mg],pg),O_e=Ze([D_e,Ci],bX),L_e=Ze([gX,Ci,mg],pg),I_e=Ze([L_e,Ci],yX),F_e=Ze([R_e,I_e,O_e],Cw),U_e=Ze([ki,HX,$X,C_e,P_e,F_e,Cn,Ci],zD),ey=Ze([ki,Cn,bg,QD,Gb,Ci,U_e],BD),z_e=Ze([ey,ki,ZD],VD),B_e=Ze([ki,ey,z_e,Ci],WD),VX=t=>{var e=Ci(t),n=mg(t),r=!1;return Zb(t,e,n,r)},GX=Ze([ki,VX],DM),WX=Ze([ki,ZD,B_e,GX],$D),H_e=Ze([Cn,QD,ki,Ci],TX),$_e=Ze([Cn,QD,ki,Ci],NX),V_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?$i(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}))}}},tu=Ze([Cn,ki,ZD,WX,VX,H_e,$_e,Ci],V_e),JD=Ze([kX,PX,Jve],(t,e,n)=>jX(n.shared,t,e)),qX=t=>t.tooltip.settings.trigger,eO=t=>t.tooltip.settings.defaultIndex,ty=Ze([xg,JD,qX,eO],FX),Ed=Ze([ty,bg,Yb,ey],YD),KX=Ze([tu,Ed],RX),tO=Ze([ty],t=>{if(t)return t.dataKey}),G_e=Ze([ty],t=>{if(t)return t.graphicalItemId}),XX=Ze([xg,JD,qX,eO],zX),W_e=Ze([Qc,Jc,Cn,Ai,tu,eO,XX,Qb],UX),q_e=Ze([ty,W_e],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),K_e=Ze([ty],t=>t.active),X_e=Ze([XX,Ed,Id,Yb,KX,Qb,JD],BX),Y_e=Ze([X_e],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});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){Z_e(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 Z_e(t,e,n){return(e=Q_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Q_e(t){var e=J_e(t,"string");return typeof e=="symbol"?e:e+""}function J_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 e1e=()=>Rt(ki),t1e=()=>{var t=e1e(),e=Rt(tu),n=Rt(WX);return wd(!t||!n?void 0:O8(O8({},t),{},{scale:n}),e)};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 hm(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){n1e(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 n1e(t,e,n){return(e=r1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function r1e(t){var e=i1e(t,"string");return typeof e=="symbol"?e:e+""}function i1e(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 a1e=(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}},s1e=(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),di(r.cx,r.cy,s,a)),{},{angle:a,radius:s})}var l=i.coordinate,{angle:c}=r;return hm(hm(hm({},r),di(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 o1e(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 YX=(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($i(d-u)!==$i(f-d)){var p=[];if($i(f-d)===$i(i[1]-i[0])){g=f;var b=d+i[1]-i[0];p[0]=Math.min(b,(b+u)/2),p[1]=Math.max(b,(b+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 x=[Math.min(d,(g+d)/2),Math.max(d,(g+d)/2)];if(t>x[0]&&t<=x[1]||t>=p[0]&&t<=p[1]){({index:s}=n[c]);break}}else{var y=Math.min(u,f),E=Math.max(u,f);if(t>(y+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},ZX=()=>Rt(SD),nO=(t,e)=>e,QX=(t,e,n)=>n,rO=(t,e,n,r)=>r,l1e=Ze(tu,t=>dM(t,e=>e.coordinate)),iO=Ze([xg,nO,QX,rO],FX),aO=Ze([iO,bg,Yb,ey],YD),c1e=(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}},JX=Ze([xg,nO,QX,rO],zX),kw=Ze([Qc,Jc,Cn,Ai,tu,rO,JX,Qb],UX),u1e=Ze([iO,kw],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),eY=Ze([tu,aO],RX),d1e=Ze([JX,aO,Id,Yb,eY,Qb,nO],BX),h1e=Ze([iO,aO],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),f1e=(t,e,n,r,i,a,s)=>{if(!(!t||!n||!r||!i)&&o1e(t,s)){var l=Dpe(t,e),c=YX(l,a,i,n,r),u=a1e(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},m1e=(t,e,n,r,i,a,s)=>{if(!(!t||!r||!i||!a||!n)){var l=Zxe(t,n);if(l){var c=Ope(l,e),u=YX(c,s,a,r,i),d=s1e(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},p1e=(t,e,n,r,i,a,s,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?f1e(t,e,r,i,a,s,l):m1e(t,e,n,r,i,a,s)},g1e=Ze(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}}),x1e=Ze(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:eve}});function I8(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 F8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I8(Object(n),!0).forEach(function(r){b1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function b1e(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=v1e(t,"string");return typeof e=="symbol"?e:e+""}function v1e(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 _1e={},w1e={zIndexMap:Object.values(Gr).reduce((t,e)=>F8(F8({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),_1e)},S1e=new Set(Object.values(Gr));function M1e(t){return S1e.has(t)}var tY=ls({name:"zIndex",initialState:w1e,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:Cr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!M1e(n)&&delete t.zIndexMap[n])},prepare:Cr()},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:Cr()},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:Cr()}}}),{registerZIndexPortal:E1e,unregisterZIndexPortal:A1e,registerZIndexPortalId:T1e,unregisterZIndexPortalId:N1e}=tY.actions,C1e=tY.reducer;function Ma(t){var{zIndex:e,children:n}=t,r=fge(),i=r&&e!==void 0&&e!==0,a=Ti(),s=xr();S.useLayoutEffect(()=>i?(s(E1e({zIndex:e})),()=>{s(A1e({zIndex:e}))}):jb,[s,e,i]);var l=Rt(u=>g1e(u,e,a));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?Mc.createPortal(n,c):null}function Y3(){return Y3=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},Y3.apply(null,arguments)}function U8(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?U8(Object(n),!0).forEach(function(r){k1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function k1e(t,e,n){return(e=P1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function P1e(t){var e=j1e(t,"string");return typeof e=="symbol"?e:e+""}function j1e(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 R1e(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return S.isValidElement(e)?S.cloneElement(e,r):S.createElement(n,r)}function D1e(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 b,v,x;if(d==="ScatterChart")b=f,v=hxe,x=Gr.cursorLine;else if(d==="BarChart")b=fxe(l,f,a,s),v=Yq,x=Gr.cursorRectangle;else if(l==="radial"&&PW(f)){var{cx:y,cy:E,radius:w,startAngle:A,endAngle:T}=Qq(f);b={cx:y,cy:E,startAngle:A,endAngle:T,innerRadius:w,outerRadius:w},v=eK,x=Gr.cursorLine}else b={points:t0e(l,f,a)},v=fp,x=Gr.cursorLine;var C=typeof c=="object"&&"className"in c?c.className:void 0,N=Vv(Vv(Vv(Vv({stroke:"#ccc",pointerEvents:"none"},a),b),of(c)),{},{payload:g,payloadIndex:p,className:In("recharts-tooltip-cursor",C)});return S.createElement(Ma,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:x},S.createElement(R1e,{cursor:c,cursorComp:v,cursorProps:N}))}function O1e(t){var e=t1e(),n=Dq(),r=Ef(),i=ZX();return e==null||n==null||r==null||i==null?null:S.createElement(D1e,Y3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var nY=S.createContext(null),L1e=()=>S.useContext(nY),mN={exports:{}},z8;function I1e(){return z8||(z8=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),b=n?n+u:u;return c._events[b]?c._events[b].fn?c._events[b]=[c._events[b],p]:c._events[b].push(p):(c._events[b]=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,b=new Array(p);g<p;g++)b[g]=f[g].fn;return b},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,b){var v=n?n+u:u;if(!this._events[v])return!1;var x=this._events[v],y=arguments.length,E,w;if(x.fn){switch(x.once&&this.removeListener(u,x.fn,void 0,!0),y){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,d),!0;case 3:return x.fn.call(x.context,d,f),!0;case 4:return x.fn.call(x.context,d,f,g),!0;case 5:return x.fn.call(x.context,d,f,g,p),!0;case 6:return x.fn.call(x.context,d,f,g,p,b),!0}for(w=1,E=new Array(y-1);w<y;w++)E[w-1]=arguments[w];x.fn.apply(x.context,E)}else{var A=x.length,T;for(w=0;w<A;w++)switch(x[w].once&&this.removeListener(u,x[w].fn,void 0,!0),y){case 1:x[w].fn.call(x[w].context);break;case 2:x[w].fn.call(x[w].context,d);break;case 3:x[w].fn.call(x[w].context,d,f);break;case 4:x[w].fn.call(x[w].context,d,f,g);break;default:if(!E)for(T=1,E=new Array(y-1);T<y;T++)E[T-1]=arguments[T];x[w].fn.apply(x[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 b=this._events[p];if(b.fn)b.fn===d&&(!g||b.once)&&(!f||b.context===f)&&s(this,p);else{for(var v=0,x=[],y=b.length;v<y;v++)(b[v].fn!==d||g&&!b[v].once||f&&b[v].context!==f)&&x.push(b[v]);x.length?this._events[p]=x.length===1?x[0]:x: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})(mN)),mN.exports}var F1e=I1e();const U1e=vo(F1e);var Z0=new U1e,Z3="recharts.syncEvent.tooltip",B8="recharts.syncEvent.brush";function VM(t,e){if(e){var n=Number.parseInt(e,10);if(!ss(n))return t?.[n]}}var z1e={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},rY=ls({name:"options",initialState:z1e,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),B1e=rY.reducer,{createEventEmitter:H1e}=rY.actions;function $1e(t){return t.tooltip.syncInteraction}var V1e={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},iY=ls({name:"chartData",initialState:V1e,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:H8,setDataStartEndIndexes:G1e,setComputedData:sqe}=iY.actions,W1e=iY.reducer,q1e=["x","y"];function $8(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?$8(Object(n),!0).forEach(function(r){K1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function K1e(t,e,n){return(e=X1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function X1e(t){var e=Y1e(t,"string");return typeof e=="symbol"?e:e+""}function Y1e(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 Z1e(t,e){if(t==null)return{};var n,r,i=Q1e(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 Q1e(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 J1e(){var t=Rt(MD),e=Rt(ED),n=xr(),r=Rt(JK),i=Rt(tu),a=Ef(),s=Fb(),l=Rt(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:b,y:v}=p,x=Z1e(p,q1e),{x:y,y:E,width:w,height:A}=d.payload.sourceViewBox,T=fm(fm({},x),{},{x:s.x+(w?(b-y)/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(K=>String(K.value)===d.payload.label));var{coordinate:k}=d.payload;if(C==null||d.payload.active===!1||k==null||s==null){n(K3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:j,y:z}=k,I=Math.min(j,s.x+s.width),q=Math.min(z,s.y+s.height),R={x:a==="horizontal"?C.coordinate:I,y:a==="horizontal"?q:C.coordinate},W=K3({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(W)}}};return Z0.on(Z3,c),()=>{Z0.off(Z3,c)}},[l,n,e,t,r,i,a,s])}function ewe(){var t=Rt(MD),e=Rt(ED),n=xr();S.useEffect(()=>{if(t==null)return jb;var r=(i,a,s)=>{e!==s&&t===i&&n(G1e(a))};return Z0.on(B8,r),()=>{Z0.off(B8,r)}},[n,e,t])}function twe(){var t=xr();S.useEffect(()=>{t(H1e())},[t]),J1e(),ewe()}function nwe(t,e,n,r,i,a){var s=Rt(p=>c1e(p,t,e)),l=Rt(ED),c=Rt(MD),u=Rt(JK),d=Rt($1e),f=d?.active,g=Fb();S.useEffect(()=>{if(!f&&c!=null&&l!=null){var p=K3({active:a,coordinate:n,dataKey:s,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});Z0.emit(Z3,c,p,l)}},[f,n,s,i,r,l,c,u,a,g])}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 G8(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){rwe(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 rwe(t,e,n){return(e=iwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function iwe(t){var e=awe(t,"string");return typeof e=="symbol"?e:e+""}function awe(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 swe(t){return t.dataKey}function owe(t,e){return S.isValidElement(t)?S.cloneElement(t,e):typeof t=="function"?S.createElement(t,e):S.createElement(Gge,e)}var W8=[],lwe={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 _1(t){var e,n,r=Lr(t,lwe),{active:i,allowEscapeViewBox:a,animationDuration:s,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:g,position:p,reverseDirection:b,useTranslate3d:v,wrapperStyle:x,cursor:y,shared:E,trigger:w,defaultIndex:A,portal:T,axisId:C}=r,N=xr(),O=typeof A=="number"?String(A):A;S.useEffect(()=>{N(i_e({shared:E,trigger:w,axisId:C,active:i,defaultIndex:O}))},[N,E,w,C,i,O]);var k=Fb(),j=Gq(),z=Qve(E),{activeIndex:I,isActive:q}=(e=Rt(Q=>h1e(Q,z,w,O)))!==null&&e!==void 0?e:{},R=Rt(Q=>d1e(Q,z,w,O)),W=Rt(Q=>eY(Q,z,w,O)),K=Rt(Q=>u1e(Q,z,w,O)),G=R,J=L1e(),ee=(n=i??q)!==null&&n!==void 0?n:!1,[Z,F]=qW([G,ee]),V=z==="axis"?W:void 0;nwe(z,w,K,V,I,ee);var ne=T??J;if(ne==null||k==null||z==null)return null;var le=G??W8;ee||(le=W8),u&&le.length&&(le=BW(le.filter(Q=>Q.value!=null&&(Q.hide!==!0||r.includeHidden)),g,swe));var oe=le.length>0,pe=S.createElement(Qge,{allowEscapeViewBox:a,animationDuration:s,animationEasing:l,isAnimationActive:d,active:ee,coordinate:K,hasPayload:oe,offset:f,position:p,reverseDirection:b,useTranslate3d:v,viewBox:k,wrapperStyle:x,lastBoundingBox:Z,innerRef:F,hasPortalFromProps:!!T},owe(c,G8(G8({},r),{},{payload:le,label:V,active:ee,activeIndex:I,coordinate:K,accessibilityLayer:j})));return S.createElement(S.Fragment,null,Mc.createPortal(pe,ne),ee&&S.createElement(O1e,{cursor:y,tooltipEventType:z,coordinate:K,payload:le,index:I}))}var ny=t=>null;ny.displayName="Cell";function cwe(t,e,n){return(e=uwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uwe(t){var e=dwe(t,"string");return typeof e=="symbol"?e:e+""}function dwe(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 hwe{constructor(e){cwe(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 q8(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 fwe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?q8(Object(n),!0).forEach(function(r){mwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mwe(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=gwe(t,"string");return typeof e=="symbol"?e:e+""}function gwe(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 xwe={cacheSize:2e3,enableCache:!0},aY=fwe({},xwe),K8=new hwe(aY.cacheSize),bwe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},X8="recharts_measurement_span";function ywe(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 Y8=(t,e)=>{try{var n=document.getElementById(X8);n||(n=document.createElement("span"),n.setAttribute("id",X8),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,bwe,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(!aY.enableCache)return Y8(e,n);var r=ywe(e,n),i=K8.get(r);if(i)return i;var a=Y8(e,n);return K8.set(r,a),a},Z8=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Q8=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,vwe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,_we=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,sY={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},wwe=Object.keys(sY),sp="NaN";function Swe(t,e){return t*sY[e]}class Qa{static parse(e){var n,[,r,i]=(n=_we.exec(e))!==null&&n!==void 0?n:[];return new Qa(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,ss(e)&&(this.unit=""),n!==""&&!vwe.test(n)&&(this.num=NaN,this.unit=""),wwe.includes(n)&&(this.num=Swe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Qa(NaN,""):new Qa(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Qa(NaN,""):new Qa(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Qa(NaN,""):new Qa(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Qa(NaN,""):new Qa(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return ss(this.num)}}function oY(t){if(t.includes(sp))return sp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=Z8.exec(e))!==null&&n!==void 0?n:[],s=Qa.parse(r??""),l=Qa.parse(a??""),c=i==="*"?s.multiply(l):s.divide(l);if(c.isNaN())return sp;e=e.replace(Z8,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,g]=(u=Q8.exec(e))!==null&&u!==void 0?u:[],p=Qa.parse(d??""),b=Qa.parse(g??""),v=f==="+"?p.add(b):p.subtract(b);if(v.isNaN())return sp;e=e.replace(Q8,v.toString())}return e}var J8=/\(([^()]*)\)/;function Mwe(t){for(var e=t,n;(n=J8.exec(e))!=null;){var[,r]=n;e=e.replace(J8,oY(r))}return e}function Ewe(t){var e=t.replace(/\s+/g,"");return e=Mwe(e),e=oY(e),e}function Awe(t){try{return Ewe(t)}catch{return sp}}function pN(t){var e=Awe(t.slice(5,-1));return e===sp?"":e}var Twe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],Nwe=["dx","dy","angle","className","breakAll"];function Q3(){return Q3=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},Q3.apply(null,arguments)}function e6(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}var lY=/[ \f\n\r\t\v\u2028\u2029]+/,cY=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Tr(e)||(n?i=e.toString().split(""):i=e.toString().split(lY));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 kwe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var uY=(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},[]),dY=t=>t.reduce((e,n)=>e.width>n.width?e:n),Pwe="…",t6=(t,e,n,r,i,a,s,l)=>{var c=t.slice(0,e),u=cY({breakAll:n,style:r,children:c+Pwe});if(!u)return[!1,[]];var d=uY(u.wordsWithComputedWidth,a,s,l),f=d.length>i||dY(d).width>Number(a);return[f,d]},jwe=(t,e,n,r,i)=>{var{maxLines:a,children:s,style:l,breakAll:c}=t,u=Ot(a),d=String(s),f=uY(e,r,n,i);if(!u||i)return f;var g=f.length>a||dY(f).width>Number(r);if(!g)return f;for(var p=0,b=d.length-1,v=0,x;p<=b&&v<=d.length-1;){var y=Math.floor((p+b)/2),E=y-1,[w,A]=t6(d,E,c,l,a,r,n,i),[T]=t6(d,y,c,l,a,r,n,i);if(!w&&!T&&(p=y+1),w&&T&&(b=y-1),!w&&T){x=A;break}v++}return x||f},n6=t=>{var e=Tr(t)?[]:t.toString().split(lY);return[{words:e,width:void 0}]},Rwe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:s}=t;if((e||n)&&!lg.isSsr){var l,c,u=cY({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return n6(r);return jwe({breakAll:a,children:r,maxLines:s,style:i},l,c,e,!!n)}return n6(r)},hY="#808080",Dwe={angle:0,breakAll:!1,capHeight:"0.71em",fill:hY,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},GM=S.forwardRef((t,e)=>{var n=Lr(t,Dwe),{x:r,y:i,lineHeight:a,capHeight:s,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=e6(n,Twe),g=S.useMemo(()=>Rwe({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:b,angle:v,className:x,breakAll:y}=f,E=e6(f,Nwe);if(!xo(r)||!xo(i)||g.length===0)return null;var w=Number(r)+(Ot(p)?p:0),A=Number(i)+(Ot(b)?b:0);if(!er(w)||!er(A))return null;var T;switch(d){case"start":T=pN("calc(".concat(s,")"));break;case"middle":T=pN("calc(".concat((g.length-1)/2," * -").concat(a," + (").concat(s," / 2))"));break;default:T=pN("calc(".concat(g.length-1," * -").concat(a,")"));break}var C=[];if(c){var N=g[0].width,{width:O}=f;C.push("scale(".concat(Ot(O)&&Ot(N)?O/N:1,")"))}return v&&C.push("rotate(".concat(v,", ").concat(w,", ").concat(A,")")),C.length&&(E.transform=C.join(" ")),S.createElement("text",Q3({},da(E),{ref:e,x:w,y:A,className:In("recharts-text",x),textAnchor:u,fill:l.includes("url")?hY:l}),g.map((k,j)=>{var z=k.words.join(y?"":" ");return S.createElement("tspan",{x:w,dy:j===0?T:a,key:"".concat(z,"-").concat(j)},z)}))});GM.displayName="Text";var Owe=["labelRef"];function Lwe(t,e){if(t==null)return{};var n,r,i=Iwe(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 Iwe(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 r6(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?r6(Object(n),!0).forEach(function(r){Fwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Fwe(t,e,n){return(e=Uwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Uwe(t){var e=zwe(t,"string");return typeof e=="symbol"?e:e+""}function zwe(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 fY=S.createContext(null),mY=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(fY.Provider,{value:c},l)},pY=()=>{var t=S.useContext(fY),e=Fb();return t||Rq(e)},Bwe=S.createContext(null),Hwe=()=>{var t=S.useContext(Bwe),e=Rt(iX);return t||e},$we=t=>{var{value:e,formatter:n}=t,r=Tr(t.children)?e:t.children;return typeof n=="function"?n(r):r},sO=t=>t!=null&&typeof t=="function",Vwe=(t,e)=>{var n=$i(e-t),r=Math.min(Math.abs(e-t),360);return n*r},Gwe=(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,b=(u+d)/2,v=Vwe(f,g),x=v>=0?1:-1,y,E;switch(e){case"insideStart":y=f+x*a,E=p;break;case"insideEnd":y=g-x*a,E=!p;break;case"end":y=g+x*a,E=p;break;default:throw new Error("Unsupported position ".concat(e))}E=v<=0?E:!E;var w=di(l,c,b,y),A=di(l,c,b,y+(E?1:-1)*359),T="M".concat(w.x,",").concat(w.y,`
  44. A`).concat(b,",").concat(b,",0,1,").concat(E?0:1,`,
  45. `).concat(A.x,",").concat(A.y),C=Tr(t.id)?I0("recharts-radial-line-"):t.id;return S.createElement("text",_c({},r,{dominantBaseline:"central",className:In("recharts-radial-bar-label",s)}),S.createElement("defs",null,S.createElement("path",{id:C,d:T})),S.createElement("textPath",{xlinkHref:"#".concat(C)},n))},Wwe=(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}=di(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:b}=di(r,i,g,u);return{x:p,y:b,textAnchor:"middle",verticalAnchor:"middle"}},J3=t=>"cx"in t&&Ot(t.cx),qwe=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!J3(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,b=(c+u)/2,v=f+c/2,x=d>=0?1:-1,y=x*r,E=x>0?"end":"start",w=x>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-y,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+y,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 z={x:p+b+T,y:l+d/2,textAnchor:N,verticalAnchor:"middle"};return Zr(Zr({},z),a?{width:Math.max(a.x+a.width-z.x,0),height:d}:{})}var I=a?{width:b,height:d}:{};return i==="insideLeft"?Zr({x:p+T,y:l+d/2,textAnchor:N,verticalAnchor:"middle"},I):i==="insideRight"?Zr({x:p+b-T,y:l+d/2,textAnchor:C,verticalAnchor:"middle"},I):i==="insideTop"?Zr({x:f+c/2,y:l+y,textAnchor:"middle",verticalAnchor:w},I):i==="insideBottom"?Zr({x:g+u/2,y:l+d-y,textAnchor:"middle",verticalAnchor:E},I):i==="insideTopLeft"?Zr({x:f+T,y:l+y,textAnchor:N,verticalAnchor:w},I):i==="insideTopRight"?Zr({x:f+c-T,y:l+y,textAnchor:C,verticalAnchor:w},I):i==="insideBottomLeft"?Zr({x:g+T,y:l+d-y,textAnchor:N,verticalAnchor:E},I):i==="insideBottomRight"?Zr({x:g+u-T,y:l+d-y,textAnchor:C,verticalAnchor:E},I):i&&typeof i=="object"&&(Ot(i.x)||$c(i.x))&&(Ot(i.y)||$c(i.y))?Zr({x:s+wa(i.x,b),y:l+wa(i.y,d),textAnchor:"end",verticalAnchor:"end"},I):Zr({x:v,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},I)},Kwe={angle:0,offset:5,zIndex:Gr.label,position:"middle",textBreakAll:!1};function Vu(t){var e=Lr(t,Kwe),{viewBox:n,position:r,value:i,children:a,content:s,className:l="",textBreakAll:c,labelRef:u}=e,d=Hwe(),f=pY(),g=r==="center"?f:d??f,p,b,v;if(n==null?p=g:J3(n)?p=n:p=Rq(n),!p||Tr(i)&&Tr(a)&&!S.isValidElement(s)&&typeof s!="function")return null;var x=Zr(Zr({},e),{},{viewBox:p});if(S.isValidElement(s)){var{labelRef:y}=x,E=Lwe(x,Owe);return S.cloneElement(s,E)}if(typeof s=="function"){if(b=S.createElement(s,x),S.isValidElement(b))return b}else b=$we(e);var w=da(e);if(J3(p)){if(r==="insideStart"||r==="insideEnd"||r==="end")return Gwe(e,r,b,w,p);v=Wwe(p,e.offset,e.position)}else v=qwe(e,p);return S.createElement(Ma,{zIndex:e.zIndex},S.createElement(GM,_c({ref:u,className:In("recharts-label",l)},w,v,{textAnchor:kwe(w.textAnchor)?w.textAnchor:v.textAnchor,breakAll:c}),b))}Vu.displayName="Label";var Xwe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?S.createElement(Vu,_c({key:"label-implicit"},r)):xo(t)?S.createElement(Vu,_c({key:"label-implicit",value:t},r)):S.isValidElement(t)?t.type===Vu?S.cloneElement(t,Zr({key:"label-implicit"},r)):S.createElement(Vu,_c({key:"label-implicit",content:t},r)):sO(t)?S.createElement(Vu,_c({key:"label-implicit",content:t},r)):t&&typeof t=="object"?S.createElement(Vu,_c({},t,{key:"label-implicit"},r)):null};function gY(t){var{label:e,labelRef:n}=t,r=pY();return Xwe(e,r,n)||null}var gN={},xN={},i6;function Ywe(){return i6||(i6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(xN)),xN}var bN={},a6;function Zwe(){return a6||(a6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(bN)),bN}var s6;function Qwe(){return s6||(s6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ywe(),n=Zwe(),r=DR();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(gN)),gN}var yN,o6;function Jwe(){return o6||(o6=1,yN=Qwe().last),yN}var eSe=Jwe();const tSe=vo(eSe);var nSe=["valueAccessor"],rSe=["dataKey","clockWise","id","textBreakAll","zIndex"];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 l6(t,e){if(t==null)return{};var n,r,i=iSe(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 iSe(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 aSe=t=>Array.isArray(t.value)?tSe(t.value):t.value,xY=S.createContext(void 0),oO=xY.Provider,bY=S.createContext(void 0),sSe=bY.Provider;function oSe(){return S.useContext(xY)}function lSe(){return S.useContext(bY)}function w1(t){var{valueAccessor:e=aSe}=t,n=l6(t,nSe),{dataKey:r,clockWise:i,id:a,textBreakAll:s,zIndex:l}=n,c=l6(n,rSe),u=oSe(),d=lSe(),f=u||d;return!f||!f.length?null:S.createElement(Ma,{zIndex:l??Gr.label},S.createElement(Or,{className:"recharts-label-list"},f.map((g,p)=>{var b,v=Tr(r)?e(g,p):Jn(g&&g.payload,r),x=Tr(a)?{}:{id:"".concat(a,"-").concat(p)};return S.createElement(Vu,Pw({key:"label-".concat(p)},da(g),c,x,{fill:(b=n.fill)!==null&&b!==void 0?b:g.fill,parentViewBox:g.parentViewBox,value:v,textBreakAll:s,viewBox:g.viewBox,index:p,zIndex:0}))})))}w1.displayName="LabelList";function WM(t){var{label:e}=t;return e?e===!0?S.createElement(w1,{key:"labelList-implicit"}):S.isValidElement(e)||sO(e)?S.createElement(w1,{key:"labelList-implicit",content:e}):typeof e=="object"?S.createElement(w1,Pw({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function eP(){return eP=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},eP.apply(null,arguments)}var yY=t=>{var{cx:e,cy:n,r,className:i}=t,a=In("recharts-dot",i);return Ot(e)&&Ot(n)&&Ot(r)?S.createElement("circle",eP({},Ia(t),RR(t),{className:a,cx:e,cy:n,r})):null},vY=t=>t.graphicalItems.polarItems,cSe=Ze([jr,Wb],kD),qM=Ze([vY,Ir,cSe],PD),uSe=Ze([qM],jD),KM=Ze([uSe,vD],RD),dSe=Ze([KM,Ir,qM],OD);Ze([KM,Ir,qM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,s=Jn(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:s,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Jn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var c6=()=>{},hSe=Ze([KM,Ir,qM,BM,jr],UD),fSe=Ze([Ir,ID,FD,c6,hSe,c6,Cn,jr],zD),_Y=Ze([Ir,Cn,KM,dSe,Gb,jr,fSe],BD),mSe=Ze([_Y,Ir,gg],VD);Ze([Ir,_Y,mSe,jr],WD);var pSe={radiusAxis:{},angleAxis:{}},wY=ls({name:"polarAxis",initialState:pSe,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:oqe,removeRadiusAxis:lqe,addAngleAxis:cqe,removeAngleAxis:uqe}=wY.actions,gSe=wY.reducer;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 d6(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){xSe(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 xSe(t,e,n){return(e=bSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bSe(t){var e=ySe(t,"string");return typeof e=="symbol"?e:e+""}function ySe(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 vSe=(t,e)=>e,lO=Ze([vY,vSe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),_Se=[],cO=(t,e,n)=>n?.length===0?_Se:n,SY=Ze([vD,lO,cO],(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=>d6(d6({},e.presentationProps),a.props))),i!=null)return i}}),wSe=Ze([SY,lO,cO],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,s=Jn(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:Dd(s,e.dataKey),color:l,payload:r,type:e.legendType}})}),SSe=Ze([SY,lO,cO,Ai],(t,e,n,r)=>{if(!(e==null||t==null))return MMe({offset:r,pieSettings:e,displayedData:t,cells:n})}),vN={exports:{}},ir={};var h6;function MSe(){if(h6)return ir;h6=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 b(v){if(typeof v=="object"&&v!==null){var x=v.$$typeof;switch(x){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 x}}case e:return x}}}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 b(v)===a},ir.isContextProvider=function(v){return b(v)===s},ir.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===t},ir.isForwardRef=function(v){return b(v)===l},ir.isFragment=function(v){return b(v)===n},ir.isLazy=function(v){return b(v)===f},ir.isMemo=function(v){return b(v)===d},ir.isPortal=function(v){return b(v)===e},ir.isProfiler=function(v){return b(v)===i},ir.isStrictMode=function(v){return b(v)===r},ir.isSuspense=function(v){return b(v)===c},ir.isSuspenseList=function(v){return b(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=b,ir}var f6;function ESe(){return f6||(f6=1,vN.exports=MSe()),vN.exports}var ASe=ESe(),m6=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",p6=null,_N=null,MY=t=>{if(t===p6&&Array.isArray(_N))return _N;var e=[];return S.Children.forEach(t,n=>{Tr(n)||(ASe.isFragment(n)?e=e.concat(MY(n.props.children)):e.push(n))}),_N=e,p6=t,e};function uO(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>m6(i)):r=[m6(e)],MY(t).forEach(i=>{var a=lf(i,"type.displayName")||lf(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var dO=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,wN={},g6;function TSe(){return g6||(g6=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})(wN)),wN}var SN,x6;function NSe(){return x6||(x6=1,SN=TSe().isPlainObject),SN}var CSe=NSe();const kSe=vo(CSe);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 y6(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 jw(){return jw=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},jw.apply(null,arguments)}var v6=(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},DSe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},OSe=t=>{var e=Lr(t,DSe),{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,b]=S.useState(-1),v=S.useRef(i),x=S.useRef(a),y=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&&b(R)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||s!==+s||i===0&&a===0||s===0)return null;var T=In("recharts-trapezoid",l);if(!f)return S.createElement("g",null,S.createElement("path",jw({},da(e),{className:T,d:v6(n,r,i,a,s)})));var C=v.current,N=x.current,O=y.current,k=E.current,j=w.current,z="0px ".concat(p===-1?1:p,"px"),I="".concat(p,"px 0px"),q=Wq(["strokeDasharray"],u,c);return S.createElement(cg,{animationId:A,key:A,canBegin:p>0,duration:u,easing:c,isActive:f,begin:d},R=>{var W=Wn(C,i,R),K=Wn(N,a,R),G=Wn(O,s,R),J=Wn(k,n,R),ee=Wn(j,r,R);g.current&&(v.current=W,x.current=K,y.current=G,E.current=J,w.current=ee);var Z=R>0?{transition:q,strokeDasharray:I}:{strokeDasharray:z};return S.createElement("path",jw({},da(e),{className:T,d:v6(J,ee,W,K,G),ref:g,style:y6(y6({},Z),e.style)}))})},LSe=["option","shapeType","propTransformer","activeClassName"];function ISe(t,e){if(t==null)return{};var n,r,i=FSe(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 FSe(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 _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 Rw(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){USe(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 USe(t,e,n){return(e=zSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zSe(t){var e=BSe(t,"string");return typeof e=="symbol"?e:e+""}function BSe(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 HSe(t,e){return Rw(Rw({},e),t)}function $Se(t,e){return t==="symbols"}function w6(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return S.createElement(Yq,n);case"trapezoid":return S.createElement(OSe,n);case"sector":return S.createElement(eK,n);case"symbols":if($Se(e))return S.createElement(jR,n);break;case"curve":return S.createElement(fp,n);default:return null}}function VSe(t){return S.isValidElement(t)?t.props:t}function hO(t){var{option:e,shapeType:n,propTransformer:r=HSe,activeClassName:i="recharts-active-shape"}=t,a=ISe(t,LSe),s;if(S.isValidElement(e))s=S.cloneElement(e,Rw(Rw({},a),VSe(e)));else if(typeof e=="function")s=e(a,a.index);else if(kSe(e)&&typeof e!="boolean"){var l=r(e,a);s=S.createElement(w6,{shapeType:n,elementProps:l})}else{var c=a;s=S.createElement(w6,{shapeType:n,elementProps:c})}return a.isActive?S.createElement(Or,{className:i},s):s}var fO=(t,e,n)=>{var r=xr();return(i,a)=>s=>{t?.(i,a,s),r(OX({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},mO=t=>{var e=xr();return(n,r)=>i=>{t?.(n,r,i),e(a_e())}},pO=(t,e,n)=>{var r=xr();return(i,a)=>s=>{t?.(i,a,s),r(s_e({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function XM(t){var{tooltipEntrySettings:e}=t,n=xr(),r=Ti(),i=S.useRef(null);return S.useLayoutEffect(()=>{r||(i.current===null?n(t_e(e)):i.current!==e&&n(n_e({prev:i.current,next:e})),i.current=e)},[e,n,r]),S.useLayoutEffect(()=>()=>{i.current&&(n(r_e(i.current)),i.current=null)},[n]),null}function gO(t){var{legendPayload:e}=t,n=xr(),r=Ti(),i=S.useRef(null);return S.useLayoutEffect(()=>{r||(i.current===null?n(Hq(e)):i.current!==e&&n($q({prev:i.current,next:e})),i.current=e)},[n,r,e]),S.useLayoutEffect(()=>()=>{i.current&&(n(Vq(i.current)),i.current=null)},[n]),null}function GSe(t){var{legendPayload:e}=t,n=xr(),r=Rt(Cn),i=S.useRef(null);return S.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(Hq(e)):i.current!==e&&n($q({prev:i.current,next:e})),i.current=e)},[n,r,e]),S.useLayoutEffect(()=>()=>{i.current&&(n(Vq(i.current)),i.current=null)},[n]),null}var MN,WSe=()=>{var[t]=S.useState(()=>I0("uid-"));return t},qSe=(MN=uie.useId)!==null&&MN!==void 0?MN:WSe;function EY(t,e){var n=qSe();return e||(t?"".concat(t,"-").concat(n):n)}var KSe=S.createContext(void 0),YM=t=>{var{id:e,type:n,children:r}=t,i=EY("recharts-".concat(n),e);return S.createElement(KSe.Provider,{value:i},r(i))},XSe={cartesianItems:[],polarItems:[]},AY=ls({name:"graphicalItems",initialState:XSe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Cr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ho(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Cr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Ho(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:Cr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:Cr()},removePolarGraphicalItem:{reducer(t,e){var n=Ho(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Cr()}}}),{addCartesianGraphicalItem:YSe,replaceCartesianGraphicalItem:ZSe,removeCartesianGraphicalItem:QSe,addPolarGraphicalItem:JSe,removePolarGraphicalItem:eMe}=AY.actions,tMe=AY.reducer,nMe=t=>{var e=xr(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?e(YSe(t)):n.current!==t&&e(ZSe({prev:n.current,next:t})),n.current=t},[e,t]),S.useLayoutEffect(()=>()=>{n.current&&(e(QSe(n.current)),n.current=null)},[e]),null},xO=S.memo(nMe);function rMe(t){var e=xr();return S.useLayoutEffect(()=>(e(JSe(t)),()=>{e(eMe(t))}),[e,t]),null}var iMe=["key"],aMe=["onMouseEnter","onClick","onMouseLeave"],sMe=["id"],oMe=["id"];function S6(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?S6(Object(n),!0).forEach(function(r){lMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lMe(t,e,n){return(e=cMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cMe(t){var e=uMe(t,"string");return typeof e=="symbol"?e:e+""}function uMe(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 Ad(){return Ad=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},Ad.apply(null,arguments)}function ZM(t,e){if(t==null)return{};var n,r,i=dMe(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 dMe(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 hMe(t){var e=S.useMemo(()=>uO(t.children,ny),[t.children]),n=Rt(r=>wSe(r,t.id,e));return n==null?null:S.createElement(GSe,{legendPayload:n})}var fMe=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:Dd(l,e),hide:c,type:u,color:s,unit:""}};return S.createElement(XM,{tooltipEntrySettings:d})}),mMe=(t,e)=>t>e?"start":t<e?"end":"middle",pMe=(t,e,n)=>wa(typeof e=="function"?e(t):e,n,n*.8),gMe=(t,e,n)=>{var{top:r,left:i,width:a,height:s}=e,l=Zq(a,s),c=i+wa(t.cx,a,a/2),u=r+wa(t.cy,s,s/2),d=wa(t.innerRadius,l,0),f=pMe(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}},xMe=(t,e)=>{var n=$i(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function bMe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var yMe=(t,e)=>{if(S.isValidElement(t))return S.cloneElement(t,e);if(typeof t=="function")return t(e);var n=In("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=ZM(e,iMe);return S.createElement(fp,Ad({},i,{type:"linear",className:n}))},vMe=(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=In("recharts-pie-label-text",bMe(t));return S.createElement(GM,Ad({},e,{alignmentBaseline:"middle",className:i}),r)};function _Me(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:s}=n;if(!r||!i||!e)return null;var l=Ia(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 b=(g.startAngle+g.endAngle)/2,v=di(g.cx,g.cy,g.outerRadius+d,b),x=$r($r($r($r({},l),g),{},{stroke:"none"},c),{},{index:p,textAnchor:mMe(v.x,g.cx)},v),y=$r($r($r($r({},l),g),{},{fill:"none",stroke:g.fill},u),{},{index:p,points:[di(g.cx,g.cy,g.outerRadius,b),v],key:"line"});return S.createElement(Ma,{zIndex:Gr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(p)},S.createElement(Or,null,a&&yMe(a,y),vMe(i,x,Jn(g,s))))});return S.createElement(Or,{className:"recharts-pie-labels"},f)}function wMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?S.createElement(WM,{label:i}):S.createElement(_Me,{sectors:e,props:n,showLabels:r})}function SMe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:s}=t,l=Rt(Ed),c=Rt(tO),u=Rt(G_e),{onMouseEnter:d,onClick:f,onMouseLeave:g}=i,p=ZM(i,aMe),b=fO(d,i.dataKey,s),v=mO(g),x=pO(f,i.dataKey,s);return e==null||e.length===0?null:S.createElement(S.Fragment,null,e.map((y,E)=>{if(y?.startAngle===0&&y?.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({},y),{},{stroke:y.stroke,tabIndex:-1,[Nq]:E,[Cq]:i.dataKey});return S.createElement(Or,Ad({key:"sector-".concat(y?.startAngle,"-").concat(y?.endAngle,"-").concat(y.midAngle,"-").concat(E),tabIndex:-1,className:"recharts-pie-sector"},Rb(p,y,E),{onMouseEnter:b(y,E),onMouseLeave:v(y,E),onClick:x(y,E)}),S.createElement(hO,Ad({option:a??C,index:E,shapeType:"sector",isActive:A},N)))}))}function MMe(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=xMe(l,c),b=Math.abs(p),v=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,x=r.filter(C=>Jn(C,u,0)!==0).length,y=(b>=360?x:x-1)*v,E=b-x*g-y,w=r.reduce((C,N)=>{var O=Jn(N,u,0);return C+(Ot(O)?O:0)},0),A;if(w>0){var T;A=r.map((C,N)=>{var O=Jn(C,u,0),k=Jn(C,d,N),j=gMe(n,a,C),z=(Ot(O)?O:0)/w,I,q=$r($r({},C),i&&i[N]&&i[N].props);N?I=T.endAngle+$i(p)*v*(O!==0?1:0):I=l;var R=I+$i(p)*((O!==0?g:0)+z*E),W=(I+R)/2,K=(j.innerRadius+j.outerRadius)/2,G=[{name:k,value:O,payload:q,dataKey:u,type:f}],J=di(j.cx,j.cy,K,W);return T=$r($r($r($r({},n.presentationProps),{},{percent:z,cornerRadius:typeof s=="string"?parseFloat(s):s,name:k,tooltipPayload:G,midAngle:W,middleRadius:K,tooltipPosition:J},q),j),{},{value:O,dataKey:u,startAngle:I,endAngle:R,payload:q,paddingAngle:$i(p)*v}),T})}return A}function EMe(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(sSe,{value:e?i:void 0},r)}function AMe(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-"),b=n.current,[v,x]=S.useState(!1),y=S.useCallback(()=>{typeof g=="function"&&g(),x(!1)},[g]),E=S.useCallback(()=>{typeof f=="function"&&f(),x(!0)},[f]);return S.createElement(EMe,{showLabels:!v,sectors:i},S.createElement(cg,{animationId:p,begin:s,duration:l,isActive:a,easing:c,onAnimationStart:E,onAnimationEnd:y,key:p},w=>{var A=[],T=i&&i[0],C=T?.startAngle;return i?.forEach((N,O)=>{var k=b&&b[O],j=O>0?lf(N,"paddingAngle",0):0;if(k){var z=Wn(k.endAngle-k.startAngle,N.endAngle-N.startAngle,w),I=$r($r({},N),{},{startAngle:C+j,endAngle:C+z+j});A.push(I),C=I.endAngle}else{var{endAngle:q,startAngle:R}=N,W=Wn(0,q-R,w),K=$r($r({},N),{},{startAngle:C+j,endAngle:C+W+j});A.push(K),C=K.endAngle}}),n.current=A,S.createElement(Or,null,S.createElement(SMe,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),S.createElement(wMe,{showLabels:!v,sectors:i,props:e}),e.children)}var TMe={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 NMe(t){var{id:e}=t,n=ZM(t,sMe),{hide:r,className:i,rootTabIndex:a}=t,s=S.useMemo(()=>uO(t.children,ny),[t.children]),l=Rt(d=>SSe(d,e,s)),c=S.useRef(null),u=In("recharts-pie",i);return r||l==null?(c.current=null,S.createElement(Or,{tabIndex:a,className:u})):S.createElement(Ma,{zIndex:t.zIndex},S.createElement(fMe,{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(AMe,{props:$r($r({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function TY(t){var e=Lr(t,TMe),{id:n}=e,r=ZM(e,oMe),i=Ia(r);return S.createElement(YM,{id:n,type:"pie"},a=>S.createElement(S.Fragment,null,S.createElement(rMe,{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(hMe,Ad({},r,{id:a})),S.createElement(NMe,Ad({},r,{id:a}))))}TY.displayName="Pie";var CMe=["points"];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 EN(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){kMe(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 kMe(t,e,n){return(e=PMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function PMe(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 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)}function RMe(t,e){if(t==null)return{};var n,r,i=DMe(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 DMe(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 OMe(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=In(r,typeof e!="boolean"?e.className:""),a=n??{},{points:s}=a,l=RMe(a,CMe);return S.createElement(yY,Dw({},l,{className:i}))}function LMe(t,e){return t==null?!1:e?!0:t.length===1}function NY(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:s,needClip:l,clipPathId:c,zIndex:u=Gr.scatter}=t;if(!LMe(e,n))return null;var d=dO(n),f=fhe(n),g=e.map((b,v)=>{var x,y,E=EN(EN(EN({r:3},s),f),{},{index:v,cx:(x=b.x)!==null&&x!==void 0?x:void 0,cy:(y=b.y)!==null&&y!==void 0?y:void 0,dataKey:a,value:b.value,payload:b.payload,points:e});return S.createElement(OMe,{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(Ma,{zIndex:u},S.createElement(Or,Dw({className:r},p),g))}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 A6(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){IMe(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 IMe(t,e,n){return(e=FMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function FMe(t){var e=UMe(t,"string");return typeof e=="symbol"?e:e+""}function UMe(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 zMe={xAxis:{},yAxis:{},zAxis:{}},CY=ls({name:"cartesianAxis",initialState:zMe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:Cr()},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:Cr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:Cr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:Cr()},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:Cr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:Cr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:Cr()},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:Cr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:Cr()},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]=A6(A6({},t.yAxis[n]),{},{width:r,widthHistory:s})}}}}),{addXAxis:BMe,replaceXAxis:HMe,removeXAxis:$Me,addYAxis:VMe,replaceYAxis:GMe,removeYAxis:WMe,addZAxis:dqe,replaceZAxis:hqe,removeZAxis:fqe,updateYAxisWidth:qMe}=CY.actions,KMe=CY.reducer,XMe=Ze([Ai],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),YMe=Ze([XMe,Qc,Jc],(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)}}),QM=()=>Rt(YMe),ZMe=()=>Rt(Y_e);function T6(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 AN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?T6(Object(n),!0).forEach(function(r){QMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function QMe(t,e,n){return(e=JMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JMe(t){var e=eEe(t,"string");return typeof e=="symbol"?e:e+""}function eEe(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 tEe=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=AN(AN(AN({},l),of(i)),RR(i)),u;return S.isValidElement(i)?u=S.cloneElement(i,c):typeof i=="function"?u=i(c):u=S.createElement(yY,c),S.createElement(Or,{className:"recharts-active-dot",clipPath:s},u)};function tP(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:s=Gr.activeDot}=t,l=Rt(Ed),c=ZMe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Tr(u)?null:S.createElement(Ma,{zIndex:s},S.createElement(tEe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var nEe="Invariant failed";function rEe(t,e){throw new Error(nEe)}var iEe=["x","y"];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 N6(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?N6(Object(n),!0).forEach(function(r){aEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):N6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function aEe(t,e,n){return(e=sEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sEe(t){var e=oEe(t,"string");return typeof e=="symbol"?e:e+""}function oEe(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 lEe(t,e){if(t==null)return{};var n,r,i=cEe(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 cEe(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 uEe(t,e){var{x:n,y:r}=t,i=lEe(t,iEe),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 Ow(t){return S.createElement(hO,nP({shapeType:"rectangle",propTransformer:uEe,activeClassName:"recharts-active-bar"},t))}var dEe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Ot(e))return e;var a=Ot(r)||Tr(r);return a?e(r,i):(a||rEe(),n)}},hEe={},kY=ls({name:"errorBars",initialState:hEe,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:mqe,replaceErrorBar:pqe,removeErrorBar:gqe}=kY.actions,fEe=kY.reducer,mEe=["children"];function pEe(t,e){if(t==null)return{};var n,r,i=gEe(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 gEe(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 xEe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},bEe=S.createContext(xEe);function PY(t){var{children:e}=t,n=pEe(t,mEe);return S.createElement(bEe.Provider,{value:n},e)}function JM(t,e){var n,r,i=Rt(u=>Dl(u,t)),a=Rt(u=>Ol(u,e)),s=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Ii.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Fi.allowDataOverflow,c=s||l;return{needClip:c,needClipX:s,needClipY:l}}function bO(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=QM(),{needClipX:a,needClipY:s,needClip:l}=JM(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 yEe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&er(t.zIndex)?t.zIndex:e}var TN={exports:{}},NN={};var C6;function vEe(){if(C6)return NN;C6=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 NN.useSyncExternalStoreWithSelector=function(c,u,d,f,g){var p=i(null);if(p.current===null){var b={hasValue:!1,value:null};p.current=b}else b=p.current;p=s(function(){function x(T){if(!y){if(y=!0,E=T,T=f(T),g!==void 0&&b.hasValue){var C=b.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 y=!1,E,w,A=d===void 0?null:d;return[function(){return x(u())},A===null?void 0:function(){return x(A())}]},[u,d,f,g]);var v=r(c,p[0],p[1]);return a(function(){b.hasValue=!0,b.value=v},[v]),l(v),v},NN}var k6;function _Ee(){return k6||(k6=1,TN.exports=vEe()),TN.exports}_Ee();function wEe(t){t()}function SEe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){wEe(()=>{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 P6={notify(){},get:()=>[]};function MEe(t,e){let n,r=P6,i=0,a=!1;function s(v){d();const x=r.subscribe(v);let y=!1;return()=>{y||(y=!0,x(),f())}}function l(){r.notify()}function c(){b.onStateChange&&b.onStateChange()}function u(){return a}function d(){i++,n||(n=t.subscribe(c),r=SEe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=P6)}function g(){a||(a=!0,d())}function p(){a&&(a=!1,f())}const b={addNestedSub:s,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:g,tryUnsubscribe:p,getListeners:()=>r};return b}var EEe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",AEe=EEe(),TEe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",NEe=TEe(),CEe=()=>AEe||NEe?S.useLayoutEffect:S.useEffect,kEe=CEe();function j6(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function PEe(t,e){if(j6(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])||!j6(t[n[i]],e[n[i]]))return!1;return!0}var jEe=Symbol.for("react-redux-context"),REe=typeof globalThis<"u"?globalThis:{};function DEe(){if(!S.createContext)return{};const t=REe[jEe]??=new Map;let e=t.get(S.createContext);return e||(e=S.createContext(null),t.set(S.createContext,e)),e}var OEe=DEe();function LEe(t){const{children:e,context:n,serverState:r,store:i}=t,a=S.useMemo(()=>{const c=MEe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),s=S.useMemo(()=>i.getState(),[i]);kEe(()=>{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||OEe;return S.createElement(l.Provider,{value:a},e)}var IEe=LEe,FEe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function UEe(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(FEe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!PEe(t[r],e[r]))return!1}else if(!UEe(t[r],e[r]))return!1;return!0}var zEe=["onMouseEnter","onMouseLeave","onClick"],BEe=["value","background","tooltipPosition"],HEe=["id"],$Ee=["onMouseEnter","onClick","onMouseLeave"];function Xc(){return Xc=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},Xc.apply(null,arguments)}function R6(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 ja(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?R6(Object(n),!0).forEach(function(r){VEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function VEe(t,e,n){return(e=GEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GEe(t){var e=WEe(t,"string");return typeof e=="symbol"?e:e+""}function WEe(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 Lw(t,e){if(t==null)return{};var n,r,i=qEe(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 qEe(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 KEe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Dd(n,e),payload:t}]},XEe=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:Dd(a,e),hide:s,type:c,color:i,unit:l}};return S.createElement(XM,{tooltipEntrySettings:u})});function YEe(t){var e=Rt(Ed),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:s,onMouseLeave:l,onClick:c}=a,u=Lw(a,zEe),d=fO(s,r),f=mO(l),g=pO(c,r);if(!i||n==null)return null;var p=of(i);return S.createElement(Ma,{zIndex:yEe(i,Gr.barBackground)},n.map((b,v)=>{var{value:x,background:y,tooltipPosition:E}=b,w=Lw(b,BEe);if(!y)return null;var A=d(b,v),T=f(b,v),C=g(b,v),N=ja(ja(ja(ja(ja({option:i,isActive:String(v)===e},w),{},{fill:"#eee"},y),p),Rb(u,b,v)),{},{onMouseEnter:A,onMouseLeave:T,onClick:C,dataKey:r,index:v,className:"recharts-bar-background-rectangle"});return S.createElement(Ow,Xc({key:"background-bar-".concat(v)},N))}))}function ZEe(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 ja(ja({},s),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:s,fill:a.fill})});return S.createElement(oO,{value:e?i:void 0},n)}function QEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:s}=t,l=Rt(Ed),c=Rt(tO),u=n&&String(a)===l&&(c==null||s===c),d=u?n:e;return u?S.createElement(Ma,{zIndex:Gr.activeBar},S.createElement(Ow,Xc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:s}))):S.createElement(Ow,Xc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:s}))}function JEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return S.createElement(Ow,Xc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function e2e(t){var e,{data:n,props:r}=t,i=(e=Ia(r))!==null&&e!==void 0?e:{},{id:a}=i,s=Lw(i,HEe),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:g}=r,p=Lw(r,$Ee),b=fO(d,c),v=mO(g),x=pO(f,c);return n?S.createElement(S.Fragment,null,n.map((y,E)=>S.createElement(Or,Xc({key:"rectangle-".concat(y?.x,"-").concat(y?.y,"-").concat(y?.value,"-").concat(E),className:"recharts-bar-rectangle"},Rb(p,y,E),{onMouseEnter:b(y,E),onMouseLeave:v(y,E),onClick:x(y,E)}),u?S.createElement(QEe,{shape:l,activeBar:u,baseProps:s,entry:y,index:E,dataKey:c}):S.createElement(JEe,{shape:l,baseProps:s,entry:y,index:E,dataKey:c})))):null}function t2e(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,b]=S.useState(!1),v=!p,x=S.useCallback(()=>{typeof u=="function"&&u(),b(!1)},[u]),y=S.useCallback(()=>{typeof d=="function"&&d(),b(!0)},[d]);return S.createElement(ZEe,{showLabels:v,rects:r},S.createElement(cg,{animationId:g,begin:s,duration:l,isActive:a,easing:c,onAnimationEnd:x,onAnimationStart:y,key:g},E=>{var w=E===1?r:r?.map((A,T)=>{var C=f&&f[T];if(C)return ja(ja({},A),{},{x:Wn(C.x,A.x,E),y:Wn(C.y,A.y,E),width:Wn(C.width,A.width,E),height:Wn(C.height,A.height,E)});if(i==="horizontal"){var N=Wn(0,A.height,E),O=Wn(A.stackedBarStart,A.y,E);return ja(ja({},A),{},{y:O,height:N})}var k=Wn(0,A.width,E),j=Wn(A.stackedBarStart,A.x,E);return ja(ja({},A),{},{width:k,x:j})});return E>0&&(n.current=w??null),w==null?null:S.createElement(Or,null,S.createElement(e2e,{props:e,data:w}))}),S.createElement(WM,{label:e.label}),e.children)}function n2e(t){var e=S.useRef(null);return S.createElement(t2e,{previousRectanglesRef:e,props:t})}var jY=0,r2e=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Jn(t,e)}};class i2e 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=In("recharts-bar",i),f=u;return S.createElement(Or,{className:d,id:u},l&&S.createElement("defs",null,S.createElement(bO,{clipPathId:f,xAxisId:a,yAxisId:s})),S.createElement(Or,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},S.createElement(YEe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),S.createElement(n2e,this.props)))}}var a2e={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:jY,xAxisId:0,yAxisId:0,zIndex:Gr.bar};function s2e(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}=JM(e,n),g=Ef(),p=Ti(),b=uO(t.children,ny),v=Rt(E=>D2e(E,e,n,p,t.id,b));if(g!=="vertical"&&g!=="horizontal")return null;var x,y=v?.[0];return y==null||y.height==null||y.width==null?x=0:x=g==="vertical"?y.height/2:y.width/2,S.createElement(PY,{xAxisId:e,yAxisId:n,data:v,dataPointFormatter:r2e,errorBarOffset:x},S.createElement(i2e,Xc({},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 o2e(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:b,dataStartIndex:v}=t,x=e==="horizontal"?l:s,y=d?x.scale.domain():null,E=kpe({numericAxis:x}),w=x.scale(E);return f.map((A,T)=>{var C,N,O,k,j,z;d?C=Epe(d[T+v],y):(C=Jn(A,n),Array.isArray(C)||(C=[E,C]));var I=dEe(r,jY)(C[1],T);if(e==="horizontal"){var q,[R,W]=[l.scale(C[0]),l.scale(C[1])];N=Yz({axis:s,ticks:c,bandSize:a,offset:i.offset,entry:A,index:T}),O=(q=W??R)!==null&&q!==void 0?q:void 0,k=i.size;var K=R-W;if(j=ss(K)?0:K,z={x:N,y:g.top,width:k,height:g.height},Math.abs(I)>0&&Math.abs(j)<Math.abs(I)){var G=$i(j||I)*(Math.abs(I)-Math.abs(j));O-=G,j+=G}}else{var[J,ee]=[s.scale(C[0]),s.scale(C[1])];if(N=J,O=Yz({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:A,index:T}),k=ee-J,j=i.size,z={x:g.left,y:O,width:g.width,height:j},Math.abs(I)>0&&Math.abs(k)<Math.abs(I)){var Z=$i(k||I)*(Math.abs(I)-Math.abs(k));k+=Z}}if(N==null||O==null||k==null||j==null)return null;var F=ja(ja({},A),{},{stackedBarStart:w,x:N,y:O,width:k,height:j,value:d?C:C[1],payload:A,background:z,tooltipPosition:{x:N+k/2,y:O+j/2},parentViewBox:b},p&&p[T]&&p[T].props);return F}).filter(Boolean)}function l2e(t){var e=Lr(t,a2e),n=Ti();return S.createElement(YM,{id:e.id,type:"bar"},r=>S.createElement(S.Fragment,null,S.createElement(gO,{legendPayload:KEe(e)}),S.createElement(XEe,{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(xO,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:Aq(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),S.createElement(Ma,{zIndex:e.zIndex},S.createElement(s2e,Xc({},e,{id:r})))))}var RY=S.memo(l2e,ry);RY.displayName="Bar";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 Gv(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){c2e(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 c2e(t,e,n){return(e=u2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u2e(t){var e=d2e(t,"string");return typeof e=="symbol"?e:e+""}function d2e(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 h2e=(t,e)=>e,f2e=(t,e,n)=>n,m2e=(t,e,n,r)=>r,p2e=(t,e,n,r,i)=>i,iy=Ze([Kb,p2e],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),g2e=Ze([iy],t=>t?.maxBarSize),x2e=(t,e,n,r,i,a)=>a,O6=(t,e,n)=>{var r=n??t;if(!Tr(r))return wa(r,e,0)},b2e=Ze([Cn,Kb,h2e,f2e,m2e],(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")),y2e=(t,e,n,r)=>{var i=Cn(t);return i==="horizontal"?Y0(t,"yAxis",n,r):Y0(t,"xAxis",e,r)},v2e=(t,e,n)=>{var r=Cn(t);return r==="horizontal"?C8(t,"xAxis",e):C8(t,"yAxis",n)},_2e=(t,e,n)=>{var r={},i=t.filter(IM),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(b=>b.dataKey),p=O6(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=O6(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]},w2e=Ze([b2e,qye,v2e],_2e),S2e=(t,e,n,r,i)=>{var a,s,l=iy(t,e,n,r,i);if(l!=null){var c=Cn(t),u=YK(t),{maxBarSize:d}=l,f=Tr(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=wd(g,p,!0))!==null&&s!==void 0?s:f)!==null&&a!==void 0?a:0}},DY=(t,e,n,r)=>{var i=Cn(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)),wd(a,s)};function M2e(t,e,n,r,i){var a=r.length;if(!(a<1)){var s=wa(t,n,0,!0),l,c=[];if(er(r[0].barSize)){var u=!1,d=n/a,f=r.reduce((y,E)=>y+(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((y,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=[...y,A];return p=T[T.length-1].position,T},c)}else{var b=wa(e,n,0,!0);n-2*b-(a-1)*s<=0&&(s=0);var v=(n-2*b-(a-1)*s)/a;v>1&&(v>>=0);var x=er(i)?Math.min(v,i):v;l=r.reduce((y,E,w)=>[...y,{stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:b+(v+s)*w+(v-x)/2,size:x}}],c)}return l}}var E2e=(t,e,n,r,i,a,s)=>{var l=Tr(s)?e:s,c=M2e(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},A2e=Ze([w2e,YK,Wye,ZK,S2e,DY,g2e],E2e),T2e=(t,e,n,r)=>El(t,"xAxis",e,r),N2e=(t,e,n,r)=>El(t,"yAxis",n,r),C2e=(t,e,n,r)=>Ml(t,"xAxis",e,r),k2e=(t,e,n,r)=>Ml(t,"yAxis",n,r),P2e=Ze([A2e,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}}),j2e=(t,e)=>{var n=LM(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)}}}},R2e=Ze([y2e,iy],j2e),D2e=Ze([Ai,VR,T2e,N2e,C2e,k2e,P2e,Cn,Vb,DY,R2e,iy,x2e],(t,e,n,r,i,a,s,l,c,u,d,f,g)=>{var{chartData:p,dataStartIndex:b,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:x}=f,y;if(x!=null&&x.length>0?y=x:y=p?.slice(b,v+1),y!=null)return o2e({layout:l,barSettings:f,pos:s,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:y,offset:t,cells:g,dataStartIndex:b})}}),OY=t=>{var{chartData:e}=t,n=xr(),r=Ti();return S.useEffect(()=>r?()=>{}:(n(H8(e)),()=>{n(H8(void 0))}),[e,n,r]),null},L6={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},LY=ls({name:"brush",initialState:L6,reducers:{setBrushSettings(t,e){return e.payload==null?L6:e.payload}}}),{setBrushSettings:xqe}=LY.actions,O2e=LY.reducer;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 Wv(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){IY(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 IY(t,e,n){return(e=L2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function L2e(t){var e=I2e(t,"string");return typeof e=="symbol"?e:e+""}function I2e(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 F2e=(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)}},U2e=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return F2e({x:e,y:n},{x:r,y:i})};class eE{static create(e){return new eE(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}}IY(eE,"EPS",1e-4);var z2e=t=>{var e=Object.keys(t).reduce((n,r)=>Wv(Wv({},n),{},{[r]:eE.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 B2e(t){return(t%180+180)%180}var H2e=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=B2e(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)},$2e={dots:[],areas:[],lines:[]},FY=ls({name:"referenceElements",initialState:$2e,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:bqe,removeDot:yqe,addArea:vqe,removeArea:_qe,addLine:V2e,removeLine:G2e}=FY.actions,W2e=FY.reducer,UY=S.createContext(void 0),q2e=t=>{var{children:e}=t,[n]=S.useState("".concat(I0("recharts"),"-clip")),r=QM();if(r==null)return null;var{x:i,y:a,width:s,height:l}=r;return S.createElement(UY.Provider,{value:n},S.createElement("defs",null,S.createElement("clipPath",{id:n},S.createElement("rect",{x:i,y:a,height:l,width:s}))),e)},K2e=()=>S.useContext(UY);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 U6(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){X2e(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 X2e(t,e,n){return(e=Y2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Y2e(t){var e=Z2e(t,"string");return typeof e=="symbol"?e:e+""}function Z2e(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 Iw(){return Iw=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},Iw.apply(null,arguments)}var Q2e=(t,e)=>{var n;if(S.isValidElement(t))n=S.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!er(e.x1)||!er(e.y1)||!er(e.x2)||!er(e.y2))return null;n=S.createElement("line",Iw({},e,{className:"recharts-reference-line-line"}))}return n},J2e=(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},eAe=(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},tAe=(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},nAe=(t,e,n,r,i,a)=>{var{x:s,y:l,segment:c,ifOverflow:u}=a,d=xo(s),f=xo(l);return f?J2e(l,u,n,i,t,e):d?eAe(s,u,n,r,t,e):c!=null&&c.length===2?tAe(c,u,n,t):null};function rAe(t){var e=xr();return S.useEffect(()=>(e(V2e(t)),()=>{e(G2e(t))})),null}function iAe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,s=Ti(),l=K2e(),c=Rt(C=>Dl(C,e)),u=Rt(C=>Ol(C,n)),d=Rt(C=>Md(C,"xAxis",e,s)),f=Rt(C=>Md(C,"yAxis",n,s)),g=Fb();if(!l||!g||c==null||u==null||d==null||f==null)return null;var p=z2e({x:d,y:f}),b=nAe(p,g,t.position,c.orientation,u.orientation,t);if(!b)return null;var[{x:v,y:x},{x:y,y:E}]=b,w=a==="hidden"?"url(#".concat(l,")"):void 0,A=U6(U6({clipPath:w},da(t)),{},{x1:v,y1:x,x2:y,y2:E}),T=U2e({x1:v,y1:x,x2:y,y2:E});return S.createElement(Ma,{zIndex:t.zIndex},S.createElement(Or,{className:In("recharts-reference-line",i)},Q2e(r,A),S.createElement(mY,Iw({},T,{lowerWidth:T.width,upperWidth:T.width}),S.createElement(gY,{label:t.label}),t.children)))}var aAe={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,aAe);return S.createElement(S.Fragment,null,S.createElement(rAe,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),S.createElement(iAe,e))}Kx.displayName="ReferenceLine";function zY(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 sAe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return H2e(r,n)}function oAe(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 Fw(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 lAe(t,e){return zY(t,e+1)}function cAe(t,e,n,r,i){for(var a=(r||[]).slice(),{start:s,end:l}=e,c=0,u=1,d=s,f=function(){var b=r?.[c];if(b===void 0)return{v:zY(r,u)};var v=c,x,y=()=>(x===void 0&&(x=n(b,v)),x),E=b.coordinate,w=c===0||Fw(t,E,y,d,l);w||(c=0,d=s,u+=1),w&&(d=E+t*(y()/2+i),c+=u)},g;u<=a.length;)if(g=f(),g)return g.v;return[]}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 ba(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){uAe(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 uAe(t,e,n){return(e=dAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dAe(t){var e=hAe(t,"string");return typeof e=="symbol"?e:e+""}function hAe(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 fAe(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],b,v=()=>(b===void 0&&(b=n(p,g)),b);if(g===s-1){var x=t*(p.coordinate+t*v()/2-c);a[g]=p=ba(ba({},p),{},{tickCoord:x>0?p.coordinate-x*t:p.coordinate})}else a[g]=p=ba(ba({},p),{},{tickCoord:p.coordinate});if(p.tickCoord!=null){var y=Fw(t,p.tickCoord,v,l,c);y&&(c=p.tickCoord-t*(v()/2+i),a[g]=ba(ba({},p),{},{isShow:!0}))}},d=s-1;d>=0;d--)u(d);return a}function mAe(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=ba(ba({},d),{},{tickCoord:g>0?d.coordinate-g*t:d.coordinate}),d.tickCoord!=null){var p=Fw(t,d.tickCoord,()=>f,c,u);p&&(u=d.tickCoord-t*(f/2+i),s[l-1]=ba(ba({},d),{},{isShow:!0}))}}for(var b=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=ba(ba({},w),{},{tickCoord:C<0?w.coordinate-C*t:w.coordinate})}else s[E]=w=ba(ba({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var N=Fw(t,w.tickCoord,T,c,u);N&&(c=w.tickCoord+t*(T()/2+i),s[E]=ba(ba({},w),{},{isShow:!0}))}},x=0;x<b;x++)v(x);return s}function yO(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(Ot(c)||lg.isSsr){var g;return(g=lAe(i,Ot(c)?c:0))!==null&&g!==void 0?g:[]}var p=[],b=l==="top"||l==="bottom"?"width":"height",v=d&&b==="width"?l0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},x=(w,A)=>{var T=typeof u=="function"?u(w.value,A):w.value;return b==="width"?sAe(l0(T,{fontSize:e,letterSpacing:n}),v,f):l0(T,{fontSize:e,letterSpacing:n})[b]},y=i.length>=2?$i(i[1].coordinate-i[0].coordinate):1,E=oAe(a,y,b);return c==="equidistantPreserveStart"?cAe(y,E,x,i,s):(c==="preserveStart"||c==="preserveStartEnd"?p=mAe(y,E,x,i,s,c==="preserveStartEnd"):p=fAe(y,E,x,i,s),p.filter(w=>w.isShow))}var pAe=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},gAe=["axisLine","width","height","className","hide","ticks","axisType"];function xAe(t,e){if(t==null)return{};var n,r,i=bAe(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 bAe(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 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 oi(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){yAe(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 yAe(t,e,n){return(e=vAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vAe(t){var e=_Ae(t,"string");return typeof e=="symbol"?e:e+""}function _Ae(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 wAe(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),Ia(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:In("recharts-cartesian-axis-line",lf(l,"className"))}))}function SAe(t,e,n,r,i,a,s,l,c){var u,d,f,g,p,b,v=l?-1:1,x=t.tickSize||s,y=Ot(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,g=n+ +!l*i,f=g-v*x,b=f-v*c,p=y;break;case"left":f=g=t.coordinate,d=e+ +!l*r,u=d-v*x,p=u-v*c,b=y;break;case"right":f=g=t.coordinate,d=e+ +l*r,u=d+v*x,p=u+v*c,b=y;break;default:u=d=t.coordinate,g=n+ +l*i,f=g+v*x,b=f+v*c,p=y;break}return{line:{x1:u,y1:f,x2:d,y2:g},tick:{x:p,y:b}}}function MAe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function EAe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function AAe(t){var{option:e,tickProps:n,value:r}=t,i,a=In(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=In(s,e?.className)),i=S.createElement(GM,hf({},n,{className:s}),r)}return i}var TAe=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:b,height:v,tickSize:x,tickMargin:y,fontSize:E,letterSpacing:w,getTicksConfig:A,events:T,axisType:C}=t,N=yO(oi(oi({},A),{},{ticks:n}),E,w),O=MAe(d,f),k=EAe(d,f),j=Ia(A),z=of(r),I={};typeof i=="object"&&(I=i);var q=oi(oi({},j),{},{fill:"none"},I),R=N.map(G=>oi({entry:G},SAe(G,g,p,b,v,d,x,f,y))),W=R.map(G=>{var{entry:J,line:ee}=G;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({},q,ee,{className:In("recharts-cartesian-axis-tick-line",lf(i,"className"))})))}),K=R.map((G,J)=>{var{entry:ee,tick:Z}=G,F=oi(oi(oi(oi({textAnchor:O,verticalAnchor:k},j),{},{stroke:"none",fill:a},z),Z),{},{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(AAe,{option:r,tickProps:F,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")},K.length>0&&S.createElement(Ma,{zIndex:Gr.label},S.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(C,"-tick-labels"),ref:e},K)),W.length>0&&S.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(C,"-tick-lines")},W))}),NAe=S.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:s,ticks:l,axisType:c}=t,u=xAe(t,gAe),[d,f]=S.useState(""),[g,p]=S.useState(""),b=S.useRef(null);S.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var x;return pAe({ticks:b.current,label:(x=t.labelRef)===null||x===void 0?void 0:x.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var v=S.useCallback(x=>{if(x){var y=x.getElementsByClassName("recharts-cartesian-axis-tick-value");b.current=y;var E=y[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(Ma,{zIndex:t.zIndex},S.createElement(Or,{className:In("recharts-cartesian-axis",a)},S.createElement(wAe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Ia(t)}),S.createElement(TAe,{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(mY,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},S.createElement(gY,{label:t.label,labelRef:t.labelRef}),t.children)))}),vO=S.forwardRef((t,e)=>{var n=Lr(t,Rc);return S.createElement(NAe,hf({},n,{ref:e}))});vO.displayName="CartesianAxis";var CAe=["x1","y1","x2","y2","key"],kAe=["offset"],PAe=["xAxisId","yAxisId"],jAe=["xAxisId","yAxisId"];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 va(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){RAe(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 RAe(t,e,n){return(e=DAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DAe(t){var e=OAe(t,"string");return typeof e=="symbol"?e:e+""}function OAe(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 kh(){return kh=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},kh.apply(null,arguments)}function Uw(t,e){if(t==null)return{};var n,r,i=LAe(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 LAe(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 IAe=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 BY(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=Uw(n,CAe),f=(i=Ia(d))!==null&&i!==void 0?i:{},{offset:g}=f,p=Uw(f,kAe);r=S.createElement("line",kh({},p,{x1:a,y1:s,x2:l,y2:c,fill:"none",key:u}))}return r}function FAe(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=Uw(t,PAe),c=i.map((u,d)=>{var f=va(va({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return S.createElement(BY,{key:"line-".concat(d),option:r,lineItemProps:f})});return S.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function UAe(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=Uw(t,jAe),c=i.map((u,d)=>{var f=va(va({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return S.createElement(BY,{option:r,lineItemProps:f,key:"line-".concat(d)})});return S.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function zAe(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],b=p?i+s-f:u[g+1]-f;if(b<=0)return null;var v=g%e.length;return S.createElement("rect",{key:"react-".concat(g),y:f,x:r,height:b,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 BAe(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],b=p?i+s-f:u[g+1]-f;if(b<=0)return null;var v=g%n.length;return S.createElement("rect",{key:"react-".concat(g),x:f,y:a,width:b,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 HAe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return Mq(yO(va(va(va({},Rc),n),{},{ticks:Eq(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},$Ae=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return Mq(yO(va(va(va({},Rc),n),{},{ticks:Eq(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},VAe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Gr.grid};function zw(t){var e=WR(),n=qR(),r=Dq(),i=va(va({},Lr(t,VAe)),{},{x:Ot(t.x)?t.x:r.left,y:Ot(t.y)?t.y:r.top,width:Ot(t.width)?t.width:r.width,height:Ot(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,b=Ti(),v=Rt(k=>k8(k,"xAxis",a,b)),x=Rt(k=>k8(k,"yAxis",s,b));if(!wl(u)||!wl(d)||!Ot(l)||!Ot(c))return null;var y=i.verticalCoordinatesGenerator||HAe,E=i.horizontalCoordinatesGenerator||$Ae,{horizontalPoints:w,verticalPoints:A}=i;if((!w||!w.length)&&typeof E=="function"){var T=g&&g.length,C=E({yAxis:x?va(va({},x),{},{ticks:T?g:x.ticks}):void 0,width:e??u,height:n??d,offset:r},T?!0:f);cw(Array.isArray(C),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof C,"]")),Array.isArray(C)&&(w=C)}if((!A||!A.length)&&typeof y=="function"){var N=p&&p.length,O=y({xAxis:v?va(va({},v),{},{ticks:N?p:v.ticks}):void 0,width:e??u,height:n??d,offset:r},N?!0:f);cw(Array.isArray(O),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof O,"]")),Array.isArray(O)&&(A=O)}return S.createElement(Ma,{zIndex:i.zIndex},S.createElement("g",{className:"recharts-cartesian-grid"},S.createElement(IAe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),S.createElement(zAe,kh({},i,{horizontalPoints:w})),S.createElement(BAe,kh({},i,{verticalPoints:A})),S.createElement(FAe,kh({},i,{offset:r,horizontalPoints:w,xAxis:v,yAxis:x})),S.createElement(UAe,kh({},i,{offset:r,verticalPoints:A,xAxis:v,yAxis:x}))))}zw.displayName="CartesianGrid";var HY=(t,e,n,r)=>El(t,"xAxis",e,r),$Y=(t,e,n,r)=>Ml(t,"xAxis",e,r),VY=(t,e,n,r)=>El(t,"yAxis",n,r),GY=(t,e,n,r)=>Ml(t,"yAxis",n,r),GAe=Ze([Cn,HY,VY,$Y,GY],(t,e,n,r,i)=>Rl(t,"xAxis")?wd(e,r,!1):wd(n,i,!1)),WAe=(t,e,n,r,i)=>i;function qAe(t){return t.type==="line"}var KAe=Ze([Kb,WAe],(t,e)=>t.filter(qAe).find(n=>n.id===e)),XAe=Ze([Cn,HY,VY,$Y,GY,KAe,GAe,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 pTe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:s,displayedData:p})}});function WY(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 YAe=["id"],ZAe=["type","layout","connectNulls","needClip","shape"],QAe=["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 $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 cl(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){JAe(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 JAe(t,e,n){return(e=eTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eTe(t){var e=tTe(t,"string");return typeof e=="symbol"?e:e+""}function tTe(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 _O(t,e){if(t==null)return{};var n,r,i=nTe(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 nTe(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 rTe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Dd(n,e),payload:t}]},iTe=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:Dd(s,e),hide:l,type:u,color:r,unit:c}};return S.createElement(XM,{tooltipEntrySettings:d})}),qY=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function aTe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var sTe=(t,e,n)=>{var r=n.reduce((f,g)=>f+g);if(!r)return qY(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[...aTe(n,i),...l,...d].map(f=>"".concat(f,"px")).join(", ")};function oTe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:s}=r,{id:l}=r,c=_O(r,YAe),u=Ia(c);return S.createElement(NY,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:s,clipPathId:e})}function lTe(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(oO,{value:e?i:void 0},n)}function V6(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=_O(a,ZAe),g=cl(cl({},da(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(hO,Q0({shapeType:"curve",option:d},g,{pathRef:n})),S.createElement(oTe,{points:r,clipPathId:e,props:a}))}function cTe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function uTe(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:b,onAnimationEnd:v,onAnimationStart:x}=n,y=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 x=="function"&&x(),T(!0)},[x]),k=cTe(r.current),j=S.useRef(0);w.current!==E&&(j.current=a.current,w.current=E);var z=j.current;return S.createElement(lTe,{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},I=>{var q=Wn(z,k+z,I),R=Math.min(q,k),W;if(c)if(l){var K="".concat(l).split(/[,\s]+/gim).map(ee=>parseFloat(ee));W=sTe(R,k,K)}else W=qY(k,R);else W=l==null?void 0:String(l);if(I>0&&k>0&&(i.current=s,a.current=Math.max(a.current,R)),y){var G=y.length/s.length,J=I===1?s:s.map((ee,Z)=>{var F=Math.floor(Z*G);if(y[F]){var V=y[F];return cl(cl({},ee),{},{x:Wn(V.x,ee.x,I),y:Wn(V.y,ee.y,I)})}return g?cl(cl({},ee),{},{x:Wn(p*2,ee.x,I),y:Wn(b/2,ee.y,I)}):cl(cl({},ee),{},{x:ee.x,y:ee.y})});return i.current=J,S.createElement(V6,{props:n,points:J,clipPathId:e,pathRef:r,strokeDasharray:W})}return S.createElement(V6,{props:n,points:s,clipPathId:e,pathRef:r,strokeDasharray:W})}),S.createElement(WM,{label:n.label}))}function dTe(t){var{clipPathId:e,props:n}=t,r=S.useRef(null),i=S.useRef(0),a=S.useRef(null);return S.createElement(uTe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var hTe=(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:Jn(t.payload,e)}};class fTe 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 b=In("recharts-line",i),v=f,{r:x,strokeWidth:y}=WY(n),E=dO(n),w=x*2+y,A=g?"url(#clipPath-".concat(E?"":"dots-").concat(v,")"):void 0;return S.createElement(Ma,{zIndex:p},S.createElement(Or,{className:b},g&&S.createElement("defs",null,S.createElement(bO,{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(PY,{xAxisId:a,yAxisId:s,data:r,dataPointFormatter:hTe,errorBarOffset:0},S.createElement(dTe,{props:this.props,clipPathId:v}))),S.createElement(tP,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var KY={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 mTe(t){var e=Lr(t,KY),{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:b,id:v}=e,x=_O(e,QAe),{needClip:y}=JM(p,b),E=QM(),w=Ef(),A=Ti(),T=Rt(j=>XAe(j,p,b,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(fTe,Q0({},x,{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:b,points:T,layout:w,height:C,width:N,left:O,top:k,needClip:y}))}function pTe(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=Jn(u,s);if(e==="horizontal"){var g=lw({axis:n,ticks:i,bandSize:l,entry:u,index:d}),p=Tr(f)?null:r.scale(f);return{x:g,y:p,value:f,payload:u}}var b=Tr(f)?null:n.scale(f),v=lw({axis:r,ticks:a,bandSize:l,entry:u,index:d});return b==null||v==null?null:{x:b,y:v,value:f,payload:u}}).filter(Boolean)}function gTe(t){var e=Lr(t,KY),n=Ti();return S.createElement(YM,{id:e.id,type:"line"},r=>S.createElement(S.Fragment,null,S.createElement(gO,{legendPayload:rTe(e)}),S.createElement(iTe,{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(xO,{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(mTe,Q0({},e,{id:r}))))}var XY=S.memo(gTe,ry);XY.displayName="Line";var YY=(t,e,n,r)=>El(t,"xAxis",e,r),ZY=(t,e,n,r)=>Ml(t,"xAxis",e,r),QY=(t,e,n,r)=>El(t,"yAxis",n,r),JY=(t,e,n,r)=>Ml(t,"yAxis",n,r),xTe=Ze([Cn,YY,QY,ZY,JY],(t,e,n,r,i)=>Rl(t,"xAxis")?wd(e,r,!1):wd(n,i,!1)),bTe=(t,e,n,r,i)=>i,eZ=Ze([Kb,bTe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),yTe=(t,e,n,r,i)=>{var a,s=eZ(t,e,n,r,i);if(s!=null){var l=Cn(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=LM(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)}}}},vTe=Ze([Cn,YY,QY,ZY,JY,yTe,Vb,xTe,eZ,Kye],(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,b;if(p&&p.length>0?b=p:b=d?.slice(f,g+1),b!=null)return UTe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:b,chartBaseValue:u,bandSize:l})}}),_Te=["id"],wTe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Hh(){return Hh=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},Hh.apply(null,arguments)}function tZ(t,e){if(t==null)return{};var n,r,i=STe(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 STe(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){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?G6(Object(n),!0).forEach(function(r){MTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):G6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function MTe(t,e,n){return(e=ETe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ETe(t){var e=ATe(t,"string");return typeof e=="symbol"?e:e+""}function ATe(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 Bw(t,e){return t&&t!=="none"?t:e}var TTe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:s}=t;return[{inactive:s,dataKey:e,type:a,color:Bw(r,i),value:Dd(n,e),payload:t}]},NTe=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:Dd(s,e),hide:l,type:u,color:Bw(r,a),unit:c}};return S.createElement(XM,{tooltipEntrySettings:d})});function CTe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:s}=r,l=Ia(r);return S.createElement(NY,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:s,baseProps:l,needClip:i,clipPathId:e})}function kTe(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(oO,{value:e?i:void 0},n)}function W6(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=tZ(a,_Te),p=Ia(g),b=da(g);return S.createElement(S.Fragment,null,e?.length>1&&S.createElement(Or,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},S.createElement(fp,Hh({},b,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:s,stroke:"none",className:"recharts-area-area"})),c!=="none"&&S.createElement(fp,Hh({},p,{className:"recharts-area-curve",layout:s,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&S.createElement(fp,Hh({},p,{className:"recharts-area-curve",layout:s,type:l,connectNulls:u,fill:"none",points:n}))),S.createElement(CTe,{points:e,props:g,clipPathId:i}))}function PTe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,s=r[r.length-1].y;if(!er(a)||!er(s))return null;var l=e*Math.abs(a-s),c=Math.max(...r.map(u=>u.x||0));return Ot(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Ot(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 jTe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,s=r[r.length-1].x;if(!er(a)||!er(s))return null;var l=e*Math.abs(a-s),c=Math.max(...r.map(u=>u.y||0));return Ot(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Ot(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 RTe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?S.createElement(PTe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):S.createElement(jTe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function DTe(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,b=S.useMemo(()=>({points:s,baseLine:l}),[s,l]),v=ug(b,"recharts-area-"),x=hge(),[y,E]=S.useState(!1),w=!y,A=S.useCallback(()=>{typeof p=="function"&&p(),E(!1)},[p]),T=S.useCallback(()=>{typeof g=="function"&&g(),E(!0)},[g]);if(x==null)return null;var C=i.current,N=a.current;return S.createElement(kTe,{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((I,q)=>{var R=Math.floor(q*k);if(C[R]){var W=C[R];return op(op({},I),{},{x:Wn(W.x,I.x,O),y:Wn(W.y,I.y,O)})}return I}),z;return Ot(l)?z=Wn(N,l,O):Tr(l)||ss(l)?z=Wn(N,0,O):z=l.map((I,q)=>{var R=Math.floor(q*k);if(Array.isArray(N)&&N[R]){var W=N[R];return op(op({},I),{},{x:Wn(W.x,I.x,O),y:Wn(W.y,I.y,O)})}return I}),O>0&&(i.current=j,a.current=z),S.createElement(W6,{points:j,baseLine:z,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(RTe,{alpha:O,points:s,baseLine:l,layout:x,strokeWidth:r.strokeWidth}))),S.createElement(Or,{clipPath:"url(#animationClipPath-".concat(n,")")},S.createElement(W6,{points:s,baseLine:l,needClip:e,clipPathId:n,props:r})))}),S.createElement(WM,{label:r.label}))}function OTe(t){var{needClip:e,clipPathId:n,props:r}=t,i=S.useRef(null),a=S.useRef();return S.createElement(DTe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class LTe 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:b}=this.props;if(e)return null;var v=In("recharts-area",i),x=g,{r:y,strokeWidth:E}=WY(n),w=dO(n),A=y*2+E,T=l?"url(#clipPath-".concat(w?"":"dots-").concat(x,")"):void 0;return S.createElement(Ma,{zIndex:b},S.createElement(Or,{className:v},l&&S.createElement("defs",null,S.createElement(bO,{clipPathId:x,xAxisId:c,yAxisId:u}),!w&&S.createElement("clipPath",{id:"clipPath-dots-".concat(x)},S.createElement("rect",{x:s-A/2,y:a-A/2,width:d+A,height:f+A}))),S.createElement(OTe,{needClip:l,clipPathId:x,props:this.props})),S.createElement(tP,{points:r,mainColor:Bw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(p)&&S.createElement(tP,{points:p,mainColor:Bw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var nZ={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 ITe(t){var e,n=Lr(t,nZ),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:s,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:g,legendType:p,stroke:b,xAxisId:v,yAxisId:x}=n,y=tZ(n,wTe),E=Ef(),w=ZX(),{needClip:A}=JM(v,x),T=Ti(),{points:C,isRange:N,baseLine:O}=(e=Rt(R=>vTe(R,v,x,T,t.id)))!==null&&e!==void 0?e:{},k=QM();if(E!=="horizontal"&&E!=="vertical"||k==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:j,width:z,x:I,y:q}=k;return!C||!C.length?null:S.createElement(LTe,Hh({},y,{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:b,width:z,left:I,top:q,xAxisId:v,yAxisId:x}))}var FTe=(t,e,n,r,i)=>{var a=n??e;if(Ot(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 UTe(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,b=i&&i.length,v=FTe(a,s,n,l,c),x=a==="horizontal",y=!1,E=u.map((A,T)=>{var C;b?C=i[d+T]:(C=Jn(A,r),Array.isArray(C)?y=!0:C=[v,C]);var N=C[1]==null||b&&!e&&Jn(A,r)==null;return x?{x:lw({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:lw({axis:c,ticks:g,bandSize:p,entry:A,index:T}),value:C,payload:A}}),w;return b||y?w=E.map(A=>{var T=Array.isArray(A.value)?A.value[0]:null;return x?{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=x?c.scale(v):l.scale(v),{points:E,baseLine:w,isRange:y}}function zTe(t){var e=Lr(t,nZ),n=Ti();return S.createElement(YM,{id:e.id,type:"area"},r=>S.createElement(S.Fragment,null,S.createElement(gO,{legendPayload:TTe(e)}),S.createElement(NTe,{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(xO,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:Aq(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),S.createElement(ITe,Hh({},e,{id:r}))))}var rZ=S.memo(zTe,ry);rZ.displayName="Area";var BTe=["domain","range"],HTe=["domain","range"];function q6(t,e){if(t==null)return{};var n,r,i=$Te(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 $Te(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 K6(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 iZ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=q6(t,BTe),{domain:a,range:s}=e,l=q6(e,HTe);return!K6(n,a)||!K6(r,s)?!1:ry(i,l)}var VTe=["dangerouslySetInnerHTML","ticks"],GTe=["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 X6(t,e){if(t==null)return{};var n,r,i=WTe(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 WTe(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 qTe(t){var e=xr(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?e(BMe(t)):n.current!==t&&e(HMe({prev:n.current,next:t})),n.current=t},[t,e]),S.useLayoutEffect(()=>()=>{n.current&&(e($Me(n.current)),n.current=null)},[e]),null}var KTe=t=>{var{xAxisId:e,className:n}=t,r=Rt(VR),i=Ti(),a="xAxis",s=Rt(x=>Md(x,a,e,i)),l=Rt(x=>CX(x,a,e,i)),c=Rt(x=>EX(x,e)),u=Rt(x=>Gve(x,e)),d=Rt(x=>sX(x,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:g}=t,p=X6(t,VTe),{id:b}=d,v=X6(d,GTe);return S.createElement(vO,rP({},p,v,{scale:s,x:u.x,y:u.y,width:c.width,height:c.height,className:In("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:l,axisType:a}))},XTe={allowDataOverflow:Ii.allowDataOverflow,allowDecimals:Ii.allowDecimals,allowDuplicatedCategory:Ii.allowDuplicatedCategory,angle:Ii.angle,axisLine:Rc.axisLine,height:Ii.height,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,xAxisId:0},YTe=t=>{var e=Lr(t,XTe);return S.createElement(S.Fragment,null,S.createElement(qTe,{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(KTe,e))},Hw=S.memo(YTe,iZ);Hw.displayName="XAxis";var ZTe=["dangerouslySetInnerHTML","ticks"],QTe=["id"];function iP(){return iP=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},iP.apply(null,arguments)}function Y6(t,e){if(t==null)return{};var n,r,i=JTe(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 JTe(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 eNe(t){var e=xr(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?e(VMe(t)):n.current!==t&&e(GMe({prev:n.current,next:t})),n.current=t},[t,e]),S.useLayoutEffect(()=>()=>{n.current&&(e(WMe(n.current)),n.current=null)},[e]),null}var tNe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=S.useRef(null),s=S.useRef(null),l=Rt(VR),c=Ti(),u=xr(),d="yAxis",f=Rt(T=>Md(T,d,e,c)),g=Rt(T=>AX(T,e)),p=Rt(T=>qve(T,e)),b=Rt(T=>CX(T,d,e,c)),v=Rt(T=>oX(T,e));if(S.useLayoutEffect(()=>{if(!(r!=="auto"||!g||sO(i)||S.isValidElement(i)||v==null)){var T=a.current;if(T){var C=T.getCalculatedWidth();Math.round(g.width)!==Math.round(C)&&u(qMe({id:e,width:C}))}}},[b,g,u,i,e,r,v]),g==null||p==null||v==null)return null;var{dangerouslySetInnerHTML:x,ticks:y}=t,E=Y6(t,ZTe),{id:w}=v,A=Y6(v,QTe);return S.createElement(vO,iP({},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:In("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:b,axisType:d}))},nNe={allowDataOverflow:Fi.allowDataOverflow,allowDecimals:Fi.allowDecimals,allowDuplicatedCategory:Fi.allowDuplicatedCategory,angle:Fi.angle,axisLine:Rc.axisLine,hide:!1,includeHidden:Fi.includeHidden,interval:Fi.interval,minTickGap:Fi.minTickGap,mirror:Fi.mirror,orientation:Fi.orientation,padding:Fi.padding,reversed:Fi.reversed,scale:Fi.scale,tick:Fi.tick,tickCount:Fi.tickCount,tickLine:Rc.tickLine,tickSize:Rc.tickSize,type:Fi.type,width:Fi.width,yAxisId:0},rNe=t=>{var e=Lr(t,nNe);return S.createElement(S.Fragment,null,S.createElement(eNe,{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(tNe,e))},$w=S.memo(rNe,iZ);$w.displayName="YAxis";var iNe=(t,e)=>e,wO=Ze([iNe,Cn,iX,Ci,GX,tu,l1e,Ai],p1e),SO=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)}},aZ=bo("mouseClick"),sZ=Lb();sZ.startListening({actionCreator:aZ,effect:(t,e)=>{var n=t.payload,r=wO(e.getState(),SO(n));r?.activeIndex!=null&&e.dispatch(o_e({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var aP=bo("mouseMove"),oZ=Lb(),qv=null;oZ.startListening({actionCreator:aP,effect:(t,e)=>{var n=t.payload;qv!==null&&cancelAnimationFrame(qv);var r=SO(n);qv=requestAnimationFrame(()=>{var i=e.getState(),a=XD(i,i.tooltip.settings.shared);if(a==="axis"){var s=wO(i,r);s?.activeIndex!=null?e.dispatch(IX({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate})):e.dispatch(LX())}qv=null})}});var Z6={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},lZ=ls({name:"rootProps",initialState:Z6,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:Z6.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}}}),aNe=lZ.reducer,{updateOptions:sNe}=lZ.actions,cZ=ls({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:oNe}=cZ.actions,lNe=cZ.reducer,uZ=bo("keyDown"),dZ=bo("focus"),MO=Lb();MO.startListening({actionCreator:uZ,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=YD(i,bg(n),Yb(n),ey(n)),l=s==null?-1:Number(s);if(!(!Number.isFinite(l)||l<0)){var c=tu(n);if(a==="Enter"){var u=kw(n,"axis","hover",String(i.index));e.dispatch(X3({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=Zve(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 b=kw(n,"axis","hover",String(p));e.dispatch(X3({active:!0,activeIndex:p.toString(),activeDataKey:void 0,activeCoordinate:b}))}}}}}});MO.startListening({actionCreator:dZ,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=kw(n,"axis","hover",String(a));e.dispatch(X3({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:s}))}}}});var Xs=bo("externalEvent"),hZ=Lb(),CN=new Map;hZ.startListening({actionCreator:Xs,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=CN.get(i);a!==void 0&&cancelAnimationFrame(a);var s=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:q_e(l),activeDataKey:tO(l),activeIndex:Ed(l),activeLabel:KX(l),activeTooltipIndex:Ed(l),isTooltipActive:K_e(l)};n(c,r)}finally{CN.delete(i)}});CN.set(i,s)}}});var cNe=Ze([xg],t=>t.tooltipItemPayloads),uNe=Ze([cNe,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}}}),fZ=bo("touchMove"),mZ=Lb();mZ.startListening({actionCreator:fZ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=XD(r,r.tooltip.settings.shared);if(i==="axis"){var a=wO(r,SO({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(IX({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(Nq),d=(s=c.getAttribute(Cq))!==null&&s!==void 0?s:void 0,f=uNe(e.getState(),u,d);e.dispatch(OX({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var dNe=XW({brush:O2e,cartesianAxis:KMe,chartData:W1e,errorBars:fEe,graphicalItems:tMe,layout:ype,legend:Tge,options:B1e,polarAxis:gSe,polarOptions:lNe,referenceElements:W2e,rootProps:aNe,tooltip:l_e,zIndex:C1e}),hNe=function(e){return Vme({reducer:dNe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([sZ.middleware,oZ.middleware,MO.middleware,hZ.middleware,mZ.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(uq({type:"raf"}))},devTools:lg.devToolsEnabled})};function pZ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=Ti(),a=S.useRef(null);if(i)return n;a.current==null&&(a.current=hNe(e));var s=OR;return S.createElement(IEe,{context:s,store:a.current},n)}function fNe(t){var{layout:e,margin:n}=t,r=xr(),i=Ti();return S.useEffect(()=>{i||(r(gpe(e)),r(ppe(n)))},[r,i,e,n]),null}var gZ=S.memo(fNe,ry);function xZ(t){var e=xr();return S.useEffect(()=>{e(sNe(t))},[e,t]),null}function Q6(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=EY("".concat(r).concat(e)),a=xr();return S.useLayoutEffect(()=>(a(T1e({zIndex:e,elementId:i,isPanorama:n})),()=>{a(N1e({zIndex:e,isPanorama:n}))}),[a,e,i,n]),S.createElement("g",{tabIndex:-1,id:i})}function J6(t){var{children:e,isPanorama:n}=t,r=Rt(x1e);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(Q6,{key:s,zIndex:s,isPanorama:n})),e,a.map(s=>S.createElement(Q6,{key:s,zIndex:s,isPanorama:n})))}var mNe=["children"];function pNe(t,e){if(t==null)return{};var n,r,i=gNe(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 gNe(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 Vw(){return Vw=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},Vw.apply(null,arguments)}var xNe={width:"100%",height:"100%",display:"block"},bNe=S.forwardRef((t,e)=>{var n=WR(),r=qR(),i=Gq();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(ER,Vw({},s,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:xNe,ref:e}),a)}),yNe=t=>{var{children:e}=t,n=Rt(SM);if(!n)return null;var{width:r,height:i,y:a,x:s}=n;return S.createElement(ER,{width:r,height:i,x:s,y:a},e)},eH=S.forwardRef((t,e)=>{var{children:n}=t,r=pNe(t,mNe),i=Ti();return i?S.createElement(yNe,null,S.createElement(J6,{isPanorama:!0},n)):S.createElement(bNe,Vw({ref:e},r),S.createElement(J6,{isPanorama:!1},n))});function vNe(){var t=xr(),[e,n]=S.useState(null),r=Rt(Lpe);return S.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;er(a)&&a!==r&&t(bpe(a))}},[e,t,r]),n}function tH(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 _Ne(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tH(Object(n),!0).forEach(function(r){wNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wNe(t,e,n){return(e=SNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function SNe(t){var e=MNe(t,"string");return typeof e=="symbol"?e:e+""}function MNe(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 ENe=()=>(twe(),null);function Gw(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var ANe=S.forwardRef((t,e)=>{var n,r,i=S.useRef(null),[a,s]=S.useState({containerWidth:Gw((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:Gw((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=b=>{var{width:v,height:x}=b[0].contentRect;l(v,x)},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(MM,{width:a.containerWidth,height:a.containerHeight}),S.createElement("div",ff({ref:c},t)))}),TNe=S.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=S.useState({containerWidth:Gw(n),containerHeight:Gw(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(MM,{width:i.containerWidth,height:i.containerHeight}),S.createElement("div",ff({ref:l},t)))}),NNe=S.forwardRef((t,e)=>{var{width:n,height:r}=t;return S.createElement(S.Fragment,null,S.createElement(MM,{width:n,height:r}),S.createElement("div",ff({ref:e},t)))}),CNe=S.forwardRef((t,e)=>{var{width:n,height:r}=t;return $c(n)||$c(r)?S.createElement(TNe,ff({},t,{ref:e})):S.createElement(NNe,ff({},t,{ref:e}))});function kNe(t){return t===!0?ANe:CNe}var PNe=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:b,onTouchStart:v,style:x,width:y,responsive:E,dispatchTouchEvents:w=!0}=t,A=S.useRef(null),T=xr(),[C,N]=S.useState(null),[O,k]=S.useState(null),j=vNe(),z=GR(),I=z?.width>0?z.width:y,q=z?.height>0?z.height:i,R=S.useCallback(he=>{j(he),typeof e=="function"&&e(he),N(he),k(he),he!=null&&(A.current=he)},[j,e,N,k]),W=S.useCallback(he=>{T(aZ(he)),T(Xs({handler:a,reactEvent:he}))},[T,a]),K=S.useCallback(he=>{T(aP(he)),T(Xs({handler:u,reactEvent:he}))},[T,u]),G=S.useCallback(he=>{T(LX()),T(Xs({handler:d,reactEvent:he}))},[T,d]),J=S.useCallback(he=>{T(aP(he)),T(Xs({handler:f,reactEvent:he}))},[T,f]),ee=S.useCallback(()=>{T(dZ())},[T]),Z=S.useCallback(he=>{T(uZ(he.key))},[T]),F=S.useCallback(he=>{T(Xs({handler:s,reactEvent:he}))},[T,s]),V=S.useCallback(he=>{T(Xs({handler:l,reactEvent:he}))},[T,l]),ne=S.useCallback(he=>{T(Xs({handler:c,reactEvent:he}))},[T,c]),le=S.useCallback(he=>{T(Xs({handler:g,reactEvent:he}))},[T,g]),oe=S.useCallback(he=>{T(Xs({handler:v,reactEvent:he}))},[T,v]),pe=S.useCallback(he=>{w&&T(fZ(he)),T(Xs({handler:b,reactEvent:he}))},[T,w,b]),Q=S.useCallback(he=>{T(Xs({handler:p,reactEvent:he}))},[T,p]),Ee=kNe(E);return S.createElement(nY.Provider,{value:C},S.createElement(uW.Provider,{value:O},S.createElement(Ee,{width:I??x?.width,height:q??x?.height,className:In("recharts-wrapper",r),style:_Ne({position:"relative",cursor:"default",width:I,height:q},x),onClick:W,onContextMenu:F,onDoubleClick:V,onFocus:ee,onKeyDown:Z,onMouseDown:ne,onMouseEnter:K,onMouseLeave:G,onMouseMove:J,onMouseUp:le,onTouchEnd:Q,onTouchMove:pe,onTouchStart:oe,ref:R},S.createElement(ENe,null),n)))}),jNe=["width","height","responsive","children","className","style","compact","title","desc"];function RNe(t,e){if(t==null)return{};var n,r,i=DNe(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 DNe(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 bZ=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=RNe(t,jNe),g=Ia(f);return c?S.createElement(S.Fragment,null,S.createElement(MM,{width:n,height:r}),S.createElement(eH,{otherAttributes:g,title:u,desc:d},a)):S.createElement(PNe,{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(eH,{otherAttributes:g,title:u,desc:d,ref:e},S.createElement(q2e,null,a)))});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)}var ONe={top:5,right:5,bottom:5,left:5},LNe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:ONe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},EO=S.forwardRef(function(e,n){var r,i=Lr(e.categoricalChartProps,LNe),{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(pZ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},S.createElement(OY,{chartData:u.data}),S.createElement(gZ,{layout:i.layout,margin:i.margin}),S.createElement(xZ,{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(bZ,sP({},i,{ref:n})))}),INe=["axis"],FNe=S.forwardRef((t,e)=>S.createElement(EO,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:INe,tooltipPayloadSearcher:VM,categoricalChartProps:t,ref:e})),UNe=["axis","item"],zNe=S.forwardRef((t,e)=>S.createElement(EO,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:UNe,tooltipPayloadSearcher:VM,categoricalChartProps:t,ref:e}));function BNe(t){var e=xr();return S.useEffect(()=>{e(oNe(t))},[e,t]),null}var HNe=["layout"];function oP(){return oP=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},oP.apply(null,arguments)}function $Ne(t,e){if(t==null)return{};var n,r,i=VNe(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 VNe(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 GNe={top:5,right:5,bottom:5,left:5},yZ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:GNe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},WNe=S.forwardRef(function(e,n){var r,i=Lr(e.categoricalChartProps,yZ),{layout:a}=i,s=$Ne(i,HNe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return S.createElement(pZ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},S.createElement(OY,{chartData:i.data}),S.createElement(gZ,{layout:a,margin:i.margin}),S.createElement(xZ,{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(BNe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),S.createElement(bZ,oP({},s,{ref:n})))});function nH(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 rH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nH(Object(n),!0).forEach(function(r){qNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qNe(t,e,n){return(e=KNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function KNe(t){var e=XNe(t,"string");return typeof e=="symbol"?e:e+""}function XNe(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 YNe=["item"],ZNe=rH(rH({},yZ),{},{layout:"centric",startAngle:0,endAngle:360}),QNe=S.forwardRef((t,e)=>{var n=Lr(t,ZNe);return S.createElement(WNe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:YNe,tooltipPayloadSearcher:VM,categoricalChartProps:n,ref:e})}),JNe=["axis"],eCe=S.forwardRef((t,e)=>S.createElement(EO,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:JNe,tooltipPayloadSearcher:VM,categoricalChartProps:t,ref:e}));const iH=[{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 tCe({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),b=u==="dark";S.useEffect(()=>{if(!t)return;const V=ne=>{ne.key==="Escape"&&e()};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[t,e]);const v=iH.find(V=>V.value===d)?.hours||24,{data:x,isLoading:y,error:E}=pt({queryKey:["ams-history",n,i,v],queryFn:()=>_e.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const w=x?.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,z=V=>{const ne=V.filter(he=>he!=null);if(ne.length<4)return"stable";const le=ne.slice(0,Math.floor(ne.length/4)),oe=ne.slice(-Math.floor(ne.length/4)),pe=le.reduce((he,ue)=>he+ue,0)/le.length,Ee=oe.reduce((he,ue)=>he+ue,0)/oe.length-pe;return Math.abs(Ee)<2?"stable":Ee>0?"up":"down"},I=z(w.map(V=>V.humidity)),q=z(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(Z9,{className:"w-4 h-4 text-green-400"}):o.jsx(n3,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),W=V=>V==null?"#9ca3af":V<=A?"#22a352":V<=T?"#d4a017":"#c62828",K=V=>V==null?"#9ca3af":V<=C?"#22a352":V<=N?"#d4a017":"#c62828",G=b?"#2d2d2d":"#ffffff",J=b?"#1d1d1d":"#f3f4f6",ee=b?"#3d3d3d":"#e5e7eb",Z=b?"#ffffff":"#111827",F=b?"#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:G},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:Z},children:[a," ",c("common.history","History")]}),o.jsx("p",{className:"text-sm",style:{color:F},children:r})]}),o.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:F},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:F}:void 0,children:[o.jsx(dR,{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:F}:void 0,children:[o.jsx(sM,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),o.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:J},children:iH.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:F}: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:F},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(k)},children:k!=null?`${k}%`:"—"}),o.jsx(R,{trend:I})]})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:F},children:c("common.average","Average")}),o.jsx("p",{className:"text-2xl font-bold",style:{color:Z},children:x?.avg_humidity!=null?`${x.avg_humidity}%`:"—"})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:F},children:c("common.min","Min")}),o.jsx("p",{className:"text-2xl font-bold text-green-500",children:x?.min_humidity!=null?`${x.min_humidity}%`:"—"})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:F},children:c("common.max","Max")}),o.jsx("p",{className:"text-2xl font-bold text-red-500",children:x?.max_humidity!=null?`${x.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:F},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:K(j)},children:j!=null?`${j}°C`:"—"}),o.jsx(R,{trend:q})]})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:F},children:c("common.average","Average")}),o.jsx("p",{className:"text-2xl font-bold",style:{color:Z},children:x?.avg_temperature!=null?`${x.avg_temperature}°C`:"—"})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:F},children:c("common.min","Min")}),o.jsx("p",{className:"text-2xl font-bold text-blue-500",children:x?.min_temperature!=null?`${x.min_temperature}°C`:"—"})]}),o.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:[o.jsx("p",{className:"text-xs",style:{color:F},children:c("common.max","Max")}),o.jsx("p",{className:"text-2xl font-bold text-red-500",children:x?.max_temperature!=null?`${x.max_temperature}°C`:"—"})]})]})}),o.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:J},children:y?o.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:F},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:F},children:c("common.noData","No data available for this time range")}):o.jsx(y1,{width:"100%",height:300,children:o.jsxs(FNe,{data:w,children:[o.jsx(zw,{strokeDasharray:"3 3",stroke:b?"#3d3d3d":"#e5e7eb"}),o.jsx(Hw,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:V=>{const ne=new Date(V);return v>24?ne.toLocaleDateString([],{day:"numeric",month:"short"}):ne.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12}}),o.jsx($w,{stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:g==="humidity"?[0,100]:["auto","auto"],tickFormatter:V=>g==="humidity"?`${V}%`:`${V}°C`}),o.jsx(_1,{contentStyle:{backgroundColor:b?"#2d2d2d":"#ffffff",border:`1px solid ${b?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:b?"#fff":"#000"},labelFormatter:V=>new Date(V).toLocaleString(),formatter:V=>[g==="humidity"?`${V}%`:`${V}°C`,g==="humidity"?"Humidity":"Temperature"]}),o.jsx(YR,{}),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(XY,{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:F},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function kN({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),b=()=>{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 x=()=>{n||(p.current&&clearTimeout(p.current),p.current=setTimeout(()=>s(!0),80))},y=()=>{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:x,onMouseLeave:y,children:[e,a&&o.jsxs("div",{ref:g,className:`
  46. absolute left-1/2 -translate-x-1/2 z-50
  47. ${l==="top"?"bottom-full mb-2":"top-full mt-2"}
  48. animate-in fade-in-0 zoom-in-95 duration-150
  49. `,style:{maxWidth:"calc(100vw - 24px)"},children:[o.jsxs("div",{className:`
  50. w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
  51. rounded-lg shadow-xl overflow-hidden
  52. backdrop-blur-sm
  53. `,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:`
  54. absolute inset-0 flex items-center justify-center
  55. font-semibold text-sm tracking-wide
  56. ${w(A)?"text-black/80":"text-white/90"}
  57. `,children:t.colorName}),o.jsx("div",{className:`
  58. absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
  59. ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
  60. `,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(dR,{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(),b()},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(go,{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.hasUnlinkedSpools!==!1&&i.onLinkSpool?.(t.trayUuid)},disabled:i.hasUnlinkedSpools===!1,className:`w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors ${i.hasUnlinkedSpools===!1?"bg-bambu-gray/10 text-bambu-gray cursor-not-allowed":"bg-bambu-green/20 hover:bg-bambu-green/30 text-bambu-green"}`,title:i.hasUnlinkedSpools===!1?"No unlinked spools available":"Link this spool to a Spoolman spool",children:[o.jsx(Tp,{className:"w-3.5 h-3.5"}),"Link to Spoolman"]})]})]})]}),o.jsx("div",{className:`
  61. absolute left-1/2 -translate-x-1/2 w-0 h-0
  62. border-l-[6px] border-l-transparent
  63. border-r-[6px] border-r-transparent
  64. ${l==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
  65. `})]})]})}function aH({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:`
  66. absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
  67. animate-in fade-in-0 zoom-in-95 duration-150
  68. `,children:[o.jsx("div",{className:`
  69. px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary
  70. rounded-md shadow-lg text-xs text-bambu-gray whitespace-nowrap
  71. `,children:"Empty slot"}),o.jsx("div",{className:`
  72. absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
  73. border-l-[5px] border-l-transparent
  74. border-r-[5px] border-r-transparent
  75. border-t-[5px] border-t-bambu-dark-tertiary
  76. `})]})]})}function nCe({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const i=dn(),[a,s]=S.useState(null),{data:l,isLoading:c}=pt({queryKey:["unlinked-spools"],queryFn:_e.getUnlinkedSpools,enabled:t}),u=_t({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(xt,{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(go,{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(Pe,{variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(Pe,{onClick:d,disabled:!a||u.isPending,children:u.isPending?o.jsxs(o.Fragment,{children:[o.jsx(xt,{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 sH=({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"})]}),oH={"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"},rCe={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 PN(t){if(!t)return null;if(oH[t])return oH[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return rCe[n]||null}function jN(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 RN(t){return(t??.02).toFixed(3)}function lH({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 cH({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 iCe({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 aCe({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 sCe({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 oCe({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 lCe({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 DN({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 uH({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=cH:a<=l?d=iCe:d=aCe,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 dH({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=sCe):t<=s?(l="#d4a017",c="Fair",u=oCe):(l="#c62828",c="Bad",u=lCe),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 Au(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 hH(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function cCe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function uCe(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 dCe(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 hCe(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 fCe({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(bd,{className:"w-8 h-8 text-bambu-gray"})]}):o.jsx(bd,{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 mCe({printers:t}){const e=dn(),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 fH(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 mH({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:a,spoolmanEnabled:s=!1,hasUnlinkedSpools:l=!1}){const c=dn(),u=Eb(),{showToast:d}=vr(),[f,g]=S.useState(!1),[p,b]=S.useState(!1),[v,x]=S.useState(!0),[y,E]=S.useState(!1),[w,A]=S.useState(!1),[T,C]=S.useState(!1),[N,O]=S.useState(!1),[k,j]=S.useState(!1),[z,I]=S.useState(!1),[q,R]=S.useState(!1),[W,K]=S.useState(!1),[G,J]=S.useState(!1),[ee,Z]=S.useState(!1),[F,V]=S.useState(null),[ne,le]=S.useState(null),[oe,pe]=S.useState(!1),{data:Q}=pt({queryKey:["printerStatus",t.id],queryFn:()=>_e.getPrinterStatus(t.id),refetchInterval:3e4}),{data:Ee}=pt({queryKey:["firmwareUpdate",t.id],queryFn:()=>m1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3}),he=S.useMemo(()=>{const bt=new Set;if(Q?.ams)for(const Ht of Q.ams)for(const an of Ht.tray||[])an.tray_info_idx&&bt.add(an.tray_info_idx);return Q?.vt_tray?.tray_info_idx&&bt.add(Q.vt_tray.tray_info_idx),Array.from(bt)},[Q?.ams,Q?.vt_tray]),{data:ue}=pt({queryKey:["filamentInfo",he],queryFn:()=>_e.getFilamentInfo(he),enabled:he.length>0,staleTime:300*1e3}),[Ae,fe]=S.useState(null);S.useEffect(()=>{Q?.wifi_signal!=null&&fe(Q.wifi_signal)},[Q?.wifi_signal]);const at=Q?.wifi_signal??Ae,B=S.useRef(void 0);S.useEffect(()=>{Q?.connected!==void 0&&(B.current=Q.connected)},[Q?.connected]);const $=Q?.connected??B.current,ie=S.useRef({});S.useEffect(()=>{Q?.ams_extruder_map&&Object.keys(Q.ams_extruder_map).length>0&&(ie.current=Q.ams_extruder_map)},[Q?.ams_extruder_map]);const H=Q?.ams_extruder_map&&Object.keys(Q.ams_extruder_map).length>0?Q.ams_extruder_map:ie.current,Y=S.useRef([]);S.useEffect(()=>{Q?.ams&&Q.ams.length>0&&(Y.current=Q.ams)},[Q?.ams]);const se=Q?.ams&&Q.ams.length>0?Q.ams:Y.current,ve=S.useRef(255),Ne=Q?.tray_now;Ne!==void 0&&Ne!==255&&(ve.current=Ne);const Se=Ne===void 0||Ne===255?ve.current:Ne,{data:U}=pt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>_e.getSmartPlugByPrinter(t.id)}),{data:L}=pt({queryKey:["smartPlugStatus",U?.id],queryFn:()=>U?_e.getSmartPlugStatus(U.id):null,enabled:!!U,refetchInterval:1e4}),{data:te}=pt({queryKey:["queue",t.id,"pending"],queryFn:()=>_e.getQueue(t.id,"pending")}),ye=te?.length||0,{data:Me}=pt({queryKey:["archives",t.id,"last"],queryFn:()=>_e.getArchives(t.id,1,0),enabled:Q?.connected&&Q?.state!=="RUNNING"}),be=Me?.[0],qe=e&&$===!1,Ve=_t({mutationFn:bt=>_e.deletePrinter(t.id,bt.deleteArchives),onSuccess:()=>{c.invalidateQueries({queryKey:["printers"]}),c.invalidateQueries({queryKey:["archives"]})}}),We=_t({mutationFn:()=>_e.connectPrinter(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["printerStatus",t.id]})}}),lt=_t({mutationFn:bt=>U?_e.controlSmartPlug(U.id,bt):Promise.reject("No plug"),onSuccess:()=>{c.invalidateQueries({queryKey:["smartPlugStatus",U?.id]})}}),me=_t({mutationFn:bt=>U?_e.updateSmartPlug(U.id,{auto_off:bt}):Promise.reject("No plug"),onSuccess:()=>{c.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),c.invalidateQueries({queryKey:["smart-plugs"]})}}),ae=_t({mutationFn:()=>_e.stopPrint(t.id),onSuccess:()=>{d("Print stopped"),c.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:bt=>d(bt.message||"Failed to stop print","error")}),He=_t({mutationFn:()=>_e.pausePrint(t.id),onSuccess:()=>{d("Print paused"),c.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:bt=>d(bt.message||"Failed to pause print","error")}),Be=_t({mutationFn:()=>_e.resumePrint(t.id),onSuccess:()=>{d("Print resumed"),c.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:bt=>d(bt.message||"Failed to resume print","error")}),Ye=(Q?.state==="RUNNING"||Q?.state==="PAUSE"||Q?.state==="PAUSED")&&(Q?.printable_objects_count??0)>=2,{data:ot,refetch:ge}=pt({queryKey:["printableObjects",t.id],queryFn:()=>_e.getPrintableObjects(t.id),enabled:ee||Ye,refetchInterval:ee?5e3:Ye?3e4:!1}),nt=_t({mutationFn:bt=>_e.skipObjects(t.id,bt),onSuccess:bt=>{d(bt.message||"Objects skipped"),ge()},onError:bt=>d(bt.message||"Failed to skip objects","error")}),[xe,ze]=S.useState(null),Re=S.useRef(!1),we=S.useRef(null),Ke=S.useRef(!1),ft=_t({mutationFn:({amsId:bt,slotId:Ht})=>_e.refreshAmsSlot(t.id,bt,Ht),onMutate:({amsId:bt,slotId:Ht})=>{we.current&&clearTimeout(we.current),Re.current=!1,Ke.current=!1,ze({amsId:bt,slotId:Ht}),setTimeout(()=>{Ke.current=!0},2e3),we.current=setTimeout(()=>{ze(null)},3e4)},onSuccess:bt=>{d(bt.message||"RFID re-read initiated")},onError:bt=>{d(bt.message||"Failed to re-read RFID","error"),we.current&&clearTimeout(we.current),ze(null)}}),Et=S.useRef(null);S.useEffect(()=>{if(!xe)return;const bt=Q?.ams_status_main??0;return bt!==0&&(Re.current=!0,Et.current&&(clearTimeout(Et.current),Et.current=null)),Re.current&&bt===0&&(Ke.current?(we.current&&clearTimeout(we.current),ze(null)):Et.current||(Et.current=setTimeout(()=>{we.current&&clearTimeout(we.current),ze(null)},2e3))),()=>{Et.current&&clearTimeout(Et.current)}},[Q?.ams_status_main,xe]);const[wt,Qt]=S.useState(null);if(qe)return null;const Ft=()=>{switch(i){case 1:return"w-10 h-10";case 2:return"w-14 h-14";case 3:return"w-16 h-16";case 4:return"w-20 h-20";default:return"w-14 h-14"}},hn=()=>{switch(i){case 1:return"text-base truncate";case 2:return"text-lg";case 3:return"text-xl";case 4:return"text-2xl";default:return"text-lg"}},Hn=()=>{switch(i){case 1:return"mb-2";case 2:return"mb-4";case 3:return"mb-5";case 4:return"mb-6";default:return"mb-4"}};return o.jsxs(At,{className:"relative",children:[o.jsxs(Tt,{className:i>=3?"p-5":"",children:[o.jsxs("div",{className:Hn(),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:dCe(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${Ft()}`}),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 ${hn()}`,children:t.name}),r==="compact"&&o.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${Q?.connected?"bg-bambu-green":"bg-red-500"}`,title:Q?.connected?"Connected":"Offline"})]}),o.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&Q?.nozzles&&Q.nozzles[0]?.nozzle_diameter&&o.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:Q.nozzles[0].nozzle_type||"Nozzle",children:["• ",Q.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(Pe,{variant:"ghost",size:"sm",onClick:()=>g(!f),children:o.jsx(o0,{className:"w-4 h-4"})}),f&&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:()=>{E(!0),g(!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:()=>{We.mutate(),g(!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:()=>{C(!0),g(!1)},children:[o.jsx(Y9,{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:()=>{b(!0),g(!1)},children:[o.jsx(Rn,{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 ${Q?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[Q?.connected?o.jsx(Cb,{className:"w-3 h-3"}):o.jsx(J9,{className:"w-3 h-3"}),Q?.connected?"Connected":"Offline"]}),Q?.connected&&at!=null&&o.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${at>=-50||at>=-60?"bg-bambu-green/20 text-bambu-green":at>=-70?"bg-amber-500/20 text-amber-600":at>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${at} dBm - ${hCe(at).label}`,children:[o.jsx(Kue,{className:"w-3 h-3"}),at,"dBm"]}),Q?.connected&&(()=>{const bt=Q.hms_errors?ahe(Q.hms_errors):[];return o.jsxs("button",{onClick:()=>I(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${bt.length>0?bt.some(Ht=>Ht.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(qn,{className:"w-3 h-3"}),bt.length>0?bt.length:"OK"]})})(),n&&o.jsxs("button",{onClick:()=>u("/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(_d,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),ye>0&&o.jsxs("button",{onClick:()=>u("/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:`${ye} print${ye>1?"s":""} in queue`,children:[o.jsx(vd,{className:"w-3 h-3"}),ye]}),Ee?.update_available&&o.jsxs("button",{onClick:()=>pe(!0),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-orange-500/20 text-orange-400 hover:opacity-80 transition-opacity",title:`Firmware update available: ${Ee.current_version} → ${Ee.latest_version}`,children:[o.jsx(Wi,{className:"w-3 h-3"}),"Update"]})]})]}),p&&o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:o.jsx(At,{className:"w-full max-w-md mx-4",children:o.jsxs(Tt,{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(qn,{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:v,onChange:bt=>x(bt.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:v?"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(Pe,{variant:"secondary",onClick:()=>{b(!1),x(!0)},children:"Cancel"}),o.jsx(Pe,{variant:"danger",onClick:()=>{Ve.mutate({deleteArchives:v}),b(!1),x(!0)},children:"Delete"})]})]})})}),Q?.connected&&o.jsxs(o.Fragment,{children:[r==="compact"?o.jsx("div",{className:"mt-2",children:Q.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:`${Q.progress||0}%`}})}),o.jsxs("span",{className:"text-xs text-white",children:[Math.round(Q.progress||0),"%"]})]}):o.jsx("p",{className:"text-xs text-bambu-gray",children:fH(Q.state,Q.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:()=>Z(!0),disabled:!(Q.state==="RUNNING"||Q.state==="PAUSE"||Q.state==="PAUSED")||(Q.printable_objects_count??0)<2,className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(Q.state==="RUNNING"||Q.state==="PAUSE"||Q.state==="PAUSED")&&(Q.printable_objects_count??0)>=2?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:Q.state==="RUNNING"||Q.state==="PAUSE"||Q.state==="PAUSED"?(Q.printable_objects_count??0)>=2?"Skip objects":"Skip objects (requires 2+ objects)":"Skip objects (only while printing)",children:[o.jsx(sH,{className:"w-4 h-4"}),ot&&ot.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:ot.skipped_count})]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx(fCe,{url:Q.state==="RUNNING"?Q.cover_url:null,printName:Q.state==="RUNNING"&&(Q.subtask_name||Q.current_print)||void 0}),o.jsx("div",{className:"flex-1 min-w-0",children:Q.current_print&&Q.state==="RUNNING"?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:Q.stg_cur_name||"Printing"}),o.jsx("p",{className:"text-white text-sm mb-2 truncate",children:Q.subtask_name||Q.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:`${Q.progress||0}%`}})}),o.jsxs("span",{className:"text-white",children:[Math.round(Q.progress||0),"%"]})]}),o.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[Q.remaining_time!=null&&Q.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"}),cCe(Q.remaining_time*60)]}),o.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",uCe(Q.remaining_time)]})]}),Q.layer_num!=null&&Q.total_layers!=null&&Q.total_layers>0&&o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(vd,{className:"w-3 h-3"}),Q.layer_num,"/",Q.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:fH(Q.state,Q.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:"—"})]}),be?o.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:be.print_name||be.filename,children:["Last: ",be.print_name||be.filename,be.completed_at&&o.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",new Date(be.completed_at).toLocaleDateString([],{month:"short",day:"numeric"})]})]}):o.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})]}),Q.state!=="RUNNING"&&o.jsx(che,{printerId:t.id})]}),Q.temperatures&&r==="expanded"&&(()=>{const bt=Q.temperatures.nozzle_heating||Q.temperatures.nozzle_2_heating||!1,Ht=Q.temperatures.bed_heating||!1,an=Q.temperatures.chamber_heating||!1;return o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[o.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[o.jsx(DN,{className:"w-4 h-4 mx-auto mb-1",color:"text-orange-400",isHeating:bt}),Q.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(Q.temperatures.nozzle||0),"° / ",Math.round(Q.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(Q.temperatures.nozzle||0),"°C"]})]})]}),o.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[o.jsx(DN,{className:"w-4 h-4 mx-auto mb-1",color:"text-blue-400",isHeating:Ht}),o.jsx("p",{className:"text-[10px] text-bambu-gray",children:"Bed"}),o.jsxs("p",{className:"text-xs text-white",children:[Math.round(Q.temperatures.bed||0),"°C"]})]}),Q.temperatures.chamber!==void 0?o.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[o.jsx(DN,{className:"w-4 h-4 mx-auto mb-1",color:"text-green-400",isHeating:an}),o.jsx("p",{className:"text-[10px] text-bambu-gray",children:"Chamber"}),o.jsxs("p",{className:"text-xs text-white",children:[Math.round(Q.temperatures.chamber||0),"°C"]})]}):o.jsx("div",{})]})})(),r==="expanded"&&(()=>{const bt=Q.state==="RUNNING",Ht=Q.state==="PAUSED"||Q.state==="PAUSE",an=bt||Ht,mt=ae.isPending||He.isPending||Be.isPending,Zt=Q.cooling_fan_speed,sn=Q.big_fan1_speed,Yt=Q.big_fan2_speed;return o.jsxs("div",{className:"mt-3",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Controls"}),o.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Zt&&Zt>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:"Part Cooling Fan",children:[o.jsx($9,{className:`w-3.5 h-3.5 ${Zt&&Zt>0?"text-cyan-400":"text-bambu-gray/50"}`}),o.jsxs("span",{className:`text-[10px] ${Zt&&Zt>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[Zt??0,"%"]})]}),o.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${sn&&sn>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:"Auxiliary Fan",children:[o.jsx(tW,{className:`w-3.5 h-3.5 ${sn&&sn>0?"text-blue-400":"text-bambu-gray/50"}`}),o.jsxs("span",{className:`text-[10px] ${sn&&sn>0?"text-blue-400":"text-bambu-gray/50"}`,children:[sn??0,"%"]})]}),o.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Yt&&Yt>0?"bg-green-500/10":"bg-bambu-dark"}`,title:"Chamber Fan",children:[o.jsx(joe,{className:`w-3.5 h-3.5 ${Yt&&Yt>0?"text-green-400":"text-bambu-gray/50"}`}),o.jsxs("span",{className:`text-[10px] ${Yt&&Yt>0?"text-green-400":"text-bambu-gray/50"}`,children:[Yt??0,"%"]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("button",{onClick:()=>R(!0),disabled:!an||mt,className:`
  77. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  78. transition-colors
  79. ${an?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
  80. `,title:"Stop print",children:[o.jsx(af,{className:"w-3 h-3"}),"Stop"]}),o.jsxs("button",{onClick:()=>Ht?J(!0):K(!0),disabled:!an||mt,className:`
  81. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  82. transition-colors
  83. ${an?Ht?"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"}
  84. `,title:Ht?"Resume print":"Pause print",children:[Ht?o.jsx(Hc,{className:"w-3 h-3"}):o.jsx(yR,{className:"w-3 h-3"}),Ht?"Resume":"Pause"]})]})]})]})})(),se&&se.length>0&&r==="expanded"&&(()=>{const bt=se.filter(mt=>mt.tray.length>1),Ht=se.filter(mt=>mt.tray.length===1),an=t.nozzle_count===2||Q?.temperatures?.nozzle_2!==void 0;return o.jsxs("div",{className:"mt-3",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",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:[bt.length>0&&o.jsx("div",{className:"grid grid-cols-2 gap-3",children:bt.map(mt=>{const Zt=H[String(mt.id)],sn=mt.id>=128?mt.id-128:mt.id,Yt=Zt!==void 0?Zt:sn,_n=Yt===1,wn=Yt===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:Au(mt.id,mt.tray.length)}),an&&(_n||wn)&&o.jsx(lH,{side:_n?"L":"R"})]}),(mt.humidity!=null||mt.temp!=null)&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[mt.humidity!=null&&o.jsx(uH,{humidity:mt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>V({amsId:mt.id,amsLabel:Au(mt.id,mt.tray.length),mode:"humidity"}),compact:!0}),mt.temp!=null&&o.jsx(dH,{temp:mt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>V({amsId:mt.id,amsLabel:Au(mt.id,mt.tray.length),mode:"temperature"}),compact:!0})]})]}),o.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(Ce=>{const ce=mt.tray[Ce]||mt.tray.find(De=>De.id===Ce),Ue=ce?.tray_type&&ce.remain>=0,Xe=!ce?.tray_type,rt=mt.id*4+Ce,et=Se===rt,gt=ce?.tray_info_idx?ue?.[ce.tray_info_idx]:null,re=ce?.tray_type?{vendor:ce.tray_uuid?"Bambu Lab":"Generic",profile:gt?.name||ce.tray_sub_brands||ce.tray_type,colorName:PN(ce.tray_id_name)||jN(ce.tray_color),colorHex:ce.tray_color||null,kFactor:RN(ce.k),fillLevel:Ue?ce.remain:null,trayUuid:ce.tray_uuid||null}:null,Te=xe?.amsId===mt.id&&xe?.slotId===Ce,Ie=o.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Xe?"opacity-50":""} ${et?"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:ce?.tray_color?`#${ce.tray_color}`:ce?.tray_type?"#333":"transparent",borderColor:Xe?"#666":"rgba(255,255,255,0.1)",borderStyle:Xe?"dashed":"solid"}}),o.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:ce?.tray_type||"—"}),o.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Ue&&ce?o.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${ce.remain}%`,backgroundColor:hH(ce.remain)}}):ce?.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:[Te&&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"})}),Q?.state!=="RUNNING"&&o.jsx("button",{onClick:De=>{De.stopPropagation(),Qt(wt?.amsId===mt.id&&wt?.slotId===Ce?null:{amsId:mt.id,slotId:Ce})},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"})}),Q?.state!=="RUNNING"&&wt?.amsId===mt.id&&wt?.slotId===Ce&&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:De=>{De.stopPropagation(),ft.mutate({amsId:mt.id,slotId:Ce}),Qt(null)},disabled:Te,children:[o.jsx(li,{className:`w-3 h-3 ${Te?"animate-spin":""}`}),"Re-read RFID"]})}),re?o.jsx(kN,{data:re,spoolman:{enabled:s,hasUnlinkedSpools:l,onLinkSpool:s&&re.trayUuid?De=>{le({trayUuid:De,trayInfo:{type:re.profile,color:re.colorHex||"",location:`${Au(mt.id,mt.tray.length)} Slot ${Ce+1}`}})}:void 0},children:Ie}):o.jsx(aH,{children:Ie})]},Ce)})})]},mt.id)})}),(Ht.length>0||Q.vt_tray&&Q.vt_tray.tray_type)&&o.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[Ht.map(mt=>{const Zt=H[String(mt.id)],sn=mt.id>=128?mt.id-128:mt.id,Yt=Zt!==void 0?Zt:sn,_n=Yt===1,wn=Yt===0,Ce=mt.tray[0],ce=Ce?.tray_type&&Ce.remain>=0,Ue=!Ce?.tray_type,Xe=mt.id*4+(Ce?.id??0),rt=Se===Xe,et=Ce?.tray_info_idx?ue?.[Ce.tray_info_idx]:null,gt=Ce?.tray_type?{vendor:Ce.tray_uuid?"Bambu Lab":"Generic",profile:et?.name||Ce.tray_sub_brands||Ce.tray_type,colorName:PN(Ce.tray_id_name)||jN(Ce.tray_color),colorHex:Ce.tray_color||null,kFactor:RN(Ce.k),fillLevel:ce?Ce.remain:null,trayUuid:Ce.tray_uuid||null}:null,re=Ce?.id??0,Te=xe?.amsId===mt.id&&xe?.slotId===re,Ie=o.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Ue?"opacity-50":""} ${rt?"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:Ce?.tray_color?`#${Ce.tray_color}`:Ce?.tray_type?"#333":"transparent",borderColor:Ue?"#666":"rgba(255,255,255,0.1)",borderStyle:Ue?"dashed":"solid"}}),o.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Ce?.tray_type||"—"}),o.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:ce?o.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Ce.remain}%`,backgroundColor:hH(Ce.remain)}}):Ce?.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:Au(mt.id,mt.tray.length)}),an&&(_n||wn)&&o.jsx(lH,{side:_n?"L":"R"})]}),o.jsxs("div",{className:"flex gap-1.5",children:[o.jsxs("div",{className:"relative group flex-1",children:[Te&&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"})}),Q?.state!=="RUNNING"&&o.jsx("button",{onClick:De=>{De.stopPropagation(),Qt(wt?.amsId===mt.id&&wt?.slotId===re?null:{amsId:mt.id,slotId:re})},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"})}),Q?.state!=="RUNNING"&&wt?.amsId===mt.id&&wt?.slotId===re&&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:De=>{De.stopPropagation(),ft.mutate({amsId:mt.id,slotId:re}),Qt(null)},disabled:Te,children:[o.jsx(li,{className:`w-3 h-3 ${Te?"animate-spin":""}`}),"Re-read RFID"]})}),gt?o.jsx(kN,{data:gt,spoolman:{enabled:s,hasUnlinkedSpools:l,onLinkSpool:s&&gt.trayUuid?De=>{le({trayUuid:De,trayInfo:{type:gt.profile,color:gt.colorHex||"",location:Au(mt.id,mt.tray.length)}})}:void 0},children:Ie}):o.jsx(aH,{children:Ie})]}),(mt.humidity!=null||mt.temp!=null)&&o.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[mt.temp!=null&&o.jsx(dH,{temp:mt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>V({amsId:mt.id,amsLabel:Au(mt.id,mt.tray.length),mode:"temperature"}),compact:!0}),mt.humidity!=null&&o.jsx(uH,{humidity:mt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>V({amsId:mt.id,amsLabel:Au(mt.id,mt.tray.length),mode:"humidity"}),compact:!0})]})]})]},mt.id)}),Q.vt_tray&&Q.vt_tray.tray_type&&(()=>{const mt=Q.vt_tray,Zt=Se===254,sn=mt.tray_info_idx?ue?.[mt.tray_info_idx]:null,Yt={vendor:mt.tray_uuid?"Bambu Lab":"Generic",profile:sn?.name||mt.tray_sub_brands||mt.tray_type||"Unknown",colorName:PN(mt.tray_id_name)||jN(mt.tray_color),colorHex:mt.tray_color||null,kFactor:RN(mt.k),fillLevel:null,trayUuid:mt.tray_uuid||null},_n=o.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${Zt?"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:mt.tray_color?`#${mt.tray_color}`:"#333",borderColor:Zt?"var(--accent)":"rgba(255,255,255,0.1)"}}),o.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:mt.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(kN,{data:Yt,spoolman:{enabled:s,hasUnlinkedSpools:l,onLinkSpool:s&&Yt.trayUuid?wn=>{le({trayUuid:wn,trayInfo:{type:Yt.profile,color:Yt.colorHex||"",location:"External Spool"}})}:void 0},children:_n})]})})()]})]})]})})()]}),U&&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:U.name}),L&&o.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${L.state==="ON"?"bg-bambu-green/20 text-bambu-green":L.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[L.state||"?",L.state==="ON"&&L.energy?.power!=null&&o.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",L.energy.power,"W"]})]})]}),o.jsx("div",{className:"flex-1"}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsxs("button",{onClick:()=>O(!0),disabled:lt.isPending||L?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${L?.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:()=>j(!0),disabled:lt.isPending||L?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${L?.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(iM,{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 ${U.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:U.auto_off_executed?"Auto-off done":"Auto-off"}),o.jsx("button",{onClick:()=>me.mutate(!U.auto_off),disabled:me.isPending||U.auto_off_executed,title:U.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 ${U.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":U.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 ${U.auto_off||U.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(Pe,{variant:"secondary",size:"sm",onClick:()=>{const bt=localStorage.getItem("cameraWindowState"),Ht=bt?JSON.parse(bt):{width:640,height:400},an=[`width=${Ht.width}`,`height=${Ht.height}`,Ht.left!==void 0?`left=${Ht.left}`:"",Ht.top!==void 0?`top=${Ht.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,an)},disabled:!Q?.connected,title:"Open camera in new window",children:o.jsx(eW,{className:"w-4 h-4"})}),o.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>A(!0),title:"Browse printer files",children:[o.jsx(pR,{className:"w-4 h-4"}),"Files"]})]})]})]}),w&&o.jsx(nhe,{printerId:t.id,printerName:t.name,onClose:()=>A(!1)}),T&&o.jsx(rhe,{printerId:t.id,printerName:t.name,onClose:()=>C(!1)}),N&&U&&o.jsx(mr,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{lt.mutate("on"),O(!1)},onCancel:()=>O(!1)}),k&&U&&o.jsx(mr,{title:"Power Off Printer",message:Q?.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:()=>{lt.mutate("off"),j(!1)},onCancel:()=>j(!1)}),q&&o.jsx(mr,{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:()=>{ae.mutate(),R(!1)},onCancel:()=>R(!1)}),W&&o.jsx(mr,{title:"Pause Print",message:`Are you sure you want to pause the current print on "${t.name}"?`,confirmText:"Pause Print",variant:"default",onConfirm:()=>{He.mutate(),K(!1)},onCancel:()=>K(!1)}),G&&o.jsx(mr,{title:"Resume Print",message:`Are you sure you want to resume the print on "${t.name}"?`,confirmText:"Resume Print",variant:"default",onConfirm:()=>{Be.mutate(),J(!1)},onCancel:()=>J(!1)}),ee&&o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>Z(!1),onKeyDown:bt=>bt.key==="Escape"&&Z(!1),tabIndex:-1,ref:bt=>bt?.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:bt=>bt.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(sH,{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:()=>Z(!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"})})]}),ot?ot.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(cue,{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:[ot.skipped_count,"/",ot.total," skipped"]})]}),(Q?.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(Sa,{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 ",Q?.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:[Q?.cover_url?o.jsx("img",{src:`${Q.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(bd,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),ot.objects.length>0&&o.jsx("div",{className:"absolute inset-0 pointer-events-none",children:ot.objects.map((bt,Ht)=>{let an,mt;if(bt.x!=null&&bt.y!=null&&ot.bbox_all){const[Zt,sn,Yt,_n]=ot.bbox_all,wn=Yt-Zt,Ce=_n-sn,ce=10,Ue=100-ce*2;an=ce+(bt.x-Zt)/wn*Ue,mt=ce+(_n-bt.y)/Ce*Ue,an=Math.max(5,Math.min(95,an)),mt=Math.max(5,Math.min(95,mt))}else if(bt.x!=null&&bt.y!=null)an=Math.max(10,Math.min(90,bt.x/256*100)),mt=Math.max(10,Math.min(90,100-bt.y/256*100));else{const Zt=Math.ceil(Math.sqrt(ot.objects.length)),sn=Math.floor(Ht/Zt),Yt=Ht%Zt,_n=Math.ceil(ot.objects.length/Zt);an=15+Yt*(70/Zt)+35/Zt,mt=15+sn*(70/_n)+35/_n}return o.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${bt.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${an}%`,top:`${mt}%`,transform:"translate(-50%, -50%)"},title:bt.name,children:bt.id},bt.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:[ot.objects.filter(bt=>!bt.skipped).length," active"]})]})}),o.jsx("div",{className:"flex-1 min-w-0",children:ot.objects.map(bt=>o.jsxs("div",{className:`
  85. flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
  86. ${bt.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
  87. `,children:[o.jsxs("div",{className:`
  88. w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
  89. ${bt.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"}
  90. `,children:[o.jsx("span",{className:`text-lg font-mono font-bold ${bt.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:bt.id}),o.jsx("span",{className:`text-[8px] uppercase tracking-wider ${bt.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 ${bt.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:bt.name}),bt.skipped&&o.jsx("span",{className:"text-[10px] text-red-400/60",children:"Will be skipped"})]}),bt.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:()=>nt.mutate([bt.id]),disabled:nt.isPending||(Q?.layer_num??0)<=1,className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(Q?.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:(Q?.layer_num??0)<=1?"Wait for layer 2+":"Skip this object",children:"Skip"})]},bt.id))})]})]}):o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(xt,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),z&&o.jsx(ohe,{printerName:t.name,errors:Q?.hms_errors||[],onClose:()=>I(!1)}),F&&o.jsx(tCe,{isOpen:!!F,onClose:()=>V(null),printerId:t.id,printerName:t.name,amsId:F.amsId,amsLabel:F.amsLabel,initialMode:F.mode,thresholds:a}),ne&&o.jsx(nCe,{isOpen:!!ne,onClose:()=>le(null),trayUuid:ne.trayUuid,trayInfo:ne.trayInfo}),y&&o.jsx(xCe,{printer:t,onClose:()=>E(!1)}),oe&&Ee&&o.jsx(gCe,{printer:t,firmwareInfo:Ee,onClose:()=>pe(!1)}),wt&&o.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Qt(null)})]})}function pCe({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,b]=S.useState(!1),[v,x]=S.useState("192.168.1.0/24"),[y,E]=S.useState({scanned:0,total:0});S.useEffect(()=>{nl.getInfo().then(N=>{b(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(At,{className:"w-full max-w-md",onClick:N=>N.stopPropagation(),children:o.jsxs(Tt,{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=>x(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(Pe,{type:"button",variant:"secondary",onClick:A,disabled:a,className:"w-full",children:a?o.jsxs(o.Fragment,{children:[o.jsx(xt,{className:"w-4 h-4 animate-spin"}),p&&y.total>0?`Scanning... ${y.scanned}/${y.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(Os,{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(Pe,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),o.jsx(Pe,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function gCe({printer:t,firmwareInfo:e,onClose:n}){const r=dn(),{showToast:i}=vr(),[a,s]=S.useState(null),[l,c]=S.useState(!1),[u,d]=S.useState(null),{data:f,isLoading:g}=pt({queryKey:["firmwarePrepare",t.id],queryFn:()=>m1.prepareUpload(t.id),staleTime:3e4}),p=_t({mutationFn:()=>m1.startUpload(t.id),onSuccess:()=>{c(!0);const v=setInterval(async()=>{try{const x=await m1.getUploadStatus(t.id);s(x),(x.status==="complete"||x.status==="error")&&(clearInterval(v),d(null),c(!1),x.status==="complete"&&(i("Firmware uploaded! Trigger update from printer screen.","success"),r.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);d(v)},onError:v=>{i(`Failed to start upload: ${v.message}`,"error"),c(!1)}});S.useEffect(()=>()=>{u&&clearInterval(u)},[u]);const b=()=>{s(null),p.mutate()};return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:o.jsx(At,{className:"w-full max-w-md mx-4",children:o.jsxs(Tt,{children:[o.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[o.jsx("div",{className:"p-2 rounded-full bg-orange-500/20",children:o.jsx(Wi,{className:"w-5 h-5 text-orange-400"})}),o.jsxs("div",{className:"flex-1",children:[o.jsx("h3",{className:"text-lg font-semibold text-white",children:"Firmware Update"}),o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t.name})]})]}),o.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:[o.jsxs("div",{className:"flex justify-between items-center text-sm",children:[o.jsx("span",{className:"text-bambu-gray",children:"Current:"}),o.jsx("span",{className:"text-white font-mono",children:e.current_version||"Unknown"})]}),o.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[o.jsx("span",{className:"text-bambu-gray",children:"Latest:"}),o.jsx("span",{className:"text-orange-400 font-mono",children:e.latest_version})]}),e.release_notes&&o.jsxs("details",{className:"mt-3 text-sm",children:[o.jsx("summary",{className:"text-orange-400 cursor-pointer hover:underline",children:"Release Notes"}),o.jsx("div",{className:"mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap",children:e.release_notes})]})]}),g?o.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm mb-4",children:[o.jsx(xt,{className:"w-4 h-4 animate-spin"}),"Checking prerequisites..."]}):f&&!l&&!a?o.jsx("div",{className:"mb-4",children:f.can_proceed?o.jsxs("div",{className:"flex items-center gap-2 text-bambu-green text-sm",children:[o.jsx(bd,{className:"w-4 h-4"}),"SD card ready. Click below to upload firmware."]}):o.jsx("div",{className:"space-y-1",children:f.errors.map((v,x)=>o.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[o.jsx(Sa,{className:"w-4 h-4 flex-shrink-0"}),v]},x))})}):null,(l||a)&&a&&o.jsxs("div",{className:"mb-4",children:[o.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[o.jsx("span",{className:"text-bambu-gray capitalize",children:a.status}),o.jsxs("span",{className:"text-white",children:[a.progress,"%"]})]}),o.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:o.jsx("div",{className:`h-2 rounded-full transition-all ${a.status==="error"?"bg-red-500":a.status==="complete"?"bg-bambu-green":"bg-orange-500"} ${a.status==="uploading"?"animate-pulse":""}`,style:{width:`${a.progress}%`}})}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a.message}),a.error&&o.jsx("p",{className:"text-xs text-red-400 mt-1",children:a.error})]}),a?.status==="complete"&&o.jsxs("div",{className:"bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4",children:[o.jsx("p",{className:"text-sm text-bambu-green font-medium mb-2",children:"Firmware uploaded to SD card!"}),o.jsx("p",{className:"text-xs text-bambu-gray",children:"To apply the update on your printer:"}),o.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[o.jsxs("li",{children:["On the printer's touchscreen, go to ",o.jsx("strong",{className:"text-white",children:"Settings"})]}),o.jsxs("li",{children:["Navigate to ",o.jsx("strong",{className:"text-white",children:"Firmware"})]}),o.jsxs("li",{children:["Select ",o.jsx("strong",{className:"text-white",children:"Update from SD card"})]}),o.jsx("li",{children:"The update will take 10-20 minutes"})]})]}),o.jsxs("div",{className:"flex gap-2 justify-end",children:[o.jsx(Pe,{variant:"secondary",onClick:n,children:a?.status==="complete"?"Done":"Cancel"}),f?.can_proceed&&!l&&a?.status!=="complete"&&o.jsx(Pe,{onClick:b,disabled:p.isPending,children:p.isPending?o.jsxs(o.Fragment,{children:[o.jsx(xt,{className:"w-4 h-4 animate-spin mr-2"}),"Starting..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Wi,{className:"w-4 h-4 mr-2"}),"Upload Firmware"]})})]})]})})})}function xCe({printer:t,onClose:e}){const n=dn(),[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=_t({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(At,{className:"w-full max-w-md",onClick:l=>l.stopPropagation(),children:o.jsxs(Tt,{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(Pe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsx(Pe,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function bCe(t){const{data:e}=pt({queryKey:["printerStatus",t],queryFn:()=>_e.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function yCe({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=bCe(t.id),{data:a}=pt({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 vCe(){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(()=>{const Z=localStorage.getItem("printerCardSize");return Z?parseInt(Z,10):2}),b=g===1?"compact":"expanded",v=dn(),{data:x,isLoading:y}=pt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:E}=pt({queryKey:["settings"],queryFn:_e.getSettings}),{data:w}=pt({queryKey:["smart-plugs"],queryFn:_e.getSmartPlugs}),{data:A}=pt({queryKey:["maintenanceOverview"],queryFn:_e.getMaintenanceOverview,staleTime:60*1e3}),{data:T}=pt({queryKey:["spoolman-status"],queryFn:_e.getSpoolmanStatus,staleTime:60*1e3}),C=T?.enabled&&T?.connected,{data:N}=pt({queryKey:["unlinked-spools"],queryFn:_e.getUnlinkedSpools,enabled:!!C,staleTime:30*1e3}),O=N&&N.length>0,k=A?.reduce((Z,F)=>(Z[F.printer_id]={due_count:F.due_count,warning_count:F.warning_count,total_print_hours:F.total_print_hours},Z),{})||{},j=w?.reduce((Z,F)=>(F.printer_id&&(Z[F.printer_id]=F),Z),{})||{},z=_t({mutationFn:_e.createPrinter,onSuccess:()=>{v.invalidateQueries({queryKey:["printers"]}),e(!1)}}),I=_t({mutationFn:Z=>_e.controlSmartPlug(Z,"on"),onSuccess:()=>{v.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),q=()=>{const Z=!n;r(Z),localStorage.setItem("hideDisconnectedPrinters",String(Z))},R=Z=>{u(Z),localStorage.setItem("printerSortBy",Z)},W=()=>{const Z=!d;f(Z),localStorage.setItem("printerSortAsc",String(Z))},K=()=>{switch(g){case 1:return"grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5";case 2:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3";case 3:return"grid-cols-1 lg:grid-cols-2";case 4:return"grid-cols-1";default:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3"}},G=["S","M","L","XL"],J=S.useMemo(()=>{if(!x)return[];const Z=[...x];switch(c){case"name":Z.sort((F,V)=>F.name.localeCompare(V.name));break;case"model":Z.sort((F,V)=>(F.model||"").localeCompare(V.model||""));break;case"location":Z.sort((F,V)=>{const ne=F.location||"",le=V.location||"";return!ne&&le?1:ne&&!le?-1:ne.localeCompare(le)||F.name.localeCompare(V.name)});break;case"status":Z.sort((F,V)=>{const ne=v.getQueryData(["printerStatus",F.id]),le=v.getQueryData(["printerStatus",V.id]),oe=pe=>pe?.connected?pe.state==="RUNNING"?0:1:2;return oe(ne)-oe(le)});break}return d||Z.reverse(),Z},[x,c,d,v]),ee=S.useMemo(()=>{if(c!=="location")return null;const Z={};return J.forEach(F=>{const V=F.location||"Ungrouped";Z[V]||(Z[V]=[]),Z[V].push(F)}),Z},[c,J]);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(mCe,{printers:x})]}),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:Z=>R(Z.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:W,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("div",{className:"flex items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:G.map((Z,F)=>{const V=F+1,ne=g===V;return o.jsx("button",{onClick:()=>{p(V),localStorage.setItem("printerCardSize",String(V))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${F===0?"rounded-l-lg":""} ${F===G.length-1?"rounded-r-lg":""} ${ne?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:`${Z==="S"?"Small":Z==="M"?"Medium":Z==="L"?"Large":"Extra large"} cards`,children:Z},Z)})}),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:q,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(j).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(Os,{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"}),x?.filter(Z=>j[Z.id]).map(Z=>o.jsx(yCe,{printer:Z,plug:j[Z.id],onPowerOn:F=>{l(F),I.mutate(F)},isPowering:s===j[Z.id]?.id},Z.id)),x?.filter(Z=>j[Z.id]).length===0&&o.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),o.jsxs(Pe,{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..."}):x?.length===0?o.jsx(At,{children:o.jsxs(Tt,{className:"text-center py-12",children:[o.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),o.jsxs(Pe,{onClick:()=>e(!0),children:[o.jsx(fr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):ee?o.jsx("div",{className:"space-y-6",children:Object.entries(ee).map(([Z,F])=>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"}),Z,o.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",F.length,")"]})]}),o.jsx("div",{className:`grid gap-4 ${g>=3?"gap-6":""} ${K()}`,children:F.map(V=>o.jsx(mH,{printer:V,hideIfDisconnected:n,maintenanceInfo:k[V.id],viewMode:b,cardSize:g,amsThresholds:E?{humidityGood:Number(E.ams_humidity_good)||40,humidityFair:Number(E.ams_humidity_fair)||60,tempGood:Number(E.ams_temp_good)||28,tempFair:Number(E.ams_temp_fair)||35}:void 0,spoolmanEnabled:C,hasUnlinkedSpools:O},V.id))})]},Z))}):o.jsx("div",{className:`grid gap-4 ${g>=3?"gap-6":""} ${K()}`,children:J.map(Z=>o.jsx(mH,{printer:Z,hideIfDisconnected:n,maintenanceInfo:k[Z.id],viewMode:b,cardSize:g,spoolmanEnabled:C,hasUnlinkedSpools:O,amsThresholds:E?{humidityGood:Number(E.ams_humidity_good)||40,humidityFair:Number(E.ams_humidity_fair)||60,tempGood:Number(E.ams_temp_good)||28,tempFair:Number(E.ams_temp_fair)||35}:void 0},Z.id))}),t&&o.jsx(pCe,{onClose:()=>e(!1),onAdd:Z=>z.mutate(Z),existingSerials:x?.map(Z=>Z.serial_number)||[]})]})}function _Ce(){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 wCe(){switch(_Ce()){case"windows":return"bambustudio://";case"macos":case"linux":default:return"bambustudioopen://"}}function vh(t){const e=wCe();window.location.href=`${e}${encodeURIComponent(t)}`}const AO="181",pp={ROTATE:0,DOLLY:1,PAN:2},lp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},SCe=0,pH=1,MCe=2,vZ=1,ECe=2,pc=3,Td=0,ns=1,dl=2,Dc=0,gp=1,gH=2,xH=3,bH=4,ACe=5,_h=100,TCe=101,NCe=102,CCe=103,kCe=104,PCe=200,jCe=201,RCe=202,DCe=203,lP=204,cP=205,OCe=206,LCe=207,ICe=208,FCe=209,UCe=210,zCe=211,BCe=212,HCe=213,$Ce=214,uP=0,dP=1,hP=2,Fp=3,fP=4,mP=5,pP=6,gP=7,TO=0,VCe=1,GCe=2,ud=0,WCe=1,qCe=2,KCe=3,XCe=4,YCe=5,ZCe=6,QCe=7,_Z=300,Up=301,zp=302,xP=303,bP=304,tE=306,yP=1e3,Tc=1001,vP=1002,ks=1003,JCe=1004,Kv=1005,lo=1006,ON=1007,Ph=1008,Al=1009,wZ=1010,SZ=1011,J0=1012,NO=1013,mf=1014,Nc=1015,yg=1016,CO=1017,kO=1018,eb=1020,MZ=35902,EZ=35899,AZ=1021,TZ=1022,Fo=1023,tb=1026,nb=1027,NZ=1028,PO=1029,jO=1030,RO=1031,DO=1033,S1=33776,M1=33777,E1=33778,A1=33779,_P=35840,wP=35841,SP=35842,MP=35843,EP=36196,AP=37492,TP=37496,NP=37808,CP=37809,kP=37810,PP=37811,jP=37812,RP=37813,DP=37814,OP=37815,LP=37816,IP=37817,FP=37818,UP=37819,zP=37820,BP=37821,HP=36492,$P=36494,VP=36495,GP=36283,WP=36284,qP=36285,KP=36286,eke=3200,tke=3201,CZ=0,nke=1,Qu="",Js="srgb",Bp="srgb-linear",Ww="linear",ar="srgb",mm=7680,yH=519,rke=512,ike=513,ake=514,kZ=515,ske=516,oke=517,lke=518,cke=519,vH=35044,_H="300 es",pl=2e3,qw=2001;function PZ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Kw(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function uke(){const t=Kw("canvas");return t.style.display="block",t}const wH={};function SH(...t){const e="THREE."+t.shift();console.log(e,...t)}function nn(...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 wH||(wH[e]=!0,nn(...t))}function dke(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 fa=["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"],T1=Math.PI/180,XP=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(fa[t&255]+fa[t>>8&255]+fa[t>>16&255]+fa[t>>24&255]+"-"+fa[e&255]+fa[e>>8&255]+"-"+fa[e>>16&15|64]+fa[e>>24&255]+"-"+fa[n&63|128]+fa[n>>8&255]+"-"+fa[n>>16&255]+fa[n>>24&255]+fa[r&255]+fa[r>>8&255]+fa[r>>16&255]+fa[r>>24&255]).toLowerCase()}function Tn(t,e,n){return Math.max(e,Math.min(n,t))}function hke(t,e){return(t%e+e)%e}function LN(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 Xa(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 fke={DEG2RAD:T1};let bn=class jZ{constructor(e=0,n=0){jZ.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=Tn(this.x,e.x,n.x),this.y=Tn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Tn(this.x,e,n),this.y=Tn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Tn(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(Tn(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],b=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]=b,e[n+3]=v;return}if(f!==v||c!==g||u!==p||d!==b){let x=c*g+u*p+d*b+f*v;x<0&&(g=-g,p=-p,b=-b,v=-v,x=-x);let y=1-l;if(x<.9995){const E=Math.acos(x),w=Math.sin(E);y=Math.sin(y*E)/w,l=Math.sin(l*E)/w,c=c*y+g*l,u=u*y+p*l,d=d*y+b*l,f=f*y+v*l}else{c=c*y+g*l,u=u*y+p*l,d=d*y+b*l,f=f*y+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],b=a[s+3];return e[n]=l*b+d*f+c*p-u*g,e[n+1]=c*b+d*g+u*f-l*p,e[n+2]=u*b+d*p+l*g-c*f,e[n+3]=d*b-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),b=c(a/2);switch(s){case"XYZ":this._x=g*d*f+u*p*b,this._y=u*p*f-g*d*b,this._z=u*d*b+g*p*f,this._w=u*d*f-g*p*b;break;case"YXZ":this._x=g*d*f+u*p*b,this._y=u*p*f-g*d*b,this._z=u*d*b-g*p*f,this._w=u*d*f+g*p*b;break;case"ZXY":this._x=g*d*f-u*p*b,this._y=u*p*f+g*d*b,this._z=u*d*b+g*p*f,this._w=u*d*f-g*p*b;break;case"ZYX":this._x=g*d*f-u*p*b,this._y=u*p*f+g*d*b,this._z=u*d*b-g*p*f,this._w=u*d*f+g*p*b;break;case"YZX":this._x=g*d*f+u*p*b,this._y=u*p*f+g*d*b,this._z=u*d*b-g*p*f,this._w=u*d*f-g*p*b;break;case"XZY":this._x=g*d*f-u*p*b,this._y=u*p*f-g*d*b,this._z=u*d*b+g*p*f,this._w=u*d*f+g*p*b;break;default:nn("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(Tn(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}},it=class RZ{constructor(e=0,n=0,r=0){RZ.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(MH.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(MH.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=Tn(this.x,e.x,n.x),this.y=Tn(this.y,e.y,n.y),this.z=Tn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Tn(this.x,e,n),this.y=Tn(this.y,e,n),this.z=Tn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Tn(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 IN.copy(this).projectOnVector(e),this.sub(IN)}reflect(e){return this.sub(IN.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(Tn(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 IN=new it,MH=new pf;let vn=class DZ{constructor(e,n,r,i,a,s,l,c,u){DZ.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],b=r[8],v=i[0],x=i[3],y=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*x+l*w+c*C,a[6]=s*y+l*A+c*N,a[1]=u*v+d*E+f*T,a[4]=u*x+d*w+f*C,a[7]=u*y+d*A+f*N,a[2]=g*v+p*E+b*T,a[5]=g*x+p*w+b*C,a[8]=g*y+p*A+b*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,b=n*f+r*g+i*p;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/b;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(FN.makeScale(e,n)),this}rotate(e){return this.premultiply(FN.makeRotation(-e)),this}translate(e,n){return this.premultiply(FN.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 FN=new vn,EH=new vn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),AH=new vn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function mke(){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===Qu?Ww: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:Ww,toXYZ:EH,fromXYZ:AH,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Js},outputColorSpaceConfig:{drawingBufferColorSpace:Js}},[Js]:{primaries:e,whitePoint:r,transfer:ar,toXYZ:EH,fromXYZ:AH,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Js}}}),t}const zn=mke();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,pke=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=Kw("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=Kw("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 nn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},gke=0,OO=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:gke++}),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(UN(i[s].image)):a.push(UN(i[s]))}else a=UN(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function UN(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?pke.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(nn("Texture: Unable to serialize Texture."),{})}let xke=0;const zN=new it;let Yo=class N1 extends Nf{constructor(e=N1.DEFAULT_IMAGE,n=N1.DEFAULT_MAPPING,r=Tc,i=Tc,a=lo,s=Ph,l=Fo,c=Al,u=N1.DEFAULT_ANISOTROPY,d=Qu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:xke++}),this.uuid=ay(),this.name="",this.source=new OO(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 bn(0,0),this.repeat=new bn(1,1),this.center=new bn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new vn,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(zN).x}get height(){return this.source.getSize(zN).y}get depth(){return this.source.getSize(zN).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){nn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){nn(`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!==_Z)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case yP:e.x=e.x-Math.floor(e.x);break;case Tc:e.x=e.x<0?0:1;break;case vP: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 yP:e.y=e.y-Math.floor(e.y);break;case Tc:e.y=e.y<0?0:1;break;case vP: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=_Z;Yo.DEFAULT_ANISOTROPY=1;let ci=class OZ{constructor(e=0,n=0,r=0,i=1){OZ.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],b=c[9],v=c[2],x=c[6],y=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-v)<.01&&Math.abs(b-x)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+v)<.1&&Math.abs(b+x)<.1&&Math.abs(u+p+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(u+1)/2,A=(p+1)/2,T=(y+1)/2,C=(d+g)/4,N=(f+v)/4,O=(b+x)/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((x-b)*(x-b)+(f-v)*(f-v)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(x-b)/E,this.y=(f-v)/E,this.z=(g-d)/E,this.w=Math.acos((u+p+y-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=Tn(this.x,e.x,n.x),this.y=Tn(this.y,e.y,n.y),this.z=Tn(this.z,e.z,n.z),this.w=Tn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Tn(this.x,e,n),this.y=Tn(this.y,e,n),this.z=Tn(this.z,e,n),this.w=Tn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Tn(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}},bke=class extends Nf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:lo,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:lo,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 OO(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 bke{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},LZ=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()}},yke=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 it(1/0,1/0,1/0),n=new it(-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),Tu.subVectors(xm,gm),Nu.subVectors(bm,xm),rh.subVectors(gm,bm);let n=[0,-Tu.z,Tu.y,0,-Nu.z,Nu.y,0,-rh.z,rh.y,Tu.z,0,-Tu.x,Nu.z,0,-Nu.x,rh.z,0,-rh.x,-Tu.y,Tu.x,0,-Nu.y,Nu.x,0,-rh.y,rh.x,0];return!BN(n,gm,xm,bm,Yv)||(n=[1,0,0,0,1,0,0,0,1],!BN(n,gm,xm,bm,Yv))?!1:(Zv.crossVectors(Tu,Nu),n=[Zv.x,Zv.y,Zv.z],BN(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 it,new it,new it,new it,new it,new it,new it,new it],Ao=new it,Xv=new xf,gm=new it,xm=new it,bm=new it,Tu=new it,Nu=new it,rh=new it,Cx=new it,Yv=new it,Zv=new it,ih=new it;function BN(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){ih.fromArray(t,a);const l=i.x*Math.abs(ih.x)+i.y*Math.abs(ih.y)+i.z*Math.abs(ih.z),c=e.dot(ih),u=n.dot(ih),d=r.dot(ih);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const vke=new xf,kx=new it,HN=new it;let nE=class{constructor(e=new it,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):vke.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):(HN.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(kx.copy(e.center).add(HN)),this.expandByPoint(kx.copy(e.center).sub(HN))),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 it,$N=new it,Qv=new it,Cu=new it,VN=new it,Jv=new it,GN=new it;let LO=class{constructor(e=new it,n=new it(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){$N.copy(e).add(n).multiplyScalar(.5),Qv.copy(n).sub(e).normalize(),Cu.copy(this.origin).sub($N);const a=e.distanceTo(n)*.5,s=-this.direction.dot(Qv),l=Cu.dot(this.direction),c=-Cu.dot(Qv),u=Cu.lengthSq(),d=Math.abs(1-s*s);let f,g,p,b;if(d>0)if(f=s*c-l,g=s*l-c,b=a*d,f>=0)if(g>=-b)if(g<=b){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<=-b?(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<=b?(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($N).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){VN.subVectors(n,e),Jv.subVectors(r,e),GN.crossVectors(VN,Jv);let s=this.direction.dot(GN),l;if(s>0){if(i)return null;l=1}else if(s<0)l=-1,s=-s;else return null;Cu.subVectors(this.origin,e);const c=l*this.direction.dot(Jv.crossVectors(Cu,Jv));if(c<0)return null;const u=l*this.direction.dot(VN.cross(Cu));if(u<0||c+u>s)return null;const d=-l*Cu.dot(GN);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)}},mi=class YP{constructor(e,n,r,i,a,s,l,c,u,d,f,g,p,b,v,x){YP.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,b,v,x)}set(e,n,r,i,a,s,l,c,u,d,f,g,p,b,v,x){const y=this.elements;return y[0]=e,y[4]=n,y[8]=r,y[12]=i,y[1]=a,y[5]=s,y[9]=l,y[13]=c,y[2]=u,y[6]=d,y[10]=f,y[14]=g,y[3]=p,y[7]=b,y[11]=v,y[15]=x,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 YP().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,b=l*d,v=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+b*u,n[5]=g-v*u,n[9]=-l*c,n[2]=v-g*u,n[6]=b+p*u,n[10]=s*c}else if(e.order==="YXZ"){const g=c*d,p=c*f,b=u*d,v=u*f;n[0]=g+v*l,n[4]=b*l-p,n[8]=s*u,n[1]=s*f,n[5]=s*d,n[9]=-l,n[2]=p*l-b,n[6]=v+g*l,n[10]=s*c}else if(e.order==="ZXY"){const g=c*d,p=c*f,b=u*d,v=u*f;n[0]=g-v*l,n[4]=-s*f,n[8]=b+p*l,n[1]=p+b*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,b=l*d,v=l*f;n[0]=c*d,n[4]=b*u-p,n[8]=g*u+v,n[1]=c*f,n[5]=v*u+g,n[9]=p*u-b,n[2]=-u,n[6]=l*c,n[10]=s*c}else if(e.order==="YZX"){const g=s*c,p=s*u,b=l*c,v=l*u;n[0]=c*d,n[4]=v-g*f,n[8]=b*f+p,n[1]=f,n[5]=s*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+b,n[10]=g-v*f}else if(e.order==="XZY"){const g=s*c,p=s*u,b=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-b,n[2]=b*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(_ke,e,wke)}lookAt(e,n,r){const i=this.elements;return bs.subVectors(e,n),bs.lengthSq()===0&&(bs.z=1),bs.normalize(),ku.crossVectors(r,bs),ku.lengthSq()===0&&(Math.abs(r.z)===1?bs.x+=1e-4:bs.z+=1e-4,bs.normalize(),ku.crossVectors(r,bs)),ku.normalize(),e_.crossVectors(bs,ku),i[0]=ku.x,i[4]=e_.x,i[8]=bs.x,i[1]=ku.y,i[5]=e_.y,i[9]=bs.y,i[2]=ku.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],b=r[2],v=r[6],x=r[10],y=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],z=i[5],I=i[9],q=i[13],R=i[2],W=i[6],K=i[10],G=i[14],J=i[3],ee=i[7],Z=i[11],F=i[15];return a[0]=s*C+l*j+c*R+u*J,a[4]=s*N+l*z+c*W+u*ee,a[8]=s*O+l*I+c*K+u*Z,a[12]=s*k+l*q+c*G+u*F,a[1]=d*C+f*j+g*R+p*J,a[5]=d*N+f*z+g*W+p*ee,a[9]=d*O+f*I+g*K+p*Z,a[13]=d*k+f*q+g*G+p*F,a[2]=b*C+v*j+x*R+y*J,a[6]=b*N+v*z+x*W+y*ee,a[10]=b*O+v*I+x*K+y*Z,a[14]=b*k+v*q+x*G+y*F,a[3]=E*C+w*j+A*R+T*J,a[7]=E*N+w*z+A*W+T*ee,a[11]=E*O+w*I+A*K+T*Z,a[15]=E*k+w*q+A*G+T*F,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],b=e[3],v=e[7],x=e[11],y=e[15];return b*(+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)+x*(+n*u*f-n*l*p-a*s*f+r*s*p+a*l*d-r*u*d)+y*(-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],b=e[12],v=e[13],x=e[14],y=e[15],E=f*x*u-v*g*u+v*c*p-l*x*p-f*c*y+l*g*y,w=b*g*u-d*x*u-b*c*p+s*x*p+d*c*y-s*g*y,A=d*v*u-b*f*u+b*l*p-s*v*p-d*l*y+s*f*y,T=b*f*c-d*v*c-b*l*g+s*v*g+d*l*x-s*f*x,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*x*a-v*i*p+r*x*p+f*i*y-r*g*y)*N,e[2]=(l*x*a-v*c*a+v*i*u-r*x*u-l*i*y+r*c*y)*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*x*a-b*g*a+b*i*p-n*x*p-d*i*y+n*g*y)*N,e[6]=(b*c*a-s*x*a-b*i*u+n*x*u+s*i*y-n*c*y)*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]=(b*f*a-d*v*a-b*r*p+n*v*p+d*r*y-n*f*y)*N,e[10]=(s*v*a-b*l*a+b*r*u-n*v*u-s*r*y+n*l*y)*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-b*f*i+b*r*g-n*v*g-d*r*x+n*f*x)*N,e[14]=(b*l*i-s*v*i-b*r*c+n*v*c+s*r*x-n*l*x)*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,b=a*f,v=s*d,x=s*f,y=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+y))*T,i[1]=(p+A)*T,i[2]=(b-w)*T,i[3]=0,i[4]=(p-A)*C,i[5]=(1-(g+y))*C,i[6]=(x+E)*C,i[7]=0,i[8]=(b+w)*N,i[9]=(x-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 b,v;if(c)b=a/(s-a),v=s*a/(s-a);else if(l===pl)b=-(s+a)/(s-a),v=-2*s*a/(s-a);else if(l===qw)b=-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]=b,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 b,v;if(c)b=1/(s-a),v=s/(s-a);else if(l===pl)b=-2/(s-a),v=-(s+a)/(s-a);else if(l===qw)b=-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]=b,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 it,To=new mi,_ke=new it(0,0,0),wke=new it(1,1,1),ku=new it,e_=new it,bs=new it,TH=new mi,NH=new pf;let Nd=class IZ{constructor(e=0,n=0,r=0,i=IZ.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(Tn(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(-Tn(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(Tn(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(-Tn(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(Tn(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(-Tn(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:nn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return TH.makeRotationFromQuaternion(e),this.setFromRotationMatrix(TH,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return NH.setFromEuler(this),this.setFromQuaternion(NH,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}};Nd.DEFAULT_ORDER="XYZ";let FZ=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}},Ske=0;const CH=new it,vm=new pf,rc=new mi,t_=new it,Px=new it,Mke=new it,Eke=new pf,kH=new it(1,0,0),PH=new it(0,1,0),jH=new it(0,0,1),RH={type:"added"},Ake={type:"removed"},_m={type:"childadded",child:null},WN={type:"childremoved",child:null};let Ds=class C1 extends Nf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ske++}),this.uuid=ay(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=C1.DEFAULT_UP.clone();const e=new it,n=new Nd,r=new pf,i=new it(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 mi},normalMatrix:{value:new vn}}),this.matrix=new mi,this.matrixWorld=new mi,this.matrixAutoUpdate=C1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=C1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new FZ,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(kH,e)}rotateY(e){return this.rotateOnAxis(PH,e)}rotateZ(e){return this.rotateOnAxis(jH,e)}translateOnAxis(e,n){return CH.copy(e).applyQuaternion(this.quaternion),this.position.add(CH.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(kH,e)}translateY(e){return this.translateOnAxis(PH,e)}translateZ(e){return this.translateOnAxis(jH,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(RH),_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(Ake),WN.child=e,this.dispatchEvent(WN),WN.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(RH),_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,Mke),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Px,Eke,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),b=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),b.length>0&&(r.nodes=b)}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 it(0,1,0);Ds.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ds.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const No=new it,ic=new it,qN=new it,ac=new it,wm=new it,Sm=new it,DH=new it,KN=new it,XN=new it,YN=new it,ZN=new ci,QN=new ci,JN=new ci;let jx=class Jm{constructor(e=new it,n=new it,r=new it){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),qN.subVectors(e,n);const s=No.dot(No),l=No.dot(ic),c=No.dot(qN),u=ic.dot(ic),d=ic.dot(qN),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,b=(s*d-l*c)*g;return a.set(1-p-b,b,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 ZN.setScalar(0),QN.setScalar(0),JN.setScalar(0),ZN.fromBufferAttribute(e,n),QN.fromBufferAttribute(e,r),JN.fromBufferAttribute(e,i),s.setScalar(0),s.addScaledVector(ZN,a.x),s.addScaledVector(QN,a.y),s.addScaledVector(JN,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),KN.subVectors(e,r);const c=wm.dot(KN),u=Sm.dot(KN);if(c<=0&&u<=0)return n.copy(r);XN.subVectors(e,i);const d=wm.dot(XN),f=Sm.dot(XN);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);YN.subVectors(e,a);const p=wm.dot(YN),b=Sm.dot(YN);if(b>=0&&p<=b)return n.copy(a);const v=p*u-c*b;if(v<=0&&u>=0&&b<=0)return l=u/(u-b),n.copy(r).addScaledVector(Sm,l);const x=d*b-p*f;if(x<=0&&f-d>=0&&p-b>=0)return DH.subVectors(a,i),l=(f-d)/(f-d+(p-b)),n.copy(i).addScaledVector(DH,l);const y=1/(x+v+g);return s=v*y,l=g*y,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 UZ={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},Pu={h:0,s:0,l:0},n_={h:0,s:0,l:0};function eC(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 Nn=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=Js){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,zn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=zn.workingColorSpace){return this.r=e,this.g=n,this.b=r,zn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=zn.workingColorSpace){if(e=hke(e,1),n=Tn(n,0,1),r=Tn(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=eC(s,a,e+1/3),this.g=eC(s,a,e),this.b=eC(s,a,e-1/3)}return zn.colorSpaceToWorking(this,i),this}setStyle(e,n=Js){function r(a){a!==void 0&&parseFloat(a)<1&&nn("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:nn("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);nn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Js){const r=UZ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):nn("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=Js){return zn.workingToColorSpace(ma.copy(this),e),Math.round(Tn(ma.r*255,0,255))*65536+Math.round(Tn(ma.g*255,0,255))*256+Math.round(Tn(ma.b*255,0,255))}getHexString(e=Js){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=zn.workingColorSpace){zn.workingToColorSpace(ma.copy(this),n);const r=ma.r,i=ma.g,a=ma.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=zn.workingColorSpace){return zn.workingToColorSpace(ma.copy(this),n),e.r=ma.r,e.g=ma.g,e.b=ma.b,e}getStyle(e=Js){zn.workingToColorSpace(ma.copy(this),e);const n=ma.r,r=ma.g,i=ma.b;return e!==Js?`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(Pu),this.setHSL(Pu.h+e,Pu.s+n,Pu.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(Pu),e.getHSL(n_);const r=LN(Pu.h,n_.h,n),i=LN(Pu.s,n_.s,n),a=LN(Pu.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 ma=new Nn;Nn.NAMES=UZ;let Tke=0,vg=class extends Nf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Tke++}),this.uuid=ay(),this.name="",this.type="Material",this.blending=gp,this.side=Td,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=lP,this.blendDst=cP,this.blendEquation=_h,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Nn(0,0,0),this.blendAlpha=0,this.depthFunc=Fp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=yH,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){nn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){nn(`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!==Td&&(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!==lP&&(r.blendSrc=this.blendSrc),this.blendDst!==cP&&(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!==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!==yH&&(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++}},IO=class extends vg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Nn(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 Nd,this.combine=TO,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 it,r_=new bn;let Nke=0,ho=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:Nke++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=vH,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=Xa(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=Xa(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=Xa(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=Xa(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=Xa(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Xa(n,this.array),r=Xa(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=Xa(n,this.array),r=Xa(r,this.array),i=Xa(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=Xa(n,this.array),r=Xa(r,this.array),i=Xa(i,this.array),a=Xa(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!==vH&&(e.usage=this.usage),e}},zZ=class extends ho{constructor(e,n,r){super(new Uint16Array(e),n,r)}},BZ=class extends ho{constructor(e,n,r){super(new Uint32Array(e),n,r)}},$o=class extends ho{constructor(e,n,r){super(new Float32Array(e),n,r)}},Cke=0;const Ws=new mi,tC=new Ds,Mm=new it,ys=new xf,Rx=new xf,Oi=new it;let Ll=class HZ extends Nf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Cke++}),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(PZ(e)?BZ:zZ)(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 vn().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 tC.lookAt(e),tC.updateMatrix(),this.applyMatrix4(tC.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&&nn("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 it(-1/0,-1/0,-1/0),new it(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?(Oi.addVectors(this.boundingBox.min,ys.min),this.boundingBox.expandByPoint(Oi),Oi.addVectors(this.boundingBox.max,ys.max),this.boundingBox.expandByPoint(Oi)):(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 nE);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 it,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?(Oi.addVectors(ys.min,Rx.min),ys.expandByPoint(Oi),Oi.addVectors(ys.max,Rx.max),ys.expandByPoint(Oi)):(ys.expandByPoint(Rx.min),ys.expandByPoint(Rx.max))}ys.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&&(Mm.fromBufferAttribute(e,u),Oi.add(Mm)),i=Math.max(i,r.distanceToSquared(Oi))}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 ho(new Float32Array(4*r.count),4));const s=this.getAttribute("tangent"),l=[],c=[];for(let O=0;O<r.count;O++)l[O]=new it,c[O]=new it;const u=new it,d=new it,f=new it,g=new bn,p=new bn,b=new bn,v=new it,x=new it;function y(O,k,j){u.fromBufferAttribute(r,O),d.fromBufferAttribute(r,k),f.fromBufferAttribute(r,j),g.fromBufferAttribute(a,O),p.fromBufferAttribute(a,k),b.fromBufferAttribute(a,j),d.sub(u),f.sub(u),p.sub(g),b.sub(g);const z=1/(p.x*b.y-b.x*p.y);isFinite(z)&&(v.copy(d).multiplyScalar(b.y).addScaledVector(f,-p.y).multiplyScalar(z),x.copy(f).multiplyScalar(p.x).addScaledVector(d,-b.x).multiplyScalar(z),l[O].add(v),l[k].add(v),l[j].add(v),c[O].add(x),c[k].add(x),c[j].add(x))}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],z=j.start,I=j.count;for(let q=z,R=z+I;q<R;q+=3)y(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const w=new it,A=new it,T=new it,C=new it;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 z=A.dot(c[O])<0?-1:1;s.setXYZW(O,w.x,w.y,w.z,z)}for(let O=0,k=E.length;O<k;++O){const j=E[O],z=j.start,I=j.count;for(let q=z,R=z+I;q<R;q+=3)N(e.getX(q+0)),N(e.getX(q+1)),N(e.getX(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 ho(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 it,a=new it,s=new it,l=new it,c=new it,u=new it,d=new it,f=new it;if(e)for(let g=0,p=e.count;g<p;g+=3){const b=e.getX(g+0),v=e.getX(g+1),x=e.getX(g+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,v),s.fromBufferAttribute(n,x),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,b),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,x),l.add(d),c.add(d),u.add(d),r.setXYZ(b,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(x,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,b=0;for(let v=0,x=c.length;v<x;v++){l.isInterleavedBufferAttribute?p=c[v]*l.data.stride+l.offset:p=c[v]*d;for(let y=0;y<d;y++)g[b++]=u[p++]}return new ho(g,d,f)}if(this.index===null)return nn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new HZ,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 OH=new mi,ah=new LO,i_=new nE,LH=new it,a_=new it,s_=new it,o_=new it,nC=new it,l_=new it,IH=new it,c_=new it;let Tl=class extends Ds{constructor(e=new Ll,n=new IO){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&&(nC.fromBufferAttribute(f,e),s?l_.addScaledVector(nC,d):l_.addScaledVector(nC.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),ah.copy(e.ray).recast(e.near),!(i_.containsPoint(ah.origin)===!1&&(ah.intersectSphere(i_,LH)===null||ah.origin.distanceToSquared(LH)>(e.far-e.near)**2))&&(OH.copy(a).invert(),ah.copy(e.ray).applyMatrix4(OH),!(r.boundingBox!==null&&ah.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,ah)))}_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 b=0,v=g.length;b<v;b++){const x=g[b],y=s[x.materialIndex],E=Math.max(x.start,p.start),w=Math.min(l.count,Math.min(x.start+x.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,y,e,r,u,d,f,C,N,O),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let x=b,y=v;x<y;x+=3){const E=l.getX(x),w=l.getX(x+1),A=l.getX(x+2);i=u_(this,s,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(s))for(let b=0,v=g.length;b<v;b++){const x=g[b],y=s[x.materialIndex],E=Math.max(x.start,p.start),w=Math.min(c.count,Math.min(x.start+x.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,y,e,r,u,d,f,C,N,O),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let x=b,y=v;x<y;x+=3){const E=x,w=x+1,A=x+2;i=u_(this,s,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}}};function kke(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===Td,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=kke(t,e,n,r,a_,s_,o_,IH);if(d){const f=new it;jx.getBarycoord(IH,a_,s_,o_,f),i&&(d.uv=jx.getInterpolatedAttribute(i,l,c,u,f,new bn)),a&&(d.uv1=jx.getInterpolatedAttribute(a,l,c,u,f,new bn)),s&&(d.normal=jx.getInterpolatedAttribute(s,l,c,u,f,new it),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const g={a:l,b:c,c:u,normal:new it,materialIndex:0};jx.getNormal(a_,s_,o_,g.normal),d.face=g,d.barycoord=f}return d}let FO=class $Z 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;b("z","y","x",-1,-1,r,n,e,s,a,0),b("z","y","x",1,-1,r,n,-e,s,a,1),b("x","z","y",1,1,e,r,n,i,s,2),b("x","z","y",1,-1,e,r,-n,i,s,3),b("x","y","z",1,-1,e,n,r,i,a,4),b("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 b(v,x,y,E,w,A,T,C,N,O,k){const j=A/N,z=T/O,I=A/2,q=T/2,R=C/2,W=N+1,K=O+1;let G=0,J=0;const ee=new it;for(let Z=0;Z<K;Z++){const F=Z*z-q;for(let V=0;V<W;V++){const ne=V*j-I;ee[v]=ne*E,ee[x]=F*w,ee[y]=R,u.push(ee.x,ee.y,ee.z),ee[v]=0,ee[x]=0,ee[y]=C>0?1:-1,d.push(ee.x,ee.y,ee.z),f.push(V/N),f.push(1-Z/O),G+=1}}for(let Z=0;Z<O;Z++)for(let F=0;F<N;F++){const V=g+F+W*Z,ne=g+F+W*(Z+1),le=g+(F+1)+W*(Z+1),oe=g+(F+1)+W*Z;c.push(V,ne,oe),c.push(ne,le,oe),J+=6}l.addGroup(p,J,k),p+=J,g+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $Z(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?(nn("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 Ca(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 Pke(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function VZ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:zn.workingColorSpace}const jke={clone:Hp,merge:Ca};var Rke=`void main() {
  91. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  92. }`,Dke=`void main() {
  93. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  94. }`;let Yc=class extends vg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Rke,this.fragmentShader=Dke,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=Pke(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}},GZ=class extends Ds{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new mi,this.projectionMatrix=new mi,this.projectionMatrixInverse=new mi,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 ju=new it,FH=new bn,UH=new bn;let no=class extends GZ{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=XP*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(T1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return XP*2*Math.atan(Math.tan(T1*.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){ju.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ju.x,ju.y).multiplyScalar(-e/ju.z),ju.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(ju.x,ju.y).multiplyScalar(-e/ju.z)}getViewSize(e,n){return this.getViewBounds(e,FH,UH),n.subVectors(UH,FH)}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(T1*.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 Oke=class extends Ds{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new no(Em,Am,e,n);i.layers=this.layers,this.add(i);const a=new no(Em,Am,e,n);a.layers=this.layers,this.add(a);const s=new no(Em,Am,e,n);s.layers=this.layers,this.add(s);const l=new no(Em,Am,e,n);l.layers=this.layers,this.add(l);const c=new no(Em,Am,e,n);c.layers=this.layers,this.add(c);const u=new no(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===qw)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(),b=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=b,r.texture.needsPMREMUpdate=!0}},WZ=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}},Lke=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 WZ(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:`
  95. varying vec3 vWorldDirection;
  96. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  97. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  98. }
  99. void main() {
  100. vWorldDirection = transformDirection( position, modelMatrix );
  101. #include <begin_vertex>
  102. #include <project_vertex>
  103. }
  104. `,fragmentShader:`
  105. uniform sampler2D tEquirect;
  106. varying vec3 vWorldDirection;
  107. #include <common>
  108. void main() {
  109. vec3 direction = normalize( vWorldDirection );
  110. vec2 sampleUV = equirectUv( direction );
  111. gl_FragColor = texture2D( tEquirect, sampleUV );
  112. }
  113. `},i=new FO(5,5,5),a=new Yc({name:"CubemapFromEquirect",uniforms:Hp(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ns,blending:Dc});a.uniforms.tEquirect.value=n;const s=new Tl(i,a),l=n.minFilter;return n.minFilter===Ph&&(n.minFilter=lo),new Oke(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 Ike={type:"move"};let rC=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 it,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new it),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 it,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new it),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 x=n.getJointPose(v,r),y=this._getHandJoint(u,v);x!==null&&(y.matrix.fromArray(x.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=x.radius),y.visible=x!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),p=.02,b=.005;u.inputState.pinching&&g>p+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=p-b&&(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(Ike)))}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]}},Fke=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 Nd,this.environmentIntensity=1,this.environmentRotation=new Nd,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}},Uke=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 iC=new it,zke=new it,Bke=new vn;let Gu=class{constructor(e=new it(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=iC.subVectors(r,n).cross(zke.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(iC),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||Bke.getNormalMatrix(e),i=this.coplanarPoint(iC).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 sh=new nE,Hke=new bn(.5,.5),d_=new it;let UO=class{constructor(e=new Gu,n=new Gu,r=new Gu,i=new Gu,a=new Gu,s=new Gu){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],b=a[8],v=a[9],x=a[10],y=a[11],E=a[12],w=a[13],A=a[14],T=a[15];if(i[0].setComponents(u-s,p-d,y-b,T-E).normalize(),i[1].setComponents(u+s,p+d,y+b,T+E).normalize(),i[2].setComponents(u+l,p+f,y+v,T+w).normalize(),i[3].setComponents(u-l,p-f,y-v,T-w).normalize(),r)i[4].setComponents(c,g,x,A).normalize(),i[5].setComponents(u-c,p-g,y-x,T-A).normalize();else if(i[4].setComponents(u-c,p-g,y-x,T-A).normalize(),n===pl)i[5].setComponents(u+c,p+g,y+x,T+A).normalize();else if(n===qw)i[5].setComponents(c,g,x,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(),sh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),sh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(sh)}intersectsSprite(e){sh.center.set(0,0,0);const n=Hke.distanceTo(e.center);return sh.radius=.7071067811865476+n,sh.applyMatrix4(e.matrixWorld),this.intersectsSphere(sh)}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)}},qZ=class extends vg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Nn(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 Xw=new it,Yw=new it,zH=new mi,Dx=new LO,h_=new nE,aC=new it,BH=new it;let $ke=class extends Ds{constructor(e=new Ll,n=new qZ){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++)Xw.fromBufferAttribute(n,i-1),Yw.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=Xw.distanceTo(Yw);e.setAttribute("lineDistance",new $o(r,1))}else nn("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;zH.copy(i).invert(),Dx.copy(e.ray).applyMatrix4(zH);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),b=Math.min(d.count,s.start+s.count);for(let v=p,x=b-1;v<x;v+=u){const y=d.getX(v),E=d.getX(v+1),w=f_(this,e,Dx,c,y,E,v);w&&n.push(w)}if(this.isLineLoop){const v=d.getX(b-1),x=d.getX(p),y=f_(this,e,Dx,c,v,x,b-1);y&&n.push(y)}}else{const p=Math.max(0,s.start),b=Math.min(g.count,s.start+s.count);for(let v=p,x=b-1;v<x;v+=u){const y=f_(this,e,Dx,c,v,v+1,v);y&&n.push(y)}if(this.isLineLoop){const v=f_(this,e,Dx,c,b-1,p,b-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(Xw.fromBufferAttribute(l,i),Yw.fromBufferAttribute(l,a),n.distanceSqToSegment(Xw,Yw,aC,BH)>r)return;aC.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(aC);if(!(u<e.near||u>e.far))return{distance:u,point:BH.clone().applyMatrix4(t.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:t}}const HH=new it,$H=new it;let Vke=class extends $ke{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)HH.fromBufferAttribute(n,i),$H.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+HH.distanceTo($H);e.setAttribute("lineDistance",new $o(r,1))}else nn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},KZ=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 OO(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 XZ extends Yo{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let zO=class YZ 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=[],b=[],v=[],x=[];for(let y=0;y<d;y++){const E=y*g-s;for(let w=0;w<u;w++){const A=w*f-a;b.push(A,-E,0),v.push(0,0,1),x.push(w/l),x.push(1-y/c)}}for(let y=0;y<c;y++)for(let E=0;E<l;E++){const w=E+u*y,A=E+u*(y+1),T=E+1+u*(y+1),C=E+1+u*y;p.push(w,A,C),p.push(A,T,C)}this.setIndex(p),this.setAttribute("position",new $o(b,3)),this.setAttribute("normal",new $o(v,3)),this.setAttribute("uv",new $o(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new YZ(e.width,e.height,e.widthSegments,e.heightSegments)}};class Gke extends vg{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Nn(16777215),this.specular=new Nn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Nn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=CZ,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Nd,this.combine=TO,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 Wke=class extends vg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=eke,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}},qke=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}},ZZ=class extends Ds{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Nn(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 sC=new mi,VH=new it,GH=new it;let Kke=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new bn(512,512),this.mapType=Al,this.map=null,this.mapPass=null,this.matrix=new mi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new UO,this._frameExtents=new bn(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;VH.setFromMatrixPosition(e.matrixWorld),n.position.copy(VH),GH.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(GH),n.updateMatrixWorld(),sC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sC,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(sC)}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}},QZ=class extends GZ{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 Xke extends Kke{constructor(){super(new QZ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class WH extends ZZ{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 Xke}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let Yke=class extends ZZ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},Zke=class extends no{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},qH=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=Tn(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(Tn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class Qke extends Vke{constructor(e=10,n=10,r=4473924,i=8947848){r=new Nn(r),i=new Nn(i);const a=n/2,s=e/n,l=e/2,c=[],u=[];for(let g=0,p=0,b=-l;g<=n;g++,b+=s){c.push(-l,0,b,l,0,b),c.push(b,0,-l,b,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 qZ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Jke 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){nn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function KH(t,e,n,r){const i=e3e(r);switch(n){case AZ:return t*e;case NZ:return t*e/i.components*i.byteLength;case PO:return t*e/i.components*i.byteLength;case jO:return t*e*2/i.components*i.byteLength;case RO:return t*e*2/i.components*i.byteLength;case TZ:return t*e*3/i.components*i.byteLength;case Fo:return t*e*4/i.components*i.byteLength;case DO:return t*e*4/i.components*i.byteLength;case S1:case M1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case E1:case A1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case wP:case MP:return Math.max(t,16)*Math.max(e,8)/4;case _P:case SP:return Math.max(t,8)*Math.max(e,8)/2;case EP:case AP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case TP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case NP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case CP:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case kP:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case PP:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case jP:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case RP:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case DP:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case OP:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case LP:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case IP:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case FP:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case UP:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case zP:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case BP:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case HP:case $P:case VP:return Math.ceil(t/4)*Math.ceil(e/4)*16;case GP:case WP:return Math.ceil(t/4)*Math.ceil(e/4)*8;case qP:case KP:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function e3e(t){switch(t){case Al:case wZ:return{byteLength:1,components:1};case J0:case SZ:case yg:return{byteLength:2,components:1};case CO:case kO:return{byteLength:2,components:4};case mf:case NO:case Nc:return{byteLength:4,components:1};case MZ:case EZ:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:AO}}));typeof window<"u"&&(window.__THREE__?nn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=AO);function JZ(){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 t3e(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,b)=>p.start-b.start);let g=0;for(let p=1;p<f.length;p++){const b=f[g],v=f[p];v.start<=b.start+b.count+1?b.count=Math.max(b.count,v.start+v.count-b.start):(++g,f[g]=v)}f.length=g+1;for(let p=0,b=f.length;p<b;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 n3e=`#ifdef USE_ALPHAHASH
  114. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  115. #endif`,r3e=`#ifdef USE_ALPHAHASH
  116. const float ALPHA_HASH_SCALE = 0.05;
  117. float hash2D( vec2 value ) {
  118. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  119. }
  120. float hash3D( vec3 value ) {
  121. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  122. }
  123. float getAlphaHashThreshold( vec3 position ) {
  124. float maxDeriv = max(
  125. length( dFdx( position.xyz ) ),
  126. length( dFdy( position.xyz ) )
  127. );
  128. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  129. vec2 pixScales = vec2(
  130. exp2( floor( log2( pixScale ) ) ),
  131. exp2( ceil( log2( pixScale ) ) )
  132. );
  133. vec2 alpha = vec2(
  134. hash3D( floor( pixScales.x * position.xyz ) ),
  135. hash3D( floor( pixScales.y * position.xyz ) )
  136. );
  137. float lerpFactor = fract( log2( pixScale ) );
  138. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  139. float a = min( lerpFactor, 1.0 - lerpFactor );
  140. vec3 cases = vec3(
  141. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  142. ( x - 0.5 * a ) / ( 1.0 - a ),
  143. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  144. );
  145. float threshold = ( x < ( 1.0 - a ) )
  146. ? ( ( x < a ) ? cases.x : cases.y )
  147. : cases.z;
  148. return clamp( threshold , 1.0e-6, 1.0 );
  149. }
  150. #endif`,i3e=`#ifdef USE_ALPHAMAP
  151. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  152. #endif`,a3e=`#ifdef USE_ALPHAMAP
  153. uniform sampler2D alphaMap;
  154. #endif`,s3e=`#ifdef USE_ALPHATEST
  155. #ifdef ALPHA_TO_COVERAGE
  156. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  157. if ( diffuseColor.a == 0.0 ) discard;
  158. #else
  159. if ( diffuseColor.a < alphaTest ) discard;
  160. #endif
  161. #endif`,o3e=`#ifdef USE_ALPHATEST
  162. uniform float alphaTest;
  163. #endif`,l3e=`#ifdef USE_AOMAP
  164. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  165. reflectedLight.indirectDiffuse *= ambientOcclusion;
  166. #if defined( USE_CLEARCOAT )
  167. clearcoatSpecularIndirect *= ambientOcclusion;
  168. #endif
  169. #if defined( USE_SHEEN )
  170. sheenSpecularIndirect *= ambientOcclusion;
  171. #endif
  172. #if defined( USE_ENVMAP ) && defined( STANDARD )
  173. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  174. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  175. #endif
  176. #endif`,c3e=`#ifdef USE_AOMAP
  177. uniform sampler2D aoMap;
  178. uniform float aoMapIntensity;
  179. #endif`,u3e=`#ifdef USE_BATCHING
  180. #if ! defined( GL_ANGLE_multi_draw )
  181. #define gl_DrawID _gl_DrawID
  182. uniform int _gl_DrawID;
  183. #endif
  184. uniform highp sampler2D batchingTexture;
  185. uniform highp usampler2D batchingIdTexture;
  186. mat4 getBatchingMatrix( const in float i ) {
  187. int size = textureSize( batchingTexture, 0 ).x;
  188. int j = int( i ) * 4;
  189. int x = j % size;
  190. int y = j / size;
  191. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  192. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  193. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  194. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  195. return mat4( v1, v2, v3, v4 );
  196. }
  197. float getIndirectIndex( const in int i ) {
  198. int size = textureSize( batchingIdTexture, 0 ).x;
  199. int x = i % size;
  200. int y = i / size;
  201. return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
  202. }
  203. #endif
  204. #ifdef USE_BATCHING_COLOR
  205. uniform sampler2D batchingColorTexture;
  206. vec3 getBatchingColor( const in float i ) {
  207. int size = textureSize( batchingColorTexture, 0 ).x;
  208. int j = int( i );
  209. int x = j % size;
  210. int y = j / size;
  211. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  212. }
  213. #endif`,d3e=`#ifdef USE_BATCHING
  214. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  215. #endif`,h3e=`vec3 transformed = vec3( position );
  216. #ifdef USE_ALPHAHASH
  217. vPosition = vec3( position );
  218. #endif`,f3e=`vec3 objectNormal = vec3( normal );
  219. #ifdef USE_TANGENT
  220. vec3 objectTangent = vec3( tangent.xyz );
  221. #endif`,m3e=`float G_BlinnPhong_Implicit( ) {
  222. return 0.25;
  223. }
  224. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  225. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  226. }
  227. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  228. vec3 halfDir = normalize( lightDir + viewDir );
  229. float dotNH = saturate( dot( normal, halfDir ) );
  230. float dotVH = saturate( dot( viewDir, halfDir ) );
  231. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  232. float G = G_BlinnPhong_Implicit( );
  233. float D = D_BlinnPhong( shininess, dotNH );
  234. return F * ( G * D );
  235. } // validated`,p3e=`#ifdef USE_IRIDESCENCE
  236. const mat3 XYZ_TO_REC709 = mat3(
  237. 3.2404542, -0.9692660, 0.0556434,
  238. -1.5371385, 1.8760108, -0.2040259,
  239. -0.4985314, 0.0415560, 1.0572252
  240. );
  241. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  242. vec3 sqrtF0 = sqrt( fresnel0 );
  243. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  244. }
  245. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  246. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  247. }
  248. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  249. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  250. }
  251. vec3 evalSensitivity( float OPD, vec3 shift ) {
  252. float phase = 2.0 * PI * OPD * 1.0e-9;
  253. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  254. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  255. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  256. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  257. 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 ) );
  258. xyz /= 1.0685e-7;
  259. vec3 rgb = XYZ_TO_REC709 * xyz;
  260. return rgb;
  261. }
  262. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  263. vec3 I;
  264. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  265. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  266. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  267. if ( cosTheta2Sq < 0.0 ) {
  268. return vec3( 1.0 );
  269. }
  270. float cosTheta2 = sqrt( cosTheta2Sq );
  271. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  272. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  273. float T121 = 1.0 - R12;
  274. float phi12 = 0.0;
  275. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  276. float phi21 = PI - phi12;
  277. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  278. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  279. vec3 phi23 = vec3( 0.0 );
  280. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  281. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  282. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  283. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  284. vec3 phi = vec3( phi21 ) + phi23;
  285. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  286. vec3 r123 = sqrt( R123 );
  287. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  288. vec3 C0 = R12 + Rs;
  289. I = C0;
  290. vec3 Cm = Rs - T121;
  291. for ( int m = 1; m <= 2; ++ m ) {
  292. Cm *= r123;
  293. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  294. I += Cm * Sm;
  295. }
  296. return max( I, vec3( 0.0 ) );
  297. }
  298. #endif`,g3e=`#ifdef USE_BUMPMAP
  299. uniform sampler2D bumpMap;
  300. uniform float bumpScale;
  301. vec2 dHdxy_fwd() {
  302. vec2 dSTdx = dFdx( vBumpMapUv );
  303. vec2 dSTdy = dFdy( vBumpMapUv );
  304. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  305. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  306. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  307. return vec2( dBx, dBy );
  308. }
  309. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  310. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  311. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  312. vec3 vN = surf_norm;
  313. vec3 R1 = cross( vSigmaY, vN );
  314. vec3 R2 = cross( vN, vSigmaX );
  315. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  316. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  317. return normalize( abs( fDet ) * surf_norm - vGrad );
  318. }
  319. #endif`,x3e=`#if NUM_CLIPPING_PLANES > 0
  320. vec4 plane;
  321. #ifdef ALPHA_TO_COVERAGE
  322. float distanceToPlane, distanceGradient;
  323. float clipOpacity = 1.0;
  324. #pragma unroll_loop_start
  325. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  326. plane = clippingPlanes[ i ];
  327. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  328. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  329. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  330. if ( clipOpacity == 0.0 ) discard;
  331. }
  332. #pragma unroll_loop_end
  333. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  334. float unionClipOpacity = 1.0;
  335. #pragma unroll_loop_start
  336. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  337. plane = clippingPlanes[ i ];
  338. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  339. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  340. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  341. }
  342. #pragma unroll_loop_end
  343. clipOpacity *= 1.0 - unionClipOpacity;
  344. #endif
  345. diffuseColor.a *= clipOpacity;
  346. if ( diffuseColor.a == 0.0 ) discard;
  347. #else
  348. #pragma unroll_loop_start
  349. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  350. plane = clippingPlanes[ i ];
  351. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  352. }
  353. #pragma unroll_loop_end
  354. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  355. bool clipped = true;
  356. #pragma unroll_loop_start
  357. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  358. plane = clippingPlanes[ i ];
  359. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  360. }
  361. #pragma unroll_loop_end
  362. if ( clipped ) discard;
  363. #endif
  364. #endif
  365. #endif`,b3e=`#if NUM_CLIPPING_PLANES > 0
  366. varying vec3 vClipPosition;
  367. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  368. #endif`,y3e=`#if NUM_CLIPPING_PLANES > 0
  369. varying vec3 vClipPosition;
  370. #endif`,v3e=`#if NUM_CLIPPING_PLANES > 0
  371. vClipPosition = - mvPosition.xyz;
  372. #endif`,_3e=`#if defined( USE_COLOR_ALPHA )
  373. diffuseColor *= vColor;
  374. #elif defined( USE_COLOR )
  375. diffuseColor.rgb *= vColor;
  376. #endif`,w3e=`#if defined( USE_COLOR_ALPHA )
  377. varying vec4 vColor;
  378. #elif defined( USE_COLOR )
  379. varying vec3 vColor;
  380. #endif`,S3e=`#if defined( USE_COLOR_ALPHA )
  381. varying vec4 vColor;
  382. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  383. varying vec3 vColor;
  384. #endif`,M3e=`#if defined( USE_COLOR_ALPHA )
  385. vColor = vec4( 1.0 );
  386. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  387. vColor = vec3( 1.0 );
  388. #endif
  389. #ifdef USE_COLOR
  390. vColor *= color;
  391. #endif
  392. #ifdef USE_INSTANCING_COLOR
  393. vColor.xyz *= instanceColor.xyz;
  394. #endif
  395. #ifdef USE_BATCHING_COLOR
  396. vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
  397. vColor.xyz *= batchingColor.xyz;
  398. #endif`,E3e=`#define PI 3.141592653589793
  399. #define PI2 6.283185307179586
  400. #define PI_HALF 1.5707963267948966
  401. #define RECIPROCAL_PI 0.3183098861837907
  402. #define RECIPROCAL_PI2 0.15915494309189535
  403. #define EPSILON 1e-6
  404. #ifndef saturate
  405. #define saturate( a ) clamp( a, 0.0, 1.0 )
  406. #endif
  407. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  408. float pow2( const in float x ) { return x*x; }
  409. vec3 pow2( const in vec3 x ) { return x*x; }
  410. float pow3( const in float x ) { return x*x*x; }
  411. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  412. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  413. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  414. highp float rand( const in vec2 uv ) {
  415. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  416. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  417. return fract( sin( sn ) * c );
  418. }
  419. #ifdef HIGH_PRECISION
  420. float precisionSafeLength( vec3 v ) { return length( v ); }
  421. #else
  422. float precisionSafeLength( vec3 v ) {
  423. float maxComponent = max3( abs( v ) );
  424. return length( v / maxComponent ) * maxComponent;
  425. }
  426. #endif
  427. struct IncidentLight {
  428. vec3 color;
  429. vec3 direction;
  430. bool visible;
  431. };
  432. struct ReflectedLight {
  433. vec3 directDiffuse;
  434. vec3 directSpecular;
  435. vec3 indirectDiffuse;
  436. vec3 indirectSpecular;
  437. };
  438. #ifdef USE_ALPHAHASH
  439. varying vec3 vPosition;
  440. #endif
  441. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  442. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  443. }
  444. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  445. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  446. }
  447. bool isPerspectiveMatrix( mat4 m ) {
  448. return m[ 2 ][ 3 ] == - 1.0;
  449. }
  450. vec2 equirectUv( in vec3 dir ) {
  451. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  452. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  453. return vec2( u, v );
  454. }
  455. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  456. return RECIPROCAL_PI * diffuseColor;
  457. }
  458. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  459. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  460. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  461. }
  462. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  463. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  464. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  465. } // validated`,A3e=`#ifdef ENVMAP_TYPE_CUBE_UV
  466. #define cubeUV_minMipLevel 4.0
  467. #define cubeUV_minTileSize 16.0
  468. float getFace( vec3 direction ) {
  469. vec3 absDirection = abs( direction );
  470. float face = - 1.0;
  471. if ( absDirection.x > absDirection.z ) {
  472. if ( absDirection.x > absDirection.y )
  473. face = direction.x > 0.0 ? 0.0 : 3.0;
  474. else
  475. face = direction.y > 0.0 ? 1.0 : 4.0;
  476. } else {
  477. if ( absDirection.z > absDirection.y )
  478. face = direction.z > 0.0 ? 2.0 : 5.0;
  479. else
  480. face = direction.y > 0.0 ? 1.0 : 4.0;
  481. }
  482. return face;
  483. }
  484. vec2 getUV( vec3 direction, float face ) {
  485. vec2 uv;
  486. if ( face == 0.0 ) {
  487. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  488. } else if ( face == 1.0 ) {
  489. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  490. } else if ( face == 2.0 ) {
  491. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  492. } else if ( face == 3.0 ) {
  493. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  494. } else if ( face == 4.0 ) {
  495. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  496. } else {
  497. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  498. }
  499. return 0.5 * ( uv + 1.0 );
  500. }
  501. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  502. float face = getFace( direction );
  503. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  504. mipInt = max( mipInt, cubeUV_minMipLevel );
  505. float faceSize = exp2( mipInt );
  506. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  507. if ( face > 2.0 ) {
  508. uv.y += faceSize;
  509. face -= 3.0;
  510. }
  511. uv.x += face * faceSize;
  512. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  513. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  514. uv.x *= CUBEUV_TEXEL_WIDTH;
  515. uv.y *= CUBEUV_TEXEL_HEIGHT;
  516. #ifdef texture2DGradEXT
  517. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  518. #else
  519. return texture2D( envMap, uv ).rgb;
  520. #endif
  521. }
  522. #define cubeUV_r0 1.0
  523. #define cubeUV_m0 - 2.0
  524. #define cubeUV_r1 0.8
  525. #define cubeUV_m1 - 1.0
  526. #define cubeUV_r4 0.4
  527. #define cubeUV_m4 2.0
  528. #define cubeUV_r5 0.305
  529. #define cubeUV_m5 3.0
  530. #define cubeUV_r6 0.21
  531. #define cubeUV_m6 4.0
  532. float roughnessToMip( float roughness ) {
  533. float mip = 0.0;
  534. if ( roughness >= cubeUV_r1 ) {
  535. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  536. } else if ( roughness >= cubeUV_r4 ) {
  537. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  538. } else if ( roughness >= cubeUV_r5 ) {
  539. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  540. } else if ( roughness >= cubeUV_r6 ) {
  541. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  542. } else {
  543. mip = - 2.0 * log2( 1.16 * roughness ); }
  544. return mip;
  545. }
  546. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  547. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  548. float mipF = fract( mip );
  549. float mipInt = floor( mip );
  550. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  551. if ( mipF == 0.0 ) {
  552. return vec4( color0, 1.0 );
  553. } else {
  554. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  555. return vec4( mix( color0, color1, mipF ), 1.0 );
  556. }
  557. }
  558. #endif`,T3e=`vec3 transformedNormal = objectNormal;
  559. #ifdef USE_TANGENT
  560. vec3 transformedTangent = objectTangent;
  561. #endif
  562. #ifdef USE_BATCHING
  563. mat3 bm = mat3( batchingMatrix );
  564. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  565. transformedNormal = bm * transformedNormal;
  566. #ifdef USE_TANGENT
  567. transformedTangent = bm * transformedTangent;
  568. #endif
  569. #endif
  570. #ifdef USE_INSTANCING
  571. mat3 im = mat3( instanceMatrix );
  572. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  573. transformedNormal = im * transformedNormal;
  574. #ifdef USE_TANGENT
  575. transformedTangent = im * transformedTangent;
  576. #endif
  577. #endif
  578. transformedNormal = normalMatrix * transformedNormal;
  579. #ifdef FLIP_SIDED
  580. transformedNormal = - transformedNormal;
  581. #endif
  582. #ifdef USE_TANGENT
  583. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  584. #ifdef FLIP_SIDED
  585. transformedTangent = - transformedTangent;
  586. #endif
  587. #endif`,N3e=`#ifdef USE_DISPLACEMENTMAP
  588. uniform sampler2D displacementMap;
  589. uniform float displacementScale;
  590. uniform float displacementBias;
  591. #endif`,C3e=`#ifdef USE_DISPLACEMENTMAP
  592. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  593. #endif`,k3e=`#ifdef USE_EMISSIVEMAP
  594. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  595. #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
  596. emissiveColor = sRGBTransferEOTF( emissiveColor );
  597. #endif
  598. totalEmissiveRadiance *= emissiveColor.rgb;
  599. #endif`,P3e=`#ifdef USE_EMISSIVEMAP
  600. uniform sampler2D emissiveMap;
  601. #endif`,j3e="gl_FragColor = linearToOutputTexel( gl_FragColor );",R3e=`vec4 LinearTransferOETF( in vec4 value ) {
  602. return value;
  603. }
  604. vec4 sRGBTransferEOTF( in vec4 value ) {
  605. 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 );
  606. }
  607. vec4 sRGBTransferOETF( in vec4 value ) {
  608. 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 );
  609. }`,D3e=`#ifdef USE_ENVMAP
  610. #ifdef ENV_WORLDPOS
  611. vec3 cameraToFrag;
  612. if ( isOrthographic ) {
  613. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  614. } else {
  615. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  616. }
  617. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  618. #ifdef ENVMAP_MODE_REFLECTION
  619. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  620. #else
  621. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  622. #endif
  623. #else
  624. vec3 reflectVec = vReflect;
  625. #endif
  626. #ifdef ENVMAP_TYPE_CUBE
  627. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  628. #else
  629. vec4 envColor = vec4( 0.0 );
  630. #endif
  631. #ifdef ENVMAP_BLENDING_MULTIPLY
  632. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  633. #elif defined( ENVMAP_BLENDING_MIX )
  634. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  635. #elif defined( ENVMAP_BLENDING_ADD )
  636. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  637. #endif
  638. #endif`,O3e=`#ifdef USE_ENVMAP
  639. uniform float envMapIntensity;
  640. uniform float flipEnvMap;
  641. uniform mat3 envMapRotation;
  642. #ifdef ENVMAP_TYPE_CUBE
  643. uniform samplerCube envMap;
  644. #else
  645. uniform sampler2D envMap;
  646. #endif
  647. #endif`,L3e=`#ifdef USE_ENVMAP
  648. uniform float reflectivity;
  649. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  650. #define ENV_WORLDPOS
  651. #endif
  652. #ifdef ENV_WORLDPOS
  653. varying vec3 vWorldPosition;
  654. uniform float refractionRatio;
  655. #else
  656. varying vec3 vReflect;
  657. #endif
  658. #endif`,I3e=`#ifdef USE_ENVMAP
  659. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  660. #define ENV_WORLDPOS
  661. #endif
  662. #ifdef ENV_WORLDPOS
  663. varying vec3 vWorldPosition;
  664. #else
  665. varying vec3 vReflect;
  666. uniform float refractionRatio;
  667. #endif
  668. #endif`,F3e=`#ifdef USE_ENVMAP
  669. #ifdef ENV_WORLDPOS
  670. vWorldPosition = worldPosition.xyz;
  671. #else
  672. vec3 cameraToVertex;
  673. if ( isOrthographic ) {
  674. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  675. } else {
  676. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  677. }
  678. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  679. #ifdef ENVMAP_MODE_REFLECTION
  680. vReflect = reflect( cameraToVertex, worldNormal );
  681. #else
  682. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  683. #endif
  684. #endif
  685. #endif`,U3e=`#ifdef USE_FOG
  686. vFogDepth = - mvPosition.z;
  687. #endif`,z3e=`#ifdef USE_FOG
  688. varying float vFogDepth;
  689. #endif`,B3e=`#ifdef USE_FOG
  690. #ifdef FOG_EXP2
  691. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  692. #else
  693. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  694. #endif
  695. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  696. #endif`,H3e=`#ifdef USE_FOG
  697. uniform vec3 fogColor;
  698. varying float vFogDepth;
  699. #ifdef FOG_EXP2
  700. uniform float fogDensity;
  701. #else
  702. uniform float fogNear;
  703. uniform float fogFar;
  704. #endif
  705. #endif`,$3e=`#ifdef USE_GRADIENTMAP
  706. uniform sampler2D gradientMap;
  707. #endif
  708. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  709. float dotNL = dot( normal, lightDirection );
  710. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  711. #ifdef USE_GRADIENTMAP
  712. return vec3( texture2D( gradientMap, coord ).r );
  713. #else
  714. vec2 fw = fwidth( coord ) * 0.5;
  715. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  716. #endif
  717. }`,V3e=`#ifdef USE_LIGHTMAP
  718. uniform sampler2D lightMap;
  719. uniform float lightMapIntensity;
  720. #endif`,G3e=`LambertMaterial material;
  721. material.diffuseColor = diffuseColor.rgb;
  722. material.specularStrength = specularStrength;`,W3e=`varying vec3 vViewPosition;
  723. struct LambertMaterial {
  724. vec3 diffuseColor;
  725. float specularStrength;
  726. };
  727. 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 ) {
  728. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  729. vec3 irradiance = dotNL * directLight.color;
  730. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  731. }
  732. 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 ) {
  733. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  734. }
  735. #define RE_Direct RE_Direct_Lambert
  736. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,q3e=`uniform bool receiveShadow;
  737. uniform vec3 ambientLightColor;
  738. #if defined( USE_LIGHT_PROBES )
  739. uniform vec3 lightProbe[ 9 ];
  740. #endif
  741. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  742. float x = normal.x, y = normal.y, z = normal.z;
  743. vec3 result = shCoefficients[ 0 ] * 0.886227;
  744. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  745. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  746. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  747. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  748. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  749. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  750. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  751. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  752. return result;
  753. }
  754. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  755. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  756. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  757. return irradiance;
  758. }
  759. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  760. vec3 irradiance = ambientLightColor;
  761. return irradiance;
  762. }
  763. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  764. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  765. if ( cutoffDistance > 0.0 ) {
  766. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  767. }
  768. return distanceFalloff;
  769. }
  770. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  771. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  772. }
  773. #if NUM_DIR_LIGHTS > 0
  774. struct DirectionalLight {
  775. vec3 direction;
  776. vec3 color;
  777. };
  778. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  779. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  780. light.color = directionalLight.color;
  781. light.direction = directionalLight.direction;
  782. light.visible = true;
  783. }
  784. #endif
  785. #if NUM_POINT_LIGHTS > 0
  786. struct PointLight {
  787. vec3 position;
  788. vec3 color;
  789. float distance;
  790. float decay;
  791. };
  792. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  793. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  794. vec3 lVector = pointLight.position - geometryPosition;
  795. light.direction = normalize( lVector );
  796. float lightDistance = length( lVector );
  797. light.color = pointLight.color;
  798. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  799. light.visible = ( light.color != vec3( 0.0 ) );
  800. }
  801. #endif
  802. #if NUM_SPOT_LIGHTS > 0
  803. struct SpotLight {
  804. vec3 position;
  805. vec3 direction;
  806. vec3 color;
  807. float distance;
  808. float decay;
  809. float coneCos;
  810. float penumbraCos;
  811. };
  812. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  813. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  814. vec3 lVector = spotLight.position - geometryPosition;
  815. light.direction = normalize( lVector );
  816. float angleCos = dot( light.direction, spotLight.direction );
  817. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  818. if ( spotAttenuation > 0.0 ) {
  819. float lightDistance = length( lVector );
  820. light.color = spotLight.color * spotAttenuation;
  821. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  822. light.visible = ( light.color != vec3( 0.0 ) );
  823. } else {
  824. light.color = vec3( 0.0 );
  825. light.visible = false;
  826. }
  827. }
  828. #endif
  829. #if NUM_RECT_AREA_LIGHTS > 0
  830. struct RectAreaLight {
  831. vec3 color;
  832. vec3 position;
  833. vec3 halfWidth;
  834. vec3 halfHeight;
  835. };
  836. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  837. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  838. #endif
  839. #if NUM_HEMI_LIGHTS > 0
  840. struct HemisphereLight {
  841. vec3 direction;
  842. vec3 skyColor;
  843. vec3 groundColor;
  844. };
  845. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  846. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  847. float dotNL = dot( normal, hemiLight.direction );
  848. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  849. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  850. return irradiance;
  851. }
  852. #endif`,K3e=`#ifdef USE_ENVMAP
  853. vec3 getIBLIrradiance( const in vec3 normal ) {
  854. #ifdef ENVMAP_TYPE_CUBE_UV
  855. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  856. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  857. return PI * envMapColor.rgb * envMapIntensity;
  858. #else
  859. return vec3( 0.0 );
  860. #endif
  861. }
  862. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  863. #ifdef ENVMAP_TYPE_CUBE_UV
  864. vec3 reflectVec = reflect( - viewDir, normal );
  865. reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
  866. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  867. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  868. return envMapColor.rgb * envMapIntensity;
  869. #else
  870. return vec3( 0.0 );
  871. #endif
  872. }
  873. #ifdef USE_ANISOTROPY
  874. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  875. #ifdef ENVMAP_TYPE_CUBE_UV
  876. vec3 bentNormal = cross( bitangent, viewDir );
  877. bentNormal = normalize( cross( bentNormal, bitangent ) );
  878. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  879. return getIBLRadiance( viewDir, bentNormal, roughness );
  880. #else
  881. return vec3( 0.0 );
  882. #endif
  883. }
  884. #endif
  885. #endif`,X3e=`ToonMaterial material;
  886. material.diffuseColor = diffuseColor.rgb;`,Y3e=`varying vec3 vViewPosition;
  887. struct ToonMaterial {
  888. vec3 diffuseColor;
  889. };
  890. 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 ) {
  891. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  892. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  893. }
  894. 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 ) {
  895. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  896. }
  897. #define RE_Direct RE_Direct_Toon
  898. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Z3e=`BlinnPhongMaterial material;
  899. material.diffuseColor = diffuseColor.rgb;
  900. material.specularColor = specular;
  901. material.specularShininess = shininess;
  902. material.specularStrength = specularStrength;`,Q3e=`varying vec3 vViewPosition;
  903. struct BlinnPhongMaterial {
  904. vec3 diffuseColor;
  905. vec3 specularColor;
  906. float specularShininess;
  907. float specularStrength;
  908. };
  909. 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 ) {
  910. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  911. vec3 irradiance = dotNL * directLight.color;
  912. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  913. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  914. }
  915. 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 ) {
  916. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  917. }
  918. #define RE_Direct RE_Direct_BlinnPhong
  919. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,J3e=`PhysicalMaterial material;
  920. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  921. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  922. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  923. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  924. material.roughness = min( material.roughness, 1.0 );
  925. #ifdef IOR
  926. material.ior = ior;
  927. #ifdef USE_SPECULAR
  928. float specularIntensityFactor = specularIntensity;
  929. vec3 specularColorFactor = specularColor;
  930. #ifdef USE_SPECULAR_COLORMAP
  931. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  932. #endif
  933. #ifdef USE_SPECULAR_INTENSITYMAP
  934. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  935. #endif
  936. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  937. #else
  938. float specularIntensityFactor = 1.0;
  939. vec3 specularColorFactor = vec3( 1.0 );
  940. material.specularF90 = 1.0;
  941. #endif
  942. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  943. #else
  944. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  945. material.specularF90 = 1.0;
  946. #endif
  947. #ifdef USE_CLEARCOAT
  948. material.clearcoat = clearcoat;
  949. material.clearcoatRoughness = clearcoatRoughness;
  950. material.clearcoatF0 = vec3( 0.04 );
  951. material.clearcoatF90 = 1.0;
  952. #ifdef USE_CLEARCOATMAP
  953. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  954. #endif
  955. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  956. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  957. #endif
  958. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  959. material.clearcoatRoughness += geometryRoughness;
  960. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  961. #endif
  962. #ifdef USE_DISPERSION
  963. material.dispersion = dispersion;
  964. #endif
  965. #ifdef USE_IRIDESCENCE
  966. material.iridescence = iridescence;
  967. material.iridescenceIOR = iridescenceIOR;
  968. #ifdef USE_IRIDESCENCEMAP
  969. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  970. #endif
  971. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  972. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  973. #else
  974. material.iridescenceThickness = iridescenceThicknessMaximum;
  975. #endif
  976. #endif
  977. #ifdef USE_SHEEN
  978. material.sheenColor = sheenColor;
  979. #ifdef USE_SHEEN_COLORMAP
  980. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  981. #endif
  982. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  983. #ifdef USE_SHEEN_ROUGHNESSMAP
  984. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  985. #endif
  986. #endif
  987. #ifdef USE_ANISOTROPY
  988. #ifdef USE_ANISOTROPYMAP
  989. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  990. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  991. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  992. #else
  993. vec2 anisotropyV = anisotropyVector;
  994. #endif
  995. material.anisotropy = length( anisotropyV );
  996. if( material.anisotropy == 0.0 ) {
  997. anisotropyV = vec2( 1.0, 0.0 );
  998. } else {
  999. anisotropyV /= material.anisotropy;
  1000. material.anisotropy = saturate( material.anisotropy );
  1001. }
  1002. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  1003. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  1004. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  1005. #endif`,ePe=`uniform sampler2D dfgLUT;
  1006. struct PhysicalMaterial {
  1007. vec3 diffuseColor;
  1008. float roughness;
  1009. vec3 specularColor;
  1010. float specularF90;
  1011. float dispersion;
  1012. #ifdef USE_CLEARCOAT
  1013. float clearcoat;
  1014. float clearcoatRoughness;
  1015. vec3 clearcoatF0;
  1016. float clearcoatF90;
  1017. #endif
  1018. #ifdef USE_IRIDESCENCE
  1019. float iridescence;
  1020. float iridescenceIOR;
  1021. float iridescenceThickness;
  1022. vec3 iridescenceFresnel;
  1023. vec3 iridescenceF0;
  1024. #endif
  1025. #ifdef USE_SHEEN
  1026. vec3 sheenColor;
  1027. float sheenRoughness;
  1028. #endif
  1029. #ifdef IOR
  1030. float ior;
  1031. #endif
  1032. #ifdef USE_TRANSMISSION
  1033. float transmission;
  1034. float transmissionAlpha;
  1035. float thickness;
  1036. float attenuationDistance;
  1037. vec3 attenuationColor;
  1038. #endif
  1039. #ifdef USE_ANISOTROPY
  1040. float anisotropy;
  1041. float alphaT;
  1042. vec3 anisotropyT;
  1043. vec3 anisotropyB;
  1044. #endif
  1045. };
  1046. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  1047. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  1048. vec3 sheenSpecularDirect = vec3( 0.0 );
  1049. vec3 sheenSpecularIndirect = vec3(0.0 );
  1050. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  1051. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  1052. float x2 = x * x;
  1053. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  1054. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  1055. }
  1056. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  1057. float a2 = pow2( alpha );
  1058. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  1059. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  1060. return 0.5 / max( gv + gl, EPSILON );
  1061. }
  1062. float D_GGX( const in float alpha, const in float dotNH ) {
  1063. float a2 = pow2( alpha );
  1064. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  1065. return RECIPROCAL_PI * a2 / pow2( denom );
  1066. }
  1067. #ifdef USE_ANISOTROPY
  1068. 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 ) {
  1069. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  1070. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  1071. float v = 0.5 / ( gv + gl );
  1072. return saturate(v);
  1073. }
  1074. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  1075. float a2 = alphaT * alphaB;
  1076. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  1077. highp float v2 = dot( v, v );
  1078. float w2 = a2 / v2;
  1079. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1080. }
  1081. #endif
  1082. #ifdef USE_CLEARCOAT
  1083. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1084. vec3 f0 = material.clearcoatF0;
  1085. float f90 = material.clearcoatF90;
  1086. float roughness = material.clearcoatRoughness;
  1087. float alpha = pow2( roughness );
  1088. vec3 halfDir = normalize( lightDir + viewDir );
  1089. float dotNL = saturate( dot( normal, lightDir ) );
  1090. float dotNV = saturate( dot( normal, viewDir ) );
  1091. float dotNH = saturate( dot( normal, halfDir ) );
  1092. float dotVH = saturate( dot( viewDir, halfDir ) );
  1093. vec3 F = F_Schlick( f0, f90, dotVH );
  1094. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1095. float D = D_GGX( alpha, dotNH );
  1096. return F * ( V * D );
  1097. }
  1098. #endif
  1099. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1100. vec3 f0 = material.specularColor;
  1101. float f90 = material.specularF90;
  1102. float roughness = material.roughness;
  1103. float alpha = pow2( roughness );
  1104. vec3 halfDir = normalize( lightDir + viewDir );
  1105. float dotNL = saturate( dot( normal, lightDir ) );
  1106. float dotNV = saturate( dot( normal, viewDir ) );
  1107. float dotNH = saturate( dot( normal, halfDir ) );
  1108. float dotVH = saturate( dot( viewDir, halfDir ) );
  1109. vec3 F = F_Schlick( f0, f90, dotVH );
  1110. #ifdef USE_IRIDESCENCE
  1111. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1112. #endif
  1113. #ifdef USE_ANISOTROPY
  1114. float dotTL = dot( material.anisotropyT, lightDir );
  1115. float dotTV = dot( material.anisotropyT, viewDir );
  1116. float dotTH = dot( material.anisotropyT, halfDir );
  1117. float dotBL = dot( material.anisotropyB, lightDir );
  1118. float dotBV = dot( material.anisotropyB, viewDir );
  1119. float dotBH = dot( material.anisotropyB, halfDir );
  1120. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1121. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1122. #else
  1123. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1124. float D = D_GGX( alpha, dotNH );
  1125. #endif
  1126. return F * ( V * D );
  1127. }
  1128. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1129. const float LUT_SIZE = 64.0;
  1130. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1131. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1132. float dotNV = saturate( dot( N, V ) );
  1133. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1134. uv = uv * LUT_SCALE + LUT_BIAS;
  1135. return uv;
  1136. }
  1137. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1138. float l = length( f );
  1139. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1140. }
  1141. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1142. float x = dot( v1, v2 );
  1143. float y = abs( x );
  1144. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1145. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1146. float v = a / b;
  1147. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1148. return cross( v1, v2 ) * theta_sintheta;
  1149. }
  1150. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1151. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1152. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1153. vec3 lightNormal = cross( v1, v2 );
  1154. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1155. vec3 T1, T2;
  1156. T1 = normalize( V - N * dot( V, N ) );
  1157. T2 = - cross( N, T1 );
  1158. mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
  1159. vec3 coords[ 4 ];
  1160. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1161. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1162. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1163. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1164. coords[ 0 ] = normalize( coords[ 0 ] );
  1165. coords[ 1 ] = normalize( coords[ 1 ] );
  1166. coords[ 2 ] = normalize( coords[ 2 ] );
  1167. coords[ 3 ] = normalize( coords[ 3 ] );
  1168. vec3 vectorFormFactor = vec3( 0.0 );
  1169. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1170. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1171. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1172. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1173. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1174. return vec3( result );
  1175. }
  1176. #if defined( USE_SHEEN )
  1177. float D_Charlie( float roughness, float dotNH ) {
  1178. float alpha = pow2( roughness );
  1179. float invAlpha = 1.0 / alpha;
  1180. float cos2h = dotNH * dotNH;
  1181. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1182. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1183. }
  1184. float V_Neubelt( float dotNV, float dotNL ) {
  1185. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1186. }
  1187. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1188. vec3 halfDir = normalize( lightDir + viewDir );
  1189. float dotNL = saturate( dot( normal, lightDir ) );
  1190. float dotNV = saturate( dot( normal, viewDir ) );
  1191. float dotNH = saturate( dot( normal, halfDir ) );
  1192. float D = D_Charlie( sheenRoughness, dotNH );
  1193. float V = V_Neubelt( dotNV, dotNL );
  1194. return sheenColor * ( D * V );
  1195. }
  1196. #endif
  1197. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1198. float dotNV = saturate( dot( normal, viewDir ) );
  1199. float r2 = roughness * roughness;
  1200. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  1201. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  1202. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  1203. return saturate( DG * RECIPROCAL_PI );
  1204. }
  1205. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1206. float dotNV = saturate( dot( normal, viewDir ) );
  1207. vec2 uv = vec2( roughness, dotNV );
  1208. return texture2D( dfgLUT, uv ).rg;
  1209. }
  1210. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1211. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1212. return specularColor * fab.x + specularF90 * fab.y;
  1213. }
  1214. #ifdef USE_IRIDESCENCE
  1215. 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 ) {
  1216. #else
  1217. 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 ) {
  1218. #endif
  1219. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1220. #ifdef USE_IRIDESCENCE
  1221. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1222. #else
  1223. vec3 Fr = specularColor;
  1224. #endif
  1225. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1226. float Ess = fab.x + fab.y;
  1227. float Ems = 1.0 - Ess;
  1228. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1229. singleScatter += FssEss;
  1230. multiScatter += Fms * Ems;
  1231. }
  1232. vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1233. vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
  1234. float dotNL = saturate( dot( normal, lightDir ) );
  1235. float dotNV = saturate( dot( normal, viewDir ) );
  1236. vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
  1237. vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
  1238. vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
  1239. vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
  1240. float Ess_V = dfgV.x + dfgV.y;
  1241. float Ess_L = dfgL.x + dfgL.y;
  1242. float Ems_V = 1.0 - Ess_V;
  1243. float Ems_L = 1.0 - Ess_L;
  1244. vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
  1245. vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
  1246. float compensationFactor = Ems_V * Ems_L;
  1247. vec3 multiScatter = Fms * compensationFactor;
  1248. return singleScatter + multiScatter;
  1249. }
  1250. #if NUM_RECT_AREA_LIGHTS > 0
  1251. 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 ) {
  1252. vec3 normal = geometryNormal;
  1253. vec3 viewDir = geometryViewDir;
  1254. vec3 position = geometryPosition;
  1255. vec3 lightPos = rectAreaLight.position;
  1256. vec3 halfWidth = rectAreaLight.halfWidth;
  1257. vec3 halfHeight = rectAreaLight.halfHeight;
  1258. vec3 lightColor = rectAreaLight.color;
  1259. float roughness = material.roughness;
  1260. vec3 rectCoords[ 4 ];
  1261. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1262. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1263. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1264. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1265. vec4 t1 = texture2D( ltc_1, uv );
  1266. vec4 t2 = texture2D( ltc_2, uv );
  1267. mat3 mInv = mat3(
  1268. vec3( t1.x, 0, t1.y ),
  1269. vec3( 0, 1, 0 ),
  1270. vec3( t1.z, 0, t1.w )
  1271. );
  1272. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1273. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1274. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1275. }
  1276. #endif
  1277. 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 ) {
  1278. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1279. vec3 irradiance = dotNL * directLight.color;
  1280. #ifdef USE_CLEARCOAT
  1281. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1282. vec3 ccIrradiance = dotNLcc * directLight.color;
  1283. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1284. #endif
  1285. #ifdef USE_SHEEN
  1286. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1287. #endif
  1288. reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
  1289. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1290. }
  1291. 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 ) {
  1292. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1293. }
  1294. 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) {
  1295. #ifdef USE_CLEARCOAT
  1296. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1297. #endif
  1298. #ifdef USE_SHEEN
  1299. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1300. #endif
  1301. vec3 singleScattering = vec3( 0.0 );
  1302. vec3 multiScattering = vec3( 0.0 );
  1303. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1304. #ifdef USE_IRIDESCENCE
  1305. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1306. #else
  1307. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1308. #endif
  1309. vec3 totalScattering = singleScattering + multiScattering;
  1310. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1311. reflectedLight.indirectSpecular += radiance * singleScattering;
  1312. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1313. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1314. }
  1315. #define RE_Direct RE_Direct_Physical
  1316. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1317. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1318. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1319. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1320. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1321. }`,tPe=`
  1322. vec3 geometryPosition = - vViewPosition;
  1323. vec3 geometryNormal = normal;
  1324. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1325. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1326. #ifdef USE_CLEARCOAT
  1327. geometryClearcoatNormal = clearcoatNormal;
  1328. #endif
  1329. #ifdef USE_IRIDESCENCE
  1330. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1331. if ( material.iridescenceThickness == 0.0 ) {
  1332. material.iridescence = 0.0;
  1333. } else {
  1334. material.iridescence = saturate( material.iridescence );
  1335. }
  1336. if ( material.iridescence > 0.0 ) {
  1337. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1338. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1339. }
  1340. #endif
  1341. IncidentLight directLight;
  1342. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1343. PointLight pointLight;
  1344. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1345. PointLightShadow pointLightShadow;
  1346. #endif
  1347. #pragma unroll_loop_start
  1348. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1349. pointLight = pointLights[ i ];
  1350. getPointLightInfo( pointLight, geometryPosition, directLight );
  1351. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1352. pointLightShadow = pointLightShadows[ i ];
  1353. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1354. #endif
  1355. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1356. }
  1357. #pragma unroll_loop_end
  1358. #endif
  1359. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1360. SpotLight spotLight;
  1361. vec4 spotColor;
  1362. vec3 spotLightCoord;
  1363. bool inSpotLightMap;
  1364. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1365. SpotLightShadow spotLightShadow;
  1366. #endif
  1367. #pragma unroll_loop_start
  1368. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1369. spotLight = spotLights[ i ];
  1370. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1371. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1372. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1373. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1374. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1375. #else
  1376. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1377. #endif
  1378. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1379. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1380. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1381. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1382. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1383. #endif
  1384. #undef SPOT_LIGHT_MAP_INDEX
  1385. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1386. spotLightShadow = spotLightShadows[ i ];
  1387. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1388. #endif
  1389. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1390. }
  1391. #pragma unroll_loop_end
  1392. #endif
  1393. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1394. DirectionalLight directionalLight;
  1395. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1396. DirectionalLightShadow directionalLightShadow;
  1397. #endif
  1398. #pragma unroll_loop_start
  1399. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1400. directionalLight = directionalLights[ i ];
  1401. getDirectionalLightInfo( directionalLight, directLight );
  1402. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1403. directionalLightShadow = directionalLightShadows[ i ];
  1404. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1405. #endif
  1406. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1407. }
  1408. #pragma unroll_loop_end
  1409. #endif
  1410. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1411. RectAreaLight rectAreaLight;
  1412. #pragma unroll_loop_start
  1413. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1414. rectAreaLight = rectAreaLights[ i ];
  1415. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1416. }
  1417. #pragma unroll_loop_end
  1418. #endif
  1419. #if defined( RE_IndirectDiffuse )
  1420. vec3 iblIrradiance = vec3( 0.0 );
  1421. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1422. #if defined( USE_LIGHT_PROBES )
  1423. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1424. #endif
  1425. #if ( NUM_HEMI_LIGHTS > 0 )
  1426. #pragma unroll_loop_start
  1427. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1428. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1429. }
  1430. #pragma unroll_loop_end
  1431. #endif
  1432. #endif
  1433. #if defined( RE_IndirectSpecular )
  1434. vec3 radiance = vec3( 0.0 );
  1435. vec3 clearcoatRadiance = vec3( 0.0 );
  1436. #endif`,nPe=`#if defined( RE_IndirectDiffuse )
  1437. #ifdef USE_LIGHTMAP
  1438. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1439. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1440. irradiance += lightMapIrradiance;
  1441. #endif
  1442. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1443. iblIrradiance += getIBLIrradiance( geometryNormal );
  1444. #endif
  1445. #endif
  1446. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1447. #ifdef USE_ANISOTROPY
  1448. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1449. #else
  1450. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1451. #endif
  1452. #ifdef USE_CLEARCOAT
  1453. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1454. #endif
  1455. #endif`,rPe=`#if defined( RE_IndirectDiffuse )
  1456. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1457. #endif
  1458. #if defined( RE_IndirectSpecular )
  1459. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1460. #endif`,iPe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1461. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1462. #endif`,aPe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1463. uniform float logDepthBufFC;
  1464. varying float vFragDepth;
  1465. varying float vIsPerspective;
  1466. #endif`,sPe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1467. varying float vFragDepth;
  1468. varying float vIsPerspective;
  1469. #endif`,oPe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1470. vFragDepth = 1.0 + gl_Position.w;
  1471. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1472. #endif`,lPe=`#ifdef USE_MAP
  1473. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1474. #ifdef DECODE_VIDEO_TEXTURE
  1475. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1476. #endif
  1477. diffuseColor *= sampledDiffuseColor;
  1478. #endif`,cPe=`#ifdef USE_MAP
  1479. uniform sampler2D map;
  1480. #endif`,uPe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1481. #if defined( USE_POINTS_UV )
  1482. vec2 uv = vUv;
  1483. #else
  1484. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1485. #endif
  1486. #endif
  1487. #ifdef USE_MAP
  1488. diffuseColor *= texture2D( map, uv );
  1489. #endif
  1490. #ifdef USE_ALPHAMAP
  1491. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1492. #endif`,dPe=`#if defined( USE_POINTS_UV )
  1493. varying vec2 vUv;
  1494. #else
  1495. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1496. uniform mat3 uvTransform;
  1497. #endif
  1498. #endif
  1499. #ifdef USE_MAP
  1500. uniform sampler2D map;
  1501. #endif
  1502. #ifdef USE_ALPHAMAP
  1503. uniform sampler2D alphaMap;
  1504. #endif`,hPe=`float metalnessFactor = metalness;
  1505. #ifdef USE_METALNESSMAP
  1506. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1507. metalnessFactor *= texelMetalness.b;
  1508. #endif`,fPe=`#ifdef USE_METALNESSMAP
  1509. uniform sampler2D metalnessMap;
  1510. #endif`,mPe=`#ifdef USE_INSTANCING_MORPH
  1511. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1512. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1513. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1514. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1515. }
  1516. #endif`,pPe=`#if defined( USE_MORPHCOLORS )
  1517. vColor *= morphTargetBaseInfluence;
  1518. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1519. #if defined( USE_COLOR_ALPHA )
  1520. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1521. #elif defined( USE_COLOR )
  1522. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1523. #endif
  1524. }
  1525. #endif`,gPe=`#ifdef USE_MORPHNORMALS
  1526. objectNormal *= morphTargetBaseInfluence;
  1527. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1528. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1529. }
  1530. #endif`,xPe=`#ifdef USE_MORPHTARGETS
  1531. #ifndef USE_INSTANCING_MORPH
  1532. uniform float morphTargetBaseInfluence;
  1533. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1534. #endif
  1535. uniform sampler2DArray morphTargetsTexture;
  1536. uniform ivec2 morphTargetsTextureSize;
  1537. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1538. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1539. int y = texelIndex / morphTargetsTextureSize.x;
  1540. int x = texelIndex - y * morphTargetsTextureSize.x;
  1541. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1542. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1543. }
  1544. #endif`,bPe=`#ifdef USE_MORPHTARGETS
  1545. transformed *= morphTargetBaseInfluence;
  1546. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1547. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1548. }
  1549. #endif`,yPe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1550. #ifdef FLAT_SHADED
  1551. vec3 fdx = dFdx( vViewPosition );
  1552. vec3 fdy = dFdy( vViewPosition );
  1553. vec3 normal = normalize( cross( fdx, fdy ) );
  1554. #else
  1555. vec3 normal = normalize( vNormal );
  1556. #ifdef DOUBLE_SIDED
  1557. normal *= faceDirection;
  1558. #endif
  1559. #endif
  1560. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1561. #ifdef USE_TANGENT
  1562. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1563. #else
  1564. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1565. #if defined( USE_NORMALMAP )
  1566. vNormalMapUv
  1567. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1568. vClearcoatNormalMapUv
  1569. #else
  1570. vUv
  1571. #endif
  1572. );
  1573. #endif
  1574. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1575. tbn[0] *= faceDirection;
  1576. tbn[1] *= faceDirection;
  1577. #endif
  1578. #endif
  1579. #ifdef USE_CLEARCOAT_NORMALMAP
  1580. #ifdef USE_TANGENT
  1581. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1582. #else
  1583. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1584. #endif
  1585. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1586. tbn2[0] *= faceDirection;
  1587. tbn2[1] *= faceDirection;
  1588. #endif
  1589. #endif
  1590. vec3 nonPerturbedNormal = normal;`,vPe=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1591. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1592. #ifdef FLIP_SIDED
  1593. normal = - normal;
  1594. #endif
  1595. #ifdef DOUBLE_SIDED
  1596. normal = normal * faceDirection;
  1597. #endif
  1598. normal = normalize( normalMatrix * normal );
  1599. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1600. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1601. mapN.xy *= normalScale;
  1602. normal = normalize( tbn * mapN );
  1603. #elif defined( USE_BUMPMAP )
  1604. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1605. #endif`,_Pe=`#ifndef FLAT_SHADED
  1606. varying vec3 vNormal;
  1607. #ifdef USE_TANGENT
  1608. varying vec3 vTangent;
  1609. varying vec3 vBitangent;
  1610. #endif
  1611. #endif`,wPe=`#ifndef FLAT_SHADED
  1612. varying vec3 vNormal;
  1613. #ifdef USE_TANGENT
  1614. varying vec3 vTangent;
  1615. varying vec3 vBitangent;
  1616. #endif
  1617. #endif`,SPe=`#ifndef FLAT_SHADED
  1618. vNormal = normalize( transformedNormal );
  1619. #ifdef USE_TANGENT
  1620. vTangent = normalize( transformedTangent );
  1621. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1622. #endif
  1623. #endif`,MPe=`#ifdef USE_NORMALMAP
  1624. uniform sampler2D normalMap;
  1625. uniform vec2 normalScale;
  1626. #endif
  1627. #ifdef USE_NORMALMAP_OBJECTSPACE
  1628. uniform mat3 normalMatrix;
  1629. #endif
  1630. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1631. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1632. vec3 q0 = dFdx( eye_pos.xyz );
  1633. vec3 q1 = dFdy( eye_pos.xyz );
  1634. vec2 st0 = dFdx( uv.st );
  1635. vec2 st1 = dFdy( uv.st );
  1636. vec3 N = surf_norm;
  1637. vec3 q1perp = cross( q1, N );
  1638. vec3 q0perp = cross( N, q0 );
  1639. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1640. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1641. float det = max( dot( T, T ), dot( B, B ) );
  1642. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1643. return mat3( T * scale, B * scale, N );
  1644. }
  1645. #endif`,EPe=`#ifdef USE_CLEARCOAT
  1646. vec3 clearcoatNormal = nonPerturbedNormal;
  1647. #endif`,APe=`#ifdef USE_CLEARCOAT_NORMALMAP
  1648. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1649. clearcoatMapN.xy *= clearcoatNormalScale;
  1650. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1651. #endif`,TPe=`#ifdef USE_CLEARCOATMAP
  1652. uniform sampler2D clearcoatMap;
  1653. #endif
  1654. #ifdef USE_CLEARCOAT_NORMALMAP
  1655. uniform sampler2D clearcoatNormalMap;
  1656. uniform vec2 clearcoatNormalScale;
  1657. #endif
  1658. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1659. uniform sampler2D clearcoatRoughnessMap;
  1660. #endif`,NPe=`#ifdef USE_IRIDESCENCEMAP
  1661. uniform sampler2D iridescenceMap;
  1662. #endif
  1663. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1664. uniform sampler2D iridescenceThicknessMap;
  1665. #endif`,CPe=`#ifdef OPAQUE
  1666. diffuseColor.a = 1.0;
  1667. #endif
  1668. #ifdef USE_TRANSMISSION
  1669. diffuseColor.a *= material.transmissionAlpha;
  1670. #endif
  1671. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,kPe=`vec3 packNormalToRGB( const in vec3 normal ) {
  1672. return normalize( normal ) * 0.5 + 0.5;
  1673. }
  1674. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1675. return 2.0 * rgb.xyz - 1.0;
  1676. }
  1677. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1678. const float Inv255 = 1. / 255.;
  1679. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1680. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1681. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1682. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1683. vec4 packDepthToRGBA( const in float v ) {
  1684. if( v <= 0.0 )
  1685. return vec4( 0., 0., 0., 0. );
  1686. if( v >= 1.0 )
  1687. return vec4( 1., 1., 1., 1. );
  1688. float vuf;
  1689. float af = modf( v * PackFactors.a, vuf );
  1690. float bf = modf( vuf * ShiftRight8, vuf );
  1691. float gf = modf( vuf * ShiftRight8, vuf );
  1692. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1693. }
  1694. vec3 packDepthToRGB( const in float v ) {
  1695. if( v <= 0.0 )
  1696. return vec3( 0., 0., 0. );
  1697. if( v >= 1.0 )
  1698. return vec3( 1., 1., 1. );
  1699. float vuf;
  1700. float bf = modf( v * PackFactors.b, vuf );
  1701. float gf = modf( vuf * ShiftRight8, vuf );
  1702. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1703. }
  1704. vec2 packDepthToRG( const in float v ) {
  1705. if( v <= 0.0 )
  1706. return vec2( 0., 0. );
  1707. if( v >= 1.0 )
  1708. return vec2( 1., 1. );
  1709. float vuf;
  1710. float gf = modf( v * 256., vuf );
  1711. return vec2( vuf * Inv255, gf );
  1712. }
  1713. float unpackRGBAToDepth( const in vec4 v ) {
  1714. return dot( v, UnpackFactors4 );
  1715. }
  1716. float unpackRGBToDepth( const in vec3 v ) {
  1717. return dot( v, UnpackFactors3 );
  1718. }
  1719. float unpackRGToDepth( const in vec2 v ) {
  1720. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1721. }
  1722. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1723. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1724. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1725. }
  1726. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1727. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1728. }
  1729. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1730. return ( viewZ + near ) / ( near - far );
  1731. }
  1732. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1733. return depth * ( near - far ) - near;
  1734. }
  1735. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1736. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1737. }
  1738. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1739. return ( near * far ) / ( ( far - near ) * depth - far );
  1740. }`,PPe=`#ifdef PREMULTIPLIED_ALPHA
  1741. gl_FragColor.rgb *= gl_FragColor.a;
  1742. #endif`,jPe=`vec4 mvPosition = vec4( transformed, 1.0 );
  1743. #ifdef USE_BATCHING
  1744. mvPosition = batchingMatrix * mvPosition;
  1745. #endif
  1746. #ifdef USE_INSTANCING
  1747. mvPosition = instanceMatrix * mvPosition;
  1748. #endif
  1749. mvPosition = modelViewMatrix * mvPosition;
  1750. gl_Position = projectionMatrix * mvPosition;`,RPe=`#ifdef DITHERING
  1751. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1752. #endif`,DPe=`#ifdef DITHERING
  1753. vec3 dithering( vec3 color ) {
  1754. float grid_position = rand( gl_FragCoord.xy );
  1755. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1756. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1757. return color + dither_shift_RGB;
  1758. }
  1759. #endif`,OPe=`float roughnessFactor = roughness;
  1760. #ifdef USE_ROUGHNESSMAP
  1761. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1762. roughnessFactor *= texelRoughness.g;
  1763. #endif`,LPe=`#ifdef USE_ROUGHNESSMAP
  1764. uniform sampler2D roughnessMap;
  1765. #endif`,IPe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1766. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1767. #endif
  1768. #if NUM_SPOT_LIGHT_MAPS > 0
  1769. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1770. #endif
  1771. #ifdef USE_SHADOWMAP
  1772. #if NUM_DIR_LIGHT_SHADOWS > 0
  1773. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1774. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1775. struct DirectionalLightShadow {
  1776. float shadowIntensity;
  1777. float shadowBias;
  1778. float shadowNormalBias;
  1779. float shadowRadius;
  1780. vec2 shadowMapSize;
  1781. };
  1782. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1783. #endif
  1784. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1785. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1786. struct SpotLightShadow {
  1787. float shadowIntensity;
  1788. float shadowBias;
  1789. float shadowNormalBias;
  1790. float shadowRadius;
  1791. vec2 shadowMapSize;
  1792. };
  1793. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1794. #endif
  1795. #if NUM_POINT_LIGHT_SHADOWS > 0
  1796. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1797. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1798. struct PointLightShadow {
  1799. float shadowIntensity;
  1800. float shadowBias;
  1801. float shadowNormalBias;
  1802. float shadowRadius;
  1803. vec2 shadowMapSize;
  1804. float shadowCameraNear;
  1805. float shadowCameraFar;
  1806. };
  1807. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1808. #endif
  1809. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1810. float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
  1811. #ifdef USE_REVERSED_DEPTH_BUFFER
  1812. return step( depth, compare );
  1813. #else
  1814. return step( compare, depth );
  1815. #endif
  1816. }
  1817. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1818. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1819. }
  1820. float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
  1821. float occlusion = 1.0;
  1822. vec2 distribution = texture2DDistribution( shadow, uv );
  1823. #ifdef USE_REVERSED_DEPTH_BUFFER
  1824. float hard_shadow = step( distribution.x, compare );
  1825. #else
  1826. float hard_shadow = step( compare, distribution.x );
  1827. #endif
  1828. if ( hard_shadow != 1.0 ) {
  1829. float distance = compare - distribution.x;
  1830. float variance = max( 0.00000, distribution.y * distribution.y );
  1831. 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 );
  1832. }
  1833. return occlusion;
  1834. }
  1835. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1836. float shadow = 1.0;
  1837. shadowCoord.xyz /= shadowCoord.w;
  1838. shadowCoord.z += shadowBias;
  1839. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1840. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1841. if ( frustumTest ) {
  1842. #if defined( SHADOWMAP_TYPE_PCF )
  1843. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1844. float dx0 = - texelSize.x * shadowRadius;
  1845. float dy0 = - texelSize.y * shadowRadius;
  1846. float dx1 = + texelSize.x * shadowRadius;
  1847. float dy1 = + texelSize.y * shadowRadius;
  1848. float dx2 = dx0 / 2.0;
  1849. float dy2 = dy0 / 2.0;
  1850. float dx3 = dx1 / 2.0;
  1851. float dy3 = dy1 / 2.0;
  1852. shadow = (
  1853. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1854. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1855. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1856. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1857. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1858. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1859. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1860. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1861. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1862. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1863. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1864. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1865. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1866. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1867. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1868. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1869. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1870. ) * ( 1.0 / 17.0 );
  1871. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1872. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1873. float dx = texelSize.x;
  1874. float dy = texelSize.y;
  1875. vec2 uv = shadowCoord.xy;
  1876. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1877. uv -= f * texelSize;
  1878. shadow = (
  1879. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1880. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1881. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1882. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1883. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1884. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1885. f.x ) +
  1886. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1887. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1888. f.x ) +
  1889. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1890. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1891. f.y ) +
  1892. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1893. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1894. f.y ) +
  1895. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1896. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1897. f.x ),
  1898. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1899. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1900. f.x ),
  1901. f.y )
  1902. ) * ( 1.0 / 9.0 );
  1903. #elif defined( SHADOWMAP_TYPE_VSM )
  1904. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1905. #else
  1906. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1907. #endif
  1908. }
  1909. return mix( 1.0, shadow, shadowIntensity );
  1910. }
  1911. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1912. vec3 absV = abs( v );
  1913. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1914. absV *= scaleToCube;
  1915. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1916. vec2 planar = v.xy;
  1917. float almostATexel = 1.5 * texelSizeY;
  1918. float almostOne = 1.0 - almostATexel;
  1919. if ( absV.z >= almostOne ) {
  1920. if ( v.z > 0.0 )
  1921. planar.x = 4.0 - v.x;
  1922. } else if ( absV.x >= almostOne ) {
  1923. float signX = sign( v.x );
  1924. planar.x = v.z * signX + 2.0 * signX;
  1925. } else if ( absV.y >= almostOne ) {
  1926. float signY = sign( v.y );
  1927. planar.x = v.x + 2.0 * signY + 2.0;
  1928. planar.y = v.z * signY - 2.0;
  1929. }
  1930. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1931. }
  1932. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1933. float shadow = 1.0;
  1934. vec3 lightToPosition = shadowCoord.xyz;
  1935. float lightToPositionLength = length( lightToPosition );
  1936. if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
  1937. float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1938. vec3 bd3D = normalize( lightToPosition );
  1939. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1940. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1941. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1942. shadow = (
  1943. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1944. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1945. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1946. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1947. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1948. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1949. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1950. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1951. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1952. ) * ( 1.0 / 9.0 );
  1953. #else
  1954. shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1955. #endif
  1956. }
  1957. return mix( 1.0, shadow, shadowIntensity );
  1958. }
  1959. #endif`,FPe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1960. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1961. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1962. #endif
  1963. #ifdef USE_SHADOWMAP
  1964. #if NUM_DIR_LIGHT_SHADOWS > 0
  1965. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1966. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1967. struct DirectionalLightShadow {
  1968. float shadowIntensity;
  1969. float shadowBias;
  1970. float shadowNormalBias;
  1971. float shadowRadius;
  1972. vec2 shadowMapSize;
  1973. };
  1974. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1975. #endif
  1976. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1977. struct SpotLightShadow {
  1978. float shadowIntensity;
  1979. float shadowBias;
  1980. float shadowNormalBias;
  1981. float shadowRadius;
  1982. vec2 shadowMapSize;
  1983. };
  1984. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1985. #endif
  1986. #if NUM_POINT_LIGHT_SHADOWS > 0
  1987. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1988. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1989. struct PointLightShadow {
  1990. float shadowIntensity;
  1991. float shadowBias;
  1992. float shadowNormalBias;
  1993. float shadowRadius;
  1994. vec2 shadowMapSize;
  1995. float shadowCameraNear;
  1996. float shadowCameraFar;
  1997. };
  1998. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1999. #endif
  2000. #endif`,UPe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  2001. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  2002. vec4 shadowWorldPosition;
  2003. #endif
  2004. #if defined( USE_SHADOWMAP )
  2005. #if NUM_DIR_LIGHT_SHADOWS > 0
  2006. #pragma unroll_loop_start
  2007. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  2008. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  2009. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  2010. }
  2011. #pragma unroll_loop_end
  2012. #endif
  2013. #if NUM_POINT_LIGHT_SHADOWS > 0
  2014. #pragma unroll_loop_start
  2015. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  2016. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  2017. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  2018. }
  2019. #pragma unroll_loop_end
  2020. #endif
  2021. #endif
  2022. #if NUM_SPOT_LIGHT_COORDS > 0
  2023. #pragma unroll_loop_start
  2024. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  2025. shadowWorldPosition = worldPosition;
  2026. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  2027. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  2028. #endif
  2029. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  2030. }
  2031. #pragma unroll_loop_end
  2032. #endif`,zPe=`float getShadowMask() {
  2033. float shadow = 1.0;
  2034. #ifdef USE_SHADOWMAP
  2035. #if NUM_DIR_LIGHT_SHADOWS > 0
  2036. DirectionalLightShadow directionalLight;
  2037. #pragma unroll_loop_start
  2038. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  2039. directionalLight = directionalLightShadows[ i ];
  2040. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  2041. }
  2042. #pragma unroll_loop_end
  2043. #endif
  2044. #if NUM_SPOT_LIGHT_SHADOWS > 0
  2045. SpotLightShadow spotLight;
  2046. #pragma unroll_loop_start
  2047. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  2048. spotLight = spotLightShadows[ i ];
  2049. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  2050. }
  2051. #pragma unroll_loop_end
  2052. #endif
  2053. #if NUM_POINT_LIGHT_SHADOWS > 0
  2054. PointLightShadow pointLight;
  2055. #pragma unroll_loop_start
  2056. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  2057. pointLight = pointLightShadows[ i ];
  2058. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  2059. }
  2060. #pragma unroll_loop_end
  2061. #endif
  2062. #endif
  2063. return shadow;
  2064. }`,BPe=`#ifdef USE_SKINNING
  2065. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  2066. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  2067. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  2068. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  2069. #endif`,HPe=`#ifdef USE_SKINNING
  2070. uniform mat4 bindMatrix;
  2071. uniform mat4 bindMatrixInverse;
  2072. uniform highp sampler2D boneTexture;
  2073. mat4 getBoneMatrix( const in float i ) {
  2074. int size = textureSize( boneTexture, 0 ).x;
  2075. int j = int( i ) * 4;
  2076. int x = j % size;
  2077. int y = j / size;
  2078. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  2079. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  2080. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  2081. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  2082. return mat4( v1, v2, v3, v4 );
  2083. }
  2084. #endif`,$Pe=`#ifdef USE_SKINNING
  2085. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  2086. vec4 skinned = vec4( 0.0 );
  2087. skinned += boneMatX * skinVertex * skinWeight.x;
  2088. skinned += boneMatY * skinVertex * skinWeight.y;
  2089. skinned += boneMatZ * skinVertex * skinWeight.z;
  2090. skinned += boneMatW * skinVertex * skinWeight.w;
  2091. transformed = ( bindMatrixInverse * skinned ).xyz;
  2092. #endif`,VPe=`#ifdef USE_SKINNING
  2093. mat4 skinMatrix = mat4( 0.0 );
  2094. skinMatrix += skinWeight.x * boneMatX;
  2095. skinMatrix += skinWeight.y * boneMatY;
  2096. skinMatrix += skinWeight.z * boneMatZ;
  2097. skinMatrix += skinWeight.w * boneMatW;
  2098. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2099. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2100. #ifdef USE_TANGENT
  2101. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2102. #endif
  2103. #endif`,GPe=`float specularStrength;
  2104. #ifdef USE_SPECULARMAP
  2105. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2106. specularStrength = texelSpecular.r;
  2107. #else
  2108. specularStrength = 1.0;
  2109. #endif`,WPe=`#ifdef USE_SPECULARMAP
  2110. uniform sampler2D specularMap;
  2111. #endif`,qPe=`#if defined( TONE_MAPPING )
  2112. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2113. #endif`,KPe=`#ifndef saturate
  2114. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2115. #endif
  2116. uniform float toneMappingExposure;
  2117. vec3 LinearToneMapping( vec3 color ) {
  2118. return saturate( toneMappingExposure * color );
  2119. }
  2120. vec3 ReinhardToneMapping( vec3 color ) {
  2121. color *= toneMappingExposure;
  2122. return saturate( color / ( vec3( 1.0 ) + color ) );
  2123. }
  2124. vec3 CineonToneMapping( vec3 color ) {
  2125. color *= toneMappingExposure;
  2126. color = max( vec3( 0.0 ), color - 0.004 );
  2127. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2128. }
  2129. vec3 RRTAndODTFit( vec3 v ) {
  2130. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2131. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2132. return a / b;
  2133. }
  2134. vec3 ACESFilmicToneMapping( vec3 color ) {
  2135. const mat3 ACESInputMat = mat3(
  2136. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2137. vec3( 0.04823, 0.01566, 0.83777 )
  2138. );
  2139. const mat3 ACESOutputMat = mat3(
  2140. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2141. vec3( -0.07367, -0.00605, 1.07602 )
  2142. );
  2143. color *= toneMappingExposure / 0.6;
  2144. color = ACESInputMat * color;
  2145. color = RRTAndODTFit( color );
  2146. color = ACESOutputMat * color;
  2147. return saturate( color );
  2148. }
  2149. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2150. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2151. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2152. vec3( - 0.0728, - 0.0083, 1.1187 )
  2153. );
  2154. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2155. vec3( 0.6274, 0.0691, 0.0164 ),
  2156. vec3( 0.3293, 0.9195, 0.0880 ),
  2157. vec3( 0.0433, 0.0113, 0.8956 )
  2158. );
  2159. vec3 agxDefaultContrastApprox( vec3 x ) {
  2160. vec3 x2 = x * x;
  2161. vec3 x4 = x2 * x2;
  2162. return + 15.5 * x4 * x2
  2163. - 40.14 * x4 * x
  2164. + 31.96 * x4
  2165. - 6.868 * x2 * x
  2166. + 0.4298 * x2
  2167. + 0.1191 * x
  2168. - 0.00232;
  2169. }
  2170. vec3 AgXToneMapping( vec3 color ) {
  2171. const mat3 AgXInsetMatrix = mat3(
  2172. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2173. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2174. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2175. );
  2176. const mat3 AgXOutsetMatrix = mat3(
  2177. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2178. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2179. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2180. );
  2181. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2182. color *= toneMappingExposure;
  2183. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2184. color = AgXInsetMatrix * color;
  2185. color = max( color, 1e-10 ); color = log2( color );
  2186. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2187. color = clamp( color, 0.0, 1.0 );
  2188. color = agxDefaultContrastApprox( color );
  2189. color = AgXOutsetMatrix * color;
  2190. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2191. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2192. color = clamp( color, 0.0, 1.0 );
  2193. return color;
  2194. }
  2195. vec3 NeutralToneMapping( vec3 color ) {
  2196. const float StartCompression = 0.8 - 0.04;
  2197. const float Desaturation = 0.15;
  2198. color *= toneMappingExposure;
  2199. float x = min( color.r, min( color.g, color.b ) );
  2200. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2201. color -= offset;
  2202. float peak = max( color.r, max( color.g, color.b ) );
  2203. if ( peak < StartCompression ) return color;
  2204. float d = 1. - StartCompression;
  2205. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2206. color *= newPeak / peak;
  2207. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2208. return mix( color, vec3( newPeak ), g );
  2209. }
  2210. vec3 CustomToneMapping( vec3 color ) { return color; }`,XPe=`#ifdef USE_TRANSMISSION
  2211. material.transmission = transmission;
  2212. material.transmissionAlpha = 1.0;
  2213. material.thickness = thickness;
  2214. material.attenuationDistance = attenuationDistance;
  2215. material.attenuationColor = attenuationColor;
  2216. #ifdef USE_TRANSMISSIONMAP
  2217. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2218. #endif
  2219. #ifdef USE_THICKNESSMAP
  2220. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2221. #endif
  2222. vec3 pos = vWorldPosition;
  2223. vec3 v = normalize( cameraPosition - pos );
  2224. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2225. vec4 transmitted = getIBLVolumeRefraction(
  2226. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  2227. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2228. material.attenuationColor, material.attenuationDistance );
  2229. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2230. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2231. #endif`,YPe=`#ifdef USE_TRANSMISSION
  2232. uniform float transmission;
  2233. uniform float thickness;
  2234. uniform float attenuationDistance;
  2235. uniform vec3 attenuationColor;
  2236. #ifdef USE_TRANSMISSIONMAP
  2237. uniform sampler2D transmissionMap;
  2238. #endif
  2239. #ifdef USE_THICKNESSMAP
  2240. uniform sampler2D thicknessMap;
  2241. #endif
  2242. uniform vec2 transmissionSamplerSize;
  2243. uniform sampler2D transmissionSamplerMap;
  2244. uniform mat4 modelMatrix;
  2245. uniform mat4 projectionMatrix;
  2246. varying vec3 vWorldPosition;
  2247. float w0( float a ) {
  2248. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2249. }
  2250. float w1( float a ) {
  2251. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2252. }
  2253. float w2( float a ){
  2254. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2255. }
  2256. float w3( float a ) {
  2257. return ( 1.0 / 6.0 ) * ( a * a * a );
  2258. }
  2259. float g0( float a ) {
  2260. return w0( a ) + w1( a );
  2261. }
  2262. float g1( float a ) {
  2263. return w2( a ) + w3( a );
  2264. }
  2265. float h0( float a ) {
  2266. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2267. }
  2268. float h1( float a ) {
  2269. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2270. }
  2271. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2272. uv = uv * texelSize.zw + 0.5;
  2273. vec2 iuv = floor( uv );
  2274. vec2 fuv = fract( uv );
  2275. float g0x = g0( fuv.x );
  2276. float g1x = g1( fuv.x );
  2277. float h0x = h0( fuv.x );
  2278. float h1x = h1( fuv.x );
  2279. float h0y = h0( fuv.y );
  2280. float h1y = h1( fuv.y );
  2281. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2282. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2283. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2284. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2285. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2286. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2287. }
  2288. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2289. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2290. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2291. vec2 fLodSizeInv = 1.0 / fLodSize;
  2292. vec2 cLodSizeInv = 1.0 / cLodSize;
  2293. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2294. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2295. return mix( fSample, cSample, fract( lod ) );
  2296. }
  2297. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2298. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2299. vec3 modelScale;
  2300. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2301. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2302. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2303. return normalize( refractionVector ) * thickness * modelScale;
  2304. }
  2305. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2306. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2307. }
  2308. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2309. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2310. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2311. }
  2312. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2313. if ( isinf( attenuationDistance ) ) {
  2314. return vec3( 1.0 );
  2315. } else {
  2316. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2317. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2318. }
  2319. }
  2320. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2321. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2322. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2323. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2324. vec4 transmittedLight;
  2325. vec3 transmittance;
  2326. #ifdef USE_DISPERSION
  2327. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2328. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2329. for ( int i = 0; i < 3; i ++ ) {
  2330. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2331. vec3 refractedRayExit = position + transmissionRay;
  2332. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2333. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2334. refractionCoords += 1.0;
  2335. refractionCoords /= 2.0;
  2336. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2337. transmittedLight[ i ] = transmissionSample[ i ];
  2338. transmittedLight.a += transmissionSample.a;
  2339. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2340. }
  2341. transmittedLight.a /= 3.0;
  2342. #else
  2343. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2344. vec3 refractedRayExit = position + transmissionRay;
  2345. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2346. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2347. refractionCoords += 1.0;
  2348. refractionCoords /= 2.0;
  2349. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2350. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2351. #endif
  2352. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2353. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2354. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2355. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2356. }
  2357. #endif`,ZPe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2358. varying vec2 vUv;
  2359. #endif
  2360. #ifdef USE_MAP
  2361. varying vec2 vMapUv;
  2362. #endif
  2363. #ifdef USE_ALPHAMAP
  2364. varying vec2 vAlphaMapUv;
  2365. #endif
  2366. #ifdef USE_LIGHTMAP
  2367. varying vec2 vLightMapUv;
  2368. #endif
  2369. #ifdef USE_AOMAP
  2370. varying vec2 vAoMapUv;
  2371. #endif
  2372. #ifdef USE_BUMPMAP
  2373. varying vec2 vBumpMapUv;
  2374. #endif
  2375. #ifdef USE_NORMALMAP
  2376. varying vec2 vNormalMapUv;
  2377. #endif
  2378. #ifdef USE_EMISSIVEMAP
  2379. varying vec2 vEmissiveMapUv;
  2380. #endif
  2381. #ifdef USE_METALNESSMAP
  2382. varying vec2 vMetalnessMapUv;
  2383. #endif
  2384. #ifdef USE_ROUGHNESSMAP
  2385. varying vec2 vRoughnessMapUv;
  2386. #endif
  2387. #ifdef USE_ANISOTROPYMAP
  2388. varying vec2 vAnisotropyMapUv;
  2389. #endif
  2390. #ifdef USE_CLEARCOATMAP
  2391. varying vec2 vClearcoatMapUv;
  2392. #endif
  2393. #ifdef USE_CLEARCOAT_NORMALMAP
  2394. varying vec2 vClearcoatNormalMapUv;
  2395. #endif
  2396. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2397. varying vec2 vClearcoatRoughnessMapUv;
  2398. #endif
  2399. #ifdef USE_IRIDESCENCEMAP
  2400. varying vec2 vIridescenceMapUv;
  2401. #endif
  2402. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2403. varying vec2 vIridescenceThicknessMapUv;
  2404. #endif
  2405. #ifdef USE_SHEEN_COLORMAP
  2406. varying vec2 vSheenColorMapUv;
  2407. #endif
  2408. #ifdef USE_SHEEN_ROUGHNESSMAP
  2409. varying vec2 vSheenRoughnessMapUv;
  2410. #endif
  2411. #ifdef USE_SPECULARMAP
  2412. varying vec2 vSpecularMapUv;
  2413. #endif
  2414. #ifdef USE_SPECULAR_COLORMAP
  2415. varying vec2 vSpecularColorMapUv;
  2416. #endif
  2417. #ifdef USE_SPECULAR_INTENSITYMAP
  2418. varying vec2 vSpecularIntensityMapUv;
  2419. #endif
  2420. #ifdef USE_TRANSMISSIONMAP
  2421. uniform mat3 transmissionMapTransform;
  2422. varying vec2 vTransmissionMapUv;
  2423. #endif
  2424. #ifdef USE_THICKNESSMAP
  2425. uniform mat3 thicknessMapTransform;
  2426. varying vec2 vThicknessMapUv;
  2427. #endif`,QPe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2428. varying vec2 vUv;
  2429. #endif
  2430. #ifdef USE_MAP
  2431. uniform mat3 mapTransform;
  2432. varying vec2 vMapUv;
  2433. #endif
  2434. #ifdef USE_ALPHAMAP
  2435. uniform mat3 alphaMapTransform;
  2436. varying vec2 vAlphaMapUv;
  2437. #endif
  2438. #ifdef USE_LIGHTMAP
  2439. uniform mat3 lightMapTransform;
  2440. varying vec2 vLightMapUv;
  2441. #endif
  2442. #ifdef USE_AOMAP
  2443. uniform mat3 aoMapTransform;
  2444. varying vec2 vAoMapUv;
  2445. #endif
  2446. #ifdef USE_BUMPMAP
  2447. uniform mat3 bumpMapTransform;
  2448. varying vec2 vBumpMapUv;
  2449. #endif
  2450. #ifdef USE_NORMALMAP
  2451. uniform mat3 normalMapTransform;
  2452. varying vec2 vNormalMapUv;
  2453. #endif
  2454. #ifdef USE_DISPLACEMENTMAP
  2455. uniform mat3 displacementMapTransform;
  2456. varying vec2 vDisplacementMapUv;
  2457. #endif
  2458. #ifdef USE_EMISSIVEMAP
  2459. uniform mat3 emissiveMapTransform;
  2460. varying vec2 vEmissiveMapUv;
  2461. #endif
  2462. #ifdef USE_METALNESSMAP
  2463. uniform mat3 metalnessMapTransform;
  2464. varying vec2 vMetalnessMapUv;
  2465. #endif
  2466. #ifdef USE_ROUGHNESSMAP
  2467. uniform mat3 roughnessMapTransform;
  2468. varying vec2 vRoughnessMapUv;
  2469. #endif
  2470. #ifdef USE_ANISOTROPYMAP
  2471. uniform mat3 anisotropyMapTransform;
  2472. varying vec2 vAnisotropyMapUv;
  2473. #endif
  2474. #ifdef USE_CLEARCOATMAP
  2475. uniform mat3 clearcoatMapTransform;
  2476. varying vec2 vClearcoatMapUv;
  2477. #endif
  2478. #ifdef USE_CLEARCOAT_NORMALMAP
  2479. uniform mat3 clearcoatNormalMapTransform;
  2480. varying vec2 vClearcoatNormalMapUv;
  2481. #endif
  2482. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2483. uniform mat3 clearcoatRoughnessMapTransform;
  2484. varying vec2 vClearcoatRoughnessMapUv;
  2485. #endif
  2486. #ifdef USE_SHEEN_COLORMAP
  2487. uniform mat3 sheenColorMapTransform;
  2488. varying vec2 vSheenColorMapUv;
  2489. #endif
  2490. #ifdef USE_SHEEN_ROUGHNESSMAP
  2491. uniform mat3 sheenRoughnessMapTransform;
  2492. varying vec2 vSheenRoughnessMapUv;
  2493. #endif
  2494. #ifdef USE_IRIDESCENCEMAP
  2495. uniform mat3 iridescenceMapTransform;
  2496. varying vec2 vIridescenceMapUv;
  2497. #endif
  2498. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2499. uniform mat3 iridescenceThicknessMapTransform;
  2500. varying vec2 vIridescenceThicknessMapUv;
  2501. #endif
  2502. #ifdef USE_SPECULARMAP
  2503. uniform mat3 specularMapTransform;
  2504. varying vec2 vSpecularMapUv;
  2505. #endif
  2506. #ifdef USE_SPECULAR_COLORMAP
  2507. uniform mat3 specularColorMapTransform;
  2508. varying vec2 vSpecularColorMapUv;
  2509. #endif
  2510. #ifdef USE_SPECULAR_INTENSITYMAP
  2511. uniform mat3 specularIntensityMapTransform;
  2512. varying vec2 vSpecularIntensityMapUv;
  2513. #endif
  2514. #ifdef USE_TRANSMISSIONMAP
  2515. uniform mat3 transmissionMapTransform;
  2516. varying vec2 vTransmissionMapUv;
  2517. #endif
  2518. #ifdef USE_THICKNESSMAP
  2519. uniform mat3 thicknessMapTransform;
  2520. varying vec2 vThicknessMapUv;
  2521. #endif`,JPe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2522. vUv = vec3( uv, 1 ).xy;
  2523. #endif
  2524. #ifdef USE_MAP
  2525. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2526. #endif
  2527. #ifdef USE_ALPHAMAP
  2528. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2529. #endif
  2530. #ifdef USE_LIGHTMAP
  2531. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2532. #endif
  2533. #ifdef USE_AOMAP
  2534. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2535. #endif
  2536. #ifdef USE_BUMPMAP
  2537. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2538. #endif
  2539. #ifdef USE_NORMALMAP
  2540. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2541. #endif
  2542. #ifdef USE_DISPLACEMENTMAP
  2543. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2544. #endif
  2545. #ifdef USE_EMISSIVEMAP
  2546. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2547. #endif
  2548. #ifdef USE_METALNESSMAP
  2549. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2550. #endif
  2551. #ifdef USE_ROUGHNESSMAP
  2552. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2553. #endif
  2554. #ifdef USE_ANISOTROPYMAP
  2555. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2556. #endif
  2557. #ifdef USE_CLEARCOATMAP
  2558. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2559. #endif
  2560. #ifdef USE_CLEARCOAT_NORMALMAP
  2561. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2562. #endif
  2563. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2564. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2565. #endif
  2566. #ifdef USE_IRIDESCENCEMAP
  2567. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2568. #endif
  2569. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2570. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2571. #endif
  2572. #ifdef USE_SHEEN_COLORMAP
  2573. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2574. #endif
  2575. #ifdef USE_SHEEN_ROUGHNESSMAP
  2576. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2577. #endif
  2578. #ifdef USE_SPECULARMAP
  2579. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2580. #endif
  2581. #ifdef USE_SPECULAR_COLORMAP
  2582. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2583. #endif
  2584. #ifdef USE_SPECULAR_INTENSITYMAP
  2585. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2586. #endif
  2587. #ifdef USE_TRANSMISSIONMAP
  2588. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2589. #endif
  2590. #ifdef USE_THICKNESSMAP
  2591. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2592. #endif`,eje=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2593. vec4 worldPosition = vec4( transformed, 1.0 );
  2594. #ifdef USE_BATCHING
  2595. worldPosition = batchingMatrix * worldPosition;
  2596. #endif
  2597. #ifdef USE_INSTANCING
  2598. worldPosition = instanceMatrix * worldPosition;
  2599. #endif
  2600. worldPosition = modelMatrix * worldPosition;
  2601. #endif`;const tje=`varying vec2 vUv;
  2602. uniform mat3 uvTransform;
  2603. void main() {
  2604. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2605. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2606. }`,nje=`uniform sampler2D t2D;
  2607. uniform float backgroundIntensity;
  2608. varying vec2 vUv;
  2609. void main() {
  2610. vec4 texColor = texture2D( t2D, vUv );
  2611. #ifdef DECODE_VIDEO_TEXTURE
  2612. 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 );
  2613. #endif
  2614. texColor.rgb *= backgroundIntensity;
  2615. gl_FragColor = texColor;
  2616. #include <tonemapping_fragment>
  2617. #include <colorspace_fragment>
  2618. }`,rje=`varying vec3 vWorldDirection;
  2619. #include <common>
  2620. void main() {
  2621. vWorldDirection = transformDirection( position, modelMatrix );
  2622. #include <begin_vertex>
  2623. #include <project_vertex>
  2624. gl_Position.z = gl_Position.w;
  2625. }`,ije=`#ifdef ENVMAP_TYPE_CUBE
  2626. uniform samplerCube envMap;
  2627. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2628. uniform sampler2D envMap;
  2629. #endif
  2630. uniform float flipEnvMap;
  2631. uniform float backgroundBlurriness;
  2632. uniform float backgroundIntensity;
  2633. uniform mat3 backgroundRotation;
  2634. varying vec3 vWorldDirection;
  2635. #include <cube_uv_reflection_fragment>
  2636. void main() {
  2637. #ifdef ENVMAP_TYPE_CUBE
  2638. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2639. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2640. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2641. #else
  2642. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2643. #endif
  2644. texColor.rgb *= backgroundIntensity;
  2645. gl_FragColor = texColor;
  2646. #include <tonemapping_fragment>
  2647. #include <colorspace_fragment>
  2648. }`,aje=`varying vec3 vWorldDirection;
  2649. #include <common>
  2650. void main() {
  2651. vWorldDirection = transformDirection( position, modelMatrix );
  2652. #include <begin_vertex>
  2653. #include <project_vertex>
  2654. gl_Position.z = gl_Position.w;
  2655. }`,sje=`uniform samplerCube tCube;
  2656. uniform float tFlip;
  2657. uniform float opacity;
  2658. varying vec3 vWorldDirection;
  2659. void main() {
  2660. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2661. gl_FragColor = texColor;
  2662. gl_FragColor.a *= opacity;
  2663. #include <tonemapping_fragment>
  2664. #include <colorspace_fragment>
  2665. }`,oje=`#include <common>
  2666. #include <batching_pars_vertex>
  2667. #include <uv_pars_vertex>
  2668. #include <displacementmap_pars_vertex>
  2669. #include <morphtarget_pars_vertex>
  2670. #include <skinning_pars_vertex>
  2671. #include <logdepthbuf_pars_vertex>
  2672. #include <clipping_planes_pars_vertex>
  2673. varying vec2 vHighPrecisionZW;
  2674. void main() {
  2675. #include <uv_vertex>
  2676. #include <batching_vertex>
  2677. #include <skinbase_vertex>
  2678. #include <morphinstance_vertex>
  2679. #ifdef USE_DISPLACEMENTMAP
  2680. #include <beginnormal_vertex>
  2681. #include <morphnormal_vertex>
  2682. #include <skinnormal_vertex>
  2683. #endif
  2684. #include <begin_vertex>
  2685. #include <morphtarget_vertex>
  2686. #include <skinning_vertex>
  2687. #include <displacementmap_vertex>
  2688. #include <project_vertex>
  2689. #include <logdepthbuf_vertex>
  2690. #include <clipping_planes_vertex>
  2691. vHighPrecisionZW = gl_Position.zw;
  2692. }`,lje=`#if DEPTH_PACKING == 3200
  2693. uniform float opacity;
  2694. #endif
  2695. #include <common>
  2696. #include <packing>
  2697. #include <uv_pars_fragment>
  2698. #include <map_pars_fragment>
  2699. #include <alphamap_pars_fragment>
  2700. #include <alphatest_pars_fragment>
  2701. #include <alphahash_pars_fragment>
  2702. #include <logdepthbuf_pars_fragment>
  2703. #include <clipping_planes_pars_fragment>
  2704. varying vec2 vHighPrecisionZW;
  2705. void main() {
  2706. vec4 diffuseColor = vec4( 1.0 );
  2707. #include <clipping_planes_fragment>
  2708. #if DEPTH_PACKING == 3200
  2709. diffuseColor.a = opacity;
  2710. #endif
  2711. #include <map_fragment>
  2712. #include <alphamap_fragment>
  2713. #include <alphatest_fragment>
  2714. #include <alphahash_fragment>
  2715. #include <logdepthbuf_fragment>
  2716. #ifdef USE_REVERSED_DEPTH_BUFFER
  2717. float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
  2718. #else
  2719. float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
  2720. #endif
  2721. #if DEPTH_PACKING == 3200
  2722. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2723. #elif DEPTH_PACKING == 3201
  2724. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2725. #elif DEPTH_PACKING == 3202
  2726. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2727. #elif DEPTH_PACKING == 3203
  2728. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2729. #endif
  2730. }`,cje=`#define DISTANCE
  2731. varying vec3 vWorldPosition;
  2732. #include <common>
  2733. #include <batching_pars_vertex>
  2734. #include <uv_pars_vertex>
  2735. #include <displacementmap_pars_vertex>
  2736. #include <morphtarget_pars_vertex>
  2737. #include <skinning_pars_vertex>
  2738. #include <clipping_planes_pars_vertex>
  2739. void main() {
  2740. #include <uv_vertex>
  2741. #include <batching_vertex>
  2742. #include <skinbase_vertex>
  2743. #include <morphinstance_vertex>
  2744. #ifdef USE_DISPLACEMENTMAP
  2745. #include <beginnormal_vertex>
  2746. #include <morphnormal_vertex>
  2747. #include <skinnormal_vertex>
  2748. #endif
  2749. #include <begin_vertex>
  2750. #include <morphtarget_vertex>
  2751. #include <skinning_vertex>
  2752. #include <displacementmap_vertex>
  2753. #include <project_vertex>
  2754. #include <worldpos_vertex>
  2755. #include <clipping_planes_vertex>
  2756. vWorldPosition = worldPosition.xyz;
  2757. }`,uje=`#define DISTANCE
  2758. uniform vec3 referencePosition;
  2759. uniform float nearDistance;
  2760. uniform float farDistance;
  2761. varying vec3 vWorldPosition;
  2762. #include <common>
  2763. #include <packing>
  2764. #include <uv_pars_fragment>
  2765. #include <map_pars_fragment>
  2766. #include <alphamap_pars_fragment>
  2767. #include <alphatest_pars_fragment>
  2768. #include <alphahash_pars_fragment>
  2769. #include <clipping_planes_pars_fragment>
  2770. void main () {
  2771. vec4 diffuseColor = vec4( 1.0 );
  2772. #include <clipping_planes_fragment>
  2773. #include <map_fragment>
  2774. #include <alphamap_fragment>
  2775. #include <alphatest_fragment>
  2776. #include <alphahash_fragment>
  2777. float dist = length( vWorldPosition - referencePosition );
  2778. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2779. dist = saturate( dist );
  2780. gl_FragColor = packDepthToRGBA( dist );
  2781. }`,dje=`varying vec3 vWorldDirection;
  2782. #include <common>
  2783. void main() {
  2784. vWorldDirection = transformDirection( position, modelMatrix );
  2785. #include <begin_vertex>
  2786. #include <project_vertex>
  2787. }`,hje=`uniform sampler2D tEquirect;
  2788. varying vec3 vWorldDirection;
  2789. #include <common>
  2790. void main() {
  2791. vec3 direction = normalize( vWorldDirection );
  2792. vec2 sampleUV = equirectUv( direction );
  2793. gl_FragColor = texture2D( tEquirect, sampleUV );
  2794. #include <tonemapping_fragment>
  2795. #include <colorspace_fragment>
  2796. }`,fje=`uniform float scale;
  2797. attribute float lineDistance;
  2798. varying float vLineDistance;
  2799. #include <common>
  2800. #include <uv_pars_vertex>
  2801. #include <color_pars_vertex>
  2802. #include <fog_pars_vertex>
  2803. #include <morphtarget_pars_vertex>
  2804. #include <logdepthbuf_pars_vertex>
  2805. #include <clipping_planes_pars_vertex>
  2806. void main() {
  2807. vLineDistance = scale * lineDistance;
  2808. #include <uv_vertex>
  2809. #include <color_vertex>
  2810. #include <morphinstance_vertex>
  2811. #include <morphcolor_vertex>
  2812. #include <begin_vertex>
  2813. #include <morphtarget_vertex>
  2814. #include <project_vertex>
  2815. #include <logdepthbuf_vertex>
  2816. #include <clipping_planes_vertex>
  2817. #include <fog_vertex>
  2818. }`,mje=`uniform vec3 diffuse;
  2819. uniform float opacity;
  2820. uniform float dashSize;
  2821. uniform float totalSize;
  2822. varying float vLineDistance;
  2823. #include <common>
  2824. #include <color_pars_fragment>
  2825. #include <uv_pars_fragment>
  2826. #include <map_pars_fragment>
  2827. #include <fog_pars_fragment>
  2828. #include <logdepthbuf_pars_fragment>
  2829. #include <clipping_planes_pars_fragment>
  2830. void main() {
  2831. vec4 diffuseColor = vec4( diffuse, opacity );
  2832. #include <clipping_planes_fragment>
  2833. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2834. discard;
  2835. }
  2836. vec3 outgoingLight = vec3( 0.0 );
  2837. #include <logdepthbuf_fragment>
  2838. #include <map_fragment>
  2839. #include <color_fragment>
  2840. outgoingLight = diffuseColor.rgb;
  2841. #include <opaque_fragment>
  2842. #include <tonemapping_fragment>
  2843. #include <colorspace_fragment>
  2844. #include <fog_fragment>
  2845. #include <premultiplied_alpha_fragment>
  2846. }`,pje=`#include <common>
  2847. #include <batching_pars_vertex>
  2848. #include <uv_pars_vertex>
  2849. #include <envmap_pars_vertex>
  2850. #include <color_pars_vertex>
  2851. #include <fog_pars_vertex>
  2852. #include <morphtarget_pars_vertex>
  2853. #include <skinning_pars_vertex>
  2854. #include <logdepthbuf_pars_vertex>
  2855. #include <clipping_planes_pars_vertex>
  2856. void main() {
  2857. #include <uv_vertex>
  2858. #include <color_vertex>
  2859. #include <morphinstance_vertex>
  2860. #include <morphcolor_vertex>
  2861. #include <batching_vertex>
  2862. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2863. #include <beginnormal_vertex>
  2864. #include <morphnormal_vertex>
  2865. #include <skinbase_vertex>
  2866. #include <skinnormal_vertex>
  2867. #include <defaultnormal_vertex>
  2868. #endif
  2869. #include <begin_vertex>
  2870. #include <morphtarget_vertex>
  2871. #include <skinning_vertex>
  2872. #include <project_vertex>
  2873. #include <logdepthbuf_vertex>
  2874. #include <clipping_planes_vertex>
  2875. #include <worldpos_vertex>
  2876. #include <envmap_vertex>
  2877. #include <fog_vertex>
  2878. }`,gje=`uniform vec3 diffuse;
  2879. uniform float opacity;
  2880. #ifndef FLAT_SHADED
  2881. varying vec3 vNormal;
  2882. #endif
  2883. #include <common>
  2884. #include <dithering_pars_fragment>
  2885. #include <color_pars_fragment>
  2886. #include <uv_pars_fragment>
  2887. #include <map_pars_fragment>
  2888. #include <alphamap_pars_fragment>
  2889. #include <alphatest_pars_fragment>
  2890. #include <alphahash_pars_fragment>
  2891. #include <aomap_pars_fragment>
  2892. #include <lightmap_pars_fragment>
  2893. #include <envmap_common_pars_fragment>
  2894. #include <envmap_pars_fragment>
  2895. #include <fog_pars_fragment>
  2896. #include <specularmap_pars_fragment>
  2897. #include <logdepthbuf_pars_fragment>
  2898. #include <clipping_planes_pars_fragment>
  2899. void main() {
  2900. vec4 diffuseColor = vec4( diffuse, opacity );
  2901. #include <clipping_planes_fragment>
  2902. #include <logdepthbuf_fragment>
  2903. #include <map_fragment>
  2904. #include <color_fragment>
  2905. #include <alphamap_fragment>
  2906. #include <alphatest_fragment>
  2907. #include <alphahash_fragment>
  2908. #include <specularmap_fragment>
  2909. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2910. #ifdef USE_LIGHTMAP
  2911. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2912. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2913. #else
  2914. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2915. #endif
  2916. #include <aomap_fragment>
  2917. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2918. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2919. #include <envmap_fragment>
  2920. #include <opaque_fragment>
  2921. #include <tonemapping_fragment>
  2922. #include <colorspace_fragment>
  2923. #include <fog_fragment>
  2924. #include <premultiplied_alpha_fragment>
  2925. #include <dithering_fragment>
  2926. }`,xje=`#define LAMBERT
  2927. varying vec3 vViewPosition;
  2928. #include <common>
  2929. #include <batching_pars_vertex>
  2930. #include <uv_pars_vertex>
  2931. #include <displacementmap_pars_vertex>
  2932. #include <envmap_pars_vertex>
  2933. #include <color_pars_vertex>
  2934. #include <fog_pars_vertex>
  2935. #include <normal_pars_vertex>
  2936. #include <morphtarget_pars_vertex>
  2937. #include <skinning_pars_vertex>
  2938. #include <shadowmap_pars_vertex>
  2939. #include <logdepthbuf_pars_vertex>
  2940. #include <clipping_planes_pars_vertex>
  2941. void main() {
  2942. #include <uv_vertex>
  2943. #include <color_vertex>
  2944. #include <morphinstance_vertex>
  2945. #include <morphcolor_vertex>
  2946. #include <batching_vertex>
  2947. #include <beginnormal_vertex>
  2948. #include <morphnormal_vertex>
  2949. #include <skinbase_vertex>
  2950. #include <skinnormal_vertex>
  2951. #include <defaultnormal_vertex>
  2952. #include <normal_vertex>
  2953. #include <begin_vertex>
  2954. #include <morphtarget_vertex>
  2955. #include <skinning_vertex>
  2956. #include <displacementmap_vertex>
  2957. #include <project_vertex>
  2958. #include <logdepthbuf_vertex>
  2959. #include <clipping_planes_vertex>
  2960. vViewPosition = - mvPosition.xyz;
  2961. #include <worldpos_vertex>
  2962. #include <envmap_vertex>
  2963. #include <shadowmap_vertex>
  2964. #include <fog_vertex>
  2965. }`,bje=`#define LAMBERT
  2966. uniform vec3 diffuse;
  2967. uniform vec3 emissive;
  2968. uniform float opacity;
  2969. #include <common>
  2970. #include <packing>
  2971. #include <dithering_pars_fragment>
  2972. #include <color_pars_fragment>
  2973. #include <uv_pars_fragment>
  2974. #include <map_pars_fragment>
  2975. #include <alphamap_pars_fragment>
  2976. #include <alphatest_pars_fragment>
  2977. #include <alphahash_pars_fragment>
  2978. #include <aomap_pars_fragment>
  2979. #include <lightmap_pars_fragment>
  2980. #include <emissivemap_pars_fragment>
  2981. #include <envmap_common_pars_fragment>
  2982. #include <envmap_pars_fragment>
  2983. #include <fog_pars_fragment>
  2984. #include <bsdfs>
  2985. #include <lights_pars_begin>
  2986. #include <normal_pars_fragment>
  2987. #include <lights_lambert_pars_fragment>
  2988. #include <shadowmap_pars_fragment>
  2989. #include <bumpmap_pars_fragment>
  2990. #include <normalmap_pars_fragment>
  2991. #include <specularmap_pars_fragment>
  2992. #include <logdepthbuf_pars_fragment>
  2993. #include <clipping_planes_pars_fragment>
  2994. void main() {
  2995. vec4 diffuseColor = vec4( diffuse, opacity );
  2996. #include <clipping_planes_fragment>
  2997. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2998. vec3 totalEmissiveRadiance = emissive;
  2999. #include <logdepthbuf_fragment>
  3000. #include <map_fragment>
  3001. #include <color_fragment>
  3002. #include <alphamap_fragment>
  3003. #include <alphatest_fragment>
  3004. #include <alphahash_fragment>
  3005. #include <specularmap_fragment>
  3006. #include <normal_fragment_begin>
  3007. #include <normal_fragment_maps>
  3008. #include <emissivemap_fragment>
  3009. #include <lights_lambert_fragment>
  3010. #include <lights_fragment_begin>
  3011. #include <lights_fragment_maps>
  3012. #include <lights_fragment_end>
  3013. #include <aomap_fragment>
  3014. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3015. #include <envmap_fragment>
  3016. #include <opaque_fragment>
  3017. #include <tonemapping_fragment>
  3018. #include <colorspace_fragment>
  3019. #include <fog_fragment>
  3020. #include <premultiplied_alpha_fragment>
  3021. #include <dithering_fragment>
  3022. }`,yje=`#define MATCAP
  3023. varying vec3 vViewPosition;
  3024. #include <common>
  3025. #include <batching_pars_vertex>
  3026. #include <uv_pars_vertex>
  3027. #include <color_pars_vertex>
  3028. #include <displacementmap_pars_vertex>
  3029. #include <fog_pars_vertex>
  3030. #include <normal_pars_vertex>
  3031. #include <morphtarget_pars_vertex>
  3032. #include <skinning_pars_vertex>
  3033. #include <logdepthbuf_pars_vertex>
  3034. #include <clipping_planes_pars_vertex>
  3035. void main() {
  3036. #include <uv_vertex>
  3037. #include <color_vertex>
  3038. #include <morphinstance_vertex>
  3039. #include <morphcolor_vertex>
  3040. #include <batching_vertex>
  3041. #include <beginnormal_vertex>
  3042. #include <morphnormal_vertex>
  3043. #include <skinbase_vertex>
  3044. #include <skinnormal_vertex>
  3045. #include <defaultnormal_vertex>
  3046. #include <normal_vertex>
  3047. #include <begin_vertex>
  3048. #include <morphtarget_vertex>
  3049. #include <skinning_vertex>
  3050. #include <displacementmap_vertex>
  3051. #include <project_vertex>
  3052. #include <logdepthbuf_vertex>
  3053. #include <clipping_planes_vertex>
  3054. #include <fog_vertex>
  3055. vViewPosition = - mvPosition.xyz;
  3056. }`,vje=`#define MATCAP
  3057. uniform vec3 diffuse;
  3058. uniform float opacity;
  3059. uniform sampler2D matcap;
  3060. varying vec3 vViewPosition;
  3061. #include <common>
  3062. #include <dithering_pars_fragment>
  3063. #include <color_pars_fragment>
  3064. #include <uv_pars_fragment>
  3065. #include <map_pars_fragment>
  3066. #include <alphamap_pars_fragment>
  3067. #include <alphatest_pars_fragment>
  3068. #include <alphahash_pars_fragment>
  3069. #include <fog_pars_fragment>
  3070. #include <normal_pars_fragment>
  3071. #include <bumpmap_pars_fragment>
  3072. #include <normalmap_pars_fragment>
  3073. #include <logdepthbuf_pars_fragment>
  3074. #include <clipping_planes_pars_fragment>
  3075. void main() {
  3076. vec4 diffuseColor = vec4( diffuse, opacity );
  3077. #include <clipping_planes_fragment>
  3078. #include <logdepthbuf_fragment>
  3079. #include <map_fragment>
  3080. #include <color_fragment>
  3081. #include <alphamap_fragment>
  3082. #include <alphatest_fragment>
  3083. #include <alphahash_fragment>
  3084. #include <normal_fragment_begin>
  3085. #include <normal_fragment_maps>
  3086. vec3 viewDir = normalize( vViewPosition );
  3087. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  3088. vec3 y = cross( viewDir, x );
  3089. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  3090. #ifdef USE_MATCAP
  3091. vec4 matcapColor = texture2D( matcap, uv );
  3092. #else
  3093. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  3094. #endif
  3095. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  3096. #include <opaque_fragment>
  3097. #include <tonemapping_fragment>
  3098. #include <colorspace_fragment>
  3099. #include <fog_fragment>
  3100. #include <premultiplied_alpha_fragment>
  3101. #include <dithering_fragment>
  3102. }`,_je=`#define NORMAL
  3103. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3104. varying vec3 vViewPosition;
  3105. #endif
  3106. #include <common>
  3107. #include <batching_pars_vertex>
  3108. #include <uv_pars_vertex>
  3109. #include <displacementmap_pars_vertex>
  3110. #include <normal_pars_vertex>
  3111. #include <morphtarget_pars_vertex>
  3112. #include <skinning_pars_vertex>
  3113. #include <logdepthbuf_pars_vertex>
  3114. #include <clipping_planes_pars_vertex>
  3115. void main() {
  3116. #include <uv_vertex>
  3117. #include <batching_vertex>
  3118. #include <beginnormal_vertex>
  3119. #include <morphinstance_vertex>
  3120. #include <morphnormal_vertex>
  3121. #include <skinbase_vertex>
  3122. #include <skinnormal_vertex>
  3123. #include <defaultnormal_vertex>
  3124. #include <normal_vertex>
  3125. #include <begin_vertex>
  3126. #include <morphtarget_vertex>
  3127. #include <skinning_vertex>
  3128. #include <displacementmap_vertex>
  3129. #include <project_vertex>
  3130. #include <logdepthbuf_vertex>
  3131. #include <clipping_planes_vertex>
  3132. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3133. vViewPosition = - mvPosition.xyz;
  3134. #endif
  3135. }`,wje=`#define NORMAL
  3136. uniform float opacity;
  3137. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3138. varying vec3 vViewPosition;
  3139. #endif
  3140. #include <packing>
  3141. #include <uv_pars_fragment>
  3142. #include <normal_pars_fragment>
  3143. #include <bumpmap_pars_fragment>
  3144. #include <normalmap_pars_fragment>
  3145. #include <logdepthbuf_pars_fragment>
  3146. #include <clipping_planes_pars_fragment>
  3147. void main() {
  3148. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3149. #include <clipping_planes_fragment>
  3150. #include <logdepthbuf_fragment>
  3151. #include <normal_fragment_begin>
  3152. #include <normal_fragment_maps>
  3153. gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
  3154. #ifdef OPAQUE
  3155. gl_FragColor.a = 1.0;
  3156. #endif
  3157. }`,Sje=`#define PHONG
  3158. varying vec3 vViewPosition;
  3159. #include <common>
  3160. #include <batching_pars_vertex>
  3161. #include <uv_pars_vertex>
  3162. #include <displacementmap_pars_vertex>
  3163. #include <envmap_pars_vertex>
  3164. #include <color_pars_vertex>
  3165. #include <fog_pars_vertex>
  3166. #include <normal_pars_vertex>
  3167. #include <morphtarget_pars_vertex>
  3168. #include <skinning_pars_vertex>
  3169. #include <shadowmap_pars_vertex>
  3170. #include <logdepthbuf_pars_vertex>
  3171. #include <clipping_planes_pars_vertex>
  3172. void main() {
  3173. #include <uv_vertex>
  3174. #include <color_vertex>
  3175. #include <morphcolor_vertex>
  3176. #include <batching_vertex>
  3177. #include <beginnormal_vertex>
  3178. #include <morphinstance_vertex>
  3179. #include <morphnormal_vertex>
  3180. #include <skinbase_vertex>
  3181. #include <skinnormal_vertex>
  3182. #include <defaultnormal_vertex>
  3183. #include <normal_vertex>
  3184. #include <begin_vertex>
  3185. #include <morphtarget_vertex>
  3186. #include <skinning_vertex>
  3187. #include <displacementmap_vertex>
  3188. #include <project_vertex>
  3189. #include <logdepthbuf_vertex>
  3190. #include <clipping_planes_vertex>
  3191. vViewPosition = - mvPosition.xyz;
  3192. #include <worldpos_vertex>
  3193. #include <envmap_vertex>
  3194. #include <shadowmap_vertex>
  3195. #include <fog_vertex>
  3196. }`,Mje=`#define PHONG
  3197. uniform vec3 diffuse;
  3198. uniform vec3 emissive;
  3199. uniform vec3 specular;
  3200. uniform float shininess;
  3201. uniform float opacity;
  3202. #include <common>
  3203. #include <packing>
  3204. #include <dithering_pars_fragment>
  3205. #include <color_pars_fragment>
  3206. #include <uv_pars_fragment>
  3207. #include <map_pars_fragment>
  3208. #include <alphamap_pars_fragment>
  3209. #include <alphatest_pars_fragment>
  3210. #include <alphahash_pars_fragment>
  3211. #include <aomap_pars_fragment>
  3212. #include <lightmap_pars_fragment>
  3213. #include <emissivemap_pars_fragment>
  3214. #include <envmap_common_pars_fragment>
  3215. #include <envmap_pars_fragment>
  3216. #include <fog_pars_fragment>
  3217. #include <bsdfs>
  3218. #include <lights_pars_begin>
  3219. #include <normal_pars_fragment>
  3220. #include <lights_phong_pars_fragment>
  3221. #include <shadowmap_pars_fragment>
  3222. #include <bumpmap_pars_fragment>
  3223. #include <normalmap_pars_fragment>
  3224. #include <specularmap_pars_fragment>
  3225. #include <logdepthbuf_pars_fragment>
  3226. #include <clipping_planes_pars_fragment>
  3227. void main() {
  3228. vec4 diffuseColor = vec4( diffuse, opacity );
  3229. #include <clipping_planes_fragment>
  3230. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3231. vec3 totalEmissiveRadiance = emissive;
  3232. #include <logdepthbuf_fragment>
  3233. #include <map_fragment>
  3234. #include <color_fragment>
  3235. #include <alphamap_fragment>
  3236. #include <alphatest_fragment>
  3237. #include <alphahash_fragment>
  3238. #include <specularmap_fragment>
  3239. #include <normal_fragment_begin>
  3240. #include <normal_fragment_maps>
  3241. #include <emissivemap_fragment>
  3242. #include <lights_phong_fragment>
  3243. #include <lights_fragment_begin>
  3244. #include <lights_fragment_maps>
  3245. #include <lights_fragment_end>
  3246. #include <aomap_fragment>
  3247. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3248. #include <envmap_fragment>
  3249. #include <opaque_fragment>
  3250. #include <tonemapping_fragment>
  3251. #include <colorspace_fragment>
  3252. #include <fog_fragment>
  3253. #include <premultiplied_alpha_fragment>
  3254. #include <dithering_fragment>
  3255. }`,Eje=`#define STANDARD
  3256. varying vec3 vViewPosition;
  3257. #ifdef USE_TRANSMISSION
  3258. varying vec3 vWorldPosition;
  3259. #endif
  3260. #include <common>
  3261. #include <batching_pars_vertex>
  3262. #include <uv_pars_vertex>
  3263. #include <displacementmap_pars_vertex>
  3264. #include <color_pars_vertex>
  3265. #include <fog_pars_vertex>
  3266. #include <normal_pars_vertex>
  3267. #include <morphtarget_pars_vertex>
  3268. #include <skinning_pars_vertex>
  3269. #include <shadowmap_pars_vertex>
  3270. #include <logdepthbuf_pars_vertex>
  3271. #include <clipping_planes_pars_vertex>
  3272. void main() {
  3273. #include <uv_vertex>
  3274. #include <color_vertex>
  3275. #include <morphinstance_vertex>
  3276. #include <morphcolor_vertex>
  3277. #include <batching_vertex>
  3278. #include <beginnormal_vertex>
  3279. #include <morphnormal_vertex>
  3280. #include <skinbase_vertex>
  3281. #include <skinnormal_vertex>
  3282. #include <defaultnormal_vertex>
  3283. #include <normal_vertex>
  3284. #include <begin_vertex>
  3285. #include <morphtarget_vertex>
  3286. #include <skinning_vertex>
  3287. #include <displacementmap_vertex>
  3288. #include <project_vertex>
  3289. #include <logdepthbuf_vertex>
  3290. #include <clipping_planes_vertex>
  3291. vViewPosition = - mvPosition.xyz;
  3292. #include <worldpos_vertex>
  3293. #include <shadowmap_vertex>
  3294. #include <fog_vertex>
  3295. #ifdef USE_TRANSMISSION
  3296. vWorldPosition = worldPosition.xyz;
  3297. #endif
  3298. }`,Aje=`#define STANDARD
  3299. #ifdef PHYSICAL
  3300. #define IOR
  3301. #define USE_SPECULAR
  3302. #endif
  3303. uniform vec3 diffuse;
  3304. uniform vec3 emissive;
  3305. uniform float roughness;
  3306. uniform float metalness;
  3307. uniform float opacity;
  3308. #ifdef IOR
  3309. uniform float ior;
  3310. #endif
  3311. #ifdef USE_SPECULAR
  3312. uniform float specularIntensity;
  3313. uniform vec3 specularColor;
  3314. #ifdef USE_SPECULAR_COLORMAP
  3315. uniform sampler2D specularColorMap;
  3316. #endif
  3317. #ifdef USE_SPECULAR_INTENSITYMAP
  3318. uniform sampler2D specularIntensityMap;
  3319. #endif
  3320. #endif
  3321. #ifdef USE_CLEARCOAT
  3322. uniform float clearcoat;
  3323. uniform float clearcoatRoughness;
  3324. #endif
  3325. #ifdef USE_DISPERSION
  3326. uniform float dispersion;
  3327. #endif
  3328. #ifdef USE_IRIDESCENCE
  3329. uniform float iridescence;
  3330. uniform float iridescenceIOR;
  3331. uniform float iridescenceThicknessMinimum;
  3332. uniform float iridescenceThicknessMaximum;
  3333. #endif
  3334. #ifdef USE_SHEEN
  3335. uniform vec3 sheenColor;
  3336. uniform float sheenRoughness;
  3337. #ifdef USE_SHEEN_COLORMAP
  3338. uniform sampler2D sheenColorMap;
  3339. #endif
  3340. #ifdef USE_SHEEN_ROUGHNESSMAP
  3341. uniform sampler2D sheenRoughnessMap;
  3342. #endif
  3343. #endif
  3344. #ifdef USE_ANISOTROPY
  3345. uniform vec2 anisotropyVector;
  3346. #ifdef USE_ANISOTROPYMAP
  3347. uniform sampler2D anisotropyMap;
  3348. #endif
  3349. #endif
  3350. varying vec3 vViewPosition;
  3351. #include <common>
  3352. #include <packing>
  3353. #include <dithering_pars_fragment>
  3354. #include <color_pars_fragment>
  3355. #include <uv_pars_fragment>
  3356. #include <map_pars_fragment>
  3357. #include <alphamap_pars_fragment>
  3358. #include <alphatest_pars_fragment>
  3359. #include <alphahash_pars_fragment>
  3360. #include <aomap_pars_fragment>
  3361. #include <lightmap_pars_fragment>
  3362. #include <emissivemap_pars_fragment>
  3363. #include <iridescence_fragment>
  3364. #include <cube_uv_reflection_fragment>
  3365. #include <envmap_common_pars_fragment>
  3366. #include <envmap_physical_pars_fragment>
  3367. #include <fog_pars_fragment>
  3368. #include <lights_pars_begin>
  3369. #include <normal_pars_fragment>
  3370. #include <lights_physical_pars_fragment>
  3371. #include <transmission_pars_fragment>
  3372. #include <shadowmap_pars_fragment>
  3373. #include <bumpmap_pars_fragment>
  3374. #include <normalmap_pars_fragment>
  3375. #include <clearcoat_pars_fragment>
  3376. #include <iridescence_pars_fragment>
  3377. #include <roughnessmap_pars_fragment>
  3378. #include <metalnessmap_pars_fragment>
  3379. #include <logdepthbuf_pars_fragment>
  3380. #include <clipping_planes_pars_fragment>
  3381. void main() {
  3382. vec4 diffuseColor = vec4( diffuse, opacity );
  3383. #include <clipping_planes_fragment>
  3384. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3385. vec3 totalEmissiveRadiance = emissive;
  3386. #include <logdepthbuf_fragment>
  3387. #include <map_fragment>
  3388. #include <color_fragment>
  3389. #include <alphamap_fragment>
  3390. #include <alphatest_fragment>
  3391. #include <alphahash_fragment>
  3392. #include <roughnessmap_fragment>
  3393. #include <metalnessmap_fragment>
  3394. #include <normal_fragment_begin>
  3395. #include <normal_fragment_maps>
  3396. #include <clearcoat_normal_fragment_begin>
  3397. #include <clearcoat_normal_fragment_maps>
  3398. #include <emissivemap_fragment>
  3399. #include <lights_physical_fragment>
  3400. #include <lights_fragment_begin>
  3401. #include <lights_fragment_maps>
  3402. #include <lights_fragment_end>
  3403. #include <aomap_fragment>
  3404. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3405. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3406. #include <transmission_fragment>
  3407. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3408. #ifdef USE_SHEEN
  3409. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  3410. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  3411. #endif
  3412. #ifdef USE_CLEARCOAT
  3413. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3414. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3415. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3416. #endif
  3417. #include <opaque_fragment>
  3418. #include <tonemapping_fragment>
  3419. #include <colorspace_fragment>
  3420. #include <fog_fragment>
  3421. #include <premultiplied_alpha_fragment>
  3422. #include <dithering_fragment>
  3423. }`,Tje=`#define TOON
  3424. varying vec3 vViewPosition;
  3425. #include <common>
  3426. #include <batching_pars_vertex>
  3427. #include <uv_pars_vertex>
  3428. #include <displacementmap_pars_vertex>
  3429. #include <color_pars_vertex>
  3430. #include <fog_pars_vertex>
  3431. #include <normal_pars_vertex>
  3432. #include <morphtarget_pars_vertex>
  3433. #include <skinning_pars_vertex>
  3434. #include <shadowmap_pars_vertex>
  3435. #include <logdepthbuf_pars_vertex>
  3436. #include <clipping_planes_pars_vertex>
  3437. void main() {
  3438. #include <uv_vertex>
  3439. #include <color_vertex>
  3440. #include <morphinstance_vertex>
  3441. #include <morphcolor_vertex>
  3442. #include <batching_vertex>
  3443. #include <beginnormal_vertex>
  3444. #include <morphnormal_vertex>
  3445. #include <skinbase_vertex>
  3446. #include <skinnormal_vertex>
  3447. #include <defaultnormal_vertex>
  3448. #include <normal_vertex>
  3449. #include <begin_vertex>
  3450. #include <morphtarget_vertex>
  3451. #include <skinning_vertex>
  3452. #include <displacementmap_vertex>
  3453. #include <project_vertex>
  3454. #include <logdepthbuf_vertex>
  3455. #include <clipping_planes_vertex>
  3456. vViewPosition = - mvPosition.xyz;
  3457. #include <worldpos_vertex>
  3458. #include <shadowmap_vertex>
  3459. #include <fog_vertex>
  3460. }`,Nje=`#define TOON
  3461. uniform vec3 diffuse;
  3462. uniform vec3 emissive;
  3463. uniform float opacity;
  3464. #include <common>
  3465. #include <packing>
  3466. #include <dithering_pars_fragment>
  3467. #include <color_pars_fragment>
  3468. #include <uv_pars_fragment>
  3469. #include <map_pars_fragment>
  3470. #include <alphamap_pars_fragment>
  3471. #include <alphatest_pars_fragment>
  3472. #include <alphahash_pars_fragment>
  3473. #include <aomap_pars_fragment>
  3474. #include <lightmap_pars_fragment>
  3475. #include <emissivemap_pars_fragment>
  3476. #include <gradientmap_pars_fragment>
  3477. #include <fog_pars_fragment>
  3478. #include <bsdfs>
  3479. #include <lights_pars_begin>
  3480. #include <normal_pars_fragment>
  3481. #include <lights_toon_pars_fragment>
  3482. #include <shadowmap_pars_fragment>
  3483. #include <bumpmap_pars_fragment>
  3484. #include <normalmap_pars_fragment>
  3485. #include <logdepthbuf_pars_fragment>
  3486. #include <clipping_planes_pars_fragment>
  3487. void main() {
  3488. vec4 diffuseColor = vec4( diffuse, opacity );
  3489. #include <clipping_planes_fragment>
  3490. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3491. vec3 totalEmissiveRadiance = emissive;
  3492. #include <logdepthbuf_fragment>
  3493. #include <map_fragment>
  3494. #include <color_fragment>
  3495. #include <alphamap_fragment>
  3496. #include <alphatest_fragment>
  3497. #include <alphahash_fragment>
  3498. #include <normal_fragment_begin>
  3499. #include <normal_fragment_maps>
  3500. #include <emissivemap_fragment>
  3501. #include <lights_toon_fragment>
  3502. #include <lights_fragment_begin>
  3503. #include <lights_fragment_maps>
  3504. #include <lights_fragment_end>
  3505. #include <aomap_fragment>
  3506. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3507. #include <opaque_fragment>
  3508. #include <tonemapping_fragment>
  3509. #include <colorspace_fragment>
  3510. #include <fog_fragment>
  3511. #include <premultiplied_alpha_fragment>
  3512. #include <dithering_fragment>
  3513. }`,Cje=`uniform float size;
  3514. uniform float scale;
  3515. #include <common>
  3516. #include <color_pars_vertex>
  3517. #include <fog_pars_vertex>
  3518. #include <morphtarget_pars_vertex>
  3519. #include <logdepthbuf_pars_vertex>
  3520. #include <clipping_planes_pars_vertex>
  3521. #ifdef USE_POINTS_UV
  3522. varying vec2 vUv;
  3523. uniform mat3 uvTransform;
  3524. #endif
  3525. void main() {
  3526. #ifdef USE_POINTS_UV
  3527. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3528. #endif
  3529. #include <color_vertex>
  3530. #include <morphinstance_vertex>
  3531. #include <morphcolor_vertex>
  3532. #include <begin_vertex>
  3533. #include <morphtarget_vertex>
  3534. #include <project_vertex>
  3535. gl_PointSize = size;
  3536. #ifdef USE_SIZEATTENUATION
  3537. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3538. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3539. #endif
  3540. #include <logdepthbuf_vertex>
  3541. #include <clipping_planes_vertex>
  3542. #include <worldpos_vertex>
  3543. #include <fog_vertex>
  3544. }`,kje=`uniform vec3 diffuse;
  3545. uniform float opacity;
  3546. #include <common>
  3547. #include <color_pars_fragment>
  3548. #include <map_particle_pars_fragment>
  3549. #include <alphatest_pars_fragment>
  3550. #include <alphahash_pars_fragment>
  3551. #include <fog_pars_fragment>
  3552. #include <logdepthbuf_pars_fragment>
  3553. #include <clipping_planes_pars_fragment>
  3554. void main() {
  3555. vec4 diffuseColor = vec4( diffuse, opacity );
  3556. #include <clipping_planes_fragment>
  3557. vec3 outgoingLight = vec3( 0.0 );
  3558. #include <logdepthbuf_fragment>
  3559. #include <map_particle_fragment>
  3560. #include <color_fragment>
  3561. #include <alphatest_fragment>
  3562. #include <alphahash_fragment>
  3563. outgoingLight = diffuseColor.rgb;
  3564. #include <opaque_fragment>
  3565. #include <tonemapping_fragment>
  3566. #include <colorspace_fragment>
  3567. #include <fog_fragment>
  3568. #include <premultiplied_alpha_fragment>
  3569. }`,Pje=`#include <common>
  3570. #include <batching_pars_vertex>
  3571. #include <fog_pars_vertex>
  3572. #include <morphtarget_pars_vertex>
  3573. #include <skinning_pars_vertex>
  3574. #include <logdepthbuf_pars_vertex>
  3575. #include <shadowmap_pars_vertex>
  3576. void main() {
  3577. #include <batching_vertex>
  3578. #include <beginnormal_vertex>
  3579. #include <morphinstance_vertex>
  3580. #include <morphnormal_vertex>
  3581. #include <skinbase_vertex>
  3582. #include <skinnormal_vertex>
  3583. #include <defaultnormal_vertex>
  3584. #include <begin_vertex>
  3585. #include <morphtarget_vertex>
  3586. #include <skinning_vertex>
  3587. #include <project_vertex>
  3588. #include <logdepthbuf_vertex>
  3589. #include <worldpos_vertex>
  3590. #include <shadowmap_vertex>
  3591. #include <fog_vertex>
  3592. }`,jje=`uniform vec3 color;
  3593. uniform float opacity;
  3594. #include <common>
  3595. #include <packing>
  3596. #include <fog_pars_fragment>
  3597. #include <bsdfs>
  3598. #include <lights_pars_begin>
  3599. #include <logdepthbuf_pars_fragment>
  3600. #include <shadowmap_pars_fragment>
  3601. #include <shadowmask_pars_fragment>
  3602. void main() {
  3603. #include <logdepthbuf_fragment>
  3604. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3605. #include <tonemapping_fragment>
  3606. #include <colorspace_fragment>
  3607. #include <fog_fragment>
  3608. }`,Rje=`uniform float rotation;
  3609. uniform vec2 center;
  3610. #include <common>
  3611. #include <uv_pars_vertex>
  3612. #include <fog_pars_vertex>
  3613. #include <logdepthbuf_pars_vertex>
  3614. #include <clipping_planes_pars_vertex>
  3615. void main() {
  3616. #include <uv_vertex>
  3617. vec4 mvPosition = modelViewMatrix[ 3 ];
  3618. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3619. #ifndef USE_SIZEATTENUATION
  3620. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3621. if ( isPerspective ) scale *= - mvPosition.z;
  3622. #endif
  3623. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3624. vec2 rotatedPosition;
  3625. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3626. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3627. mvPosition.xy += rotatedPosition;
  3628. gl_Position = projectionMatrix * mvPosition;
  3629. #include <logdepthbuf_vertex>
  3630. #include <clipping_planes_vertex>
  3631. #include <fog_vertex>
  3632. }`,Dje=`uniform vec3 diffuse;
  3633. uniform float opacity;
  3634. #include <common>
  3635. #include <uv_pars_fragment>
  3636. #include <map_pars_fragment>
  3637. #include <alphamap_pars_fragment>
  3638. #include <alphatest_pars_fragment>
  3639. #include <alphahash_pars_fragment>
  3640. #include <fog_pars_fragment>
  3641. #include <logdepthbuf_pars_fragment>
  3642. #include <clipping_planes_pars_fragment>
  3643. void main() {
  3644. vec4 diffuseColor = vec4( diffuse, opacity );
  3645. #include <clipping_planes_fragment>
  3646. vec3 outgoingLight = vec3( 0.0 );
  3647. #include <logdepthbuf_fragment>
  3648. #include <map_fragment>
  3649. #include <alphamap_fragment>
  3650. #include <alphatest_fragment>
  3651. #include <alphahash_fragment>
  3652. outgoingLight = diffuseColor.rgb;
  3653. #include <opaque_fragment>
  3654. #include <tonemapping_fragment>
  3655. #include <colorspace_fragment>
  3656. #include <fog_fragment>
  3657. }`,gn={alphahash_fragment:n3e,alphahash_pars_fragment:r3e,alphamap_fragment:i3e,alphamap_pars_fragment:a3e,alphatest_fragment:s3e,alphatest_pars_fragment:o3e,aomap_fragment:l3e,aomap_pars_fragment:c3e,batching_pars_vertex:u3e,batching_vertex:d3e,begin_vertex:h3e,beginnormal_vertex:f3e,bsdfs:m3e,iridescence_fragment:p3e,bumpmap_pars_fragment:g3e,clipping_planes_fragment:x3e,clipping_planes_pars_fragment:b3e,clipping_planes_pars_vertex:y3e,clipping_planes_vertex:v3e,color_fragment:_3e,color_pars_fragment:w3e,color_pars_vertex:S3e,color_vertex:M3e,common:E3e,cube_uv_reflection_fragment:A3e,defaultnormal_vertex:T3e,displacementmap_pars_vertex:N3e,displacementmap_vertex:C3e,emissivemap_fragment:k3e,emissivemap_pars_fragment:P3e,colorspace_fragment:j3e,colorspace_pars_fragment:R3e,envmap_fragment:D3e,envmap_common_pars_fragment:O3e,envmap_pars_fragment:L3e,envmap_pars_vertex:I3e,envmap_physical_pars_fragment:K3e,envmap_vertex:F3e,fog_vertex:U3e,fog_pars_vertex:z3e,fog_fragment:B3e,fog_pars_fragment:H3e,gradientmap_pars_fragment:$3e,lightmap_pars_fragment:V3e,lights_lambert_fragment:G3e,lights_lambert_pars_fragment:W3e,lights_pars_begin:q3e,lights_toon_fragment:X3e,lights_toon_pars_fragment:Y3e,lights_phong_fragment:Z3e,lights_phong_pars_fragment:Q3e,lights_physical_fragment:J3e,lights_physical_pars_fragment:ePe,lights_fragment_begin:tPe,lights_fragment_maps:nPe,lights_fragment_end:rPe,logdepthbuf_fragment:iPe,logdepthbuf_pars_fragment:aPe,logdepthbuf_pars_vertex:sPe,logdepthbuf_vertex:oPe,map_fragment:lPe,map_pars_fragment:cPe,map_particle_fragment:uPe,map_particle_pars_fragment:dPe,metalnessmap_fragment:hPe,metalnessmap_pars_fragment:fPe,morphinstance_vertex:mPe,morphcolor_vertex:pPe,morphnormal_vertex:gPe,morphtarget_pars_vertex:xPe,morphtarget_vertex:bPe,normal_fragment_begin:yPe,normal_fragment_maps:vPe,normal_pars_fragment:_Pe,normal_pars_vertex:wPe,normal_vertex:SPe,normalmap_pars_fragment:MPe,clearcoat_normal_fragment_begin:EPe,clearcoat_normal_fragment_maps:APe,clearcoat_pars_fragment:TPe,iridescence_pars_fragment:NPe,opaque_fragment:CPe,packing:kPe,premultiplied_alpha_fragment:PPe,project_vertex:jPe,dithering_fragment:RPe,dithering_pars_fragment:DPe,roughnessmap_fragment:OPe,roughnessmap_pars_fragment:LPe,shadowmap_pars_fragment:IPe,shadowmap_pars_vertex:FPe,shadowmap_vertex:UPe,shadowmask_pars_fragment:zPe,skinbase_vertex:BPe,skinning_pars_vertex:HPe,skinning_vertex:$Pe,skinnormal_vertex:VPe,specularmap_fragment:GPe,specularmap_pars_fragment:WPe,tonemapping_fragment:qPe,tonemapping_pars_fragment:KPe,transmission_fragment:XPe,transmission_pars_fragment:YPe,uv_pars_fragment:ZPe,uv_pars_vertex:QPe,uv_vertex:JPe,worldpos_vertex:eje,background_vert:tje,background_frag:nje,backgroundCube_vert:rje,backgroundCube_frag:ije,cube_vert:aje,cube_frag:sje,depth_vert:oje,depth_frag:lje,distanceRGBA_vert:cje,distanceRGBA_frag:uje,equirect_vert:dje,equirect_frag:hje,linedashed_vert:fje,linedashed_frag:mje,meshbasic_vert:pje,meshbasic_frag:gje,meshlambert_vert:xje,meshlambert_frag:bje,meshmatcap_vert:yje,meshmatcap_frag:vje,meshnormal_vert:_je,meshnormal_frag:wje,meshphong_vert:Sje,meshphong_frag:Mje,meshphysical_vert:Eje,meshphysical_frag:Aje,meshtoon_vert:Tje,meshtoon_frag:Nje,points_vert:Cje,points_frag:kje,shadow_vert:Pje,shadow_frag:jje,sprite_vert:Rje,sprite_frag:Dje},Pt={common:{diffuse:{value:new Nn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new vn},alphaMap:{value:null},alphaMapTransform:{value:new vn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new vn}},envmap:{envMap:{value:null},envMapRotation:{value:new vn},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 vn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new vn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new vn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new vn},normalScale:{value:new bn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new vn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new vn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new vn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new vn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Nn(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 Nn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new vn},alphaTest:{value:0},uvTransform:{value:new vn}},sprite:{diffuse:{value:new Nn(16777215)},opacity:{value:1},center:{value:new bn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new vn},alphaMap:{value:null},alphaMapTransform:{value:new vn},alphaTest:{value:0}}},ul={basic:{uniforms:Ca([Pt.common,Pt.specularmap,Pt.envmap,Pt.aomap,Pt.lightmap,Pt.fog]),vertexShader:gn.meshbasic_vert,fragmentShader:gn.meshbasic_frag},lambert:{uniforms:Ca([Pt.common,Pt.specularmap,Pt.envmap,Pt.aomap,Pt.lightmap,Pt.emissivemap,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.fog,Pt.lights,{emissive:{value:new Nn(0)}}]),vertexShader:gn.meshlambert_vert,fragmentShader:gn.meshlambert_frag},phong:{uniforms:Ca([Pt.common,Pt.specularmap,Pt.envmap,Pt.aomap,Pt.lightmap,Pt.emissivemap,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.fog,Pt.lights,{emissive:{value:new Nn(0)},specular:{value:new Nn(1118481)},shininess:{value:30}}]),vertexShader:gn.meshphong_vert,fragmentShader:gn.meshphong_frag},standard:{uniforms:Ca([Pt.common,Pt.envmap,Pt.aomap,Pt.lightmap,Pt.emissivemap,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.roughnessmap,Pt.metalnessmap,Pt.fog,Pt.lights,{emissive:{value:new Nn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:gn.meshphysical_vert,fragmentShader:gn.meshphysical_frag},toon:{uniforms:Ca([Pt.common,Pt.aomap,Pt.lightmap,Pt.emissivemap,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.gradientmap,Pt.fog,Pt.lights,{emissive:{value:new Nn(0)}}]),vertexShader:gn.meshtoon_vert,fragmentShader:gn.meshtoon_frag},matcap:{uniforms:Ca([Pt.common,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.fog,{matcap:{value:null}}]),vertexShader:gn.meshmatcap_vert,fragmentShader:gn.meshmatcap_frag},points:{uniforms:Ca([Pt.points,Pt.fog]),vertexShader:gn.points_vert,fragmentShader:gn.points_frag},dashed:{uniforms:Ca([Pt.common,Pt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:gn.linedashed_vert,fragmentShader:gn.linedashed_frag},depth:{uniforms:Ca([Pt.common,Pt.displacementmap]),vertexShader:gn.depth_vert,fragmentShader:gn.depth_frag},normal:{uniforms:Ca([Pt.common,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,{opacity:{value:1}}]),vertexShader:gn.meshnormal_vert,fragmentShader:gn.meshnormal_frag},sprite:{uniforms:Ca([Pt.sprite,Pt.fog]),vertexShader:gn.sprite_vert,fragmentShader:gn.sprite_frag},background:{uniforms:{uvTransform:{value:new vn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:gn.background_vert,fragmentShader:gn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new vn}},vertexShader:gn.backgroundCube_vert,fragmentShader:gn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:gn.cube_vert,fragmentShader:gn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:gn.equirect_vert,fragmentShader:gn.equirect_frag},distanceRGBA:{uniforms:Ca([Pt.common,Pt.displacementmap,{referencePosition:{value:new it},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:gn.distanceRGBA_vert,fragmentShader:gn.distanceRGBA_frag},shadow:{uniforms:Ca([Pt.lights,Pt.fog,{color:{value:new Nn(0)},opacity:{value:1}}]),vertexShader:gn.shadow_vert,fragmentShader:gn.shadow_frag}};ul.physical={uniforms:Ca([ul.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new vn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new vn},clearcoatNormalScale:{value:new bn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new vn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new vn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new vn},sheen:{value:0},sheenColor:{value:new Nn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new vn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new vn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new vn},transmissionSamplerSize:{value:new bn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new vn},attenuationDistance:{value:0},attenuationColor:{value:new Nn(0)},specularColor:{value:new Nn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new vn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new vn},anisotropyVector:{value:new bn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new vn}}]),vertexShader:gn.meshphysical_vert,fragmentShader:gn.meshphysical_frag};const m_={r:0,b:0,g:0},oh=new Nd,Oje=new mi;function Lje(t,e,n,r,i,a,s){const l=new Nn(0);let c=a===!0?0:1,u,d,f=null,g=0,p=null;function b(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=b(w);T===null?y(l,c):T&&T.isColor&&(y(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 x(w,A){const T=b(A);T&&(T.isCubeTexture||T.mapping===tE)?(d===void 0&&(d=new Tl(new FO(1,1,1),new Yc({name:"BackgroundCubeMaterial",uniforms:Hp(ul.backgroundCube.uniforms),vertexShader:ul.backgroundCube.vertexShader,fragmentShader:ul.backgroundCube.fragmentShader,side:ns,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)),oh.copy(A.backgroundRotation),oh.x*=-1,oh.y*=-1,oh.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(oh.y*=-1,oh.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(Oje.makeRotationFromEuler(oh)),d.material.toneMapped=zn.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 zO(2,2),new Yc({name:"BackgroundMaterial",uniforms:Hp(ul.background.uniforms),vertexShader:ul.background.vertexShader,fragmentShader:ul.background.fragmentShader,side:Td,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=zn.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 y(w,A){w.getRGB(m_,VZ(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,y(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(w){c=w,y(l,c)},render:v,addToRenderList:x,dispose:E}}function Ije(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=g(null);let a=i,s=!1;function l(j,z,I,q,R){let W=!1;const K=f(q,I,z);a!==K&&(a=K,u(a.object)),W=p(j,q,I,R),W&&b(j,q,I,R),R!==null&&e.update(R,t.ELEMENT_ARRAY_BUFFER),(W||s)&&(s=!1,A(j,z,I,q),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,z,I){const q=I.wireframe===!0;let R=r[j.id];R===void 0&&(R={},r[j.id]=R);let W=R[z.id];W===void 0&&(W={},R[z.id]=W);let K=W[q];return K===void 0&&(K=g(c()),W[q]=K),K}function g(j){const z=[],I=[],q=[];for(let R=0;R<n;R++)z[R]=0,I[R]=0,q[R]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:z,enabledAttributes:I,attributeDivisors:q,object:j,attributes:{},index:null}}function p(j,z,I,q){const R=a.attributes,W=z.attributes;let K=0;const G=I.getAttributes();for(const J in G)if(G[J].location>=0){const Z=R[J];let F=W[J];if(F===void 0&&(J==="instanceMatrix"&&j.instanceMatrix&&(F=j.instanceMatrix),J==="instanceColor"&&j.instanceColor&&(F=j.instanceColor)),Z===void 0||Z.attribute!==F||F&&Z.data!==F.data)return!0;K++}return a.attributesNum!==K||a.index!==q}function b(j,z,I,q){const R={},W=z.attributes;let K=0;const G=I.getAttributes();for(const J in G)if(G[J].location>=0){let Z=W[J];Z===void 0&&(J==="instanceMatrix"&&j.instanceMatrix&&(Z=j.instanceMatrix),J==="instanceColor"&&j.instanceColor&&(Z=j.instanceColor));const F={};F.attribute=Z,Z&&Z.data&&(F.data=Z.data),R[J]=F,K++}a.attributes=R,a.attributesNum=K,a.index=q}function v(){const j=a.newAttributes;for(let z=0,I=j.length;z<I;z++)j[z]=0}function x(j){y(j,0)}function y(j,z){const I=a.newAttributes,q=a.enabledAttributes,R=a.attributeDivisors;I[j]=1,q[j]===0&&(t.enableVertexAttribArray(j),q[j]=1),R[j]!==z&&(t.vertexAttribDivisor(j,z),R[j]=z)}function E(){const j=a.newAttributes,z=a.enabledAttributes;for(let I=0,q=z.length;I<q;I++)z[I]!==j[I]&&(t.disableVertexAttribArray(I),z[I]=0)}function w(j,z,I,q,R,W,K){K===!0?t.vertexAttribIPointer(j,z,I,R,W):t.vertexAttribPointer(j,z,I,q,R,W)}function A(j,z,I,q){v();const R=q.attributes,W=I.getAttributes(),K=z.defaultAttributeValues;for(const G in W){const J=W[G];if(J.location>=0){let ee=R[G];if(ee===void 0&&(G==="instanceMatrix"&&j.instanceMatrix&&(ee=j.instanceMatrix),G==="instanceColor"&&j.instanceColor&&(ee=j.instanceColor)),ee!==void 0){const Z=ee.normalized,F=ee.itemSize,V=e.get(ee);if(V===void 0)continue;const ne=V.buffer,le=V.type,oe=V.bytesPerElement,pe=le===t.INT||le===t.UNSIGNED_INT||ee.gpuType===NO;if(ee.isInterleavedBufferAttribute){const Q=ee.data,Ee=Q.stride,he=ee.offset;if(Q.isInstancedInterleavedBuffer){for(let ue=0;ue<J.locationSize;ue++)y(J.location+ue,Q.meshPerAttribute);j.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=Q.meshPerAttribute*Q.count)}else for(let ue=0;ue<J.locationSize;ue++)x(J.location+ue);t.bindBuffer(t.ARRAY_BUFFER,ne);for(let ue=0;ue<J.locationSize;ue++)w(J.location+ue,F/J.locationSize,le,Z,Ee*oe,(he+F/J.locationSize*ue)*oe,pe)}else{if(ee.isInstancedBufferAttribute){for(let Q=0;Q<J.locationSize;Q++)y(J.location+Q,ee.meshPerAttribute);j.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let Q=0;Q<J.locationSize;Q++)x(J.location+Q);t.bindBuffer(t.ARRAY_BUFFER,ne);for(let Q=0;Q<J.locationSize;Q++)w(J.location+Q,F/J.locationSize,le,Z,F*oe,F/J.locationSize*Q*oe,pe)}}else if(K!==void 0){const Z=K[G];if(Z!==void 0)switch(Z.length){case 2:t.vertexAttrib2fv(J.location,Z);break;case 3:t.vertexAttrib3fv(J.location,Z);break;case 4:t.vertexAttrib4fv(J.location,Z);break;default:t.vertexAttrib1fv(J.location,Z)}}}}E()}function T(){O();for(const j in r){const z=r[j];for(const I in z){const q=z[I];for(const R in q)d(q[R].object),delete q[R];delete z[I]}delete r[j]}}function C(j){if(r[j.id]===void 0)return;const z=r[j.id];for(const I in z){const q=z[I];for(const R in q)d(q[R].object),delete q[R];delete z[I]}delete r[j.id]}function N(j){for(const z in r){const I=r[z];if(I[j.id]===void 0)continue;const q=I[j.id];for(const R in q)d(q[R].object),delete q[R];delete I[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:x,disableUnusedAttributes:E}}function Fje(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 b=0;b<f;b++)p+=d[b];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 b=0;b<u.length;b++)s(u[b],d[b],g[b]);else{p.multiDrawArraysInstancedWEBGL(r,u,0,d,0,g,0,f);let b=0;for(let v=0;v<f;v++)b+=d[v]*g[v];n.update(b,r,1)}}this.setMode=i,this.render=a,this.renderInstances=s,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function Uje(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&&(nn("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),b=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=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=b>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:b,maxTextureSize:v,maxCubemapSize:x,maxAttributes:y,maxVertexUniforms:E,maxVaryings:w,maxFragmentUniforms:A,vertexTextures:T,maxSamples:C}}function zje(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new Gu,l=new vn,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 b=f.clippingPlanes,v=f.clipIntersection,x=f.clipShadows,y=t.get(f);if(!i||b===null||b.length===0||a&&!x)a?d(null):u();else{const E=a?0:r,w=E*4;let A=y.clippingState||null;c.value=A,A=d(b,g,w,p);for(let T=0;T!==w;++T)A[T]=n[T];y.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,b){const v=f!==null?f.length:0;let x=null;if(v!==0){if(x=c.value,b!==!0||x===null){const y=p+v*4,E=g.matrixWorldInverse;l.getNormalMatrix(E),(x===null||x.length<y)&&(x=new Float32Array(y));for(let w=0,A=p;w!==v;++w,A+=4)s.copy(f[w]).applyMatrix4(E,l),s.normal.toArray(x,A),x[A+3]=s.constant}c.value=x,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,x}}function Bje(t){let e=new WeakMap;function n(s,l){return l===xP?s.mapping=Up:l===bP&&(s.mapping=zp),s}function r(s){if(s&&s.isTexture){const l=s.mapping;if(l===xP||l===bP)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 Lke(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 nd=4,XH=[.125,.215,.35,.446,.526,.582],wh=20,Hje=256,Ox=new QZ,YH=new Nn;let oC=null,lC=0,cC=0,uC=!1;const $je=new it;let ZH=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=$je}=a;oC=this._renderer.getRenderTarget(),lC=this._renderer.getActiveCubeFace(),cC=this._renderer.getActiveMipmapLevel(),uC=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=e$(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=JH(),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(oC,lC,cC),this._renderer.xr.enabled=uC,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),oC=this._renderer.getRenderTarget(),lC=this._renderer.getActiveCubeFace(),cC=this._renderer.getActiveMipmapLevel(),uC=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:lo,minFilter:lo,generateMipmaps:!1,type:yg,format:Fo,colorSpace:Bp,depthBuffer:!1},i=QH(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=QH(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Vje(a)),this._blurMaterial=Wje(a,e,n),this._ggxMaterial=Gje(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 no(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(YH),f.toneMapping=ud,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Tl(new FO,new IO({name:"PMREM.Background",side:ns,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,x=v.material;let y=!1;const E=e.background;E?E.isColor&&(x.color.copy(E),e.background=null,y=!0):(x.color.copy(YH),y=!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),y&&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=e$()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=JH());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:b}=this,v=this._sizeLods[r],x=3*v*(r>b-nd?r-b+nd:0),y=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=b-n,Tm(a,x,y,3*v,2*v),i.setRenderTarget(a),i.render(l,Ox),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=b-r,Tm(e,x,y,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,b=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*wh-1),v=a/b,x=isFinite(a)?1+Math.floor(d*v):wh;x>wh&&nn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${wh}`);const y=[];let E=0;for(let N=0;N<wh;++N){const O=N/v,k=Math.exp(-O*O/2);y.push(k),N===0?E+=k:N<x&&(E+=2*k)}for(let N=0;N<y.length;N++)y[N]=y[N]/E;g.envMap.value=e.texture,g.samples.value=x,g.weights.value=y,g.latitudinal.value=s==="latitudinal",l&&(g.poleAxis.value=l);const{_lodMax:w}=this;g.dTheta.value=b,g.mipInt.value=w-r;const A=this._sizeLods[i],T=3*A*(i>w-nd?i-w+nd:0),C=4*(this._cubeSize-A);Tm(n,T,C,3*A,2*A),c.setRenderTarget(n),c.render(f,Ox)}};function Vje(t){const e=[],n=[],r=[];let i=t;const a=t-nd+1+XH.length;for(let s=0;s<a;s++){const l=Math.pow(2,i);e.push(l);let c=1/l;s>t-nd?c=XH[s-t+nd-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,b=6,v=3,x=2,y=1,E=new Float32Array(v*b*p),w=new Float32Array(x*b*p),A=new Float32Array(y*b*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*b*C),w.set(g,x*b*C);const j=[C,C,C,C,C,C];A.set(j,y*b*C)}const T=new Ll;T.setAttribute("position",new ho(E,v)),T.setAttribute("uv",new ho(w,x)),T.setAttribute("faceIndex",new ho(A,y)),r.push(new Tl(T,null)),i>nd&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function QH(t,e,n){const r=new gf(t,e,n);return r.texture.mapping=tE,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 Gje(t,e,n){return new Yc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Hje,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:rE(),fragmentShader:`
  3658. precision highp float;
  3659. precision highp int;
  3660. varying vec3 vOutputDirection;
  3661. uniform sampler2D envMap;
  3662. uniform float roughness;
  3663. uniform float mipInt;
  3664. #define ENVMAP_TYPE_CUBE_UV
  3665. #include <cube_uv_reflection_fragment>
  3666. #define PI 3.14159265359
  3667. // Van der Corput radical inverse
  3668. float radicalInverse_VdC(uint bits) {
  3669. bits = (bits << 16u) | (bits >> 16u);
  3670. bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
  3671. bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
  3672. bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
  3673. bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
  3674. return float(bits) * 2.3283064365386963e-10; // / 0x100000000
  3675. }
  3676. // Hammersley sequence
  3677. vec2 hammersley(uint i, uint N) {
  3678. return vec2(float(i) / float(N), radicalInverse_VdC(i));
  3679. }
  3680. // GGX VNDF importance sampling (Eric Heitz 2018)
  3681. // "Sampling the GGX Distribution of Visible Normals"
  3682. // https://jcgt.org/published/0007/04/01/
  3683. vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
  3684. float alpha = roughness * roughness;
  3685. // Section 3.2: Transform view direction to hemisphere configuration
  3686. vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
  3687. // Section 4.1: Orthonormal basis
  3688. float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
  3689. vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
  3690. vec3 T2 = cross(Vh, T1);
  3691. // Section 4.2: Parameterization of projected area
  3692. float r = sqrt(Xi.x);
  3693. float phi = 2.0 * PI * Xi.y;
  3694. float t1 = r * cos(phi);
  3695. float t2 = r * sin(phi);
  3696. float s = 0.5 * (1.0 + Vh.z);
  3697. t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
  3698. // Section 4.3: Reprojection onto hemisphere
  3699. vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
  3700. // Section 3.4: Transform back to ellipsoid configuration
  3701. return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
  3702. }
  3703. void main() {
  3704. vec3 N = normalize(vOutputDirection);
  3705. vec3 V = N; // Assume view direction equals normal for pre-filtering
  3706. vec3 prefilteredColor = vec3(0.0);
  3707. float totalWeight = 0.0;
  3708. // For very low roughness, just sample the environment directly
  3709. if (roughness < 0.001) {
  3710. gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
  3711. return;
  3712. }
  3713. // Tangent space basis for VNDF sampling
  3714. vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  3715. vec3 tangent = normalize(cross(up, N));
  3716. vec3 bitangent = cross(N, tangent);
  3717. for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
  3718. vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
  3719. // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
  3720. vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
  3721. // Transform H back to world space
  3722. vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
  3723. vec3 L = normalize(2.0 * dot(V, H) * H - V);
  3724. float NdotL = max(dot(N, L), 0.0);
  3725. if(NdotL > 0.0) {
  3726. // Sample environment at fixed mip level
  3727. // VNDF importance sampling handles the distribution filtering
  3728. vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
  3729. // Weight by NdotL for the split-sum approximation
  3730. // VNDF PDF naturally accounts for the visible microfacet distribution
  3731. prefilteredColor += sampleColor * NdotL;
  3732. totalWeight += NdotL;
  3733. }
  3734. }
  3735. if (totalWeight > 0.0) {
  3736. prefilteredColor = prefilteredColor / totalWeight;
  3737. }
  3738. gl_FragColor = vec4(prefilteredColor, 1.0);
  3739. }
  3740. `,blending:Dc,depthTest:!1,depthWrite:!1})}function Wje(t,e,n){const r=new Float32Array(wh),i=new it(0,1,0);return new Yc({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:rE(),fragmentShader:`
  3741. precision mediump float;
  3742. precision mediump int;
  3743. varying vec3 vOutputDirection;
  3744. uniform sampler2D envMap;
  3745. uniform int samples;
  3746. uniform float weights[ n ];
  3747. uniform bool latitudinal;
  3748. uniform float dTheta;
  3749. uniform float mipInt;
  3750. uniform vec3 poleAxis;
  3751. #define ENVMAP_TYPE_CUBE_UV
  3752. #include <cube_uv_reflection_fragment>
  3753. vec3 getSample( float theta, vec3 axis ) {
  3754. float cosTheta = cos( theta );
  3755. // Rodrigues' axis-angle rotation
  3756. vec3 sampleDirection = vOutputDirection * cosTheta
  3757. + cross( axis, vOutputDirection ) * sin( theta )
  3758. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3759. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3760. }
  3761. void main() {
  3762. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3763. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3764. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3765. }
  3766. axis = normalize( axis );
  3767. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3768. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3769. for ( int i = 1; i < n; i++ ) {
  3770. if ( i >= samples ) {
  3771. break;
  3772. }
  3773. float theta = dTheta * float( i );
  3774. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3775. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3776. }
  3777. }
  3778. `,blending:Dc,depthTest:!1,depthWrite:!1})}function JH(){return new Yc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:rE(),fragmentShader:`
  3779. precision mediump float;
  3780. precision mediump int;
  3781. varying vec3 vOutputDirection;
  3782. uniform sampler2D envMap;
  3783. #include <common>
  3784. void main() {
  3785. vec3 outputDirection = normalize( vOutputDirection );
  3786. vec2 uv = equirectUv( outputDirection );
  3787. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3788. }
  3789. `,blending:Dc,depthTest:!1,depthWrite:!1})}function e$(){return new Yc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:rE(),fragmentShader:`
  3790. precision mediump float;
  3791. precision mediump int;
  3792. uniform float flipEnvMap;
  3793. varying vec3 vOutputDirection;
  3794. uniform samplerCube envMap;
  3795. void main() {
  3796. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3797. }
  3798. `,blending:Dc,depthTest:!1,depthWrite:!1})}function rE(){return`
  3799. precision mediump float;
  3800. precision mediump int;
  3801. attribute float faceIndex;
  3802. varying vec3 vOutputDirection;
  3803. // RH coordinate system; PMREM face-indexing convention
  3804. vec3 getDirection( vec2 uv, float face ) {
  3805. uv = 2.0 * uv - 1.0;
  3806. vec3 direction = vec3( uv, 1.0 );
  3807. if ( face == 0.0 ) {
  3808. direction = direction.zyx; // ( 1, v, u ) pos x
  3809. } else if ( face == 1.0 ) {
  3810. direction = direction.xzy;
  3811. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3812. } else if ( face == 2.0 ) {
  3813. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3814. } else if ( face == 3.0 ) {
  3815. direction = direction.zyx;
  3816. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3817. } else if ( face == 4.0 ) {
  3818. direction = direction.xzy;
  3819. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3820. } else if ( face == 5.0 ) {
  3821. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3822. }
  3823. return direction;
  3824. }
  3825. void main() {
  3826. vOutputDirection = getDirection( uv, faceIndex );
  3827. gl_Position = vec4( position, 1.0 );
  3828. }
  3829. `}function qje(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===xP||c===bP,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 ZH(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 ZH(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 Kje(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 Xje(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 b in g.attributes)e.remove(g.attributes[b]);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,b=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(b!==void 0){const E=b.array;v=b.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 x=new(PZ(g)?BZ:zZ)(g,1);x.version=v;const y=a.get(f);y&&e.remove(y),a.set(f,x)}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 Yje(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,b){b!==0&&(t.drawElementsInstanced(r,p,a,g*s,b),n.update(p,r,b))}function d(g,p,b){if(b===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,p,0,a,g,0,b);let x=0;for(let y=0;y<b;y++)x+=p[y];n.update(x,r,1)}function f(g,p,b,v){if(b===0)return;const x=e.get("WEBGL_multi_draw");if(x===null)for(let y=0;y<g.length;y++)u(g[y]/s,p[y],v[y]);else{x.multiDrawElementsInstancedWEBGL(r,p,0,a,g,0,v,0,b);let y=0;for(let E=0;E<b;E++)y+=p[E]*v[E];n.update(y,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function Zje(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 Qje(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 b=l.morphAttributes.position!==void 0,v=l.morphAttributes.normal!==void 0,x=l.morphAttributes.color!==void 0,y=l.morphAttributes.position||[],E=l.morphAttributes.normal||[],w=l.morphAttributes.color||[];let A=0;b===!0&&(A=1),v===!0&&(A=2),x===!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 LZ(N,T,C,f);O.type=Nc,O.needsUpdate=!0;const k=A*4;for(let z=0;z<f;z++){const I=y[z],q=E[z],R=w[z],W=T*C*4*z;for(let K=0;K<I.count;K++){const G=K*k;b===!0&&(i.fromBufferAttribute(I,K),N[W+G+0]=i.x,N[W+G+1]=i.y,N[W+G+2]=i.z,N[W+G+3]=0),v===!0&&(i.fromBufferAttribute(q,K),N[W+G+4]=i.x,N[W+G+5]=i.y,N[W+G+6]=i.z,N[W+G+7]=0),x===!0&&(i.fromBufferAttribute(R,K),N[W+G+8]=i.x,N[W+G+9]=i.y,N[W+G+10]=i.z,N[W+G+11]=R.itemSize===4?i.w:1)}}g={count:f,texture:O,size:new bn(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 b=0;for(let x=0;x<u.length;x++)b+=u[x];const v=l.morphTargetsRelative?1:1-b;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 Jje(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 eQ=new Yo,t$=new KZ(1,1),tQ=new LZ,nQ=new yke,rQ=new WZ,n$=[],r$=[],i$=new Float32Array(16),a$=new Float32Array(9),s$=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=n$[i];if(a===void 0&&(a=new Float32Array(i),n$[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 wi(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 Si(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function iE(t,e){let n=r$[e];n===void 0&&(n=new Int32Array(e),r$[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function eRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function tRe(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(wi(n,e))return;t.uniform2fv(this.addr,e),Si(n,e)}}function nRe(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(wi(n,e))return;t.uniform3fv(this.addr,e),Si(n,e)}}function rRe(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(wi(n,e))return;t.uniform4fv(this.addr,e),Si(n,e)}}function iRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(wi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Si(n,e)}else{if(wi(n,r))return;s$.set(r),t.uniformMatrix2fv(this.addr,!1,s$),Si(n,r)}}function aRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(wi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Si(n,e)}else{if(wi(n,r))return;a$.set(r),t.uniformMatrix3fv(this.addr,!1,a$),Si(n,r)}}function sRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(wi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Si(n,e)}else{if(wi(n,r))return;i$.set(r),t.uniformMatrix4fv(this.addr,!1,i$),Si(n,r)}}function oRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function lRe(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(wi(n,e))return;t.uniform2iv(this.addr,e),Si(n,e)}}function cRe(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(wi(n,e))return;t.uniform3iv(this.addr,e),Si(n,e)}}function uRe(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(wi(n,e))return;t.uniform4iv(this.addr,e),Si(n,e)}}function dRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function hRe(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(wi(n,e))return;t.uniform2uiv(this.addr,e),Si(n,e)}}function fRe(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(wi(n,e))return;t.uniform3uiv(this.addr,e),Si(n,e)}}function mRe(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(wi(n,e))return;t.uniform4uiv(this.addr,e),Si(n,e)}}function pRe(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?(t$.compareFunction=kZ,a=t$):a=eQ,n.setTexture2D(e||a,i)}function gRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||nQ,i)}function xRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||rQ,i)}function bRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||tQ,i)}function yRe(t){switch(t){case 5126:return eRe;case 35664:return tRe;case 35665:return nRe;case 35666:return rRe;case 35674:return iRe;case 35675:return aRe;case 35676:return sRe;case 5124:case 35670:return oRe;case 35667:case 35671:return lRe;case 35668:case 35672:return cRe;case 35669:case 35673:return uRe;case 5125:return dRe;case 36294:return hRe;case 36295:return fRe;case 36296:return mRe;case 35678:case 36198:case 36298:case 36306:case 35682:return pRe;case 35679:case 36299:case 36307:return gRe;case 35680:case 36300:case 36308:case 36293:return xRe;case 36289:case 36303:case 36311:case 36292:return bRe}}function vRe(t,e){t.uniform1fv(this.addr,e)}function _Re(t,e){const n=_g(e,this.size,2);t.uniform2fv(this.addr,n)}function wRe(t,e){const n=_g(e,this.size,3);t.uniform3fv(this.addr,n)}function SRe(t,e){const n=_g(e,this.size,4);t.uniform4fv(this.addr,n)}function MRe(t,e){const n=_g(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function ERe(t,e){const n=_g(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function ARe(t,e){const n=_g(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function TRe(t,e){t.uniform1iv(this.addr,e)}function NRe(t,e){t.uniform2iv(this.addr,e)}function CRe(t,e){t.uniform3iv(this.addr,e)}function kRe(t,e){t.uniform4iv(this.addr,e)}function PRe(t,e){t.uniform1uiv(this.addr,e)}function jRe(t,e){t.uniform2uiv(this.addr,e)}function RRe(t,e){t.uniform3uiv(this.addr,e)}function DRe(t,e){t.uniform4uiv(this.addr,e)}function ORe(t,e,n){const r=this.cache,i=e.length,a=iE(n,i);wi(r,a)||(t.uniform1iv(this.addr,a),Si(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||eQ,a[s])}function LRe(t,e,n){const r=this.cache,i=e.length,a=iE(n,i);wi(r,a)||(t.uniform1iv(this.addr,a),Si(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||nQ,a[s])}function IRe(t,e,n){const r=this.cache,i=e.length,a=iE(n,i);wi(r,a)||(t.uniform1iv(this.addr,a),Si(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||rQ,a[s])}function FRe(t,e,n){const r=this.cache,i=e.length,a=iE(n,i);wi(r,a)||(t.uniform1iv(this.addr,a),Si(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||tQ,a[s])}function URe(t){switch(t){case 5126:return vRe;case 35664:return _Re;case 35665:return wRe;case 35666:return SRe;case 35674:return MRe;case 35675:return ERe;case 35676:return ARe;case 5124:case 35670:return TRe;case 35667:case 35671:return NRe;case 35668:case 35672:return CRe;case 35669:case 35673:return kRe;case 5125:return PRe;case 36294:return jRe;case 36295:return RRe;case 36296:return DRe;case 35678:case 36198:case 36298:case 36306:case 35682:return ORe;case 35679:case 36299:case 36307:return LRe;case 35680:case 36300:case 36308:case 36293:return IRe;case 36289:case 36303:case 36311:case 36292:return FRe}}let zRe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=yRe(n.type)}},BRe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=URe(n.type)}},HRe=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 dC=/(\w+)(\])?(\[|\.)?/g;function o$(t,e){t.seq.push(e),t.map[e.id]=e}function $Re(t,e,n){const r=t.name,i=r.length;for(dC.lastIndex=0;;){const a=dC.exec(r),s=dC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&s+2===i){o$(n,u===void 0?new zRe(l,t,e):new BRe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new HRe(l),o$(n,f)),n=f}}}let k1=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);$Re(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 l$(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const VRe=37297;let GRe=0;function WRe(t,e){const n=t.split(`
  3830. `),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(`
  3831. `)}const c$=new vn;function qRe(t){zn._getMatrix(c$,zn.workingColorSpace,t);const e=`mat3( ${c$.elements.map(n=>n.toFixed(4))} )`;switch(zn.getTransfer(t)){case Ww:return[e,"LinearTransferOETF"];case ar:return[e,"sRGBTransferOETF"];default:return nn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function u$(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()+`
  3832. `+a+`
  3833. `+WRe(t.getShaderSource(e),l)}else return a}function KRe(t,e){const n=qRe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3834. `)}function XRe(t,e){let n;switch(e){case WCe:n="Linear";break;case qCe:n="Reinhard";break;case KCe:n="Cineon";break;case XCe:n="ACESFilmic";break;case ZCe:n="AgX";break;case QCe:n="Neutral";break;case YCe:n="Custom";break;default:nn("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const p_=new it;function YRe(){zn.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(`
  3835. `)}function ZRe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Yx).join(`
  3836. `)}function QRe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3837. `)}function JRe(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 d$(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 h$(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const eDe=/^[ \t]*#include +<([\w\d./]+)>/gm;function ZP(t){return t.replace(eDe,nDe)}const tDe=new Map;function nDe(t,e){let n=gn[e];if(n===void 0){const r=tDe.get(e);if(r!==void 0)n=gn[r],nn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return ZP(n)}const rDe=/#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 f$(t){return t.replace(rDe,iDe)}function iDe(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 m$(t){let e=`precision ${t.precision} float;
  3838. precision ${t.precision} int;
  3839. precision ${t.precision} sampler2D;
  3840. precision ${t.precision} samplerCube;
  3841. precision ${t.precision} sampler3D;
  3842. precision ${t.precision} sampler2DArray;
  3843. precision ${t.precision} sampler2DShadow;
  3844. precision ${t.precision} samplerCubeShadow;
  3845. precision ${t.precision} sampler2DArrayShadow;
  3846. precision ${t.precision} isampler2D;
  3847. precision ${t.precision} isampler3D;
  3848. precision ${t.precision} isamplerCube;
  3849. precision ${t.precision} isampler2DArray;
  3850. precision ${t.precision} usampler2D;
  3851. precision ${t.precision} usampler3D;
  3852. precision ${t.precision} usamplerCube;
  3853. precision ${t.precision} usampler2DArray;
  3854. `;return t.precision==="highp"?e+=`
  3855. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  3856. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  3857. #define LOW_PRECISION`),e}function aDe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===vZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===ECe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===pc&&(e="SHADOWMAP_TYPE_VSM"),e}function sDe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Up:case zp:e="ENVMAP_TYPE_CUBE";break;case tE:e="ENVMAP_TYPE_CUBE_UV";break}return e}function oDe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case zp:e="ENVMAP_MODE_REFRACTION";break}return e}function lDe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case TO:e="ENVMAP_BLENDING_MULTIPLY";break;case VCe:e="ENVMAP_BLENDING_MIX";break;case GCe:e="ENVMAP_BLENDING_ADD";break}return e}function cDe(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 uDe(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,l=n.fragmentShader;const c=aDe(n),u=sDe(n),d=oDe(n),f=lDe(n),g=cDe(n),p=ZRe(n),b=QRe(a),v=i.createProgram();let x,y,E=n.glslVersion?"#version "+n.glslVersion+`
  3858. `:"";n.isRawShaderMaterial?(x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Yx).join(`
  3859. `),x.length>0&&(x+=`
  3860. `),y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Yx).join(`
  3861. `),y.length>0&&(y+=`
  3862. `)):(x=[m$(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,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",`
  3863. `].filter(Yx).join(`
  3864. `),y=[m$(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,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!==ud?"#define TONE_MAPPING":"",n.toneMapping!==ud?gn.tonemapping_pars_fragment:"",n.toneMapping!==ud?XRe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",gn.colorspace_pars_fragment,KRe("linearToOutputTexel",n.outputColorSpace),YRe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3865. `].filter(Yx).join(`
  3866. `)),s=ZP(s),s=d$(s,n),s=h$(s,n),l=ZP(l),l=d$(l,n),l=h$(l,n),s=f$(s),l=f$(l),n.isRawShaderMaterial!==!0&&(E=`#version 300 es
  3867. `,x=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3868. `)+`
  3869. `+x,y=["#define varying in",n.glslVersion===_H?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===_H?"":"#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(`
  3870. `)+`
  3871. `+y);const w=E+x+s,A=E+y+l,T=l$(i,i.VERTEX_SHADER,w),C=l$(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(z){if(t.debug.checkShaderErrors){const I=i.getProgramInfoLog(v)||"",q=i.getShaderInfoLog(T)||"",R=i.getShaderInfoLog(C)||"",W=I.trim(),K=q.trim(),G=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 Z=u$(i,T,"vertex"),F=u$(i,C,"fragment");Qr("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
  3872. Material Name: `+z.name+`
  3873. Material Type: `+z.type+`
  3874. Program Info Log: `+W+`
  3875. `+Z+`
  3876. `+F)}else W!==""?nn("WebGLProgram: Program Info Log:",W):(K===""||G==="")&&(ee=!1);ee&&(z.diagnostics={runnable:J,programLog:W,vertexShader:{log:K,prefix:x},fragmentShader:{log:G,prefix:y}})}i.deleteShader(T),i.deleteShader(C),O=new k1(i,v),k=JRe(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,VRe)),j},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=GRe++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=T,this.fragmentShader=C,this}let dDe=0,hDe=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 fDe(e),n.set(e,r)),r}},fDe=class{constructor(e){this.id=dDe++,this.code=e,this.usedTimes=0}};function mDe(t,e,n,r,i,a,s){const l=new FZ,c=new hDe,u=new Set,d=[],f=i.logarithmicDepthBuffer,g=i.vertexTextures;let p=i.precision;const b={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 x(k,j,z,I,q){const R=I.fog,W=q.geometry,K=k.isMeshStandardMaterial?I.environment:null,G=(k.isMeshStandardMaterial?n:e).get(k.envMap||K),J=G&&G.mapping===tE?G.image.height:null,ee=b[k.type];k.precision!==null&&(p=i.getMaxPrecision(k.precision),p!==k.precision&&nn("WebGLProgram.getParameters:",k.precision,"not supported, using",p,"instead."));const Z=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,F=Z!==void 0?Z.length:0;let V=0;W.morphAttributes.position!==void 0&&(V=1),W.morphAttributes.normal!==void 0&&(V=2),W.morphAttributes.color!==void 0&&(V=3);let ne,le,oe,pe;if(ee){const wt=ul[ee];ne=wt.vertexShader,le=wt.fragmentShader}else ne=k.vertexShader,le=k.fragmentShader,c.update(k),oe=c.getVertexShaderID(k),pe=c.getFragmentShaderID(k);const Q=t.getRenderTarget(),Ee=t.state.buffers.depth.getReversed(),he=q.isInstancedMesh===!0,ue=q.isBatchedMesh===!0,Ae=!!k.map,fe=!!k.matcap,at=!!G,B=!!k.aoMap,$=!!k.lightMap,ie=!!k.bumpMap,H=!!k.normalMap,Y=!!k.displacementMap,se=!!k.emissiveMap,ve=!!k.metalnessMap,Ne=!!k.roughnessMap,Se=k.anisotropy>0,U=k.clearcoat>0,L=k.dispersion>0,te=k.iridescence>0,ye=k.sheen>0,Me=k.transmission>0,be=Se&&!!k.anisotropyMap,qe=U&&!!k.clearcoatMap,Ve=U&&!!k.clearcoatNormalMap,We=U&&!!k.clearcoatRoughnessMap,lt=te&&!!k.iridescenceMap,me=te&&!!k.iridescenceThicknessMap,ae=ye&&!!k.sheenColorMap,He=ye&&!!k.sheenRoughnessMap,Be=!!k.specularMap,Ye=!!k.specularColorMap,ot=!!k.specularIntensityMap,ge=Me&&!!k.transmissionMap,nt=Me&&!!k.thicknessMap,xe=!!k.gradientMap,ze=!!k.alphaMap,Re=k.alphaTest>0,we=!!k.alphaHash,Ke=!!k.extensions;let ft=ud;k.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(ft=t.toneMapping);const Et={shaderID:ee,shaderType:k.type,shaderName:k.name,vertexShader:ne,fragmentShader:le,defines:k.defines,customVertexShaderID:oe,customFragmentShaderID:pe,isRawShaderMaterial:k.isRawShaderMaterial===!0,glslVersion:k.glslVersion,precision:p,batching:ue,batchingColor:ue&&q._colorsTexture!==null,instancing:he,instancingColor:he&&q.instanceColor!==null,instancingMorph:he&&q.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:Q===null?t.outputColorSpace:Q.isXRRenderTarget===!0?Q.texture.colorSpace:Bp,alphaToCoverage:!!k.alphaToCoverage,map:Ae,matcap:fe,envMap:at,envMapMode:at&&G.mapping,envMapCubeUVHeight:J,aoMap:B,lightMap:$,bumpMap:ie,normalMap:H,displacementMap:g&&Y,emissiveMap:se,normalMapObjectSpace:H&&k.normalMapType===nke,normalMapTangentSpace:H&&k.normalMapType===CZ,metalnessMap:ve,roughnessMap:Ne,anisotropy:Se,anisotropyMap:be,clearcoat:U,clearcoatMap:qe,clearcoatNormalMap:Ve,clearcoatRoughnessMap:We,dispersion:L,iridescence:te,iridescenceMap:lt,iridescenceThicknessMap:me,sheen:ye,sheenColorMap:ae,sheenRoughnessMap:He,specularMap:Be,specularColorMap:Ye,specularIntensityMap:ot,transmission:Me,transmissionMap:ge,thicknessMap:nt,gradientMap:xe,opaque:k.transparent===!1&&k.blending===gp&&k.alphaToCoverage===!1,alphaMap:ze,alphaTest:Re,alphaHash:we,combine:k.combine,mapUv:Ae&&v(k.map.channel),aoMapUv:B&&v(k.aoMap.channel),lightMapUv:$&&v(k.lightMap.channel),bumpMapUv:ie&&v(k.bumpMap.channel),normalMapUv:H&&v(k.normalMap.channel),displacementMapUv:Y&&v(k.displacementMap.channel),emissiveMapUv:se&&v(k.emissiveMap.channel),metalnessMapUv:ve&&v(k.metalnessMap.channel),roughnessMapUv:Ne&&v(k.roughnessMap.channel),anisotropyMapUv:be&&v(k.anisotropyMap.channel),clearcoatMapUv:qe&&v(k.clearcoatMap.channel),clearcoatNormalMapUv:Ve&&v(k.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:We&&v(k.clearcoatRoughnessMap.channel),iridescenceMapUv:lt&&v(k.iridescenceMap.channel),iridescenceThicknessMapUv:me&&v(k.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&v(k.sheenColorMap.channel),sheenRoughnessMapUv:He&&v(k.sheenRoughnessMap.channel),specularMapUv:Be&&v(k.specularMap.channel),specularColorMapUv:Ye&&v(k.specularColorMap.channel),specularIntensityMapUv:ot&&v(k.specularIntensityMap.channel),transmissionMapUv:ge&&v(k.transmissionMap.channel),thicknessMapUv:nt&&v(k.thicknessMap.channel),alphaMapUv:ze&&v(k.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(H||Se),vertexColors:k.vertexColors,vertexAlphas:k.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(Ae||ze),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:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:F,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&&z.length>0,shadowMapType:t.shadowMap.type,toneMapping:ft,decodeVideoTexture:Ae&&k.map.isVideoTexture===!0&&zn.getTransfer(k.map.colorSpace)===ar,decodeVideoTextureEmissive:se&&k.emissiveMap.isVideoTexture===!0&&zn.getTransfer(k.emissiveMap.colorSpace)===ar,premultipliedAlpha:k.premultipliedAlpha,doubleSided:k.side===dl,flipSided:k.side===ns,useDepthPacking:k.depthPacking>=0,depthPacking:k.depthPacking||0,index0AttributeName:k.index0AttributeName,extensionClipCullDistance:Ke&&k.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ke&&k.extensions.multiDraw===!0||ue)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:k.customProgramCacheKey()};return Et.vertexUv1s=u.has(1),Et.vertexUv2s=u.has(2),Et.vertexUv3s=u.has(3),u.clear(),Et}function y(k){const j=[];if(k.shaderID?j.push(k.shaderID):(j.push(k.customVertexShaderID),j.push(k.customFragmentShaderID)),k.defines!==void 0)for(const z in k.defines)j.push(z),j.push(k.defines[z]);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=b[k.type];let z;if(j){const I=ul[j];z=jke.clone(I.uniforms)}else z=k.uniforms;return z}function T(k,j){let z;for(let I=0,q=d.length;I<q;I++){const R=d[I];if(R.cacheKey===j){z=R,++z.usedTimes;break}}return z===void 0&&(z=new uDe(t,j,k,a),d.push(z)),z}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:x,getProgramCacheKey:y,getUniforms:A,acquireProgram:T,releaseProgram:C,releaseShaderCache:N,programs:d,dispose:O}}function pDe(){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 gDe(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 p$(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 g$(){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,b,v,x){let y=t[e];return y===void 0?(y={id:f.id,object:f,geometry:g,material:p,groupOrder:b,renderOrder:f.renderOrder,z:v,group:x},t[e]=y):(y.id=f.id,y.object=f,y.geometry=g,y.material=p,y.groupOrder=b,y.renderOrder=f.renderOrder,y.z=v,y.group=x),e++,y}function l(f,g,p,b,v,x){const y=s(f,g,p,b,v,x);p.transmission>0?r.push(y):p.transparent===!0?i.push(y):n.push(y)}function c(f,g,p,b,v,x){const y=s(f,g,p,b,v,x);p.transmission>0?r.unshift(y):p.transparent===!0?i.unshift(y):n.unshift(y)}function u(f,g){n.length>1&&n.sort(f||gDe),r.length>1&&r.sort(g||p$),i.length>1&&i.sort(g||p$)}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 xDe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new g$,t.set(r,[s])):i>=a.length?(s=new g$,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function bDe(){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 it,color:new Nn};break;case"SpotLight":n={position:new it,direction:new it,color:new Nn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new it,color:new Nn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new it,skyColor:new Nn,groundColor:new Nn};break;case"RectAreaLight":n={color:new Nn,position:new it,halfWidth:new it,halfHeight:new it};break}return t[e.id]=n,n}}}function yDe(){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 bn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let vDe=0;function _De(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function wDe(t){const e=new bDe,n=yDe(),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 it);const i=new it,a=new mi,s=new mi;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,b=0,v=0,x=0,y=0,E=0,w=0,A=0,T=0,C=0,N=0;u.sort(_De);for(let k=0,j=u.length;k<j;k++){const z=u[k],I=z.color,q=z.intensity,R=z.distance,W=z.shadow&&z.shadow.map?z.shadow.map.texture:null;if(z.isAmbientLight)d+=I.r*q,f+=I.g*q,g+=I.b*q;else if(z.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(z.sh.coefficients[K],q);N++}else if(z.isDirectionalLight){const K=e.get(z);if(K.color.copy(z.color).multiplyScalar(z.intensity),z.castShadow){const G=z.shadow,J=n.get(z);J.shadowIntensity=G.intensity,J.shadowBias=G.bias,J.shadowNormalBias=G.normalBias,J.shadowRadius=G.radius,J.shadowMapSize=G.mapSize,r.directionalShadow[p]=J,r.directionalShadowMap[p]=W,r.directionalShadowMatrix[p]=z.shadow.matrix,E++}r.directional[p]=K,p++}else if(z.isSpotLight){const K=e.get(z);K.position.setFromMatrixPosition(z.matrixWorld),K.color.copy(I).multiplyScalar(q),K.distance=R,K.coneCos=Math.cos(z.angle),K.penumbraCos=Math.cos(z.angle*(1-z.penumbra)),K.decay=z.decay,r.spot[v]=K;const G=z.shadow;if(z.map&&(r.spotLightMap[T]=z.map,T++,G.updateMatrices(z),z.castShadow&&C++),r.spotLightMatrix[v]=G.matrix,z.castShadow){const J=n.get(z);J.shadowIntensity=G.intensity,J.shadowBias=G.bias,J.shadowNormalBias=G.normalBias,J.shadowRadius=G.radius,J.shadowMapSize=G.mapSize,r.spotShadow[v]=J,r.spotShadowMap[v]=W,A++}v++}else if(z.isRectAreaLight){const K=e.get(z);K.color.copy(I).multiplyScalar(q),K.halfWidth.set(z.width*.5,0,0),K.halfHeight.set(0,z.height*.5,0),r.rectArea[x]=K,x++}else if(z.isPointLight){const K=e.get(z);if(K.color.copy(z.color).multiplyScalar(z.intensity),K.distance=z.distance,K.decay=z.decay,z.castShadow){const G=z.shadow,J=n.get(z);J.shadowIntensity=G.intensity,J.shadowBias=G.bias,J.shadowNormalBias=G.normalBias,J.shadowRadius=G.radius,J.shadowMapSize=G.mapSize,J.shadowCameraNear=G.camera.near,J.shadowCameraFar=G.camera.far,r.pointShadow[b]=J,r.pointShadowMap[b]=W,r.pointShadowMatrix[b]=z.shadow.matrix,w++}r.point[b]=K,b++}else if(z.isHemisphereLight){const K=e.get(z);K.skyColor.copy(z.color).multiplyScalar(q),K.groundColor.copy(z.groundColor).multiplyScalar(q),r.hemi[y]=K,y++}}x>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Pt.LTC_FLOAT_1,r.rectAreaLTC2=Pt.LTC_FLOAT_2):(r.rectAreaLTC1=Pt.LTC_HALF_1,r.rectAreaLTC2=Pt.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=g;const O=r.hash;(O.directionalLength!==p||O.pointLength!==b||O.spotLength!==v||O.rectAreaLength!==x||O.hemiLength!==y||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=x,r.point.length=b,r.hemi.length=y,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=b,O.spotLength=v,O.rectAreaLength=x,O.hemiLength=y,O.numDirectionalShadows=E,O.numPointShadows=w,O.numSpotShadows=A,O.numSpotMaps=T,O.numLightProbes=N,r.version=vDe++)}function c(u,d){let f=0,g=0,p=0,b=0,v=0;const x=d.matrixWorldInverse;for(let y=0,E=u.length;y<E;y++){const w=u[y];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(x),f++}else if(w.isSpotLight){const A=r.spot[p];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(x),A.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(x),p++}else if(w.isRectAreaLight){const A=r.rectArea[b];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(x),s.identity(),a.copy(w.matrixWorld),a.premultiply(x),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),b++}else if(w.isPointLight){const A=r.point[g];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(x),g++}else if(w.isHemisphereLight){const A=r.hemi[v];A.direction.setFromMatrixPosition(w.matrixWorld),A.direction.transformDirection(x),v++}}}return{setup:l,setupView:c,state:r}}function x$(t){const e=new wDe(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 SDe(t){let e=new WeakMap;function n(i,a=0){const s=e.get(i);let l;return s===void 0?(l=new x$(t),e.set(i,[l])):a>=s.length?(l=new x$(t),s.push(l)):l=s[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const MDe=`void main() {
  3877. gl_Position = vec4( position, 1.0 );
  3878. }`,EDe=`uniform sampler2D shadow_pass;
  3879. uniform vec2 resolution;
  3880. uniform float radius;
  3881. #include <packing>
  3882. void main() {
  3883. const float samples = float( VSM_SAMPLES );
  3884. float mean = 0.0;
  3885. float squared_mean = 0.0;
  3886. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3887. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3888. for ( float i = 0.0; i < samples; i ++ ) {
  3889. float uvOffset = uvStart + i * uvStride;
  3890. #ifdef HORIZONTAL_PASS
  3891. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3892. mean += distribution.x;
  3893. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3894. #else
  3895. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3896. mean += depth;
  3897. squared_mean += depth * depth;
  3898. #endif
  3899. }
  3900. mean = mean / samples;
  3901. squared_mean = squared_mean / samples;
  3902. float std_dev = sqrt( squared_mean - mean * mean );
  3903. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3904. }`;function ADe(t,e,n){let r=new UO;const i=new bn,a=new bn,s=new ci,l=new Wke({depthPacking:tke}),c=new qke,u={},d=n.maxTextureSize,f={[Td]:ns,[ns]:Td,[dl]:dl},g=new Yc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new bn},radius:{value:4}},vertexShader:MDe,fragmentShader:EDe}),p=g.clone();p.defines.HORIZONTAL_PASS=1;const b=new Ll;b.setAttribute("position",new ho(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Tl(b,g),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=vZ;let y=this.type;this.render=function(C,N,O){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||C.length===0)return;const k=t.getRenderTarget(),j=t.getActiveCubeFace(),z=t.getActiveMipmapLevel(),I=t.state;I.setBlending(Dc),I.buffers.depth.getReversed()===!0?I.buffers.color.setClear(0,0,0,0):I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const q=y!==pc&&this.type===pc,R=y===pc&&this.type!==pc;for(let W=0,K=C.length;W<K;W++){const G=C[W],J=G.shadow;if(J===void 0){nn("WebGLShadowMap:",G,"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||q===!0||R===!0){const F=this.type!==pc?{minFilter:ks,magFilter:ks}:{};J.map!==null&&J.map.dispose(),J.map=new gf(i.x,i.y,F),J.map.texture.name=G.name+".shadowMap",J.camera.updateProjectionMatrix()}t.setRenderTarget(J.map),t.clear();const Z=J.getViewportCount();for(let F=0;F<Z;F++){const V=J.getViewport(F);s.set(a.x*V.x,a.y*V.y,a.x*V.z,a.y*V.w),I.viewport(s),J.updateMatrices(G,F),r=J.getFrustum(),A(N,O,J.camera,G,this.type)}J.isPointLightShadow!==!0&&this.type===pc&&E(J,O),J.needsUpdate=!1}y=this.type,x.needsUpdate=!1,t.setRenderTarget(k,j,z)};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 z=O.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(z!==void 0)j=z;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 I=j.uuid,q=N.uuid;let R=u[I];R===void 0&&(R={},u[I]=R);let W=R[q];W===void 0&&(W=j.clone(),R[q]=W,N.addEventListener("dispose",T)),j=W}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 I=t.properties.get(j);I.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 q=e.update(C),R=C.material;if(Array.isArray(R)){const W=q.groups;for(let K=0,G=W.length;K<G;K++){const J=W[K],ee=R[J.materialIndex];if(ee&&ee.visible){const Z=w(C,ee,k,j);C.onBeforeShadow(t,C,N,O,q,Z,J),t.renderBufferDirect(O,null,q,Z,C,J),C.onAfterShadow(t,C,N,O,q,Z,J)}}}else if(R.visible){const W=w(C,R,k,j);C.onBeforeShadow(t,C,N,O,q,W,null),t.renderBufferDirect(O,null,q,W,C,null),C.onAfterShadow(t,C,N,O,q,W,null)}}const I=C.children;for(let q=0,R=I.length;q<R;q++)A(I[q],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 TDe={[uP]:dP,[hP]:pP,[fP]:gP,[Fp]:mP,[dP]:uP,[pP]:hP,[gP]:fP,[mP]:Fp};function NDe(t,e){function n(){let ge=!1;const nt=new ci;let xe=null;const ze=new ci(0,0,0,0);return{setMask:function(Re){xe!==Re&&!ge&&(t.colorMask(Re,Re,Re,Re),xe=Re)},setLocked:function(Re){ge=Re},setClear:function(Re,we,Ke,ft,Et){Et===!0&&(Re*=ft,we*=ft,Ke*=ft),nt.set(Re,we,Ke,ft),ze.equals(nt)===!1&&(t.clearColor(Re,we,Ke,ft),ze.copy(nt))},reset:function(){ge=!1,xe=null,ze.set(-1,0,0,0)}}}function r(){let ge=!1,nt=!1,xe=null,ze=null,Re=null;return{setReversed:function(we){if(nt!==we){const Ke=e.get("EXT_clip_control");we?Ke.clipControlEXT(Ke.LOWER_LEFT_EXT,Ke.ZERO_TO_ONE_EXT):Ke.clipControlEXT(Ke.LOWER_LEFT_EXT,Ke.NEGATIVE_ONE_TO_ONE_EXT),nt=we;const ft=Re;Re=null,this.setClear(ft)}},getReversed:function(){return nt},setTest:function(we){we?Q(t.DEPTH_TEST):Ee(t.DEPTH_TEST)},setMask:function(we){xe!==we&&!ge&&(t.depthMask(we),xe=we)},setFunc:function(we){if(nt&&(we=TDe[we]),ze!==we){switch(we){case uP:t.depthFunc(t.NEVER);break;case dP:t.depthFunc(t.ALWAYS);break;case hP:t.depthFunc(t.LESS);break;case Fp:t.depthFunc(t.LEQUAL);break;case fP:t.depthFunc(t.EQUAL);break;case mP:t.depthFunc(t.GEQUAL);break;case pP:t.depthFunc(t.GREATER);break;case gP:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}ze=we}},setLocked:function(we){ge=we},setClear:function(we){Re!==we&&(nt&&(we=1-we),t.clearDepth(we),Re=we)},reset:function(){ge=!1,xe=null,ze=null,Re=null,nt=!1}}}function i(){let ge=!1,nt=null,xe=null,ze=null,Re=null,we=null,Ke=null,ft=null,Et=null;return{setTest:function(wt){ge||(wt?Q(t.STENCIL_TEST):Ee(t.STENCIL_TEST))},setMask:function(wt){nt!==wt&&!ge&&(t.stencilMask(wt),nt=wt)},setFunc:function(wt,Qt,Ft){(xe!==wt||ze!==Qt||Re!==Ft)&&(t.stencilFunc(wt,Qt,Ft),xe=wt,ze=Qt,Re=Ft)},setOp:function(wt,Qt,Ft){(we!==wt||Ke!==Qt||ft!==Ft)&&(t.stencilOp(wt,Qt,Ft),we=wt,Ke=Qt,ft=Ft)},setLocked:function(wt){ge=wt},setClear:function(wt){Et!==wt&&(t.clearStencil(wt),Et=wt)},reset:function(){ge=!1,nt=null,xe=null,ze=null,Re=null,we=null,Ke=null,ft=null,Et=null}}}const a=new n,s=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},g=new WeakMap,p=[],b=null,v=!1,x=null,y=null,E=null,w=null,A=null,T=null,C=null,N=new Nn(0,0,0),O=0,k=!1,j=null,z=null,I=null,q=null,R=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,G=0;const J=t.getParameter(t.VERSION);J.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(J)[1]),K=G>=1):J.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(J)[1]),K=G>=2);let ee=null,Z={};const F=t.getParameter(t.SCISSOR_BOX),V=t.getParameter(t.VIEWPORT),ne=new ci().fromArray(F),le=new ci().fromArray(V);function oe(ge,nt,xe,ze){const Re=new Uint8Array(4),we=t.createTexture();t.bindTexture(ge,we),t.texParameteri(ge,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ge,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Ke=0;Ke<xe;Ke++)ge===t.TEXTURE_3D||ge===t.TEXTURE_2D_ARRAY?t.texImage3D(nt,0,t.RGBA,1,1,ze,0,t.RGBA,t.UNSIGNED_BYTE,Re):t.texImage2D(nt+Ke,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Re);return we}const pe={};pe[t.TEXTURE_2D]=oe(t.TEXTURE_2D,t.TEXTURE_2D,1),pe[t.TEXTURE_CUBE_MAP]=oe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),pe[t.TEXTURE_2D_ARRAY]=oe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),pe[t.TEXTURE_3D]=oe(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),l.setClear(0),Q(t.DEPTH_TEST),s.setFunc(Fp),ie(!1),H(pH),Q(t.CULL_FACE),B(Dc);function Q(ge){d[ge]!==!0&&(t.enable(ge),d[ge]=!0)}function Ee(ge){d[ge]!==!1&&(t.disable(ge),d[ge]=!1)}function he(ge,nt){return f[ge]!==nt?(t.bindFramebuffer(ge,nt),f[ge]=nt,ge===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=nt),ge===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=nt),!0):!1}function ue(ge,nt){let xe=p,ze=!1;if(ge){xe=g.get(nt),xe===void 0&&(xe=[],g.set(nt,xe));const Re=ge.textures;if(xe.length!==Re.length||xe[0]!==t.COLOR_ATTACHMENT0){for(let we=0,Ke=Re.length;we<Ke;we++)xe[we]=t.COLOR_ATTACHMENT0+we;xe.length=Re.length,ze=!0}}else xe[0]!==t.BACK&&(xe[0]=t.BACK,ze=!0);ze&&t.drawBuffers(xe)}function Ae(ge){return b!==ge?(t.useProgram(ge),b=ge,!0):!1}const fe={[_h]:t.FUNC_ADD,[TCe]:t.FUNC_SUBTRACT,[NCe]:t.FUNC_REVERSE_SUBTRACT};fe[CCe]=t.MIN,fe[kCe]=t.MAX;const at={[PCe]:t.ZERO,[jCe]:t.ONE,[RCe]:t.SRC_COLOR,[lP]:t.SRC_ALPHA,[UCe]:t.SRC_ALPHA_SATURATE,[ICe]:t.DST_COLOR,[OCe]:t.DST_ALPHA,[DCe]:t.ONE_MINUS_SRC_COLOR,[cP]:t.ONE_MINUS_SRC_ALPHA,[FCe]:t.ONE_MINUS_DST_COLOR,[LCe]:t.ONE_MINUS_DST_ALPHA,[zCe]:t.CONSTANT_COLOR,[BCe]:t.ONE_MINUS_CONSTANT_COLOR,[HCe]:t.CONSTANT_ALPHA,[$Ce]:t.ONE_MINUS_CONSTANT_ALPHA};function B(ge,nt,xe,ze,Re,we,Ke,ft,Et,wt){if(ge===Dc){v===!0&&(Ee(t.BLEND),v=!1);return}if(v===!1&&(Q(t.BLEND),v=!0),ge!==ACe){if(ge!==x||wt!==k){if((y!==_h||A!==_h)&&(t.blendEquation(t.FUNC_ADD),y=_h,A=_h),wt)switch(ge){case gp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case gH:t.blendFunc(t.ONE,t.ONE);break;case xH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case bH:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Qr("WebGLState: Invalid blending: ",ge);break}else switch(ge){case gp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case gH:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case xH:Qr("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case bH:Qr("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Qr("WebGLState: Invalid blending: ",ge);break}E=null,w=null,T=null,C=null,N.set(0,0,0),O=0,x=ge,k=wt}return}Re=Re||nt,we=we||xe,Ke=Ke||ze,(nt!==y||Re!==A)&&(t.blendEquationSeparate(fe[nt],fe[Re]),y=nt,A=Re),(xe!==E||ze!==w||we!==T||Ke!==C)&&(t.blendFuncSeparate(at[xe],at[ze],at[we],at[Ke]),E=xe,w=ze,T=we,C=Ke),(ft.equals(N)===!1||Et!==O)&&(t.blendColor(ft.r,ft.g,ft.b,Et),N.copy(ft),O=Et),x=ge,k=!1}function $(ge,nt){ge.side===dl?Ee(t.CULL_FACE):Q(t.CULL_FACE);let xe=ge.side===ns;nt&&(xe=!xe),ie(xe),ge.blending===gp&&ge.transparent===!1?B(Dc):B(ge.blending,ge.blendEquation,ge.blendSrc,ge.blendDst,ge.blendEquationAlpha,ge.blendSrcAlpha,ge.blendDstAlpha,ge.blendColor,ge.blendAlpha,ge.premultipliedAlpha),s.setFunc(ge.depthFunc),s.setTest(ge.depthTest),s.setMask(ge.depthWrite),a.setMask(ge.colorWrite);const ze=ge.stencilWrite;l.setTest(ze),ze&&(l.setMask(ge.stencilWriteMask),l.setFunc(ge.stencilFunc,ge.stencilRef,ge.stencilFuncMask),l.setOp(ge.stencilFail,ge.stencilZFail,ge.stencilZPass)),se(ge.polygonOffset,ge.polygonOffsetFactor,ge.polygonOffsetUnits),ge.alphaToCoverage===!0?Q(t.SAMPLE_ALPHA_TO_COVERAGE):Ee(t.SAMPLE_ALPHA_TO_COVERAGE)}function ie(ge){j!==ge&&(ge?t.frontFace(t.CW):t.frontFace(t.CCW),j=ge)}function H(ge){ge!==SCe?(Q(t.CULL_FACE),ge!==z&&(ge===pH?t.cullFace(t.BACK):ge===MCe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ee(t.CULL_FACE),z=ge}function Y(ge){ge!==I&&(K&&t.lineWidth(ge),I=ge)}function se(ge,nt,xe){ge?(Q(t.POLYGON_OFFSET_FILL),(q!==nt||R!==xe)&&(t.polygonOffset(nt,xe),q=nt,R=xe)):Ee(t.POLYGON_OFFSET_FILL)}function ve(ge){ge?Q(t.SCISSOR_TEST):Ee(t.SCISSOR_TEST)}function Ne(ge){ge===void 0&&(ge=t.TEXTURE0+W-1),ee!==ge&&(t.activeTexture(ge),ee=ge)}function Se(ge,nt,xe){xe===void 0&&(ee===null?xe=t.TEXTURE0+W-1:xe=ee);let ze=Z[xe];ze===void 0&&(ze={type:void 0,texture:void 0},Z[xe]=ze),(ze.type!==ge||ze.texture!==nt)&&(ee!==xe&&(t.activeTexture(xe),ee=xe),t.bindTexture(ge,nt||pe[ge]),ze.type=ge,ze.texture=nt)}function U(){const ge=Z[ee];ge!==void 0&&ge.type!==void 0&&(t.bindTexture(ge.type,null),ge.type=void 0,ge.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(ge){ge("WebGLState:",ge)}}function te(){try{t.compressedTexImage3D(...arguments)}catch(ge){ge("WebGLState:",ge)}}function ye(){try{t.texSubImage2D(...arguments)}catch(ge){ge("WebGLState:",ge)}}function Me(){try{t.texSubImage3D(...arguments)}catch(ge){ge("WebGLState:",ge)}}function be(){try{t.compressedTexSubImage2D(...arguments)}catch(ge){ge("WebGLState:",ge)}}function qe(){try{t.compressedTexSubImage3D(...arguments)}catch(ge){ge("WebGLState:",ge)}}function Ve(){try{t.texStorage2D(...arguments)}catch(ge){ge("WebGLState:",ge)}}function We(){try{t.texStorage3D(...arguments)}catch(ge){ge("WebGLState:",ge)}}function lt(){try{t.texImage2D(...arguments)}catch(ge){ge("WebGLState:",ge)}}function me(){try{t.texImage3D(...arguments)}catch(ge){ge("WebGLState:",ge)}}function ae(ge){ne.equals(ge)===!1&&(t.scissor(ge.x,ge.y,ge.z,ge.w),ne.copy(ge))}function He(ge){le.equals(ge)===!1&&(t.viewport(ge.x,ge.y,ge.z,ge.w),le.copy(ge))}function Be(ge,nt){let xe=u.get(nt);xe===void 0&&(xe=new WeakMap,u.set(nt,xe));let ze=xe.get(ge);ze===void 0&&(ze=t.getUniformBlockIndex(nt,ge.name),xe.set(ge,ze))}function Ye(ge,nt){const ze=u.get(nt).get(ge);c.get(nt)!==ze&&(t.uniformBlockBinding(nt,ze,ge.__bindingPointIndex),c.set(nt,ze))}function ot(){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,Z={},f={},g=new WeakMap,p=[],b=null,v=!1,x=null,y=null,E=null,w=null,A=null,T=null,C=null,N=new Nn(0,0,0),O=0,k=!1,j=null,z=null,I=null,q=null,R=null,ne.set(0,0,t.canvas.width,t.canvas.height),le.set(0,0,t.canvas.width,t.canvas.height),a.reset(),s.reset(),l.reset()}return{buffers:{color:a,depth:s,stencil:l},enable:Q,disable:Ee,bindFramebuffer:he,drawBuffers:ue,useProgram:Ae,setBlending:B,setMaterial:$,setFlipSided:ie,setCullFace:H,setLineWidth:Y,setPolygonOffset:se,setScissorTest:ve,activeTexture:Ne,bindTexture:Se,unbindTexture:U,compressedTexImage2D:L,compressedTexImage3D:te,texImage2D:lt,texImage3D:me,updateUBOMapping:Be,uniformBlockBinding:Ye,texStorage2D:Ve,texStorage3D:We,texSubImage2D:ye,texSubImage3D:Me,compressedTexSubImage2D:be,compressedTexSubImage3D:qe,scissor:ae,viewport:He,reset:ot}}function CDe(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 bn,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 b(U,L){return p?new OffscreenCanvas(U,L):Kw("canvas")}function v(U,L,te){let ye=1;const Me=Se(U);if((Me.width>te||Me.height>te)&&(ye=te/Math.max(Me.width,Me.height)),ye<1)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap||typeof VideoFrame<"u"&&U instanceof VideoFrame){const be=Math.floor(ye*Me.width),qe=Math.floor(ye*Me.height);f===void 0&&(f=b(be,qe));const Ve=L?b(be,qe):f;return Ve.width=be,Ve.height=qe,Ve.getContext("2d").drawImage(U,0,0,be,qe),nn("WebGLRenderer: Texture has been resized from ("+Me.width+"x"+Me.height+") to ("+be+"x"+qe+")."),Ve}else return"data"in U&&nn("WebGLRenderer: Image in DataTexture is too big ("+Me.width+"x"+Me.height+")."),U;return U}function x(U){return U.generateMipmaps}function y(U){t.generateMipmap(U)}function E(U){return U.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:U.isWebGL3DRenderTarget?t.TEXTURE_3D:U.isWebGLArrayRenderTarget||U.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function w(U,L,te,ye,Me=!1){if(U!==null){if(t[U]!==void 0)return t[U];nn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let be=L;if(L===t.RED&&(te===t.FLOAT&&(be=t.R32F),te===t.HALF_FLOAT&&(be=t.R16F),te===t.UNSIGNED_BYTE&&(be=t.R8)),L===t.RED_INTEGER&&(te===t.UNSIGNED_BYTE&&(be=t.R8UI),te===t.UNSIGNED_SHORT&&(be=t.R16UI),te===t.UNSIGNED_INT&&(be=t.R32UI),te===t.BYTE&&(be=t.R8I),te===t.SHORT&&(be=t.R16I),te===t.INT&&(be=t.R32I)),L===t.RG&&(te===t.FLOAT&&(be=t.RG32F),te===t.HALF_FLOAT&&(be=t.RG16F),te===t.UNSIGNED_BYTE&&(be=t.RG8)),L===t.RG_INTEGER&&(te===t.UNSIGNED_BYTE&&(be=t.RG8UI),te===t.UNSIGNED_SHORT&&(be=t.RG16UI),te===t.UNSIGNED_INT&&(be=t.RG32UI),te===t.BYTE&&(be=t.RG8I),te===t.SHORT&&(be=t.RG16I),te===t.INT&&(be=t.RG32I)),L===t.RGB_INTEGER&&(te===t.UNSIGNED_BYTE&&(be=t.RGB8UI),te===t.UNSIGNED_SHORT&&(be=t.RGB16UI),te===t.UNSIGNED_INT&&(be=t.RGB32UI),te===t.BYTE&&(be=t.RGB8I),te===t.SHORT&&(be=t.RGB16I),te===t.INT&&(be=t.RGB32I)),L===t.RGBA_INTEGER&&(te===t.UNSIGNED_BYTE&&(be=t.RGBA8UI),te===t.UNSIGNED_SHORT&&(be=t.RGBA16UI),te===t.UNSIGNED_INT&&(be=t.RGBA32UI),te===t.BYTE&&(be=t.RGBA8I),te===t.SHORT&&(be=t.RGBA16I),te===t.INT&&(be=t.RGBA32I)),L===t.RGB&&(te===t.UNSIGNED_INT_5_9_9_9_REV&&(be=t.RGB9_E5),te===t.UNSIGNED_INT_10F_11F_11F_REV&&(be=t.R11F_G11F_B10F)),L===t.RGBA){const qe=Me?Ww:zn.getTransfer(ye);te===t.FLOAT&&(be=t.RGBA32F),te===t.HALF_FLOAT&&(be=t.RGBA16F),te===t.UNSIGNED_BYTE&&(be=qe===ar?t.SRGB8_ALPHA8:t.RGBA8),te===t.UNSIGNED_SHORT_4_4_4_4&&(be=t.RGBA4),te===t.UNSIGNED_SHORT_5_5_5_1&&(be=t.RGB5_A1)}return(be===t.R16F||be===t.R32F||be===t.RG16F||be===t.RG32F||be===t.RGBA16F||be===t.RGBA32F)&&e.get("EXT_color_buffer_float"),be}function A(U,L){let te;return U?L===null||L===mf||L===eb?te=t.DEPTH24_STENCIL8:L===Nc?te=t.DEPTH32F_STENCIL8:L===J0&&(te=t.DEPTH24_STENCIL8,nn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===mf||L===eb?te=t.DEPTH_COMPONENT24:L===Nc?te=t.DEPTH_COMPONENT32F:L===J0&&(te=t.DEPTH_COMPONENT16),te}function T(U,L){return x(U)===!0||U.isFramebufferTexture&&U.minFilter!==ks&&U.minFilter!==lo?Math.log2(Math.max(L.width,L.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?L.mipmaps.length:1}function C(U){const L=U.target;L.removeEventListener("dispose",C),O(L),L.isVideoTexture&&d.delete(L)}function N(U){const L=U.target;L.removeEventListener("dispose",N),j(L)}function O(U){const L=r.get(U);if(L.__webglInit===void 0)return;const te=U.source,ye=g.get(te);if(ye){const Me=ye[L.__cacheKey];Me.usedTimes--,Me.usedTimes===0&&k(U),Object.keys(ye).length===0&&g.delete(te)}r.remove(U)}function k(U){const L=r.get(U);t.deleteTexture(L.__webglTexture);const te=U.source,ye=g.get(te);delete ye[L.__cacheKey],s.memory.textures--}function j(U){const L=r.get(U);if(U.depthTexture&&(U.depthTexture.dispose(),r.remove(U.depthTexture)),U.isWebGLCubeRenderTarget)for(let ye=0;ye<6;ye++){if(Array.isArray(L.__webglFramebuffer[ye]))for(let Me=0;Me<L.__webglFramebuffer[ye].length;Me++)t.deleteFramebuffer(L.__webglFramebuffer[ye][Me]);else t.deleteFramebuffer(L.__webglFramebuffer[ye]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[ye])}else{if(Array.isArray(L.__webglFramebuffer))for(let ye=0;ye<L.__webglFramebuffer.length;ye++)t.deleteFramebuffer(L.__webglFramebuffer[ye]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let ye=0;ye<L.__webglColorRenderbuffer.length;ye++)L.__webglColorRenderbuffer[ye]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[ye]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const te=U.textures;for(let ye=0,Me=te.length;ye<Me;ye++){const be=r.get(te[ye]);be.__webglTexture&&(t.deleteTexture(be.__webglTexture),s.memory.textures--),r.remove(te[ye])}r.remove(U)}let z=0;function I(){z=0}function q(){const U=z;return U>=i.maxTextures&&nn("WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+i.maxTextures),z+=1,U}function R(U){const L=[];return L.push(U.wrapS),L.push(U.wrapT),L.push(U.wrapR||0),L.push(U.magFilter),L.push(U.minFilter),L.push(U.anisotropy),L.push(U.internalFormat),L.push(U.format),L.push(U.type),L.push(U.generateMipmaps),L.push(U.premultiplyAlpha),L.push(U.flipY),L.push(U.unpackAlignment),L.push(U.colorSpace),L.join()}function W(U,L){const te=r.get(U);if(U.isVideoTexture&&ve(U),U.isRenderTargetTexture===!1&&U.isExternalTexture!==!0&&U.version>0&&te.__version!==U.version){const ye=U.image;if(ye===null)nn("WebGLRenderer: Texture marked for update but no image data found.");else if(ye.complete===!1)nn("WebGLRenderer: Texture marked for update but image is incomplete");else{pe(te,U,L);return}}else U.isExternalTexture&&(te.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,te.__webglTexture,t.TEXTURE0+L)}function K(U,L){const te=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&te.__version!==U.version){pe(te,U,L);return}else U.isExternalTexture&&(te.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,te.__webglTexture,t.TEXTURE0+L)}function G(U,L){const te=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&te.__version!==U.version){pe(te,U,L);return}n.bindTexture(t.TEXTURE_3D,te.__webglTexture,t.TEXTURE0+L)}function J(U,L){const te=r.get(U);if(U.version>0&&te.__version!==U.version){Q(te,U,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,te.__webglTexture,t.TEXTURE0+L)}const ee={[yP]:t.REPEAT,[Tc]:t.CLAMP_TO_EDGE,[vP]:t.MIRRORED_REPEAT},Z={[ks]:t.NEAREST,[JCe]:t.NEAREST_MIPMAP_NEAREST,[Kv]:t.NEAREST_MIPMAP_LINEAR,[lo]:t.LINEAR,[ON]:t.LINEAR_MIPMAP_NEAREST,[Ph]:t.LINEAR_MIPMAP_LINEAR},F={[rke]:t.NEVER,[cke]:t.ALWAYS,[ike]:t.LESS,[kZ]:t.LEQUAL,[ake]:t.EQUAL,[lke]:t.GEQUAL,[ske]:t.GREATER,[oke]:t.NOTEQUAL};function V(U,L){if(L.type===Nc&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===lo||L.magFilter===ON||L.magFilter===Kv||L.magFilter===Ph||L.minFilter===lo||L.minFilter===ON||L.minFilter===Kv||L.minFilter===Ph)&&nn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(U,t.TEXTURE_WRAP_S,ee[L.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,ee[L.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,ee[L.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,Z[L.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,Z[L.minFilter]),L.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,F[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===ks||L.minFilter!==Kv&&L.minFilter!==Ph||L.type===Nc&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||r.get(L).__currentAnisotropy){const te=e.get("EXT_texture_filter_anisotropic");t.texParameterf(U,te.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function ne(U,L){let te=!1;U.__webglInit===void 0&&(U.__webglInit=!0,L.addEventListener("dispose",C));const ye=L.source;let Me=g.get(ye);Me===void 0&&(Me={},g.set(ye,Me));const be=R(L);if(be!==U.__cacheKey){Me[be]===void 0&&(Me[be]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,te=!0),Me[be].usedTimes++;const qe=Me[U.__cacheKey];qe!==void 0&&(Me[U.__cacheKey].usedTimes--,qe.usedTimes===0&&k(L)),U.__cacheKey=be,U.__webglTexture=Me[be].texture}return te}function le(U,L,te){return Math.floor(Math.floor(U/te)/L)}function oe(U,L,te,ye){const be=U.updateRanges;if(be.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,te,ye,L.data);else{be.sort((me,ae)=>me.start-ae.start);let qe=0;for(let me=1;me<be.length;me++){const ae=be[qe],He=be[me],Be=ae.start+ae.count,Ye=le(He.start,L.width,4),ot=le(ae.start,L.width,4);He.start<=Be+1&&Ye===ot&&le(He.start+He.count-1,L.width,4)===Ye?ae.count=Math.max(ae.count,He.start+He.count-ae.start):(++qe,be[qe]=He)}be.length=qe+1;const Ve=t.getParameter(t.UNPACK_ROW_LENGTH),We=t.getParameter(t.UNPACK_SKIP_PIXELS),lt=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let me=0,ae=be.length;me<ae;me++){const He=be[me],Be=Math.floor(He.start/4),Ye=Math.ceil(He.count/4),ot=Be%L.width,ge=Math.floor(Be/L.width),nt=Ye,xe=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ot),t.pixelStorei(t.UNPACK_SKIP_ROWS,ge),n.texSubImage2D(t.TEXTURE_2D,0,ot,ge,nt,xe,te,ye,L.data)}U.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ve),t.pixelStorei(t.UNPACK_SKIP_PIXELS,We),t.pixelStorei(t.UNPACK_SKIP_ROWS,lt)}}function pe(U,L,te){let ye=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ye=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ye=t.TEXTURE_3D);const Me=ne(U,L),be=L.source;n.bindTexture(ye,U.__webglTexture,t.TEXTURE0+te);const qe=r.get(be);if(be.version!==qe.__version||Me===!0){n.activeTexture(t.TEXTURE0+te);const Ve=zn.getPrimaries(zn.workingColorSpace),We=L.colorSpace===Qu?null:zn.getPrimaries(L.colorSpace),lt=L.colorSpace===Qu||Ve===We?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,lt);let me=v(L.image,!1,i.maxTextureSize);me=Ne(L,me);const ae=a.convert(L.format,L.colorSpace),He=a.convert(L.type);let Be=w(L.internalFormat,ae,He,L.colorSpace,L.isVideoTexture);V(ye,L);let Ye;const ot=L.mipmaps,ge=L.isVideoTexture!==!0,nt=qe.__version===void 0||Me===!0,xe=be.dataReady,ze=T(L,me);if(L.isDepthTexture)Be=A(L.format===nb,L.type),nt&&(ge?n.texStorage2D(t.TEXTURE_2D,1,Be,me.width,me.height):n.texImage2D(t.TEXTURE_2D,0,Be,me.width,me.height,0,ae,He,null));else if(L.isDataTexture)if(ot.length>0){ge&&nt&&n.texStorage2D(t.TEXTURE_2D,ze,Be,ot[0].width,ot[0].height);for(let Re=0,we=ot.length;Re<we;Re++)Ye=ot[Re],ge?xe&&n.texSubImage2D(t.TEXTURE_2D,Re,0,0,Ye.width,Ye.height,ae,He,Ye.data):n.texImage2D(t.TEXTURE_2D,Re,Be,Ye.width,Ye.height,0,ae,He,Ye.data);L.generateMipmaps=!1}else ge?(nt&&n.texStorage2D(t.TEXTURE_2D,ze,Be,me.width,me.height),xe&&oe(L,me,ae,He)):n.texImage2D(t.TEXTURE_2D,0,Be,me.width,me.height,0,ae,He,me.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){ge&&nt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ze,Be,ot[0].width,ot[0].height,me.depth);for(let Re=0,we=ot.length;Re<we;Re++)if(Ye=ot[Re],L.format!==Fo)if(ae!==null)if(ge){if(xe)if(L.layerUpdates.size>0){const Ke=KH(Ye.width,Ye.height,L.format,L.type);for(const ft of L.layerUpdates){const Et=Ye.data.subarray(ft*Ke/Ye.data.BYTES_PER_ELEMENT,(ft+1)*Ke/Ye.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Re,0,0,ft,Ye.width,Ye.height,1,ae,Et)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Re,0,0,0,Ye.width,Ye.height,me.depth,ae,Ye.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Re,Be,Ye.width,Ye.height,me.depth,0,Ye.data,0,0);else nn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ge?xe&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Re,0,0,0,Ye.width,Ye.height,me.depth,ae,He,Ye.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Re,Be,Ye.width,Ye.height,me.depth,0,ae,He,Ye.data)}else{ge&&nt&&n.texStorage2D(t.TEXTURE_2D,ze,Be,ot[0].width,ot[0].height);for(let Re=0,we=ot.length;Re<we;Re++)Ye=ot[Re],L.format!==Fo?ae!==null?ge?xe&&n.compressedTexSubImage2D(t.TEXTURE_2D,Re,0,0,Ye.width,Ye.height,ae,Ye.data):n.compressedTexImage2D(t.TEXTURE_2D,Re,Be,Ye.width,Ye.height,0,Ye.data):nn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ge?xe&&n.texSubImage2D(t.TEXTURE_2D,Re,0,0,Ye.width,Ye.height,ae,He,Ye.data):n.texImage2D(t.TEXTURE_2D,Re,Be,Ye.width,Ye.height,0,ae,He,Ye.data)}else if(L.isDataArrayTexture)if(ge){if(nt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ze,Be,me.width,me.height,me.depth),xe)if(L.layerUpdates.size>0){const Re=KH(me.width,me.height,L.format,L.type);for(const we of L.layerUpdates){const Ke=me.data.subarray(we*Re/me.data.BYTES_PER_ELEMENT,(we+1)*Re/me.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,we,me.width,me.height,1,ae,He,Ke)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,me.width,me.height,me.depth,ae,He,me.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Be,me.width,me.height,me.depth,0,ae,He,me.data);else if(L.isData3DTexture)ge?(nt&&n.texStorage3D(t.TEXTURE_3D,ze,Be,me.width,me.height,me.depth),xe&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,me.width,me.height,me.depth,ae,He,me.data)):n.texImage3D(t.TEXTURE_3D,0,Be,me.width,me.height,me.depth,0,ae,He,me.data);else if(L.isFramebufferTexture){if(nt)if(ge)n.texStorage2D(t.TEXTURE_2D,ze,Be,me.width,me.height);else{let Re=me.width,we=me.height;for(let Ke=0;Ke<ze;Ke++)n.texImage2D(t.TEXTURE_2D,Ke,Be,Re,we,0,ae,He,null),Re>>=1,we>>=1}}else if(ot.length>0){if(ge&&nt){const Re=Se(ot[0]);n.texStorage2D(t.TEXTURE_2D,ze,Be,Re.width,Re.height)}for(let Re=0,we=ot.length;Re<we;Re++)Ye=ot[Re],ge?xe&&n.texSubImage2D(t.TEXTURE_2D,Re,0,0,ae,He,Ye):n.texImage2D(t.TEXTURE_2D,Re,Be,ae,He,Ye);L.generateMipmaps=!1}else if(ge){if(nt){const Re=Se(me);n.texStorage2D(t.TEXTURE_2D,ze,Be,Re.width,Re.height)}xe&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ae,He,me)}else n.texImage2D(t.TEXTURE_2D,0,Be,ae,He,me);x(L)&&y(ye),qe.__version=be.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function Q(U,L,te){if(L.image.length!==6)return;const ye=ne(U,L),Me=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+te);const be=r.get(Me);if(Me.version!==be.__version||ye===!0){n.activeTexture(t.TEXTURE0+te);const qe=zn.getPrimaries(zn.workingColorSpace),Ve=L.colorSpace===Qu?null:zn.getPrimaries(L.colorSpace),We=L.colorSpace===Qu||qe===Ve?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,We);const lt=L.isCompressedTexture||L.image[0].isCompressedTexture,me=L.image[0]&&L.image[0].isDataTexture,ae=[];for(let we=0;we<6;we++)!lt&&!me?ae[we]=v(L.image[we],!0,i.maxCubemapSize):ae[we]=me?L.image[we].image:L.image[we],ae[we]=Ne(L,ae[we]);const He=ae[0],Be=a.convert(L.format,L.colorSpace),Ye=a.convert(L.type),ot=w(L.internalFormat,Be,Ye,L.colorSpace),ge=L.isVideoTexture!==!0,nt=be.__version===void 0||ye===!0,xe=Me.dataReady;let ze=T(L,He);V(t.TEXTURE_CUBE_MAP,L);let Re;if(lt){ge&&nt&&n.texStorage2D(t.TEXTURE_CUBE_MAP,ze,ot,He.width,He.height);for(let we=0;we<6;we++){Re=ae[we].mipmaps;for(let Ke=0;Ke<Re.length;Ke++){const ft=Re[Ke];L.format!==Fo?Be!==null?ge?xe&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke,0,0,ft.width,ft.height,Be,ft.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke,ot,ft.width,ft.height,0,ft.data):nn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ge?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke,0,0,ft.width,ft.height,Be,Ye,ft.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke,ot,ft.width,ft.height,0,Be,Ye,ft.data)}}}else{if(Re=L.mipmaps,ge&&nt){Re.length>0&&ze++;const we=Se(ae[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,ze,ot,we.width,we.height)}for(let we=0;we<6;we++)if(me){ge?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,ae[we].width,ae[we].height,Be,Ye,ae[we].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,ot,ae[we].width,ae[we].height,0,Be,Ye,ae[we].data);for(let Ke=0;Ke<Re.length;Ke++){const Et=Re[Ke].image[we].image;ge?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke+1,0,0,Et.width,Et.height,Be,Ye,Et.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke+1,ot,Et.width,Et.height,0,Be,Ye,Et.data)}}else{ge?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,Be,Ye,ae[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,ot,Be,Ye,ae[we]);for(let Ke=0;Ke<Re.length;Ke++){const ft=Re[Ke];ge?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke+1,0,0,Be,Ye,ft.image[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke+1,ot,Be,Ye,ft.image[we])}}}x(L)&&y(t.TEXTURE_CUBE_MAP),be.__version=Me.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function Ee(U,L,te,ye,Me,be){const qe=a.convert(te.format,te.colorSpace),Ve=a.convert(te.type),We=w(te.internalFormat,qe,Ve,te.colorSpace),lt=r.get(L),me=r.get(te);if(me.__renderTarget=L,!lt.__hasExternalTextures){const ae=Math.max(1,L.width>>be),He=Math.max(1,L.height>>be);Me===t.TEXTURE_3D||Me===t.TEXTURE_2D_ARRAY?n.texImage3D(Me,be,We,ae,He,L.depth,0,qe,Ve,null):n.texImage2D(Me,be,We,ae,He,0,qe,Ve,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),se(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ye,Me,me.__webglTexture,0,Y(L)):(Me===t.TEXTURE_2D||Me>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Me<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ye,Me,me.__webglTexture,be),n.bindFramebuffer(t.FRAMEBUFFER,null)}function he(U,L,te){if(t.bindRenderbuffer(t.RENDERBUFFER,U),L.depthBuffer){const ye=L.depthTexture,Me=ye&&ye.isDepthTexture?ye.type:null,be=A(L.stencilBuffer,Me),qe=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ve=Y(L);se(L)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ve,be,L.width,L.height):te?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,be,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,be,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,qe,t.RENDERBUFFER,U)}else{const ye=L.textures;for(let Me=0;Me<ye.length;Me++){const be=ye[Me],qe=a.convert(be.format,be.colorSpace),Ve=a.convert(be.type),We=w(be.internalFormat,qe,Ve,be.colorSpace),lt=Y(L);te&&se(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,lt,We,L.width,L.height):se(L)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,lt,We,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,We,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ue(U,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ye=r.get(L.depthTexture);ye.__renderTarget=L,(!ye.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),W(L.depthTexture,0);const Me=ye.__webglTexture,be=Y(L);if(L.depthTexture.format===tb)se(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Me,0,be):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Me,0);else if(L.depthTexture.format===nb)se(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Me,0,be):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Me,0);else throw new Error("Unknown depthTexture format")}function Ae(U){const L=r.get(U),te=U.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==U.depthTexture){const ye=U.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),ye){const Me=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,ye.removeEventListener("dispose",Me)};ye.addEventListener("dispose",Me),L.__depthDisposeCallback=Me}L.__boundDepthTexture=ye}if(U.depthTexture&&!L.__autoAllocateDepthBuffer){if(te)throw new Error("target.depthTexture not supported in Cube render targets");const ye=U.texture.mipmaps;ye&&ye.length>0?ue(L.__webglFramebuffer[0],U):ue(L.__webglFramebuffer,U)}else if(te){L.__webglDepthbuffer=[];for(let ye=0;ye<6;ye++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ye]),L.__webglDepthbuffer[ye]===void 0)L.__webglDepthbuffer[ye]=t.createRenderbuffer(),he(L.__webglDepthbuffer[ye],U,!1);else{const Me=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,be=L.__webglDepthbuffer[ye];t.bindRenderbuffer(t.RENDERBUFFER,be),t.framebufferRenderbuffer(t.FRAMEBUFFER,Me,t.RENDERBUFFER,be)}}else{const ye=U.texture.mipmaps;if(ye&&ye.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),he(L.__webglDepthbuffer,U,!1);else{const Me=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,be=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,be),t.framebufferRenderbuffer(t.FRAMEBUFFER,Me,t.RENDERBUFFER,be)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function fe(U,L,te){const ye=r.get(U);L!==void 0&&Ee(ye.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),te!==void 0&&Ae(U)}function at(U){const L=U.texture,te=r.get(U),ye=r.get(L);U.addEventListener("dispose",N);const Me=U.textures,be=U.isWebGLCubeRenderTarget===!0,qe=Me.length>1;if(qe||(ye.__webglTexture===void 0&&(ye.__webglTexture=t.createTexture()),ye.__version=L.version,s.memory.textures++),be){te.__webglFramebuffer=[];for(let Ve=0;Ve<6;Ve++)if(L.mipmaps&&L.mipmaps.length>0){te.__webglFramebuffer[Ve]=[];for(let We=0;We<L.mipmaps.length;We++)te.__webglFramebuffer[Ve][We]=t.createFramebuffer()}else te.__webglFramebuffer[Ve]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){te.__webglFramebuffer=[];for(let Ve=0;Ve<L.mipmaps.length;Ve++)te.__webglFramebuffer[Ve]=t.createFramebuffer()}else te.__webglFramebuffer=t.createFramebuffer();if(qe)for(let Ve=0,We=Me.length;Ve<We;Ve++){const lt=r.get(Me[Ve]);lt.__webglTexture===void 0&&(lt.__webglTexture=t.createTexture(),s.memory.textures++)}if(U.samples>0&&se(U)===!1){te.__webglMultisampledFramebuffer=t.createFramebuffer(),te.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,te.__webglMultisampledFramebuffer);for(let Ve=0;Ve<Me.length;Ve++){const We=Me[Ve];te.__webglColorRenderbuffer[Ve]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,te.__webglColorRenderbuffer[Ve]);const lt=a.convert(We.format,We.colorSpace),me=a.convert(We.type),ae=w(We.internalFormat,lt,me,We.colorSpace,U.isXRRenderTarget===!0),He=Y(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,He,ae,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,te.__webglColorRenderbuffer[Ve])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(te.__webglDepthRenderbuffer=t.createRenderbuffer(),he(te.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(be){n.bindTexture(t.TEXTURE_CUBE_MAP,ye.__webglTexture),V(t.TEXTURE_CUBE_MAP,L);for(let Ve=0;Ve<6;Ve++)if(L.mipmaps&&L.mipmaps.length>0)for(let We=0;We<L.mipmaps.length;We++)Ee(te.__webglFramebuffer[Ve][We],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,We);else Ee(te.__webglFramebuffer[Ve],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0);x(L)&&y(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(qe){for(let Ve=0,We=Me.length;Ve<We;Ve++){const lt=Me[Ve],me=r.get(lt);let ae=t.TEXTURE_2D;(U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(ae=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ae,me.__webglTexture),V(ae,lt),Ee(te.__webglFramebuffer,U,lt,t.COLOR_ATTACHMENT0+Ve,ae,0),x(lt)&&y(ae)}n.unbindTexture()}else{let Ve=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(Ve=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ve,ye.__webglTexture),V(Ve,L),L.mipmaps&&L.mipmaps.length>0)for(let We=0;We<L.mipmaps.length;We++)Ee(te.__webglFramebuffer[We],U,L,t.COLOR_ATTACHMENT0,Ve,We);else Ee(te.__webglFramebuffer,U,L,t.COLOR_ATTACHMENT0,Ve,0);x(L)&&y(Ve),n.unbindTexture()}U.depthBuffer&&Ae(U)}function B(U){const L=U.textures;for(let te=0,ye=L.length;te<ye;te++){const Me=L[te];if(x(Me)){const be=E(U),qe=r.get(Me).__webglTexture;n.bindTexture(be,qe),y(be),n.unbindTexture()}}}const $=[],ie=[];function H(U){if(U.samples>0){if(se(U)===!1){const L=U.textures,te=U.width,ye=U.height;let Me=t.COLOR_BUFFER_BIT;const be=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,qe=r.get(U),Ve=L.length>1;if(Ve)for(let lt=0;lt<L.length;lt++)n.bindFramebuffer(t.FRAMEBUFFER,qe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,qe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,qe.__webglMultisampledFramebuffer);const We=U.texture.mipmaps;We&&We.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,qe.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,qe.__webglFramebuffer);for(let lt=0;lt<L.length;lt++){if(U.resolveDepthBuffer&&(U.depthBuffer&&(Me|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&U.resolveStencilBuffer&&(Me|=t.STENCIL_BUFFER_BIT)),Ve){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,qe.__webglColorRenderbuffer[lt]);const me=r.get(L[lt]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,me,0)}t.blitFramebuffer(0,0,te,ye,0,0,te,ye,Me,t.NEAREST),c===!0&&($.length=0,ie.length=0,$.push(t.COLOR_ATTACHMENT0+lt),U.depthBuffer&&U.resolveDepthBuffer===!1&&($.push(be),ie.push(be),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,ie)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,$))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ve)for(let lt=0;lt<L.length;lt++){n.bindFramebuffer(t.FRAMEBUFFER,qe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.RENDERBUFFER,qe.__webglColorRenderbuffer[lt]);const me=r.get(L[lt]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,qe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.TEXTURE_2D,me,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,qe.__webglMultisampledFramebuffer)}else if(U.depthBuffer&&U.resolveDepthBuffer===!1&&c){const L=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function Y(U){return Math.min(i.maxSamples,U.samples)}function se(U){const L=r.get(U);return U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function ve(U){const L=s.render.frame;d.get(U)!==L&&(d.set(U,L),U.update())}function Ne(U,L){const te=U.colorSpace,ye=U.format,Me=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||te!==Bp&&te!==Qu&&(zn.getTransfer(te)===ar?(ye!==Fo||Me!==Al)&&nn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Qr("WebGLTextures: Unsupported texture color space:",te)),L}function Se(U){return typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement?(u.width=U.naturalWidth||U.width,u.height=U.naturalHeight||U.height):typeof VideoFrame<"u"&&U instanceof VideoFrame?(u.width=U.displayWidth,u.height=U.displayHeight):(u.width=U.width,u.height=U.height),u}this.allocateTextureUnit=q,this.resetTextureUnits=I,this.setTexture2D=W,this.setTexture2DArray=K,this.setTexture3D=G,this.setTextureCube=J,this.rebindTextures=fe,this.setupRenderTarget=at,this.updateRenderTargetMipmap=B,this.updateMultisampleRenderTarget=H,this.setupDepthRenderbuffer=Ae,this.setupFrameBufferTexture=Ee,this.useMultisampledRTT=se}function kDe(t,e){function n(r,i=Qu){let a;const s=zn.getTransfer(i);if(r===Al)return t.UNSIGNED_BYTE;if(r===CO)return t.UNSIGNED_SHORT_4_4_4_4;if(r===kO)return t.UNSIGNED_SHORT_5_5_5_1;if(r===MZ)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===EZ)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===wZ)return t.BYTE;if(r===SZ)return t.SHORT;if(r===J0)return t.UNSIGNED_SHORT;if(r===NO)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===AZ)return t.ALPHA;if(r===TZ)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===NZ)return t.RED;if(r===PO)return t.RED_INTEGER;if(r===jO)return t.RG;if(r===RO)return t.RG_INTEGER;if(r===DO)return t.RGBA_INTEGER;if(r===S1||r===M1||r===E1||r===A1)if(s===ar)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===S1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===M1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===E1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===A1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===S1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===M1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===E1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===A1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===_P||r===wP||r===SP||r===MP)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===_P)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===wP)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===SP)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===MP)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===EP||r===AP||r===TP)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===EP||r===AP)return s===ar?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===TP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(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||r===BP)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===NP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===CP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===kP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===PP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===jP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===RP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===DP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===OP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===LP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===IP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===FP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===UP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===zP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===BP)return s===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===HP||r===$P||r===VP)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===HP)return s===ar?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===$P)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===VP)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===GP||r===WP||r===qP||r===KP)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===GP)return a.COMPRESSED_RED_RGTC1_EXT;if(r===WP)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===qP)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===KP)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 PDe=`
  3905. void main() {
  3906. gl_Position = vec4( position, 1.0 );
  3907. }`,jDe=`
  3908. uniform sampler2DArray depthColor;
  3909. uniform float depthWidth;
  3910. uniform float depthHeight;
  3911. void main() {
  3912. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3913. if ( coord.x >= 1.0 ) {
  3914. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3915. } else {
  3916. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3917. }
  3918. }`;class RDe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new XZ(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 Yc({vertexShader:PDe,fragmentShader:jDe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Tl(new zO(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let DDe=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,b=null;const v=typeof XRWebGLBinding<"u",x=new RDe,y={},E=n.getContextAttributes();let w=null,A=null;const T=[],C=[],N=new bn;let O=null;const k=new no;k.viewport=new ci;const j=new no;j.viewport=new ci;const z=[k,j],I=new Zke;let q=null,R=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(pe){let Q=T[pe];return Q===void 0&&(Q=new rC,T[pe]=Q),Q.getTargetRaySpace()},this.getControllerGrip=function(pe){let Q=T[pe];return Q===void 0&&(Q=new rC,T[pe]=Q),Q.getGripSpace()},this.getHand=function(pe){let Q=T[pe];return Q===void 0&&(Q=new rC,T[pe]=Q),Q.getHandSpace()};function W(pe){const Q=C.indexOf(pe.inputSource);if(Q===-1)return;const Ee=T[Q];Ee!==void 0&&(Ee.update(pe.inputSource,pe.frame,u||s),Ee.dispatchEvent({type:pe.type,data:pe.inputSource}))}function K(){i.removeEventListener("select",W),i.removeEventListener("selectstart",W),i.removeEventListener("selectend",W),i.removeEventListener("squeeze",W),i.removeEventListener("squeezestart",W),i.removeEventListener("squeezeend",W),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",G);for(let pe=0;pe<T.length;pe++){const Q=C[pe];Q!==null&&(C[pe]=null,T[pe].disconnect(Q))}q=null,R=null,x.reset();for(const pe in y)delete y[pe];e.setRenderTarget(w),p=null,g=null,f=null,i=null,A=null,oe.stop(),r.isPresenting=!1,e.setPixelRatio(O),e.setSize(N.width,N.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(pe){a=pe,r.isPresenting===!0&&nn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(pe){l=pe,r.isPresenting===!0&&nn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||s},this.setReferenceSpace=function(pe){u=pe},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 b},this.getSession=function(){return i},this.setSession=async function(pe){if(i=pe,i!==null){if(w=e.getRenderTarget(),i.addEventListener("select",W),i.addEventListener("selectstart",W),i.addEventListener("selectend",W),i.addEventListener("squeeze",W),i.addEventListener("squeezestart",W),i.addEventListener("squeezeend",W),i.addEventListener("end",K),i.addEventListener("inputsourceschange",G),E.xrCompatible!==!0&&await n.makeXRCompatible(),O=e.getPixelRatio(),e.getSize(N),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ee=null,he=null,ue=null;E.depth&&(ue=E.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ee=E.stencil?nb:tb,he=E.stencil?eb:mf);const Ae={colorFormat:n.RGBA8,depthFormat:ue,scaleFactor:a};f=this.getBinding(),g=f.createProjectionLayer(Ae),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 KZ(g.textureWidth,g.textureHeight,he,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),oe.setContext(i),oe.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function G(pe){for(let Q=0;Q<pe.removed.length;Q++){const Ee=pe.removed[Q],he=C.indexOf(Ee);he>=0&&(C[he]=null,T[he].disconnect(Ee))}for(let Q=0;Q<pe.added.length;Q++){const Ee=pe.added[Q];let he=C.indexOf(Ee);if(he===-1){for(let Ae=0;Ae<T.length;Ae++)if(Ae>=C.length){C.push(Ee),he=Ae;break}else if(C[Ae]===null){C[Ae]=Ee,he=Ae;break}if(he===-1)break}const ue=T[he];ue&&ue.connect(Ee)}}const J=new it,ee=new it;function Z(pe,Q,Ee){J.setFromMatrixPosition(Q.matrixWorld),ee.setFromMatrixPosition(Ee.matrixWorld);const he=J.distanceTo(ee),ue=Q.projectionMatrix.elements,Ae=Ee.projectionMatrix.elements,fe=ue[14]/(ue[10]-1),at=ue[14]/(ue[10]+1),B=(ue[9]+1)/ue[5],$=(ue[9]-1)/ue[5],ie=(ue[8]-1)/ue[0],H=(Ae[8]+1)/Ae[0],Y=fe*ie,se=fe*H,ve=he/(-ie+H),Ne=ve*-ie;if(Q.matrixWorld.decompose(pe.position,pe.quaternion,pe.scale),pe.translateX(Ne),pe.translateZ(ve),pe.matrixWorld.compose(pe.position,pe.quaternion,pe.scale),pe.matrixWorldInverse.copy(pe.matrixWorld).invert(),ue[10]===-1)pe.projectionMatrix.copy(Q.projectionMatrix),pe.projectionMatrixInverse.copy(Q.projectionMatrixInverse);else{const Se=fe+ve,U=at+ve,L=Y-Ne,te=se+(he-Ne),ye=B*at/U*Se,Me=$*at/U*Se;pe.projectionMatrix.makePerspective(L,te,ye,Me,Se,U),pe.projectionMatrixInverse.copy(pe.projectionMatrix).invert()}}function F(pe,Q){Q===null?pe.matrixWorld.copy(pe.matrix):pe.matrixWorld.multiplyMatrices(Q.matrixWorld,pe.matrix),pe.matrixWorldInverse.copy(pe.matrixWorld).invert()}this.updateCamera=function(pe){if(i===null)return;let Q=pe.near,Ee=pe.far;x.texture!==null&&(x.depthNear>0&&(Q=x.depthNear),x.depthFar>0&&(Ee=x.depthFar)),I.near=j.near=k.near=Q,I.far=j.far=k.far=Ee,(q!==I.near||R!==I.far)&&(i.updateRenderState({depthNear:I.near,depthFar:I.far}),q=I.near,R=I.far),I.layers.mask=pe.layers.mask|6,k.layers.mask=I.layers.mask&3,j.layers.mask=I.layers.mask&5;const he=pe.parent,ue=I.cameras;F(I,he);for(let Ae=0;Ae<ue.length;Ae++)F(ue[Ae],he);ue.length===2?Z(I,k,j):I.projectionMatrix.copy(k.projectionMatrix),V(pe,I,he)};function V(pe,Q,Ee){Ee===null?pe.matrix.copy(Q.matrixWorld):(pe.matrix.copy(Ee.matrixWorld),pe.matrix.invert(),pe.matrix.multiply(Q.matrixWorld)),pe.matrix.decompose(pe.position,pe.quaternion,pe.scale),pe.updateMatrixWorld(!0),pe.projectionMatrix.copy(Q.projectionMatrix),pe.projectionMatrixInverse.copy(Q.projectionMatrixInverse),pe.isPerspectiveCamera&&(pe.fov=XP*2*Math.atan(1/pe.projectionMatrix.elements[5]),pe.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(g===null&&p===null))return c},this.setFoveation=function(pe){c=pe,g!==null&&(g.fixedFoveation=pe),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=pe)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(I)},this.getCameraTexture=function(pe){return y[pe]};let ne=null;function le(pe,Q){if(d=Q.getViewerPose(u||s),b=Q,d!==null){const Ee=d.views;p!==null&&(e.setRenderTargetFramebuffer(A,p.framebuffer),e.setRenderTarget(A));let he=!1;Ee.length!==I.cameras.length&&(I.cameras.length=0,he=!0);for(let at=0;at<Ee.length;at++){const B=Ee[at];let $=null;if(p!==null)$=p.getViewport(B);else{const H=f.getViewSubImage(g,B);$=H.viewport,at===0&&(e.setRenderTargetTextures(A,H.colorTexture,H.depthStencilTexture),e.setRenderTarget(A))}let ie=z[at];ie===void 0&&(ie=new no,ie.layers.enable(at),ie.viewport=new ci,z[at]=ie),ie.matrix.fromArray(B.transform.matrix),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.projectionMatrix.fromArray(B.projectionMatrix),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert(),ie.viewport.set($.x,$.y,$.width,$.height),at===0&&(I.matrix.copy(ie.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),he===!0&&I.cameras.push(ie)}const ue=i.enabledFeatures;if(ue&&ue.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){f=r.getBinding();const at=f.getDepthInformation(Ee[0]);at&&at.isValid&&at.texture&&x.init(at,i.renderState)}if(ue&&ue.includes("camera-access")&&v){e.state.unbindTexture(),f=r.getBinding();for(let at=0;at<Ee.length;at++){const B=Ee[at].camera;if(B){let $=y[B];$||($=new XZ,y[B]=$);const ie=f.getCameraImage(B);$.sourceTexture=ie}}}}for(let Ee=0;Ee<T.length;Ee++){const he=C[Ee],ue=T[Ee];he!==null&&ue!==void 0&&ue.update(he,Q,u||s)}ne&&ne(pe,Q),Q.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:Q}),b=null}const oe=new JZ;oe.setAnimationLoop(le),this.setAnimationLoop=function(pe){ne=pe},this.dispose=function(){}}};const lh=new Nd,ODe=new mi;function LDe(t,e){function n(x,y){x.matrixAutoUpdate===!0&&x.updateMatrix(),y.value.copy(x.matrix)}function r(x,y){y.color.getRGB(x.fogColor.value,VZ(t)),y.isFog?(x.fogNear.value=y.near,x.fogFar.value=y.far):y.isFogExp2&&(x.fogDensity.value=y.density)}function i(x,y,E,w,A){y.isMeshBasicMaterial||y.isMeshLambertMaterial?a(x,y):y.isMeshToonMaterial?(a(x,y),f(x,y)):y.isMeshPhongMaterial?(a(x,y),d(x,y)):y.isMeshStandardMaterial?(a(x,y),g(x,y),y.isMeshPhysicalMaterial&&p(x,y,A)):y.isMeshMatcapMaterial?(a(x,y),b(x,y)):y.isMeshDepthMaterial?a(x,y):y.isMeshDistanceMaterial?(a(x,y),v(x,y)):y.isMeshNormalMaterial?a(x,y):y.isLineBasicMaterial?(s(x,y),y.isLineDashedMaterial&&l(x,y)):y.isPointsMaterial?c(x,y,E,w):y.isSpriteMaterial?u(x,y):y.isShadowMaterial?(x.color.value.copy(y.color),x.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function a(x,y){x.opacity.value=y.opacity,y.color&&x.diffuse.value.copy(y.color),y.emissive&&x.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(x.map.value=y.map,n(y.map,x.mapTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.bumpMap&&(x.bumpMap.value=y.bumpMap,n(y.bumpMap,x.bumpMapTransform),x.bumpScale.value=y.bumpScale,y.side===ns&&(x.bumpScale.value*=-1)),y.normalMap&&(x.normalMap.value=y.normalMap,n(y.normalMap,x.normalMapTransform),x.normalScale.value.copy(y.normalScale),y.side===ns&&x.normalScale.value.negate()),y.displacementMap&&(x.displacementMap.value=y.displacementMap,n(y.displacementMap,x.displacementMapTransform),x.displacementScale.value=y.displacementScale,x.displacementBias.value=y.displacementBias),y.emissiveMap&&(x.emissiveMap.value=y.emissiveMap,n(y.emissiveMap,x.emissiveMapTransform)),y.specularMap&&(x.specularMap.value=y.specularMap,n(y.specularMap,x.specularMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest);const E=e.get(y),w=E.envMap,A=E.envMapRotation;w&&(x.envMap.value=w,lh.copy(A),lh.x*=-1,lh.y*=-1,lh.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(lh.y*=-1,lh.z*=-1),x.envMapRotation.value.setFromMatrix4(ODe.makeRotationFromEuler(lh)),x.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=y.reflectivity,x.ior.value=y.ior,x.refractionRatio.value=y.refractionRatio),y.lightMap&&(x.lightMap.value=y.lightMap,x.lightMapIntensity.value=y.lightMapIntensity,n(y.lightMap,x.lightMapTransform)),y.aoMap&&(x.aoMap.value=y.aoMap,x.aoMapIntensity.value=y.aoMapIntensity,n(y.aoMap,x.aoMapTransform))}function s(x,y){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,y.map&&(x.map.value=y.map,n(y.map,x.mapTransform))}function l(x,y){x.dashSize.value=y.dashSize,x.totalSize.value=y.dashSize+y.gapSize,x.scale.value=y.scale}function c(x,y,E,w){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,x.size.value=y.size*E,x.scale.value=w*.5,y.map&&(x.map.value=y.map,n(y.map,x.uvTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest)}function u(x,y){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,x.rotation.value=y.rotation,y.map&&(x.map.value=y.map,n(y.map,x.mapTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest)}function d(x,y){x.specular.value.copy(y.specular),x.shininess.value=Math.max(y.shininess,1e-4)}function f(x,y){y.gradientMap&&(x.gradientMap.value=y.gradientMap)}function g(x,y){x.metalness.value=y.metalness,y.metalnessMap&&(x.metalnessMap.value=y.metalnessMap,n(y.metalnessMap,x.metalnessMapTransform)),x.roughness.value=y.roughness,y.roughnessMap&&(x.roughnessMap.value=y.roughnessMap,n(y.roughnessMap,x.roughnessMapTransform)),y.envMap&&(x.envMapIntensity.value=y.envMapIntensity)}function p(x,y,E){x.ior.value=y.ior,y.sheen>0&&(x.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),x.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(x.sheenColorMap.value=y.sheenColorMap,n(y.sheenColorMap,x.sheenColorMapTransform)),y.sheenRoughnessMap&&(x.sheenRoughnessMap.value=y.sheenRoughnessMap,n(y.sheenRoughnessMap,x.sheenRoughnessMapTransform))),y.clearcoat>0&&(x.clearcoat.value=y.clearcoat,x.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(x.clearcoatMap.value=y.clearcoatMap,n(y.clearcoatMap,x.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,n(y.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(x.clearcoatNormalMap.value=y.clearcoatNormalMap,n(y.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===ns&&x.clearcoatNormalScale.value.negate())),y.dispersion>0&&(x.dispersion.value=y.dispersion),y.iridescence>0&&(x.iridescence.value=y.iridescence,x.iridescenceIOR.value=y.iridescenceIOR,x.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(x.iridescenceMap.value=y.iridescenceMap,n(y.iridescenceMap,x.iridescenceMapTransform)),y.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=y.iridescenceThicknessMap,n(y.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),y.transmission>0&&(x.transmission.value=y.transmission,x.transmissionSamplerMap.value=E.texture,x.transmissionSamplerSize.value.set(E.width,E.height),y.transmissionMap&&(x.transmissionMap.value=y.transmissionMap,n(y.transmissionMap,x.transmissionMapTransform)),x.thickness.value=y.thickness,y.thicknessMap&&(x.thicknessMap.value=y.thicknessMap,n(y.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=y.attenuationDistance,x.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(x.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(x.anisotropyMap.value=y.anisotropyMap,n(y.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=y.specularIntensity,x.specularColor.value.copy(y.specularColor),y.specularColorMap&&(x.specularColorMap.value=y.specularColorMap,n(y.specularColorMap,x.specularColorMapTransform)),y.specularIntensityMap&&(x.specularIntensityMap.value=y.specularIntensityMap,n(y.specularIntensityMap,x.specularIntensityMapTransform))}function b(x,y){y.matcap&&(x.matcap.value=y.matcap)}function v(x,y){const E=e.get(y).light;x.referencePosition.value.setFromMatrixPosition(E.matrixWorld),x.nearDistance.value=E.shadow.camera.near,x.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function IDe(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&&(b(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",x));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 z=O[k];if(p(z,C,k,T)===!0){const I=z.__offset,q=Array.isArray(z.value)?z.value:[z.value];let R=0;for(let W=0;W<q.length;W++){const K=q[W],G=v(K);typeof K=="number"||typeof K=="boolean"?(z.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,I+R,z.__data)):K.isMatrix3?(z.__data[0]=K.elements[0],z.__data[1]=K.elements[1],z.__data[2]=K.elements[2],z.__data[3]=0,z.__data[4]=K.elements[3],z.__data[5]=K.elements[4],z.__data[6]=K.elements[5],z.__data[7]=0,z.__data[8]=K.elements[6],z.__data[9]=K.elements[7],z.__data[10]=K.elements[8],z.__data[11]=0):(K.toArray(z.__data,R),R+=G.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,I,z.__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 b(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,z=k.length;j<z;j++){const I=k[j],q=Array.isArray(I.value)?I.value:[I.value];for(let R=0,W=q.length;R<W;R++){const K=q[R],G=v(K),J=A%T,ee=J%G.boundary,Z=J+ee;A+=ee,Z!==0&&T-Z<G.storage&&(A+=T-Z),I.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=A,A+=G.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?nn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):nn("WebGLRenderer: Unsupported uniform value type.",E),w}function x(E){const w=E.target;w.removeEventListener("dispose",x);const A=s.indexOf(w.__bindingPointIndex);s.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function y(){for(const E in i)t.deleteBuffer(i[E]);s=[],i={},a={}}return{bind:c,update:u,dispose:y}}const FDe=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 UDe(){return sc===null&&(sc=new Uke(FDe,32,32,jO,yg),sc.minFilter=lo,sc.magFilter=lo,sc.wrapS=Tc,sc.wrapT=Tc,sc.generateMipmaps=!1,sc.needsUpdate=!0),sc}let zDe=class{constructor(e={}){const{canvas:n=uke(),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 b=new Set([DO,RO,PO]),v=new Set([Al,mf,J0,eb,CO,kO]),x=new Uint32Array(4),y=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=ud,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let N=!1;this._outputColorSpace=Js;let O=0,k=0,j=null,z=-1,I=null;const q=new ci,R=new ci;let W=null;const K=new Nn(0);let G=0,J=n.width,ee=n.height,Z=1,F=null,V=null;const ne=new ci(0,0,J,ee),le=new ci(0,0,J,ee);let oe=!1;const pe=new UO;let Q=!1,Ee=!1;const he=new mi,ue=new it,Ae=new ci,fe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let at=!1;function B(){return j===null?Z:1}let $=r;function ie(re,Te){return n.getContext(re,Te)}try{const re={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${AO}`),n.addEventListener("webglcontextlost",Re,!1),n.addEventListener("webglcontextrestored",we,!1),n.addEventListener("webglcontextcreationerror",Ke,!1),$===null){const Te="webgl2";if($=ie(Te,re),$===null)throw ie(Te)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(re){throw re("WebGLRenderer: "+re.message),re}let H,Y,se,ve,Ne,Se,U,L,te,ye,Me,be,qe,Ve,We,lt,me,ae,He,Be,Ye,ot,ge,nt;function xe(){H=new Kje($),H.init(),ot=new kDe($,H),Y=new Uje($,H,e,ot),se=new NDe($,H),Y.reversedDepthBuffer&&g&&se.buffers.depth.setReversed(!0),ve=new Zje($),Ne=new pDe,Se=new CDe($,H,se,Ne,Y,ot,ve),U=new Bje(C),L=new qje(C),te=new t3e($),ge=new Ije($,te),ye=new Xje($,te,ve,ge),Me=new Jje($,ye,te,ve),He=new Qje($,Y,Se),lt=new zje(Ne),be=new mDe(C,U,L,H,Y,ge,lt),qe=new LDe(C,Ne),Ve=new xDe,We=new SDe(H),ae=new Lje(C,U,L,se,Me,p,c),me=new ADe(C,Me,Y),nt=new IDe($,ve,Y,se),Be=new Fje($,H,ve),Ye=new Yje($,H,ve),ve.programs=be.programs,C.capabilities=Y,C.extensions=H,C.properties=Ne,C.renderLists=Ve,C.shadowMap=me,C.state=se,C.info=ve}xe();const ze=new DDe(C,$);this.xr=ze,this.getContext=function(){return $},this.getContextAttributes=function(){return $.getContextAttributes()},this.forceContextLoss=function(){const re=H.get("WEBGL_lose_context");re&&re.loseContext()},this.forceContextRestore=function(){const re=H.get("WEBGL_lose_context");re&&re.restoreContext()},this.getPixelRatio=function(){return Z},this.setPixelRatio=function(re){re!==void 0&&(Z=re,this.setSize(J,ee,!1))},this.getSize=function(re){return re.set(J,ee)},this.setSize=function(re,Te,Ie=!0){if(ze.isPresenting){nn("WebGLRenderer: Can't change size while VR device is presenting.");return}J=re,ee=Te,n.width=Math.floor(re*Z),n.height=Math.floor(Te*Z),Ie===!0&&(n.style.width=re+"px",n.style.height=Te+"px"),this.setViewport(0,0,re,Te)},this.getDrawingBufferSize=function(re){return re.set(J*Z,ee*Z).floor()},this.setDrawingBufferSize=function(re,Te,Ie){J=re,ee=Te,Z=Ie,n.width=Math.floor(re*Ie),n.height=Math.floor(Te*Ie),this.setViewport(0,0,re,Te)},this.getCurrentViewport=function(re){return re.copy(q)},this.getViewport=function(re){return re.copy(ne)},this.setViewport=function(re,Te,Ie,De){re.isVector4?ne.set(re.x,re.y,re.z,re.w):ne.set(re,Te,Ie,De),se.viewport(q.copy(ne).multiplyScalar(Z).round())},this.getScissor=function(re){return re.copy(le)},this.setScissor=function(re,Te,Ie,De){re.isVector4?le.set(re.x,re.y,re.z,re.w):le.set(re,Te,Ie,De),se.scissor(R.copy(le).multiplyScalar(Z).round())},this.getScissorTest=function(){return oe},this.setScissorTest=function(re){se.setScissorTest(oe=re)},this.setOpaqueSort=function(re){F=re},this.setTransparentSort=function(re){V=re},this.getClearColor=function(re){return re.copy(ae.getClearColor())},this.setClearColor=function(){ae.setClearColor(...arguments)},this.getClearAlpha=function(){return ae.getClearAlpha()},this.setClearAlpha=function(){ae.setClearAlpha(...arguments)},this.clear=function(re=!0,Te=!0,Ie=!0){let De=0;if(re){let je=!1;if(j!==null){const ct=j.texture.format;je=b.has(ct)}if(je){const ct=j.texture.type,yt=v.has(ct),Ct=ae.getClearColor(),Nt=ae.getClearAlpha(),Ut=Ct.r,jt=Ct.g,St=Ct.b;yt?(x[0]=Ut,x[1]=jt,x[2]=St,x[3]=Nt,$.clearBufferuiv($.COLOR,0,x)):(y[0]=Ut,y[1]=jt,y[2]=St,y[3]=Nt,$.clearBufferiv($.COLOR,0,y))}else De|=$.COLOR_BUFFER_BIT}Te&&(De|=$.DEPTH_BUFFER_BIT),Ie&&(De|=$.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),$.clear(De)},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",Re,!1),n.removeEventListener("webglcontextrestored",we,!1),n.removeEventListener("webglcontextcreationerror",Ke,!1),ae.dispose(),Ve.dispose(),We.dispose(),Ne.dispose(),U.dispose(),L.dispose(),Me.dispose(),ge.dispose(),nt.dispose(),be.dispose(),ze.dispose(),ze.removeEventListener("sessionstart",Hn),ze.removeEventListener("sessionend",bt),Ht.stop()};function Re(re){re.preventDefault(),SH("WebGLRenderer: Context Lost."),N=!0}function we(){SH("WebGLRenderer: Context Restored."),N=!1;const re=ve.autoReset,Te=me.enabled,Ie=me.autoUpdate,De=me.needsUpdate,je=me.type;xe(),ve.autoReset=re,me.enabled=Te,me.autoUpdate=Ie,me.needsUpdate=De,me.type=je}function Ke(re){Qr("WebGLRenderer: A WebGL context could not be created. Reason: ",re.statusMessage)}function ft(re){const Te=re.target;Te.removeEventListener("dispose",ft),Et(Te)}function Et(re){wt(re),Ne.remove(re)}function wt(re){const Te=Ne.get(re).programs;Te!==void 0&&(Te.forEach(function(Ie){be.releaseProgram(Ie)}),re.isShaderMaterial&&be.releaseShaderCache(re))}this.renderBufferDirect=function(re,Te,Ie,De,je,ct){Te===null&&(Te=fe);const yt=je.isMesh&&je.matrixWorld.determinant()<0,Ct=ce(re,Te,Ie,De,je);se.setMaterial(De,yt);let Nt=Ie.index,Ut=1;if(De.wireframe===!0){if(Nt=ye.getWireframeAttribute(Ie),Nt===void 0)return;Ut=2}const jt=Ie.drawRange,St=Ie.attributes.position;let tn=jt.start*Ut,$t=(jt.start+jt.count)*Ut;ct!==null&&(tn=Math.max(tn,ct.start*Ut),$t=Math.min($t,(ct.start+ct.count)*Ut)),Nt!==null?(tn=Math.max(tn,0),$t=Math.min($t,Nt.count)):St!=null&&(tn=Math.max(tn,0),$t=Math.min($t,St.count));const mn=$t-tn;if(mn<0||mn===1/0)return;ge.setup(je,De,Ct,Ie,Nt);let Sn,kn=Be;if(Nt!==null&&(Sn=te.get(Nt),kn=Ye,kn.setIndex(Sn)),je.isMesh)De.wireframe===!0?(se.setLineWidth(De.wireframeLinewidth*B()),kn.setMode($.LINES)):kn.setMode($.TRIANGLES);else if(je.isLine){let Bt=De.linewidth;Bt===void 0&&(Bt=1),se.setLineWidth(Bt*B()),je.isLineSegments?kn.setMode($.LINES):je.isLineLoop?kn.setMode($.LINE_LOOP):kn.setMode($.LINE_STRIP)}else je.isPoints?kn.setMode($.POINTS):je.isSprite&&kn.setMode($.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."),kn.renderMultiDrawInstances(je._multiDrawStarts,je._multiDrawCounts,je._multiDrawCount,je._multiDrawInstances);else if(H.get("WEBGL_multi_draw"))kn.renderMultiDraw(je._multiDrawStarts,je._multiDrawCounts,je._multiDrawCount);else{const Bt=je._multiDrawStarts,on=je._multiDrawCounts,cn=je._multiDrawCount,Ur=Nt?te.get(Nt).bytesPerElement:1,qr=Ne.get(De).currentProgram.getUniforms();for(let Gn=0;Gn<cn;Gn++)qr.setValue($,"_gl_DrawID",Gn),kn.render(Bt[Gn]/Ur,on[Gn])}else if(je.isInstancedMesh)kn.renderInstances(tn,mn,je.count);else if(Ie.isInstancedBufferGeometry){const Bt=Ie._maxInstanceCount!==void 0?Ie._maxInstanceCount:1/0,on=Math.min(Ie.instanceCount,Bt);kn.renderInstances(tn,mn,on)}else kn.render(tn,mn)};function Qt(re,Te,Ie){re.transparent===!0&&re.side===dl&&re.forceSinglePass===!1?(re.side=ns,re.needsUpdate=!0,_n(re,Te,Ie),re.side=Td,re.needsUpdate=!0,_n(re,Te,Ie),re.side=dl):_n(re,Te,Ie)}this.compile=function(re,Te,Ie=null){Ie===null&&(Ie=re),w=We.get(Ie),w.init(Te),T.push(w),Ie.traverseVisible(function(je){je.isLight&&je.layers.test(Te.layers)&&(w.pushLight(je),je.castShadow&&w.pushShadow(je))}),re!==Ie&&re.traverseVisible(function(je){je.isLight&&je.layers.test(Te.layers)&&(w.pushLight(je),je.castShadow&&w.pushShadow(je))}),w.setupLights();const De=new Set;return re.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 yt=0;yt<ct.length;yt++){const Ct=ct[yt];Qt(Ct,Ie,je),De.add(Ct)}else Qt(ct,Ie,je),De.add(ct)}),w=T.pop(),De},this.compileAsync=function(re,Te,Ie=null){const De=this.compile(re,Te,Ie);return new Promise(je=>{function ct(){if(De.forEach(function(yt){Ne.get(yt).currentProgram.isReady()&&De.delete(yt)}),De.size===0){je(re);return}setTimeout(ct,10)}H.get("KHR_parallel_shader_compile")!==null?ct():setTimeout(ct,10)})};let Ft=null;function hn(re){Ft&&Ft(re)}function Hn(){Ht.stop()}function bt(){Ht.start()}const Ht=new JZ;Ht.setAnimationLoop(hn),typeof self<"u"&&Ht.setContext(self),this.setAnimationLoop=function(re){Ft=re,ze.setAnimationLoop(re),re===null?Ht.stop():Ht.start()},ze.addEventListener("sessionstart",Hn),ze.addEventListener("sessionend",bt),this.render=function(re,Te){if(Te!==void 0&&Te.isCamera!==!0){Qr("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(re.matrixWorldAutoUpdate===!0&&re.updateMatrixWorld(),Te.parent===null&&Te.matrixWorldAutoUpdate===!0&&Te.updateMatrixWorld(),ze.enabled===!0&&ze.isPresenting===!0&&(ze.cameraAutoUpdate===!0&&ze.updateCamera(Te),Te=ze.getCamera()),re.isScene===!0&&re.onBeforeRender(C,re,Te,j),w=We.get(re,T.length),w.init(Te),T.push(w),he.multiplyMatrices(Te.projectionMatrix,Te.matrixWorldInverse),pe.setFromProjectionMatrix(he,pl,Te.reversedDepth),Ee=this.localClippingEnabled,Q=lt.init(this.clippingPlanes,Ee),E=Ve.get(re,A.length),E.init(),A.push(E),ze.enabled===!0&&ze.isPresenting===!0){const ct=C.xr.getDepthSensingMesh();ct!==null&&an(ct,Te,-1/0,C.sortObjects)}an(re,Te,0,C.sortObjects),E.finish(),C.sortObjects===!0&&E.sort(F,V),at=ze.enabled===!1||ze.isPresenting===!1||ze.hasDepthSensing()===!1,at&&ae.addToRenderList(E,re),this.info.render.frame++,Q===!0&&lt.beginShadows();const Ie=w.state.shadowsArray;me.render(Ie,re,Te),Q===!0&&lt.endShadows(),this.info.autoReset===!0&&this.info.reset();const De=E.opaque,je=E.transmissive;if(w.setupLights(),Te.isArrayCamera){const ct=Te.cameras;if(je.length>0)for(let yt=0,Ct=ct.length;yt<Ct;yt++){const Nt=ct[yt];Zt(De,je,re,Nt)}at&&ae.render(re);for(let yt=0,Ct=ct.length;yt<Ct;yt++){const Nt=ct[yt];mt(E,re,Nt,Nt.viewport)}}else je.length>0&&Zt(De,je,re,Te),at&&ae.render(re),mt(E,re,Te);j!==null&&k===0&&(Se.updateMultisampleRenderTarget(j),Se.updateRenderTargetMipmap(j)),re.isScene===!0&&re.onAfterRender(C,re,Te),ge.resetDefaultState(),z=-1,I=null,T.pop(),T.length>0?(w=T[T.length-1],Q===!0&&lt.setGlobalState(C.clippingPlanes,w.state.camera)):w=null,A.pop(),A.length>0?E=A[A.length-1]:E=null};function an(re,Te,Ie,De){if(re.visible===!1)return;if(re.layers.test(Te.layers)){if(re.isGroup)Ie=re.renderOrder;else if(re.isLOD)re.autoUpdate===!0&&re.update(Te);else if(re.isLight)w.pushLight(re),re.castShadow&&w.pushShadow(re);else if(re.isSprite){if(!re.frustumCulled||pe.intersectsSprite(re)){De&&Ae.setFromMatrixPosition(re.matrixWorld).applyMatrix4(he);const yt=Me.update(re),Ct=re.material;Ct.visible&&E.push(re,yt,Ct,Ie,Ae.z,null)}}else if((re.isMesh||re.isLine||re.isPoints)&&(!re.frustumCulled||pe.intersectsObject(re))){const yt=Me.update(re),Ct=re.material;if(De&&(re.boundingSphere!==void 0?(re.boundingSphere===null&&re.computeBoundingSphere(),Ae.copy(re.boundingSphere.center)):(yt.boundingSphere===null&&yt.computeBoundingSphere(),Ae.copy(yt.boundingSphere.center)),Ae.applyMatrix4(re.matrixWorld).applyMatrix4(he)),Array.isArray(Ct)){const Nt=yt.groups;for(let Ut=0,jt=Nt.length;Ut<jt;Ut++){const St=Nt[Ut],tn=Ct[St.materialIndex];tn&&tn.visible&&E.push(re,yt,tn,Ie,Ae.z,St)}}else Ct.visible&&E.push(re,yt,Ct,Ie,Ae.z,null)}}const ct=re.children;for(let yt=0,Ct=ct.length;yt<Ct;yt++)an(ct[yt],Te,Ie,De)}function mt(re,Te,Ie,De){const{opaque:je,transmissive:ct,transparent:yt}=re;w.setupLightsView(Ie),Q===!0&&lt.setGlobalState(C.clippingPlanes,Ie),De&&se.viewport(q.copy(De)),je.length>0&&sn(je,Te,Ie),ct.length>0&&sn(ct,Te,Ie),yt.length>0&&sn(yt,Te,Ie),se.buffers.depth.setTest(!0),se.buffers.depth.setMask(!0),se.buffers.color.setMask(!0),se.setPolygonOffset(!1)}function Zt(re,Te,Ie,De){if((Ie.isScene===!0?Ie.overrideMaterial:null)!==null)return;w.state.transmissionRenderTarget[De.id]===void 0&&(w.state.transmissionRenderTarget[De.id]=new gf(1,1,{generateMipmaps:!0,type:H.has("EXT_color_buffer_half_float")||H.has("EXT_color_buffer_float")?yg:Al,minFilter:Ph,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:zn.workingColorSpace}));const ct=w.state.transmissionRenderTarget[De.id],yt=De.viewport||q;ct.setSize(yt.z*C.transmissionResolutionScale,yt.w*C.transmissionResolutionScale);const Ct=C.getRenderTarget(),Nt=C.getActiveCubeFace(),Ut=C.getActiveMipmapLevel();C.setRenderTarget(ct),C.getClearColor(K),G=C.getClearAlpha(),G<1&&C.setClearColor(16777215,.5),C.clear(),at&&ae.render(Ie);const jt=C.toneMapping;C.toneMapping=ud;const St=De.viewport;if(De.viewport!==void 0&&(De.viewport=void 0),w.setupLightsView(De),Q===!0&&lt.setGlobalState(C.clippingPlanes,De),sn(re,Ie,De),Se.updateMultisampleRenderTarget(ct),Se.updateRenderTargetMipmap(ct),H.has("WEBGL_multisampled_render_to_texture")===!1){let tn=!1;for(let $t=0,mn=Te.length;$t<mn;$t++){const Sn=Te[$t],{object:kn,geometry:Bt,material:on,group:cn}=Sn;if(on.side===dl&&kn.layers.test(De.layers)){const Ur=on.side;on.side=ns,on.needsUpdate=!0,Yt(kn,Ie,De,Bt,on,cn),on.side=Ur,on.needsUpdate=!0,tn=!0}}tn===!0&&(Se.updateMultisampleRenderTarget(ct),Se.updateRenderTargetMipmap(ct))}C.setRenderTarget(Ct,Nt,Ut),C.setClearColor(K,G),St!==void 0&&(De.viewport=St),C.toneMapping=jt}function sn(re,Te,Ie){const De=Te.isScene===!0?Te.overrideMaterial:null;for(let je=0,ct=re.length;je<ct;je++){const yt=re[je],{object:Ct,geometry:Nt,group:Ut}=yt;let jt=yt.material;jt.allowOverride===!0&&De!==null&&(jt=De),Ct.layers.test(Ie.layers)&&Yt(Ct,Te,Ie,Nt,jt,Ut)}}function Yt(re,Te,Ie,De,je,ct){re.onBeforeRender(C,Te,Ie,De,je,ct),re.modelViewMatrix.multiplyMatrices(Ie.matrixWorldInverse,re.matrixWorld),re.normalMatrix.getNormalMatrix(re.modelViewMatrix),je.onBeforeRender(C,Te,Ie,De,re,ct),je.transparent===!0&&je.side===dl&&je.forceSinglePass===!1?(je.side=ns,je.needsUpdate=!0,C.renderBufferDirect(Ie,Te,De,je,re,ct),je.side=Td,je.needsUpdate=!0,C.renderBufferDirect(Ie,Te,De,je,re,ct),je.side=dl):C.renderBufferDirect(Ie,Te,De,je,re,ct),re.onAfterRender(C,Te,Ie,De,je,ct)}function _n(re,Te,Ie){Te.isScene!==!0&&(Te=fe);const De=Ne.get(re),je=w.state.lights,ct=w.state.shadowsArray,yt=je.state.version,Ct=be.getParameters(re,je.state,ct,Te,Ie),Nt=be.getProgramCacheKey(Ct);let Ut=De.programs;De.environment=re.isMeshStandardMaterial?Te.environment:null,De.fog=Te.fog,De.envMap=(re.isMeshStandardMaterial?L:U).get(re.envMap||De.environment),De.envMapRotation=De.environment!==null&&re.envMap===null?Te.environmentRotation:re.envMapRotation,Ut===void 0&&(re.addEventListener("dispose",ft),Ut=new Map,De.programs=Ut);let jt=Ut.get(Nt);if(jt!==void 0){if(De.currentProgram===jt&&De.lightsStateVersion===yt)return Ce(re,Ct),jt}else Ct.uniforms=be.getUniforms(re),re.onBeforeCompile(Ct,C),jt=be.acquireProgram(Ct,Nt),Ut.set(Nt,jt),De.uniforms=Ct.uniforms;const St=De.uniforms;return(!re.isShaderMaterial&&!re.isRawShaderMaterial||re.clipping===!0)&&(St.clippingPlanes=lt.uniform),Ce(re,Ct),De.needsLights=Xe(re),De.lightsStateVersion=yt,De.needsLights&&(St.ambientLightColor.value=je.state.ambient,St.lightProbe.value=je.state.probe,St.directionalLights.value=je.state.directional,St.directionalLightShadows.value=je.state.directionalShadow,St.spotLights.value=je.state.spot,St.spotLightShadows.value=je.state.spotShadow,St.rectAreaLights.value=je.state.rectArea,St.ltc_1.value=je.state.rectAreaLTC1,St.ltc_2.value=je.state.rectAreaLTC2,St.pointLights.value=je.state.point,St.pointLightShadows.value=je.state.pointShadow,St.hemisphereLights.value=je.state.hemi,St.directionalShadowMap.value=je.state.directionalShadowMap,St.directionalShadowMatrix.value=je.state.directionalShadowMatrix,St.spotShadowMap.value=je.state.spotShadowMap,St.spotLightMatrix.value=je.state.spotLightMatrix,St.spotLightMap.value=je.state.spotLightMap,St.pointShadowMap.value=je.state.pointShadowMap,St.pointShadowMatrix.value=je.state.pointShadowMatrix),De.currentProgram=jt,De.uniformsList=null,jt}function wn(re){if(re.uniformsList===null){const Te=re.currentProgram.getUniforms();re.uniformsList=k1.seqWithValue(Te.seq,re.uniforms)}return re.uniformsList}function Ce(re,Te){const Ie=Ne.get(re);Ie.outputColorSpace=Te.outputColorSpace,Ie.batching=Te.batching,Ie.batchingColor=Te.batchingColor,Ie.instancing=Te.instancing,Ie.instancingColor=Te.instancingColor,Ie.instancingMorph=Te.instancingMorph,Ie.skinning=Te.skinning,Ie.morphTargets=Te.morphTargets,Ie.morphNormals=Te.morphNormals,Ie.morphColors=Te.morphColors,Ie.morphTargetsCount=Te.morphTargetsCount,Ie.numClippingPlanes=Te.numClippingPlanes,Ie.numIntersection=Te.numClipIntersection,Ie.vertexAlphas=Te.vertexAlphas,Ie.vertexTangents=Te.vertexTangents,Ie.toneMapping=Te.toneMapping}function ce(re,Te,Ie,De,je){Te.isScene!==!0&&(Te=fe),Se.resetTextureUnits();const ct=Te.fog,yt=De.isMeshStandardMaterial?Te.environment:null,Ct=j===null?C.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:Bp,Nt=(De.isMeshStandardMaterial?L:U).get(De.envMap||yt),Ut=De.vertexColors===!0&&!!Ie.attributes.color&&Ie.attributes.color.itemSize===4,jt=!!Ie.attributes.tangent&&(!!De.normalMap||De.anisotropy>0),St=!!Ie.morphAttributes.position,tn=!!Ie.morphAttributes.normal,$t=!!Ie.morphAttributes.color;let mn=ud;De.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(mn=C.toneMapping);const Sn=Ie.morphAttributes.position||Ie.morphAttributes.normal||Ie.morphAttributes.color,kn=Sn!==void 0?Sn.length:0,Bt=Ne.get(De),on=w.state.lights;if(Q===!0&&(Ee===!0||re!==I)){const Ri=re===I&&De.id===z;lt.setState(De,re,Ri)}let cn=!1;De.version===Bt.__version?(Bt.needsLights&&Bt.lightsStateVersion!==on.state.version||Bt.outputColorSpace!==Ct||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!==Nt||De.fog===!0&&Bt.fog!==ct||Bt.numClippingPlanes!==void 0&&(Bt.numClippingPlanes!==lt.numPlanes||Bt.numIntersection!==lt.numIntersection)||Bt.vertexAlphas!==Ut||Bt.vertexTangents!==jt||Bt.morphTargets!==St||Bt.morphNormals!==tn||Bt.morphColors!==$t||Bt.toneMapping!==mn||Bt.morphTargetsCount!==kn)&&(cn=!0):(cn=!0,Bt.__version=De.version);let Ur=Bt.currentProgram;cn===!0&&(Ur=_n(De,Te,je));let qr=!1,Gn=!1,wo=!1;const Kn=Ur.getUniforms(),ji=Bt.uniforms;if(se.useProgram(Ur.program)&&(qr=!0,Gn=!0,wo=!0),De.id!==z&&(z=De.id,Gn=!0),qr||I!==re){se.buffers.depth.getReversed()&&re.reversedDepth!==!0&&(re._reversedDepth=!0,re.updateProjectionMatrix()),Kn.setValue($,"projectionMatrix",re.projectionMatrix),Kn.setValue($,"viewMatrix",re.matrixWorldInverse);const Xi=Kn.map.cameraPosition;Xi!==void 0&&Xi.setValue($,ue.setFromMatrixPosition(re.matrixWorld)),Y.logarithmicDepthBuffer&&Kn.setValue($,"logDepthBufFC",2/(Math.log(re.far+1)/Math.LN2)),(De.isMeshPhongMaterial||De.isMeshToonMaterial||De.isMeshLambertMaterial||De.isMeshBasicMaterial||De.isMeshStandardMaterial||De.isShaderMaterial)&&Kn.setValue($,"isOrthographic",re.isOrthographicCamera===!0),I!==re&&(I=re,Gn=!0,wo=!0)}if(je.isSkinnedMesh){Kn.setOptional($,je,"bindMatrix"),Kn.setOptional($,je,"bindMatrixInverse");const Ri=je.skeleton;Ri&&(Ri.boneTexture===null&&Ri.computeBoneTexture(),Kn.setValue($,"boneTexture",Ri.boneTexture,Se))}je.isBatchedMesh&&(Kn.setOptional($,je,"batchingTexture"),Kn.setValue($,"batchingTexture",je._matricesTexture,Se),Kn.setOptional($,je,"batchingIdTexture"),Kn.setValue($,"batchingIdTexture",je._indirectTexture,Se),Kn.setOptional($,je,"batchingColorTexture"),je._colorsTexture!==null&&Kn.setValue($,"batchingColorTexture",je._colorsTexture,Se));const gi=Ie.morphAttributes;if((gi.position!==void 0||gi.normal!==void 0||gi.color!==void 0)&&He.update(je,Ie,Ur),(Gn||Bt.receiveShadow!==je.receiveShadow)&&(Bt.receiveShadow=je.receiveShadow,Kn.setValue($,"receiveShadow",je.receiveShadow)),De.isMeshGouraudMaterial&&De.envMap!==null&&(ji.envMap.value=Nt,ji.flipEnvMap.value=Nt.isCubeTexture&&Nt.isRenderTargetTexture===!1?-1:1),De.isMeshStandardMaterial&&De.envMap===null&&Te.environment!==null&&(ji.envMapIntensity.value=Te.environmentIntensity),ji.dfgLUT!==void 0&&(ji.dfgLUT.value=UDe()),Gn&&(Kn.setValue($,"toneMappingExposure",C.toneMappingExposure),Bt.needsLights&&Ue(ji,wo),ct&&De.fog===!0&&qe.refreshFogUniforms(ji,ct),qe.refreshMaterialUniforms(ji,De,Z,ee,w.state.transmissionRenderTarget[re.id]),k1.upload($,wn(Bt),ji,Se)),De.isShaderMaterial&&De.uniformsNeedUpdate===!0&&(k1.upload($,wn(Bt),ji,Se),De.uniformsNeedUpdate=!1),De.isSpriteMaterial&&Kn.setValue($,"center",je.center),Kn.setValue($,"modelViewMatrix",je.modelViewMatrix),Kn.setValue($,"normalMatrix",je.normalMatrix),Kn.setValue($,"modelMatrix",je.matrixWorld),De.isShaderMaterial||De.isRawShaderMaterial){const Ri=De.uniformsGroups;for(let Xi=0,Zo=Ri.length;Xi<Zo;Xi++){const Il=Ri[Xi];nt.update(Il,Ur),nt.bind(Il,Ur)}}return Ur}function Ue(re,Te){re.ambientLightColor.needsUpdate=Te,re.lightProbe.needsUpdate=Te,re.directionalLights.needsUpdate=Te,re.directionalLightShadows.needsUpdate=Te,re.pointLights.needsUpdate=Te,re.pointLightShadows.needsUpdate=Te,re.spotLights.needsUpdate=Te,re.spotLightShadows.needsUpdate=Te,re.rectAreaLights.needsUpdate=Te,re.hemisphereLights.needsUpdate=Te}function Xe(re){return re.isMeshLambertMaterial||re.isMeshToonMaterial||re.isMeshPhongMaterial||re.isMeshStandardMaterial||re.isShadowMaterial||re.isShaderMaterial&&re.lights===!0}this.getActiveCubeFace=function(){return O},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return j},this.setRenderTargetTextures=function(re,Te,Ie){const De=Ne.get(re);De.__autoAllocateDepthBuffer=re.resolveDepthBuffer===!1,De.__autoAllocateDepthBuffer===!1&&(De.__useRenderToTexture=!1),Ne.get(re.texture).__webglTexture=Te,Ne.get(re.depthTexture).__webglTexture=De.__autoAllocateDepthBuffer?void 0:Ie,De.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(re,Te){const Ie=Ne.get(re);Ie.__webglFramebuffer=Te,Ie.__useDefaultFramebuffer=Te===void 0};const rt=$.createFramebuffer();this.setRenderTarget=function(re,Te=0,Ie=0){j=re,O=Te,k=Ie;let De=!0,je=null,ct=!1,yt=!1;if(re){const Nt=Ne.get(re);if(Nt.__useDefaultFramebuffer!==void 0)se.bindFramebuffer($.FRAMEBUFFER,null),De=!1;else if(Nt.__webglFramebuffer===void 0)Se.setupRenderTarget(re);else if(Nt.__hasExternalTextures)Se.rebindTextures(re,Ne.get(re.texture).__webglTexture,Ne.get(re.depthTexture).__webglTexture);else if(re.depthBuffer){const St=re.depthTexture;if(Nt.__boundDepthTexture!==St){if(St!==null&&Ne.has(St)&&(re.width!==St.image.width||re.height!==St.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Se.setupDepthRenderbuffer(re)}}const Ut=re.texture;(Ut.isData3DTexture||Ut.isDataArrayTexture||Ut.isCompressedArrayTexture)&&(yt=!0);const jt=Ne.get(re).__webglFramebuffer;re.isWebGLCubeRenderTarget?(Array.isArray(jt[Te])?je=jt[Te][Ie]:je=jt[Te],ct=!0):re.samples>0&&Se.useMultisampledRTT(re)===!1?je=Ne.get(re).__webglMultisampledFramebuffer:Array.isArray(jt)?je=jt[Ie]:je=jt,q.copy(re.viewport),R.copy(re.scissor),W=re.scissorTest}else q.copy(ne).multiplyScalar(Z).floor(),R.copy(le).multiplyScalar(Z).floor(),W=oe;if(Ie!==0&&(je=rt),se.bindFramebuffer($.FRAMEBUFFER,je)&&De&&se.drawBuffers(re,je),se.viewport(q),se.scissor(R),se.setScissorTest(W),ct){const Nt=Ne.get(re.texture);$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_CUBE_MAP_POSITIVE_X+Te,Nt.__webglTexture,Ie)}else if(yt){const Nt=Te;for(let Ut=0;Ut<re.textures.length;Ut++){const jt=Ne.get(re.textures[Ut]);$.framebufferTextureLayer($.FRAMEBUFFER,$.COLOR_ATTACHMENT0+Ut,jt.__webglTexture,Ie,Nt)}}else if(re!==null&&Ie!==0){const Nt=Ne.get(re.texture);$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,Nt.__webglTexture,Ie)}z=-1},this.readRenderTargetPixels=function(re,Te,Ie,De,je,ct,yt,Ct=0){if(!(re&&re.isWebGLRenderTarget)){Qr("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Nt=Ne.get(re).__webglFramebuffer;if(re.isWebGLCubeRenderTarget&&yt!==void 0&&(Nt=Nt[yt]),Nt){se.bindFramebuffer($.FRAMEBUFFER,Nt);try{const Ut=re.textures[Ct],jt=Ut.format,St=Ut.type;if(!Y.textureFormatReadable(jt)){Qr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Y.textureTypeReadable(St)){Qr("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Te>=0&&Te<=re.width-De&&Ie>=0&&Ie<=re.height-je&&(re.textures.length>1&&$.readBuffer($.COLOR_ATTACHMENT0+Ct),$.readPixels(Te,Ie,De,je,ot.convert(jt),ot.convert(St),ct))}finally{const Ut=j!==null?Ne.get(j).__webglFramebuffer:null;se.bindFramebuffer($.FRAMEBUFFER,Ut)}}},this.readRenderTargetPixelsAsync=async function(re,Te,Ie,De,je,ct,yt,Ct=0){if(!(re&&re.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Nt=Ne.get(re).__webglFramebuffer;if(re.isWebGLCubeRenderTarget&&yt!==void 0&&(Nt=Nt[yt]),Nt)if(Te>=0&&Te<=re.width-De&&Ie>=0&&Ie<=re.height-je){se.bindFramebuffer($.FRAMEBUFFER,Nt);const Ut=re.textures[Ct],jt=Ut.format,St=Ut.type;if(!Y.textureFormatReadable(jt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Y.textureTypeReadable(St))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const tn=$.createBuffer();$.bindBuffer($.PIXEL_PACK_BUFFER,tn),$.bufferData($.PIXEL_PACK_BUFFER,ct.byteLength,$.STREAM_READ),re.textures.length>1&&$.readBuffer($.COLOR_ATTACHMENT0+Ct),$.readPixels(Te,Ie,De,je,ot.convert(jt),ot.convert(St),0);const $t=j!==null?Ne.get(j).__webglFramebuffer:null;se.bindFramebuffer($.FRAMEBUFFER,$t);const mn=$.fenceSync($.SYNC_GPU_COMMANDS_COMPLETE,0);return $.flush(),await dke($,mn,4),$.bindBuffer($.PIXEL_PACK_BUFFER,tn),$.getBufferSubData($.PIXEL_PACK_BUFFER,0,ct),$.deleteBuffer(tn),$.deleteSync(mn),ct}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(re,Te=null,Ie=0){const De=Math.pow(2,-Ie),je=Math.floor(re.image.width*De),ct=Math.floor(re.image.height*De),yt=Te!==null?Te.x:0,Ct=Te!==null?Te.y:0;Se.setTexture2D(re,0),$.copyTexSubImage2D($.TEXTURE_2D,Ie,0,0,yt,Ct,je,ct),se.unbindTexture()};const et=$.createFramebuffer(),gt=$.createFramebuffer();this.copyTextureToTexture=function(re,Te,Ie=null,De=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 yt,Ct,Nt,Ut,jt,St,tn,$t,mn;const Sn=re.isCompressedTexture?re.mipmaps[ct]:re.image;if(Ie!==null)yt=Ie.max.x-Ie.min.x,Ct=Ie.max.y-Ie.min.y,Nt=Ie.isBox3?Ie.max.z-Ie.min.z:1,Ut=Ie.min.x,jt=Ie.min.y,St=Ie.isBox3?Ie.min.z:0;else{const gi=Math.pow(2,-je);yt=Math.floor(Sn.width*gi),Ct=Math.floor(Sn.height*gi),re.isDataArrayTexture?Nt=Sn.depth:re.isData3DTexture?Nt=Math.floor(Sn.depth*gi):Nt=1,Ut=0,jt=0,St=0}De!==null?(tn=De.x,$t=De.y,mn=De.z):(tn=0,$t=0,mn=0);const kn=ot.convert(Te.format),Bt=ot.convert(Te.type);let on;Te.isData3DTexture?(Se.setTexture3D(Te,0),on=$.TEXTURE_3D):Te.isDataArrayTexture||Te.isCompressedArrayTexture?(Se.setTexture2DArray(Te,0),on=$.TEXTURE_2D_ARRAY):(Se.setTexture2D(Te,0),on=$.TEXTURE_2D),$.pixelStorei($.UNPACK_FLIP_Y_WEBGL,Te.flipY),$.pixelStorei($.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Te.premultiplyAlpha),$.pixelStorei($.UNPACK_ALIGNMENT,Te.unpackAlignment);const cn=$.getParameter($.UNPACK_ROW_LENGTH),Ur=$.getParameter($.UNPACK_IMAGE_HEIGHT),qr=$.getParameter($.UNPACK_SKIP_PIXELS),Gn=$.getParameter($.UNPACK_SKIP_ROWS),wo=$.getParameter($.UNPACK_SKIP_IMAGES);$.pixelStorei($.UNPACK_ROW_LENGTH,Sn.width),$.pixelStorei($.UNPACK_IMAGE_HEIGHT,Sn.height),$.pixelStorei($.UNPACK_SKIP_PIXELS,Ut),$.pixelStorei($.UNPACK_SKIP_ROWS,jt),$.pixelStorei($.UNPACK_SKIP_IMAGES,St);const Kn=re.isDataArrayTexture||re.isData3DTexture,ji=Te.isDataArrayTexture||Te.isData3DTexture;if(re.isDepthTexture){const gi=Ne.get(re),Ri=Ne.get(Te),Xi=Ne.get(gi.__renderTarget),Zo=Ne.get(Ri.__renderTarget);se.bindFramebuffer($.READ_FRAMEBUFFER,Xi.__webglFramebuffer),se.bindFramebuffer($.DRAW_FRAMEBUFFER,Zo.__webglFramebuffer);for(let Il=0;Il<Nt;Il++)Kn&&($.framebufferTextureLayer($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,Ne.get(re).__webglTexture,je,St+Il),$.framebufferTextureLayer($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,Ne.get(Te).__webglTexture,ct,mn+Il)),$.blitFramebuffer(Ut,jt,yt,Ct,tn,$t,yt,Ct,$.DEPTH_BUFFER_BIT,$.NEAREST);se.bindFramebuffer($.READ_FRAMEBUFFER,null),se.bindFramebuffer($.DRAW_FRAMEBUFFER,null)}else if(je!==0||re.isRenderTargetTexture||Ne.has(re)){const gi=Ne.get(re),Ri=Ne.get(Te);se.bindFramebuffer($.READ_FRAMEBUFFER,et),se.bindFramebuffer($.DRAW_FRAMEBUFFER,gt);for(let Xi=0;Xi<Nt;Xi++)Kn?$.framebufferTextureLayer($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,gi.__webglTexture,je,St+Xi):$.framebufferTexture2D($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,gi.__webglTexture,je),ji?$.framebufferTextureLayer($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,Ri.__webglTexture,ct,mn+Xi):$.framebufferTexture2D($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,Ri.__webglTexture,ct),je!==0?$.blitFramebuffer(Ut,jt,yt,Ct,tn,$t,yt,Ct,$.COLOR_BUFFER_BIT,$.NEAREST):ji?$.copyTexSubImage3D(on,ct,tn,$t,mn+Xi,Ut,jt,yt,Ct):$.copyTexSubImage2D(on,ct,tn,$t,Ut,jt,yt,Ct);se.bindFramebuffer($.READ_FRAMEBUFFER,null),se.bindFramebuffer($.DRAW_FRAMEBUFFER,null)}else ji?re.isDataTexture||re.isData3DTexture?$.texSubImage3D(on,ct,tn,$t,mn,yt,Ct,Nt,kn,Bt,Sn.data):Te.isCompressedArrayTexture?$.compressedTexSubImage3D(on,ct,tn,$t,mn,yt,Ct,Nt,kn,Sn.data):$.texSubImage3D(on,ct,tn,$t,mn,yt,Ct,Nt,kn,Bt,Sn):re.isDataTexture?$.texSubImage2D($.TEXTURE_2D,ct,tn,$t,yt,Ct,kn,Bt,Sn.data):re.isCompressedTexture?$.compressedTexSubImage2D($.TEXTURE_2D,ct,tn,$t,Sn.width,Sn.height,kn,Sn.data):$.texSubImage2D($.TEXTURE_2D,ct,tn,$t,yt,Ct,kn,Bt,Sn);$.pixelStorei($.UNPACK_ROW_LENGTH,cn),$.pixelStorei($.UNPACK_IMAGE_HEIGHT,Ur),$.pixelStorei($.UNPACK_SKIP_PIXELS,qr),$.pixelStorei($.UNPACK_SKIP_ROWS,Gn),$.pixelStorei($.UNPACK_SKIP_IMAGES,wo),ct===0&&Te.generateMipmaps&&$.generateMipmap(on),se.unbindTexture()},this.initRenderTarget=function(re){Ne.get(re).__webglFramebuffer===void 0&&Se.setupRenderTarget(re)},this.initTexture=function(re){re.isCubeTexture?Se.setTextureCube(re,0):re.isData3DTexture?Se.setTexture3D(re,0):re.isDataArrayTexture||re.isCompressedArrayTexture?Se.setTexture2DArray(re,0):Se.setTexture2D(re,0),se.unbindTexture()},this.resetState=function(){O=0,k=0,j=null,se.reset(),ge.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=zn._getDrawingBufferColorSpace(e),n.unpackColorSpace=zn._getUnpackColorSpace()}};const b$={type:"change"},BO={type:"start"},iQ={type:"end"},g_=new LO,y$=new Gu,BDe=Math.cos(70*fke.DEG2RAD),bi=new it,Ya=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},hC=1e-6;class HDe extends Jke{constructor(e,n=null){super(e,n),this.state=lr.NONE,this.target=new it,this.cursor=new it,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 it,this._lastQuaternion=new pf,this._lastTargetPosition=new it,this._quat=new pf().setFromUnitVectors(e.up,new it(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new qH,this._sphericalDelta=new qH,this._scale=1,this._panOffset=new it,this._rotateStart=new bn,this._rotateEnd=new bn,this._rotateDelta=new bn,this._panStart=new bn,this._panEnd=new bn,this._panDelta=new bn,this._dollyStart=new bn,this._dollyEnd=new bn,this._dollyDelta=new bn,this._dollyDirection=new it,this._mouse=new bn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=VDe.bind(this),this._onPointerDown=$De.bind(this),this._onPointerUp=GDe.bind(this),this._onContextMenu=QDe.bind(this),this._onMouseWheel=KDe.bind(this),this._onKeyDown=XDe.bind(this),this._onTouchStart=YDe.bind(this),this._onTouchMove=ZDe.bind(this),this._onMouseDown=WDe.bind(this),this._onMouseMove=qDe.bind(this),this._interceptControlDown=JDe.bind(this),this._interceptControlUp=eOe.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(b$),this.update(),this.state=lr.NONE}update(e=null){const n=this.object.position;bi.copy(n).sub(this.target),bi.applyQuaternion(this._quat),this._spherical.setFromVector3(bi),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+=Ya:r>Math.PI&&(r-=Ya),i<-Math.PI?i+=Ya:i>Math.PI&&(i-=Ya),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(bi.setFromSpherical(this._spherical),bi.applyQuaternion(this._quatInverse),n.copy(this.target).add(bi),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=bi.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 it(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 it(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),s=bi.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))<BDe?this.object.lookAt(this.target):(y$.setFromNormalAndCoplanarPoint(this.object.up,this.target),g_.intersectPlane(y$,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)>hC||8*(1-this._lastQuaternion.dot(this.object.quaternion))>hC||this._lastTargetPosition.distanceToSquared(this.target)>hC?(this.dispatchEvent(b$),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ya/60*this.autoRotateSpeed*e:Ya/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){bi.setFromMatrixColumn(n,0),bi.multiplyScalar(-e),this._panOffset.add(bi)}_panUp(e,n){this.screenSpacePanning===!0?bi.setFromMatrixColumn(n,1):(bi.setFromMatrixColumn(n,0),bi.crossVectors(this.object.up,bi)),bi.multiplyScalar(e),this._panOffset.add(bi)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;bi.copy(i).sub(this.target);let a=bi.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(Ya*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ya*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(Ya*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(-Ya*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(Ya*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(-Ya*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(Ya*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ya*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 bn,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 $De(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 VDe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function GDe(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(iQ),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 WDe(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(BO)}function qDe(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 KDe(t){this.enabled===!1||this.enableZoom===!1||this.state!==lr.NONE||(t.preventDefault(),this.dispatchEvent(BO),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(iQ))}function XDe(t){this.enabled!==!1&&this._handleKeyDown(t)}function YDe(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(BO)}function ZDe(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 QDe(t){this.enabled!==!1&&t.preventDefault()}function JDe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function eOe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function tOe(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 b=0;b<p.count;++b)f.push(p.getX(b)+d);d+=t[g].attributes.position.count}c.setIndex(f)}for(const d in a){const f=v$(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 b=v$(p);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(b)}}return c}function v$(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 ho(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 b=0;b<n;b++){const v=d.getComponent(g,b);l.setComponent(g+f,b,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 fC={exports:{}};var _$;function nOe(){return _$||(_$=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(b){var v=r[u][1][b];return s(v||b)},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,b,v,x=[],y=0,E=c.length,w=E,A=a.getTypeOf(c)!=="string";y<c.length;)w=E-y,f=A?(u=c[y++],d=y<E?c[y++]:0,y<E?c[y++]:0):(u=c.charCodeAt(y++),d=y<E?c.charCodeAt(y++):0,y<E?c.charCodeAt(y++):0),g=u>>2,p=(3&u)<<4|d>>4,b=1<w?(15&d)<<2|f>>6:64,v=2<w?63&f:64,x.push(l.charAt(g)+l.charAt(p)+l.charAt(b)+l.charAt(v));return x.join("")},i.decode=function(c){var u,d,f,g,p,b,v=0,x=0,y="data:";if(c.substr(0,y.length)===y)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|(b=l.indexOf(c.charAt(v++))),E[x++]=u,p!==64&&(E[x++]=d),b!==64&&(E[x++]=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,b){this.compressedSize=d,this.uncompressedSize=f,this.crc32=g,this.compression=p,this.compressedContent=b}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,b=g+f;u^=-1;for(var v=g;v<b;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,b=g+f;u^=-1;for(var v=g;v<b;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,b){var v,x="";for(v=0;v<b;v++)x+=String.fromCharCode(255&p),p>>>=8;return x}function s(p,b,v,x,y,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,z=l.transformTo("string",E(j)),I=l.transformTo("string",u.utf8encode(j)),q=k.length!==T.name.length,R=I.length!==j.length,W="",K="",G="",J=T.dir,ee=T.date,Z={crc32:0,compressedSize:0,uncompressedSize:0};b&&!v||(Z.crc32=p.crc32,Z.compressedSize=p.compressedSize,Z.uncompressedSize=p.uncompressedSize);var F=0;b&&(F|=8),N||!q&&!R||(F|=2048);var V=0,ne=0;J&&(V|=16),y==="UNIX"?(ne=798,V|=(function(oe,pe){var Q=oe;return oe||(Q=pe?16893:33204),(65535&Q)<<16})(T.unixPermissions,J)):(ne=20,V|=(function(oe){return 63&(oe||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(),q&&(K=a(1,1)+a(d(O),4)+k,W+="up"+a(K.length,2)+K),R&&(G=a(1,1)+a(d(z),4)+I,W+="uc"+a(G.length,2)+G);var le="";return le+=`
  3919. \0`,le+=a(F,2),le+=C.magic,le+=a(w,2),le+=a(A,2),le+=a(Z.crc32,4),le+=a(Z.compressedSize,4),le+=a(Z.uncompressedSize,4),le+=a(O.length,2),le+=a(W.length,2),{fileRecord:f.LOCAL_FILE_HEADER+le+O+W,dirRecord:f.CENTRAL_FILE_HEADER+a(ne,2)+le+a(z.length,2)+"\0\0\0\0"+a(V,4)+a(x,4)+O+W+z}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function g(p,b,v,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=v,this.encodeFileName=x,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 b=p.meta.percent||0,v=this.entriesCount,x=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?(b+100*(v-x-1))/v:100}}))},g.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var b=this.streamFiles&&!p.file.dir;if(b){var v=s(p,b,!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 b=this.streamFiles&&!p.file.dir,v=s(p,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(v.dirRecord),b)this.push({data:(function(x){return f.DATA_DESCRIPTOR+a(x.crc32,4)+a(x.compressedSize,4)+a(x.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,b=0;b<this.dirRecords.length;b++)this.push({data:this.dirRecords[b],meta:{percent:100}});var v=this.bytesWritten-p,x=(function(y,E,w,A,T){var C=l.transformTo("string",T(A));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(y,2)+a(y,2)+a(E,4)+a(w,4)+a(C.length,2)+C})(this.dirRecords.length,v,p,this.zipComment,this.encodeFileName);this.push({data:x,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 b=this;return p.on("data",function(v){b.processChunk(v)}),p.on("end",function(){b.closedSource(b.previous.streamInfo),b._sources.length?b.prepareNextSource():b.end()}),p.on("error",function(v){b.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 b=this._sources;if(!c.prototype.error.call(this,p))return!1;for(var v=0;v<b.length;v++)try{b[v].error(p)}catch{}return!0},g.prototype.lock=function(){c.prototype.lock.call(this);for(var p=this._sources,b=0;b<p.length;b++)p[b].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 b=(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||{},x=p.dir,y=p.date;p._compressWorker(b,v).withStreamInfo("file",{name:g,dir:x,date:y,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,b){var v=g.decompressed.getContentWorker().pipe(new u);v.on("error",function(x){b(x)}).on("end",function(){v.streamInfo.crc32!==g.decompressed.crc32?b(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}r.exports=function(g,p){var b=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 x=new c(p);return x.load(v),x}).then(function(v){var x=[s.Promise.resolve(v)],y=v.files;if(p.checkCRC32)for(var E=0;E<y.length;E++)x.push(f(y[E]));return s.Promise.all(x)}).then(function(v){for(var x=v.shift(),y=x.files,E=0;E<y.length;E++){var w=y[E],A=w.fileNameStr,T=a.resolve(w.fileNameStr);b.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||(b.file(T).unsafeOriginalName=A)}return x.zipComment.length&&(b.comment=x.zipComment),b})}},{"./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=y(T)),j.createFolders&&(O=x(T))&&E.call(this,O,!0);var z=k==="string"&&j.binary===!1&&j.base64===!1;N&&N.binary!==void 0||(j.binary=!z),(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 I=null;I=C instanceof f||C instanceof c?C:b.isNode&&b.isStream(C)?new v(T,C):l.prepareContent(T,C,j.binary,j.optimizedBinaryString,j.base64);var q=new g(T,I,j);this.files[T]=q}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"),b=n("./nodejsUtils"),v=n("./nodejs/NodejsStreamInputAdapter"),x=function(T){T.slice(-1)==="/"&&(T=T.substring(0,T.length-1));var C=T.lastIndexOf("/");return 0<C?T.substring(0,C):""},y=function(T){return T.slice(-1)!=="/"&&(T+="/"),T},E=function(T,C){return C=C!==void 0?C:d.createFolders,T=y(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,z){return!z.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(b,v){return new d.Promise(function(x,y){var E=[],w=b._internalType,A=b._outputType,T=b._mimeType;b.on("data",function(C,N){E.push(C),v&&v(N)}).on("error",function(C){E=[],y(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,z=null,I=0;for(k=0;k<O.length;k++)I+=O[k].length;switch(N){case"string":return O.join("");case"array":return Array.prototype.concat.apply([],O);case"uint8array":for(z=new Uint8Array(I),k=0;k<O.length;k++)z.set(O[k],j),j+=O[k].length;return z;case"nodebuffer":return Buffer.concat(O);default:throw new Error("concat : unsupported type '"+N+"'")}})(w,E),T);x(C)}catch(N){y(N)}E=[]}).resume()})}function p(b,v,x){var y=v;switch(v){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=v,this._mimeType=x,a.checkSupport(y),this._worker=b.pipe(new s(y)),b.lock()}catch(E){this._worker=new l("error"),this._worker.error(E)}}p.prototype={accumulate:function(b){return g(this,b)},on:function(b,v){var x=this;return b==="data"?this._worker.on(b,function(y){v.call(x,y.data,y.meta)}):this._worker.on(b,function(){a.delay(v,arguments,x)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(b){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"},b)}},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(b){var v,x,y,E,w,A=b.length,T=0;for(E=0;E<A;E++)(64512&(x=b.charCodeAt(E)))==55296&&E+1<A&&(64512&(y=b.charCodeAt(E+1)))==56320&&(x=65536+(x-55296<<10)+(y-56320),E++),T+=x<128?1:x<2048?2:x<65536?3:4;for(v=s.uint8array?new Uint8Array(T):new Array(T),E=w=0;w<T;E++)(64512&(x=b.charCodeAt(E)))==55296&&E+1<A&&(64512&(y=b.charCodeAt(E+1)))==56320&&(x=65536+(x-55296<<10)+(y-56320),E++),x<128?v[w++]=x:(x<2048?v[w++]=192|x>>>6:(x<65536?v[w++]=224|x>>>12:(v[w++]=240|x>>>18,v[w++]=128|x>>>12&63),v[w++]=128|x>>>6&63),v[w++]=128|63&x);return v})(p)},i.utf8decode=function(p){return s.nodebuffer?a.transformTo("nodebuffer",p).toString("utf-8"):(function(b){var v,x,y,E,w=b.length,A=new Array(2*w);for(v=x=0;v<w;)if((y=b[v++])<128)A[x++]=y;else if(4<(E=u[y]))A[x++]=65533,v+=E-1;else{for(y&=E===2?31:E===3?15:7;1<E&&v<w;)y=y<<6|63&b[v++],E--;1<E?A[x++]=65533:y<65536?A[x++]=y:(y-=65536,A[x++]=55296|y>>10&1023,A[x++]=56320|1023&y)}return A.length!==x&&(A.subarray?A=A.subarray(0,x):A.length=x),a.applyFromCharCode(A)})(p=a.transformTo(s.uint8array?"uint8array":"array",p))},a.inherits(f,c),f.prototype.processChunk=function(p){var b=a.transformTo(s.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var v=b;(b=new Uint8Array(v.length+this.leftOver.length)).set(this.leftOver,0),b.set(v,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var x=(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})(b),y=b;x!==b.length&&(s.uint8array?(y=b.subarray(0,x),this.leftOver=b.subarray(x,b.length)):(y=b.slice(0,x),this.leftOver=b.slice(x,b.length))),this.push({data:i.utf8decode(y),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,x){for(var y=0;y<v.length;++y)x[y]=255&v.charCodeAt(y);return x}n("setimmediate"),i.newBlob=function(v,x){i.checkSupport("blob");try{return new Blob([v],{type:x})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(v),y.getBlob(x)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(v,x,y){var E=[],w=0,A=v.length;if(A<=y)return String.fromCharCode.apply(null,v);for(;w<A;)x==="array"||x==="nodebuffer"?E.push(String.fromCharCode.apply(null,v.slice(w,Math.min(w+y,A)))):E.push(String.fromCharCode.apply(null,v.subarray(w,Math.min(w+y,A)))),w+=y;return E.join("")},stringifyByChar:function(v){for(var x="",y=0;y<v.length;y++)x+=String.fromCharCode(v[y]);return x},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 x=65536,y=i.getTypeOf(v),E=!0;if(y==="uint8array"?E=f.applyCanBeUsed.uint8array:y==="nodebuffer"&&(E=f.applyCanBeUsed.nodebuffer),E)for(;1<x;)try{return f.stringifyByChunk(v,y,x)}catch{x=Math.floor(x/2)}return f.stringifyByChar(v)}function p(v,x){for(var y=0;y<v.length;y++)x[y]=v[y];return x}i.applyFromCharCode=g;var b={};b.string={string:u,array:function(v){return d(v,new Array(v.length))},arraybuffer:function(v){return b.string.uint8array(v).buffer},uint8array:function(v){return d(v,new Uint8Array(v.length))},nodebuffer:function(v){return d(v,l.allocBuffer(v.length))}},b.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)}},b.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))}},b.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)}},b.nodebuffer={string:g,array:function(v){return p(v,new Array(v.length))},arraybuffer:function(v){return b.nodebuffer.uint8array(v).buffer},uint8array:function(v){return p(v,new Uint8Array(v.length))},nodebuffer:u},i.transformTo=function(v,x){if(x=x||"",!v)return x;i.checkSupport(v);var y=i.getTypeOf(x);return b[y][v](x)},i.resolve=function(v){for(var x=v.split("/"),y=[],E=0;E<x.length;E++){var w=x[E];w==="."||w===""&&E!==0&&E!==x.length-1||(w===".."?y.pop():y.push(w))}return y.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 x,y,E="";for(y=0;y<(v||"").length;y++)E+="\\x"+((x=v.charCodeAt(y))<16?"0":"")+x.toString(16).toUpperCase();return E},i.delay=function(v,x,y){setImmediate(function(){v.apply(y||null,x||[])})},i.inherits=function(v,x){function y(){}y.prototype=x.prototype,v.prototype=new y},i.extend=function(){var v,x,y={};for(v=0;v<arguments.length;v++)for(x in arguments[v])Object.prototype.hasOwnProperty.call(arguments[v],x)&&y[x]===void 0&&(y[x]=arguments[v][x]);return y},i.prepareContent=function(v,x,y,E,w){return c.Promise.resolve(x).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):y&&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 b=this.reader.readString(4)===g;return this.reader.setIndex(p),b},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,b=this.zip64EndOfCentralSize-44;0<b;)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 b=g-p;if(0<b)this.isSignature(g,l.CENTRAL_FILE_HEADER)||(this.reader.zero=b);else if(b<0)throw new Error("Corrupted zip: missing "+Math.abs(b)+" 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,b){this.options=p,this.loadOptions=b}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var b,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((b=(function(x){for(var y in d)if(Object.prototype.hasOwnProperty.call(d,y)&&d[y].magic===x)return d[y];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,b,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 b=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(b),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 b,v,x,y=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<y;)b=p.readInt(2),v=p.readInt(2),x=p.readData(v),this.extraFields[b]={id:b,length:v,value:x};p.setIndex(y)},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 b=this.findExtraFieldUnicodePath();if(b!==null)this.fileNameStr=b;else{var v=s.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(v)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var y=s.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var b=a(p.value);return b.readInt(1)!==1||c(this.fileName)!==b.readInt(4)?null:u.utf8decode(b.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var b=a(p.value);return b.readInt(1)!==1||c(this.fileComment)!==b.readInt(4)?null:u.utf8decode(b.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(b,v,x){this.name=b,this.dir=x.dir,this.date=x.date,this.comment=x.comment,this.unixPermissions=x.unixPermissions,this.dosPermissions=x.dosPermissions,this._data=v,this._dataBinary=x.binary,this.options={compression:x.compression,compressionOptions:x.compressionOptions}}var s=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");a.prototype={internalStream:function(b){var v=null,x="string";try{if(!b)throw new Error("No output type specified.");var y=(x=b.toLowerCase())==="string"||x==="text";x!=="binarystring"&&x!=="text"||(x="string"),v=this._decompressWorker();var E=!this._dataBinary;E&&!y&&(v=v.pipe(new c.Utf8EncodeWorker)),!E&&y&&(v=v.pipe(new c.Utf8DecodeWorker))}catch(w){(v=new d("error")).error(w)}return new s(v,x,"")},async:function(b,v){return this.internalStream(b).accumulate(v)},nodeStream:function(b,v){return this.internalStream(b||"nodebuffer").toNodejsStream(v)},_compressWorker:function(b,v){if(this._data instanceof u&&this._data.compression.magic===b.magic)return this._data.getCompressedWorker();var x=this._decompressWorker();return this._dataBinary||(x=x.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(x,b,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(b),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(){b(),v.onreadystatechange=null,v.parentNode.removeChild(v),v=null},a.document.documentElement.appendChild(v)}:function(){setTimeout(b,0)};else{var g=new a.MessageChannel;g.port1.onmessage=b,s=function(){g.port2.postMessage(0)}}var p=[];function b(){var v,x;l=!0;for(var y=p.length;y;){for(x=p,p=[],v=-1;++v<y;)x[v]();y=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(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,y!==s&&v(this,y)}function g(y,E,w){this.promise=y,typeof E=="function"&&(this.onFulfilled=E,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function p(y,E,w){a(function(){var A;try{A=E(w)}catch(T){return l.reject(y,T)}A===y?l.reject(y,new TypeError("Cannot resolve promise with itself")):l.resolve(y,A)})}function b(y){var E=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof E=="function")return function(){E.apply(y,arguments)}}function v(y,E){var w=!1;function A(N){w||(w=!0,l.reject(y,N))}function T(N){w||(w=!0,l.resolve(y,N))}var C=x(function(){E(T,A)});C.status==="error"&&A(C.value)}function x(y,E){var w={};try{w.value=y(E),w.status="success"}catch(A){w.status="error",w.value=A}return w}(r.exports=f).prototype.finally=function(y){if(typeof y!="function")return this;var E=this.constructor;return this.then(function(w){return E.resolve(y()).then(function(){return w})},function(w){return E.resolve(y()).then(function(){throw w})})},f.prototype.catch=function(y){return this.then(null,y)},f.prototype.then=function(y,E){if(typeof y!="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?y:E,this.outcome):this.queue.push(new g(w,y,E)),w},g.prototype.callFulfilled=function(y){l.resolve(this.promise,y)},g.prototype.otherCallFulfilled=function(y){p(this.promise,this.onFulfilled,y)},g.prototype.callRejected=function(y){l.reject(this.promise,y)},g.prototype.otherCallRejected=function(y){p(this.promise,this.onRejected,y)},l.resolve=function(y,E){var w=x(b,E);if(w.status==="error")return l.reject(y,w.value);var A=w.value;if(A)v(y,A);else{y.state=u,y.outcome=E;for(var T=-1,C=y.queue.length;++T<C;)y.queue[T].callFulfilled(E)}return y},l.reject=function(y,E){y.state=c,y.outcome=E;for(var w=-1,A=y.queue.length;++w<A;)y.queue[w].callRejected(E);return y},f.resolve=function(y){return y instanceof this?y:l.resolve(new this(s),y)},f.reject=function(y){var E=new this(s);return l.reject(E,y)},f.all=function(y){var E=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=y.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(y[N],N);return O;function k(j,z){E.resolve(j).then(function(I){T[z]=I,++C!==w||A||(A=!0,l.resolve(O,T))},function(I){A||(A=!0,l.reject(O,I))})}},f.race=function(y){var E=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=y.length,A=!1;if(!w)return this.resolve([]);for(var T=-1,C=new this(s);++T<w;)N=y[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,b=8;function v(y){if(!(this instanceof v))return new v(y);this.options=s.assign({level:g,method:b,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},y||{});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 x(y,E){var w=new v(E);if(w.push(y,!0),w.err)throw w.msg||c[w.err];return w.result}v.prototype.push=function(y,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 y=="string"?T.input=l.string2buf(y):d.call(y)==="[object ArrayBuffer]"?T.input=new Uint8Array(y):T.input=y,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(y){this.chunks.push(y)},v.prototype.onEnd=function(y){y===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=v,i.deflate=x,i.deflateRaw=function(y,E){return(E=E||{}).raw=!0,x(y,E)},i.gzip=function(y,E){return(E=E||{}).gzip=!0,x(y,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 x=this.options;x.raw&&0<=x.windowBits&&x.windowBits<16&&(x.windowBits=-x.windowBits,x.windowBits===0&&(x.windowBits=-15)),!(0<=x.windowBits&&x.windowBits<16)||v&&v.windowBits||(x.windowBits+=32),15<x.windowBits&&x.windowBits<48&&(15&x.windowBits)==0&&(x.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var y=a.inflateInit2(this.strm,x.windowBits);if(y!==c.Z_OK)throw new Error(u[y]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function b(v,x){var y=new p(x);if(y.push(v,!0),y.err)throw y.msg||u[y.err];return y.result}p.prototype.push=function(v,x){var y,E,w,A,T,C,N=this.strm,O=this.options.chunkSize,k=this.options.dictionary,j=!1;if(this.ended)return!1;E=x===~~x?x:x===!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),(y=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,y=a.inflateSetDictionary(this.strm,C)),y===c.Z_BUF_ERROR&&j===!0&&(y=c.Z_OK,j=!1),y!==c.Z_STREAM_END&&y!==c.Z_OK)return this.onEnd(y),!(this.ended=!0);N.next_out&&(N.avail_out!==0&&y!==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)&&y!==c.Z_STREAM_END);return y===c.Z_STREAM_END&&(E=c.Z_FINISH),E===c.Z_FINISH?(y=a.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===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=b,i.inflateRaw=function(v,x){return(x=x||{}).raw=!0,b(v,x)},i.ungzip=b},{"./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,b;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(b=new Uint8Array(f),u=g=0,d=c.length;u<d;u++)p=c[u],b.set(p,g),g+=p.length;return b}},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="",b=0;b<g;b++)p+=String.fromCharCode(f[b]);return p}c[254]=c[254]=1,i.string2buf=function(f){var g,p,b,v,x,y=f.length,E=0;for(v=0;v<y;v++)(64512&(p=f.charCodeAt(v)))==55296&&v+1<y&&(64512&(b=f.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(b-56320),v++),E+=p<128?1:p<2048?2:p<65536?3:4;for(g=new a.Buf8(E),v=x=0;x<E;v++)(64512&(p=f.charCodeAt(v)))==55296&&v+1<y&&(64512&(b=f.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(b-56320),v++),p<128?g[x++]=p:(p<2048?g[x++]=192|p>>>6:(p<65536?g[x++]=224|p>>>12:(g[x++]=240|p>>>18,g[x++]=128|p>>>12&63),g[x++]=128|p>>>6&63),g[x++]=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,b=g.length;p<b;p++)g[p]=f.charCodeAt(p);return g},i.buf2string=function(f,g){var p,b,v,x,y=g||f.length,E=new Array(2*y);for(p=b=0;p<y;)if((v=f[p++])<128)E[b++]=v;else if(4<(x=c[v]))E[b++]=65533,p+=x-1;else{for(v&=x===2?31:x===3?15:7;1<x&&p<y;)v=v<<6|63&f[p++],x--;1<x?E[b++]=65533:v<65536?E[b++]=v:(v-=65536,E[b++]=55296|v>>10&1023,E[b++]=56320|1023&v)}return d(E,b)},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,b=-2,v=-1,x=4,y=2,E=8,w=9,A=286,T=30,C=19,N=2*A+1,O=15,k=3,j=258,z=j+k+1,I=42,q=113,R=1,W=2,K=3,G=4;function J(B,$){return B.msg=d[$],$}function ee(B){return(B<<1)-(4<B?9:0)}function Z(B){for(var $=B.length;0<=--$;)B[$]=0}function F(B){var $=B.state,ie=$.pending;ie>B.avail_out&&(ie=B.avail_out),ie!==0&&(s.arraySet(B.output,$.pending_buf,$.pending_out,ie,B.next_out),B.next_out+=ie,$.pending_out+=ie,B.total_out+=ie,B.avail_out-=ie,$.pending-=ie,$.pending===0&&($.pending_out=0))}function V(B,$){l._tr_flush_block(B,0<=B.block_start?B.block_start:-1,B.strstart-B.block_start,$),B.block_start=B.strstart,F(B.strm)}function ne(B,$){B.pending_buf[B.pending++]=$}function le(B,$){B.pending_buf[B.pending++]=$>>>8&255,B.pending_buf[B.pending++]=255&$}function oe(B,$){var ie,H,Y=B.max_chain_length,se=B.strstart,ve=B.prev_length,Ne=B.nice_match,Se=B.strstart>B.w_size-z?B.strstart-(B.w_size-z):0,U=B.window,L=B.w_mask,te=B.prev,ye=B.strstart+j,Me=U[se+ve-1],be=U[se+ve];B.prev_length>=B.good_match&&(Y>>=2),Ne>B.lookahead&&(Ne=B.lookahead);do if(U[(ie=$)+ve]===be&&U[ie+ve-1]===Me&&U[ie]===U[se]&&U[++ie]===U[se+1]){se+=2,ie++;do;while(U[++se]===U[++ie]&&U[++se]===U[++ie]&&U[++se]===U[++ie]&&U[++se]===U[++ie]&&U[++se]===U[++ie]&&U[++se]===U[++ie]&&U[++se]===U[++ie]&&U[++se]===U[++ie]&&se<ye);if(H=j-(ye-se),se=ye-j,ve<H){if(B.match_start=$,Ne<=(ve=H))break;Me=U[se+ve-1],be=U[se+ve]}}while(($=te[$&L])>Se&&--Y!=0);return ve<=B.lookahead?ve:B.lookahead}function pe(B){var $,ie,H,Y,se,ve,Ne,Se,U,L,te=B.w_size;do{if(Y=B.window_size-B.lookahead-B.strstart,B.strstart>=te+(te-z)){for(s.arraySet(B.window,B.window,te,te,0),B.match_start-=te,B.strstart-=te,B.block_start-=te,$=ie=B.hash_size;H=B.head[--$],B.head[$]=te<=H?H-te:0,--ie;);for($=ie=te;H=B.prev[--$],B.prev[$]=te<=H?H-te:0,--ie;);Y+=te}if(B.strm.avail_in===0)break;if(ve=B.strm,Ne=B.window,Se=B.strstart+B.lookahead,U=Y,L=void 0,L=ve.avail_in,U<L&&(L=U),ie=L===0?0:(ve.avail_in-=L,s.arraySet(Ne,ve.input,ve.next_in,L,Se),ve.state.wrap===1?ve.adler=c(ve.adler,Ne,L,Se):ve.state.wrap===2&&(ve.adler=u(ve.adler,Ne,L,Se)),ve.next_in+=L,ve.total_in+=L,L),B.lookahead+=ie,B.lookahead+B.insert>=k)for(se=B.strstart-B.insert,B.ins_h=B.window[se],B.ins_h=(B.ins_h<<B.hash_shift^B.window[se+1])&B.hash_mask;B.insert&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[se+k-1])&B.hash_mask,B.prev[se&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=se,se++,B.insert--,!(B.lookahead+B.insert<k)););}while(B.lookahead<z&&B.strm.avail_in!==0)}function Q(B,$){for(var ie,H;;){if(B.lookahead<z){if(pe(B),B.lookahead<z&&$===f)return R;if(B.lookahead===0)break}if(ie=0,B.lookahead>=k&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+k-1])&B.hash_mask,ie=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),ie!==0&&B.strstart-ie<=B.w_size-z&&(B.match_length=oe(B,ie)),B.match_length>=k)if(H=l._tr_tally(B,B.strstart-B.match_start,B.match_length-k),B.lookahead-=B.match_length,B.match_length<=B.max_lazy_match&&B.lookahead>=k){for(B.match_length--;B.strstart++,B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+k-1])&B.hash_mask,ie=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart,--B.match_length!=0;);B.strstart++}else B.strstart+=B.match_length,B.match_length=0,B.ins_h=B.window[B.strstart],B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+1])&B.hash_mask;else H=l._tr_tally(B,0,B.window[B.strstart]),B.lookahead--,B.strstart++;if(H&&(V(B,!1),B.strm.avail_out===0))return R}return B.insert=B.strstart<k-1?B.strstart:k-1,$===g?(V(B,!0),B.strm.avail_out===0?K:G):B.last_lit&&(V(B,!1),B.strm.avail_out===0)?R:W}function Ee(B,$){for(var ie,H,Y;;){if(B.lookahead<z){if(pe(B),B.lookahead<z&&$===f)return R;if(B.lookahead===0)break}if(ie=0,B.lookahead>=k&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+k-1])&B.hash_mask,ie=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),B.prev_length=B.match_length,B.prev_match=B.match_start,B.match_length=k-1,ie!==0&&B.prev_length<B.max_lazy_match&&B.strstart-ie<=B.w_size-z&&(B.match_length=oe(B,ie),B.match_length<=5&&(B.strategy===1||B.match_length===k&&4096<B.strstart-B.match_start)&&(B.match_length=k-1)),B.prev_length>=k&&B.match_length<=B.prev_length){for(Y=B.strstart+B.lookahead-k,H=l._tr_tally(B,B.strstart-1-B.prev_match,B.prev_length-k),B.lookahead-=B.prev_length-1,B.prev_length-=2;++B.strstart<=Y&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+k-1])&B.hash_mask,ie=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),--B.prev_length!=0;);if(B.match_available=0,B.match_length=k-1,B.strstart++,H&&(V(B,!1),B.strm.avail_out===0))return R}else if(B.match_available){if((H=l._tr_tally(B,0,B.window[B.strstart-1]))&&V(B,!1),B.strstart++,B.lookahead--,B.strm.avail_out===0)return R}else B.match_available=1,B.strstart++,B.lookahead--}return B.match_available&&(H=l._tr_tally(B,0,B.window[B.strstart-1]),B.match_available=0),B.insert=B.strstart<k-1?B.strstart:k-1,$===g?(V(B,!0),B.strm.avail_out===0?K:G):B.last_lit&&(V(B,!1),B.strm.avail_out===0)?R:W}function he(B,$,ie,H,Y){this.good_length=B,this.max_lazy=$,this.nice_length=ie,this.max_chain=H,this.func=Y}function ue(){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)),Z(this.dyn_ltree),Z(this.dyn_dtree),Z(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),Z(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*A+1),Z(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 Ae(B){var $;return B&&B.state?(B.total_in=B.total_out=0,B.data_type=y,($=B.state).pending=0,$.pending_out=0,$.wrap<0&&($.wrap=-$.wrap),$.status=$.wrap?I:q,B.adler=$.wrap===2?0:1,$.last_flush=f,l._tr_init($),p):J(B,b)}function fe(B){var $=Ae(B);return $===p&&(function(ie){ie.window_size=2*ie.w_size,Z(ie.head),ie.max_lazy_match=a[ie.level].max_lazy,ie.good_match=a[ie.level].good_length,ie.nice_match=a[ie.level].nice_length,ie.max_chain_length=a[ie.level].max_chain,ie.strstart=0,ie.block_start=0,ie.lookahead=0,ie.insert=0,ie.match_length=ie.prev_length=k-1,ie.match_available=0,ie.ins_h=0})(B.state),$}function at(B,$,ie,H,Y,se){if(!B)return b;var ve=1;if($===v&&($=6),H<0?(ve=0,H=-H):15<H&&(ve=2,H-=16),Y<1||w<Y||ie!==E||H<8||15<H||$<0||9<$||se<0||x<se)return J(B,b);H===8&&(H=9);var Ne=new ue;return(B.state=Ne).strm=B,Ne.wrap=ve,Ne.gzhead=null,Ne.w_bits=H,Ne.w_size=1<<Ne.w_bits,Ne.w_mask=Ne.w_size-1,Ne.hash_bits=Y+7,Ne.hash_size=1<<Ne.hash_bits,Ne.hash_mask=Ne.hash_size-1,Ne.hash_shift=~~((Ne.hash_bits+k-1)/k),Ne.window=new s.Buf8(2*Ne.w_size),Ne.head=new s.Buf16(Ne.hash_size),Ne.prev=new s.Buf16(Ne.w_size),Ne.lit_bufsize=1<<Y+6,Ne.pending_buf_size=4*Ne.lit_bufsize,Ne.pending_buf=new s.Buf8(Ne.pending_buf_size),Ne.d_buf=1*Ne.lit_bufsize,Ne.l_buf=3*Ne.lit_bufsize,Ne.level=$,Ne.strategy=se,Ne.method=ie,fe(B)}a=[new he(0,0,0,0,function(B,$){var ie=65535;for(ie>B.pending_buf_size-5&&(ie=B.pending_buf_size-5);;){if(B.lookahead<=1){if(pe(B),B.lookahead===0&&$===f)return R;if(B.lookahead===0)break}B.strstart+=B.lookahead,B.lookahead=0;var H=B.block_start+ie;if((B.strstart===0||B.strstart>=H)&&(B.lookahead=B.strstart-H,B.strstart=H,V(B,!1),B.strm.avail_out===0)||B.strstart-B.block_start>=B.w_size-z&&(V(B,!1),B.strm.avail_out===0))return R}return B.insert=0,$===g?(V(B,!0),B.strm.avail_out===0?K:G):(B.strstart>B.block_start&&(V(B,!1),B.strm.avail_out),R)}),new he(4,4,8,4,Q),new he(4,5,16,8,Q),new he(4,6,32,32,Q),new he(4,4,16,16,Ee),new he(8,16,32,32,Ee),new he(8,16,128,128,Ee),new he(8,32,128,256,Ee),new he(32,128,258,1024,Ee),new he(32,258,258,4096,Ee)],i.deflateInit=function(B,$){return at(B,$,E,15,8,0)},i.deflateInit2=at,i.deflateReset=fe,i.deflateResetKeep=Ae,i.deflateSetHeader=function(B,$){return B&&B.state?B.state.wrap!==2?b:(B.state.gzhead=$,p):b},i.deflate=function(B,$){var ie,H,Y,se;if(!B||!B.state||5<$||$<0)return B?J(B,b):b;if(H=B.state,!B.output||!B.input&&B.avail_in!==0||H.status===666&&$!==g)return J(B,B.avail_out===0?-5:b);if(H.strm=B,ie=H.last_flush,H.last_flush=$,H.status===I)if(H.wrap===2)B.adler=0,ne(H,31),ne(H,139),ne(H,8),H.gzhead?(ne(H,(H.gzhead.text?1:0)+(H.gzhead.hcrc?2:0)+(H.gzhead.extra?4:0)+(H.gzhead.name?8:0)+(H.gzhead.comment?16:0)),ne(H,255&H.gzhead.time),ne(H,H.gzhead.time>>8&255),ne(H,H.gzhead.time>>16&255),ne(H,H.gzhead.time>>24&255),ne(H,H.level===9?2:2<=H.strategy||H.level<2?4:0),ne(H,255&H.gzhead.os),H.gzhead.extra&&H.gzhead.extra.length&&(ne(H,255&H.gzhead.extra.length),ne(H,H.gzhead.extra.length>>8&255)),H.gzhead.hcrc&&(B.adler=u(B.adler,H.pending_buf,H.pending,0)),H.gzindex=0,H.status=69):(ne(H,0),ne(H,0),ne(H,0),ne(H,0),ne(H,0),ne(H,H.level===9?2:2<=H.strategy||H.level<2?4:0),ne(H,3),H.status=q);else{var ve=E+(H.w_bits-8<<4)<<8;ve|=(2<=H.strategy||H.level<2?0:H.level<6?1:H.level===6?2:3)<<6,H.strstart!==0&&(ve|=32),ve+=31-ve%31,H.status=q,le(H,ve),H.strstart!==0&&(le(H,B.adler>>>16),le(H,65535&B.adler)),B.adler=1}if(H.status===69)if(H.gzhead.extra){for(Y=H.pending;H.gzindex<(65535&H.gzhead.extra.length)&&(H.pending!==H.pending_buf_size||(H.gzhead.hcrc&&H.pending>Y&&(B.adler=u(B.adler,H.pending_buf,H.pending-Y,Y)),F(B),Y=H.pending,H.pending!==H.pending_buf_size));)ne(H,255&H.gzhead.extra[H.gzindex]),H.gzindex++;H.gzhead.hcrc&&H.pending>Y&&(B.adler=u(B.adler,H.pending_buf,H.pending-Y,Y)),H.gzindex===H.gzhead.extra.length&&(H.gzindex=0,H.status=73)}else H.status=73;if(H.status===73)if(H.gzhead.name){Y=H.pending;do{if(H.pending===H.pending_buf_size&&(H.gzhead.hcrc&&H.pending>Y&&(B.adler=u(B.adler,H.pending_buf,H.pending-Y,Y)),F(B),Y=H.pending,H.pending===H.pending_buf_size)){se=1;break}se=H.gzindex<H.gzhead.name.length?255&H.gzhead.name.charCodeAt(H.gzindex++):0,ne(H,se)}while(se!==0);H.gzhead.hcrc&&H.pending>Y&&(B.adler=u(B.adler,H.pending_buf,H.pending-Y,Y)),se===0&&(H.gzindex=0,H.status=91)}else H.status=91;if(H.status===91)if(H.gzhead.comment){Y=H.pending;do{if(H.pending===H.pending_buf_size&&(H.gzhead.hcrc&&H.pending>Y&&(B.adler=u(B.adler,H.pending_buf,H.pending-Y,Y)),F(B),Y=H.pending,H.pending===H.pending_buf_size)){se=1;break}se=H.gzindex<H.gzhead.comment.length?255&H.gzhead.comment.charCodeAt(H.gzindex++):0,ne(H,se)}while(se!==0);H.gzhead.hcrc&&H.pending>Y&&(B.adler=u(B.adler,H.pending_buf,H.pending-Y,Y)),se===0&&(H.status=103)}else H.status=103;if(H.status===103&&(H.gzhead.hcrc?(H.pending+2>H.pending_buf_size&&F(B),H.pending+2<=H.pending_buf_size&&(ne(H,255&B.adler),ne(H,B.adler>>8&255),B.adler=0,H.status=q)):H.status=q),H.pending!==0){if(F(B),B.avail_out===0)return H.last_flush=-1,p}else if(B.avail_in===0&&ee($)<=ee(ie)&&$!==g)return J(B,-5);if(H.status===666&&B.avail_in!==0)return J(B,-5);if(B.avail_in!==0||H.lookahead!==0||$!==f&&H.status!==666){var Ne=H.strategy===2?(function(Se,U){for(var L;;){if(Se.lookahead===0&&(pe(Se),Se.lookahead===0)){if(U===f)return R;break}if(Se.match_length=0,L=l._tr_tally(Se,0,Se.window[Se.strstart]),Se.lookahead--,Se.strstart++,L&&(V(Se,!1),Se.strm.avail_out===0))return R}return Se.insert=0,U===g?(V(Se,!0),Se.strm.avail_out===0?K:G):Se.last_lit&&(V(Se,!1),Se.strm.avail_out===0)?R:W})(H,$):H.strategy===3?(function(Se,U){for(var L,te,ye,Me,be=Se.window;;){if(Se.lookahead<=j){if(pe(Se),Se.lookahead<=j&&U===f)return R;if(Se.lookahead===0)break}if(Se.match_length=0,Se.lookahead>=k&&0<Se.strstart&&(te=be[ye=Se.strstart-1])===be[++ye]&&te===be[++ye]&&te===be[++ye]){Me=Se.strstart+j;do;while(te===be[++ye]&&te===be[++ye]&&te===be[++ye]&&te===be[++ye]&&te===be[++ye]&&te===be[++ye]&&te===be[++ye]&&te===be[++ye]&&ye<Me);Se.match_length=j-(Me-ye),Se.match_length>Se.lookahead&&(Se.match_length=Se.lookahead)}if(Se.match_length>=k?(L=l._tr_tally(Se,1,Se.match_length-k),Se.lookahead-=Se.match_length,Se.strstart+=Se.match_length,Se.match_length=0):(L=l._tr_tally(Se,0,Se.window[Se.strstart]),Se.lookahead--,Se.strstart++),L&&(V(Se,!1),Se.strm.avail_out===0))return R}return Se.insert=0,U===g?(V(Se,!0),Se.strm.avail_out===0?K:G):Se.last_lit&&(V(Se,!1),Se.strm.avail_out===0)?R:W})(H,$):a[H.level].func(H,$);if(Ne!==K&&Ne!==G||(H.status=666),Ne===R||Ne===K)return B.avail_out===0&&(H.last_flush=-1),p;if(Ne===W&&($===1?l._tr_align(H):$!==5&&(l._tr_stored_block(H,0,0,!1),$===3&&(Z(H.head),H.lookahead===0&&(H.strstart=0,H.block_start=0,H.insert=0))),F(B),B.avail_out===0))return H.last_flush=-1,p}return $!==g?p:H.wrap<=0?1:(H.wrap===2?(ne(H,255&B.adler),ne(H,B.adler>>8&255),ne(H,B.adler>>16&255),ne(H,B.adler>>24&255),ne(H,255&B.total_in),ne(H,B.total_in>>8&255),ne(H,B.total_in>>16&255),ne(H,B.total_in>>24&255)):(le(H,B.adler>>>16),le(H,65535&B.adler)),F(B),0<H.wrap&&(H.wrap=-H.wrap),H.pending!==0?p:1)},i.deflateEnd=function(B){var $;return B&&B.state?($=B.state.status)!==I&&$!==69&&$!==73&&$!==91&&$!==103&&$!==q&&$!==666?J(B,b):(B.state=null,$===q?J(B,-3):p):b},i.deflateSetDictionary=function(B,$){var ie,H,Y,se,ve,Ne,Se,U,L=$.length;if(!B||!B.state||(se=(ie=B.state).wrap)===2||se===1&&ie.status!==I||ie.lookahead)return b;for(se===1&&(B.adler=c(B.adler,$,L,0)),ie.wrap=0,L>=ie.w_size&&(se===0&&(Z(ie.head),ie.strstart=0,ie.block_start=0,ie.insert=0),U=new s.Buf8(ie.w_size),s.arraySet(U,$,L-ie.w_size,ie.w_size,0),$=U,L=ie.w_size),ve=B.avail_in,Ne=B.next_in,Se=B.input,B.avail_in=L,B.next_in=0,B.input=$,pe(ie);ie.lookahead>=k;){for(H=ie.strstart,Y=ie.lookahead-(k-1);ie.ins_h=(ie.ins_h<<ie.hash_shift^ie.window[H+k-1])&ie.hash_mask,ie.prev[H&ie.w_mask]=ie.head[ie.ins_h],ie.head[ie.ins_h]=H,H++,--Y;);ie.strstart=H,ie.lookahead=k-1,pe(ie)}return ie.strstart+=ie.lookahead,ie.block_start=ie.strstart,ie.insert=ie.lookahead,ie.lookahead=0,ie.match_length=ie.prev_length=k-1,ie.match_available=0,B.next_in=Ne,B.input=Se,B.avail_in=ve,ie.wrap=se,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,b,v,x,y,E,w,A,T,C,N,O,k,j,z,I,q,R,W;l=a.state,c=a.next_in,R=a.input,u=c+(a.avail_in-5),d=a.next_out,W=a.output,f=d-(s-a.avail_out),g=d+(a.avail_out-257),p=l.dmax,b=l.wsize,v=l.whave,x=l.wnext,y=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)W[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(z=65535&O,w<(k&=15)&&(E+=R[c++]<<w,(w+=8)<k&&(E+=R[c++]<<w,w+=8)),p<(z+=E&(1<<k)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(E>>>=k,w-=k,(k=d-f)<z){if(v<(k=z-k)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(q=y,(I=0)===x){if(I+=b-k,k<j){for(j-=k;W[d++]=y[I++],--k;);I=d-z,q=W}}else if(x<k){if(I+=b+x-k,(k-=x)<j){for(j-=k;W[d++]=y[I++],--k;);if(I=0,x<j){for(j-=k=x;W[d++]=y[I++],--k;);I=d-z,q=W}}}else if(I+=x-k,k<j){for(j-=k;W[d++]=y[I++],--k;);I=d-z,q=W}for(;2<j;)W[d++]=q[I++],W[d++]=q[I++],W[d++]=q[I++],j-=3;j&&(W[d++]=q[I++],1<j&&(W[d++]=q[I++]))}else{for(I=d-z;W[d++]=W[I++],W[d++]=W[I++],W[d++]=W[I++],2<(j-=3););j&&(W[d++]=W[I++],1<j&&(W[d++]=W[I++]))}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,b=1,v=852,x=592;function y(I){return(I>>>24&255)+(I>>>8&65280)+((65280&I)<<8)+((255&I)<<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(I){var q;return I&&I.state?(q=I.state,I.total_in=I.total_out=q.total=0,I.msg="",q.wrap&&(I.adler=1&q.wrap),q.mode=b,q.last=0,q.havedict=0,q.dmax=32768,q.head=null,q.hold=0,q.bits=0,q.lencode=q.lendyn=new a.Buf32(v),q.distcode=q.distdyn=new a.Buf32(x),q.sane=1,q.back=-1,g):p}function A(I){var q;return I&&I.state?((q=I.state).wsize=0,q.whave=0,q.wnext=0,w(I)):p}function T(I,q){var R,W;return I&&I.state?(W=I.state,q<0?(R=0,q=-q):(R=1+(q>>4),q<48&&(q&=15)),q&&(q<8||15<q)?p:(W.window!==null&&W.wbits!==q&&(W.window=null),W.wrap=R,W.wbits=q,A(I))):p}function C(I,q){var R,W;return I?(W=new E,(I.state=W).window=null,(R=T(I,q))!==g&&(I.state=null),R):p}var N,O,k=!0;function j(I){if(k){var q;for(N=new a.Buf32(512),O=new a.Buf32(32),q=0;q<144;)I.lens[q++]=8;for(;q<256;)I.lens[q++]=9;for(;q<280;)I.lens[q++]=7;for(;q<288;)I.lens[q++]=8;for(u(d,I.lens,0,288,N,0,I.work,{bits:9}),q=0;q<32;)I.lens[q++]=5;u(f,I.lens,0,32,O,0,I.work,{bits:5}),k=!1}I.lencode=N,I.lenbits=9,I.distcode=O,I.distbits=5}function z(I,q,R,W){var K,G=I.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new a.Buf8(G.wsize)),W>=G.wsize?(a.arraySet(G.window,q,R-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(W<(K=G.wsize-G.wnext)&&(K=W),a.arraySet(G.window,q,R-W,K,G.wnext),(W-=K)?(a.arraySet(G.window,q,R-W,W,0),G.wnext=W,G.whave=G.wsize):(G.wnext+=K,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=K))),0}i.inflateReset=A,i.inflateReset2=T,i.inflateResetKeep=w,i.inflateInit=function(I){return C(I,15)},i.inflateInit2=C,i.inflate=function(I,q){var R,W,K,G,J,ee,Z,F,V,ne,le,oe,pe,Q,Ee,he,ue,Ae,fe,at,B,$,ie,H,Y=0,se=new a.Buf8(4),ve=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!I||!I.state||!I.output||!I.input&&I.avail_in!==0)return p;(R=I.state).mode===12&&(R.mode=13),J=I.next_out,K=I.output,Z=I.avail_out,G=I.next_in,W=I.input,ee=I.avail_in,F=R.hold,V=R.bits,ne=ee,le=Z,$=g;e:for(;;)switch(R.mode){case b:if(R.wrap===0){R.mode=13;break}for(;V<16;){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}if(2&R.wrap&&F===35615){se[R.check=0]=255&F,se[1]=F>>>8&255,R.check=l(R.check,se,2,0),V=F=0,R.mode=2;break}if(R.flags=0,R.head&&(R.head.done=!1),!(1&R.wrap)||(((255&F)<<8)+(F>>8))%31){I.msg="incorrect header check",R.mode=30;break}if((15&F)!=8){I.msg="unknown compression method",R.mode=30;break}if(V-=4,B=8+(15&(F>>>=4)),R.wbits===0)R.wbits=B;else if(B>R.wbits){I.msg="invalid window size",R.mode=30;break}R.dmax=1<<B,I.adler=R.check=1,R.mode=512&F?10:12,V=F=0;break;case 2:for(;V<16;){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}if(R.flags=F,(255&R.flags)!=8){I.msg="unknown compression method",R.mode=30;break}if(57344&R.flags){I.msg="unknown header flags set",R.mode=30;break}R.head&&(R.head.text=F>>8&1),512&R.flags&&(se[0]=255&F,se[1]=F>>>8&255,R.check=l(R.check,se,2,0)),V=F=0,R.mode=3;case 3:for(;V<32;){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}R.head&&(R.head.time=F),512&R.flags&&(se[0]=255&F,se[1]=F>>>8&255,se[2]=F>>>16&255,se[3]=F>>>24&255,R.check=l(R.check,se,4,0)),V=F=0,R.mode=4;case 4:for(;V<16;){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}R.head&&(R.head.xflags=255&F,R.head.os=F>>8),512&R.flags&&(se[0]=255&F,se[1]=F>>>8&255,R.check=l(R.check,se,2,0)),V=F=0,R.mode=5;case 5:if(1024&R.flags){for(;V<16;){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}R.length=F,R.head&&(R.head.extra_len=F),512&R.flags&&(se[0]=255&F,se[1]=F>>>8&255,R.check=l(R.check,se,2,0)),V=F=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(ee<(oe=R.length)&&(oe=ee),oe&&(R.head&&(B=R.head.extra_len-R.length,R.head.extra||(R.head.extra=new Array(R.head.extra_len)),a.arraySet(R.head.extra,W,G,oe,B)),512&R.flags&&(R.check=l(R.check,W,oe,G)),ee-=oe,G+=oe,R.length-=oe),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(ee===0)break e;for(oe=0;B=W[G+oe++],R.head&&B&&R.length<65536&&(R.head.name+=String.fromCharCode(B)),B&&oe<ee;);if(512&R.flags&&(R.check=l(R.check,W,oe,G)),ee-=oe,G+=oe,B)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(oe=0;B=W[G+oe++],R.head&&B&&R.length<65536&&(R.head.comment+=String.fromCharCode(B)),B&&oe<ee;);if(512&R.flags&&(R.check=l(R.check,W,oe,G)),ee-=oe,G+=oe,B)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--,F+=W[G++]<<V,V+=8}if(F!==(65535&R.check)){I.msg="header crc mismatch",R.mode=30;break}V=F=0}R.head&&(R.head.hcrc=R.flags>>9&1,R.head.done=!0),I.adler=R.check=0,R.mode=12;break;case 10:for(;V<32;){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}I.adler=R.check=y(F),V=F=0,R.mode=11;case 11:if(R.havedict===0)return I.next_out=J,I.avail_out=Z,I.next_in=G,I.avail_in=ee,R.hold=F,R.bits=V,2;I.adler=R.check=1,R.mode=12;case 12:if(q===5||q===6)break e;case 13:if(R.last){F>>>=7&V,V-=7&V,R.mode=27;break}for(;V<3;){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}switch(R.last=1&F,V-=1,3&(F>>>=1)){case 0:R.mode=14;break;case 1:if(j(R),R.mode=20,q!==6)break;F>>>=2,V-=2;break e;case 2:R.mode=17;break;case 3:I.msg="invalid block type",R.mode=30}F>>>=2,V-=2;break;case 14:for(F>>>=7&V,V-=7&V;V<32;){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}if((65535&F)!=(F>>>16^65535)){I.msg="invalid stored block lengths",R.mode=30;break}if(R.length=65535&F,V=F=0,R.mode=15,q===6)break e;case 15:R.mode=16;case 16:if(oe=R.length){if(ee<oe&&(oe=ee),Z<oe&&(oe=Z),oe===0)break e;a.arraySet(K,W,G,oe,J),ee-=oe,G+=oe,Z-=oe,J+=oe,R.length-=oe;break}R.mode=12;break;case 17:for(;V<14;){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}if(R.nlen=257+(31&F),F>>>=5,V-=5,R.ndist=1+(31&F),F>>>=5,V-=5,R.ncode=4+(15&F),F>>>=4,V-=4,286<R.nlen||30<R.ndist){I.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--,F+=W[G++]<<V,V+=8}R.lens[ve[R.have++]]=7&F,F>>>=3,V-=3}for(;R.have<19;)R.lens[ve[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,ie={bits:R.lenbits},$=u(0,R.lens,0,19,R.lencode,0,R.work,ie),R.lenbits=ie.bits,$){I.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(;he=(Y=R.lencode[F&(1<<R.lenbits)-1])>>>16&255,ue=65535&Y,!((Ee=Y>>>24)<=V);){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}if(ue<16)F>>>=Ee,V-=Ee,R.lens[R.have++]=ue;else{if(ue===16){for(H=Ee+2;V<H;){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}if(F>>>=Ee,V-=Ee,R.have===0){I.msg="invalid bit length repeat",R.mode=30;break}B=R.lens[R.have-1],oe=3+(3&F),F>>>=2,V-=2}else if(ue===17){for(H=Ee+3;V<H;){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}V-=Ee,B=0,oe=3+(7&(F>>>=Ee)),F>>>=3,V-=3}else{for(H=Ee+7;V<H;){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}V-=Ee,B=0,oe=11+(127&(F>>>=Ee)),F>>>=7,V-=7}if(R.have+oe>R.nlen+R.ndist){I.msg="invalid bit length repeat",R.mode=30;break}for(;oe--;)R.lens[R.have++]=B}}if(R.mode===30)break;if(R.lens[256]===0){I.msg="invalid code -- missing end-of-block",R.mode=30;break}if(R.lenbits=9,ie={bits:R.lenbits},$=u(d,R.lens,0,R.nlen,R.lencode,0,R.work,ie),R.lenbits=ie.bits,$){I.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,ie={bits:R.distbits},$=u(f,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,ie),R.distbits=ie.bits,$){I.msg="invalid distances set",R.mode=30;break}if(R.mode=20,q===6)break e;case 20:R.mode=21;case 21:if(6<=ee&&258<=Z){I.next_out=J,I.avail_out=Z,I.next_in=G,I.avail_in=ee,R.hold=F,R.bits=V,c(I,le),J=I.next_out,K=I.output,Z=I.avail_out,G=I.next_in,W=I.input,ee=I.avail_in,F=R.hold,V=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;he=(Y=R.lencode[F&(1<<R.lenbits)-1])>>>16&255,ue=65535&Y,!((Ee=Y>>>24)<=V);){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}if(he&&(240&he)==0){for(Ae=Ee,fe=he,at=ue;he=(Y=R.lencode[at+((F&(1<<Ae+fe)-1)>>Ae)])>>>16&255,ue=65535&Y,!(Ae+(Ee=Y>>>24)<=V);){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}F>>>=Ae,V-=Ae,R.back+=Ae}if(F>>>=Ee,V-=Ee,R.back+=Ee,R.length=ue,he===0){R.mode=26;break}if(32&he){R.back=-1,R.mode=12;break}if(64&he){I.msg="invalid literal/length code",R.mode=30;break}R.extra=15&he,R.mode=22;case 22:if(R.extra){for(H=R.extra;V<H;){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}R.length+=F&(1<<R.extra)-1,F>>>=R.extra,V-=R.extra,R.back+=R.extra}R.was=R.length,R.mode=23;case 23:for(;he=(Y=R.distcode[F&(1<<R.distbits)-1])>>>16&255,ue=65535&Y,!((Ee=Y>>>24)<=V);){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}if((240&he)==0){for(Ae=Ee,fe=he,at=ue;he=(Y=R.distcode[at+((F&(1<<Ae+fe)-1)>>Ae)])>>>16&255,ue=65535&Y,!(Ae+(Ee=Y>>>24)<=V);){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}F>>>=Ae,V-=Ae,R.back+=Ae}if(F>>>=Ee,V-=Ee,R.back+=Ee,64&he){I.msg="invalid distance code",R.mode=30;break}R.offset=ue,R.extra=15&he,R.mode=24;case 24:if(R.extra){for(H=R.extra;V<H;){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}R.offset+=F&(1<<R.extra)-1,F>>>=R.extra,V-=R.extra,R.back+=R.extra}if(R.offset>R.dmax){I.msg="invalid distance too far back",R.mode=30;break}R.mode=25;case 25:if(Z===0)break e;if(oe=le-Z,R.offset>oe){if((oe=R.offset-oe)>R.whave&&R.sane){I.msg="invalid distance too far back",R.mode=30;break}pe=oe>R.wnext?(oe-=R.wnext,R.wsize-oe):R.wnext-oe,oe>R.length&&(oe=R.length),Q=R.window}else Q=K,pe=J-R.offset,oe=R.length;for(Z<oe&&(oe=Z),Z-=oe,R.length-=oe;K[J++]=Q[pe++],--oe;);R.length===0&&(R.mode=21);break;case 26:if(Z===0)break e;K[J++]=R.length,Z--,R.mode=21;break;case 27:if(R.wrap){for(;V<32;){if(ee===0)break e;ee--,F|=W[G++]<<V,V+=8}if(le-=Z,I.total_out+=le,R.total+=le,le&&(I.adler=R.check=R.flags?l(R.check,K,le,J-le):s(R.check,K,le,J-le)),le=Z,(R.flags?F:y(F))!==R.check){I.msg="incorrect data check",R.mode=30;break}V=F=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;V<32;){if(ee===0)break e;ee--,F+=W[G++]<<V,V+=8}if(F!==(4294967295&R.total)){I.msg="incorrect length check",R.mode=30;break}V=F=0}R.mode=29;case 29:$=1;break e;case 30:$=-3;break e;case 31:return-4;case 32:default:return p}return I.next_out=J,I.avail_out=Z,I.next_in=G,I.avail_in=ee,R.hold=F,R.bits=V,(R.wsize||le!==I.avail_out&&R.mode<30&&(R.mode<27||q!==4))&&z(I,I.output,I.next_out,le-I.avail_out)?(R.mode=31,-4):(ne-=I.avail_in,le-=I.avail_out,I.total_in+=ne,I.total_out+=le,R.total+=le,R.wrap&&le&&(I.adler=R.check=R.flags?l(R.check,K,le,I.next_out-le):s(R.check,K,le,I.next_out-le)),I.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(ne==0&&le===0||q===4)&&$===g&&($=-5),$)},i.inflateEnd=function(I){if(!I||!I.state)return p;var q=I.state;return q.window&&(q.window=null),I.state=null,g},i.inflateGetHeader=function(I,q){var R;return I&&I.state?(2&(R=I.state).wrap)==0?p:((R.head=q).done=!1,g):p},i.inflateSetDictionary=function(I,q){var R,W=q.length;return I&&I.state?(R=I.state).wrap!==0&&R.mode!==11?p:R.mode===11&&s(1,q,W,0)!==R.check?-3:z(I,q,W,W)?(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,b,v,x,y){var E,w,A,T,C,N,O,k,j,z=y.bits,I=0,q=0,R=0,W=0,K=0,G=0,J=0,ee=0,Z=0,F=0,V=null,ne=0,le=new a.Buf16(16),oe=new a.Buf16(16),pe=null,Q=0;for(I=0;I<=15;I++)le[I]=0;for(q=0;q<p;q++)le[f[g+q]]++;for(K=z,W=15;1<=W&&le[W]===0;W--);if(W<K&&(K=W),W===0)return b[v++]=20971520,b[v++]=20971520,y.bits=1,0;for(R=1;R<W&&le[R]===0;R++);for(K<R&&(K=R),I=ee=1;I<=15;I++)if(ee<<=1,(ee-=le[I])<0)return-1;if(0<ee&&(d===0||W!==1))return-1;for(oe[1]=0,I=1;I<15;I++)oe[I+1]=oe[I]+le[I];for(q=0;q<p;q++)f[g+q]!==0&&(x[oe[f[g+q]]++]=q);if(N=d===0?(V=pe=x,19):d===1?(V=s,ne-=257,pe=l,Q-=257,256):(V=c,pe=u,-1),I=R,C=v,J=q=F=0,A=-1,T=(Z=1<<(G=K))-1,d===1&&852<Z||d===2&&592<Z)return 1;for(;;){for(O=I-J,j=x[q]<N?(k=0,x[q]):x[q]>N?(k=pe[Q+x[q]],V[ne+x[q]]):(k=96,0),E=1<<I-J,R=w=1<<G;b[C+(F>>J)+(w-=E)]=O<<24|k<<16|j|0,w!==0;);for(E=1<<I-1;F&E;)E>>=1;if(E!==0?(F&=E-1,F+=E):F=0,q++,--le[I]==0){if(I===W)break;I=f[g+x[q]]}if(K<I&&(F&T)!==A){for(J===0&&(J=K),C+=R,ee=1<<(G=I-J);G+J<W&&!((ee-=le[G+J])<=0);)G++,ee<<=1;if(Z+=1<<G,d===1&&852<Z||d===2&&592<Z)return 1;b[A=F&T]=K<<24|G<<16|C-v|0}}return F!==0&&(b[C+F]=I-J<<24|64<<16|0),y.bits=K,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(Y){for(var se=Y.length;0<=--se;)Y[se]=0}var u=0,d=29,f=256,g=f+1+d,p=30,b=19,v=2*g+1,x=15,y=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],z=new Array(2*(g+2));c(z);var I=new Array(2*p);c(I);var q=new Array(512);c(q);var R=new Array(256);c(R);var W=new Array(d);c(W);var K,G,J,ee=new Array(p);function Z(Y,se,ve,Ne,Se){this.static_tree=Y,this.extra_bits=se,this.extra_base=ve,this.elems=Ne,this.max_length=Se,this.has_stree=Y&&Y.length}function F(Y,se){this.dyn_tree=Y,this.max_code=0,this.stat_desc=se}function V(Y){return Y<256?q[Y]:q[256+(Y>>>7)]}function ne(Y,se){Y.pending_buf[Y.pending++]=255&se,Y.pending_buf[Y.pending++]=se>>>8&255}function le(Y,se,ve){Y.bi_valid>y-ve?(Y.bi_buf|=se<<Y.bi_valid&65535,ne(Y,Y.bi_buf),Y.bi_buf=se>>y-Y.bi_valid,Y.bi_valid+=ve-y):(Y.bi_buf|=se<<Y.bi_valid&65535,Y.bi_valid+=ve)}function oe(Y,se,ve){le(Y,ve[2*se],ve[2*se+1])}function pe(Y,se){for(var ve=0;ve|=1&Y,Y>>>=1,ve<<=1,0<--se;);return ve>>>1}function Q(Y,se,ve){var Ne,Se,U=new Array(x+1),L=0;for(Ne=1;Ne<=x;Ne++)U[Ne]=L=L+ve[Ne-1]<<1;for(Se=0;Se<=se;Se++){var te=Y[2*Se+1];te!==0&&(Y[2*Se]=pe(U[te]++,te))}}function Ee(Y){var se;for(se=0;se<g;se++)Y.dyn_ltree[2*se]=0;for(se=0;se<p;se++)Y.dyn_dtree[2*se]=0;for(se=0;se<b;se++)Y.bl_tree[2*se]=0;Y.dyn_ltree[2*w]=1,Y.opt_len=Y.static_len=0,Y.last_lit=Y.matches=0}function he(Y){8<Y.bi_valid?ne(Y,Y.bi_buf):0<Y.bi_valid&&(Y.pending_buf[Y.pending++]=Y.bi_buf),Y.bi_buf=0,Y.bi_valid=0}function ue(Y,se,ve,Ne){var Se=2*se,U=2*ve;return Y[Se]<Y[U]||Y[Se]===Y[U]&&Ne[se]<=Ne[ve]}function Ae(Y,se,ve){for(var Ne=Y.heap[ve],Se=ve<<1;Se<=Y.heap_len&&(Se<Y.heap_len&&ue(se,Y.heap[Se+1],Y.heap[Se],Y.depth)&&Se++,!ue(se,Ne,Y.heap[Se],Y.depth));)Y.heap[ve]=Y.heap[Se],ve=Se,Se<<=1;Y.heap[ve]=Ne}function fe(Y,se,ve){var Ne,Se,U,L,te=0;if(Y.last_lit!==0)for(;Ne=Y.pending_buf[Y.d_buf+2*te]<<8|Y.pending_buf[Y.d_buf+2*te+1],Se=Y.pending_buf[Y.l_buf+te],te++,Ne===0?oe(Y,Se,se):(oe(Y,(U=R[Se])+f+1,se),(L=N[U])!==0&&le(Y,Se-=W[U],L),oe(Y,U=V(--Ne),ve),(L=O[U])!==0&&le(Y,Ne-=ee[U],L)),te<Y.last_lit;);oe(Y,w,se)}function at(Y,se){var ve,Ne,Se,U=se.dyn_tree,L=se.stat_desc.static_tree,te=se.stat_desc.has_stree,ye=se.stat_desc.elems,Me=-1;for(Y.heap_len=0,Y.heap_max=v,ve=0;ve<ye;ve++)U[2*ve]!==0?(Y.heap[++Y.heap_len]=Me=ve,Y.depth[ve]=0):U[2*ve+1]=0;for(;Y.heap_len<2;)U[2*(Se=Y.heap[++Y.heap_len]=Me<2?++Me:0)]=1,Y.depth[Se]=0,Y.opt_len--,te&&(Y.static_len-=L[2*Se+1]);for(se.max_code=Me,ve=Y.heap_len>>1;1<=ve;ve--)Ae(Y,U,ve);for(Se=ye;ve=Y.heap[1],Y.heap[1]=Y.heap[Y.heap_len--],Ae(Y,U,1),Ne=Y.heap[1],Y.heap[--Y.heap_max]=ve,Y.heap[--Y.heap_max]=Ne,U[2*Se]=U[2*ve]+U[2*Ne],Y.depth[Se]=(Y.depth[ve]>=Y.depth[Ne]?Y.depth[ve]:Y.depth[Ne])+1,U[2*ve+1]=U[2*Ne+1]=Se,Y.heap[1]=Se++,Ae(Y,U,1),2<=Y.heap_len;);Y.heap[--Y.heap_max]=Y.heap[1],(function(be,qe){var Ve,We,lt,me,ae,He,Be=qe.dyn_tree,Ye=qe.max_code,ot=qe.stat_desc.static_tree,ge=qe.stat_desc.has_stree,nt=qe.stat_desc.extra_bits,xe=qe.stat_desc.extra_base,ze=qe.stat_desc.max_length,Re=0;for(me=0;me<=x;me++)be.bl_count[me]=0;for(Be[2*be.heap[be.heap_max]+1]=0,Ve=be.heap_max+1;Ve<v;Ve++)ze<(me=Be[2*Be[2*(We=be.heap[Ve])+1]+1]+1)&&(me=ze,Re++),Be[2*We+1]=me,Ye<We||(be.bl_count[me]++,ae=0,xe<=We&&(ae=nt[We-xe]),He=Be[2*We],be.opt_len+=He*(me+ae),ge&&(be.static_len+=He*(ot[2*We+1]+ae)));if(Re!==0){do{for(me=ze-1;be.bl_count[me]===0;)me--;be.bl_count[me]--,be.bl_count[me+1]+=2,be.bl_count[ze]--,Re-=2}while(0<Re);for(me=ze;me!==0;me--)for(We=be.bl_count[me];We!==0;)Ye<(lt=be.heap[--Ve])||(Be[2*lt+1]!==me&&(be.opt_len+=(me-Be[2*lt+1])*Be[2*lt],Be[2*lt+1]=me),We--)}})(Y,se),Q(U,Me,Y.bl_count)}function B(Y,se,ve){var Ne,Se,U=-1,L=se[1],te=0,ye=7,Me=4;for(L===0&&(ye=138,Me=3),se[2*(ve+1)+1]=65535,Ne=0;Ne<=ve;Ne++)Se=L,L=se[2*(Ne+1)+1],++te<ye&&Se===L||(te<Me?Y.bl_tree[2*Se]+=te:Se!==0?(Se!==U&&Y.bl_tree[2*Se]++,Y.bl_tree[2*A]++):te<=10?Y.bl_tree[2*T]++:Y.bl_tree[2*C]++,U=Se,Me=(te=0)===L?(ye=138,3):Se===L?(ye=6,3):(ye=7,4))}function $(Y,se,ve){var Ne,Se,U=-1,L=se[1],te=0,ye=7,Me=4;for(L===0&&(ye=138,Me=3),Ne=0;Ne<=ve;Ne++)if(Se=L,L=se[2*(Ne+1)+1],!(++te<ye&&Se===L)){if(te<Me)for(;oe(Y,Se,Y.bl_tree),--te!=0;);else Se!==0?(Se!==U&&(oe(Y,Se,Y.bl_tree),te--),oe(Y,A,Y.bl_tree),le(Y,te-3,2)):te<=10?(oe(Y,T,Y.bl_tree),le(Y,te-3,3)):(oe(Y,C,Y.bl_tree),le(Y,te-11,7));U=Se,Me=(te=0)===L?(ye=138,3):Se===L?(ye=6,3):(ye=7,4)}}c(ee);var ie=!1;function H(Y,se,ve,Ne){le(Y,(u<<1)+(Ne?1:0),3),(function(Se,U,L,te){he(Se),ne(Se,L),ne(Se,~L),a.arraySet(Se.pending_buf,Se.window,U,L,Se.pending),Se.pending+=L})(Y,se,ve)}i._tr_init=function(Y){ie||((function(){var se,ve,Ne,Se,U,L=new Array(x+1);for(Se=Ne=0;Se<d-1;Se++)for(W[Se]=Ne,se=0;se<1<<N[Se];se++)R[Ne++]=Se;for(R[Ne-1]=Se,Se=U=0;Se<16;Se++)for(ee[Se]=U,se=0;se<1<<O[Se];se++)q[U++]=Se;for(U>>=7;Se<p;Se++)for(ee[Se]=U<<7,se=0;se<1<<O[Se]-7;se++)q[256+U++]=Se;for(ve=0;ve<=x;ve++)L[ve]=0;for(se=0;se<=143;)z[2*se+1]=8,se++,L[8]++;for(;se<=255;)z[2*se+1]=9,se++,L[9]++;for(;se<=279;)z[2*se+1]=7,se++,L[7]++;for(;se<=287;)z[2*se+1]=8,se++,L[8]++;for(Q(z,g+1,L),se=0;se<p;se++)I[2*se+1]=5,I[2*se]=pe(se,5);K=new Z(z,N,f+1,g,x),G=new Z(I,O,0,p,x),J=new Z(new Array(0),k,0,b,E)})(),ie=!0),Y.l_desc=new F(Y.dyn_ltree,K),Y.d_desc=new F(Y.dyn_dtree,G),Y.bl_desc=new F(Y.bl_tree,J),Y.bi_buf=0,Y.bi_valid=0,Ee(Y)},i._tr_stored_block=H,i._tr_flush_block=function(Y,se,ve,Ne){var Se,U,L=0;0<Y.level?(Y.strm.data_type===2&&(Y.strm.data_type=(function(te){var ye,Me=4093624447;for(ye=0;ye<=31;ye++,Me>>>=1)if(1&Me&&te.dyn_ltree[2*ye]!==0)return s;if(te.dyn_ltree[18]!==0||te.dyn_ltree[20]!==0||te.dyn_ltree[26]!==0)return l;for(ye=32;ye<f;ye++)if(te.dyn_ltree[2*ye]!==0)return l;return s})(Y)),at(Y,Y.l_desc),at(Y,Y.d_desc),L=(function(te){var ye;for(B(te,te.dyn_ltree,te.l_desc.max_code),B(te,te.dyn_dtree,te.d_desc.max_code),at(te,te.bl_desc),ye=b-1;3<=ye&&te.bl_tree[2*j[ye]+1]===0;ye--);return te.opt_len+=3*(ye+1)+5+5+4,ye})(Y),Se=Y.opt_len+3+7>>>3,(U=Y.static_len+3+7>>>3)<=Se&&(Se=U)):Se=U=ve+5,ve+4<=Se&&se!==-1?H(Y,se,ve,Ne):Y.strategy===4||U===Se?(le(Y,2+(Ne?1:0),3),fe(Y,z,I)):(le(Y,4+(Ne?1:0),3),(function(te,ye,Me,be){var qe;for(le(te,ye-257,5),le(te,Me-1,5),le(te,be-4,4),qe=0;qe<be;qe++)le(te,te.bl_tree[2*j[qe]+1],3);$(te,te.dyn_ltree,ye-1),$(te,te.dyn_dtree,Me-1)})(Y,Y.l_desc.max_code+1,Y.d_desc.max_code+1,L+1),fe(Y,Y.dyn_ltree,Y.dyn_dtree)),Ee(Y),Ne&&he(Y)},i._tr_tally=function(Y,se,ve){return Y.pending_buf[Y.d_buf+2*Y.last_lit]=se>>>8&255,Y.pending_buf[Y.d_buf+2*Y.last_lit+1]=255&se,Y.pending_buf[Y.l_buf+Y.last_lit]=255&ve,Y.last_lit++,se===0?Y.dyn_ltree[2*ve]++:(Y.matches++,se--,Y.dyn_ltree[2*(R[ve]+f+1)]++,Y.dyn_dtree[2*V(se)]++),Y.last_lit===Y.lit_bufsize-1},i._tr_align=function(Y){le(Y,2,3),oe(Y,w,z),(function(se){se.bi_valid===16?(ne(se,se.bi_buf),se.bi_buf=0,se.bi_valid=0):8<=se.bi_valid&&(se.pending_buf[se.pending++]=255&se.bi_buf,se.bi_buf>>=8,se.bi_valid-=8)})(Y)}},{"../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={},b=!1,v=s.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(s);x=x&&x.setTimeout?x: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)},x.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++},x.clearImmediate=y}function y(A){delete p[A]}function E(A){if(b)setTimeout(E,0,A);else{var T=p[A];if(T){b=!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{y(A),b=!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)})})(fC)),fC.exports}var rOe=nOe();const iOe=vo(rOe);function aOe(t){const e=new mi;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 w$=aOe;async function S$(t,e=0){const n=[],r=t.getElementsByTagName("mesh");for(let i=0;i<r.length;i++){const a=r[i],s=[],l=[],c=a.getElementsByTagName("vertex");for(let d=0;d<c.length;d++){const f=c[d];s.push(parseFloat(f.getAttribute("x")||"0"),parseFloat(f.getAttribute("y")||"0"),parseFloat(f.getAttribute("z")||"0"))}const u=a.getElementsByTagName("triangle");for(let d=0;d<u.length;d++){const f=u[d];l.push(parseInt(f.getAttribute("v1")||"0"),parseInt(f.getAttribute("v2")||"0"),parseInt(f.getAttribute("v3")||"0"))}s.length>0&&l.length>0&&n.push({vertices:s,triangles:l,extruder:e})}return n}async function sOe(t){const e=await iOe.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(p){const b=p.startsWith("/")?p.slice(1):p,v=e.files[b];if(!v)return null;const x=await v.async("string");return i.parseFromString(x,"application/xml")}const s=new Map,l=new Map,c=e.files["Metadata/model_settings.config"];if(c)try{const p=await c.async("string"),v=i.parseFromString(p,"application/xml").getElementsByTagName("object");for(let x=0;x<v.length;x++){const y=v[x],E=y.getAttribute("id");if(!E)continue;const w=Array.from(y.children).filter(T=>T.tagName==="metadata"&&T.getAttribute("key")==="extruder");if(w.length>0){const T=w[0].getAttribute("value");T&&s.set(E,Math.max(0,parseInt(T,10)-1))}const A=y.getElementsByTagName("part");for(let T=0;T<A.length;T++){const C=A[T],N=C.getAttribute("id");if(!N)continue;const O=Array.from(C.children).filter(k=>k.tagName==="metadata"&&k.getAttribute("key")==="extruder");if(O.length>0){const k=O[0].getAttribute("value");k&&l.set(`${E}:${N}`,Math.max(0,parseInt(k,10)-1))}}}}catch{}const u=Object.keys(e.files).find(p=>p==="3D/3dmodel.model"||p.endsWith("/3dmodel.model"));if(!u){const p=Object.keys(e.files).find(b=>b.endsWith(".model"));if(p){const b=await a(p);if(b){const v=await S$(b,0);v.length>0&&n.set("1",{id:"1",meshes:v,defaultExtruder:0})}}return{objects:n,buildItems:r}}const d=await a(u);if(!d)return{objects:n,buildItems:r};const f=d.getElementsByTagName("object");for(let p=0;p<f.length;p++){const b=f[p],v=b.getAttribute("id");if(!v)continue;let x=s.get(v)??-1;if(x<0){const A=b.getAttribute("p:extruder")||b.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";x=Math.max(0,parseInt(A,10)-1)}const y=[],E=b.getElementsByTagName("mesh");for(let A=0;A<E.length;A++){const T=E[A],C=[],N=[],O=T.getElementsByTagName("vertex");for(let j=0;j<O.length;j++){const z=O[j];C.push(parseFloat(z.getAttribute("x")||"0"),parseFloat(z.getAttribute("y")||"0"),parseFloat(z.getAttribute("z")||"0"))}const k=T.getElementsByTagName("triangle");for(let j=0;j<k.length;j++){const z=k[j];N.push(parseInt(z.getAttribute("v1")||"0"),parseInt(z.getAttribute("v2")||"0"),parseInt(z.getAttribute("v3")||"0"))}C.length>0&&N.length>0&&y.push({vertices:C,triangles:N,extruder:x})}const w=b.getElementsByTagName("component");for(let A=0;A<w.length;A++){const T=w[A],C=T.getAttribute("p:path")||T.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),N=T.getAttribute("objectid");if(C){const O=await a(C);if(O){const k=N?`${v}:${N}`:null,j=k?l.get(k)??x:x,z=await S$(O,j),I=T.getAttribute("transform"),q=w$(I);for(const R of z)if(I){const W=[];for(let K=0;K<R.vertices.length;K+=3){const G=new it(R.vertices[K],R.vertices[K+1],R.vertices[K+2]);G.applyMatrix4(q),W.push(G.x,G.y,G.z)}y.push({vertices:W,triangles:R.triangles,extruder:R.extruder})}else y.push(R)}}}y.length>0&&n.set(v,{id:v,meshes:y,defaultExtruder:x})}const g=d.getElementsByTagName("build");if(g.length>0){const p=g[0].getElementsByTagName("item");for(let b=0;b<p.length;b++){const v=p[b],x=v.getAttribute("objectid");if(!x)continue;const y=w$(v.getAttribute("transform"));r.push({objectId:x,transform:y})}}return{objects:n,buildItems:r}}function M$(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 ho(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function oOe({url: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=S.useRef(null),c=S.useRef(null),[u,d]=S.useState(!0),[f,g]=S.useState(null);S.useEffect(()=>{if(!i.current)return;const v=i.current,x=v.clientWidth,y=v.clientHeight,E=new Fke;E.background=new Nn(1710618),s.current=E;const w=new no(45,x/y,.1,1e4);w.position.set(150,150,150),l.current=w;const A=new zDe({antialias:!0});A.setSize(x,y),A.setPixelRatio(window.devicePixelRatio),v.appendChild(A.domElement),a.current=A;const T=new HDe(w,A.domElement);T.enableDamping=!0,T.dampingFactor=.05,c.current=T;const C=new Yke(16777215,.6);E.add(C);const N=new WH(16777215,.8);N.position.set(100,100,100),E.add(N);const O=new WH(16777215,.4);O.position.set(-100,50,-100),E.add(O);const k=Math.max(e.x,e.y),j=Math.ceil(k/16),z=new Qke(k,j,4473924,3355443);E.add(z);const I=new zO(e.x,e.y),q=new IO({color:44610,transparent:!0,opacity:.15,side:dl}),R=new Tl(I,q);R.rotation.x=-Math.PI/2,R.position.y=-.5,E.add(R);let W;const K=()=>{W=requestAnimationFrame(K),T.update(),A.render(E,w)};K(),fetch(t).then(J=>{if(!J.ok)throw new Error("Failed to load file");return J.arrayBuffer()}).then(sOe).then(({objects:J,buildItems:ee})=>{if(J.size===0)throw new Error("No meshes found in 3MF file");const Z=ue=>{const fe=n?.[ue]||"#00ae42",at=new Nn(fe);return new Gke({color:at,shininess:30,flatShading:!1})},F=new Xx,V=new Map;if(ee.length>0)for(const ue of ee){const Ae=J.get(ue.objectId);if(Ae)for(const fe of Ae.meshes){const at=ue.extruder??fe.extruder,B=[];for(let ie=0;ie<fe.vertices.length;ie+=3){const H=new it(fe.vertices[ie],fe.vertices[ie+1],fe.vertices[ie+2]);H.applyMatrix4(ue.transform),B.push(H.x,H.y,H.z)}const $=M$({vertices:B,triangles:fe.triangles});V.has(at)||V.set(at,[]),V.get(at).push($)}}else for(const ue of J.values())for(const Ae of ue.meshes){const fe=Ae.extruder,at=M$(Ae);V.has(fe)||V.set(fe,[]),V.get(fe).push(at)}for(const[ue,Ae]of V){if(Ae.length===0)continue;const fe=Ae.length===1?Ae[0]:tOe(Ae,!1);if(fe){const at=Z(ue),B=new Tl(fe,at);F.add(B)}if(Ae.length>1)for(const at of Ae)at.dispose()}const ne=new xf().setFromObject(F),le=ne.getCenter(new it);F.position.y=-ne.min.y,ee.length===0&&(F.position.x=-le.x,F.position.z=-le.z),E.add(F);const oe=new xf().setFromObject(F),pe=oe.getCenter(new it),Q=oe.getSize(new it),he=Math.max(Q.x,Q.y,Q.z)*1.8;w.position.set(pe.x+he*.7,pe.y+he*.5,pe.z+he*.7),T.target.copy(pe),T.update(),d(!1)}).catch(J=>{g(J.message),d(!1)});const G=()=>{if(!v)return;const J=v.clientWidth,ee=v.clientHeight;w.aspect=J/ee,w.updateProjectionMatrix(),A.setSize(J,ee)};return window.addEventListener("resize",G),()=>{window.removeEventListener("resize",G),cancelAnimationFrame(W),T.dispose(),A.dispose(),v.removeChild(A.domElement)}},[t,e,n]);const p=()=>{l.current&&c.current&&(l.current.position.set(150,150,150),c.current.target.set(0,50,0),c.current.update())},b=v=>{l.current&&l.current.position.multiplyScalar(v)};return o.jsxs("div",{className:`relative ${r}`,children:[o.jsx("div",{ref:i,className:"w-full h-full min-h-[400px]"}),u&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}),f&&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:f})}),!u&&!f&&o.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[o.jsx(Pe,{variant:"secondary",size:"sm",onClick:()=>b(.8),children:o.jsx(Fde,{className:"w-4 h-4"})}),o.jsx(Pe,{variant:"secondary",size:"sm",onClick:()=>b(1.25),children:o.jsx(Bde,{className:"w-4 h-4"})}),o.jsx(Pe,{variant:"secondary",size:"sm",onClick:p,children:o.jsx(sg,{className:"w-4 h-4"})})]})]})}const aE="159",Nm={ROTATE:0,DOLLY:1,PAN:2},Cm={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},lOe=0,E$=1,cOe=2,aQ=1,uOe=2,gc=3,Cd=0,rs=1,wc=2,dd=0,bp=1,A$=2,T$=3,N$=4,dOe=5,Sh=100,hOe=101,fOe=102,C$=103,k$=104,mOe=200,pOe=201,gOe=202,xOe=203,QP=204,JP=205,bOe=206,yOe=207,vOe=208,_Oe=209,wOe=210,SOe=211,MOe=212,EOe=213,AOe=214,TOe=0,NOe=1,COe=2,Zw=3,kOe=4,POe=5,jOe=6,ROe=7,HO=0,DOe=1,OOe=2,hd=0,LOe=1,IOe=2,FOe=3,UOe=4,zOe=5,sQ=300,$p=301,Vp=302,ej=303,tj=304,sE=306,nj=1e3,Lo=1001,rj=1002,aa=1003,P$=1004,mC=1005,ro=1006,BOe=1007,ib=1008,fd=1009,HOe=1010,$Oe=1011,$O=1012,oQ=1013,rd=1014,Cc=1015,ab=1016,lQ=1017,cQ=1018,$h=1020,VOe=1021,io=1023,GOe=1024,WOe=1025,Vh=1026,Gp=1027,qOe=1028,uQ=1029,KOe=1030,dQ=1031,hQ=1033,pC=33776,gC=33777,xC=33778,bC=33779,j$=35840,R$=35841,D$=35842,O$=35843,fQ=36196,L$=37492,I$=37496,F$=37808,U$=37809,z$=37810,B$=37811,H$=37812,$$=37813,V$=37814,G$=37815,W$=37816,q$=37817,K$=37818,X$=37819,Y$=37820,Z$=37821,yC=36492,Q$=36494,J$=36495,XOe=36283,eV=36284,tV=36285,nV=36286,mQ=3e3,Gh=3001,YOe=3200,ZOe=3201,pQ=0,QOe=1,ao="",sa="srgb",Zc="srgb-linear",VO="display-p3",oE="display-p3-linear",Qw="linear",Sr="srgb",Jw="rec709",eS="p3",km=7680,rV=519,JOe=512,eLe=513,tLe=514,gQ=515,nLe=516,rLe=517,iLe=518,aLe=519,ij=35044,iV="300 es",aj=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 pa=["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 aV=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(pa[t&255]+pa[t>>8&255]+pa[t>>16&255]+pa[t>>24&255]+"-"+pa[e&255]+pa[e>>8&255]+"-"+pa[e>>16&15|64]+pa[e>>24&255]+"-"+pa[n&63|128]+pa[n>>8&255]+"-"+pa[n>>16&255]+pa[n>>24&255]+pa[r&255]+pa[r>>8&255]+pa[r>>16&255]+pa[r>>24&255]).toLowerCase()}function oa(t,e,n){return Math.max(e,Math.min(n,t))}function GO(t,e){return(t%e+e)%e}function sLe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function oLe(t,e,n){return t!==e?(n-t)/(e-t):0}function u0(t,e,n){return(1-n)*t+n*e}function lLe(t,e,n,r){return u0(t,e,1-Math.exp(-n*r))}function cLe(t,e=1){return e-Math.abs(GO(t,e*2)-e)}function uLe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function dLe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function hLe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function fLe(t,e){return t+Math.random()*(e-t)}function mLe(t){return t*(.5-Math.random())}function pLe(t){t!==void 0&&(aV=t);let e=aV+=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 gLe(t){return t*c0}function xLe(t){return t*ob}function sj(t){return(t&t-1)===0&&t!==0}function bLe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function tS(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function yLe(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),b=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*b,c*p,l*u);break;case"YXY":t.set(c*p,l*d,c*b,l*u);break;case"ZYZ":t.set(c*b,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 xQ={DEG2RAD:c0,RAD2DEG:ob,generateUUID:Lc,clamp:oa,euclideanModulo:GO,mapLinear:sLe,inverseLerp:oLe,lerp:u0,damp:lLe,pingpong:cLe,smoothstep:uLe,smootherstep:dLe,randInt:hLe,randFloat:fLe,randFloatSpread:mLe,seededRandom:pLe,degToRad:gLe,radToDeg:xLe,isPowerOfTwo:sj,ceilPowerOfTwo:bLe,floorPowerOfTwo:tS,setQuaternionFromProperEuler:yLe,normalize:sr,denormalize:hl};class rn{constructor(e=0,n=0){rn.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(oa(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 Mn{constructor(e,n,r,i,a,s,l,c,u){Mn.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],b=r[8],v=i[0],x=i[3],y=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*x+l*w+c*C,a[6]=s*y+l*A+c*N,a[1]=u*v+d*E+f*T,a[4]=u*x+d*w+f*C,a[7]=u*y+d*A+f*N,a[2]=g*v+p*E+b*T,a[5]=g*x+p*w+b*C,a[8]=g*y+p*A+b*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,b=n*f+r*g+i*p;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/b;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(vC.makeScale(e,n)),this}rotate(e){return this.premultiply(vC.makeRotation(-e)),this}translate(e,n){return this.premultiply(vC.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 vC=new Mn;function bQ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function nS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function vLe(){const t=nS("canvas");return t.style.display="block",t}const sV={};function d0(t){t in sV||(sV[t]=!0,console.warn(t))}const oV=new Mn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),lV=new Mn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),b_={[Zc]:{transfer:Qw,primaries:Jw,toReference:t=>t,fromReference:t=>t},[sa]:{transfer:Sr,primaries:Jw,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[oE]:{transfer:Qw,primaries:eS,toReference:t=>t.applyMatrix3(lV),fromReference:t=>t.applyMatrix3(oV)},[VO]:{transfer:Sr,primaries:eS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(lV),fromReference:t=>t.applyMatrix3(oV).convertLinearToSRGB()}},_Le=new Set([Zc,oE]),or={enabled:!0,_workingColorSpace:Zc,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(!_Le.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===ao?Qw:b_[t].transfer}};function yp(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function _C(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Pm;class yQ{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=nS("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=nS("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 wLe=0;class vQ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:wLe++}),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(wC(i[s].image)):a.push(wC(i[s]))}else a=wC(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function wC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?yQ.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 SLe=0;class is extends Cf{constructor(e=is.DEFAULT_IMAGE,n=is.DEFAULT_MAPPING,r=Lo,i=Lo,a=ro,s=ib,l=io,c=fd,u=is.DEFAULT_ANISOTROPY,d=ao){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:SLe++}),this.uuid=Lc(),this.name="",this.source=new vQ(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 rn(0,0),this.repeat=new rn(1,1),this.center=new rn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Mn,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===Gh?sa:ao),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!==sQ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case nj:e.x=e.x-Math.floor(e.x);break;case Lo:e.x=e.x<0?0:1;break;case rj: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 nj:e.y=e.y-Math.floor(e.y);break;case Lo:e.y=e.y<0?0:1;break;case rj: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===sa?Gh:mQ}set encoding(e){d0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Gh?sa:ao}}is.DEFAULT_IMAGE=null;is.DEFAULT_MAPPING=sQ;is.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],b=c[9],v=c[2],x=c[6],y=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-v)<.01&&Math.abs(b-x)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+v)<.1&&Math.abs(b+x)<.1&&Math.abs(u+p+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(u+1)/2,A=(p+1)/2,T=(y+1)/2,C=(d+g)/4,N=(f+v)/4,O=(b+x)/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((x-b)*(x-b)+(f-v)*(f-v)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(x-b)/E,this.y=(f-v)/E,this.z=(g-d)/E,this.w=Math.acos((u+p+y-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 MLe 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===Gh?sa:ao),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ro,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new is(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 vQ(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 MLe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class _Q extends is{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=aa,this.minFilter=aa,this.wrapR=Lo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ELe extends is{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=aa,this.minFilter=aa,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],b=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]=b,e[n+3]=v;return}if(f!==v||c!==g||u!==p||d!==b){let x=1-l;const y=c*g+u*p+d*b+f*v,E=y>=0?1:-1,w=1-y*y;if(w>Number.EPSILON){const T=Math.sqrt(w),C=Math.atan2(T,y*E);x=Math.sin(x*C)/T,l=Math.sin(l*C)/T}const A=l*E;if(c=c*x+g*A,u=u*x+p*A,d=d*x+b*A,f=f*x+v*A,x===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],b=a[s+3];return e[n]=l*b+d*f+c*p-u*g,e[n+1]=c*b+d*g+u*f-l*p,e[n+2]=u*b+d*p+l*g-c*f,e[n+3]=d*b-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),b=c(a/2);switch(s){case"XYZ":this._x=g*d*f+u*p*b,this._y=u*p*f-g*d*b,this._z=u*d*b+g*p*f,this._w=u*d*f-g*p*b;break;case"YXZ":this._x=g*d*f+u*p*b,this._y=u*p*f-g*d*b,this._z=u*d*b-g*p*f,this._w=u*d*f+g*p*b;break;case"ZXY":this._x=g*d*f-u*p*b,this._y=u*p*f+g*d*b,this._z=u*d*b+g*p*f,this._w=u*d*f-g*p*b;break;case"ZYX":this._x=g*d*f-u*p*b,this._y=u*p*f+g*d*b,this._z=u*d*b-g*p*f,this._w=u*d*f+g*p*b;break;case"YZX":this._x=g*d*f+u*p*b,this._y=u*p*f+g*d*b,this._z=u*d*b-g*p*f,this._w=u*d*f-g*p*b;break;case"XZY":this._x=g*d*f-u*p*b,this._y=u*p*f-g*d*b,this._z=u*d*b+g*p*f,this._w=u*d*f+g*p*b;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(oa(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 Le{constructor(e=0,n=0,r=0){Le.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(cV.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(cV.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 SC.copy(this).projectOnVector(e),this.sub(SC)}reflect(e){return this.sub(SC.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(oa(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 SC=new Le,cV=new yf;class fo{constructor(e=new Le(1/0,1/0,1/0),n=new Le(-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),Ru.subVectors(Rm,jm),Du.subVectors(Dm,Rm),ch.subVectors(jm,Dm);let n=[0,-Ru.z,Ru.y,0,-Du.z,Du.y,0,-ch.z,ch.y,Ru.z,0,-Ru.x,Du.z,0,-Du.x,ch.z,0,-ch.x,-Ru.y,Ru.x,0,-Du.y,Du.x,0,-ch.y,ch.x,0];return!MC(n,jm,Rm,Dm,v_)||(n=[1,0,0,0,1,0,0,0,1],!MC(n,jm,Rm,Dm,v_))?!1:(__.crossVectors(Ru,Du),n=[__.x,__.y,__.z],MC(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 Le,new Le,new Le,new Le,new Le,new Le,new Le,new Le],Co=new Le,y_=new fo,jm=new Le,Rm=new Le,Dm=new Le,Ru=new Le,Du=new Le,ch=new Le,Lx=new Le,v_=new Le,__=new Le,uh=new Le;function MC(t,e,n,r,i){for(let a=0,s=t.length-3;a<=s;a+=3){uh.fromArray(t,a);const l=i.x*Math.abs(uh.x)+i.y*Math.abs(uh.y)+i.z*Math.abs(uh.z),c=e.dot(uh),u=n.dot(uh),d=r.dot(uh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const ALe=new fo,Ix=new Le,EC=new Le;class bl{constructor(e=new Le,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):ALe.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):(EC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ix.copy(e.center).add(EC)),this.expandByPoint(Ix.copy(e.center).sub(EC))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const lc=new Le,AC=new Le,w_=new Le,Ou=new Le,TC=new Le,S_=new Le,NC=new Le;class WO{constructor(e=new Le,n=new Le(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){AC.copy(e).add(n).multiplyScalar(.5),w_.copy(n).sub(e).normalize(),Ou.copy(this.origin).sub(AC);const a=e.distanceTo(n)*.5,s=-this.direction.dot(w_),l=Ou.dot(this.direction),c=-Ou.dot(w_),u=Ou.lengthSq(),d=Math.abs(1-s*s);let f,g,p,b;if(d>0)if(f=s*c-l,g=s*l-c,b=a*d,f>=0)if(g>=-b)if(g<=b){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<=-b?(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<=b?(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(AC).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){TC.subVectors(n,e),S_.subVectors(r,e),NC.crossVectors(TC,S_);let s=this.direction.dot(NC),l;if(s>0){if(i)return null;l=1}else if(s<0)l=-1,s=-s;else return null;Ou.subVectors(this.origin,e);const c=l*this.direction.dot(S_.crossVectors(Ou,S_));if(c<0)return null;const u=l*this.direction.dot(TC.cross(Ou));if(u<0||c+u>s)return null;const d=-l*Ou.dot(NC);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,b,v,x){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,b,v,x)}set(e,n,r,i,a,s,l,c,u,d,f,g,p,b,v,x){const y=this.elements;return y[0]=e,y[4]=n,y[8]=r,y[12]=i,y[1]=a,y[5]=s,y[9]=l,y[13]=c,y[2]=u,y[6]=d,y[10]=f,y[14]=g,y[3]=p,y[7]=b,y[11]=v,y[15]=x,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,b=l*d,v=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+b*u,n[5]=g-v*u,n[9]=-l*c,n[2]=v-g*u,n[6]=b+p*u,n[10]=s*c}else if(e.order==="YXZ"){const g=c*d,p=c*f,b=u*d,v=u*f;n[0]=g+v*l,n[4]=b*l-p,n[8]=s*u,n[1]=s*f,n[5]=s*d,n[9]=-l,n[2]=p*l-b,n[6]=v+g*l,n[10]=s*c}else if(e.order==="ZXY"){const g=c*d,p=c*f,b=u*d,v=u*f;n[0]=g-v*l,n[4]=-s*f,n[8]=b+p*l,n[1]=p+b*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,b=l*d,v=l*f;n[0]=c*d,n[4]=b*u-p,n[8]=g*u+v,n[1]=c*f,n[5]=v*u+g,n[9]=p*u-b,n[2]=-u,n[6]=l*c,n[10]=s*c}else if(e.order==="YZX"){const g=s*c,p=s*u,b=l*c,v=l*u;n[0]=c*d,n[4]=v-g*f,n[8]=b*f+p,n[1]=f,n[5]=s*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+b,n[10]=g-v*f}else if(e.order==="XZY"){const g=s*c,p=s*u,b=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-b,n[2]=b*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(TLe,e,NLe)}lookAt(e,n,r){const i=this.elements;return vs.subVectors(e,n),vs.lengthSq()===0&&(vs.z=1),vs.normalize(),Lu.crossVectors(r,vs),Lu.lengthSq()===0&&(Math.abs(r.z)===1?vs.x+=1e-4:vs.z+=1e-4,vs.normalize(),Lu.crossVectors(r,vs)),Lu.normalize(),M_.crossVectors(vs,Lu),i[0]=Lu.x,i[4]=M_.x,i[8]=vs.x,i[1]=Lu.y,i[5]=M_.y,i[9]=vs.y,i[2]=Lu.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],b=r[2],v=r[6],x=r[10],y=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],z=i[5],I=i[9],q=i[13],R=i[2],W=i[6],K=i[10],G=i[14],J=i[3],ee=i[7],Z=i[11],F=i[15];return a[0]=s*C+l*j+c*R+u*J,a[4]=s*N+l*z+c*W+u*ee,a[8]=s*O+l*I+c*K+u*Z,a[12]=s*k+l*q+c*G+u*F,a[1]=d*C+f*j+g*R+p*J,a[5]=d*N+f*z+g*W+p*ee,a[9]=d*O+f*I+g*K+p*Z,a[13]=d*k+f*q+g*G+p*F,a[2]=b*C+v*j+x*R+y*J,a[6]=b*N+v*z+x*W+y*ee,a[10]=b*O+v*I+x*K+y*Z,a[14]=b*k+v*q+x*G+y*F,a[3]=E*C+w*j+A*R+T*J,a[7]=E*N+w*z+A*W+T*ee,a[11]=E*O+w*I+A*K+T*Z,a[15]=E*k+w*q+A*G+T*F,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],b=e[3],v=e[7],x=e[11],y=e[15];return b*(+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)+x*(+n*u*f-n*l*p-a*s*f+r*s*p+a*l*d-r*u*d)+y*(-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],b=e[12],v=e[13],x=e[14],y=e[15],E=f*x*u-v*g*u+v*c*p-l*x*p-f*c*y+l*g*y,w=b*g*u-d*x*u-b*c*p+s*x*p+d*c*y-s*g*y,A=d*v*u-b*f*u+b*l*p-s*v*p-d*l*y+s*f*y,T=b*f*c-d*v*c-b*l*g+s*v*g+d*l*x-s*f*x,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*x*a-v*i*p+r*x*p+f*i*y-r*g*y)*N,e[2]=(l*x*a-v*c*a+v*i*u-r*x*u-l*i*y+r*c*y)*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*x*a-b*g*a+b*i*p-n*x*p-d*i*y+n*g*y)*N,e[6]=(b*c*a-s*x*a-b*i*u+n*x*u+s*i*y-n*c*y)*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]=(b*f*a-d*v*a-b*r*p+n*v*p+d*r*y-n*f*y)*N,e[10]=(s*v*a-b*l*a+b*r*u-n*v*u-s*r*y+n*l*y)*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-b*f*i+b*r*g-n*v*g-d*r*x+n*f*x)*N,e[14]=(b*l*i-s*v*i-b*r*c+n*v*c+s*r*x-n*l*x)*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,b=a*f,v=s*d,x=s*f,y=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+y))*T,i[1]=(p+A)*T,i[2]=(b-w)*T,i[3]=0,i[4]=(p-A)*C,i[5]=(1-(g+y))*C,i[6]=(x+E)*C,i[7]=0,i[8]=(b+w)*N,i[9]=(x-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,b;if(l===gl)p=-(s+a)/(s-a),b=-2*s*a/(s-a);else if(l===sb)p=-s/(s-a),b=-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]=b,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 b,v;if(l===gl)b=(s+a)*f,v=-2*f;else if(l===sb)b=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]=-b,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 Le,ko=new yr,TLe=new Le(0,0,0),NLe=new Le(1,1,1),Lu=new Le,M_=new Le,vs=new Le,uV=new yr,dV=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(oa(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(-oa(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(oa(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(-oa(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(oa(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(-oa(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 uV.makeRotationFromQuaternion(e),this.setFromRotationMatrix(uV,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return dV.setFromEuler(this),this.setFromQuaternion(dV,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 wQ{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 CLe=0;const hV=new Le,Lm=new yf,cc=new yr,E_=new Le,Fx=new Le,kLe=new Le,PLe=new yf,fV=new Le(1,0,0),mV=new Le(0,1,0),pV=new Le(0,0,1),jLe={type:"added"},RLe={type:"removed"};class La extends Cf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:CLe++}),this.uuid=Lc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=La.DEFAULT_UP.clone();const e=new Le,n=new sy,r=new yf,i=new Le(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 Mn}}),this.matrix=new yr,this.matrixWorld=new yr,this.matrixAutoUpdate=La.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=La.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new wQ,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(fV,e)}rotateY(e){return this.rotateOnAxis(mV,e)}rotateZ(e){return this.rotateOnAxis(pV,e)}translateOnAxis(e,n){return hV.copy(e).applyQuaternion(this.quaternion),this.position.add(hV.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(fV,e)}translateY(e){return this.translateOnAxis(mV,e)}translateZ(e){return this.translateOnAxis(pV,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(jLe)):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(RLe)),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,kLe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Fx,PLe,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),b=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),b.length>0&&(r.nodes=b)}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}}La.DEFAULT_UP=new Le(0,1,0);La.DEFAULT_MATRIX_AUTO_UPDATE=!0;La.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Po=new Le,uc=new Le,CC=new Le,dc=new Le,Im=new Le,Fm=new Le,gV=new Le,kC=new Le,PC=new Le,jC=new Le;let A_=!1;class jo{constructor(e=new Le,n=new Le,r=new Le){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),CC.subVectors(e,n);const s=Po.dot(Po),l=Po.dot(uc),c=Po.dot(CC),u=uc.dot(uc),d=uc.dot(CC),f=s*u-l*l;if(f===0)return a.set(-2,-1,-1);const g=1/f,p=(u*c-l*d)*g,b=(s*d-l*c)*g;return a.set(1-p-b,b,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),kC.subVectors(e,r);const c=Im.dot(kC),u=Fm.dot(kC);if(c<=0&&u<=0)return n.copy(r);PC.subVectors(e,i);const d=Im.dot(PC),f=Fm.dot(PC);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);jC.subVectors(e,a);const p=Im.dot(jC),b=Fm.dot(jC);if(b>=0&&p<=b)return n.copy(a);const v=p*u-c*b;if(v<=0&&u>=0&&b<=0)return l=u/(u-b),n.copy(r).addScaledVector(Fm,l);const x=d*b-p*f;if(x<=0&&f-d>=0&&p-b>=0)return gV.subVectors(a,i),l=(f-d)/(f-d+(p-b)),n.copy(i).addScaledVector(gV,l);const y=1/(x+v+g);return s=v*y,l=g*y,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 SQ={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},Iu={h:0,s:0,l:0},T_={h:0,s:0,l:0};function RC(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=sa){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=GO(e,1),n=oa(n,0,1),r=oa(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=RC(s,a,e+1/3),this.g=RC(s,a,e),this.b=RC(s,a,e-1/3)}return or.toWorkingColorSpace(this,i),this}setStyle(e,n=sa){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=sa){const r=SQ[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=_C(e.r),this.g=_C(e.g),this.b=_C(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=sa){return or.fromWorkingColorSpace(ga.copy(this),e),Math.round(oa(ga.r*255,0,255))*65536+Math.round(oa(ga.g*255,0,255))*256+Math.round(oa(ga.b*255,0,255))}getHexString(e=sa){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=or.workingColorSpace){or.fromWorkingColorSpace(ga.copy(this),n);const r=ga.r,i=ga.g,a=ga.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(ga.copy(this),n),e.r=ga.r,e.g=ga.g,e.b=ga.b,e}getStyle(e=sa){or.fromWorkingColorSpace(ga.copy(this),e);const n=ga.r,r=ga.g,i=ga.b;return e!==sa?`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(Iu),this.setHSL(Iu.h+e,Iu.s+n,Iu.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(Iu),e.getHSL(T_);const r=u0(Iu.h,T_.h,n),i=u0(Iu.s,T_.s,n),a=u0(Iu.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 ga=new Kt;Kt.NAMES=SQ;let DLe=0;class wg extends Cf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:DLe++}),this.uuid=Lc(),this.name="",this.type="Material",this.blending=bp,this.side=Cd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=QP,this.blendDst=JP,this.blendEquation=Sh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Kt(0,0,0),this.blendAlpha=0,this.depthFunc=Zw,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=rV,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!==Cd&&(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!==QP&&(r.blendSrc=this.blendSrc),this.blendDst!==JP&&(r.blendDst=this.blendDst),this.blendEquation!==Sh&&(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!==Zw&&(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!==rV&&(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 MQ 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=HO,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 Le,N_=new rn;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=ij,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!==ij&&(e.usage=this.usage),e}}class EQ extends Ps{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class AQ 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 OLe=0;const qs=new yr,DC=new La,Um=new Le,_s=new fo,Ux=new fo,Li=new Le;class Ea extends Cf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:OLe++}),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(bQ(e)?AQ:EQ)(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 Mn().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 qs.makeRotationFromQuaternion(e),this.applyMatrix4(qs),this}rotateX(e){return qs.makeRotationX(e),this.applyMatrix4(qs),this}rotateY(e){return qs.makeRotationY(e),this.applyMatrix4(qs),this}rotateZ(e){return qs.makeRotationZ(e),this.applyMatrix4(qs),this}translate(e,n,r){return qs.makeTranslation(e,n,r),this.applyMatrix4(qs),this}scale(e,n,r){return qs.makeScale(e,n,r),this.applyMatrix4(qs),this}lookAt(e){return DC.lookAt(e),DC.updateMatrix(),this.applyMatrix4(DC.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 fo);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 Le(-1/0,-1/0,-1/0),new Le(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?(Li.addVectors(this.boundingBox.min,_s.min),this.boundingBox.expandByPoint(Li),Li.addVectors(this.boundingBox.max,_s.max),this.boundingBox.expandByPoint(Li)):(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 Le,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?(Li.addVectors(_s.min,Ux.min),_s.expandByPoint(Li),Li.addVectors(_s.max,Ux.max),_s.expandByPoint(Li)):(_s.expandByPoint(Ux.min),_s.expandByPoint(Ux.max))}_s.getCenter(r);let i=0;for(let a=0,s=e.count;a<s;a++)Li.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Li));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++)Li.fromBufferAttribute(l,u),c&&(Um.fromBufferAttribute(e,u),Li.add(Um)),i=Math.max(i,r.distanceToSquared(Li))}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 Le,d[j]=new Le;const f=new Le,g=new Le,p=new Le,b=new rn,v=new rn,x=new rn,y=new Le,E=new Le;function w(j,z,I){f.fromArray(i,j*3),g.fromArray(i,z*3),p.fromArray(i,I*3),b.fromArray(s,j*2),v.fromArray(s,z*2),x.fromArray(s,I*2),g.sub(f),p.sub(f),v.sub(b),x.sub(b);const q=1/(v.x*x.y-x.x*v.y);isFinite(q)&&(y.copy(g).multiplyScalar(x.y).addScaledVector(p,-v.y).multiplyScalar(q),E.copy(p).multiplyScalar(v.x).addScaledVector(g,-x.x).multiplyScalar(q),u[j].add(y),u[z].add(y),u[I].add(y),d[j].add(E),d[z].add(E),d[I].add(E))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let j=0,z=A.length;j<z;++j){const I=A[j],q=I.start,R=I.count;for(let W=q,K=q+R;W<K;W+=3)w(r[W+0],r[W+1],r[W+2])}const T=new Le,C=new Le,N=new Le,O=new Le;function k(j){N.fromArray(a,j*3),O.copy(N);const z=u[j];T.copy(z),T.sub(N.multiplyScalar(N.dot(z))).normalize(),C.crossVectors(O,z);const q=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]=q}for(let j=0,z=A.length;j<z;++j){const I=A[j],q=I.start,R=I.count;for(let W=q,K=q+R;W<K;W+=3)k(r[W+0]),k(r[W+1]),k(r[W+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 Le,a=new Le,s=new Le,l=new Le,c=new Le,u=new Le,d=new Le,f=new Le;if(e)for(let g=0,p=e.count;g<p;g+=3){const b=e.getX(g+0),v=e.getX(g+1),x=e.getX(g+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,v),s.fromBufferAttribute(n,x),d.subVectors(s,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,b),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,x),l.add(d),c.add(d),u.add(d),r.setXYZ(b,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(x,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++)Li.fromBufferAttribute(e,n),Li.normalize(),e.setXYZ(n,Li.x,Li.y,Li.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,b=0;for(let v=0,x=c.length;v<x;v++){l.isInterleavedBufferAttribute?p=c[v]*l.data.stride+l.offset:p=c[v]*d;for(let y=0;y<d;y++)g[b++]=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 Ea,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 xV=new yr,dh=new WO,C_=new bl,bV=new Le,zm=new Le,Bm=new Le,Hm=new Le,OC=new Le,k_=new Le,P_=new rn,j_=new rn,R_=new rn,yV=new Le,vV=new Le,_V=new Le,D_=new Le,O_=new Le;class Uo extends La{constructor(e=new Ea,n=new MQ){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&&(OC.fromBufferAttribute(f,e),s?k_.addScaledVector(OC,d):k_.addScaledVector(OC.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),dh.copy(e.ray).recast(e.near),!(C_.containsPoint(dh.origin)===!1&&(dh.intersectSphere(C_,bV)===null||dh.origin.distanceToSquared(bV)>(e.far-e.near)**2))&&(xV.copy(a).invert(),dh.copy(e.ray).applyMatrix4(xV),!(r.boundingBox!==null&&dh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,dh)))}_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 b=0,v=g.length;b<v;b++){const x=g[b],y=s[x.materialIndex],E=Math.max(x.start,p.start),w=Math.min(l.count,Math.min(x.start+x.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,y,e,r,u,d,f,C,N,O),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let x=b,y=v;x<y;x+=3){const E=l.getX(x),w=l.getX(x+1),A=l.getX(x+2);i=L_(this,s,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(s))for(let b=0,v=g.length;b<v;b++){const x=g[b],y=s[x.materialIndex],E=Math.max(x.start,p.start),w=Math.min(c.count,Math.min(x.start+x.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,y,e,r,u,d,f,C,N,O),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let x=b,y=v;x<y;x+=3){const E=x,w=x+1,A=x+2;i=L_(this,s,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}}}function LLe(t,e,n,r,i,a,s,l){let c;if(e.side===rs?c=r.intersectTriangle(s,a,i,!0,l):c=r.intersectTriangle(i,a,s,e.side===Cd,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=LLe(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 rn)),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 rn),d.uv2=d.uv1),s&&(yV.fromBufferAttribute(s,l),vV.fromBufferAttribute(s,c),_V.fromBufferAttribute(s,u),d.normal=jo.getInterpolation(D_,zm,Bm,Hm,yV,vV,_V,new Le),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new Le,materialIndex:0};jo.getNormal(zm,Bm,Hm,f.normal),d.face=f}return d}class oy extends Ea{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;b("z","y","x",-1,-1,r,n,e,s,a,0),b("z","y","x",1,-1,r,n,-e,s,a,1),b("x","z","y",1,1,e,r,n,i,s,2),b("x","z","y",1,-1,e,r,-n,i,s,3),b("x","y","z",1,-1,e,n,r,i,a,4),b("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 b(v,x,y,E,w,A,T,C,N,O,k){const j=A/N,z=T/O,I=A/2,q=T/2,R=C/2,W=N+1,K=O+1;let G=0,J=0;const ee=new Le;for(let Z=0;Z<K;Z++){const F=Z*z-q;for(let V=0;V<W;V++){const ne=V*j-I;ee[v]=ne*E,ee[x]=F*w,ee[y]=R,u.push(ee.x,ee.y,ee.z),ee[v]=0,ee[x]=0,ee[y]=C>0?1:-1,d.push(ee.x,ee.y,ee.z),f.push(V/N),f.push(1-Z/O),G+=1}}for(let Z=0;Z<O;Z++)for(let F=0;F<N;F++){const V=g+F+W*Z,ne=g+F+W*(Z+1),le=g+(F+1)+W*(Z+1),oe=g+(F+1)+W*Z;c.push(V,ne,oe),c.push(ne,le,oe),J+=6}l.addGroup(p,J,k),p+=J,g+=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 ka(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 ILe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function TQ(t){return t.getRenderTarget()===null?t.outputColorSpace:or.workingColorSpace}const qO={clone:Wp,merge:ka};var FLe=`void main() {
  3920. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3921. }`,ULe=`void main() {
  3922. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3923. }`;class kd extends wg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=FLe,this.fragmentShader=ULe,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=ILe(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 NQ extends La{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 NQ{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 zLe extends La{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(),b=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=b,r.texture.needsPMREMUpdate=!0}}class CQ extends is{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 BLe 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===Gh?sa:ao),this.texture=new CQ(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:ro}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:`
  3924. varying vec3 vWorldDirection;
  3925. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  3926. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  3927. }
  3928. void main() {
  3929. vWorldDirection = transformDirection( position, modelMatrix );
  3930. #include <begin_vertex>
  3931. #include <project_vertex>
  3932. }
  3933. `,fragmentShader:`
  3934. uniform sampler2D tEquirect;
  3935. varying vec3 vWorldDirection;
  3936. #include <common>
  3937. void main() {
  3938. vec3 direction = normalize( vWorldDirection );
  3939. vec2 sampleUV = equirectUv( direction );
  3940. gl_FragColor = texture2D( tEquirect, sampleUV );
  3941. }
  3942. `},i=new oy(5,5,5),a=new kd({name:"CubemapFromEquirect",uniforms:Wp(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:rs,blending:dd});a.uniforms.tEquirect.value=n;const s=new Uo(i,a),l=n.minFilter;return n.minFilter===ib&&(n.minFilter=ro),new zLe(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 LC=new Le,HLe=new Le,$Le=new Mn;class Wu{constructor(e=new Le(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=LC.subVectors(r,n).cross(HLe.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(LC),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||$Le.getNormalMatrix(e),i=this.coplanarPoint(LC).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 hh=new bl,I_=new Le;class lE{constructor(e=new Wu,n=new Wu,r=new Wu,i=new Wu,a=new Wu,s=new Wu){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],b=i[9],v=i[10],x=i[11],y=i[12],E=i[13],w=i[14],A=i[15];if(r[0].setComponents(c-a,g-u,x-p,A-y).normalize(),r[1].setComponents(c+a,g+u,x+p,A+y).normalize(),r[2].setComponents(c+s,g+d,x+b,A+E).normalize(),r[3].setComponents(c-s,g-d,x-b,A-E).normalize(),r[4].setComponents(c-l,g-f,x-v,A-w).normalize(),n===gl)r[5].setComponents(c+l,g+f,x+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(),hh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),hh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(hh)}intersectsSprite(e){return hh.center.set(0,0,0),hh.radius=.7071067811865476,hh.applyMatrix4(e.matrixWorld),this.intersectsSphere(hh)}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 kQ(){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 VLe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,g=u.usage,p=f.byteLength,b=t.createBuffer();t.bindBuffer(d,b),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:b,type:v,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:p}}function a(u,d,f){const g=d.array,p=d._updateRange,b=d.updateRanges;if(t.bindBuffer(f,u),p.count===-1&&b.length===0&&t.bufferSubData(f,0,g),b.length!==0){for(let v=0,x=b.length;v<x;v++){const y=b[v];n?t.bufferSubData(f,y.start*g.BYTES_PER_ELEMENT,g,y.start,y.count):t.bufferSubData(f,y.start*g.BYTES_PER_ELEMENT,g.subarray(y.start,y.start+y.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 KO extends Ea{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=[],b=[],v=[],x=[];for(let y=0;y<d;y++){const E=y*g-s;for(let w=0;w<u;w++){const A=w*f-a;b.push(A,-E,0),v.push(0,0,1),x.push(w/l),x.push(1-y/c)}}for(let y=0;y<c;y++)for(let E=0;E<l;E++){const w=E+u*y,A=E+u*(y+1),T=E+1+u*(y+1),C=E+1+u*y;p.push(w,A,C),p.push(A,T,C)}this.setIndex(p),this.setAttribute("position",new ei(b,3)),this.setAttribute("normal",new ei(v,3)),this.setAttribute("uv",new ei(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new KO(e.width,e.height,e.widthSegments,e.heightSegments)}}var GLe=`#ifdef USE_ALPHAHASH
  3943. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3944. #endif`,WLe=`#ifdef USE_ALPHAHASH
  3945. const float ALPHA_HASH_SCALE = 0.05;
  3946. float hash2D( vec2 value ) {
  3947. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  3948. }
  3949. float hash3D( vec3 value ) {
  3950. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  3951. }
  3952. float getAlphaHashThreshold( vec3 position ) {
  3953. float maxDeriv = max(
  3954. length( dFdx( position.xyz ) ),
  3955. length( dFdy( position.xyz ) )
  3956. );
  3957. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  3958. vec2 pixScales = vec2(
  3959. exp2( floor( log2( pixScale ) ) ),
  3960. exp2( ceil( log2( pixScale ) ) )
  3961. );
  3962. vec2 alpha = vec2(
  3963. hash3D( floor( pixScales.x * position.xyz ) ),
  3964. hash3D( floor( pixScales.y * position.xyz ) )
  3965. );
  3966. float lerpFactor = fract( log2( pixScale ) );
  3967. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  3968. float a = min( lerpFactor, 1.0 - lerpFactor );
  3969. vec3 cases = vec3(
  3970. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  3971. ( x - 0.5 * a ) / ( 1.0 - a ),
  3972. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  3973. );
  3974. float threshold = ( x < ( 1.0 - a ) )
  3975. ? ( ( x < a ) ? cases.x : cases.y )
  3976. : cases.z;
  3977. return clamp( threshold , 1.0e-6, 1.0 );
  3978. }
  3979. #endif`,qLe=`#ifdef USE_ALPHAMAP
  3980. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  3981. #endif`,KLe=`#ifdef USE_ALPHAMAP
  3982. uniform sampler2D alphaMap;
  3983. #endif`,XLe=`#ifdef USE_ALPHATEST
  3984. if ( diffuseColor.a < alphaTest ) discard;
  3985. #endif`,YLe=`#ifdef USE_ALPHATEST
  3986. uniform float alphaTest;
  3987. #endif`,ZLe=`#ifdef USE_AOMAP
  3988. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  3989. reflectedLight.indirectDiffuse *= ambientOcclusion;
  3990. #if defined( USE_CLEARCOAT )
  3991. clearcoatSpecularIndirect *= ambientOcclusion;
  3992. #endif
  3993. #if defined( USE_SHEEN )
  3994. sheenSpecularIndirect *= ambientOcclusion;
  3995. #endif
  3996. #if defined( USE_ENVMAP ) && defined( STANDARD )
  3997. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  3998. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  3999. #endif
  4000. #endif`,QLe=`#ifdef USE_AOMAP
  4001. uniform sampler2D aoMap;
  4002. uniform float aoMapIntensity;
  4003. #endif`,JLe=`#ifdef USE_BATCHING
  4004. attribute float batchId;
  4005. uniform highp sampler2D batchingTexture;
  4006. mat4 getBatchingMatrix( const in float i ) {
  4007. int size = textureSize( batchingTexture, 0 ).x;
  4008. int j = int( i ) * 4;
  4009. int x = j % size;
  4010. int y = j / size;
  4011. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  4012. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  4013. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  4014. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  4015. return mat4( v1, v2, v3, v4 );
  4016. }
  4017. #endif`,e4e=`#ifdef USE_BATCHING
  4018. mat4 batchingMatrix = getBatchingMatrix( batchId );
  4019. #endif`,t4e=`vec3 transformed = vec3( position );
  4020. #ifdef USE_ALPHAHASH
  4021. vPosition = vec3( position );
  4022. #endif`,n4e=`vec3 objectNormal = vec3( normal );
  4023. #ifdef USE_TANGENT
  4024. vec3 objectTangent = vec3( tangent.xyz );
  4025. #endif`,r4e=`float G_BlinnPhong_Implicit( ) {
  4026. return 0.25;
  4027. }
  4028. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  4029. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  4030. }
  4031. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  4032. vec3 halfDir = normalize( lightDir + viewDir );
  4033. float dotNH = saturate( dot( normal, halfDir ) );
  4034. float dotVH = saturate( dot( viewDir, halfDir ) );
  4035. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  4036. float G = G_BlinnPhong_Implicit( );
  4037. float D = D_BlinnPhong( shininess, dotNH );
  4038. return F * ( G * D );
  4039. } // validated`,i4e=`#ifdef USE_IRIDESCENCE
  4040. const mat3 XYZ_TO_REC709 = mat3(
  4041. 3.2404542, -0.9692660, 0.0556434,
  4042. -1.5371385, 1.8760108, -0.2040259,
  4043. -0.4985314, 0.0415560, 1.0572252
  4044. );
  4045. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  4046. vec3 sqrtF0 = sqrt( fresnel0 );
  4047. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  4048. }
  4049. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  4050. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  4051. }
  4052. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  4053. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  4054. }
  4055. vec3 evalSensitivity( float OPD, vec3 shift ) {
  4056. float phase = 2.0 * PI * OPD * 1.0e-9;
  4057. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  4058. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  4059. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  4060. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  4061. 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 ) );
  4062. xyz /= 1.0685e-7;
  4063. vec3 rgb = XYZ_TO_REC709 * xyz;
  4064. return rgb;
  4065. }
  4066. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  4067. vec3 I;
  4068. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  4069. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  4070. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  4071. if ( cosTheta2Sq < 0.0 ) {
  4072. return vec3( 1.0 );
  4073. }
  4074. float cosTheta2 = sqrt( cosTheta2Sq );
  4075. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  4076. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  4077. float T121 = 1.0 - R12;
  4078. float phi12 = 0.0;
  4079. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  4080. float phi21 = PI - phi12;
  4081. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  4082. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  4083. vec3 phi23 = vec3( 0.0 );
  4084. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  4085. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  4086. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  4087. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  4088. vec3 phi = vec3( phi21 ) + phi23;
  4089. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  4090. vec3 r123 = sqrt( R123 );
  4091. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  4092. vec3 C0 = R12 + Rs;
  4093. I = C0;
  4094. vec3 Cm = Rs - T121;
  4095. for ( int m = 1; m <= 2; ++ m ) {
  4096. Cm *= r123;
  4097. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  4098. I += Cm * Sm;
  4099. }
  4100. return max( I, vec3( 0.0 ) );
  4101. }
  4102. #endif`,a4e=`#ifdef USE_BUMPMAP
  4103. uniform sampler2D bumpMap;
  4104. uniform float bumpScale;
  4105. vec2 dHdxy_fwd() {
  4106. vec2 dSTdx = dFdx( vBumpMapUv );
  4107. vec2 dSTdy = dFdy( vBumpMapUv );
  4108. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  4109. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  4110. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  4111. return vec2( dBx, dBy );
  4112. }
  4113. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  4114. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  4115. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  4116. vec3 vN = surf_norm;
  4117. vec3 R1 = cross( vSigmaY, vN );
  4118. vec3 R2 = cross( vN, vSigmaX );
  4119. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  4120. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  4121. return normalize( abs( fDet ) * surf_norm - vGrad );
  4122. }
  4123. #endif`,s4e=`#if NUM_CLIPPING_PLANES > 0
  4124. vec4 plane;
  4125. #pragma unroll_loop_start
  4126. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  4127. plane = clippingPlanes[ i ];
  4128. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  4129. }
  4130. #pragma unroll_loop_end
  4131. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  4132. bool clipped = true;
  4133. #pragma unroll_loop_start
  4134. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  4135. plane = clippingPlanes[ i ];
  4136. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  4137. }
  4138. #pragma unroll_loop_end
  4139. if ( clipped ) discard;
  4140. #endif
  4141. #endif`,o4e=`#if NUM_CLIPPING_PLANES > 0
  4142. varying vec3 vClipPosition;
  4143. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4144. #endif`,l4e=`#if NUM_CLIPPING_PLANES > 0
  4145. varying vec3 vClipPosition;
  4146. #endif`,c4e=`#if NUM_CLIPPING_PLANES > 0
  4147. vClipPosition = - mvPosition.xyz;
  4148. #endif`,u4e=`#if defined( USE_COLOR_ALPHA )
  4149. diffuseColor *= vColor;
  4150. #elif defined( USE_COLOR )
  4151. diffuseColor.rgb *= vColor;
  4152. #endif`,d4e=`#if defined( USE_COLOR_ALPHA )
  4153. varying vec4 vColor;
  4154. #elif defined( USE_COLOR )
  4155. varying vec3 vColor;
  4156. #endif`,h4e=`#if defined( USE_COLOR_ALPHA )
  4157. varying vec4 vColor;
  4158. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4159. varying vec3 vColor;
  4160. #endif`,f4e=`#if defined( USE_COLOR_ALPHA )
  4161. vColor = vec4( 1.0 );
  4162. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4163. vColor = vec3( 1.0 );
  4164. #endif
  4165. #ifdef USE_COLOR
  4166. vColor *= color;
  4167. #endif
  4168. #ifdef USE_INSTANCING_COLOR
  4169. vColor.xyz *= instanceColor.xyz;
  4170. #endif`,m4e=`#define PI 3.141592653589793
  4171. #define PI2 6.283185307179586
  4172. #define PI_HALF 1.5707963267948966
  4173. #define RECIPROCAL_PI 0.3183098861837907
  4174. #define RECIPROCAL_PI2 0.15915494309189535
  4175. #define EPSILON 1e-6
  4176. #ifndef saturate
  4177. #define saturate( a ) clamp( a, 0.0, 1.0 )
  4178. #endif
  4179. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  4180. float pow2( const in float x ) { return x*x; }
  4181. vec3 pow2( const in vec3 x ) { return x*x; }
  4182. float pow3( const in float x ) { return x*x*x; }
  4183. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  4184. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  4185. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  4186. highp float rand( const in vec2 uv ) {
  4187. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  4188. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  4189. return fract( sin( sn ) * c );
  4190. }
  4191. #ifdef HIGH_PRECISION
  4192. float precisionSafeLength( vec3 v ) { return length( v ); }
  4193. #else
  4194. float precisionSafeLength( vec3 v ) {
  4195. float maxComponent = max3( abs( v ) );
  4196. return length( v / maxComponent ) * maxComponent;
  4197. }
  4198. #endif
  4199. struct IncidentLight {
  4200. vec3 color;
  4201. vec3 direction;
  4202. bool visible;
  4203. };
  4204. struct ReflectedLight {
  4205. vec3 directDiffuse;
  4206. vec3 directSpecular;
  4207. vec3 indirectDiffuse;
  4208. vec3 indirectSpecular;
  4209. };
  4210. #ifdef USE_ALPHAHASH
  4211. varying vec3 vPosition;
  4212. #endif
  4213. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  4214. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  4215. }
  4216. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  4217. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  4218. }
  4219. mat3 transposeMat3( const in mat3 m ) {
  4220. mat3 tmp;
  4221. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  4222. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  4223. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  4224. return tmp;
  4225. }
  4226. float luminance( const in vec3 rgb ) {
  4227. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  4228. return dot( weights, rgb );
  4229. }
  4230. bool isPerspectiveMatrix( mat4 m ) {
  4231. return m[ 2 ][ 3 ] == - 1.0;
  4232. }
  4233. vec2 equirectUv( in vec3 dir ) {
  4234. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  4235. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  4236. return vec2( u, v );
  4237. }
  4238. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  4239. return RECIPROCAL_PI * diffuseColor;
  4240. }
  4241. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  4242. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4243. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4244. }
  4245. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  4246. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4247. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4248. } // validated`,p4e=`#ifdef ENVMAP_TYPE_CUBE_UV
  4249. #define cubeUV_minMipLevel 4.0
  4250. #define cubeUV_minTileSize 16.0
  4251. float getFace( vec3 direction ) {
  4252. vec3 absDirection = abs( direction );
  4253. float face = - 1.0;
  4254. if ( absDirection.x > absDirection.z ) {
  4255. if ( absDirection.x > absDirection.y )
  4256. face = direction.x > 0.0 ? 0.0 : 3.0;
  4257. else
  4258. face = direction.y > 0.0 ? 1.0 : 4.0;
  4259. } else {
  4260. if ( absDirection.z > absDirection.y )
  4261. face = direction.z > 0.0 ? 2.0 : 5.0;
  4262. else
  4263. face = direction.y > 0.0 ? 1.0 : 4.0;
  4264. }
  4265. return face;
  4266. }
  4267. vec2 getUV( vec3 direction, float face ) {
  4268. vec2 uv;
  4269. if ( face == 0.0 ) {
  4270. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  4271. } else if ( face == 1.0 ) {
  4272. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  4273. } else if ( face == 2.0 ) {
  4274. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  4275. } else if ( face == 3.0 ) {
  4276. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  4277. } else if ( face == 4.0 ) {
  4278. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  4279. } else {
  4280. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  4281. }
  4282. return 0.5 * ( uv + 1.0 );
  4283. }
  4284. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  4285. float face = getFace( direction );
  4286. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  4287. mipInt = max( mipInt, cubeUV_minMipLevel );
  4288. float faceSize = exp2( mipInt );
  4289. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  4290. if ( face > 2.0 ) {
  4291. uv.y += faceSize;
  4292. face -= 3.0;
  4293. }
  4294. uv.x += face * faceSize;
  4295. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  4296. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  4297. uv.x *= CUBEUV_TEXEL_WIDTH;
  4298. uv.y *= CUBEUV_TEXEL_HEIGHT;
  4299. #ifdef texture2DGradEXT
  4300. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  4301. #else
  4302. return texture2D( envMap, uv ).rgb;
  4303. #endif
  4304. }
  4305. #define cubeUV_r0 1.0
  4306. #define cubeUV_v0 0.339
  4307. #define cubeUV_m0 - 2.0
  4308. #define cubeUV_r1 0.8
  4309. #define cubeUV_v1 0.276
  4310. #define cubeUV_m1 - 1.0
  4311. #define cubeUV_r4 0.4
  4312. #define cubeUV_v4 0.046
  4313. #define cubeUV_m4 2.0
  4314. #define cubeUV_r5 0.305
  4315. #define cubeUV_v5 0.016
  4316. #define cubeUV_m5 3.0
  4317. #define cubeUV_r6 0.21
  4318. #define cubeUV_v6 0.0038
  4319. #define cubeUV_m6 4.0
  4320. float roughnessToMip( float roughness ) {
  4321. float mip = 0.0;
  4322. if ( roughness >= cubeUV_r1 ) {
  4323. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  4324. } else if ( roughness >= cubeUV_r4 ) {
  4325. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  4326. } else if ( roughness >= cubeUV_r5 ) {
  4327. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  4328. } else if ( roughness >= cubeUV_r6 ) {
  4329. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  4330. } else {
  4331. mip = - 2.0 * log2( 1.16 * roughness ); }
  4332. return mip;
  4333. }
  4334. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  4335. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  4336. float mipF = fract( mip );
  4337. float mipInt = floor( mip );
  4338. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  4339. if ( mipF == 0.0 ) {
  4340. return vec4( color0, 1.0 );
  4341. } else {
  4342. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  4343. return vec4( mix( color0, color1, mipF ), 1.0 );
  4344. }
  4345. }
  4346. #endif`,g4e=`vec3 transformedNormal = objectNormal;
  4347. #ifdef USE_TANGENT
  4348. vec3 transformedTangent = objectTangent;
  4349. #endif
  4350. #ifdef USE_BATCHING
  4351. mat3 bm = mat3( batchingMatrix );
  4352. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  4353. transformedNormal = bm * transformedNormal;
  4354. #ifdef USE_TANGENT
  4355. transformedTangent = bm * transformedTangent;
  4356. #endif
  4357. #endif
  4358. #ifdef USE_INSTANCING
  4359. mat3 im = mat3( instanceMatrix );
  4360. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  4361. transformedNormal = im * transformedNormal;
  4362. #ifdef USE_TANGENT
  4363. transformedTangent = im * transformedTangent;
  4364. #endif
  4365. #endif
  4366. transformedNormal = normalMatrix * transformedNormal;
  4367. #ifdef FLIP_SIDED
  4368. transformedNormal = - transformedNormal;
  4369. #endif
  4370. #ifdef USE_TANGENT
  4371. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  4372. #ifdef FLIP_SIDED
  4373. transformedTangent = - transformedTangent;
  4374. #endif
  4375. #endif`,x4e=`#ifdef USE_DISPLACEMENTMAP
  4376. uniform sampler2D displacementMap;
  4377. uniform float displacementScale;
  4378. uniform float displacementBias;
  4379. #endif`,b4e=`#ifdef USE_DISPLACEMENTMAP
  4380. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4381. #endif`,y4e=`#ifdef USE_EMISSIVEMAP
  4382. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4383. totalEmissiveRadiance *= emissiveColor.rgb;
  4384. #endif`,v4e=`#ifdef USE_EMISSIVEMAP
  4385. uniform sampler2D emissiveMap;
  4386. #endif`,_4e="gl_FragColor = linearToOutputTexel( gl_FragColor );",w4e=`
  4387. const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
  4388. vec3( 0.8224621, 0.177538, 0.0 ),
  4389. vec3( 0.0331941, 0.9668058, 0.0 ),
  4390. vec3( 0.0170827, 0.0723974, 0.9105199 )
  4391. );
  4392. const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
  4393. vec3( 1.2249401, - 0.2249404, 0.0 ),
  4394. vec3( - 0.0420569, 1.0420571, 0.0 ),
  4395. vec3( - 0.0196376, - 0.0786361, 1.0982735 )
  4396. );
  4397. vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
  4398. return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
  4399. }
  4400. vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
  4401. return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
  4402. }
  4403. vec4 LinearTransferOETF( in vec4 value ) {
  4404. return value;
  4405. }
  4406. vec4 sRGBTransferOETF( in vec4 value ) {
  4407. 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 );
  4408. }
  4409. vec4 LinearToLinear( in vec4 value ) {
  4410. return value;
  4411. }
  4412. vec4 LinearTosRGB( in vec4 value ) {
  4413. return sRGBTransferOETF( value );
  4414. }`,S4e=`#ifdef USE_ENVMAP
  4415. #ifdef ENV_WORLDPOS
  4416. vec3 cameraToFrag;
  4417. if ( isOrthographic ) {
  4418. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4419. } else {
  4420. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  4421. }
  4422. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4423. #ifdef ENVMAP_MODE_REFLECTION
  4424. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  4425. #else
  4426. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  4427. #endif
  4428. #else
  4429. vec3 reflectVec = vReflect;
  4430. #endif
  4431. #ifdef ENVMAP_TYPE_CUBE
  4432. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  4433. #else
  4434. vec4 envColor = vec4( 0.0 );
  4435. #endif
  4436. #ifdef ENVMAP_BLENDING_MULTIPLY
  4437. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  4438. #elif defined( ENVMAP_BLENDING_MIX )
  4439. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  4440. #elif defined( ENVMAP_BLENDING_ADD )
  4441. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  4442. #endif
  4443. #endif`,M4e=`#ifdef USE_ENVMAP
  4444. uniform float envMapIntensity;
  4445. uniform float flipEnvMap;
  4446. #ifdef ENVMAP_TYPE_CUBE
  4447. uniform samplerCube envMap;
  4448. #else
  4449. uniform sampler2D envMap;
  4450. #endif
  4451. #endif`,E4e=`#ifdef USE_ENVMAP
  4452. uniform float reflectivity;
  4453. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4454. #define ENV_WORLDPOS
  4455. #endif
  4456. #ifdef ENV_WORLDPOS
  4457. varying vec3 vWorldPosition;
  4458. uniform float refractionRatio;
  4459. #else
  4460. varying vec3 vReflect;
  4461. #endif
  4462. #endif`,A4e=`#ifdef USE_ENVMAP
  4463. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4464. #define ENV_WORLDPOS
  4465. #endif
  4466. #ifdef ENV_WORLDPOS
  4467. varying vec3 vWorldPosition;
  4468. #else
  4469. varying vec3 vReflect;
  4470. uniform float refractionRatio;
  4471. #endif
  4472. #endif`,T4e=`#ifdef USE_ENVMAP
  4473. #ifdef ENV_WORLDPOS
  4474. vWorldPosition = worldPosition.xyz;
  4475. #else
  4476. vec3 cameraToVertex;
  4477. if ( isOrthographic ) {
  4478. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4479. } else {
  4480. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  4481. }
  4482. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  4483. #ifdef ENVMAP_MODE_REFLECTION
  4484. vReflect = reflect( cameraToVertex, worldNormal );
  4485. #else
  4486. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  4487. #endif
  4488. #endif
  4489. #endif`,N4e=`#ifdef USE_FOG
  4490. vFogDepth = - mvPosition.z;
  4491. #endif`,C4e=`#ifdef USE_FOG
  4492. varying float vFogDepth;
  4493. #endif`,k4e=`#ifdef USE_FOG
  4494. #ifdef FOG_EXP2
  4495. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  4496. #else
  4497. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  4498. #endif
  4499. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  4500. #endif`,P4e=`#ifdef USE_FOG
  4501. uniform vec3 fogColor;
  4502. varying float vFogDepth;
  4503. #ifdef FOG_EXP2
  4504. uniform float fogDensity;
  4505. #else
  4506. uniform float fogNear;
  4507. uniform float fogFar;
  4508. #endif
  4509. #endif`,j4e=`#ifdef USE_GRADIENTMAP
  4510. uniform sampler2D gradientMap;
  4511. #endif
  4512. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  4513. float dotNL = dot( normal, lightDirection );
  4514. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  4515. #ifdef USE_GRADIENTMAP
  4516. return vec3( texture2D( gradientMap, coord ).r );
  4517. #else
  4518. vec2 fw = fwidth( coord ) * 0.5;
  4519. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  4520. #endif
  4521. }`,R4e=`#ifdef USE_LIGHTMAP
  4522. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4523. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4524. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4525. #endif`,D4e=`#ifdef USE_LIGHTMAP
  4526. uniform sampler2D lightMap;
  4527. uniform float lightMapIntensity;
  4528. #endif`,O4e=`LambertMaterial material;
  4529. material.diffuseColor = diffuseColor.rgb;
  4530. material.specularStrength = specularStrength;`,L4e=`varying vec3 vViewPosition;
  4531. struct LambertMaterial {
  4532. vec3 diffuseColor;
  4533. float specularStrength;
  4534. };
  4535. 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 ) {
  4536. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4537. vec3 irradiance = dotNL * directLight.color;
  4538. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4539. }
  4540. 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 ) {
  4541. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4542. }
  4543. #define RE_Direct RE_Direct_Lambert
  4544. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,I4e=`uniform bool receiveShadow;
  4545. uniform vec3 ambientLightColor;
  4546. #if defined( USE_LIGHT_PROBES )
  4547. uniform vec3 lightProbe[ 9 ];
  4548. #endif
  4549. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  4550. float x = normal.x, y = normal.y, z = normal.z;
  4551. vec3 result = shCoefficients[ 0 ] * 0.886227;
  4552. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  4553. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  4554. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  4555. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  4556. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  4557. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  4558. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  4559. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  4560. return result;
  4561. }
  4562. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  4563. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4564. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  4565. return irradiance;
  4566. }
  4567. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  4568. vec3 irradiance = ambientLightColor;
  4569. return irradiance;
  4570. }
  4571. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  4572. #if defined ( LEGACY_LIGHTS )
  4573. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  4574. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  4575. }
  4576. return 1.0;
  4577. #else
  4578. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  4579. if ( cutoffDistance > 0.0 ) {
  4580. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  4581. }
  4582. return distanceFalloff;
  4583. #endif
  4584. }
  4585. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  4586. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  4587. }
  4588. #if NUM_DIR_LIGHTS > 0
  4589. struct DirectionalLight {
  4590. vec3 direction;
  4591. vec3 color;
  4592. };
  4593. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  4594. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  4595. light.color = directionalLight.color;
  4596. light.direction = directionalLight.direction;
  4597. light.visible = true;
  4598. }
  4599. #endif
  4600. #if NUM_POINT_LIGHTS > 0
  4601. struct PointLight {
  4602. vec3 position;
  4603. vec3 color;
  4604. float distance;
  4605. float decay;
  4606. };
  4607. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  4608. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4609. vec3 lVector = pointLight.position - geometryPosition;
  4610. light.direction = normalize( lVector );
  4611. float lightDistance = length( lVector );
  4612. light.color = pointLight.color;
  4613. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  4614. light.visible = ( light.color != vec3( 0.0 ) );
  4615. }
  4616. #endif
  4617. #if NUM_SPOT_LIGHTS > 0
  4618. struct SpotLight {
  4619. vec3 position;
  4620. vec3 direction;
  4621. vec3 color;
  4622. float distance;
  4623. float decay;
  4624. float coneCos;
  4625. float penumbraCos;
  4626. };
  4627. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  4628. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4629. vec3 lVector = spotLight.position - geometryPosition;
  4630. light.direction = normalize( lVector );
  4631. float angleCos = dot( light.direction, spotLight.direction );
  4632. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  4633. if ( spotAttenuation > 0.0 ) {
  4634. float lightDistance = length( lVector );
  4635. light.color = spotLight.color * spotAttenuation;
  4636. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  4637. light.visible = ( light.color != vec3( 0.0 ) );
  4638. } else {
  4639. light.color = vec3( 0.0 );
  4640. light.visible = false;
  4641. }
  4642. }
  4643. #endif
  4644. #if NUM_RECT_AREA_LIGHTS > 0
  4645. struct RectAreaLight {
  4646. vec3 color;
  4647. vec3 position;
  4648. vec3 halfWidth;
  4649. vec3 halfHeight;
  4650. };
  4651. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  4652. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  4653. #endif
  4654. #if NUM_HEMI_LIGHTS > 0
  4655. struct HemisphereLight {
  4656. vec3 direction;
  4657. vec3 skyColor;
  4658. vec3 groundColor;
  4659. };
  4660. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  4661. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  4662. float dotNL = dot( normal, hemiLight.direction );
  4663. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  4664. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  4665. return irradiance;
  4666. }
  4667. #endif`,F4e=`#ifdef USE_ENVMAP
  4668. vec3 getIBLIrradiance( const in vec3 normal ) {
  4669. #ifdef ENVMAP_TYPE_CUBE_UV
  4670. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4671. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  4672. return PI * envMapColor.rgb * envMapIntensity;
  4673. #else
  4674. return vec3( 0.0 );
  4675. #endif
  4676. }
  4677. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  4678. #ifdef ENVMAP_TYPE_CUBE_UV
  4679. vec3 reflectVec = reflect( - viewDir, normal );
  4680. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  4681. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  4682. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  4683. return envMapColor.rgb * envMapIntensity;
  4684. #else
  4685. return vec3( 0.0 );
  4686. #endif
  4687. }
  4688. #ifdef USE_ANISOTROPY
  4689. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  4690. #ifdef ENVMAP_TYPE_CUBE_UV
  4691. vec3 bentNormal = cross( bitangent, viewDir );
  4692. bentNormal = normalize( cross( bentNormal, bitangent ) );
  4693. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  4694. return getIBLRadiance( viewDir, bentNormal, roughness );
  4695. #else
  4696. return vec3( 0.0 );
  4697. #endif
  4698. }
  4699. #endif
  4700. #endif`,U4e=`ToonMaterial material;
  4701. material.diffuseColor = diffuseColor.rgb;`,z4e=`varying vec3 vViewPosition;
  4702. struct ToonMaterial {
  4703. vec3 diffuseColor;
  4704. };
  4705. 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 ) {
  4706. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  4707. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4708. }
  4709. 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 ) {
  4710. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4711. }
  4712. #define RE_Direct RE_Direct_Toon
  4713. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,B4e=`BlinnPhongMaterial material;
  4714. material.diffuseColor = diffuseColor.rgb;
  4715. material.specularColor = specular;
  4716. material.specularShininess = shininess;
  4717. material.specularStrength = specularStrength;`,H4e=`varying vec3 vViewPosition;
  4718. struct BlinnPhongMaterial {
  4719. vec3 diffuseColor;
  4720. vec3 specularColor;
  4721. float specularShininess;
  4722. float specularStrength;
  4723. };
  4724. 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 ) {
  4725. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4726. vec3 irradiance = dotNL * directLight.color;
  4727. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4728. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  4729. }
  4730. 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 ) {
  4731. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4732. }
  4733. #define RE_Direct RE_Direct_BlinnPhong
  4734. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,$4e=`PhysicalMaterial material;
  4735. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  4736. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  4737. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  4738. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  4739. material.roughness = min( material.roughness, 1.0 );
  4740. #ifdef IOR
  4741. material.ior = ior;
  4742. #ifdef USE_SPECULAR
  4743. float specularIntensityFactor = specularIntensity;
  4744. vec3 specularColorFactor = specularColor;
  4745. #ifdef USE_SPECULAR_COLORMAP
  4746. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  4747. #endif
  4748. #ifdef USE_SPECULAR_INTENSITYMAP
  4749. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  4750. #endif
  4751. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  4752. #else
  4753. float specularIntensityFactor = 1.0;
  4754. vec3 specularColorFactor = vec3( 1.0 );
  4755. material.specularF90 = 1.0;
  4756. #endif
  4757. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  4758. #else
  4759. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  4760. material.specularF90 = 1.0;
  4761. #endif
  4762. #ifdef USE_CLEARCOAT
  4763. material.clearcoat = clearcoat;
  4764. material.clearcoatRoughness = clearcoatRoughness;
  4765. material.clearcoatF0 = vec3( 0.04 );
  4766. material.clearcoatF90 = 1.0;
  4767. #ifdef USE_CLEARCOATMAP
  4768. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  4769. #endif
  4770. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  4771. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  4772. #endif
  4773. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  4774. material.clearcoatRoughness += geometryRoughness;
  4775. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  4776. #endif
  4777. #ifdef USE_IRIDESCENCE
  4778. material.iridescence = iridescence;
  4779. material.iridescenceIOR = iridescenceIOR;
  4780. #ifdef USE_IRIDESCENCEMAP
  4781. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  4782. #endif
  4783. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  4784. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  4785. #else
  4786. material.iridescenceThickness = iridescenceThicknessMaximum;
  4787. #endif
  4788. #endif
  4789. #ifdef USE_SHEEN
  4790. material.sheenColor = sheenColor;
  4791. #ifdef USE_SHEEN_COLORMAP
  4792. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  4793. #endif
  4794. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  4795. #ifdef USE_SHEEN_ROUGHNESSMAP
  4796. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  4797. #endif
  4798. #endif
  4799. #ifdef USE_ANISOTROPY
  4800. #ifdef USE_ANISOTROPYMAP
  4801. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  4802. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  4803. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  4804. #else
  4805. vec2 anisotropyV = anisotropyVector;
  4806. #endif
  4807. material.anisotropy = length( anisotropyV );
  4808. if( material.anisotropy == 0.0 ) {
  4809. anisotropyV = vec2( 1.0, 0.0 );
  4810. } else {
  4811. anisotropyV /= material.anisotropy;
  4812. material.anisotropy = saturate( material.anisotropy );
  4813. }
  4814. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  4815. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  4816. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  4817. #endif`,V4e=`struct PhysicalMaterial {
  4818. vec3 diffuseColor;
  4819. float roughness;
  4820. vec3 specularColor;
  4821. float specularF90;
  4822. #ifdef USE_CLEARCOAT
  4823. float clearcoat;
  4824. float clearcoatRoughness;
  4825. vec3 clearcoatF0;
  4826. float clearcoatF90;
  4827. #endif
  4828. #ifdef USE_IRIDESCENCE
  4829. float iridescence;
  4830. float iridescenceIOR;
  4831. float iridescenceThickness;
  4832. vec3 iridescenceFresnel;
  4833. vec3 iridescenceF0;
  4834. #endif
  4835. #ifdef USE_SHEEN
  4836. vec3 sheenColor;
  4837. float sheenRoughness;
  4838. #endif
  4839. #ifdef IOR
  4840. float ior;
  4841. #endif
  4842. #ifdef USE_TRANSMISSION
  4843. float transmission;
  4844. float transmissionAlpha;
  4845. float thickness;
  4846. float attenuationDistance;
  4847. vec3 attenuationColor;
  4848. #endif
  4849. #ifdef USE_ANISOTROPY
  4850. float anisotropy;
  4851. float alphaT;
  4852. vec3 anisotropyT;
  4853. vec3 anisotropyB;
  4854. #endif
  4855. };
  4856. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  4857. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  4858. vec3 sheenSpecularDirect = vec3( 0.0 );
  4859. vec3 sheenSpecularIndirect = vec3(0.0 );
  4860. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  4861. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  4862. float x2 = x * x;
  4863. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  4864. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  4865. }
  4866. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  4867. float a2 = pow2( alpha );
  4868. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  4869. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  4870. return 0.5 / max( gv + gl, EPSILON );
  4871. }
  4872. float D_GGX( const in float alpha, const in float dotNH ) {
  4873. float a2 = pow2( alpha );
  4874. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  4875. return RECIPROCAL_PI * a2 / pow2( denom );
  4876. }
  4877. #ifdef USE_ANISOTROPY
  4878. 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 ) {
  4879. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  4880. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  4881. float v = 0.5 / ( gv + gl );
  4882. return saturate(v);
  4883. }
  4884. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  4885. float a2 = alphaT * alphaB;
  4886. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  4887. highp float v2 = dot( v, v );
  4888. float w2 = a2 / v2;
  4889. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  4890. }
  4891. #endif
  4892. #ifdef USE_CLEARCOAT
  4893. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  4894. vec3 f0 = material.clearcoatF0;
  4895. float f90 = material.clearcoatF90;
  4896. float roughness = material.clearcoatRoughness;
  4897. float alpha = pow2( roughness );
  4898. vec3 halfDir = normalize( lightDir + viewDir );
  4899. float dotNL = saturate( dot( normal, lightDir ) );
  4900. float dotNV = saturate( dot( normal, viewDir ) );
  4901. float dotNH = saturate( dot( normal, halfDir ) );
  4902. float dotVH = saturate( dot( viewDir, halfDir ) );
  4903. vec3 F = F_Schlick( f0, f90, dotVH );
  4904. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4905. float D = D_GGX( alpha, dotNH );
  4906. return F * ( V * D );
  4907. }
  4908. #endif
  4909. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  4910. vec3 f0 = material.specularColor;
  4911. float f90 = material.specularF90;
  4912. float roughness = material.roughness;
  4913. float alpha = pow2( roughness );
  4914. vec3 halfDir = normalize( lightDir + viewDir );
  4915. float dotNL = saturate( dot( normal, lightDir ) );
  4916. float dotNV = saturate( dot( normal, viewDir ) );
  4917. float dotNH = saturate( dot( normal, halfDir ) );
  4918. float dotVH = saturate( dot( viewDir, halfDir ) );
  4919. vec3 F = F_Schlick( f0, f90, dotVH );
  4920. #ifdef USE_IRIDESCENCE
  4921. F = mix( F, material.iridescenceFresnel, material.iridescence );
  4922. #endif
  4923. #ifdef USE_ANISOTROPY
  4924. float dotTL = dot( material.anisotropyT, lightDir );
  4925. float dotTV = dot( material.anisotropyT, viewDir );
  4926. float dotTH = dot( material.anisotropyT, halfDir );
  4927. float dotBL = dot( material.anisotropyB, lightDir );
  4928. float dotBV = dot( material.anisotropyB, viewDir );
  4929. float dotBH = dot( material.anisotropyB, halfDir );
  4930. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  4931. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  4932. #else
  4933. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4934. float D = D_GGX( alpha, dotNH );
  4935. #endif
  4936. return F * ( V * D );
  4937. }
  4938. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  4939. const float LUT_SIZE = 64.0;
  4940. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  4941. const float LUT_BIAS = 0.5 / LUT_SIZE;
  4942. float dotNV = saturate( dot( N, V ) );
  4943. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  4944. uv = uv * LUT_SCALE + LUT_BIAS;
  4945. return uv;
  4946. }
  4947. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  4948. float l = length( f );
  4949. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  4950. }
  4951. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  4952. float x = dot( v1, v2 );
  4953. float y = abs( x );
  4954. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  4955. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  4956. float v = a / b;
  4957. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  4958. return cross( v1, v2 ) * theta_sintheta;
  4959. }
  4960. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  4961. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  4962. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  4963. vec3 lightNormal = cross( v1, v2 );
  4964. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  4965. vec3 T1, T2;
  4966. T1 = normalize( V - N * dot( V, N ) );
  4967. T2 = - cross( N, T1 );
  4968. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  4969. vec3 coords[ 4 ];
  4970. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  4971. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  4972. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  4973. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  4974. coords[ 0 ] = normalize( coords[ 0 ] );
  4975. coords[ 1 ] = normalize( coords[ 1 ] );
  4976. coords[ 2 ] = normalize( coords[ 2 ] );
  4977. coords[ 3 ] = normalize( coords[ 3 ] );
  4978. vec3 vectorFormFactor = vec3( 0.0 );
  4979. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  4980. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  4981. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  4982. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  4983. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  4984. return vec3( result );
  4985. }
  4986. #if defined( USE_SHEEN )
  4987. float D_Charlie( float roughness, float dotNH ) {
  4988. float alpha = pow2( roughness );
  4989. float invAlpha = 1.0 / alpha;
  4990. float cos2h = dotNH * dotNH;
  4991. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  4992. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  4993. }
  4994. float V_Neubelt( float dotNV, float dotNL ) {
  4995. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  4996. }
  4997. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  4998. vec3 halfDir = normalize( lightDir + viewDir );
  4999. float dotNL = saturate( dot( normal, lightDir ) );
  5000. float dotNV = saturate( dot( normal, viewDir ) );
  5001. float dotNH = saturate( dot( normal, halfDir ) );
  5002. float D = D_Charlie( sheenRoughness, dotNH );
  5003. float V = V_Neubelt( dotNV, dotNL );
  5004. return sheenColor * ( D * V );
  5005. }
  5006. #endif
  5007. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  5008. float dotNV = saturate( dot( normal, viewDir ) );
  5009. float r2 = roughness * roughness;
  5010. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  5011. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  5012. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  5013. return saturate( DG * RECIPROCAL_PI );
  5014. }
  5015. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  5016. float dotNV = saturate( dot( normal, viewDir ) );
  5017. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  5018. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  5019. vec4 r = roughness * c0 + c1;
  5020. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  5021. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  5022. return fab;
  5023. }
  5024. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  5025. vec2 fab = DFGApprox( normal, viewDir, roughness );
  5026. return specularColor * fab.x + specularF90 * fab.y;
  5027. }
  5028. #ifdef USE_IRIDESCENCE
  5029. 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 ) {
  5030. #else
  5031. 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 ) {
  5032. #endif
  5033. vec2 fab = DFGApprox( normal, viewDir, roughness );
  5034. #ifdef USE_IRIDESCENCE
  5035. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  5036. #else
  5037. vec3 Fr = specularColor;
  5038. #endif
  5039. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  5040. float Ess = fab.x + fab.y;
  5041. float Ems = 1.0 - Ess;
  5042. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  5043. singleScatter += FssEss;
  5044. multiScatter += Fms * Ems;
  5045. }
  5046. #if NUM_RECT_AREA_LIGHTS > 0
  5047. 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 ) {
  5048. vec3 normal = geometryNormal;
  5049. vec3 viewDir = geometryViewDir;
  5050. vec3 position = geometryPosition;
  5051. vec3 lightPos = rectAreaLight.position;
  5052. vec3 halfWidth = rectAreaLight.halfWidth;
  5053. vec3 halfHeight = rectAreaLight.halfHeight;
  5054. vec3 lightColor = rectAreaLight.color;
  5055. float roughness = material.roughness;
  5056. vec3 rectCoords[ 4 ];
  5057. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  5058. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  5059. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  5060. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  5061. vec4 t1 = texture2D( ltc_1, uv );
  5062. vec4 t2 = texture2D( ltc_2, uv );
  5063. mat3 mInv = mat3(
  5064. vec3( t1.x, 0, t1.y ),
  5065. vec3( 0, 1, 0 ),
  5066. vec3( t1.z, 0, t1.w )
  5067. );
  5068. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  5069. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  5070. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  5071. }
  5072. #endif
  5073. 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 ) {
  5074. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  5075. vec3 irradiance = dotNL * directLight.color;
  5076. #ifdef USE_CLEARCOAT
  5077. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  5078. vec3 ccIrradiance = dotNLcc * directLight.color;
  5079. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  5080. #endif
  5081. #ifdef USE_SHEEN
  5082. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  5083. #endif
  5084. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  5085. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5086. }
  5087. 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 ) {
  5088. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5089. }
  5090. 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) {
  5091. #ifdef USE_CLEARCOAT
  5092. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  5093. #endif
  5094. #ifdef USE_SHEEN
  5095. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  5096. #endif
  5097. vec3 singleScattering = vec3( 0.0 );
  5098. vec3 multiScattering = vec3( 0.0 );
  5099. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  5100. #ifdef USE_IRIDESCENCE
  5101. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  5102. #else
  5103. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  5104. #endif
  5105. vec3 totalScattering = singleScattering + multiScattering;
  5106. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  5107. reflectedLight.indirectSpecular += radiance * singleScattering;
  5108. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  5109. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  5110. }
  5111. #define RE_Direct RE_Direct_Physical
  5112. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  5113. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  5114. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  5115. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  5116. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  5117. }`,G4e=`
  5118. vec3 geometryPosition = - vViewPosition;
  5119. vec3 geometryNormal = normal;
  5120. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  5121. vec3 geometryClearcoatNormal = vec3( 0.0 );
  5122. #ifdef USE_CLEARCOAT
  5123. geometryClearcoatNormal = clearcoatNormal;
  5124. #endif
  5125. #ifdef USE_IRIDESCENCE
  5126. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  5127. if ( material.iridescenceThickness == 0.0 ) {
  5128. material.iridescence = 0.0;
  5129. } else {
  5130. material.iridescence = saturate( material.iridescence );
  5131. }
  5132. if ( material.iridescence > 0.0 ) {
  5133. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  5134. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  5135. }
  5136. #endif
  5137. IncidentLight directLight;
  5138. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  5139. PointLight pointLight;
  5140. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  5141. PointLightShadow pointLightShadow;
  5142. #endif
  5143. #pragma unroll_loop_start
  5144. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  5145. pointLight = pointLights[ i ];
  5146. getPointLightInfo( pointLight, geometryPosition, directLight );
  5147. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  5148. pointLightShadow = pointLightShadows[ i ];
  5149. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  5150. #endif
  5151. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5152. }
  5153. #pragma unroll_loop_end
  5154. #endif
  5155. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  5156. SpotLight spotLight;
  5157. vec4 spotColor;
  5158. vec3 spotLightCoord;
  5159. bool inSpotLightMap;
  5160. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  5161. SpotLightShadow spotLightShadow;
  5162. #endif
  5163. #pragma unroll_loop_start
  5164. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  5165. spotLight = spotLights[ i ];
  5166. getSpotLightInfo( spotLight, geometryPosition, directLight );
  5167. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5168. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  5169. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5170. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  5171. #else
  5172. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5173. #endif
  5174. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  5175. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  5176. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  5177. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  5178. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  5179. #endif
  5180. #undef SPOT_LIGHT_MAP_INDEX
  5181. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5182. spotLightShadow = spotLightShadows[ i ];
  5183. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5184. #endif
  5185. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5186. }
  5187. #pragma unroll_loop_end
  5188. #endif
  5189. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  5190. DirectionalLight directionalLight;
  5191. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  5192. DirectionalLightShadow directionalLightShadow;
  5193. #endif
  5194. #pragma unroll_loop_start
  5195. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  5196. directionalLight = directionalLights[ i ];
  5197. getDirectionalLightInfo( directionalLight, directLight );
  5198. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  5199. directionalLightShadow = directionalLightShadows[ i ];
  5200. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5201. #endif
  5202. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5203. }
  5204. #pragma unroll_loop_end
  5205. #endif
  5206. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  5207. RectAreaLight rectAreaLight;
  5208. #pragma unroll_loop_start
  5209. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  5210. rectAreaLight = rectAreaLights[ i ];
  5211. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5212. }
  5213. #pragma unroll_loop_end
  5214. #endif
  5215. #if defined( RE_IndirectDiffuse )
  5216. vec3 iblIrradiance = vec3( 0.0 );
  5217. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  5218. #if defined( USE_LIGHT_PROBES )
  5219. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  5220. #endif
  5221. #if ( NUM_HEMI_LIGHTS > 0 )
  5222. #pragma unroll_loop_start
  5223. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  5224. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  5225. }
  5226. #pragma unroll_loop_end
  5227. #endif
  5228. #endif
  5229. #if defined( RE_IndirectSpecular )
  5230. vec3 radiance = vec3( 0.0 );
  5231. vec3 clearcoatRadiance = vec3( 0.0 );
  5232. #endif`,W4e=`#if defined( RE_IndirectDiffuse )
  5233. #ifdef USE_LIGHTMAP
  5234. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  5235. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  5236. irradiance += lightMapIrradiance;
  5237. #endif
  5238. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  5239. iblIrradiance += getIBLIrradiance( geometryNormal );
  5240. #endif
  5241. #endif
  5242. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  5243. #ifdef USE_ANISOTROPY
  5244. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  5245. #else
  5246. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  5247. #endif
  5248. #ifdef USE_CLEARCOAT
  5249. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  5250. #endif
  5251. #endif`,q4e=`#if defined( RE_IndirectDiffuse )
  5252. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5253. #endif
  5254. #if defined( RE_IndirectSpecular )
  5255. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5256. #endif`,K4e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5257. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5258. #endif`,X4e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5259. uniform float logDepthBufFC;
  5260. varying float vFragDepth;
  5261. varying float vIsPerspective;
  5262. #endif`,Y4e=`#ifdef USE_LOGDEPTHBUF
  5263. #ifdef USE_LOGDEPTHBUF_EXT
  5264. varying float vFragDepth;
  5265. varying float vIsPerspective;
  5266. #else
  5267. uniform float logDepthBufFC;
  5268. #endif
  5269. #endif`,Z4e=`#ifdef USE_LOGDEPTHBUF
  5270. #ifdef USE_LOGDEPTHBUF_EXT
  5271. vFragDepth = 1.0 + gl_Position.w;
  5272. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  5273. #else
  5274. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  5275. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  5276. gl_Position.z *= gl_Position.w;
  5277. }
  5278. #endif
  5279. #endif`,Q4e=`#ifdef USE_MAP
  5280. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  5281. #ifdef DECODE_VIDEO_TEXTURE
  5282. 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 );
  5283. #endif
  5284. diffuseColor *= sampledDiffuseColor;
  5285. #endif`,J4e=`#ifdef USE_MAP
  5286. uniform sampler2D map;
  5287. #endif`,eIe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5288. #if defined( USE_POINTS_UV )
  5289. vec2 uv = vUv;
  5290. #else
  5291. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  5292. #endif
  5293. #endif
  5294. #ifdef USE_MAP
  5295. diffuseColor *= texture2D( map, uv );
  5296. #endif
  5297. #ifdef USE_ALPHAMAP
  5298. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  5299. #endif`,tIe=`#if defined( USE_POINTS_UV )
  5300. varying vec2 vUv;
  5301. #else
  5302. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5303. uniform mat3 uvTransform;
  5304. #endif
  5305. #endif
  5306. #ifdef USE_MAP
  5307. uniform sampler2D map;
  5308. #endif
  5309. #ifdef USE_ALPHAMAP
  5310. uniform sampler2D alphaMap;
  5311. #endif`,nIe=`float metalnessFactor = metalness;
  5312. #ifdef USE_METALNESSMAP
  5313. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5314. metalnessFactor *= texelMetalness.b;
  5315. #endif`,rIe=`#ifdef USE_METALNESSMAP
  5316. uniform sampler2D metalnessMap;
  5317. #endif`,iIe=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  5318. vColor *= morphTargetBaseInfluence;
  5319. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5320. #if defined( USE_COLOR_ALPHA )
  5321. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  5322. #elif defined( USE_COLOR )
  5323. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  5324. #endif
  5325. }
  5326. #endif`,aIe=`#ifdef USE_MORPHNORMALS
  5327. objectNormal *= morphTargetBaseInfluence;
  5328. #ifdef MORPHTARGETS_TEXTURE
  5329. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5330. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  5331. }
  5332. #else
  5333. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  5334. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  5335. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  5336. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  5337. #endif
  5338. #endif`,sIe=`#ifdef USE_MORPHTARGETS
  5339. uniform float morphTargetBaseInfluence;
  5340. #ifdef MORPHTARGETS_TEXTURE
  5341. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  5342. uniform sampler2DArray morphTargetsTexture;
  5343. uniform ivec2 morphTargetsTextureSize;
  5344. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  5345. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  5346. int y = texelIndex / morphTargetsTextureSize.x;
  5347. int x = texelIndex - y * morphTargetsTextureSize.x;
  5348. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  5349. return texelFetch( morphTargetsTexture, morphUV, 0 );
  5350. }
  5351. #else
  5352. #ifndef USE_MORPHNORMALS
  5353. uniform float morphTargetInfluences[ 8 ];
  5354. #else
  5355. uniform float morphTargetInfluences[ 4 ];
  5356. #endif
  5357. #endif
  5358. #endif`,oIe=`#ifdef USE_MORPHTARGETS
  5359. transformed *= morphTargetBaseInfluence;
  5360. #ifdef MORPHTARGETS_TEXTURE
  5361. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5362. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  5363. }
  5364. #else
  5365. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  5366. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  5367. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  5368. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  5369. #ifndef USE_MORPHNORMALS
  5370. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  5371. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  5372. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  5373. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  5374. #endif
  5375. #endif
  5376. #endif`,lIe=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  5377. #ifdef FLAT_SHADED
  5378. vec3 fdx = dFdx( vViewPosition );
  5379. vec3 fdy = dFdy( vViewPosition );
  5380. vec3 normal = normalize( cross( fdx, fdy ) );
  5381. #else
  5382. vec3 normal = normalize( vNormal );
  5383. #ifdef DOUBLE_SIDED
  5384. normal *= faceDirection;
  5385. #endif
  5386. #endif
  5387. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  5388. #ifdef USE_TANGENT
  5389. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5390. #else
  5391. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  5392. #if defined( USE_NORMALMAP )
  5393. vNormalMapUv
  5394. #elif defined( USE_CLEARCOAT_NORMALMAP )
  5395. vClearcoatNormalMapUv
  5396. #else
  5397. vUv
  5398. #endif
  5399. );
  5400. #endif
  5401. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5402. tbn[0] *= faceDirection;
  5403. tbn[1] *= faceDirection;
  5404. #endif
  5405. #endif
  5406. #ifdef USE_CLEARCOAT_NORMALMAP
  5407. #ifdef USE_TANGENT
  5408. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5409. #else
  5410. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  5411. #endif
  5412. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5413. tbn2[0] *= faceDirection;
  5414. tbn2[1] *= faceDirection;
  5415. #endif
  5416. #endif
  5417. vec3 nonPerturbedNormal = normal;`,cIe=`#ifdef USE_NORMALMAP_OBJECTSPACE
  5418. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5419. #ifdef FLIP_SIDED
  5420. normal = - normal;
  5421. #endif
  5422. #ifdef DOUBLE_SIDED
  5423. normal = normal * faceDirection;
  5424. #endif
  5425. normal = normalize( normalMatrix * normal );
  5426. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  5427. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5428. mapN.xy *= normalScale;
  5429. normal = normalize( tbn * mapN );
  5430. #elif defined( USE_BUMPMAP )
  5431. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  5432. #endif`,uIe=`#ifndef FLAT_SHADED
  5433. varying vec3 vNormal;
  5434. #ifdef USE_TANGENT
  5435. varying vec3 vTangent;
  5436. varying vec3 vBitangent;
  5437. #endif
  5438. #endif`,dIe=`#ifndef FLAT_SHADED
  5439. varying vec3 vNormal;
  5440. #ifdef USE_TANGENT
  5441. varying vec3 vTangent;
  5442. varying vec3 vBitangent;
  5443. #endif
  5444. #endif`,hIe=`#ifndef FLAT_SHADED
  5445. vNormal = normalize( transformedNormal );
  5446. #ifdef USE_TANGENT
  5447. vTangent = normalize( transformedTangent );
  5448. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  5449. #endif
  5450. #endif`,fIe=`#ifdef USE_NORMALMAP
  5451. uniform sampler2D normalMap;
  5452. uniform vec2 normalScale;
  5453. #endif
  5454. #ifdef USE_NORMALMAP_OBJECTSPACE
  5455. uniform mat3 normalMatrix;
  5456. #endif
  5457. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  5458. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  5459. vec3 q0 = dFdx( eye_pos.xyz );
  5460. vec3 q1 = dFdy( eye_pos.xyz );
  5461. vec2 st0 = dFdx( uv.st );
  5462. vec2 st1 = dFdy( uv.st );
  5463. vec3 N = surf_norm;
  5464. vec3 q1perp = cross( q1, N );
  5465. vec3 q0perp = cross( N, q0 );
  5466. vec3 T = q1perp * st0.x + q0perp * st1.x;
  5467. vec3 B = q1perp * st0.y + q0perp * st1.y;
  5468. float det = max( dot( T, T ), dot( B, B ) );
  5469. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  5470. return mat3( T * scale, B * scale, N );
  5471. }
  5472. #endif`,mIe=`#ifdef USE_CLEARCOAT
  5473. vec3 clearcoatNormal = nonPerturbedNormal;
  5474. #endif`,pIe=`#ifdef USE_CLEARCOAT_NORMALMAP
  5475. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  5476. clearcoatMapN.xy *= clearcoatNormalScale;
  5477. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  5478. #endif`,gIe=`#ifdef USE_CLEARCOATMAP
  5479. uniform sampler2D clearcoatMap;
  5480. #endif
  5481. #ifdef USE_CLEARCOAT_NORMALMAP
  5482. uniform sampler2D clearcoatNormalMap;
  5483. uniform vec2 clearcoatNormalScale;
  5484. #endif
  5485. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  5486. uniform sampler2D clearcoatRoughnessMap;
  5487. #endif`,xIe=`#ifdef USE_IRIDESCENCEMAP
  5488. uniform sampler2D iridescenceMap;
  5489. #endif
  5490. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5491. uniform sampler2D iridescenceThicknessMap;
  5492. #endif`,bIe=`#ifdef OPAQUE
  5493. diffuseColor.a = 1.0;
  5494. #endif
  5495. #ifdef USE_TRANSMISSION
  5496. diffuseColor.a *= material.transmissionAlpha;
  5497. #endif
  5498. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,yIe=`vec3 packNormalToRGB( const in vec3 normal ) {
  5499. return normalize( normal ) * 0.5 + 0.5;
  5500. }
  5501. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  5502. return 2.0 * rgb.xyz - 1.0;
  5503. }
  5504. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  5505. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  5506. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  5507. const float ShiftRight8 = 1. / 256.;
  5508. vec4 packDepthToRGBA( const in float v ) {
  5509. vec4 r = vec4( fract( v * PackFactors ), v );
  5510. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  5511. }
  5512. float unpackRGBAToDepth( const in vec4 v ) {
  5513. return dot( v, UnpackFactors );
  5514. }
  5515. vec2 packDepthToRG( in highp float v ) {
  5516. return packDepthToRGBA( v ).yx;
  5517. }
  5518. float unpackRGToDepth( const in highp vec2 v ) {
  5519. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  5520. }
  5521. vec4 pack2HalfToRGBA( vec2 v ) {
  5522. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  5523. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  5524. }
  5525. vec2 unpackRGBATo2Half( vec4 v ) {
  5526. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  5527. }
  5528. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  5529. return ( viewZ + near ) / ( near - far );
  5530. }
  5531. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5532. return depth * ( near - far ) - near;
  5533. }
  5534. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  5535. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  5536. }
  5537. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5538. return ( near * far ) / ( ( far - near ) * depth - far );
  5539. }`,vIe=`#ifdef PREMULTIPLIED_ALPHA
  5540. gl_FragColor.rgb *= gl_FragColor.a;
  5541. #endif`,_Ie=`vec4 mvPosition = vec4( transformed, 1.0 );
  5542. #ifdef USE_BATCHING
  5543. mvPosition = batchingMatrix * mvPosition;
  5544. #endif
  5545. #ifdef USE_INSTANCING
  5546. mvPosition = instanceMatrix * mvPosition;
  5547. #endif
  5548. mvPosition = modelViewMatrix * mvPosition;
  5549. gl_Position = projectionMatrix * mvPosition;`,wIe=`#ifdef DITHERING
  5550. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5551. #endif`,SIe=`#ifdef DITHERING
  5552. vec3 dithering( vec3 color ) {
  5553. float grid_position = rand( gl_FragCoord.xy );
  5554. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  5555. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  5556. return color + dither_shift_RGB;
  5557. }
  5558. #endif`,MIe=`float roughnessFactor = roughness;
  5559. #ifdef USE_ROUGHNESSMAP
  5560. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5561. roughnessFactor *= texelRoughness.g;
  5562. #endif`,EIe=`#ifdef USE_ROUGHNESSMAP
  5563. uniform sampler2D roughnessMap;
  5564. #endif`,AIe=`#if NUM_SPOT_LIGHT_COORDS > 0
  5565. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5566. #endif
  5567. #if NUM_SPOT_LIGHT_MAPS > 0
  5568. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  5569. #endif
  5570. #ifdef USE_SHADOWMAP
  5571. #if NUM_DIR_LIGHT_SHADOWS > 0
  5572. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  5573. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5574. struct DirectionalLightShadow {
  5575. float shadowBias;
  5576. float shadowNormalBias;
  5577. float shadowRadius;
  5578. vec2 shadowMapSize;
  5579. };
  5580. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5581. #endif
  5582. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5583. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  5584. struct SpotLightShadow {
  5585. float shadowBias;
  5586. float shadowNormalBias;
  5587. float shadowRadius;
  5588. vec2 shadowMapSize;
  5589. };
  5590. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5591. #endif
  5592. #if NUM_POINT_LIGHT_SHADOWS > 0
  5593. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  5594. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5595. struct PointLightShadow {
  5596. float shadowBias;
  5597. float shadowNormalBias;
  5598. float shadowRadius;
  5599. vec2 shadowMapSize;
  5600. float shadowCameraNear;
  5601. float shadowCameraFar;
  5602. };
  5603. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5604. #endif
  5605. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  5606. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  5607. }
  5608. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  5609. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  5610. }
  5611. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  5612. float occlusion = 1.0;
  5613. vec2 distribution = texture2DDistribution( shadow, uv );
  5614. float hard_shadow = step( compare , distribution.x );
  5615. if (hard_shadow != 1.0 ) {
  5616. float distance = compare - distribution.x ;
  5617. float variance = max( 0.00000, distribution.y * distribution.y );
  5618. 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 );
  5619. }
  5620. return occlusion;
  5621. }
  5622. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  5623. float shadow = 1.0;
  5624. shadowCoord.xyz /= shadowCoord.w;
  5625. shadowCoord.z += shadowBias;
  5626. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  5627. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  5628. if ( frustumTest ) {
  5629. #if defined( SHADOWMAP_TYPE_PCF )
  5630. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5631. float dx0 = - texelSize.x * shadowRadius;
  5632. float dy0 = - texelSize.y * shadowRadius;
  5633. float dx1 = + texelSize.x * shadowRadius;
  5634. float dy1 = + texelSize.y * shadowRadius;
  5635. float dx2 = dx0 / 2.0;
  5636. float dy2 = dy0 / 2.0;
  5637. float dx3 = dx1 / 2.0;
  5638. float dy3 = dy1 / 2.0;
  5639. shadow = (
  5640. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  5641. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  5642. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  5643. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  5644. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  5645. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  5646. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  5647. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  5648. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  5649. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  5650. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  5651. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  5652. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  5653. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  5654. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  5655. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  5656. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  5657. ) * ( 1.0 / 17.0 );
  5658. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5659. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5660. float dx = texelSize.x;
  5661. float dy = texelSize.y;
  5662. vec2 uv = shadowCoord.xy;
  5663. vec2 f = fract( uv * shadowMapSize + 0.5 );
  5664. uv -= f * texelSize;
  5665. shadow = (
  5666. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  5667. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  5668. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  5669. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  5670. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  5671. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  5672. f.x ) +
  5673. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  5674. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  5675. f.x ) +
  5676. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  5677. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  5678. f.y ) +
  5679. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  5680. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  5681. f.y ) +
  5682. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  5683. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  5684. f.x ),
  5685. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  5686. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  5687. f.x ),
  5688. f.y )
  5689. ) * ( 1.0 / 9.0 );
  5690. #elif defined( SHADOWMAP_TYPE_VSM )
  5691. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  5692. #else
  5693. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  5694. #endif
  5695. }
  5696. return shadow;
  5697. }
  5698. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  5699. vec3 absV = abs( v );
  5700. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  5701. absV *= scaleToCube;
  5702. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  5703. vec2 planar = v.xy;
  5704. float almostATexel = 1.5 * texelSizeY;
  5705. float almostOne = 1.0 - almostATexel;
  5706. if ( absV.z >= almostOne ) {
  5707. if ( v.z > 0.0 )
  5708. planar.x = 4.0 - v.x;
  5709. } else if ( absV.x >= almostOne ) {
  5710. float signX = sign( v.x );
  5711. planar.x = v.z * signX + 2.0 * signX;
  5712. } else if ( absV.y >= almostOne ) {
  5713. float signY = sign( v.y );
  5714. planar.x = v.x + 2.0 * signY + 2.0;
  5715. planar.y = v.z * signY - 2.0;
  5716. }
  5717. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  5718. }
  5719. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  5720. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  5721. vec3 lightToPosition = shadowCoord.xyz;
  5722. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  5723. vec3 bd3D = normalize( lightToPosition );
  5724. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  5725. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  5726. return (
  5727. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  5728. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  5729. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  5730. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  5731. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  5732. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  5733. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  5734. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  5735. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  5736. ) * ( 1.0 / 9.0 );
  5737. #else
  5738. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  5739. #endif
  5740. }
  5741. #endif`,TIe=`#if NUM_SPOT_LIGHT_COORDS > 0
  5742. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  5743. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5744. #endif
  5745. #ifdef USE_SHADOWMAP
  5746. #if NUM_DIR_LIGHT_SHADOWS > 0
  5747. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  5748. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5749. struct DirectionalLightShadow {
  5750. float shadowBias;
  5751. float shadowNormalBias;
  5752. float shadowRadius;
  5753. vec2 shadowMapSize;
  5754. };
  5755. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5756. #endif
  5757. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5758. struct SpotLightShadow {
  5759. float shadowBias;
  5760. float shadowNormalBias;
  5761. float shadowRadius;
  5762. vec2 shadowMapSize;
  5763. };
  5764. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5765. #endif
  5766. #if NUM_POINT_LIGHT_SHADOWS > 0
  5767. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  5768. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5769. struct PointLightShadow {
  5770. float shadowBias;
  5771. float shadowNormalBias;
  5772. float shadowRadius;
  5773. vec2 shadowMapSize;
  5774. float shadowCameraNear;
  5775. float shadowCameraFar;
  5776. };
  5777. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5778. #endif
  5779. #endif`,NIe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  5780. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  5781. vec4 shadowWorldPosition;
  5782. #endif
  5783. #if defined( USE_SHADOWMAP )
  5784. #if NUM_DIR_LIGHT_SHADOWS > 0
  5785. #pragma unroll_loop_start
  5786. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5787. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  5788. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  5789. }
  5790. #pragma unroll_loop_end
  5791. #endif
  5792. #if NUM_POINT_LIGHT_SHADOWS > 0
  5793. #pragma unroll_loop_start
  5794. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5795. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  5796. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  5797. }
  5798. #pragma unroll_loop_end
  5799. #endif
  5800. #endif
  5801. #if NUM_SPOT_LIGHT_COORDS > 0
  5802. #pragma unroll_loop_start
  5803. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  5804. shadowWorldPosition = worldPosition;
  5805. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5806. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  5807. #endif
  5808. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  5809. }
  5810. #pragma unroll_loop_end
  5811. #endif`,CIe=`float getShadowMask() {
  5812. float shadow = 1.0;
  5813. #ifdef USE_SHADOWMAP
  5814. #if NUM_DIR_LIGHT_SHADOWS > 0
  5815. DirectionalLightShadow directionalLight;
  5816. #pragma unroll_loop_start
  5817. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5818. directionalLight = directionalLightShadows[ i ];
  5819. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5820. }
  5821. #pragma unroll_loop_end
  5822. #endif
  5823. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5824. SpotLightShadow spotLight;
  5825. #pragma unroll_loop_start
  5826. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  5827. spotLight = spotLightShadows[ i ];
  5828. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5829. }
  5830. #pragma unroll_loop_end
  5831. #endif
  5832. #if NUM_POINT_LIGHT_SHADOWS > 0
  5833. PointLightShadow pointLight;
  5834. #pragma unroll_loop_start
  5835. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5836. pointLight = pointLightShadows[ i ];
  5837. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  5838. }
  5839. #pragma unroll_loop_end
  5840. #endif
  5841. #endif
  5842. return shadow;
  5843. }`,kIe=`#ifdef USE_SKINNING
  5844. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  5845. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  5846. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  5847. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  5848. #endif`,PIe=`#ifdef USE_SKINNING
  5849. uniform mat4 bindMatrix;
  5850. uniform mat4 bindMatrixInverse;
  5851. uniform highp sampler2D boneTexture;
  5852. mat4 getBoneMatrix( const in float i ) {
  5853. int size = textureSize( boneTexture, 0 ).x;
  5854. int j = int( i ) * 4;
  5855. int x = j % size;
  5856. int y = j / size;
  5857. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  5858. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  5859. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  5860. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  5861. return mat4( v1, v2, v3, v4 );
  5862. }
  5863. #endif`,jIe=`#ifdef USE_SKINNING
  5864. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  5865. vec4 skinned = vec4( 0.0 );
  5866. skinned += boneMatX * skinVertex * skinWeight.x;
  5867. skinned += boneMatY * skinVertex * skinWeight.y;
  5868. skinned += boneMatZ * skinVertex * skinWeight.z;
  5869. skinned += boneMatW * skinVertex * skinWeight.w;
  5870. transformed = ( bindMatrixInverse * skinned ).xyz;
  5871. #endif`,RIe=`#ifdef USE_SKINNING
  5872. mat4 skinMatrix = mat4( 0.0 );
  5873. skinMatrix += skinWeight.x * boneMatX;
  5874. skinMatrix += skinWeight.y * boneMatY;
  5875. skinMatrix += skinWeight.z * boneMatZ;
  5876. skinMatrix += skinWeight.w * boneMatW;
  5877. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  5878. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  5879. #ifdef USE_TANGENT
  5880. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  5881. #endif
  5882. #endif`,DIe=`float specularStrength;
  5883. #ifdef USE_SPECULARMAP
  5884. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5885. specularStrength = texelSpecular.r;
  5886. #else
  5887. specularStrength = 1.0;
  5888. #endif`,OIe=`#ifdef USE_SPECULARMAP
  5889. uniform sampler2D specularMap;
  5890. #endif`,LIe=`#if defined( TONE_MAPPING )
  5891. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5892. #endif`,IIe=`#ifndef saturate
  5893. #define saturate( a ) clamp( a, 0.0, 1.0 )
  5894. #endif
  5895. uniform float toneMappingExposure;
  5896. vec3 LinearToneMapping( vec3 color ) {
  5897. return saturate( toneMappingExposure * color );
  5898. }
  5899. vec3 ReinhardToneMapping( vec3 color ) {
  5900. color *= toneMappingExposure;
  5901. return saturate( color / ( vec3( 1.0 ) + color ) );
  5902. }
  5903. vec3 OptimizedCineonToneMapping( vec3 color ) {
  5904. color *= toneMappingExposure;
  5905. color = max( vec3( 0.0 ), color - 0.004 );
  5906. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  5907. }
  5908. vec3 RRTAndODTFit( vec3 v ) {
  5909. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  5910. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  5911. return a / b;
  5912. }
  5913. vec3 ACESFilmicToneMapping( vec3 color ) {
  5914. const mat3 ACESInputMat = mat3(
  5915. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  5916. vec3( 0.04823, 0.01566, 0.83777 )
  5917. );
  5918. const mat3 ACESOutputMat = mat3(
  5919. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  5920. vec3( -0.07367, -0.00605, 1.07602 )
  5921. );
  5922. color *= toneMappingExposure / 0.6;
  5923. color = ACESInputMat * color;
  5924. color = RRTAndODTFit( color );
  5925. color = ACESOutputMat * color;
  5926. return saturate( color );
  5927. }
  5928. vec3 CustomToneMapping( vec3 color ) { return color; }`,FIe=`#ifdef USE_TRANSMISSION
  5929. material.transmission = transmission;
  5930. material.transmissionAlpha = 1.0;
  5931. material.thickness = thickness;
  5932. material.attenuationDistance = attenuationDistance;
  5933. material.attenuationColor = attenuationColor;
  5934. #ifdef USE_TRANSMISSIONMAP
  5935. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  5936. #endif
  5937. #ifdef USE_THICKNESSMAP
  5938. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  5939. #endif
  5940. vec3 pos = vWorldPosition;
  5941. vec3 v = normalize( cameraPosition - pos );
  5942. vec3 n = inverseTransformDirection( normal, viewMatrix );
  5943. vec4 transmitted = getIBLVolumeRefraction(
  5944. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  5945. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  5946. material.attenuationColor, material.attenuationDistance );
  5947. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  5948. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  5949. #endif`,UIe=`#ifdef USE_TRANSMISSION
  5950. uniform float transmission;
  5951. uniform float thickness;
  5952. uniform float attenuationDistance;
  5953. uniform vec3 attenuationColor;
  5954. #ifdef USE_TRANSMISSIONMAP
  5955. uniform sampler2D transmissionMap;
  5956. #endif
  5957. #ifdef USE_THICKNESSMAP
  5958. uniform sampler2D thicknessMap;
  5959. #endif
  5960. uniform vec2 transmissionSamplerSize;
  5961. uniform sampler2D transmissionSamplerMap;
  5962. uniform mat4 modelMatrix;
  5963. uniform mat4 projectionMatrix;
  5964. varying vec3 vWorldPosition;
  5965. float w0( float a ) {
  5966. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  5967. }
  5968. float w1( float a ) {
  5969. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  5970. }
  5971. float w2( float a ){
  5972. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  5973. }
  5974. float w3( float a ) {
  5975. return ( 1.0 / 6.0 ) * ( a * a * a );
  5976. }
  5977. float g0( float a ) {
  5978. return w0( a ) + w1( a );
  5979. }
  5980. float g1( float a ) {
  5981. return w2( a ) + w3( a );
  5982. }
  5983. float h0( float a ) {
  5984. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  5985. }
  5986. float h1( float a ) {
  5987. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  5988. }
  5989. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  5990. uv = uv * texelSize.zw + 0.5;
  5991. vec2 iuv = floor( uv );
  5992. vec2 fuv = fract( uv );
  5993. float g0x = g0( fuv.x );
  5994. float g1x = g1( fuv.x );
  5995. float h0x = h0( fuv.x );
  5996. float h1x = h1( fuv.x );
  5997. float h0y = h0( fuv.y );
  5998. float h1y = h1( fuv.y );
  5999. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  6000. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  6001. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  6002. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  6003. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  6004. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  6005. }
  6006. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  6007. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  6008. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  6009. vec2 fLodSizeInv = 1.0 / fLodSize;
  6010. vec2 cLodSizeInv = 1.0 / cLodSize;
  6011. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  6012. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  6013. return mix( fSample, cSample, fract( lod ) );
  6014. }
  6015. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  6016. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  6017. vec3 modelScale;
  6018. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  6019. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  6020. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  6021. return normalize( refractionVector ) * thickness * modelScale;
  6022. }
  6023. float applyIorToRoughness( const in float roughness, const in float ior ) {
  6024. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  6025. }
  6026. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  6027. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  6028. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  6029. }
  6030. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  6031. if ( isinf( attenuationDistance ) ) {
  6032. return vec3( 1.0 );
  6033. } else {
  6034. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  6035. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  6036. }
  6037. }
  6038. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  6039. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  6040. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  6041. const in vec3 attenuationColor, const in float attenuationDistance ) {
  6042. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  6043. vec3 refractedRayExit = position + transmissionRay;
  6044. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  6045. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  6046. refractionCoords += 1.0;
  6047. refractionCoords /= 2.0;
  6048. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  6049. vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  6050. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  6051. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  6052. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  6053. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  6054. }
  6055. #endif`,zIe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6056. varying vec2 vUv;
  6057. #endif
  6058. #ifdef USE_MAP
  6059. varying vec2 vMapUv;
  6060. #endif
  6061. #ifdef USE_ALPHAMAP
  6062. varying vec2 vAlphaMapUv;
  6063. #endif
  6064. #ifdef USE_LIGHTMAP
  6065. varying vec2 vLightMapUv;
  6066. #endif
  6067. #ifdef USE_AOMAP
  6068. varying vec2 vAoMapUv;
  6069. #endif
  6070. #ifdef USE_BUMPMAP
  6071. varying vec2 vBumpMapUv;
  6072. #endif
  6073. #ifdef USE_NORMALMAP
  6074. varying vec2 vNormalMapUv;
  6075. #endif
  6076. #ifdef USE_EMISSIVEMAP
  6077. varying vec2 vEmissiveMapUv;
  6078. #endif
  6079. #ifdef USE_METALNESSMAP
  6080. varying vec2 vMetalnessMapUv;
  6081. #endif
  6082. #ifdef USE_ROUGHNESSMAP
  6083. varying vec2 vRoughnessMapUv;
  6084. #endif
  6085. #ifdef USE_ANISOTROPYMAP
  6086. varying vec2 vAnisotropyMapUv;
  6087. #endif
  6088. #ifdef USE_CLEARCOATMAP
  6089. varying vec2 vClearcoatMapUv;
  6090. #endif
  6091. #ifdef USE_CLEARCOAT_NORMALMAP
  6092. varying vec2 vClearcoatNormalMapUv;
  6093. #endif
  6094. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6095. varying vec2 vClearcoatRoughnessMapUv;
  6096. #endif
  6097. #ifdef USE_IRIDESCENCEMAP
  6098. varying vec2 vIridescenceMapUv;
  6099. #endif
  6100. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6101. varying vec2 vIridescenceThicknessMapUv;
  6102. #endif
  6103. #ifdef USE_SHEEN_COLORMAP
  6104. varying vec2 vSheenColorMapUv;
  6105. #endif
  6106. #ifdef USE_SHEEN_ROUGHNESSMAP
  6107. varying vec2 vSheenRoughnessMapUv;
  6108. #endif
  6109. #ifdef USE_SPECULARMAP
  6110. varying vec2 vSpecularMapUv;
  6111. #endif
  6112. #ifdef USE_SPECULAR_COLORMAP
  6113. varying vec2 vSpecularColorMapUv;
  6114. #endif
  6115. #ifdef USE_SPECULAR_INTENSITYMAP
  6116. varying vec2 vSpecularIntensityMapUv;
  6117. #endif
  6118. #ifdef USE_TRANSMISSIONMAP
  6119. uniform mat3 transmissionMapTransform;
  6120. varying vec2 vTransmissionMapUv;
  6121. #endif
  6122. #ifdef USE_THICKNESSMAP
  6123. uniform mat3 thicknessMapTransform;
  6124. varying vec2 vThicknessMapUv;
  6125. #endif`,BIe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6126. varying vec2 vUv;
  6127. #endif
  6128. #ifdef USE_MAP
  6129. uniform mat3 mapTransform;
  6130. varying vec2 vMapUv;
  6131. #endif
  6132. #ifdef USE_ALPHAMAP
  6133. uniform mat3 alphaMapTransform;
  6134. varying vec2 vAlphaMapUv;
  6135. #endif
  6136. #ifdef USE_LIGHTMAP
  6137. uniform mat3 lightMapTransform;
  6138. varying vec2 vLightMapUv;
  6139. #endif
  6140. #ifdef USE_AOMAP
  6141. uniform mat3 aoMapTransform;
  6142. varying vec2 vAoMapUv;
  6143. #endif
  6144. #ifdef USE_BUMPMAP
  6145. uniform mat3 bumpMapTransform;
  6146. varying vec2 vBumpMapUv;
  6147. #endif
  6148. #ifdef USE_NORMALMAP
  6149. uniform mat3 normalMapTransform;
  6150. varying vec2 vNormalMapUv;
  6151. #endif
  6152. #ifdef USE_DISPLACEMENTMAP
  6153. uniform mat3 displacementMapTransform;
  6154. varying vec2 vDisplacementMapUv;
  6155. #endif
  6156. #ifdef USE_EMISSIVEMAP
  6157. uniform mat3 emissiveMapTransform;
  6158. varying vec2 vEmissiveMapUv;
  6159. #endif
  6160. #ifdef USE_METALNESSMAP
  6161. uniform mat3 metalnessMapTransform;
  6162. varying vec2 vMetalnessMapUv;
  6163. #endif
  6164. #ifdef USE_ROUGHNESSMAP
  6165. uniform mat3 roughnessMapTransform;
  6166. varying vec2 vRoughnessMapUv;
  6167. #endif
  6168. #ifdef USE_ANISOTROPYMAP
  6169. uniform mat3 anisotropyMapTransform;
  6170. varying vec2 vAnisotropyMapUv;
  6171. #endif
  6172. #ifdef USE_CLEARCOATMAP
  6173. uniform mat3 clearcoatMapTransform;
  6174. varying vec2 vClearcoatMapUv;
  6175. #endif
  6176. #ifdef USE_CLEARCOAT_NORMALMAP
  6177. uniform mat3 clearcoatNormalMapTransform;
  6178. varying vec2 vClearcoatNormalMapUv;
  6179. #endif
  6180. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6181. uniform mat3 clearcoatRoughnessMapTransform;
  6182. varying vec2 vClearcoatRoughnessMapUv;
  6183. #endif
  6184. #ifdef USE_SHEEN_COLORMAP
  6185. uniform mat3 sheenColorMapTransform;
  6186. varying vec2 vSheenColorMapUv;
  6187. #endif
  6188. #ifdef USE_SHEEN_ROUGHNESSMAP
  6189. uniform mat3 sheenRoughnessMapTransform;
  6190. varying vec2 vSheenRoughnessMapUv;
  6191. #endif
  6192. #ifdef USE_IRIDESCENCEMAP
  6193. uniform mat3 iridescenceMapTransform;
  6194. varying vec2 vIridescenceMapUv;
  6195. #endif
  6196. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6197. uniform mat3 iridescenceThicknessMapTransform;
  6198. varying vec2 vIridescenceThicknessMapUv;
  6199. #endif
  6200. #ifdef USE_SPECULARMAP
  6201. uniform mat3 specularMapTransform;
  6202. varying vec2 vSpecularMapUv;
  6203. #endif
  6204. #ifdef USE_SPECULAR_COLORMAP
  6205. uniform mat3 specularColorMapTransform;
  6206. varying vec2 vSpecularColorMapUv;
  6207. #endif
  6208. #ifdef USE_SPECULAR_INTENSITYMAP
  6209. uniform mat3 specularIntensityMapTransform;
  6210. varying vec2 vSpecularIntensityMapUv;
  6211. #endif
  6212. #ifdef USE_TRANSMISSIONMAP
  6213. uniform mat3 transmissionMapTransform;
  6214. varying vec2 vTransmissionMapUv;
  6215. #endif
  6216. #ifdef USE_THICKNESSMAP
  6217. uniform mat3 thicknessMapTransform;
  6218. varying vec2 vThicknessMapUv;
  6219. #endif`,HIe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6220. vUv = vec3( uv, 1 ).xy;
  6221. #endif
  6222. #ifdef USE_MAP
  6223. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  6224. #endif
  6225. #ifdef USE_ALPHAMAP
  6226. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  6227. #endif
  6228. #ifdef USE_LIGHTMAP
  6229. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  6230. #endif
  6231. #ifdef USE_AOMAP
  6232. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  6233. #endif
  6234. #ifdef USE_BUMPMAP
  6235. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  6236. #endif
  6237. #ifdef USE_NORMALMAP
  6238. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  6239. #endif
  6240. #ifdef USE_DISPLACEMENTMAP
  6241. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  6242. #endif
  6243. #ifdef USE_EMISSIVEMAP
  6244. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  6245. #endif
  6246. #ifdef USE_METALNESSMAP
  6247. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  6248. #endif
  6249. #ifdef USE_ROUGHNESSMAP
  6250. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  6251. #endif
  6252. #ifdef USE_ANISOTROPYMAP
  6253. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  6254. #endif
  6255. #ifdef USE_CLEARCOATMAP
  6256. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  6257. #endif
  6258. #ifdef USE_CLEARCOAT_NORMALMAP
  6259. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  6260. #endif
  6261. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6262. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  6263. #endif
  6264. #ifdef USE_IRIDESCENCEMAP
  6265. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  6266. #endif
  6267. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6268. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  6269. #endif
  6270. #ifdef USE_SHEEN_COLORMAP
  6271. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  6272. #endif
  6273. #ifdef USE_SHEEN_ROUGHNESSMAP
  6274. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  6275. #endif
  6276. #ifdef USE_SPECULARMAP
  6277. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  6278. #endif
  6279. #ifdef USE_SPECULAR_COLORMAP
  6280. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  6281. #endif
  6282. #ifdef USE_SPECULAR_INTENSITYMAP
  6283. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  6284. #endif
  6285. #ifdef USE_TRANSMISSIONMAP
  6286. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  6287. #endif
  6288. #ifdef USE_THICKNESSMAP
  6289. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  6290. #endif`,$Ie=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  6291. vec4 worldPosition = vec4( transformed, 1.0 );
  6292. #ifdef USE_BATCHING
  6293. worldPosition = batchingMatrix * worldPosition;
  6294. #endif
  6295. #ifdef USE_INSTANCING
  6296. worldPosition = instanceMatrix * worldPosition;
  6297. #endif
  6298. worldPosition = modelMatrix * worldPosition;
  6299. #endif`;const VIe=`varying vec2 vUv;
  6300. uniform mat3 uvTransform;
  6301. void main() {
  6302. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  6303. gl_Position = vec4( position.xy, 1.0, 1.0 );
  6304. }`,GIe=`uniform sampler2D t2D;
  6305. uniform float backgroundIntensity;
  6306. varying vec2 vUv;
  6307. void main() {
  6308. vec4 texColor = texture2D( t2D, vUv );
  6309. #ifdef DECODE_VIDEO_TEXTURE
  6310. 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 );
  6311. #endif
  6312. texColor.rgb *= backgroundIntensity;
  6313. gl_FragColor = texColor;
  6314. #include <tonemapping_fragment>
  6315. #include <colorspace_fragment>
  6316. }`,WIe=`varying vec3 vWorldDirection;
  6317. #include <common>
  6318. void main() {
  6319. vWorldDirection = transformDirection( position, modelMatrix );
  6320. #include <begin_vertex>
  6321. #include <project_vertex>
  6322. gl_Position.z = gl_Position.w;
  6323. }`,qIe=`#ifdef ENVMAP_TYPE_CUBE
  6324. uniform samplerCube envMap;
  6325. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6326. uniform sampler2D envMap;
  6327. #endif
  6328. uniform float flipEnvMap;
  6329. uniform float backgroundBlurriness;
  6330. uniform float backgroundIntensity;
  6331. varying vec3 vWorldDirection;
  6332. #include <cube_uv_reflection_fragment>
  6333. void main() {
  6334. #ifdef ENVMAP_TYPE_CUBE
  6335. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  6336. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6337. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  6338. #else
  6339. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  6340. #endif
  6341. texColor.rgb *= backgroundIntensity;
  6342. gl_FragColor = texColor;
  6343. #include <tonemapping_fragment>
  6344. #include <colorspace_fragment>
  6345. }`,KIe=`varying vec3 vWorldDirection;
  6346. #include <common>
  6347. void main() {
  6348. vWorldDirection = transformDirection( position, modelMatrix );
  6349. #include <begin_vertex>
  6350. #include <project_vertex>
  6351. gl_Position.z = gl_Position.w;
  6352. }`,XIe=`uniform samplerCube tCube;
  6353. uniform float tFlip;
  6354. uniform float opacity;
  6355. varying vec3 vWorldDirection;
  6356. void main() {
  6357. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  6358. gl_FragColor = texColor;
  6359. gl_FragColor.a *= opacity;
  6360. #include <tonemapping_fragment>
  6361. #include <colorspace_fragment>
  6362. }`,YIe=`#include <common>
  6363. #include <batching_pars_vertex>
  6364. #include <uv_pars_vertex>
  6365. #include <displacementmap_pars_vertex>
  6366. #include <morphtarget_pars_vertex>
  6367. #include <skinning_pars_vertex>
  6368. #include <logdepthbuf_pars_vertex>
  6369. #include <clipping_planes_pars_vertex>
  6370. varying vec2 vHighPrecisionZW;
  6371. void main() {
  6372. #include <uv_vertex>
  6373. #include <batching_vertex>
  6374. #include <skinbase_vertex>
  6375. #ifdef USE_DISPLACEMENTMAP
  6376. #include <beginnormal_vertex>
  6377. #include <morphnormal_vertex>
  6378. #include <skinnormal_vertex>
  6379. #endif
  6380. #include <begin_vertex>
  6381. #include <morphtarget_vertex>
  6382. #include <skinning_vertex>
  6383. #include <displacementmap_vertex>
  6384. #include <project_vertex>
  6385. #include <logdepthbuf_vertex>
  6386. #include <clipping_planes_vertex>
  6387. vHighPrecisionZW = gl_Position.zw;
  6388. }`,ZIe=`#if DEPTH_PACKING == 3200
  6389. uniform float opacity;
  6390. #endif
  6391. #include <common>
  6392. #include <packing>
  6393. #include <uv_pars_fragment>
  6394. #include <map_pars_fragment>
  6395. #include <alphamap_pars_fragment>
  6396. #include <alphatest_pars_fragment>
  6397. #include <alphahash_pars_fragment>
  6398. #include <logdepthbuf_pars_fragment>
  6399. #include <clipping_planes_pars_fragment>
  6400. varying vec2 vHighPrecisionZW;
  6401. void main() {
  6402. #include <clipping_planes_fragment>
  6403. vec4 diffuseColor = vec4( 1.0 );
  6404. #if DEPTH_PACKING == 3200
  6405. diffuseColor.a = opacity;
  6406. #endif
  6407. #include <map_fragment>
  6408. #include <alphamap_fragment>
  6409. #include <alphatest_fragment>
  6410. #include <alphahash_fragment>
  6411. #include <logdepthbuf_fragment>
  6412. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  6413. #if DEPTH_PACKING == 3200
  6414. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  6415. #elif DEPTH_PACKING == 3201
  6416. gl_FragColor = packDepthToRGBA( fragCoordZ );
  6417. #endif
  6418. }`,QIe=`#define DISTANCE
  6419. varying vec3 vWorldPosition;
  6420. #include <common>
  6421. #include <batching_pars_vertex>
  6422. #include <uv_pars_vertex>
  6423. #include <displacementmap_pars_vertex>
  6424. #include <morphtarget_pars_vertex>
  6425. #include <skinning_pars_vertex>
  6426. #include <clipping_planes_pars_vertex>
  6427. void main() {
  6428. #include <uv_vertex>
  6429. #include <batching_vertex>
  6430. #include <skinbase_vertex>
  6431. #ifdef USE_DISPLACEMENTMAP
  6432. #include <beginnormal_vertex>
  6433. #include <morphnormal_vertex>
  6434. #include <skinnormal_vertex>
  6435. #endif
  6436. #include <begin_vertex>
  6437. #include <morphtarget_vertex>
  6438. #include <skinning_vertex>
  6439. #include <displacementmap_vertex>
  6440. #include <project_vertex>
  6441. #include <worldpos_vertex>
  6442. #include <clipping_planes_vertex>
  6443. vWorldPosition = worldPosition.xyz;
  6444. }`,JIe=`#define DISTANCE
  6445. uniform vec3 referencePosition;
  6446. uniform float nearDistance;
  6447. uniform float farDistance;
  6448. varying vec3 vWorldPosition;
  6449. #include <common>
  6450. #include <packing>
  6451. #include <uv_pars_fragment>
  6452. #include <map_pars_fragment>
  6453. #include <alphamap_pars_fragment>
  6454. #include <alphatest_pars_fragment>
  6455. #include <alphahash_pars_fragment>
  6456. #include <clipping_planes_pars_fragment>
  6457. void main () {
  6458. #include <clipping_planes_fragment>
  6459. vec4 diffuseColor = vec4( 1.0 );
  6460. #include <map_fragment>
  6461. #include <alphamap_fragment>
  6462. #include <alphatest_fragment>
  6463. #include <alphahash_fragment>
  6464. float dist = length( vWorldPosition - referencePosition );
  6465. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  6466. dist = saturate( dist );
  6467. gl_FragColor = packDepthToRGBA( dist );
  6468. }`,e5e=`varying vec3 vWorldDirection;
  6469. #include <common>
  6470. void main() {
  6471. vWorldDirection = transformDirection( position, modelMatrix );
  6472. #include <begin_vertex>
  6473. #include <project_vertex>
  6474. }`,t5e=`uniform sampler2D tEquirect;
  6475. varying vec3 vWorldDirection;
  6476. #include <common>
  6477. void main() {
  6478. vec3 direction = normalize( vWorldDirection );
  6479. vec2 sampleUV = equirectUv( direction );
  6480. gl_FragColor = texture2D( tEquirect, sampleUV );
  6481. #include <tonemapping_fragment>
  6482. #include <colorspace_fragment>
  6483. }`,n5e=`uniform float scale;
  6484. attribute float lineDistance;
  6485. varying float vLineDistance;
  6486. #include <common>
  6487. #include <uv_pars_vertex>
  6488. #include <color_pars_vertex>
  6489. #include <fog_pars_vertex>
  6490. #include <morphtarget_pars_vertex>
  6491. #include <logdepthbuf_pars_vertex>
  6492. #include <clipping_planes_pars_vertex>
  6493. void main() {
  6494. vLineDistance = scale * lineDistance;
  6495. #include <uv_vertex>
  6496. #include <color_vertex>
  6497. #include <morphcolor_vertex>
  6498. #include <begin_vertex>
  6499. #include <morphtarget_vertex>
  6500. #include <project_vertex>
  6501. #include <logdepthbuf_vertex>
  6502. #include <clipping_planes_vertex>
  6503. #include <fog_vertex>
  6504. }`,r5e=`uniform vec3 diffuse;
  6505. uniform float opacity;
  6506. uniform float dashSize;
  6507. uniform float totalSize;
  6508. varying float vLineDistance;
  6509. #include <common>
  6510. #include <color_pars_fragment>
  6511. #include <uv_pars_fragment>
  6512. #include <map_pars_fragment>
  6513. #include <fog_pars_fragment>
  6514. #include <logdepthbuf_pars_fragment>
  6515. #include <clipping_planes_pars_fragment>
  6516. void main() {
  6517. #include <clipping_planes_fragment>
  6518. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  6519. discard;
  6520. }
  6521. vec3 outgoingLight = vec3( 0.0 );
  6522. vec4 diffuseColor = vec4( diffuse, opacity );
  6523. #include <logdepthbuf_fragment>
  6524. #include <map_fragment>
  6525. #include <color_fragment>
  6526. outgoingLight = diffuseColor.rgb;
  6527. #include <opaque_fragment>
  6528. #include <tonemapping_fragment>
  6529. #include <colorspace_fragment>
  6530. #include <fog_fragment>
  6531. #include <premultiplied_alpha_fragment>
  6532. }`,i5e=`#include <common>
  6533. #include <batching_pars_vertex>
  6534. #include <uv_pars_vertex>
  6535. #include <envmap_pars_vertex>
  6536. #include <color_pars_vertex>
  6537. #include <fog_pars_vertex>
  6538. #include <morphtarget_pars_vertex>
  6539. #include <skinning_pars_vertex>
  6540. #include <logdepthbuf_pars_vertex>
  6541. #include <clipping_planes_pars_vertex>
  6542. void main() {
  6543. #include <uv_vertex>
  6544. #include <color_vertex>
  6545. #include <morphcolor_vertex>
  6546. #include <batching_vertex>
  6547. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  6548. #include <beginnormal_vertex>
  6549. #include <morphnormal_vertex>
  6550. #include <skinbase_vertex>
  6551. #include <skinnormal_vertex>
  6552. #include <defaultnormal_vertex>
  6553. #endif
  6554. #include <begin_vertex>
  6555. #include <morphtarget_vertex>
  6556. #include <skinning_vertex>
  6557. #include <project_vertex>
  6558. #include <logdepthbuf_vertex>
  6559. #include <clipping_planes_vertex>
  6560. #include <worldpos_vertex>
  6561. #include <envmap_vertex>
  6562. #include <fog_vertex>
  6563. }`,a5e=`uniform vec3 diffuse;
  6564. uniform float opacity;
  6565. #ifndef FLAT_SHADED
  6566. varying vec3 vNormal;
  6567. #endif
  6568. #include <common>
  6569. #include <dithering_pars_fragment>
  6570. #include <color_pars_fragment>
  6571. #include <uv_pars_fragment>
  6572. #include <map_pars_fragment>
  6573. #include <alphamap_pars_fragment>
  6574. #include <alphatest_pars_fragment>
  6575. #include <alphahash_pars_fragment>
  6576. #include <aomap_pars_fragment>
  6577. #include <lightmap_pars_fragment>
  6578. #include <envmap_common_pars_fragment>
  6579. #include <envmap_pars_fragment>
  6580. #include <fog_pars_fragment>
  6581. #include <specularmap_pars_fragment>
  6582. #include <logdepthbuf_pars_fragment>
  6583. #include <clipping_planes_pars_fragment>
  6584. void main() {
  6585. #include <clipping_planes_fragment>
  6586. vec4 diffuseColor = vec4( diffuse, opacity );
  6587. #include <logdepthbuf_fragment>
  6588. #include <map_fragment>
  6589. #include <color_fragment>
  6590. #include <alphamap_fragment>
  6591. #include <alphatest_fragment>
  6592. #include <alphahash_fragment>
  6593. #include <specularmap_fragment>
  6594. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6595. #ifdef USE_LIGHTMAP
  6596. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  6597. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  6598. #else
  6599. reflectedLight.indirectDiffuse += vec3( 1.0 );
  6600. #endif
  6601. #include <aomap_fragment>
  6602. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  6603. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  6604. #include <envmap_fragment>
  6605. #include <opaque_fragment>
  6606. #include <tonemapping_fragment>
  6607. #include <colorspace_fragment>
  6608. #include <fog_fragment>
  6609. #include <premultiplied_alpha_fragment>
  6610. #include <dithering_fragment>
  6611. }`,s5e=`#define LAMBERT
  6612. varying vec3 vViewPosition;
  6613. #include <common>
  6614. #include <batching_pars_vertex>
  6615. #include <uv_pars_vertex>
  6616. #include <displacementmap_pars_vertex>
  6617. #include <envmap_pars_vertex>
  6618. #include <color_pars_vertex>
  6619. #include <fog_pars_vertex>
  6620. #include <normal_pars_vertex>
  6621. #include <morphtarget_pars_vertex>
  6622. #include <skinning_pars_vertex>
  6623. #include <shadowmap_pars_vertex>
  6624. #include <logdepthbuf_pars_vertex>
  6625. #include <clipping_planes_pars_vertex>
  6626. void main() {
  6627. #include <uv_vertex>
  6628. #include <color_vertex>
  6629. #include <morphcolor_vertex>
  6630. #include <batching_vertex>
  6631. #include <beginnormal_vertex>
  6632. #include <morphnormal_vertex>
  6633. #include <skinbase_vertex>
  6634. #include <skinnormal_vertex>
  6635. #include <defaultnormal_vertex>
  6636. #include <normal_vertex>
  6637. #include <begin_vertex>
  6638. #include <morphtarget_vertex>
  6639. #include <skinning_vertex>
  6640. #include <displacementmap_vertex>
  6641. #include <project_vertex>
  6642. #include <logdepthbuf_vertex>
  6643. #include <clipping_planes_vertex>
  6644. vViewPosition = - mvPosition.xyz;
  6645. #include <worldpos_vertex>
  6646. #include <envmap_vertex>
  6647. #include <shadowmap_vertex>
  6648. #include <fog_vertex>
  6649. }`,o5e=`#define LAMBERT
  6650. uniform vec3 diffuse;
  6651. uniform vec3 emissive;
  6652. uniform float opacity;
  6653. #include <common>
  6654. #include <packing>
  6655. #include <dithering_pars_fragment>
  6656. #include <color_pars_fragment>
  6657. #include <uv_pars_fragment>
  6658. #include <map_pars_fragment>
  6659. #include <alphamap_pars_fragment>
  6660. #include <alphatest_pars_fragment>
  6661. #include <alphahash_pars_fragment>
  6662. #include <aomap_pars_fragment>
  6663. #include <lightmap_pars_fragment>
  6664. #include <emissivemap_pars_fragment>
  6665. #include <envmap_common_pars_fragment>
  6666. #include <envmap_pars_fragment>
  6667. #include <fog_pars_fragment>
  6668. #include <bsdfs>
  6669. #include <lights_pars_begin>
  6670. #include <normal_pars_fragment>
  6671. #include <lights_lambert_pars_fragment>
  6672. #include <shadowmap_pars_fragment>
  6673. #include <bumpmap_pars_fragment>
  6674. #include <normalmap_pars_fragment>
  6675. #include <specularmap_pars_fragment>
  6676. #include <logdepthbuf_pars_fragment>
  6677. #include <clipping_planes_pars_fragment>
  6678. void main() {
  6679. #include <clipping_planes_fragment>
  6680. vec4 diffuseColor = vec4( diffuse, opacity );
  6681. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6682. vec3 totalEmissiveRadiance = emissive;
  6683. #include <logdepthbuf_fragment>
  6684. #include <map_fragment>
  6685. #include <color_fragment>
  6686. #include <alphamap_fragment>
  6687. #include <alphatest_fragment>
  6688. #include <alphahash_fragment>
  6689. #include <specularmap_fragment>
  6690. #include <normal_fragment_begin>
  6691. #include <normal_fragment_maps>
  6692. #include <emissivemap_fragment>
  6693. #include <lights_lambert_fragment>
  6694. #include <lights_fragment_begin>
  6695. #include <lights_fragment_maps>
  6696. #include <lights_fragment_end>
  6697. #include <aomap_fragment>
  6698. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  6699. #include <envmap_fragment>
  6700. #include <opaque_fragment>
  6701. #include <tonemapping_fragment>
  6702. #include <colorspace_fragment>
  6703. #include <fog_fragment>
  6704. #include <premultiplied_alpha_fragment>
  6705. #include <dithering_fragment>
  6706. }`,l5e=`#define MATCAP
  6707. varying vec3 vViewPosition;
  6708. #include <common>
  6709. #include <batching_pars_vertex>
  6710. #include <uv_pars_vertex>
  6711. #include <color_pars_vertex>
  6712. #include <displacementmap_pars_vertex>
  6713. #include <fog_pars_vertex>
  6714. #include <normal_pars_vertex>
  6715. #include <morphtarget_pars_vertex>
  6716. #include <skinning_pars_vertex>
  6717. #include <logdepthbuf_pars_vertex>
  6718. #include <clipping_planes_pars_vertex>
  6719. void main() {
  6720. #include <uv_vertex>
  6721. #include <color_vertex>
  6722. #include <morphcolor_vertex>
  6723. #include <batching_vertex>
  6724. #include <beginnormal_vertex>
  6725. #include <morphnormal_vertex>
  6726. #include <skinbase_vertex>
  6727. #include <skinnormal_vertex>
  6728. #include <defaultnormal_vertex>
  6729. #include <normal_vertex>
  6730. #include <begin_vertex>
  6731. #include <morphtarget_vertex>
  6732. #include <skinning_vertex>
  6733. #include <displacementmap_vertex>
  6734. #include <project_vertex>
  6735. #include <logdepthbuf_vertex>
  6736. #include <clipping_planes_vertex>
  6737. #include <fog_vertex>
  6738. vViewPosition = - mvPosition.xyz;
  6739. }`,c5e=`#define MATCAP
  6740. uniform vec3 diffuse;
  6741. uniform float opacity;
  6742. uniform sampler2D matcap;
  6743. varying vec3 vViewPosition;
  6744. #include <common>
  6745. #include <dithering_pars_fragment>
  6746. #include <color_pars_fragment>
  6747. #include <uv_pars_fragment>
  6748. #include <map_pars_fragment>
  6749. #include <alphamap_pars_fragment>
  6750. #include <alphatest_pars_fragment>
  6751. #include <alphahash_pars_fragment>
  6752. #include <fog_pars_fragment>
  6753. #include <normal_pars_fragment>
  6754. #include <bumpmap_pars_fragment>
  6755. #include <normalmap_pars_fragment>
  6756. #include <logdepthbuf_pars_fragment>
  6757. #include <clipping_planes_pars_fragment>
  6758. void main() {
  6759. #include <clipping_planes_fragment>
  6760. vec4 diffuseColor = vec4( diffuse, opacity );
  6761. #include <logdepthbuf_fragment>
  6762. #include <map_fragment>
  6763. #include <color_fragment>
  6764. #include <alphamap_fragment>
  6765. #include <alphatest_fragment>
  6766. #include <alphahash_fragment>
  6767. #include <normal_fragment_begin>
  6768. #include <normal_fragment_maps>
  6769. vec3 viewDir = normalize( vViewPosition );
  6770. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  6771. vec3 y = cross( viewDir, x );
  6772. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  6773. #ifdef USE_MATCAP
  6774. vec4 matcapColor = texture2D( matcap, uv );
  6775. #else
  6776. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  6777. #endif
  6778. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  6779. #include <opaque_fragment>
  6780. #include <tonemapping_fragment>
  6781. #include <colorspace_fragment>
  6782. #include <fog_fragment>
  6783. #include <premultiplied_alpha_fragment>
  6784. #include <dithering_fragment>
  6785. }`,u5e=`#define NORMAL
  6786. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6787. varying vec3 vViewPosition;
  6788. #endif
  6789. #include <common>
  6790. #include <batching_pars_vertex>
  6791. #include <uv_pars_vertex>
  6792. #include <displacementmap_pars_vertex>
  6793. #include <normal_pars_vertex>
  6794. #include <morphtarget_pars_vertex>
  6795. #include <skinning_pars_vertex>
  6796. #include <logdepthbuf_pars_vertex>
  6797. #include <clipping_planes_pars_vertex>
  6798. void main() {
  6799. #include <uv_vertex>
  6800. #include <batching_vertex>
  6801. #include <beginnormal_vertex>
  6802. #include <morphnormal_vertex>
  6803. #include <skinbase_vertex>
  6804. #include <skinnormal_vertex>
  6805. #include <defaultnormal_vertex>
  6806. #include <normal_vertex>
  6807. #include <begin_vertex>
  6808. #include <morphtarget_vertex>
  6809. #include <skinning_vertex>
  6810. #include <displacementmap_vertex>
  6811. #include <project_vertex>
  6812. #include <logdepthbuf_vertex>
  6813. #include <clipping_planes_vertex>
  6814. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6815. vViewPosition = - mvPosition.xyz;
  6816. #endif
  6817. }`,d5e=`#define NORMAL
  6818. uniform float opacity;
  6819. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6820. varying vec3 vViewPosition;
  6821. #endif
  6822. #include <packing>
  6823. #include <uv_pars_fragment>
  6824. #include <normal_pars_fragment>
  6825. #include <bumpmap_pars_fragment>
  6826. #include <normalmap_pars_fragment>
  6827. #include <logdepthbuf_pars_fragment>
  6828. #include <clipping_planes_pars_fragment>
  6829. void main() {
  6830. #include <clipping_planes_fragment>
  6831. #include <logdepthbuf_fragment>
  6832. #include <normal_fragment_begin>
  6833. #include <normal_fragment_maps>
  6834. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  6835. #ifdef OPAQUE
  6836. gl_FragColor.a = 1.0;
  6837. #endif
  6838. }`,h5e=`#define PHONG
  6839. varying vec3 vViewPosition;
  6840. #include <common>
  6841. #include <batching_pars_vertex>
  6842. #include <uv_pars_vertex>
  6843. #include <displacementmap_pars_vertex>
  6844. #include <envmap_pars_vertex>
  6845. #include <color_pars_vertex>
  6846. #include <fog_pars_vertex>
  6847. #include <normal_pars_vertex>
  6848. #include <morphtarget_pars_vertex>
  6849. #include <skinning_pars_vertex>
  6850. #include <shadowmap_pars_vertex>
  6851. #include <logdepthbuf_pars_vertex>
  6852. #include <clipping_planes_pars_vertex>
  6853. void main() {
  6854. #include <uv_vertex>
  6855. #include <color_vertex>
  6856. #include <morphcolor_vertex>
  6857. #include <batching_vertex>
  6858. #include <beginnormal_vertex>
  6859. #include <morphnormal_vertex>
  6860. #include <skinbase_vertex>
  6861. #include <skinnormal_vertex>
  6862. #include <defaultnormal_vertex>
  6863. #include <normal_vertex>
  6864. #include <begin_vertex>
  6865. #include <morphtarget_vertex>
  6866. #include <skinning_vertex>
  6867. #include <displacementmap_vertex>
  6868. #include <project_vertex>
  6869. #include <logdepthbuf_vertex>
  6870. #include <clipping_planes_vertex>
  6871. vViewPosition = - mvPosition.xyz;
  6872. #include <worldpos_vertex>
  6873. #include <envmap_vertex>
  6874. #include <shadowmap_vertex>
  6875. #include <fog_vertex>
  6876. }`,f5e=`#define PHONG
  6877. uniform vec3 diffuse;
  6878. uniform vec3 emissive;
  6879. uniform vec3 specular;
  6880. uniform float shininess;
  6881. uniform float opacity;
  6882. #include <common>
  6883. #include <packing>
  6884. #include <dithering_pars_fragment>
  6885. #include <color_pars_fragment>
  6886. #include <uv_pars_fragment>
  6887. #include <map_pars_fragment>
  6888. #include <alphamap_pars_fragment>
  6889. #include <alphatest_pars_fragment>
  6890. #include <alphahash_pars_fragment>
  6891. #include <aomap_pars_fragment>
  6892. #include <lightmap_pars_fragment>
  6893. #include <emissivemap_pars_fragment>
  6894. #include <envmap_common_pars_fragment>
  6895. #include <envmap_pars_fragment>
  6896. #include <fog_pars_fragment>
  6897. #include <bsdfs>
  6898. #include <lights_pars_begin>
  6899. #include <normal_pars_fragment>
  6900. #include <lights_phong_pars_fragment>
  6901. #include <shadowmap_pars_fragment>
  6902. #include <bumpmap_pars_fragment>
  6903. #include <normalmap_pars_fragment>
  6904. #include <specularmap_pars_fragment>
  6905. #include <logdepthbuf_pars_fragment>
  6906. #include <clipping_planes_pars_fragment>
  6907. void main() {
  6908. #include <clipping_planes_fragment>
  6909. vec4 diffuseColor = vec4( diffuse, opacity );
  6910. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6911. vec3 totalEmissiveRadiance = emissive;
  6912. #include <logdepthbuf_fragment>
  6913. #include <map_fragment>
  6914. #include <color_fragment>
  6915. #include <alphamap_fragment>
  6916. #include <alphatest_fragment>
  6917. #include <alphahash_fragment>
  6918. #include <specularmap_fragment>
  6919. #include <normal_fragment_begin>
  6920. #include <normal_fragment_maps>
  6921. #include <emissivemap_fragment>
  6922. #include <lights_phong_fragment>
  6923. #include <lights_fragment_begin>
  6924. #include <lights_fragment_maps>
  6925. #include <lights_fragment_end>
  6926. #include <aomap_fragment>
  6927. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  6928. #include <envmap_fragment>
  6929. #include <opaque_fragment>
  6930. #include <tonemapping_fragment>
  6931. #include <colorspace_fragment>
  6932. #include <fog_fragment>
  6933. #include <premultiplied_alpha_fragment>
  6934. #include <dithering_fragment>
  6935. }`,m5e=`#define STANDARD
  6936. varying vec3 vViewPosition;
  6937. #ifdef USE_TRANSMISSION
  6938. varying vec3 vWorldPosition;
  6939. #endif
  6940. #include <common>
  6941. #include <batching_pars_vertex>
  6942. #include <uv_pars_vertex>
  6943. #include <displacementmap_pars_vertex>
  6944. #include <color_pars_vertex>
  6945. #include <fog_pars_vertex>
  6946. #include <normal_pars_vertex>
  6947. #include <morphtarget_pars_vertex>
  6948. #include <skinning_pars_vertex>
  6949. #include <shadowmap_pars_vertex>
  6950. #include <logdepthbuf_pars_vertex>
  6951. #include <clipping_planes_pars_vertex>
  6952. void main() {
  6953. #include <uv_vertex>
  6954. #include <color_vertex>
  6955. #include <morphcolor_vertex>
  6956. #include <batching_vertex>
  6957. #include <beginnormal_vertex>
  6958. #include <morphnormal_vertex>
  6959. #include <skinbase_vertex>
  6960. #include <skinnormal_vertex>
  6961. #include <defaultnormal_vertex>
  6962. #include <normal_vertex>
  6963. #include <begin_vertex>
  6964. #include <morphtarget_vertex>
  6965. #include <skinning_vertex>
  6966. #include <displacementmap_vertex>
  6967. #include <project_vertex>
  6968. #include <logdepthbuf_vertex>
  6969. #include <clipping_planes_vertex>
  6970. vViewPosition = - mvPosition.xyz;
  6971. #include <worldpos_vertex>
  6972. #include <shadowmap_vertex>
  6973. #include <fog_vertex>
  6974. #ifdef USE_TRANSMISSION
  6975. vWorldPosition = worldPosition.xyz;
  6976. #endif
  6977. }`,p5e=`#define STANDARD
  6978. #ifdef PHYSICAL
  6979. #define IOR
  6980. #define USE_SPECULAR
  6981. #endif
  6982. uniform vec3 diffuse;
  6983. uniform vec3 emissive;
  6984. uniform float roughness;
  6985. uniform float metalness;
  6986. uniform float opacity;
  6987. #ifdef IOR
  6988. uniform float ior;
  6989. #endif
  6990. #ifdef USE_SPECULAR
  6991. uniform float specularIntensity;
  6992. uniform vec3 specularColor;
  6993. #ifdef USE_SPECULAR_COLORMAP
  6994. uniform sampler2D specularColorMap;
  6995. #endif
  6996. #ifdef USE_SPECULAR_INTENSITYMAP
  6997. uniform sampler2D specularIntensityMap;
  6998. #endif
  6999. #endif
  7000. #ifdef USE_CLEARCOAT
  7001. uniform float clearcoat;
  7002. uniform float clearcoatRoughness;
  7003. #endif
  7004. #ifdef USE_IRIDESCENCE
  7005. uniform float iridescence;
  7006. uniform float iridescenceIOR;
  7007. uniform float iridescenceThicknessMinimum;
  7008. uniform float iridescenceThicknessMaximum;
  7009. #endif
  7010. #ifdef USE_SHEEN
  7011. uniform vec3 sheenColor;
  7012. uniform float sheenRoughness;
  7013. #ifdef USE_SHEEN_COLORMAP
  7014. uniform sampler2D sheenColorMap;
  7015. #endif
  7016. #ifdef USE_SHEEN_ROUGHNESSMAP
  7017. uniform sampler2D sheenRoughnessMap;
  7018. #endif
  7019. #endif
  7020. #ifdef USE_ANISOTROPY
  7021. uniform vec2 anisotropyVector;
  7022. #ifdef USE_ANISOTROPYMAP
  7023. uniform sampler2D anisotropyMap;
  7024. #endif
  7025. #endif
  7026. varying vec3 vViewPosition;
  7027. #include <common>
  7028. #include <packing>
  7029. #include <dithering_pars_fragment>
  7030. #include <color_pars_fragment>
  7031. #include <uv_pars_fragment>
  7032. #include <map_pars_fragment>
  7033. #include <alphamap_pars_fragment>
  7034. #include <alphatest_pars_fragment>
  7035. #include <alphahash_pars_fragment>
  7036. #include <aomap_pars_fragment>
  7037. #include <lightmap_pars_fragment>
  7038. #include <emissivemap_pars_fragment>
  7039. #include <iridescence_fragment>
  7040. #include <cube_uv_reflection_fragment>
  7041. #include <envmap_common_pars_fragment>
  7042. #include <envmap_physical_pars_fragment>
  7043. #include <fog_pars_fragment>
  7044. #include <lights_pars_begin>
  7045. #include <normal_pars_fragment>
  7046. #include <lights_physical_pars_fragment>
  7047. #include <transmission_pars_fragment>
  7048. #include <shadowmap_pars_fragment>
  7049. #include <bumpmap_pars_fragment>
  7050. #include <normalmap_pars_fragment>
  7051. #include <clearcoat_pars_fragment>
  7052. #include <iridescence_pars_fragment>
  7053. #include <roughnessmap_pars_fragment>
  7054. #include <metalnessmap_pars_fragment>
  7055. #include <logdepthbuf_pars_fragment>
  7056. #include <clipping_planes_pars_fragment>
  7057. void main() {
  7058. #include <clipping_planes_fragment>
  7059. vec4 diffuseColor = vec4( diffuse, opacity );
  7060. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7061. vec3 totalEmissiveRadiance = emissive;
  7062. #include <logdepthbuf_fragment>
  7063. #include <map_fragment>
  7064. #include <color_fragment>
  7065. #include <alphamap_fragment>
  7066. #include <alphatest_fragment>
  7067. #include <alphahash_fragment>
  7068. #include <roughnessmap_fragment>
  7069. #include <metalnessmap_fragment>
  7070. #include <normal_fragment_begin>
  7071. #include <normal_fragment_maps>
  7072. #include <clearcoat_normal_fragment_begin>
  7073. #include <clearcoat_normal_fragment_maps>
  7074. #include <emissivemap_fragment>
  7075. #include <lights_physical_fragment>
  7076. #include <lights_fragment_begin>
  7077. #include <lights_fragment_maps>
  7078. #include <lights_fragment_end>
  7079. #include <aomap_fragment>
  7080. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  7081. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  7082. #include <transmission_fragment>
  7083. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  7084. #ifdef USE_SHEEN
  7085. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  7086. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  7087. #endif
  7088. #ifdef USE_CLEARCOAT
  7089. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  7090. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  7091. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  7092. #endif
  7093. #include <opaque_fragment>
  7094. #include <tonemapping_fragment>
  7095. #include <colorspace_fragment>
  7096. #include <fog_fragment>
  7097. #include <premultiplied_alpha_fragment>
  7098. #include <dithering_fragment>
  7099. }`,g5e=`#define TOON
  7100. varying vec3 vViewPosition;
  7101. #include <common>
  7102. #include <batching_pars_vertex>
  7103. #include <uv_pars_vertex>
  7104. #include <displacementmap_pars_vertex>
  7105. #include <color_pars_vertex>
  7106. #include <fog_pars_vertex>
  7107. #include <normal_pars_vertex>
  7108. #include <morphtarget_pars_vertex>
  7109. #include <skinning_pars_vertex>
  7110. #include <shadowmap_pars_vertex>
  7111. #include <logdepthbuf_pars_vertex>
  7112. #include <clipping_planes_pars_vertex>
  7113. void main() {
  7114. #include <uv_vertex>
  7115. #include <color_vertex>
  7116. #include <morphcolor_vertex>
  7117. #include <batching_vertex>
  7118. #include <beginnormal_vertex>
  7119. #include <morphnormal_vertex>
  7120. #include <skinbase_vertex>
  7121. #include <skinnormal_vertex>
  7122. #include <defaultnormal_vertex>
  7123. #include <normal_vertex>
  7124. #include <begin_vertex>
  7125. #include <morphtarget_vertex>
  7126. #include <skinning_vertex>
  7127. #include <displacementmap_vertex>
  7128. #include <project_vertex>
  7129. #include <logdepthbuf_vertex>
  7130. #include <clipping_planes_vertex>
  7131. vViewPosition = - mvPosition.xyz;
  7132. #include <worldpos_vertex>
  7133. #include <shadowmap_vertex>
  7134. #include <fog_vertex>
  7135. }`,x5e=`#define TOON
  7136. uniform vec3 diffuse;
  7137. uniform vec3 emissive;
  7138. uniform float opacity;
  7139. #include <common>
  7140. #include <packing>
  7141. #include <dithering_pars_fragment>
  7142. #include <color_pars_fragment>
  7143. #include <uv_pars_fragment>
  7144. #include <map_pars_fragment>
  7145. #include <alphamap_pars_fragment>
  7146. #include <alphatest_pars_fragment>
  7147. #include <alphahash_pars_fragment>
  7148. #include <aomap_pars_fragment>
  7149. #include <lightmap_pars_fragment>
  7150. #include <emissivemap_pars_fragment>
  7151. #include <gradientmap_pars_fragment>
  7152. #include <fog_pars_fragment>
  7153. #include <bsdfs>
  7154. #include <lights_pars_begin>
  7155. #include <normal_pars_fragment>
  7156. #include <lights_toon_pars_fragment>
  7157. #include <shadowmap_pars_fragment>
  7158. #include <bumpmap_pars_fragment>
  7159. #include <normalmap_pars_fragment>
  7160. #include <logdepthbuf_pars_fragment>
  7161. #include <clipping_planes_pars_fragment>
  7162. void main() {
  7163. #include <clipping_planes_fragment>
  7164. vec4 diffuseColor = vec4( diffuse, opacity );
  7165. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7166. vec3 totalEmissiveRadiance = emissive;
  7167. #include <logdepthbuf_fragment>
  7168. #include <map_fragment>
  7169. #include <color_fragment>
  7170. #include <alphamap_fragment>
  7171. #include <alphatest_fragment>
  7172. #include <alphahash_fragment>
  7173. #include <normal_fragment_begin>
  7174. #include <normal_fragment_maps>
  7175. #include <emissivemap_fragment>
  7176. #include <lights_toon_fragment>
  7177. #include <lights_fragment_begin>
  7178. #include <lights_fragment_maps>
  7179. #include <lights_fragment_end>
  7180. #include <aomap_fragment>
  7181. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  7182. #include <opaque_fragment>
  7183. #include <tonemapping_fragment>
  7184. #include <colorspace_fragment>
  7185. #include <fog_fragment>
  7186. #include <premultiplied_alpha_fragment>
  7187. #include <dithering_fragment>
  7188. }`,b5e=`uniform float size;
  7189. uniform float scale;
  7190. #include <common>
  7191. #include <color_pars_vertex>
  7192. #include <fog_pars_vertex>
  7193. #include <morphtarget_pars_vertex>
  7194. #include <logdepthbuf_pars_vertex>
  7195. #include <clipping_planes_pars_vertex>
  7196. #ifdef USE_POINTS_UV
  7197. varying vec2 vUv;
  7198. uniform mat3 uvTransform;
  7199. #endif
  7200. void main() {
  7201. #ifdef USE_POINTS_UV
  7202. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  7203. #endif
  7204. #include <color_vertex>
  7205. #include <morphcolor_vertex>
  7206. #include <begin_vertex>
  7207. #include <morphtarget_vertex>
  7208. #include <project_vertex>
  7209. gl_PointSize = size;
  7210. #ifdef USE_SIZEATTENUATION
  7211. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7212. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  7213. #endif
  7214. #include <logdepthbuf_vertex>
  7215. #include <clipping_planes_vertex>
  7216. #include <worldpos_vertex>
  7217. #include <fog_vertex>
  7218. }`,y5e=`uniform vec3 diffuse;
  7219. uniform float opacity;
  7220. #include <common>
  7221. #include <color_pars_fragment>
  7222. #include <map_particle_pars_fragment>
  7223. #include <alphatest_pars_fragment>
  7224. #include <alphahash_pars_fragment>
  7225. #include <fog_pars_fragment>
  7226. #include <logdepthbuf_pars_fragment>
  7227. #include <clipping_planes_pars_fragment>
  7228. void main() {
  7229. #include <clipping_planes_fragment>
  7230. vec3 outgoingLight = vec3( 0.0 );
  7231. vec4 diffuseColor = vec4( diffuse, opacity );
  7232. #include <logdepthbuf_fragment>
  7233. #include <map_particle_fragment>
  7234. #include <color_fragment>
  7235. #include <alphatest_fragment>
  7236. #include <alphahash_fragment>
  7237. outgoingLight = diffuseColor.rgb;
  7238. #include <opaque_fragment>
  7239. #include <tonemapping_fragment>
  7240. #include <colorspace_fragment>
  7241. #include <fog_fragment>
  7242. #include <premultiplied_alpha_fragment>
  7243. }`,v5e=`#include <common>
  7244. #include <batching_pars_vertex>
  7245. #include <fog_pars_vertex>
  7246. #include <morphtarget_pars_vertex>
  7247. #include <skinning_pars_vertex>
  7248. #include <logdepthbuf_pars_vertex>
  7249. #include <shadowmap_pars_vertex>
  7250. void main() {
  7251. #include <batching_vertex>
  7252. #include <beginnormal_vertex>
  7253. #include <morphnormal_vertex>
  7254. #include <skinbase_vertex>
  7255. #include <skinnormal_vertex>
  7256. #include <defaultnormal_vertex>
  7257. #include <begin_vertex>
  7258. #include <morphtarget_vertex>
  7259. #include <skinning_vertex>
  7260. #include <project_vertex>
  7261. #include <logdepthbuf_vertex>
  7262. #include <worldpos_vertex>
  7263. #include <shadowmap_vertex>
  7264. #include <fog_vertex>
  7265. }`,_5e=`uniform vec3 color;
  7266. uniform float opacity;
  7267. #include <common>
  7268. #include <packing>
  7269. #include <fog_pars_fragment>
  7270. #include <bsdfs>
  7271. #include <lights_pars_begin>
  7272. #include <logdepthbuf_pars_fragment>
  7273. #include <shadowmap_pars_fragment>
  7274. #include <shadowmask_pars_fragment>
  7275. void main() {
  7276. #include <logdepthbuf_fragment>
  7277. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  7278. #include <tonemapping_fragment>
  7279. #include <colorspace_fragment>
  7280. #include <fog_fragment>
  7281. }`,w5e=`uniform float rotation;
  7282. uniform vec2 center;
  7283. #include <common>
  7284. #include <uv_pars_vertex>
  7285. #include <fog_pars_vertex>
  7286. #include <logdepthbuf_pars_vertex>
  7287. #include <clipping_planes_pars_vertex>
  7288. void main() {
  7289. #include <uv_vertex>
  7290. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  7291. vec2 scale;
  7292. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  7293. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  7294. #ifndef USE_SIZEATTENUATION
  7295. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7296. if ( isPerspective ) scale *= - mvPosition.z;
  7297. #endif
  7298. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  7299. vec2 rotatedPosition;
  7300. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  7301. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  7302. mvPosition.xy += rotatedPosition;
  7303. gl_Position = projectionMatrix * mvPosition;
  7304. #include <logdepthbuf_vertex>
  7305. #include <clipping_planes_vertex>
  7306. #include <fog_vertex>
  7307. }`,S5e=`uniform vec3 diffuse;
  7308. uniform float opacity;
  7309. #include <common>
  7310. #include <uv_pars_fragment>
  7311. #include <map_pars_fragment>
  7312. #include <alphamap_pars_fragment>
  7313. #include <alphatest_pars_fragment>
  7314. #include <alphahash_pars_fragment>
  7315. #include <fog_pars_fragment>
  7316. #include <logdepthbuf_pars_fragment>
  7317. #include <clipping_planes_pars_fragment>
  7318. void main() {
  7319. #include <clipping_planes_fragment>
  7320. vec3 outgoingLight = vec3( 0.0 );
  7321. vec4 diffuseColor = vec4( diffuse, opacity );
  7322. #include <logdepthbuf_fragment>
  7323. #include <map_fragment>
  7324. #include <alphamap_fragment>
  7325. #include <alphatest_fragment>
  7326. #include <alphahash_fragment>
  7327. outgoingLight = diffuseColor.rgb;
  7328. #include <opaque_fragment>
  7329. #include <tonemapping_fragment>
  7330. #include <colorspace_fragment>
  7331. #include <fog_fragment>
  7332. }`,xn={alphahash_fragment:GLe,alphahash_pars_fragment:WLe,alphamap_fragment:qLe,alphamap_pars_fragment:KLe,alphatest_fragment:XLe,alphatest_pars_fragment:YLe,aomap_fragment:ZLe,aomap_pars_fragment:QLe,batching_pars_vertex:JLe,batching_vertex:e4e,begin_vertex:t4e,beginnormal_vertex:n4e,bsdfs:r4e,iridescence_fragment:i4e,bumpmap_pars_fragment:a4e,clipping_planes_fragment:s4e,clipping_planes_pars_fragment:o4e,clipping_planes_pars_vertex:l4e,clipping_planes_vertex:c4e,color_fragment:u4e,color_pars_fragment:d4e,color_pars_vertex:h4e,color_vertex:f4e,common:m4e,cube_uv_reflection_fragment:p4e,defaultnormal_vertex:g4e,displacementmap_pars_vertex:x4e,displacementmap_vertex:b4e,emissivemap_fragment:y4e,emissivemap_pars_fragment:v4e,colorspace_fragment:_4e,colorspace_pars_fragment:w4e,envmap_fragment:S4e,envmap_common_pars_fragment:M4e,envmap_pars_fragment:E4e,envmap_pars_vertex:A4e,envmap_physical_pars_fragment:F4e,envmap_vertex:T4e,fog_vertex:N4e,fog_pars_vertex:C4e,fog_fragment:k4e,fog_pars_fragment:P4e,gradientmap_pars_fragment:j4e,lightmap_fragment:R4e,lightmap_pars_fragment:D4e,lights_lambert_fragment:O4e,lights_lambert_pars_fragment:L4e,lights_pars_begin:I4e,lights_toon_fragment:U4e,lights_toon_pars_fragment:z4e,lights_phong_fragment:B4e,lights_phong_pars_fragment:H4e,lights_physical_fragment:$4e,lights_physical_pars_fragment:V4e,lights_fragment_begin:G4e,lights_fragment_maps:W4e,lights_fragment_end:q4e,logdepthbuf_fragment:K4e,logdepthbuf_pars_fragment:X4e,logdepthbuf_pars_vertex:Y4e,logdepthbuf_vertex:Z4e,map_fragment:Q4e,map_pars_fragment:J4e,map_particle_fragment:eIe,map_particle_pars_fragment:tIe,metalnessmap_fragment:nIe,metalnessmap_pars_fragment:rIe,morphcolor_vertex:iIe,morphnormal_vertex:aIe,morphtarget_pars_vertex:sIe,morphtarget_vertex:oIe,normal_fragment_begin:lIe,normal_fragment_maps:cIe,normal_pars_fragment:uIe,normal_pars_vertex:dIe,normal_vertex:hIe,normalmap_pars_fragment:fIe,clearcoat_normal_fragment_begin:mIe,clearcoat_normal_fragment_maps:pIe,clearcoat_pars_fragment:gIe,iridescence_pars_fragment:xIe,opaque_fragment:bIe,packing:yIe,premultiplied_alpha_fragment:vIe,project_vertex:_Ie,dithering_fragment:wIe,dithering_pars_fragment:SIe,roughnessmap_fragment:MIe,roughnessmap_pars_fragment:EIe,shadowmap_pars_fragment:AIe,shadowmap_pars_vertex:TIe,shadowmap_vertex:NIe,shadowmask_pars_fragment:CIe,skinbase_vertex:kIe,skinning_pars_vertex:PIe,skinning_vertex:jIe,skinnormal_vertex:RIe,specularmap_fragment:DIe,specularmap_pars_fragment:OIe,tonemapping_fragment:LIe,tonemapping_pars_fragment:IIe,transmission_fragment:FIe,transmission_pars_fragment:UIe,uv_pars_fragment:zIe,uv_pars_vertex:BIe,uv_vertex:HIe,worldpos_vertex:$Ie,background_vert:VIe,background_frag:GIe,backgroundCube_vert:WIe,backgroundCube_frag:qIe,cube_vert:KIe,cube_frag:XIe,depth_vert:YIe,depth_frag:ZIe,distanceRGBA_vert:QIe,distanceRGBA_frag:JIe,equirect_vert:e5e,equirect_frag:t5e,linedashed_vert:n5e,linedashed_frag:r5e,meshbasic_vert:i5e,meshbasic_frag:a5e,meshlambert_vert:s5e,meshlambert_frag:o5e,meshmatcap_vert:l5e,meshmatcap_frag:c5e,meshnormal_vert:u5e,meshnormal_frag:d5e,meshphong_vert:h5e,meshphong_frag:f5e,meshphysical_vert:m5e,meshphysical_frag:p5e,meshtoon_vert:g5e,meshtoon_frag:x5e,points_vert:b5e,points_frag:y5e,shadow_vert:v5e,shadow_frag:_5e,sprite_vert:w5e,sprite_frag:S5e},kt={common:{diffuse:{value:new Kt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Mn},alphaMap:{value:null},alphaMapTransform:{value:new Mn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Mn}},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 Mn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Mn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Mn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Mn},normalScale:{value:new rn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Mn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Mn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Mn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Mn}},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 Mn},alphaTest:{value:0},uvTransform:{value:new Mn}},sprite:{diffuse:{value:new Kt(16777215)},opacity:{value:1},center:{value:new rn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Mn},alphaMap:{value:null},alphaMapTransform:{value:new Mn},alphaTest:{value:0}}},Ja={basic:{uniforms:ka([kt.common,kt.specularmap,kt.envmap,kt.aomap,kt.lightmap,kt.fog]),vertexShader:xn.meshbasic_vert,fragmentShader:xn.meshbasic_frag},lambert:{uniforms:ka([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 Kt(0)}}]),vertexShader:xn.meshlambert_vert,fragmentShader:xn.meshlambert_frag},phong:{uniforms:ka([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 Kt(0)},specular:{value:new Kt(1118481)},shininess:{value:30}}]),vertexShader:xn.meshphong_vert,fragmentShader:xn.meshphong_frag},standard:{uniforms:ka([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 Kt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:xn.meshphysical_vert,fragmentShader:xn.meshphysical_frag},toon:{uniforms:ka([kt.common,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.gradientmap,kt.fog,kt.lights,{emissive:{value:new Kt(0)}}]),vertexShader:xn.meshtoon_vert,fragmentShader:xn.meshtoon_frag},matcap:{uniforms:ka([kt.common,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.fog,{matcap:{value:null}}]),vertexShader:xn.meshmatcap_vert,fragmentShader:xn.meshmatcap_frag},points:{uniforms:ka([kt.points,kt.fog]),vertexShader:xn.points_vert,fragmentShader:xn.points_frag},dashed:{uniforms:ka([kt.common,kt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:xn.linedashed_vert,fragmentShader:xn.linedashed_frag},depth:{uniforms:ka([kt.common,kt.displacementmap]),vertexShader:xn.depth_vert,fragmentShader:xn.depth_frag},normal:{uniforms:ka([kt.common,kt.bumpmap,kt.normalmap,kt.displacementmap,{opacity:{value:1}}]),vertexShader:xn.meshnormal_vert,fragmentShader:xn.meshnormal_frag},sprite:{uniforms:ka([kt.sprite,kt.fog]),vertexShader:xn.sprite_vert,fragmentShader:xn.sprite_frag},background:{uniforms:{uvTransform:{value:new Mn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:xn.background_vert,fragmentShader:xn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:xn.backgroundCube_vert,fragmentShader:xn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:xn.cube_vert,fragmentShader:xn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:xn.equirect_vert,fragmentShader:xn.equirect_frag},distanceRGBA:{uniforms:ka([kt.common,kt.displacementmap,{referencePosition:{value:new Le},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:xn.distanceRGBA_vert,fragmentShader:xn.distanceRGBA_frag},shadow:{uniforms:ka([kt.lights,kt.fog,{color:{value:new Kt(0)},opacity:{value:1}}]),vertexShader:xn.shadow_vert,fragmentShader:xn.shadow_frag}};Ja.physical={uniforms:ka([Ja.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Mn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Mn},clearcoatNormalScale:{value:new rn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Mn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Mn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Mn},sheen:{value:0},sheenColor:{value:new Kt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Mn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Mn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Mn},transmissionSamplerSize:{value:new rn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Mn},attenuationDistance:{value:0},attenuationColor:{value:new Kt(0)},specularColor:{value:new Kt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Mn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Mn},anisotropyVector:{value:new rn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Mn}}]),vertexShader:xn.meshphysical_vert,fragmentShader:xn.meshphysical_frag};const F_={r:0,b:0,g:0};function M5e(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 b(x,y){let E=!1,w=y.isScene===!0?y.background:null;w&&w.isTexture&&(w=(y.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===sE)?(d===void 0&&(d=new Uo(new oy(1,1,1),new kd({name:"BackgroundCubeMaterial",uniforms:Wp(Ja.backgroundCube.uniforms),vertexShader:Ja.backgroundCube.vertexShader,fragmentShader:Ja.backgroundCube.fragmentShader,side:rs,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=y.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,d.material.toneMapped=or.getTransfer(w.colorSpace)!==Sr,(f!==w||g!==w.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=w,g=w.version,p=t.toneMapping),d.layers.enableAll(),x.unshift(d,d.geometry,d.material,0,0,null)):w&&w.isTexture&&(u===void 0&&(u=new Uo(new KO(2,2),new kd({name:"BackgroundMaterial",uniforms:Wp(Ja.background.uniforms),vertexShader:Ja.background.vertexShader,fragmentShader:Ja.background.fragmentShader,side:Cd,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=y.backgroundIntensity,u.material.toneMapped=or.getTransfer(w.colorSpace)!==Sr,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(),x.unshift(u,u.geometry,u.material,0,0,null))}function v(x,y){x.getRGB(F_,TQ(t)),r.buffers.color.setClear(F_.r,F_.g,F_.b,y,s)}return{getClearColor:function(){return l},setClearColor:function(x,y=1){l.set(x),c=y,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(x){c=x,v(l,c)},render:b}}function E5e(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=x(null);let u=c,d=!1;function f(R,W,K,G,J){let ee=!1;if(s){const Z=v(G,K,W);u!==Z&&(u=Z,p(u.object)),ee=y(R,G,K,J),ee&&E(R,G,K,J)}else{const Z=W.wireframe===!0;(u.geometry!==G.id||u.program!==K.id||u.wireframe!==Z)&&(u.geometry=G.id,u.program=K.id,u.wireframe=Z,ee=!0)}J!==null&&n.update(J,t.ELEMENT_ARRAY_BUFFER),(ee||d)&&(d=!1,O(R,W,K,G),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 b(R){return r.isWebGL2?t.deleteVertexArray(R):a.deleteVertexArrayOES(R)}function v(R,W,K){const G=K.wireframe===!0;let J=l[R.id];J===void 0&&(J={},l[R.id]=J);let ee=J[W.id];ee===void 0&&(ee={},J[W.id]=ee);let Z=ee[G];return Z===void 0&&(Z=x(g()),ee[G]=Z),Z}function x(R){const W=[],K=[],G=[];for(let J=0;J<i;J++)W[J]=0,K[J]=0,G[J]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:K,attributeDivisors:G,object:R,attributes:{},index:null}}function y(R,W,K,G){const J=u.attributes,ee=W.attributes;let Z=0;const F=K.getAttributes();for(const V in F)if(F[V].location>=0){const le=J[V];let oe=ee[V];if(oe===void 0&&(V==="instanceMatrix"&&R.instanceMatrix&&(oe=R.instanceMatrix),V==="instanceColor"&&R.instanceColor&&(oe=R.instanceColor)),le===void 0||le.attribute!==oe||oe&&le.data!==oe.data)return!0;Z++}return u.attributesNum!==Z||u.index!==G}function E(R,W,K,G){const J={},ee=W.attributes;let Z=0;const F=K.getAttributes();for(const V in F)if(F[V].location>=0){let le=ee[V];le===void 0&&(V==="instanceMatrix"&&R.instanceMatrix&&(le=R.instanceMatrix),V==="instanceColor"&&R.instanceColor&&(le=R.instanceColor));const oe={};oe.attribute=le,le&&le.data&&(oe.data=le.data),J[V]=oe,Z++}u.attributes=J,u.attributesNum=Z,u.index=G}function w(){const R=u.newAttributes;for(let W=0,K=R.length;W<K;W++)R[W]=0}function A(R){T(R,0)}function T(R,W){const K=u.newAttributes,G=u.enabledAttributes,J=u.attributeDivisors;K[R]=1,G[R]===0&&(t.enableVertexAttribArray(R),G[R]=1),J[R]!==W&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](R,W),J[R]=W)}function C(){const R=u.newAttributes,W=u.enabledAttributes;for(let K=0,G=W.length;K<G;K++)W[K]!==R[K]&&(t.disableVertexAttribArray(K),W[K]=0)}function N(R,W,K,G,J,ee,Z){Z===!0?t.vertexAttribIPointer(R,W,K,J,ee):t.vertexAttribPointer(R,W,K,G,J,ee)}function O(R,W,K,G){if(r.isWebGL2===!1&&(R.isInstancedMesh||G.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();const J=G.attributes,ee=K.getAttributes(),Z=W.defaultAttributeValues;for(const F in ee){const V=ee[F];if(V.location>=0){let ne=J[F];if(ne===void 0&&(F==="instanceMatrix"&&R.instanceMatrix&&(ne=R.instanceMatrix),F==="instanceColor"&&R.instanceColor&&(ne=R.instanceColor)),ne!==void 0){const le=ne.normalized,oe=ne.itemSize,pe=n.get(ne);if(pe===void 0)continue;const Q=pe.buffer,Ee=pe.type,he=pe.bytesPerElement,ue=r.isWebGL2===!0&&(Ee===t.INT||Ee===t.UNSIGNED_INT||ne.gpuType===oQ);if(ne.isInterleavedBufferAttribute){const Ae=ne.data,fe=Ae.stride,at=ne.offset;if(Ae.isInstancedInterleavedBuffer){for(let B=0;B<V.locationSize;B++)T(V.location+B,Ae.meshPerAttribute);R.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=Ae.meshPerAttribute*Ae.count)}else for(let B=0;B<V.locationSize;B++)A(V.location+B);t.bindBuffer(t.ARRAY_BUFFER,Q);for(let B=0;B<V.locationSize;B++)N(V.location+B,oe/V.locationSize,Ee,le,fe*he,(at+oe/V.locationSize*B)*he,ue)}else{if(ne.isInstancedBufferAttribute){for(let Ae=0;Ae<V.locationSize;Ae++)T(V.location+Ae,ne.meshPerAttribute);R.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Ae=0;Ae<V.locationSize;Ae++)A(V.location+Ae);t.bindBuffer(t.ARRAY_BUFFER,Q);for(let Ae=0;Ae<V.locationSize;Ae++)N(V.location+Ae,oe/V.locationSize,Ee,le,oe*he,oe/V.locationSize*Ae*he,ue)}}else if(Z!==void 0){const le=Z[F];if(le!==void 0)switch(le.length){case 2:t.vertexAttrib2fv(V.location,le);break;case 3:t.vertexAttrib3fv(V.location,le);break;case 4:t.vertexAttrib4fv(V.location,le);break;default:t.vertexAttrib1fv(V.location,le)}}}}C()}function k(){I();for(const R in l){const W=l[R];for(const K in W){const G=W[K];for(const J in G)b(G[J].object),delete G[J];delete W[K]}delete l[R]}}function j(R){if(l[R.id]===void 0)return;const W=l[R.id];for(const K in W){const G=W[K];for(const J in G)b(G[J].object),delete G[J];delete W[K]}delete l[R.id]}function z(R){for(const W in l){const K=l[W];if(K[R.id]===void 0)continue;const G=K[R.id];for(const J in G)b(G[J].object),delete G[J];delete K[R.id]}}function I(){q(),d=!0,u!==c&&(u=c,p(u.object))}function q(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:I,resetDefaultState:q,dispose:k,releaseStatesOfGeometry:j,releaseStatesOfProgram:z,initAttributes:w,enableAttribute:A,disableUnusedAttributes:C}}function A5e(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,b;if(i)p=t,b="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),b="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[b](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 b=0;b<g;b++)this.render(d[b],f[b]);else{p.multiDrawArraysWEBGL(a,d,0,f,0,g);let b=0;for(let v=0;v<g;v++)b+=f[v];n.update(b,a,1)}}this.setMode=s,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function T5e(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),b=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),x=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),y=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:b,maxAttributes:v,maxVertexUniforms:x,maxVaryings:y,maxFragmentUniforms:E,vertexTextures:w,floatFragmentTextures:A,floatVertexTextures:T,maxSamples:C}}function N5e(t){const e=this;let n=null,r=0,i=!1,a=!1;const s=new Wu,l=new Mn,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 b=f.clippingPlanes,v=f.clipIntersection,x=f.clipShadows,y=t.get(f);if(!i||b===null||b.length===0||a&&!x)a?d(null):u();else{const E=a?0:r,w=E*4;let A=y.clippingState||null;c.value=A,A=d(b,g,w,p);for(let T=0;T!==w;++T)A[T]=n[T];y.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,b){const v=f!==null?f.length:0;let x=null;if(v!==0){if(x=c.value,b!==!0||x===null){const y=p+v*4,E=g.matrixWorldInverse;l.getNormalMatrix(E),(x===null||x.length<y)&&(x=new Float32Array(y));for(let w=0,A=p;w!==v;++w,A+=4)s.copy(f[w]).applyMatrix4(E,l),s.normal.toArray(x,A),x[A+3]=s.constant}c.value=x,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,x}}function C5e(t){let e=new WeakMap;function n(s,l){return l===ej?s.mapping=$p:l===tj&&(s.mapping=Vp),s}function r(s){if(s&&s.isTexture){const l=s.mapping;if(l===ej||l===tj)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 BLe(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 k5e extends NQ{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,wV=[.125,.215,.35,.446,.526,.582],Mh=20,IC=new k5e,SV=new Kt;let FC=null,UC=0,zC=0;const yh=(1+Math.sqrt(5))/2,Gm=1/yh,MV=[new Le(1,1,1),new Le(-1,1,1),new Le(1,1,-1),new Le(-1,1,-1),new Le(0,yh,Gm),new Le(0,yh,-Gm),new Le(Gm,0,yh),new Le(-Gm,0,yh),new Le(yh,Gm,0),new Le(-yh,Gm,0)];class EV{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){FC=this._renderer.getRenderTarget(),UC=this._renderer.getActiveCubeFace(),zC=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=NV(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=TV(),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(FC,UC,zC),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),FC=this._renderer.getRenderTarget(),UC=this._renderer.getActiveCubeFace(),zC=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:ro,minFilter:ro,generateMipmaps:!1,type:ab,format:io,colorSpace:Zc,depthBuffer:!1},i=AV(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=AV(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=P5e(a)),this._blurMaterial=j5e(a,e,n)}return i}_compileMaterial(e){const n=new Uo(this._lodPlanes[0],e);this._renderer.compile(n,IC)}_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(SV),d.toneMapping=hd,d.autoClear=!1;const p=new MQ({name:"PMREM.Background",side:rs,depthWrite:!1,depthTest:!1}),b=new Uo(new oy,p);let v=!1;const x=e.background;x?x.isColor&&(p.color.copy(x),e.background=null,v=!0):(p.color.copy(SV),v=!0);for(let y=0;y<6;y++){const E=y%3;E===0?(l.up.set(0,c[y],0),l.lookAt(u[y],0,0)):E===1?(l.up.set(0,0,c[y]),l.lookAt(0,u[y],0)):(l.up.set(0,c[y],0),l.lookAt(0,0,u[y]));const w=this._cubeSize;U_(i,E*w,y>2?w:0,w,w),d.setRenderTarget(i),v&&d.render(b,l),d.render(e,l)}b.geometry.dispose(),b.material.dispose(),d.toneMapping=g,d.autoClear=f,e.background=x}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===$p||e.mapping===Vp;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=NV()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=TV());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,IC)}_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=MV[(i-1)%MV.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,b=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*Mh-1),v=a/b,x=isFinite(a)?1+Math.floor(d*v):Mh;x>Mh&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${Mh}`);const y=[];let E=0;for(let N=0;N<Mh;++N){const O=N/v,k=Math.exp(-O*O/2);y.push(k),N===0?E+=k:N<x&&(E+=2*k)}for(let N=0;N<y.length;N++)y[N]=y[N]/E;g.envMap.value=e.texture,g.samples.value=x,g.weights.value=y,g.latitudinal.value=s==="latitudinal",l&&(g.poleAxis.value=l);const{_lodMax:w}=this;g.dTheta.value=b,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,IC)}}function P5e(t){const e=[],n=[],r=[];let i=t;const a=t-cp+1+wV.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=wV[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,b=6,v=3,x=2,y=1,E=new Float32Array(v*b*p),w=new Float32Array(x*b*p),A=new Float32Array(y*b*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*b*C),w.set(g,x*b*C);const j=[C,C,C,C,C,C];A.set(j,y*b*C)}const T=new Ea;T.setAttribute("position",new Ps(E,v)),T.setAttribute("uv",new Ps(w,x)),T.setAttribute("faceIndex",new Ps(A,y)),e.push(T),i>cp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function AV(t,e,n){const r=new bf(t,e,n);return r.texture.mapping=sE,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 j5e(t,e,n){const r=new Float32Array(Mh),i=new Le(0,1,0);return new kd({name:"SphericalGaussianBlur",defines:{n:Mh,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:XO(),fragmentShader:`
  7333. precision mediump float;
  7334. precision mediump int;
  7335. varying vec3 vOutputDirection;
  7336. uniform sampler2D envMap;
  7337. uniform int samples;
  7338. uniform float weights[ n ];
  7339. uniform bool latitudinal;
  7340. uniform float dTheta;
  7341. uniform float mipInt;
  7342. uniform vec3 poleAxis;
  7343. #define ENVMAP_TYPE_CUBE_UV
  7344. #include <cube_uv_reflection_fragment>
  7345. vec3 getSample( float theta, vec3 axis ) {
  7346. float cosTheta = cos( theta );
  7347. // Rodrigues' axis-angle rotation
  7348. vec3 sampleDirection = vOutputDirection * cosTheta
  7349. + cross( axis, vOutputDirection ) * sin( theta )
  7350. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  7351. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  7352. }
  7353. void main() {
  7354. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  7355. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  7356. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  7357. }
  7358. axis = normalize( axis );
  7359. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  7360. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  7361. for ( int i = 1; i < n; i++ ) {
  7362. if ( i >= samples ) {
  7363. break;
  7364. }
  7365. float theta = dTheta * float( i );
  7366. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  7367. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  7368. }
  7369. }
  7370. `,blending:dd,depthTest:!1,depthWrite:!1})}function TV(){return new kd({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:XO(),fragmentShader:`
  7371. precision mediump float;
  7372. precision mediump int;
  7373. varying vec3 vOutputDirection;
  7374. uniform sampler2D envMap;
  7375. #include <common>
  7376. void main() {
  7377. vec3 outputDirection = normalize( vOutputDirection );
  7378. vec2 uv = equirectUv( outputDirection );
  7379. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  7380. }
  7381. `,blending:dd,depthTest:!1,depthWrite:!1})}function NV(){return new kd({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:XO(),fragmentShader:`
  7382. precision mediump float;
  7383. precision mediump int;
  7384. uniform float flipEnvMap;
  7385. varying vec3 vOutputDirection;
  7386. uniform samplerCube envMap;
  7387. void main() {
  7388. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  7389. }
  7390. `,blending:dd,depthTest:!1,depthWrite:!1})}function XO(){return`
  7391. precision mediump float;
  7392. precision mediump int;
  7393. attribute float faceIndex;
  7394. varying vec3 vOutputDirection;
  7395. // RH coordinate system; PMREM face-indexing convention
  7396. vec3 getDirection( vec2 uv, float face ) {
  7397. uv = 2.0 * uv - 1.0;
  7398. vec3 direction = vec3( uv, 1.0 );
  7399. if ( face == 0.0 ) {
  7400. direction = direction.zyx; // ( 1, v, u ) pos x
  7401. } else if ( face == 1.0 ) {
  7402. direction = direction.xzy;
  7403. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  7404. } else if ( face == 2.0 ) {
  7405. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  7406. } else if ( face == 3.0 ) {
  7407. direction = direction.zyx;
  7408. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  7409. } else if ( face == 4.0 ) {
  7410. direction = direction.xzy;
  7411. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  7412. } else if ( face == 5.0 ) {
  7413. direction.z *= -1.0; // ( u, v, -1 ) neg z
  7414. }
  7415. return direction;
  7416. }
  7417. void main() {
  7418. vOutputDirection = getDirection( uv, faceIndex );
  7419. gl_Position = vec4( position, 1.0 );
  7420. }
  7421. `}function R5e(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===ej||c===tj,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 EV(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 EV(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 D5e(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 O5e(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 b in g.attributes)e.remove(g.attributes[b]);for(const b in g.morphAttributes){const v=g.morphAttributes[b];for(let x=0,y=v.length;x<y;x++)e.remove(v[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 b in g)e.update(g[b],t.ARRAY_BUFFER);const p=f.morphAttributes;for(const b in p){const v=p[b];for(let x=0,y=v.length;x<y;x++)e.update(v[x],t.ARRAY_BUFFER)}}function u(f){const g=[],p=f.index,b=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(b!==void 0){const E=b.array;v=b.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 x=new(bQ(g)?AQ:EQ)(g,1);x.version=v;const y=a.get(f);y&&e.remove(y),a.set(f,x)}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 L5e(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,b){t.drawElements(a,b,l,p*c),n.update(b,a,1)}function f(p,b,v){if(v===0)return;let x,y;if(i)x=t,y="drawElementsInstanced";else if(x=e.get("ANGLE_instanced_arrays"),y="drawElementsInstancedANGLE",x===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}x[y](a,b,l,p*c,v),n.update(b,a,v)}function g(p,b,v){if(v===0)return;const x=e.get("WEBGL_multi_draw");if(x===null)for(let y=0;y<v;y++)this.render(p[y]/c,b[y]);else{x.multiDrawElementsWEBGL(a,b,0,l,p,0,v);let y=0;for(let E=0;E<v;E++)y+=b[E];n.update(y,a,1)}}this.setMode=s,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=g}function I5e(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 F5e(t,e){return t[0]-e[0]}function U5e(t,e){return Math.abs(e[1])-Math.abs(t[1])}function z5e(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 b=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,v=b!==void 0?b.length:0;let x=a.get(d);if(x===void 0||x.count!==v){let W=function(){q.dispose(),a.delete(d),d.removeEventListener("dispose",W)};var p=W;x!==void 0&&x.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,z=1;j>e.maxTextureSize&&(z=Math.ceil(j/e.maxTextureSize),j=e.maxTextureSize);const I=new Float32Array(j*z*4*v),q=new _Q(I,j,z,v);q.type=Cc,q.needsUpdate=!0;const R=k*4;for(let K=0;K<v;K++){const G=C[K],J=N[K],ee=O[K],Z=j*z*4*K;for(let F=0;F<G.count;F++){const V=F*R;w===!0&&(s.fromBufferAttribute(G,F),I[Z+V+0]=s.x,I[Z+V+1]=s.y,I[Z+V+2]=s.z,I[Z+V+3]=0),A===!0&&(s.fromBufferAttribute(J,F),I[Z+V+4]=s.x,I[Z+V+5]=s.y,I[Z+V+6]=s.z,I[Z+V+7]=0),T===!0&&(s.fromBufferAttribute(ee,F),I[Z+V+8]=s.x,I[Z+V+9]=s.y,I[Z+V+10]=s.z,I[Z+V+11]=ee.itemSize===4?s.w:1)}}x={count:v,texture:q,size:new rn(j,z)},a.set(d,x),d.addEventListener("dispose",W)}let y=0;for(let w=0;w<g.length;w++)y+=g[w];const E=d.morphTargetsRelative?1:1-y;f.getUniforms().setValue(t,"morphTargetBaseInfluence",E),f.getUniforms().setValue(t,"morphTargetInfluences",g),f.getUniforms().setValue(t,"morphTargetsTexture",x.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",x.size)}else{const b=g===void 0?0:g.length;let v=r[d.id];if(v===void 0||v.length!==b){v=[];for(let A=0;A<b;A++)v[A]=[A,0];r[d.id]=v}for(let A=0;A<b;A++){const T=v[A];T[0]=A,T[1]=g[A]}v.sort(U5e);for(let A=0;A<8;A++)A<b&&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(F5e);const x=d.morphAttributes.position,y=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?(x&&d.getAttribute("morphTarget"+A)!==x[C]&&d.setAttribute("morphTarget"+A,x[C]),y&&d.getAttribute("morphNormal"+A)!==y[C]&&d.setAttribute("morphNormal"+A,y[C]),i[A]=N,E+=N):(x&&d.hasAttribute("morphTarget"+A)===!0&&d.deleteAttribute("morphTarget"+A),y&&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 B5e(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 PQ extends is{constructor(e,n,r,i,a,s,l,c,u,d){if(d=d!==void 0?d:Vh,d!==Vh&&d!==Gp)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===Vh&&(r=rd),r===void 0&&d===Gp&&(r=$h),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:aa,this.minFilter=c!==void 0?c:aa,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 jQ=new is,RQ=new PQ(1,1);RQ.compareFunction=gQ;const DQ=new _Q,OQ=new ELe,LQ=new CQ,CV=[],kV=[],PV=new Float32Array(16),jV=new Float32Array(9),RV=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=CV[i];if(a===void 0&&(a=new Float32Array(i),CV[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 Mi(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 Ei(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function cE(t,e){let n=kV[e];n===void 0&&(n=new Int32Array(e),kV[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function H5e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function $5e(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(Mi(n,e))return;t.uniform2fv(this.addr,e),Ei(n,e)}}function V5e(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(Mi(n,e))return;t.uniform3fv(this.addr,e),Ei(n,e)}}function G5e(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(Mi(n,e))return;t.uniform4fv(this.addr,e),Ei(n,e)}}function W5e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Mi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ei(n,e)}else{if(Mi(n,r))return;RV.set(r),t.uniformMatrix2fv(this.addr,!1,RV),Ei(n,r)}}function q5e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Mi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ei(n,e)}else{if(Mi(n,r))return;jV.set(r),t.uniformMatrix3fv(this.addr,!1,jV),Ei(n,r)}}function K5e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Mi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ei(n,e)}else{if(Mi(n,r))return;PV.set(r),t.uniformMatrix4fv(this.addr,!1,PV),Ei(n,r)}}function X5e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Y5e(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(Mi(n,e))return;t.uniform2iv(this.addr,e),Ei(n,e)}}function Z5e(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(Mi(n,e))return;t.uniform3iv(this.addr,e),Ei(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.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(Mi(n,e))return;t.uniform4iv(this.addr,e),Ei(n,e)}}function J5e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function eFe(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(Mi(n,e))return;t.uniform2uiv(this.addr,e),Ei(n,e)}}function tFe(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(Mi(n,e))return;t.uniform3uiv(this.addr,e),Ei(n,e)}}function nFe(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(Mi(n,e))return;t.uniform4uiv(this.addr,e),Ei(n,e)}}function rFe(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?RQ:jQ;n.setTexture2D(e||a,i)}function iFe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||OQ,i)}function aFe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||LQ,i)}function sFe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||DQ,i)}function oFe(t){switch(t){case 5126:return H5e;case 35664:return $5e;case 35665:return V5e;case 35666:return G5e;case 35674:return W5e;case 35675:return q5e;case 35676:return K5e;case 5124:case 35670:return X5e;case 35667:case 35671:return Y5e;case 35668:case 35672:return Z5e;case 35669:case 35673:return Q5e;case 5125:return J5e;case 36294:return eFe;case 36295:return tFe;case 36296:return nFe;case 35678:case 36198:case 36298:case 36306:case 35682:return rFe;case 35679:case 36299:case 36307:return iFe;case 35680:case 36300:case 36308:case 36293:return aFe;case 36289:case 36303:case 36311:case 36292:return sFe}}function lFe(t,e){t.uniform1fv(this.addr,e)}function cFe(t,e){const n=Sg(e,this.size,2);t.uniform2fv(this.addr,n)}function uFe(t,e){const n=Sg(e,this.size,3);t.uniform3fv(this.addr,n)}function dFe(t,e){const n=Sg(e,this.size,4);t.uniform4fv(this.addr,n)}function hFe(t,e){const n=Sg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function fFe(t,e){const n=Sg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function mFe(t,e){const n=Sg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function pFe(t,e){t.uniform1iv(this.addr,e)}function gFe(t,e){t.uniform2iv(this.addr,e)}function xFe(t,e){t.uniform3iv(this.addr,e)}function bFe(t,e){t.uniform4iv(this.addr,e)}function yFe(t,e){t.uniform1uiv(this.addr,e)}function vFe(t,e){t.uniform2uiv(this.addr,e)}function _Fe(t,e){t.uniform3uiv(this.addr,e)}function wFe(t,e){t.uniform4uiv(this.addr,e)}function SFe(t,e,n){const r=this.cache,i=e.length,a=cE(n,i);Mi(r,a)||(t.uniform1iv(this.addr,a),Ei(r,a));for(let s=0;s!==i;++s)n.setTexture2D(e[s]||jQ,a[s])}function MFe(t,e,n){const r=this.cache,i=e.length,a=cE(n,i);Mi(r,a)||(t.uniform1iv(this.addr,a),Ei(r,a));for(let s=0;s!==i;++s)n.setTexture3D(e[s]||OQ,a[s])}function EFe(t,e,n){const r=this.cache,i=e.length,a=cE(n,i);Mi(r,a)||(t.uniform1iv(this.addr,a),Ei(r,a));for(let s=0;s!==i;++s)n.setTextureCube(e[s]||LQ,a[s])}function AFe(t,e,n){const r=this.cache,i=e.length,a=cE(n,i);Mi(r,a)||(t.uniform1iv(this.addr,a),Ei(r,a));for(let s=0;s!==i;++s)n.setTexture2DArray(e[s]||DQ,a[s])}function TFe(t){switch(t){case 5126:return lFe;case 35664:return cFe;case 35665:return uFe;case 35666:return dFe;case 35674:return hFe;case 35675:return fFe;case 35676:return mFe;case 5124:case 35670:return pFe;case 35667:case 35671:return gFe;case 35668:case 35672:return xFe;case 35669:case 35673:return bFe;case 5125:return yFe;case 36294:return vFe;case 36295:return _Fe;case 36296:return wFe;case 35678:case 36198:case 36298:case 36306:case 35682:return SFe;case 35679:case 36299:case 36307:return MFe;case 35680:case 36300:case 36308:case 36293:return EFe;case 36289:case 36303:case 36311:case 36292:return AFe}}class NFe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=oFe(n.type)}}class CFe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=TFe(n.type)}}class kFe{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 BC=/(\w+)(\])?(\[|\.)?/g;function DV(t,e){t.seq.push(e),t.map[e.id]=e}function PFe(t,e,n){const r=t.name,i=r.length;for(BC.lastIndex=0;;){const a=BC.exec(r),s=BC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&s+2===i){DV(n,u===void 0?new NFe(l,t,e):new CFe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new kFe(l),DV(n,f)),n=f}}}class P1{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);PFe(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 OV(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const jFe=37297;let RFe=0;function DFe(t,e){const n=t.split(`
  7422. `),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(`
  7423. `)}function OFe(t){const e=or.getPrimaries(or.workingColorSpace),n=or.getPrimaries(t);let r;switch(e===n?r="":e===eS&&n===Jw?r="LinearDisplayP3ToLinearSRGB":e===Jw&&n===eS&&(r="LinearSRGBToLinearDisplayP3"),t){case Zc:case oE:return[r,"LinearTransferOETF"];case sa:case VO:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function LV(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()+`
  7424. `+i+`
  7425. `+DFe(t.getShaderSource(e),s)}else return i}function LFe(t,e){const n=OFe(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function IFe(t,e){let n;switch(e){case LOe:n="Linear";break;case IOe:n="Reinhard";break;case FOe:n="OptimizedCineon";break;case UOe:n="ACESFilmic";break;case zOe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function FFe(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(`
  7426. `)}function UFe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7427. `)}function zFe(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 IV(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 FV(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const BFe=/^[ \t]*#include +<([\w\d./]+)>/gm;function oj(t){return t.replace(BFe,$Fe)}const HFe=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function $Fe(t,e){let n=xn[e];if(n===void 0){const r=HFe.get(e);if(r!==void 0)n=xn[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 oj(n)}const VFe=/#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 UV(t){return t.replace(VFe,GFe)}function GFe(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 zV(t){let e="precision "+t.precision+` float;
  7428. precision `+t.precision+" int;";return t.precision==="highp"?e+=`
  7429. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  7430. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  7431. #define LOW_PRECISION`),e}function WFe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===aQ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===uOe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===gc&&(e="SHADOWMAP_TYPE_VSM"),e}function qFe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case $p:case Vp:e="ENVMAP_TYPE_CUBE";break;case sE:e="ENVMAP_TYPE_CUBE_UV";break}return e}function KFe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Vp:e="ENVMAP_MODE_REFRACTION";break}return e}function XFe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case HO:e="ENVMAP_BLENDING_MULTIPLY";break;case DOe:e="ENVMAP_BLENDING_MIX";break;case OOe:e="ENVMAP_BLENDING_ADD";break}return e}function YFe(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 ZFe(t,e,n,r){const i=t.getContext(),a=n.defines;let s=n.vertexShader,l=n.fragmentShader;const c=WFe(n),u=qFe(n),d=KFe(n),f=XFe(n),g=YFe(n),p=n.isWebGL2?"":FFe(n),b=UFe(a),v=i.createProgram();let x,y,E=n.glslVersion?"#version "+n.glslVersion+`
  7432. `:"";n.isRawShaderMaterial?(x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Zx).join(`
  7433. `),x.length>0&&(x+=`
  7434. `),y=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Zx).join(`
  7435. `),y.length>0&&(y+=`
  7436. `)):(x=[zV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,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",`
  7437. `].filter(Zx).join(`
  7438. `),y=[p,zV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,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!==hd?"#define TONE_MAPPING":"",n.toneMapping!==hd?xn.tonemapping_pars_fragment:"",n.toneMapping!==hd?IFe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",xn.colorspace_pars_fragment,LFe("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7439. `].filter(Zx).join(`
  7440. `)),s=oj(s),s=IV(s,n),s=FV(s,n),l=oj(l),l=IV(l,n),l=FV(l,n),s=UV(s),l=UV(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(E=`#version 300 es
  7441. `,x=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  7442. `)+`
  7443. `+x,y=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===iV?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===iV?"":"#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(`
  7444. `)+`
  7445. `+y);const w=E+x+s,A=E+y+l,T=OV(i,i.VERTEX_SHADER,w),C=OV(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(z){if(t.debug.checkShaderErrors){const I=i.getProgramInfoLog(v).trim(),q=i.getShaderInfoLog(T).trim(),R=i.getShaderInfoLog(C).trim();let W=!0,K=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(W=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,T,C);else{const G=LV(i,T,"vertex"),J=LV(i,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
  7446. Program Info Log: `+I+`
  7447. `+G+`
  7448. `+J)}else I!==""?console.warn("THREE.WebGLProgram: Program Info Log:",I):(q===""||R==="")&&(K=!1);K&&(z.diagnostics={runnable:W,programLog:I,vertexShader:{log:q,prefix:x},fragmentShader:{log:R,prefix:y}})}i.deleteShader(T),i.deleteShader(C),O=new P1(i,v),k=zFe(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,jFe)),j},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=RFe++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=T,this.fragmentShader=C,this}let QFe=0;class JFe{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 eUe(e),n.set(e,r)),r}}class eUe{constructor(e){this.id=QFe++,this.code=e,this.usedTimes=0}}function tUe(t,e,n,r,i,a,s){const l=new wQ,c=new JFe,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,g=i.vertexTextures;let p=i.precision;const b={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 x(k,j,z,I,q){const R=I.fog,W=q.geometry,K=k.isMeshStandardMaterial?I.environment:null,G=(k.isMeshStandardMaterial?n:e).get(k.envMap||K),J=G&&G.mapping===sE?G.image.height:null,ee=b[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 Z=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,F=Z!==void 0?Z.length:0;let V=0;W.morphAttributes.position!==void 0&&(V=1),W.morphAttributes.normal!==void 0&&(V=2),W.morphAttributes.color!==void 0&&(V=3);let ne,le,oe,pe;if(ee){const Qt=Ja[ee];ne=Qt.vertexShader,le=Qt.fragmentShader}else ne=k.vertexShader,le=k.fragmentShader,c.update(k),oe=c.getVertexShaderID(k),pe=c.getFragmentShaderID(k);const Q=t.getRenderTarget(),Ee=q.isInstancedMesh===!0,he=q.isBatchedMesh===!0,ue=!!k.map,Ae=!!k.matcap,fe=!!G,at=!!k.aoMap,B=!!k.lightMap,$=!!k.bumpMap,ie=!!k.normalMap,H=!!k.displacementMap,Y=!!k.emissiveMap,se=!!k.metalnessMap,ve=!!k.roughnessMap,Ne=k.anisotropy>0,Se=k.clearcoat>0,U=k.iridescence>0,L=k.sheen>0,te=k.transmission>0,ye=Ne&&!!k.anisotropyMap,Me=Se&&!!k.clearcoatMap,be=Se&&!!k.clearcoatNormalMap,qe=Se&&!!k.clearcoatRoughnessMap,Ve=U&&!!k.iridescenceMap,We=U&&!!k.iridescenceThicknessMap,lt=L&&!!k.sheenColorMap,me=L&&!!k.sheenRoughnessMap,ae=!!k.specularMap,He=!!k.specularColorMap,Be=!!k.specularIntensityMap,Ye=te&&!!k.transmissionMap,ot=te&&!!k.thicknessMap,ge=!!k.gradientMap,nt=!!k.alphaMap,xe=k.alphaTest>0,ze=!!k.alphaHash,Re=!!k.extensions,we=!!W.attributes.uv1,Ke=!!W.attributes.uv2,ft=!!W.attributes.uv3;let Et=hd;return k.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(Et=t.toneMapping),{isWebGL2:d,shaderID:ee,shaderType:k.type,shaderName:k.name,vertexShader:ne,fragmentShader:le,defines:k.defines,customVertexShaderID:oe,customFragmentShaderID:pe,isRawShaderMaterial:k.isRawShaderMaterial===!0,glslVersion:k.glslVersion,precision:p,batching:he,instancing:Ee,instancingColor:Ee&&q.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:Q===null?t.outputColorSpace:Q.isXRRenderTarget===!0?Q.texture.colorSpace:Zc,map:ue,matcap:Ae,envMap:fe,envMapMode:fe&&G.mapping,envMapCubeUVHeight:J,aoMap:at,lightMap:B,bumpMap:$,normalMap:ie,displacementMap:g&&H,emissiveMap:Y,normalMapObjectSpace:ie&&k.normalMapType===QOe,normalMapTangentSpace:ie&&k.normalMapType===pQ,metalnessMap:se,roughnessMap:ve,anisotropy:Ne,anisotropyMap:ye,clearcoat:Se,clearcoatMap:Me,clearcoatNormalMap:be,clearcoatRoughnessMap:qe,iridescence:U,iridescenceMap:Ve,iridescenceThicknessMap:We,sheen:L,sheenColorMap:lt,sheenRoughnessMap:me,specularMap:ae,specularColorMap:He,specularIntensityMap:Be,transmission:te,transmissionMap:Ye,thicknessMap:ot,gradientMap:ge,opaque:k.transparent===!1&&k.blending===bp,alphaMap:nt,alphaTest:xe,alphaHash:ze,combine:k.combine,mapUv:ue&&v(k.map.channel),aoMapUv:at&&v(k.aoMap.channel),lightMapUv:B&&v(k.lightMap.channel),bumpMapUv:$&&v(k.bumpMap.channel),normalMapUv:ie&&v(k.normalMap.channel),displacementMapUv:H&&v(k.displacementMap.channel),emissiveMapUv:Y&&v(k.emissiveMap.channel),metalnessMapUv:se&&v(k.metalnessMap.channel),roughnessMapUv:ve&&v(k.roughnessMap.channel),anisotropyMapUv:ye&&v(k.anisotropyMap.channel),clearcoatMapUv:Me&&v(k.clearcoatMap.channel),clearcoatNormalMapUv:be&&v(k.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:qe&&v(k.clearcoatRoughnessMap.channel),iridescenceMapUv:Ve&&v(k.iridescenceMap.channel),iridescenceThicknessMapUv:We&&v(k.iridescenceThicknessMap.channel),sheenColorMapUv:lt&&v(k.sheenColorMap.channel),sheenRoughnessMapUv:me&&v(k.sheenRoughnessMap.channel),specularMapUv:ae&&v(k.specularMap.channel),specularColorMapUv:He&&v(k.specularColorMap.channel),specularIntensityMapUv:Be&&v(k.specularIntensityMap.channel),transmissionMapUv:Ye&&v(k.transmissionMap.channel),thicknessMapUv:ot&&v(k.thicknessMap.channel),alphaMapUv:nt&&v(k.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(ie||Ne),vertexColors:k.vertexColors,vertexAlphas:k.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,vertexUv1s:we,vertexUv2s:Ke,vertexUv3s:ft,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(ue||nt),fog:!!R,useFog:k.fog===!0,fogExp2:R&&R.isFogExp2,flatShading:k.flatShading===!0,sizeAttenuation:k.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:F,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&&z.length>0,shadowMapType:t.shadowMap.type,toneMapping:Et,useLegacyLights:t._useLegacyLights,decodeVideoTexture:ue&&k.map.isVideoTexture===!0&&or.getTransfer(k.map.colorSpace)===Sr,premultipliedAlpha:k.premultipliedAlpha,doubleSided:k.side===wc,flipSided:k.side===rs,useDepthPacking:k.depthPacking>=0,depthPacking:k.depthPacking||0,index0AttributeName:k.index0AttributeName,extensionDerivatives:Re&&k.extensions.derivatives===!0,extensionFragDepth:Re&&k.extensions.fragDepth===!0,extensionDrawBuffers:Re&&k.extensions.drawBuffers===!0,extensionShaderTextureLOD:Re&&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 y(k){const j=[];if(k.shaderID?j.push(k.shaderID):(j.push(k.customVertexShaderID),j.push(k.customFragmentShaderID)),k.defines!==void 0)for(const z in k.defines)j.push(z),j.push(k.defines[z]);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=b[k.type];let z;if(j){const I=Ja[j];z=qO.clone(I.uniforms)}else z=k.uniforms;return z}function T(k,j){let z;for(let I=0,q=u.length;I<q;I++){const R=u[I];if(R.cacheKey===j){z=R,++z.usedTimes;break}}return z===void 0&&(z=new ZFe(t,j,k,a),u.push(z)),z}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:x,getProgramCacheKey:y,getUniforms:A,acquireProgram:T,releaseProgram:C,releaseShaderCache:N,programs:u,dispose:O}}function nUe(){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 rUe(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 BV(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 HV(){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,b,v,x){let y=t[e];return y===void 0?(y={id:f.id,object:f,geometry:g,material:p,groupOrder:b,renderOrder:f.renderOrder,z:v,group:x},t[e]=y):(y.id=f.id,y.object=f,y.geometry=g,y.material=p,y.groupOrder=b,y.renderOrder=f.renderOrder,y.z=v,y.group=x),e++,y}function l(f,g,p,b,v,x){const y=s(f,g,p,b,v,x);p.transmission>0?r.push(y):p.transparent===!0?i.push(y):n.push(y)}function c(f,g,p,b,v,x){const y=s(f,g,p,b,v,x);p.transmission>0?r.unshift(y):p.transparent===!0?i.unshift(y):n.unshift(y)}function u(f,g){n.length>1&&n.sort(f||rUe),r.length>1&&r.sort(g||BV),i.length>1&&i.sort(g||BV)}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 iUe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let s;return a===void 0?(s=new HV,t.set(r,[s])):i>=a.length?(s=new HV,a.push(s)):s=a[i],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function aUe(){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 Le,color:new Kt};break;case"SpotLight":n={position:new Le,direction:new Le,color:new Kt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Le,color:new Kt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Le,skyColor:new Kt,groundColor:new Kt};break;case"RectAreaLight":n={color:new Kt,position:new Le,halfWidth:new Le,halfHeight:new Le};break}return t[e.id]=n,n}}}function sUe(){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 rn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let oUe=0;function lUe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function cUe(t,e){const n=new aUe,r=sUe(),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 Le);const a=new Le,s=new yr,l=new yr;function c(d,f){let g=0,p=0,b=0;for(let I=0;I<9;I++)i.probe[I].set(0,0,0);let v=0,x=0,y=0,E=0,w=0,A=0,T=0,C=0,N=0,O=0,k=0;d.sort(lUe);const j=f===!0?Math.PI:1;for(let I=0,q=d.length;I<q;I++){const R=d[I],W=R.color,K=R.intensity,G=R.distance,J=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)g+=W.r*K*j,p+=W.g*K*j,b+=W.b*K*j;else if(R.isLightProbe){for(let ee=0;ee<9;ee++)i.probe[ee].addScaledVector(R.sh.coefficients[ee],K);k++}else if(R.isDirectionalLight){const ee=n.get(R);if(ee.color.copy(R.color).multiplyScalar(R.intensity*j),R.castShadow){const Z=R.shadow,F=r.get(R);F.shadowBias=Z.bias,F.shadowNormalBias=Z.normalBias,F.shadowRadius=Z.radius,F.shadowMapSize=Z.mapSize,i.directionalShadow[v]=F,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(W).multiplyScalar(K*j),ee.distance=G,ee.coneCos=Math.cos(R.angle),ee.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),ee.decay=R.decay,i.spot[y]=ee;const Z=R.shadow;if(R.map&&(i.spotLightMap[N]=R.map,N++,Z.updateMatrices(R),R.castShadow&&O++),i.spotLightMatrix[y]=Z.matrix,R.castShadow){const F=r.get(R);F.shadowBias=Z.bias,F.shadowNormalBias=Z.normalBias,F.shadowRadius=Z.radius,F.shadowMapSize=Z.mapSize,i.spotShadow[y]=F,i.spotShadowMap[y]=J,C++}y++}else if(R.isRectAreaLight){const ee=n.get(R);ee.color.copy(W).multiplyScalar(K),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 Z=R.shadow,F=r.get(R);F.shadowBias=Z.bias,F.shadowNormalBias=Z.normalBias,F.shadowRadius=Z.radius,F.shadowMapSize=Z.mapSize,F.shadowCameraNear=Z.camera.near,F.shadowCameraFar=Z.camera.far,i.pointShadow[x]=F,i.pointShadowMap[x]=J,i.pointShadowMatrix[x]=R.shadow.matrix,T++}i.point[x]=ee,x++}else if(R.isHemisphereLight){const ee=n.get(R);ee.skyColor.copy(R.color).multiplyScalar(K*j),ee.groundColor.copy(R.groundColor).multiplyScalar(K*j),i.hemi[w]=ee,w++}}E>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=kt.LTC_FLOAT_1,i.rectAreaLTC2=kt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=kt.LTC_HALF_1,i.rectAreaLTC2=kt.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]=b;const z=i.hash;(z.directionalLength!==v||z.pointLength!==x||z.spotLength!==y||z.rectAreaLength!==E||z.hemiLength!==w||z.numDirectionalShadows!==A||z.numPointShadows!==T||z.numSpotShadows!==C||z.numSpotMaps!==N||z.numLightProbes!==k)&&(i.directional.length=v,i.spot.length=y,i.rectArea.length=E,i.point.length=x,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,z.directionalLength=v,z.pointLength=x,z.spotLength=y,z.rectAreaLength=E,z.hemiLength=w,z.numDirectionalShadows=A,z.numPointShadows=T,z.numSpotShadows=C,z.numSpotMaps=N,z.numLightProbes=k,i.version=oUe++)}function u(d,f){let g=0,p=0,b=0,v=0,x=0;const y=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(y),g++}else if(A.isSpotLight){const T=i.spot[b];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(y),T.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(y),b++}else if(A.isRectAreaLight){const T=i.rectArea[v];T.position.setFromMatrixPosition(A.matrixWorld),T.position.applyMatrix4(y),l.identity(),s.copy(A.matrixWorld),s.premultiply(y),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(y),p++}else if(A.isHemisphereLight){const T=i.hemi[x];T.direction.setFromMatrixPosition(A.matrixWorld),T.direction.transformDirection(y),x++}}}return{setup:c,setupView:u,state:i}}function $V(t,e){const n=new cUe(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 uUe(t,e){let n=new WeakMap;function r(a,s=0){const l=n.get(a);let c;return l===void 0?(c=new $V(t,e),n.set(a,[c])):s>=l.length?(c=new $V(t,e),l.push(c)):c=l[s],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class dUe extends wg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=YOe,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 hUe 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 fUe=`void main() {
  7449. gl_Position = vec4( position, 1.0 );
  7450. }`,mUe=`uniform sampler2D shadow_pass;
  7451. uniform vec2 resolution;
  7452. uniform float radius;
  7453. #include <packing>
  7454. void main() {
  7455. const float samples = float( VSM_SAMPLES );
  7456. float mean = 0.0;
  7457. float squared_mean = 0.0;
  7458. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  7459. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  7460. for ( float i = 0.0; i < samples; i ++ ) {
  7461. float uvOffset = uvStart + i * uvStride;
  7462. #ifdef HORIZONTAL_PASS
  7463. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  7464. mean += distribution.x;
  7465. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  7466. #else
  7467. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  7468. mean += depth;
  7469. squared_mean += depth * depth;
  7470. #endif
  7471. }
  7472. mean = mean / samples;
  7473. squared_mean = squared_mean / samples;
  7474. float std_dev = sqrt( squared_mean - mean * mean );
  7475. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  7476. }`;function pUe(t,e,n){let r=new lE;const i=new rn,a=new rn,s=new cr,l=new dUe({depthPacking:ZOe}),c=new hUe,u={},d=n.maxTextureSize,f={[Cd]:rs,[rs]:Cd,[wc]:wc},g=new kd({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new rn},radius:{value:4}},vertexShader:fUe,fragmentShader:mUe}),p=g.clone();p.defines.HORIZONTAL_PASS=1;const b=new Ea;b.setAttribute("position",new Ps(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Uo(b,g),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=aQ;let y=this.type;this.render=function(T,C,N){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||T.length===0)return;const O=t.getRenderTarget(),k=t.getActiveCubeFace(),j=t.getActiveMipmapLevel(),z=t.state;z.setBlending(dd),z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);const I=y!==gc&&this.type===gc,q=y===gc&&this.type!==gc;for(let R=0,W=T.length;R<W;R++){const K=T[R],G=K.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const J=G.getFrameExtents();if(i.multiply(J),a.copy(G.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/J.x),i.x=a.x*J.x,G.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/J.y),i.y=a.y*J.y,G.mapSize.y=a.y)),G.map===null||I===!0||q===!0){const Z=this.type!==gc?{minFilter:aa,magFilter:aa}:{};G.map!==null&&G.map.dispose(),G.map=new bf(i.x,i.y,Z),G.map.texture.name=K.name+".shadowMap",G.camera.updateProjectionMatrix()}t.setRenderTarget(G.map),t.clear();const ee=G.getViewportCount();for(let Z=0;Z<ee;Z++){const F=G.getViewport(Z);s.set(a.x*F.x,a.y*F.y,a.x*F.z,a.y*F.w),z.viewport(s),G.updateMatrices(K,Z),r=G.getFrustum(),A(C,N,G.camera,K,this.type)}G.isPointLightShadow!==!0&&this.type===gc&&E(G,N),G.needsUpdate=!1}y=this.type,x.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 z=k.uuid,I=C.uuid;let q=u[z];q===void 0&&(q={},u[z]=q);let R=q[I];R===void 0&&(R=k.clone(),q[I]=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 z=t.properties.get(k);z.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 I=e.update(T),q=T.material;if(Array.isArray(q)){const R=I.groups;for(let W=0,K=R.length;W<K;W++){const G=R[W],J=q[G.materialIndex];if(J&&J.visible){const ee=w(T,J,O,k);T.onBeforeShadow(t,T,C,N,I,ee,G),t.renderBufferDirect(N,null,I,ee,T,G),T.onAfterShadow(t,T,C,N,I,ee,G)}}}else if(q.visible){const R=w(T,q,O,k);T.onBeforeShadow(t,T,C,N,I,R,null),t.renderBufferDirect(N,null,I,R,T,null),T.onAfterShadow(t,T,C,N,I,R,null)}}const z=T.children;for(let I=0,q=z.length;I<q;I++)A(z[I],C,N,O,k)}}function gUe(t,e,n){const r=n.isWebGL2;function i(){let xe=!1;const ze=new cr;let Re=null;const we=new cr(0,0,0,0);return{setMask:function(Ke){Re!==Ke&&!xe&&(t.colorMask(Ke,Ke,Ke,Ke),Re=Ke)},setLocked:function(Ke){xe=Ke},setClear:function(Ke,ft,Et,wt,Qt){Qt===!0&&(Ke*=wt,ft*=wt,Et*=wt),ze.set(Ke,ft,Et,wt),we.equals(ze)===!1&&(t.clearColor(Ke,ft,Et,wt),we.copy(ze))},reset:function(){xe=!1,Re=null,we.set(-1,0,0,0)}}}function a(){let xe=!1,ze=null,Re=null,we=null;return{setTest:function(Ke){Ke?he(t.DEPTH_TEST):ue(t.DEPTH_TEST)},setMask:function(Ke){ze!==Ke&&!xe&&(t.depthMask(Ke),ze=Ke)},setFunc:function(Ke){if(Re!==Ke){switch(Ke){case TOe:t.depthFunc(t.NEVER);break;case NOe:t.depthFunc(t.ALWAYS);break;case COe:t.depthFunc(t.LESS);break;case Zw:t.depthFunc(t.LEQUAL);break;case kOe:t.depthFunc(t.EQUAL);break;case POe:t.depthFunc(t.GEQUAL);break;case jOe:t.depthFunc(t.GREATER);break;case ROe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Re=Ke}},setLocked:function(Ke){xe=Ke},setClear:function(Ke){we!==Ke&&(t.clearDepth(Ke),we=Ke)},reset:function(){xe=!1,ze=null,Re=null,we=null}}}function s(){let xe=!1,ze=null,Re=null,we=null,Ke=null,ft=null,Et=null,wt=null,Qt=null;return{setTest:function(Ft){xe||(Ft?he(t.STENCIL_TEST):ue(t.STENCIL_TEST))},setMask:function(Ft){ze!==Ft&&!xe&&(t.stencilMask(Ft),ze=Ft)},setFunc:function(Ft,hn,Hn){(Re!==Ft||we!==hn||Ke!==Hn)&&(t.stencilFunc(Ft,hn,Hn),Re=Ft,we=hn,Ke=Hn)},setOp:function(Ft,hn,Hn){(ft!==Ft||Et!==hn||wt!==Hn)&&(t.stencilOp(Ft,hn,Hn),ft=Ft,Et=hn,wt=Hn)},setLocked:function(Ft){xe=Ft},setClear:function(Ft){Qt!==Ft&&(t.clearStencil(Ft),Qt=Ft)},reset:function(){xe=!1,ze=null,Re=null,we=null,Ke=null,ft=null,Et=null,wt=null,Qt=null}}}const l=new i,c=new a,u=new s,d=new WeakMap,f=new WeakMap;let g={},p={},b=new WeakMap,v=[],x=null,y=!1,E=null,w=null,A=null,T=null,C=null,N=null,O=null,k=new Kt(0,0,0),j=0,z=!1,I=null,q=null,R=null,W=null,K=null;const G=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let J=!1,ee=0;const Z=t.getParameter(t.VERSION);Z.indexOf("WebGL")!==-1?(ee=parseFloat(/^WebGL (\d)/.exec(Z)[1]),J=ee>=1):Z.indexOf("OpenGL ES")!==-1&&(ee=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),J=ee>=2);let F=null,V={};const ne=t.getParameter(t.SCISSOR_BOX),le=t.getParameter(t.VIEWPORT),oe=new cr().fromArray(ne),pe=new cr().fromArray(le);function Q(xe,ze,Re,we){const Ke=new Uint8Array(4),ft=t.createTexture();t.bindTexture(xe,ft),t.texParameteri(xe,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(xe,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Et=0;Et<Re;Et++)r&&(xe===t.TEXTURE_3D||xe===t.TEXTURE_2D_ARRAY)?t.texImage3D(ze,0,t.RGBA,1,1,we,0,t.RGBA,t.UNSIGNED_BYTE,Ke):t.texImage2D(ze+Et,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ke);return ft}const Ee={};Ee[t.TEXTURE_2D]=Q(t.TEXTURE_2D,t.TEXTURE_2D,1),Ee[t.TEXTURE_CUBE_MAP]=Q(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ee[t.TEXTURE_2D_ARRAY]=Q(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ee[t.TEXTURE_3D]=Q(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),he(t.DEPTH_TEST),c.setFunc(Zw),Y(!1),se(E$),he(t.CULL_FACE),ie(dd);function he(xe){g[xe]!==!0&&(t.enable(xe),g[xe]=!0)}function ue(xe){g[xe]!==!1&&(t.disable(xe),g[xe]=!1)}function Ae(xe,ze){return p[xe]!==ze?(t.bindFramebuffer(xe,ze),p[xe]=ze,r&&(xe===t.DRAW_FRAMEBUFFER&&(p[t.FRAMEBUFFER]=ze),xe===t.FRAMEBUFFER&&(p[t.DRAW_FRAMEBUFFER]=ze)),!0):!1}function fe(xe,ze){let Re=v,we=!1;if(xe)if(Re=b.get(ze),Re===void 0&&(Re=[],b.set(ze,Re)),xe.isWebGLMultipleRenderTargets){const Ke=xe.texture;if(Re.length!==Ke.length||Re[0]!==t.COLOR_ATTACHMENT0){for(let ft=0,Et=Ke.length;ft<Et;ft++)Re[ft]=t.COLOR_ATTACHMENT0+ft;Re.length=Ke.length,we=!0}}else Re[0]!==t.COLOR_ATTACHMENT0&&(Re[0]=t.COLOR_ATTACHMENT0,we=!0);else Re[0]!==t.BACK&&(Re[0]=t.BACK,we=!0);we&&(n.isWebGL2?t.drawBuffers(Re):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Re))}function at(xe){return x!==xe?(t.useProgram(xe),x=xe,!0):!1}const B={[Sh]:t.FUNC_ADD,[hOe]:t.FUNC_SUBTRACT,[fOe]:t.FUNC_REVERSE_SUBTRACT};if(r)B[C$]=t.MIN,B[k$]=t.MAX;else{const xe=e.get("EXT_blend_minmax");xe!==null&&(B[C$]=xe.MIN_EXT,B[k$]=xe.MAX_EXT)}const $={[mOe]:t.ZERO,[pOe]:t.ONE,[gOe]:t.SRC_COLOR,[QP]:t.SRC_ALPHA,[wOe]:t.SRC_ALPHA_SATURATE,[vOe]:t.DST_COLOR,[bOe]:t.DST_ALPHA,[xOe]:t.ONE_MINUS_SRC_COLOR,[JP]:t.ONE_MINUS_SRC_ALPHA,[_Oe]:t.ONE_MINUS_DST_COLOR,[yOe]:t.ONE_MINUS_DST_ALPHA,[SOe]:t.CONSTANT_COLOR,[MOe]:t.ONE_MINUS_CONSTANT_COLOR,[EOe]:t.CONSTANT_ALPHA,[AOe]:t.ONE_MINUS_CONSTANT_ALPHA};function ie(xe,ze,Re,we,Ke,ft,Et,wt,Qt,Ft){if(xe===dd){y===!0&&(ue(t.BLEND),y=!1);return}if(y===!1&&(he(t.BLEND),y=!0),xe!==dOe){if(xe!==E||Ft!==z){if((w!==Sh||C!==Sh)&&(t.blendEquation(t.FUNC_ADD),w=Sh,C=Sh),Ft)switch(xe){case bp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case A$:t.blendFunc(t.ONE,t.ONE);break;case T$:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case N$: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 A$:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case T$:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case N$: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,z=Ft}return}Ke=Ke||ze,ft=ft||Re,Et=Et||we,(ze!==w||Ke!==C)&&(t.blendEquationSeparate(B[ze],B[Ke]),w=ze,C=Ke),(Re!==A||we!==T||ft!==N||Et!==O)&&(t.blendFuncSeparate($[Re],$[we],$[ft],$[Et]),A=Re,T=we,N=ft,O=Et),(wt.equals(k)===!1||Qt!==j)&&(t.blendColor(wt.r,wt.g,wt.b,Qt),k.copy(wt),j=Qt),E=xe,z=!1}function H(xe,ze){xe.side===wc?ue(t.CULL_FACE):he(t.CULL_FACE);let Re=xe.side===rs;ze&&(Re=!Re),Y(Re),xe.blending===bp&&xe.transparent===!1?ie(dd):ie(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)),Ne(xe.polygonOffset,xe.polygonOffsetFactor,xe.polygonOffsetUnits),xe.alphaToCoverage===!0?he(t.SAMPLE_ALPHA_TO_COVERAGE):ue(t.SAMPLE_ALPHA_TO_COVERAGE)}function Y(xe){I!==xe&&(xe?t.frontFace(t.CW):t.frontFace(t.CCW),I=xe)}function se(xe){xe!==lOe?(he(t.CULL_FACE),xe!==q&&(xe===E$?t.cullFace(t.BACK):xe===cOe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ue(t.CULL_FACE),q=xe}function ve(xe){xe!==R&&(J&&t.lineWidth(xe),R=xe)}function Ne(xe,ze,Re){xe?(he(t.POLYGON_OFFSET_FILL),(W!==ze||K!==Re)&&(t.polygonOffset(ze,Re),W=ze,K=Re)):ue(t.POLYGON_OFFSET_FILL)}function Se(xe){xe?he(t.SCISSOR_TEST):ue(t.SCISSOR_TEST)}function U(xe){xe===void 0&&(xe=t.TEXTURE0+G-1),F!==xe&&(t.activeTexture(xe),F=xe)}function L(xe,ze,Re){Re===void 0&&(F===null?Re=t.TEXTURE0+G-1:Re=F);let we=V[Re];we===void 0&&(we={type:void 0,texture:void 0},V[Re]=we),(we.type!==xe||we.texture!==ze)&&(F!==Re&&(t.activeTexture(Re),F=Re),t.bindTexture(xe,ze||Ee[xe]),we.type=xe,we.texture=ze)}function te(){const xe=V[F];xe!==void 0&&xe.type!==void 0&&(t.bindTexture(xe.type,null),xe.type=void 0,xe.texture=void 0)}function ye(){try{t.compressedTexImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Me(){try{t.compressedTexImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function be(){try{t.texSubImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function qe(){try{t.texSubImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Ve(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function We(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function lt(){try{t.texStorage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function me(){try{t.texStorage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function ae(){try{t.texImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function He(){try{t.texImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Be(xe){oe.equals(xe)===!1&&(t.scissor(xe.x,xe.y,xe.z,xe.w),oe.copy(xe))}function Ye(xe){pe.equals(xe)===!1&&(t.viewport(xe.x,xe.y,xe.z,xe.w),pe.copy(xe))}function ot(xe,ze){let Re=f.get(ze);Re===void 0&&(Re=new WeakMap,f.set(ze,Re));let we=Re.get(xe);we===void 0&&(we=t.getUniformBlockIndex(ze,xe.name),Re.set(xe,we))}function ge(xe,ze){const we=f.get(ze).get(xe);d.get(ze)!==we&&(t.uniformBlockBinding(ze,we,xe.__bindingPointIndex),d.set(ze,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={},F=null,V={},p={},b=new WeakMap,v=[],x=null,y=!1,E=null,w=null,A=null,T=null,C=null,N=null,O=null,k=new Kt(0,0,0),j=0,z=!1,I=null,q=null,R=null,W=null,K=null,oe.set(0,0,t.canvas.width,t.canvas.height),pe.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:he,disable:ue,bindFramebuffer:Ae,drawBuffers:fe,useProgram:at,setBlending:ie,setMaterial:H,setFlipSided:Y,setCullFace:se,setLineWidth:ve,setPolygonOffset:Ne,setScissorTest:Se,activeTexture:U,bindTexture:L,unbindTexture:te,compressedTexImage2D:ye,compressedTexImage3D:Me,texImage2D:ae,texImage3D:He,updateUBOMapping:ot,uniformBlockBinding:ge,texStorage2D:lt,texStorage3D:me,texSubImage2D:be,texSubImage3D:qe,compressedTexSubImage2D:Ve,compressedTexSubImage3D:We,scissor:Be,viewport:Ye,reset:nt}}function xUe(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),b=new WeakMap;let v;const x=new WeakMap;let y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function E(U,L){return y?new OffscreenCanvas(U,L):nS("canvas")}function w(U,L,te,ye){let Me=1;if((U.width>ye||U.height>ye)&&(Me=ye/Math.max(U.width,U.height)),Me<1||L===!0)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap){const be=L?tS:Math.floor,qe=be(Me*U.width),Ve=be(Me*U.height);v===void 0&&(v=E(qe,Ve));const We=te?E(qe,Ve):v;return We.width=qe,We.height=Ve,We.getContext("2d").drawImage(U,0,0,qe,Ve),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+U.width+"x"+U.height+") to ("+qe+"x"+Ve+")."),We}else return"data"in U&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+U.width+"x"+U.height+")."),U;return U}function A(U){return sj(U.width)&&sj(U.height)}function T(U){return l?!1:U.wrapS!==Lo||U.wrapT!==Lo||U.minFilter!==aa&&U.minFilter!==ro}function C(U,L){return U.generateMipmaps&&L&&U.minFilter!==aa&&U.minFilter!==ro}function N(U){t.generateMipmap(U)}function O(U,L,te,ye,Me=!1){if(l===!1)return L;if(U!==null){if(t[U]!==void 0)return t[U];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let be=L;if(L===t.RED&&(te===t.FLOAT&&(be=t.R32F),te===t.HALF_FLOAT&&(be=t.R16F),te===t.UNSIGNED_BYTE&&(be=t.R8)),L===t.RED_INTEGER&&(te===t.UNSIGNED_BYTE&&(be=t.R8UI),te===t.UNSIGNED_SHORT&&(be=t.R16UI),te===t.UNSIGNED_INT&&(be=t.R32UI),te===t.BYTE&&(be=t.R8I),te===t.SHORT&&(be=t.R16I),te===t.INT&&(be=t.R32I)),L===t.RG&&(te===t.FLOAT&&(be=t.RG32F),te===t.HALF_FLOAT&&(be=t.RG16F),te===t.UNSIGNED_BYTE&&(be=t.RG8)),L===t.RGBA){const qe=Me?Qw:or.getTransfer(ye);te===t.FLOAT&&(be=t.RGBA32F),te===t.HALF_FLOAT&&(be=t.RGBA16F),te===t.UNSIGNED_BYTE&&(be=qe===Sr?t.SRGB8_ALPHA8:t.RGBA8),te===t.UNSIGNED_SHORT_4_4_4_4&&(be=t.RGBA4),te===t.UNSIGNED_SHORT_5_5_5_1&&(be=t.RGB5_A1)}return(be===t.R16F||be===t.R32F||be===t.RG16F||be===t.RG32F||be===t.RGBA16F||be===t.RGBA32F)&&e.get("EXT_color_buffer_float"),be}function k(U,L,te){return C(U,te)===!0||U.isFramebufferTexture&&U.minFilter!==aa&&U.minFilter!==ro?Math.log2(Math.max(L.width,L.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?L.mipmaps.length:1}function j(U){return U===aa||U===P$||U===mC?t.NEAREST:t.LINEAR}function z(U){const L=U.target;L.removeEventListener("dispose",z),q(L),L.isVideoTexture&&b.delete(L)}function I(U){const L=U.target;L.removeEventListener("dispose",I),W(L)}function q(U){const L=r.get(U);if(L.__webglInit===void 0)return;const te=U.source,ye=x.get(te);if(ye){const Me=ye[L.__cacheKey];Me.usedTimes--,Me.usedTimes===0&&R(U),Object.keys(ye).length===0&&x.delete(te)}r.remove(U)}function R(U){const L=r.get(U);t.deleteTexture(L.__webglTexture);const te=U.source,ye=x.get(te);delete ye[L.__cacheKey],s.memory.textures--}function W(U){const L=U.texture,te=r.get(U),ye=r.get(L);if(ye.__webglTexture!==void 0&&(t.deleteTexture(ye.__webglTexture),s.memory.textures--),U.depthTexture&&U.depthTexture.dispose(),U.isWebGLCubeRenderTarget)for(let Me=0;Me<6;Me++){if(Array.isArray(te.__webglFramebuffer[Me]))for(let be=0;be<te.__webglFramebuffer[Me].length;be++)t.deleteFramebuffer(te.__webglFramebuffer[Me][be]);else t.deleteFramebuffer(te.__webglFramebuffer[Me]);te.__webglDepthbuffer&&t.deleteRenderbuffer(te.__webglDepthbuffer[Me])}else{if(Array.isArray(te.__webglFramebuffer))for(let Me=0;Me<te.__webglFramebuffer.length;Me++)t.deleteFramebuffer(te.__webglFramebuffer[Me]);else t.deleteFramebuffer(te.__webglFramebuffer);if(te.__webglDepthbuffer&&t.deleteRenderbuffer(te.__webglDepthbuffer),te.__webglMultisampledFramebuffer&&t.deleteFramebuffer(te.__webglMultisampledFramebuffer),te.__webglColorRenderbuffer)for(let Me=0;Me<te.__webglColorRenderbuffer.length;Me++)te.__webglColorRenderbuffer[Me]&&t.deleteRenderbuffer(te.__webglColorRenderbuffer[Me]);te.__webglDepthRenderbuffer&&t.deleteRenderbuffer(te.__webglDepthRenderbuffer)}if(U.isWebGLMultipleRenderTargets)for(let Me=0,be=L.length;Me<be;Me++){const qe=r.get(L[Me]);qe.__webglTexture&&(t.deleteTexture(qe.__webglTexture),s.memory.textures--),r.remove(L[Me])}r.remove(L),r.remove(U)}let K=0;function G(){K=0}function J(){const U=K;return U>=c&&console.warn("THREE.WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+c),K+=1,U}function ee(U){const L=[];return L.push(U.wrapS),L.push(U.wrapT),L.push(U.wrapR||0),L.push(U.magFilter),L.push(U.minFilter),L.push(U.anisotropy),L.push(U.internalFormat),L.push(U.format),L.push(U.type),L.push(U.generateMipmaps),L.push(U.premultiplyAlpha),L.push(U.flipY),L.push(U.unpackAlignment),L.push(U.colorSpace),L.join()}function Z(U,L){const te=r.get(U);if(U.isVideoTexture&&Ne(U),U.isRenderTargetTexture===!1&&U.version>0&&te.__version!==U.version){const ye=U.image;if(ye===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ye.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{he(te,U,L);return}}n.bindTexture(t.TEXTURE_2D,te.__webglTexture,t.TEXTURE0+L)}function F(U,L){const te=r.get(U);if(U.version>0&&te.__version!==U.version){he(te,U,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,te.__webglTexture,t.TEXTURE0+L)}function V(U,L){const te=r.get(U);if(U.version>0&&te.__version!==U.version){he(te,U,L);return}n.bindTexture(t.TEXTURE_3D,te.__webglTexture,t.TEXTURE0+L)}function ne(U,L){const te=r.get(U);if(U.version>0&&te.__version!==U.version){ue(te,U,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,te.__webglTexture,t.TEXTURE0+L)}const le={[nj]:t.REPEAT,[Lo]:t.CLAMP_TO_EDGE,[rj]:t.MIRRORED_REPEAT},oe={[aa]:t.NEAREST,[P$]:t.NEAREST_MIPMAP_NEAREST,[mC]:t.NEAREST_MIPMAP_LINEAR,[ro]:t.LINEAR,[BOe]:t.LINEAR_MIPMAP_NEAREST,[ib]:t.LINEAR_MIPMAP_LINEAR},pe={[JOe]:t.NEVER,[aLe]:t.ALWAYS,[eLe]:t.LESS,[gQ]:t.LEQUAL,[tLe]:t.EQUAL,[iLe]:t.GEQUAL,[nLe]:t.GREATER,[rLe]:t.NOTEQUAL};function Q(U,L,te){if(te?(t.texParameteri(U,t.TEXTURE_WRAP_S,le[L.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,le[L.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,le[L.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,oe[L.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,oe[L.minFilter])):(t.texParameteri(U,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(U,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==Lo||L.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(U,t.TEXTURE_MAG_FILTER,j(L.magFilter)),t.texParameteri(U,t.TEXTURE_MIN_FILTER,j(L.minFilter)),L.minFilter!==aa&&L.minFilter!==ro&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),L.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,pe[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ye=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===aa||L.minFilter!==mC&&L.minFilter!==ib||L.type===Cc&&e.has("OES_texture_float_linear")===!1||l===!1&&L.type===ab&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf(U,ye.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function Ee(U,L){let te=!1;U.__webglInit===void 0&&(U.__webglInit=!0,L.addEventListener("dispose",z));const ye=L.source;let Me=x.get(ye);Me===void 0&&(Me={},x.set(ye,Me));const be=ee(L);if(be!==U.__cacheKey){Me[be]===void 0&&(Me[be]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,te=!0),Me[be].usedTimes++;const qe=Me[U.__cacheKey];qe!==void 0&&(Me[U.__cacheKey].usedTimes--,qe.usedTimes===0&&R(L)),U.__cacheKey=be,U.__webglTexture=Me[be].texture}return te}function he(U,L,te){let ye=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(ye=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(ye=t.TEXTURE_3D);const Me=Ee(U,L),be=L.source;n.bindTexture(ye,U.__webglTexture,t.TEXTURE0+te);const qe=r.get(be);if(be.version!==qe.__version||Me===!0){n.activeTexture(t.TEXTURE0+te);const Ve=or.getPrimaries(or.workingColorSpace),We=L.colorSpace===ao?null:or.getPrimaries(L.colorSpace),lt=L.colorSpace===ao||Ve===We?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,lt);const me=T(L)&&A(L.image)===!1;let ae=w(L.image,me,!1,d);ae=Se(L,ae);const He=A(ae)||l,Be=a.convert(L.format,L.colorSpace);let Ye=a.convert(L.type),ot=O(L.internalFormat,Be,Ye,L.colorSpace,L.isVideoTexture);Q(ye,L,He);let ge;const nt=L.mipmaps,xe=l&&L.isVideoTexture!==!0&&ot!==fQ,ze=qe.__version===void 0||Me===!0,Re=k(L,ae,He);if(L.isDepthTexture)ot=t.DEPTH_COMPONENT,l?L.type===Cc?ot=t.DEPTH_COMPONENT32F:L.type===rd?ot=t.DEPTH_COMPONENT24:L.type===$h?ot=t.DEPTH24_STENCIL8:ot=t.DEPTH_COMPONENT16:L.type===Cc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===Vh&&ot===t.DEPTH_COMPONENT&&L.type!==$O&&L.type!==rd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=rd,Ye=a.convert(L.type)),L.format===Gp&&ot===t.DEPTH_COMPONENT&&(ot=t.DEPTH_STENCIL,L.type!==$h&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=$h,Ye=a.convert(L.type))),ze&&(xe?n.texStorage2D(t.TEXTURE_2D,1,ot,ae.width,ae.height):n.texImage2D(t.TEXTURE_2D,0,ot,ae.width,ae.height,0,Be,Ye,null));else if(L.isDataTexture)if(nt.length>0&&He){xe&&ze&&n.texStorage2D(t.TEXTURE_2D,Re,ot,nt[0].width,nt[0].height);for(let we=0,Ke=nt.length;we<Ke;we++)ge=nt[we],xe?n.texSubImage2D(t.TEXTURE_2D,we,0,0,ge.width,ge.height,Be,Ye,ge.data):n.texImage2D(t.TEXTURE_2D,we,ot,ge.width,ge.height,0,Be,Ye,ge.data);L.generateMipmaps=!1}else xe?(ze&&n.texStorage2D(t.TEXTURE_2D,Re,ot,ae.width,ae.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ae.width,ae.height,Be,Ye,ae.data)):n.texImage2D(t.TEXTURE_2D,0,ot,ae.width,ae.height,0,Be,Ye,ae.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){xe&&ze&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Re,ot,nt[0].width,nt[0].height,ae.depth);for(let we=0,Ke=nt.length;we<Ke;we++)ge=nt[we],L.format!==io?Be!==null?xe?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,we,0,0,0,ge.width,ge.height,ae.depth,Be,ge.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,we,ot,ge.width,ge.height,ae.depth,0,ge.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,ge.width,ge.height,ae.depth,Be,Ye,ge.data):n.texImage3D(t.TEXTURE_2D_ARRAY,we,ot,ge.width,ge.height,ae.depth,0,Be,Ye,ge.data)}else{xe&&ze&&n.texStorage2D(t.TEXTURE_2D,Re,ot,nt[0].width,nt[0].height);for(let we=0,Ke=nt.length;we<Ke;we++)ge=nt[we],L.format!==io?Be!==null?xe?n.compressedTexSubImage2D(t.TEXTURE_2D,we,0,0,ge.width,ge.height,Be,ge.data):n.compressedTexImage2D(t.TEXTURE_2D,we,ot,ge.width,ge.height,0,ge.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):xe?n.texSubImage2D(t.TEXTURE_2D,we,0,0,ge.width,ge.height,Be,Ye,ge.data):n.texImage2D(t.TEXTURE_2D,we,ot,ge.width,ge.height,0,Be,Ye,ge.data)}else if(L.isDataArrayTexture)xe?(ze&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Re,ot,ae.width,ae.height,ae.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ae.width,ae.height,ae.depth,Be,Ye,ae.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ot,ae.width,ae.height,ae.depth,0,Be,Ye,ae.data);else if(L.isData3DTexture)xe?(ze&&n.texStorage3D(t.TEXTURE_3D,Re,ot,ae.width,ae.height,ae.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ae.width,ae.height,ae.depth,Be,Ye,ae.data)):n.texImage3D(t.TEXTURE_3D,0,ot,ae.width,ae.height,ae.depth,0,Be,Ye,ae.data);else if(L.isFramebufferTexture){if(ze)if(xe)n.texStorage2D(t.TEXTURE_2D,Re,ot,ae.width,ae.height);else{let we=ae.width,Ke=ae.height;for(let ft=0;ft<Re;ft++)n.texImage2D(t.TEXTURE_2D,ft,ot,we,Ke,0,Be,Ye,null),we>>=1,Ke>>=1}}else if(nt.length>0&&He){xe&&ze&&n.texStorage2D(t.TEXTURE_2D,Re,ot,nt[0].width,nt[0].height);for(let we=0,Ke=nt.length;we<Ke;we++)ge=nt[we],xe?n.texSubImage2D(t.TEXTURE_2D,we,0,0,Be,Ye,ge):n.texImage2D(t.TEXTURE_2D,we,ot,Be,Ye,ge);L.generateMipmaps=!1}else xe?(ze&&n.texStorage2D(t.TEXTURE_2D,Re,ot,ae.width,ae.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Be,Ye,ae)):n.texImage2D(t.TEXTURE_2D,0,ot,Be,Ye,ae);C(L,He)&&N(ye),qe.__version=be.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function ue(U,L,te){if(L.image.length!==6)return;const ye=Ee(U,L),Me=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+te);const be=r.get(Me);if(Me.version!==be.__version||ye===!0){n.activeTexture(t.TEXTURE0+te);const qe=or.getPrimaries(or.workingColorSpace),Ve=L.colorSpace===ao?null:or.getPrimaries(L.colorSpace),We=L.colorSpace===ao||qe===Ve?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,We);const lt=L.isCompressedTexture||L.image[0].isCompressedTexture,me=L.image[0]&&L.image[0].isDataTexture,ae=[];for(let we=0;we<6;we++)!lt&&!me?ae[we]=w(L.image[we],!1,!0,u):ae[we]=me?L.image[we].image:L.image[we],ae[we]=Se(L,ae[we]);const He=ae[0],Be=A(He)||l,Ye=a.convert(L.format,L.colorSpace),ot=a.convert(L.type),ge=O(L.internalFormat,Ye,ot,L.colorSpace),nt=l&&L.isVideoTexture!==!0,xe=be.__version===void 0||ye===!0;let ze=k(L,He,Be);Q(t.TEXTURE_CUBE_MAP,L,Be);let Re;if(lt){nt&&xe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,ze,ge,He.width,He.height);for(let we=0;we<6;we++){Re=ae[we].mipmaps;for(let Ke=0;Ke<Re.length;Ke++){const ft=Re[Ke];L.format!==io?Ye!==null?nt?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke,0,0,ft.width,ft.height,Ye,ft.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke,ge,ft.width,ft.height,0,ft.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke,0,0,ft.width,ft.height,Ye,ot,ft.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke,ge,ft.width,ft.height,0,Ye,ot,ft.data)}}}else{Re=L.mipmaps,nt&&xe&&(Re.length>0&&ze++,n.texStorage2D(t.TEXTURE_CUBE_MAP,ze,ge,ae[0].width,ae[0].height));for(let we=0;we<6;we++)if(me){nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,ae[we].width,ae[we].height,Ye,ot,ae[we].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,ge,ae[we].width,ae[we].height,0,Ye,ot,ae[we].data);for(let Ke=0;Ke<Re.length;Ke++){const Et=Re[Ke].image[we].image;nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke+1,0,0,Et.width,Et.height,Ye,ot,Et.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke+1,ge,Et.width,Et.height,0,Ye,ot,Et.data)}}else{nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,0,0,Ye,ot,ae[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,0,ge,Ye,ot,ae[we]);for(let Ke=0;Ke<Re.length;Ke++){const ft=Re[Ke];nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke+1,0,0,Ye,ot,ft.image[we]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+we,Ke+1,ge,Ye,ot,ft.image[we])}}}C(L,Be)&&N(t.TEXTURE_CUBE_MAP),be.__version=Me.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function Ae(U,L,te,ye,Me,be){const qe=a.convert(te.format,te.colorSpace),Ve=a.convert(te.type),We=O(te.internalFormat,qe,Ve,te.colorSpace);if(!r.get(L).__hasExternalTextures){const me=Math.max(1,L.width>>be),ae=Math.max(1,L.height>>be);Me===t.TEXTURE_3D||Me===t.TEXTURE_2D_ARRAY?n.texImage3D(Me,be,We,me,ae,L.depth,0,qe,Ve,null):n.texImage2D(Me,be,We,me,ae,0,qe,Ve,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),ve(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ye,Me,r.get(te).__webglTexture,0,se(L)):(Me===t.TEXTURE_2D||Me>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Me<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ye,Me,r.get(te).__webglTexture,be),n.bindFramebuffer(t.FRAMEBUFFER,null)}function fe(U,L,te){if(t.bindRenderbuffer(t.RENDERBUFFER,U),L.depthBuffer&&!L.stencilBuffer){let ye=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(te||ve(L)){const Me=L.depthTexture;Me&&Me.isDepthTexture&&(Me.type===Cc?ye=t.DEPTH_COMPONENT32F:Me.type===rd&&(ye=t.DEPTH_COMPONENT24));const be=se(L);ve(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,be,ye,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,be,ye,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,ye,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,U)}else if(L.depthBuffer&&L.stencilBuffer){const ye=se(L);te&&ve(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ye,t.DEPTH24_STENCIL8,L.width,L.height):ve(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ye,t.DEPTH24_STENCIL8,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,U)}else{const ye=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let Me=0;Me<ye.length;Me++){const be=ye[Me],qe=a.convert(be.format,be.colorSpace),Ve=a.convert(be.type),We=O(be.internalFormat,qe,Ve,be.colorSpace),lt=se(L);te&&ve(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,lt,We,L.width,L.height):ve(L)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,lt,We,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,We,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function at(U,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),Z(L.depthTexture,0);const ye=r.get(L.depthTexture).__webglTexture,Me=se(L);if(L.depthTexture.format===Vh)ve(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0,Me):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0);else if(L.depthTexture.format===Gp)ve(L)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0,Me):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0);else throw new Error("Unknown depthTexture format")}function B(U){const L=r.get(U),te=U.isWebGLCubeRenderTarget===!0;if(U.depthTexture&&!L.__autoAllocateDepthBuffer){if(te)throw new Error("target.depthTexture not supported in Cube render targets");at(L.__webglFramebuffer,U)}else if(te){L.__webglDepthbuffer=[];for(let ye=0;ye<6;ye++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[ye]),L.__webglDepthbuffer[ye]=t.createRenderbuffer(),fe(L.__webglDepthbuffer[ye],U,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),fe(L.__webglDepthbuffer,U,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function $(U,L,te){const ye=r.get(U);L!==void 0&&Ae(ye.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),te!==void 0&&B(U)}function ie(U){const L=U.texture,te=r.get(U),ye=r.get(L);U.addEventListener("dispose",I),U.isWebGLMultipleRenderTargets!==!0&&(ye.__webglTexture===void 0&&(ye.__webglTexture=t.createTexture()),ye.__version=L.version,s.memory.textures++);const Me=U.isWebGLCubeRenderTarget===!0,be=U.isWebGLMultipleRenderTargets===!0,qe=A(U)||l;if(Me){te.__webglFramebuffer=[];for(let Ve=0;Ve<6;Ve++)if(l&&L.mipmaps&&L.mipmaps.length>0){te.__webglFramebuffer[Ve]=[];for(let We=0;We<L.mipmaps.length;We++)te.__webglFramebuffer[Ve][We]=t.createFramebuffer()}else te.__webglFramebuffer[Ve]=t.createFramebuffer()}else{if(l&&L.mipmaps&&L.mipmaps.length>0){te.__webglFramebuffer=[];for(let Ve=0;Ve<L.mipmaps.length;Ve++)te.__webglFramebuffer[Ve]=t.createFramebuffer()}else te.__webglFramebuffer=t.createFramebuffer();if(be)if(i.drawBuffers){const Ve=U.texture;for(let We=0,lt=Ve.length;We<lt;We++){const me=r.get(Ve[We]);me.__webglTexture===void 0&&(me.__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&&U.samples>0&&ve(U)===!1){const Ve=be?L:[L];te.__webglMultisampledFramebuffer=t.createFramebuffer(),te.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,te.__webglMultisampledFramebuffer);for(let We=0;We<Ve.length;We++){const lt=Ve[We];te.__webglColorRenderbuffer[We]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,te.__webglColorRenderbuffer[We]);const me=a.convert(lt.format,lt.colorSpace),ae=a.convert(lt.type),He=O(lt.internalFormat,me,ae,lt.colorSpace,U.isXRRenderTarget===!0),Be=se(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,Be,He,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+We,t.RENDERBUFFER,te.__webglColorRenderbuffer[We])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(te.__webglDepthRenderbuffer=t.createRenderbuffer(),fe(te.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(Me){n.bindTexture(t.TEXTURE_CUBE_MAP,ye.__webglTexture),Q(t.TEXTURE_CUBE_MAP,L,qe);for(let Ve=0;Ve<6;Ve++)if(l&&L.mipmaps&&L.mipmaps.length>0)for(let We=0;We<L.mipmaps.length;We++)Ae(te.__webglFramebuffer[Ve][We],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,We);else Ae(te.__webglFramebuffer[Ve],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0);C(L,qe)&&N(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(be){const Ve=U.texture;for(let We=0,lt=Ve.length;We<lt;We++){const me=Ve[We],ae=r.get(me);n.bindTexture(t.TEXTURE_2D,ae.__webglTexture),Q(t.TEXTURE_2D,me,qe),Ae(te.__webglFramebuffer,U,me,t.COLOR_ATTACHMENT0+We,t.TEXTURE_2D,0),C(me,qe)&&N(t.TEXTURE_2D)}n.unbindTexture()}else{let Ve=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(l?Ve=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ve,ye.__webglTexture),Q(Ve,L,qe),l&&L.mipmaps&&L.mipmaps.length>0)for(let We=0;We<L.mipmaps.length;We++)Ae(te.__webglFramebuffer[We],U,L,t.COLOR_ATTACHMENT0,Ve,We);else Ae(te.__webglFramebuffer,U,L,t.COLOR_ATTACHMENT0,Ve,0);C(L,qe)&&N(Ve),n.unbindTexture()}U.depthBuffer&&B(U)}function H(U){const L=A(U)||l,te=U.isWebGLMultipleRenderTargets===!0?U.texture:[U.texture];for(let ye=0,Me=te.length;ye<Me;ye++){const be=te[ye];if(C(be,L)){const qe=U.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ve=r.get(be).__webglTexture;n.bindTexture(qe,Ve),N(qe),n.unbindTexture()}}}function Y(U){if(l&&U.samples>0&&ve(U)===!1){const L=U.isWebGLMultipleRenderTargets?U.texture:[U.texture],te=U.width,ye=U.height;let Me=t.COLOR_BUFFER_BIT;const be=[],qe=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ve=r.get(U),We=U.isWebGLMultipleRenderTargets===!0;if(We)for(let lt=0;lt<L.length;lt++)n.bindFramebuffer(t.FRAMEBUFFER,Ve.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ve.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ve.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ve.__webglFramebuffer);for(let lt=0;lt<L.length;lt++){be.push(t.COLOR_ATTACHMENT0+lt),U.depthBuffer&&be.push(qe);const me=Ve.__ignoreDepthValues!==void 0?Ve.__ignoreDepthValues:!1;if(me===!1&&(U.depthBuffer&&(Me|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&(Me|=t.STENCIL_BUFFER_BIT)),We&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ve.__webglColorRenderbuffer[lt]),me===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[qe]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[qe])),We){const ae=r.get(L[lt]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ae,0)}t.blitFramebuffer(0,0,te,ye,0,0,te,ye,Me,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,be)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),We)for(let lt=0;lt<L.length;lt++){n.bindFramebuffer(t.FRAMEBUFFER,Ve.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.RENDERBUFFER,Ve.__webglColorRenderbuffer[lt]);const me=r.get(L[lt]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ve.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+lt,t.TEXTURE_2D,me,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ve.__webglMultisampledFramebuffer)}}function se(U){return Math.min(f,U.samples)}function ve(U){const L=r.get(U);return l&&U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ne(U){const L=s.render.frame;b.get(U)!==L&&(b.set(U,L),U.update())}function Se(U,L){const te=U.colorSpace,ye=U.format,Me=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||U.format===aj||te!==Zc&&te!==ao&&(or.getTransfer(te)===Sr?l===!1?e.has("EXT_sRGB")===!0&&ye===io?(U.format=aj,U.minFilter=ro,U.generateMipmaps=!1):L=yQ.sRGBToLinear(L):(ye!==io||Me!==fd)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",te)),L}this.allocateTextureUnit=J,this.resetTextureUnits=G,this.setTexture2D=Z,this.setTexture2DArray=F,this.setTexture3D=V,this.setTextureCube=ne,this.rebindTextures=$,this.setupRenderTarget=ie,this.updateRenderTargetMipmap=H,this.updateMultisampleRenderTarget=Y,this.setupDepthRenderbuffer=B,this.setupFrameBufferTexture=Ae,this.useMultisampledRTT=ve}function bUe(t,e,n){const r=n.isWebGL2;function i(a,s=ao){let l;const c=or.getTransfer(s);if(a===fd)return t.UNSIGNED_BYTE;if(a===lQ)return t.UNSIGNED_SHORT_4_4_4_4;if(a===cQ)return t.UNSIGNED_SHORT_5_5_5_1;if(a===HOe)return t.BYTE;if(a===$Oe)return t.SHORT;if(a===$O)return t.UNSIGNED_SHORT;if(a===oQ)return t.INT;if(a===rd)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===VOe)return t.ALPHA;if(a===io)return t.RGBA;if(a===GOe)return t.LUMINANCE;if(a===WOe)return t.LUMINANCE_ALPHA;if(a===Vh)return t.DEPTH_COMPONENT;if(a===Gp)return t.DEPTH_STENCIL;if(a===aj)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===qOe)return t.RED;if(a===uQ)return t.RED_INTEGER;if(a===KOe)return t.RG;if(a===dQ)return t.RG_INTEGER;if(a===hQ)return t.RGBA_INTEGER;if(a===pC||a===gC||a===xC||a===bC)if(c===Sr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===pC)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===gC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===xC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===bC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===pC)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===gC)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===xC)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===bC)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===j$||a===R$||a===D$||a===O$)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===j$)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===R$)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===D$)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===O$)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===fQ)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===L$||a===I$)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===L$)return c===Sr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===I$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===F$||a===U$||a===z$||a===B$||a===H$||a===$$||a===V$||a===G$||a===W$||a===q$||a===K$||a===X$||a===Y$||a===Z$)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===F$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===U$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===z$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===B$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===H$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===$$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===V$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===G$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===W$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===q$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===K$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===X$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===Y$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===Z$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===yC||a===Q$||a===J$)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===yC)return c===Sr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===Q$)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===J$)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===XOe||a===eV||a===tV||a===nV)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===yC)return l.COMPRESSED_RED_RGTC1_EXT;if(a===eV)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===tV)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===nV)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===$h?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 yUe extends Ss{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Qx extends La{constructor(){super(),this.isGroup=!0,this.type="Group"}}const vUe={type:"move"};class HC{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 Le,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Le),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 Le,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Le),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 x=n.getJointPose(v,r),y=this._getHandJoint(u,v);x!==null&&(y.matrix.fromArray(x.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=x.radius),y.visible=x!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),p=.02,b=.005;u.inputState.pinching&&g>p+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=p-b&&(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(vUe)))}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 _Ue 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,b=null;const v=n.getContextAttributes();let x=null,y=null;const E=[],w=[],A=new rn;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 yUe;k.layers.enable(1),k.layers.enable(2);let j=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ne){let le=E[ne];return le===void 0&&(le=new HC,E[ne]=le),le.getTargetRaySpace()},this.getControllerGrip=function(ne){let le=E[ne];return le===void 0&&(le=new HC,E[ne]=le),le.getGripSpace()},this.getHand=function(ne){let le=E[ne];return le===void 0&&(le=new HC,E[ne]=le),le.getHandSpace()};function I(ne){const le=w.indexOf(ne.inputSource);if(le===-1)return;const oe=E[le];oe!==void 0&&(oe.update(ne.inputSource,ne.frame,u||s),oe.dispatchEvent({type:ne.type,data:ne.inputSource}))}function q(){i.removeEventListener("select",I),i.removeEventListener("selectstart",I),i.removeEventListener("selectend",I),i.removeEventListener("squeeze",I),i.removeEventListener("squeezestart",I),i.removeEventListener("squeezeend",I),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",R);for(let ne=0;ne<E.length;ne++){const le=w[ne];le!==null&&(w[ne]=null,E[ne].disconnect(le))}j=null,z=null,e.setRenderTarget(x),p=null,g=null,f=null,i=null,y=null,V.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ne){a=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ne){l=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||s},this.setReferenceSpace=function(ne){u=ne},this.getBaseLayer=function(){return g!==null?g:p},this.getBinding=function(){return f},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(ne){if(i=ne,i!==null){if(x=e.getRenderTarget(),i.addEventListener("select",I),i.addEventListener("selectstart",I),i.addEventListener("selectend",I),i.addEventListener("squeeze",I),i.addEventListener("squeezestart",I),i.addEventListener("squeezeend",I),i.addEventListener("end",q),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 le={antialias:i.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,le),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),y=new bf(p.framebufferWidth,p.framebufferHeight,{format:io,type:fd,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let le=null,oe=null,pe=null;v.depth&&(pe=v.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,le=v.stencil?Gp:Vh,oe=v.stencil?$h:rd);const Q={colorFormat:n.RGBA8,depthFormat:pe,scaleFactor:a};f=new XRWebGLBinding(i,n),g=f.createProjectionLayer(Q),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),y=new bf(g.textureWidth,g.textureHeight,{format:io,type:fd,depthTexture:new PQ(g.textureWidth,g.textureHeight,oe,void 0,void 0,void 0,void 0,void 0,void 0,le),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const Ee=e.properties.get(y);Ee.__ignoreDepthValues=g.ignoreDepthValues}y.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(ne){for(let le=0;le<ne.removed.length;le++){const oe=ne.removed[le],pe=w.indexOf(oe);pe>=0&&(w[pe]=null,E[pe].disconnect(oe))}for(let le=0;le<ne.added.length;le++){const oe=ne.added[le];let pe=w.indexOf(oe);if(pe===-1){for(let Ee=0;Ee<E.length;Ee++)if(Ee>=w.length){w.push(oe),pe=Ee;break}else if(w[Ee]===null){w[Ee]=oe,pe=Ee;break}if(pe===-1)break}const Q=E[pe];Q&&Q.connect(oe)}}const W=new Le,K=new Le;function G(ne,le,oe){W.setFromMatrixPosition(le.matrixWorld),K.setFromMatrixPosition(oe.matrixWorld);const pe=W.distanceTo(K),Q=le.projectionMatrix.elements,Ee=oe.projectionMatrix.elements,he=Q[14]/(Q[10]-1),ue=Q[14]/(Q[10]+1),Ae=(Q[9]+1)/Q[5],fe=(Q[9]-1)/Q[5],at=(Q[8]-1)/Q[0],B=(Ee[8]+1)/Ee[0],$=he*at,ie=he*B,H=pe/(-at+B),Y=H*-at;le.matrixWorld.decompose(ne.position,ne.quaternion,ne.scale),ne.translateX(Y),ne.translateZ(H),ne.matrixWorld.compose(ne.position,ne.quaternion,ne.scale),ne.matrixWorldInverse.copy(ne.matrixWorld).invert();const se=he+H,ve=ue+H,Ne=$-Y,Se=ie+(pe-Y),U=Ae*ue/ve*se,L=fe*ue/ve*se;ne.projectionMatrix.makePerspective(Ne,Se,U,L,se,ve),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert()}function J(ne,le){le===null?ne.matrixWorld.copy(ne.matrix):ne.matrixWorld.multiplyMatrices(le.matrixWorld,ne.matrix),ne.matrixWorldInverse.copy(ne.matrixWorld).invert()}this.updateCamera=function(ne){if(i===null)return;k.near=N.near=C.near=ne.near,k.far=N.far=C.far=ne.far,(j!==k.near||z!==k.far)&&(i.updateRenderState({depthNear:k.near,depthFar:k.far}),j=k.near,z=k.far);const le=ne.parent,oe=k.cameras;J(k,le);for(let pe=0;pe<oe.length;pe++)J(oe[pe],le);oe.length===2?G(k,C,N):k.projectionMatrix.copy(C.projectionMatrix),ee(ne,k,le)};function ee(ne,le,oe){oe===null?ne.matrix.copy(le.matrixWorld):(ne.matrix.copy(oe.matrixWorld),ne.matrix.invert(),ne.matrix.multiply(le.matrixWorld)),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.updateMatrixWorld(!0),ne.projectionMatrix.copy(le.projectionMatrix),ne.projectionMatrixInverse.copy(le.projectionMatrixInverse),ne.isPerspectiveCamera&&(ne.fov=ob*2*Math.atan(1/ne.projectionMatrix.elements[5]),ne.zoom=1)}this.getCamera=function(){return k},this.getFoveation=function(){if(!(g===null&&p===null))return c},this.setFoveation=function(ne){c=ne,g!==null&&(g.fixedFoveation=ne),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ne)};let Z=null;function F(ne,le){if(d=le.getViewerPose(u||s),b=le,d!==null){const oe=d.views;p!==null&&(e.setRenderTargetFramebuffer(y,p.framebuffer),e.setRenderTarget(y));let pe=!1;oe.length!==k.cameras.length&&(k.cameras.length=0,pe=!0);for(let Q=0;Q<oe.length;Q++){const Ee=oe[Q];let he=null;if(p!==null)he=p.getViewport(Ee);else{const Ae=f.getViewSubImage(g,Ee);he=Ae.viewport,Q===0&&(e.setRenderTargetTextures(y,Ae.colorTexture,g.ignoreDepthValues?void 0:Ae.depthStencilTexture),e.setRenderTarget(y))}let ue=O[Q];ue===void 0&&(ue=new Ss,ue.layers.enable(Q),ue.viewport=new cr,O[Q]=ue),ue.matrix.fromArray(Ee.transform.matrix),ue.matrix.decompose(ue.position,ue.quaternion,ue.scale),ue.projectionMatrix.fromArray(Ee.projectionMatrix),ue.projectionMatrixInverse.copy(ue.projectionMatrix).invert(),ue.viewport.set(he.x,he.y,he.width,he.height),Q===0&&(k.matrix.copy(ue.matrix),k.matrix.decompose(k.position,k.quaternion,k.scale)),pe===!0&&k.cameras.push(ue)}}for(let oe=0;oe<E.length;oe++){const pe=w[oe],Q=E[oe];pe!==null&&Q!==void 0&&Q.update(pe,le,u||s)}Z&&Z(ne,le),le.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:le}),b=null}const V=new kQ;V.setAnimationLoop(F),this.setAnimationLoop=function(ne){Z=ne},this.dispose=function(){}}}function wUe(t,e){function n(x,y){x.matrixAutoUpdate===!0&&x.updateMatrix(),y.value.copy(x.matrix)}function r(x,y){y.color.getRGB(x.fogColor.value,TQ(t)),y.isFog?(x.fogNear.value=y.near,x.fogFar.value=y.far):y.isFogExp2&&(x.fogDensity.value=y.density)}function i(x,y,E,w,A){y.isMeshBasicMaterial||y.isMeshLambertMaterial?a(x,y):y.isMeshToonMaterial?(a(x,y),f(x,y)):y.isMeshPhongMaterial?(a(x,y),d(x,y)):y.isMeshStandardMaterial?(a(x,y),g(x,y),y.isMeshPhysicalMaterial&&p(x,y,A)):y.isMeshMatcapMaterial?(a(x,y),b(x,y)):y.isMeshDepthMaterial?a(x,y):y.isMeshDistanceMaterial?(a(x,y),v(x,y)):y.isMeshNormalMaterial?a(x,y):y.isLineBasicMaterial?(s(x,y),y.isLineDashedMaterial&&l(x,y)):y.isPointsMaterial?c(x,y,E,w):y.isSpriteMaterial?u(x,y):y.isShadowMaterial?(x.color.value.copy(y.color),x.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function a(x,y){x.opacity.value=y.opacity,y.color&&x.diffuse.value.copy(y.color),y.emissive&&x.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(x.map.value=y.map,n(y.map,x.mapTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.bumpMap&&(x.bumpMap.value=y.bumpMap,n(y.bumpMap,x.bumpMapTransform),x.bumpScale.value=y.bumpScale,y.side===rs&&(x.bumpScale.value*=-1)),y.normalMap&&(x.normalMap.value=y.normalMap,n(y.normalMap,x.normalMapTransform),x.normalScale.value.copy(y.normalScale),y.side===rs&&x.normalScale.value.negate()),y.displacementMap&&(x.displacementMap.value=y.displacementMap,n(y.displacementMap,x.displacementMapTransform),x.displacementScale.value=y.displacementScale,x.displacementBias.value=y.displacementBias),y.emissiveMap&&(x.emissiveMap.value=y.emissiveMap,n(y.emissiveMap,x.emissiveMapTransform)),y.specularMap&&(x.specularMap.value=y.specularMap,n(y.specularMap,x.specularMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest);const E=e.get(y).envMap;if(E&&(x.envMap.value=E,x.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=y.reflectivity,x.ior.value=y.ior,x.refractionRatio.value=y.refractionRatio),y.lightMap){x.lightMap.value=y.lightMap;const w=t._useLegacyLights===!0?Math.PI:1;x.lightMapIntensity.value=y.lightMapIntensity*w,n(y.lightMap,x.lightMapTransform)}y.aoMap&&(x.aoMap.value=y.aoMap,x.aoMapIntensity.value=y.aoMapIntensity,n(y.aoMap,x.aoMapTransform))}function s(x,y){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,y.map&&(x.map.value=y.map,n(y.map,x.mapTransform))}function l(x,y){x.dashSize.value=y.dashSize,x.totalSize.value=y.dashSize+y.gapSize,x.scale.value=y.scale}function c(x,y,E,w){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,x.size.value=y.size*E,x.scale.value=w*.5,y.map&&(x.map.value=y.map,n(y.map,x.uvTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest)}function u(x,y){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,x.rotation.value=y.rotation,y.map&&(x.map.value=y.map,n(y.map,x.mapTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest)}function d(x,y){x.specular.value.copy(y.specular),x.shininess.value=Math.max(y.shininess,1e-4)}function f(x,y){y.gradientMap&&(x.gradientMap.value=y.gradientMap)}function g(x,y){x.metalness.value=y.metalness,y.metalnessMap&&(x.metalnessMap.value=y.metalnessMap,n(y.metalnessMap,x.metalnessMapTransform)),x.roughness.value=y.roughness,y.roughnessMap&&(x.roughnessMap.value=y.roughnessMap,n(y.roughnessMap,x.roughnessMapTransform)),e.get(y).envMap&&(x.envMapIntensity.value=y.envMapIntensity)}function p(x,y,E){x.ior.value=y.ior,y.sheen>0&&(x.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),x.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(x.sheenColorMap.value=y.sheenColorMap,n(y.sheenColorMap,x.sheenColorMapTransform)),y.sheenRoughnessMap&&(x.sheenRoughnessMap.value=y.sheenRoughnessMap,n(y.sheenRoughnessMap,x.sheenRoughnessMapTransform))),y.clearcoat>0&&(x.clearcoat.value=y.clearcoat,x.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(x.clearcoatMap.value=y.clearcoatMap,n(y.clearcoatMap,x.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,n(y.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(x.clearcoatNormalMap.value=y.clearcoatNormalMap,n(y.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===rs&&x.clearcoatNormalScale.value.negate())),y.iridescence>0&&(x.iridescence.value=y.iridescence,x.iridescenceIOR.value=y.iridescenceIOR,x.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(x.iridescenceMap.value=y.iridescenceMap,n(y.iridescenceMap,x.iridescenceMapTransform)),y.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=y.iridescenceThicknessMap,n(y.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),y.transmission>0&&(x.transmission.value=y.transmission,x.transmissionSamplerMap.value=E.texture,x.transmissionSamplerSize.value.set(E.width,E.height),y.transmissionMap&&(x.transmissionMap.value=y.transmissionMap,n(y.transmissionMap,x.transmissionMapTransform)),x.thickness.value=y.thickness,y.thicknessMap&&(x.thicknessMap.value=y.thicknessMap,n(y.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=y.attenuationDistance,x.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(x.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(x.anisotropyMap.value=y.anisotropyMap,n(y.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=y.specularIntensity,x.specularColor.value.copy(y.specularColor),y.specularColorMap&&(x.specularColorMap.value=y.specularColorMap,n(y.specularColorMap,x.specularColorMapTransform)),y.specularIntensityMap&&(x.specularIntensityMap.value=y.specularIntensityMap,n(y.specularIntensityMap,x.specularIntensityMapTransform))}function b(x,y){y.matcap&&(x.matcap.value=y.matcap)}function v(x,y){const E=e.get(y).light;x.referencePosition.value.setFromMatrixPosition(E.matrixWorld),x.nearDistance.value=E.shadow.camera.near,x.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function SUe(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&&(b(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",x));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 z=0;for(let I=0;I<j.length;I++){const q=j[I],R=v(q);typeof q=="number"?(O.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,k+z,O.__data)):q.isMatrix3?(O.__data[0]=q.elements[0],O.__data[1]=q.elements[1],O.__data[2]=q.elements[2],O.__data[3]=q.elements[0],O.__data[4]=q.elements[3],O.__data[5]=q.elements[4],O.__data[6]=q.elements[5],O.__data[7]=q.elements[0],O.__data[8]=q.elements[6],O.__data[9]=q.elements[7],O.__data[10]=q.elements[8],O.__data[11]=q.elements[0]):(q.toArray(O.__data,z),z+=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 b(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},z=Array.isArray(k.value)?k.value:[k.value];for(let I=0,q=z.length;I<q;I++){const R=z[I],W=v(R);j.boundary+=W.boundary,j.storage+=W.storage}if(k.__data=new Float32Array(j.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=A,N>0){C=A%T;const I=T-C;C!==0&&I-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 x(E){const w=E.target;w.removeEventListener("dispose",x);const A=s.indexOf(w.__bindingPointIndex);s.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function y(){for(const E in i)t.deleteBuffer(i[E]);s=[],i={},a={}}return{bind:c,update:u,dispose:y}}class lj{constructor(e={}){const{canvas:n=vLe(),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),b=new Int32Array(4);let v=null,x=null;const y=[],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=sa,this._useLegacyLights=!1,this.toneMapping=hd,this.toneMappingExposure=1;const w=this;let A=!1,T=0,C=0,N=null,O=-1,k=null;const j=new cr,z=new cr;let I=null;const q=new Kt(0);let R=0,W=n.width,K=n.height,G=1,J=null,ee=null;const Z=new cr(0,0,W,K),F=new cr(0,0,W,K);let V=!1;const ne=new lE;let le=!1,oe=!1,pe=null;const Q=new yr,Ee=new rn,he=new Le,ue={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ae(){return N===null?G:1}let fe=r;function at(ce,Ue){for(let Xe=0;Xe<ce.length;Xe++){const rt=ce[Xe],et=n.getContext(rt,Ue);if(et!==null)return et}return null}try{const ce={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${aE}`),n.addEventListener("webglcontextlost",nt,!1),n.addEventListener("webglcontextrestored",xe,!1),n.addEventListener("webglcontextcreationerror",ze,!1),fe===null){const Ue=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&Ue.shift(),fe=at(Ue,ce),fe===null)throw at(Ue)?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(ce){throw console.error("THREE.WebGLRenderer: "+ce.message),ce}let B,$,ie,H,Y,se,ve,Ne,Se,U,L,te,ye,Me,be,qe,Ve,We,lt,me,ae,He,Be,Ye;function ot(){B=new D5e(fe),$=new T5e(fe,B,e),B.init($),He=new bUe(fe,B,$),ie=new gUe(fe,B,$),H=new I5e(fe),Y=new nUe,se=new xUe(fe,B,ie,Y,$,He,H),ve=new C5e(w),Ne=new R5e(w),Se=new VLe(fe,$),Be=new E5e(fe,B,Se,$),U=new O5e(fe,Se,H,Be),L=new B5e(fe,U,Se,H),lt=new z5e(fe,$,se),qe=new N5e(Y),te=new tUe(w,ve,Ne,B,$,Be,qe),ye=new wUe(w,Y),Me=new iUe,be=new uUe(B,$),We=new M5e(w,ve,Ne,ie,L,g,c),Ve=new pUe(w,L,$),Ye=new SUe(fe,H,$,ie),me=new A5e(fe,B,H,$),ae=new L5e(fe,B,H,$),H.programs=te.programs,w.capabilities=$,w.extensions=B,w.properties=Y,w.renderLists=Me,w.shadowMap=Ve,w.state=ie,w.info=H}ot();const ge=new _Ue(w,fe);this.xr=ge,this.getContext=function(){return fe},this.getContextAttributes=function(){return fe.getContextAttributes()},this.forceContextLoss=function(){const ce=B.get("WEBGL_lose_context");ce&&ce.loseContext()},this.forceContextRestore=function(){const ce=B.get("WEBGL_lose_context");ce&&ce.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(ce){ce!==void 0&&(G=ce,this.setSize(W,K,!1))},this.getSize=function(ce){return ce.set(W,K)},this.setSize=function(ce,Ue,Xe=!0){if(ge.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=ce,K=Ue,n.width=Math.floor(ce*G),n.height=Math.floor(Ue*G),Xe===!0&&(n.style.width=ce+"px",n.style.height=Ue+"px"),this.setViewport(0,0,ce,Ue)},this.getDrawingBufferSize=function(ce){return ce.set(W*G,K*G).floor()},this.setDrawingBufferSize=function(ce,Ue,Xe){W=ce,K=Ue,G=Xe,n.width=Math.floor(ce*Xe),n.height=Math.floor(Ue*Xe),this.setViewport(0,0,ce,Ue)},this.getCurrentViewport=function(ce){return ce.copy(j)},this.getViewport=function(ce){return ce.copy(Z)},this.setViewport=function(ce,Ue,Xe,rt){ce.isVector4?Z.set(ce.x,ce.y,ce.z,ce.w):Z.set(ce,Ue,Xe,rt),ie.viewport(j.copy(Z).multiplyScalar(G).floor())},this.getScissor=function(ce){return ce.copy(F)},this.setScissor=function(ce,Ue,Xe,rt){ce.isVector4?F.set(ce.x,ce.y,ce.z,ce.w):F.set(ce,Ue,Xe,rt),ie.scissor(z.copy(F).multiplyScalar(G).floor())},this.getScissorTest=function(){return V},this.setScissorTest=function(ce){ie.setScissorTest(V=ce)},this.setOpaqueSort=function(ce){J=ce},this.setTransparentSort=function(ce){ee=ce},this.getClearColor=function(ce){return ce.copy(We.getClearColor())},this.setClearColor=function(){We.setClearColor.apply(We,arguments)},this.getClearAlpha=function(){return We.getClearAlpha()},this.setClearAlpha=function(){We.setClearAlpha.apply(We,arguments)},this.clear=function(ce=!0,Ue=!0,Xe=!0){let rt=0;if(ce){let et=!1;if(N!==null){const gt=N.texture.format;et=gt===hQ||gt===dQ||gt===uQ}if(et){const gt=N.texture.type,re=gt===fd||gt===rd||gt===$O||gt===$h||gt===lQ||gt===cQ,Te=We.getClearColor(),Ie=We.getClearAlpha(),De=Te.r,je=Te.g,ct=Te.b;re?(p[0]=De,p[1]=je,p[2]=ct,p[3]=Ie,fe.clearBufferuiv(fe.COLOR,0,p)):(b[0]=De,b[1]=je,b[2]=ct,b[3]=Ie,fe.clearBufferiv(fe.COLOR,0,b))}else rt|=fe.COLOR_BUFFER_BIT}Ue&&(rt|=fe.DEPTH_BUFFER_BIT),Xe&&(rt|=fe.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),fe.clear(rt)},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",ze,!1),Me.dispose(),be.dispose(),Y.dispose(),ve.dispose(),Ne.dispose(),L.dispose(),Be.dispose(),Ye.dispose(),te.dispose(),ge.dispose(),ge.removeEventListener("sessionstart",Qt),ge.removeEventListener("sessionend",Ft),pe&&(pe.dispose(),pe=null),hn.stop()};function nt(ce){ce.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function xe(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const ce=H.autoReset,Ue=Ve.enabled,Xe=Ve.autoUpdate,rt=Ve.needsUpdate,et=Ve.type;ot(),H.autoReset=ce,Ve.enabled=Ue,Ve.autoUpdate=Xe,Ve.needsUpdate=rt,Ve.type=et}function ze(ce){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ce.statusMessage)}function Re(ce){const Ue=ce.target;Ue.removeEventListener("dispose",Re),we(Ue)}function we(ce){Ke(ce),Y.remove(ce)}function Ke(ce){const Ue=Y.get(ce).programs;Ue!==void 0&&(Ue.forEach(function(Xe){te.releaseProgram(Xe)}),ce.isShaderMaterial&&te.releaseShaderCache(ce))}this.renderBufferDirect=function(ce,Ue,Xe,rt,et,gt){Ue===null&&(Ue=ue);const re=et.isMesh&&et.matrixWorld.determinant()<0,Te=_n(ce,Ue,Xe,rt,et);ie.setMaterial(rt,re);let Ie=Xe.index,De=1;if(rt.wireframe===!0){if(Ie=U.getWireframeAttribute(Xe),Ie===void 0)return;De=2}const je=Xe.drawRange,ct=Xe.attributes.position;let yt=je.start*De,Ct=(je.start+je.count)*De;gt!==null&&(yt=Math.max(yt,gt.start*De),Ct=Math.min(Ct,(gt.start+gt.count)*De)),Ie!==null?(yt=Math.max(yt,0),Ct=Math.min(Ct,Ie.count)):ct!=null&&(yt=Math.max(yt,0),Ct=Math.min(Ct,ct.count));const Nt=Ct-yt;if(Nt<0||Nt===1/0)return;Be.setup(et,rt,Te,Xe,Ie);let Ut,jt=me;if(Ie!==null&&(Ut=Se.get(Ie),jt=ae,jt.setIndex(Ut)),et.isMesh)rt.wireframe===!0?(ie.setLineWidth(rt.wireframeLinewidth*Ae()),jt.setMode(fe.LINES)):jt.setMode(fe.TRIANGLES);else if(et.isLine){let St=rt.linewidth;St===void 0&&(St=1),ie.setLineWidth(St*Ae()),et.isLineSegments?jt.setMode(fe.LINES):et.isLineLoop?jt.setMode(fe.LINE_LOOP):jt.setMode(fe.LINE_STRIP)}else et.isPoints?jt.setMode(fe.POINTS):et.isSprite&&jt.setMode(fe.TRIANGLES);if(et.isBatchedMesh)jt.renderMultiDraw(et._multiDrawStarts,et._multiDrawCounts,et._multiDrawCount);else if(et.isInstancedMesh)jt.renderInstances(yt,Nt,et.count);else if(Xe.isInstancedBufferGeometry){const St=Xe._maxInstanceCount!==void 0?Xe._maxInstanceCount:1/0,tn=Math.min(Xe.instanceCount,St);jt.renderInstances(yt,Nt,tn)}else jt.render(yt,Nt)};function ft(ce,Ue,Xe){ce.transparent===!0&&ce.side===wc&&ce.forceSinglePass===!1?(ce.side=rs,ce.needsUpdate=!0,Zt(ce,Ue,Xe),ce.side=Cd,ce.needsUpdate=!0,Zt(ce,Ue,Xe),ce.side=wc):Zt(ce,Ue,Xe)}this.compile=function(ce,Ue,Xe=null){Xe===null&&(Xe=ce),x=be.get(Xe),x.init(),E.push(x),Xe.traverseVisible(function(et){et.isLight&&et.layers.test(Ue.layers)&&(x.pushLight(et),et.castShadow&&x.pushShadow(et))}),ce!==Xe&&ce.traverseVisible(function(et){et.isLight&&et.layers.test(Ue.layers)&&(x.pushLight(et),et.castShadow&&x.pushShadow(et))}),x.setupLights(w._useLegacyLights);const rt=new Set;return ce.traverse(function(et){const gt=et.material;if(gt)if(Array.isArray(gt))for(let re=0;re<gt.length;re++){const Te=gt[re];ft(Te,Xe,et),rt.add(Te)}else ft(gt,Xe,et),rt.add(gt)}),E.pop(),x=null,rt},this.compileAsync=function(ce,Ue,Xe=null){const rt=this.compile(ce,Ue,Xe);return new Promise(et=>{function gt(){if(rt.forEach(function(re){Y.get(re).currentProgram.isReady()&&rt.delete(re)}),rt.size===0){et(ce);return}setTimeout(gt,10)}B.get("KHR_parallel_shader_compile")!==null?gt():setTimeout(gt,10)})};let Et=null;function wt(ce){Et&&Et(ce)}function Qt(){hn.stop()}function Ft(){hn.start()}const hn=new kQ;hn.setAnimationLoop(wt),typeof self<"u"&&hn.setContext(self),this.setAnimationLoop=function(ce){Et=ce,ge.setAnimationLoop(ce),ce===null?hn.stop():hn.start()},ge.addEventListener("sessionstart",Qt),ge.addEventListener("sessionend",Ft),this.render=function(ce,Ue){if(Ue!==void 0&&Ue.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;ce.matrixWorldAutoUpdate===!0&&ce.updateMatrixWorld(),Ue.parent===null&&Ue.matrixWorldAutoUpdate===!0&&Ue.updateMatrixWorld(),ge.enabled===!0&&ge.isPresenting===!0&&(ge.cameraAutoUpdate===!0&&ge.updateCamera(Ue),Ue=ge.getCamera()),ce.isScene===!0&&ce.onBeforeRender(w,ce,Ue,N),x=be.get(ce,E.length),x.init(),E.push(x),Q.multiplyMatrices(Ue.projectionMatrix,Ue.matrixWorldInverse),ne.setFromProjectionMatrix(Q),oe=this.localClippingEnabled,le=qe.init(this.clippingPlanes,oe),v=Me.get(ce,y.length),v.init(),y.push(v),Hn(ce,Ue,0,w.sortObjects),v.finish(),w.sortObjects===!0&&v.sort(J,ee),this.info.render.frame++,le===!0&&qe.beginShadows();const Xe=x.state.shadowsArray;if(Ve.render(Xe,ce,Ue),le===!0&&qe.endShadows(),this.info.autoReset===!0&&this.info.reset(),We.render(v,ce),x.setupLights(w._useLegacyLights),Ue.isArrayCamera){const rt=Ue.cameras;for(let et=0,gt=rt.length;et<gt;et++){const re=rt[et];bt(v,ce,re,re.viewport)}}else bt(v,ce,Ue);N!==null&&(se.updateMultisampleRenderTarget(N),se.updateRenderTargetMipmap(N)),ce.isScene===!0&&ce.onAfterRender(w,ce,Ue),Be.resetDefaultState(),O=-1,k=null,E.pop(),E.length>0?x=E[E.length-1]:x=null,y.pop(),y.length>0?v=y[y.length-1]:v=null};function Hn(ce,Ue,Xe,rt){if(ce.visible===!1)return;if(ce.layers.test(Ue.layers)){if(ce.isGroup)Xe=ce.renderOrder;else if(ce.isLOD)ce.autoUpdate===!0&&ce.update(Ue);else if(ce.isLight)x.pushLight(ce),ce.castShadow&&x.pushShadow(ce);else if(ce.isSprite){if(!ce.frustumCulled||ne.intersectsSprite(ce)){rt&&he.setFromMatrixPosition(ce.matrixWorld).applyMatrix4(Q);const re=L.update(ce),Te=ce.material;Te.visible&&v.push(ce,re,Te,Xe,he.z,null)}}else if((ce.isMesh||ce.isLine||ce.isPoints)&&(!ce.frustumCulled||ne.intersectsObject(ce))){const re=L.update(ce),Te=ce.material;if(rt&&(ce.boundingSphere!==void 0?(ce.boundingSphere===null&&ce.computeBoundingSphere(),he.copy(ce.boundingSphere.center)):(re.boundingSphere===null&&re.computeBoundingSphere(),he.copy(re.boundingSphere.center)),he.applyMatrix4(ce.matrixWorld).applyMatrix4(Q)),Array.isArray(Te)){const Ie=re.groups;for(let De=0,je=Ie.length;De<je;De++){const ct=Ie[De],yt=Te[ct.materialIndex];yt&&yt.visible&&v.push(ce,re,yt,Xe,he.z,ct)}}else Te.visible&&v.push(ce,re,Te,Xe,he.z,null)}}const gt=ce.children;for(let re=0,Te=gt.length;re<Te;re++)Hn(gt[re],Ue,Xe,rt)}function bt(ce,Ue,Xe,rt){const et=ce.opaque,gt=ce.transmissive,re=ce.transparent;x.setupLightsView(Xe),le===!0&&qe.setGlobalState(w.clippingPlanes,Xe),gt.length>0&&Ht(et,gt,Ue,Xe),rt&&ie.viewport(j.copy(rt)),et.length>0&&an(et,Ue,Xe),gt.length>0&&an(gt,Ue,Xe),re.length>0&&an(re,Ue,Xe),ie.buffers.depth.setTest(!0),ie.buffers.depth.setMask(!0),ie.buffers.color.setMask(!0),ie.setPolygonOffset(!1)}function Ht(ce,Ue,Xe,rt){if((Xe.isScene===!0?Xe.overrideMaterial:null)!==null)return;const gt=$.isWebGL2;pe===null&&(pe=new bf(1,1,{generateMipmaps:!0,type:B.has("EXT_color_buffer_half_float")?ab:fd,minFilter:ib,samples:gt?4:0})),w.getDrawingBufferSize(Ee),gt?pe.setSize(Ee.x,Ee.y):pe.setSize(tS(Ee.x),tS(Ee.y));const re=w.getRenderTarget();w.setRenderTarget(pe),w.getClearColor(q),R=w.getClearAlpha(),R<1&&w.setClearColor(16777215,.5),w.clear();const Te=w.toneMapping;w.toneMapping=hd,an(ce,Xe,rt),se.updateMultisampleRenderTarget(pe),se.updateRenderTargetMipmap(pe);let Ie=!1;for(let De=0,je=Ue.length;De<je;De++){const ct=Ue[De],yt=ct.object,Ct=ct.geometry,Nt=ct.material,Ut=ct.group;if(Nt.side===wc&&yt.layers.test(rt.layers)){const jt=Nt.side;Nt.side=rs,Nt.needsUpdate=!0,mt(yt,Xe,rt,Ct,Nt,Ut),Nt.side=jt,Nt.needsUpdate=!0,Ie=!0}}Ie===!0&&(se.updateMultisampleRenderTarget(pe),se.updateRenderTargetMipmap(pe)),w.setRenderTarget(re),w.setClearColor(q,R),w.toneMapping=Te}function an(ce,Ue,Xe){const rt=Ue.isScene===!0?Ue.overrideMaterial:null;for(let et=0,gt=ce.length;et<gt;et++){const re=ce[et],Te=re.object,Ie=re.geometry,De=rt===null?re.material:rt,je=re.group;Te.layers.test(Xe.layers)&&mt(Te,Ue,Xe,Ie,De,je)}}function mt(ce,Ue,Xe,rt,et,gt){ce.onBeforeRender(w,Ue,Xe,rt,et,gt),ce.modelViewMatrix.multiplyMatrices(Xe.matrixWorldInverse,ce.matrixWorld),ce.normalMatrix.getNormalMatrix(ce.modelViewMatrix),et.onBeforeRender(w,Ue,Xe,rt,ce,gt),et.transparent===!0&&et.side===wc&&et.forceSinglePass===!1?(et.side=rs,et.needsUpdate=!0,w.renderBufferDirect(Xe,Ue,rt,et,ce,gt),et.side=Cd,et.needsUpdate=!0,w.renderBufferDirect(Xe,Ue,rt,et,ce,gt),et.side=wc):w.renderBufferDirect(Xe,Ue,rt,et,ce,gt),ce.onAfterRender(w,Ue,Xe,rt,et,gt)}function Zt(ce,Ue,Xe){Ue.isScene!==!0&&(Ue=ue);const rt=Y.get(ce),et=x.state.lights,gt=x.state.shadowsArray,re=et.state.version,Te=te.getParameters(ce,et.state,gt,Ue,Xe),Ie=te.getProgramCacheKey(Te);let De=rt.programs;rt.environment=ce.isMeshStandardMaterial?Ue.environment:null,rt.fog=Ue.fog,rt.envMap=(ce.isMeshStandardMaterial?Ne:ve).get(ce.envMap||rt.environment),De===void 0&&(ce.addEventListener("dispose",Re),De=new Map,rt.programs=De);let je=De.get(Ie);if(je!==void 0){if(rt.currentProgram===je&&rt.lightsStateVersion===re)return Yt(ce,Te),je}else Te.uniforms=te.getUniforms(ce),ce.onBuild(Xe,Te,w),ce.onBeforeCompile(Te,w),je=te.acquireProgram(Te,Ie),De.set(Ie,je),rt.uniforms=Te.uniforms;const ct=rt.uniforms;return(!ce.isShaderMaterial&&!ce.isRawShaderMaterial||ce.clipping===!0)&&(ct.clippingPlanes=qe.uniform),Yt(ce,Te),rt.needsLights=Ce(ce),rt.lightsStateVersion=re,rt.needsLights&&(ct.ambientLightColor.value=et.state.ambient,ct.lightProbe.value=et.state.probe,ct.directionalLights.value=et.state.directional,ct.directionalLightShadows.value=et.state.directionalShadow,ct.spotLights.value=et.state.spot,ct.spotLightShadows.value=et.state.spotShadow,ct.rectAreaLights.value=et.state.rectArea,ct.ltc_1.value=et.state.rectAreaLTC1,ct.ltc_2.value=et.state.rectAreaLTC2,ct.pointLights.value=et.state.point,ct.pointLightShadows.value=et.state.pointShadow,ct.hemisphereLights.value=et.state.hemi,ct.directionalShadowMap.value=et.state.directionalShadowMap,ct.directionalShadowMatrix.value=et.state.directionalShadowMatrix,ct.spotShadowMap.value=et.state.spotShadowMap,ct.spotLightMatrix.value=et.state.spotLightMatrix,ct.spotLightMap.value=et.state.spotLightMap,ct.pointShadowMap.value=et.state.pointShadowMap,ct.pointShadowMatrix.value=et.state.pointShadowMatrix),rt.currentProgram=je,rt.uniformsList=null,je}function sn(ce){if(ce.uniformsList===null){const Ue=ce.currentProgram.getUniforms();ce.uniformsList=P1.seqWithValue(Ue.seq,ce.uniforms)}return ce.uniformsList}function Yt(ce,Ue){const Xe=Y.get(ce);Xe.outputColorSpace=Ue.outputColorSpace,Xe.batching=Ue.batching,Xe.instancing=Ue.instancing,Xe.instancingColor=Ue.instancingColor,Xe.skinning=Ue.skinning,Xe.morphTargets=Ue.morphTargets,Xe.morphNormals=Ue.morphNormals,Xe.morphColors=Ue.morphColors,Xe.morphTargetsCount=Ue.morphTargetsCount,Xe.numClippingPlanes=Ue.numClippingPlanes,Xe.numIntersection=Ue.numClipIntersection,Xe.vertexAlphas=Ue.vertexAlphas,Xe.vertexTangents=Ue.vertexTangents,Xe.toneMapping=Ue.toneMapping}function _n(ce,Ue,Xe,rt,et){Ue.isScene!==!0&&(Ue=ue),se.resetTextureUnits();const gt=Ue.fog,re=rt.isMeshStandardMaterial?Ue.environment:null,Te=N===null?w.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:Zc,Ie=(rt.isMeshStandardMaterial?Ne:ve).get(rt.envMap||re),De=rt.vertexColors===!0&&!!Xe.attributes.color&&Xe.attributes.color.itemSize===4,je=!!Xe.attributes.tangent&&(!!rt.normalMap||rt.anisotropy>0),ct=!!Xe.morphAttributes.position,yt=!!Xe.morphAttributes.normal,Ct=!!Xe.morphAttributes.color;let Nt=hd;rt.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(Nt=w.toneMapping);const Ut=Xe.morphAttributes.position||Xe.morphAttributes.normal||Xe.morphAttributes.color,jt=Ut!==void 0?Ut.length:0,St=Y.get(rt),tn=x.state.lights;if(le===!0&&(oe===!0||ce!==k)){const qr=ce===k&&rt.id===O;qe.setState(rt,ce,qr)}let $t=!1;rt.version===St.__version?(St.needsLights&&St.lightsStateVersion!==tn.state.version||St.outputColorSpace!==Te||et.isBatchedMesh&&St.batching===!1||!et.isBatchedMesh&&St.batching===!0||et.isInstancedMesh&&St.instancing===!1||!et.isInstancedMesh&&St.instancing===!0||et.isSkinnedMesh&&St.skinning===!1||!et.isSkinnedMesh&&St.skinning===!0||et.isInstancedMesh&&St.instancingColor===!0&&et.instanceColor===null||et.isInstancedMesh&&St.instancingColor===!1&&et.instanceColor!==null||St.envMap!==Ie||rt.fog===!0&&St.fog!==gt||St.numClippingPlanes!==void 0&&(St.numClippingPlanes!==qe.numPlanes||St.numIntersection!==qe.numIntersection)||St.vertexAlphas!==De||St.vertexTangents!==je||St.morphTargets!==ct||St.morphNormals!==yt||St.morphColors!==Ct||St.toneMapping!==Nt||$.isWebGL2===!0&&St.morphTargetsCount!==jt)&&($t=!0):($t=!0,St.__version=rt.version);let mn=St.currentProgram;$t===!0&&(mn=Zt(rt,Ue,et));let Sn=!1,kn=!1,Bt=!1;const on=mn.getUniforms(),cn=St.uniforms;if(ie.useProgram(mn.program)&&(Sn=!0,kn=!0,Bt=!0),rt.id!==O&&(O=rt.id,kn=!0),Sn||k!==ce){on.setValue(fe,"projectionMatrix",ce.projectionMatrix),on.setValue(fe,"viewMatrix",ce.matrixWorldInverse);const qr=on.map.cameraPosition;qr!==void 0&&qr.setValue(fe,he.setFromMatrixPosition(ce.matrixWorld)),$.logarithmicDepthBuffer&&on.setValue(fe,"logDepthBufFC",2/(Math.log(ce.far+1)/Math.LN2)),(rt.isMeshPhongMaterial||rt.isMeshToonMaterial||rt.isMeshLambertMaterial||rt.isMeshBasicMaterial||rt.isMeshStandardMaterial||rt.isShaderMaterial)&&on.setValue(fe,"isOrthographic",ce.isOrthographicCamera===!0),k!==ce&&(k=ce,kn=!0,Bt=!0)}if(et.isSkinnedMesh){on.setOptional(fe,et,"bindMatrix"),on.setOptional(fe,et,"bindMatrixInverse");const qr=et.skeleton;qr&&($.floatVertexTextures?(qr.boneTexture===null&&qr.computeBoneTexture(),on.setValue(fe,"boneTexture",qr.boneTexture,se)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}et.isBatchedMesh&&(on.setOptional(fe,et,"batchingTexture"),on.setValue(fe,"batchingTexture",et._matricesTexture,se));const Ur=Xe.morphAttributes;if((Ur.position!==void 0||Ur.normal!==void 0||Ur.color!==void 0&&$.isWebGL2===!0)&&lt.update(et,Xe,mn),(kn||St.receiveShadow!==et.receiveShadow)&&(St.receiveShadow=et.receiveShadow,on.setValue(fe,"receiveShadow",et.receiveShadow)),rt.isMeshGouraudMaterial&&rt.envMap!==null&&(cn.envMap.value=Ie,cn.flipEnvMap.value=Ie.isCubeTexture&&Ie.isRenderTargetTexture===!1?-1:1),kn&&(on.setValue(fe,"toneMappingExposure",w.toneMappingExposure),St.needsLights&&wn(cn,Bt),gt&&rt.fog===!0&&ye.refreshFogUniforms(cn,gt),ye.refreshMaterialUniforms(cn,rt,G,K,pe),P1.upload(fe,sn(St),cn,se)),rt.isShaderMaterial&&rt.uniformsNeedUpdate===!0&&(P1.upload(fe,sn(St),cn,se),rt.uniformsNeedUpdate=!1),rt.isSpriteMaterial&&on.setValue(fe,"center",et.center),on.setValue(fe,"modelViewMatrix",et.modelViewMatrix),on.setValue(fe,"normalMatrix",et.normalMatrix),on.setValue(fe,"modelMatrix",et.matrixWorld),rt.isShaderMaterial||rt.isRawShaderMaterial){const qr=rt.uniformsGroups;for(let Gn=0,wo=qr.length;Gn<wo;Gn++)if($.isWebGL2){const Kn=qr[Gn];Ye.update(Kn,mn),Ye.bind(Kn,mn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return mn}function wn(ce,Ue){ce.ambientLightColor.needsUpdate=Ue,ce.lightProbe.needsUpdate=Ue,ce.directionalLights.needsUpdate=Ue,ce.directionalLightShadows.needsUpdate=Ue,ce.pointLights.needsUpdate=Ue,ce.pointLightShadows.needsUpdate=Ue,ce.spotLights.needsUpdate=Ue,ce.spotLightShadows.needsUpdate=Ue,ce.rectAreaLights.needsUpdate=Ue,ce.hemisphereLights.needsUpdate=Ue}function Ce(ce){return ce.isMeshLambertMaterial||ce.isMeshToonMaterial||ce.isMeshPhongMaterial||ce.isMeshStandardMaterial||ce.isShadowMaterial||ce.isShaderMaterial&&ce.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(ce,Ue,Xe){Y.get(ce.texture).__webglTexture=Ue,Y.get(ce.depthTexture).__webglTexture=Xe;const rt=Y.get(ce);rt.__hasExternalTextures=!0,rt.__hasExternalTextures&&(rt.__autoAllocateDepthBuffer=Xe===void 0,rt.__autoAllocateDepthBuffer||B.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),rt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(ce,Ue){const Xe=Y.get(ce);Xe.__webglFramebuffer=Ue,Xe.__useDefaultFramebuffer=Ue===void 0},this.setRenderTarget=function(ce,Ue=0,Xe=0){N=ce,T=Ue,C=Xe;let rt=!0,et=null,gt=!1,re=!1;if(ce){const Ie=Y.get(ce);Ie.__useDefaultFramebuffer!==void 0?(ie.bindFramebuffer(fe.FRAMEBUFFER,null),rt=!1):Ie.__webglFramebuffer===void 0?se.setupRenderTarget(ce):Ie.__hasExternalTextures&&se.rebindTextures(ce,Y.get(ce.texture).__webglTexture,Y.get(ce.depthTexture).__webglTexture);const De=ce.texture;(De.isData3DTexture||De.isDataArrayTexture||De.isCompressedArrayTexture)&&(re=!0);const je=Y.get(ce).__webglFramebuffer;ce.isWebGLCubeRenderTarget?(Array.isArray(je[Ue])?et=je[Ue][Xe]:et=je[Ue],gt=!0):$.isWebGL2&&ce.samples>0&&se.useMultisampledRTT(ce)===!1?et=Y.get(ce).__webglMultisampledFramebuffer:Array.isArray(je)?et=je[Xe]:et=je,j.copy(ce.viewport),z.copy(ce.scissor),I=ce.scissorTest}else j.copy(Z).multiplyScalar(G).floor(),z.copy(F).multiplyScalar(G).floor(),I=V;if(ie.bindFramebuffer(fe.FRAMEBUFFER,et)&&$.drawBuffers&&rt&&ie.drawBuffers(ce,et),ie.viewport(j),ie.scissor(z),ie.setScissorTest(I),gt){const Ie=Y.get(ce.texture);fe.framebufferTexture2D(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,fe.TEXTURE_CUBE_MAP_POSITIVE_X+Ue,Ie.__webglTexture,Xe)}else if(re){const Ie=Y.get(ce.texture),De=Ue||0;fe.framebufferTextureLayer(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,Ie.__webglTexture,Xe||0,De)}O=-1},this.readRenderTargetPixels=function(ce,Ue,Xe,rt,et,gt,re){if(!(ce&&ce.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Te=Y.get(ce).__webglFramebuffer;if(ce.isWebGLCubeRenderTarget&&re!==void 0&&(Te=Te[re]),Te){ie.bindFramebuffer(fe.FRAMEBUFFER,Te);try{const Ie=ce.texture,De=Ie.format,je=Ie.type;if(De!==io&&He.convert(De)!==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&&(B.has("EXT_color_buffer_half_float")||$.isWebGL2&&B.has("EXT_color_buffer_float"));if(je!==fd&&He.convert(je)!==fe.getParameter(fe.IMPLEMENTATION_COLOR_READ_TYPE)&&!(je===Cc&&($.isWebGL2||B.has("OES_texture_float")||B.has("WEBGL_color_buffer_float")))&&!ct){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ue>=0&&Ue<=ce.width-rt&&Xe>=0&&Xe<=ce.height-et&&fe.readPixels(Ue,Xe,rt,et,He.convert(De),He.convert(je),gt)}finally{const Ie=N!==null?Y.get(N).__webglFramebuffer:null;ie.bindFramebuffer(fe.FRAMEBUFFER,Ie)}}},this.copyFramebufferToTexture=function(ce,Ue,Xe=0){const rt=Math.pow(2,-Xe),et=Math.floor(Ue.image.width*rt),gt=Math.floor(Ue.image.height*rt);se.setTexture2D(Ue,0),fe.copyTexSubImage2D(fe.TEXTURE_2D,Xe,0,0,ce.x,ce.y,et,gt),ie.unbindTexture()},this.copyTextureToTexture=function(ce,Ue,Xe,rt=0){const et=Ue.image.width,gt=Ue.image.height,re=He.convert(Xe.format),Te=He.convert(Xe.type);se.setTexture2D(Xe,0),fe.pixelStorei(fe.UNPACK_FLIP_Y_WEBGL,Xe.flipY),fe.pixelStorei(fe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Xe.premultiplyAlpha),fe.pixelStorei(fe.UNPACK_ALIGNMENT,Xe.unpackAlignment),Ue.isDataTexture?fe.texSubImage2D(fe.TEXTURE_2D,rt,ce.x,ce.y,et,gt,re,Te,Ue.image.data):Ue.isCompressedTexture?fe.compressedTexSubImage2D(fe.TEXTURE_2D,rt,ce.x,ce.y,Ue.mipmaps[0].width,Ue.mipmaps[0].height,re,Ue.mipmaps[0].data):fe.texSubImage2D(fe.TEXTURE_2D,rt,ce.x,ce.y,re,Te,Ue.image),rt===0&&Xe.generateMipmaps&&fe.generateMipmap(fe.TEXTURE_2D),ie.unbindTexture()},this.copyTextureToTexture3D=function(ce,Ue,Xe,rt,et=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const gt=ce.max.x-ce.min.x+1,re=ce.max.y-ce.min.y+1,Te=ce.max.z-ce.min.z+1,Ie=He.convert(rt.format),De=He.convert(rt.type);let je;if(rt.isData3DTexture)se.setTexture3D(rt,0),je=fe.TEXTURE_3D;else if(rt.isDataArrayTexture)se.setTexture2DArray(rt,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,rt.flipY),fe.pixelStorei(fe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,rt.premultiplyAlpha),fe.pixelStorei(fe.UNPACK_ALIGNMENT,rt.unpackAlignment);const ct=fe.getParameter(fe.UNPACK_ROW_LENGTH),yt=fe.getParameter(fe.UNPACK_IMAGE_HEIGHT),Ct=fe.getParameter(fe.UNPACK_SKIP_PIXELS),Nt=fe.getParameter(fe.UNPACK_SKIP_ROWS),Ut=fe.getParameter(fe.UNPACK_SKIP_IMAGES),jt=Xe.isCompressedTexture?Xe.mipmaps[0]:Xe.image;fe.pixelStorei(fe.UNPACK_ROW_LENGTH,jt.width),fe.pixelStorei(fe.UNPACK_IMAGE_HEIGHT,jt.height),fe.pixelStorei(fe.UNPACK_SKIP_PIXELS,ce.min.x),fe.pixelStorei(fe.UNPACK_SKIP_ROWS,ce.min.y),fe.pixelStorei(fe.UNPACK_SKIP_IMAGES,ce.min.z),Xe.isDataTexture||Xe.isData3DTexture?fe.texSubImage3D(je,et,Ue.x,Ue.y,Ue.z,gt,re,Te,Ie,De,jt.data):Xe.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),fe.compressedTexSubImage3D(je,et,Ue.x,Ue.y,Ue.z,gt,re,Te,Ie,jt.data)):fe.texSubImage3D(je,et,Ue.x,Ue.y,Ue.z,gt,re,Te,Ie,De,jt),fe.pixelStorei(fe.UNPACK_ROW_LENGTH,ct),fe.pixelStorei(fe.UNPACK_IMAGE_HEIGHT,yt),fe.pixelStorei(fe.UNPACK_SKIP_PIXELS,Ct),fe.pixelStorei(fe.UNPACK_SKIP_ROWS,Nt),fe.pixelStorei(fe.UNPACK_SKIP_IMAGES,Ut),et===0&&rt.generateMipmaps&&fe.generateMipmap(je),ie.unbindTexture()},this.initTexture=function(ce){ce.isCubeTexture?se.setTextureCube(ce,0):ce.isData3DTexture?se.setTexture3D(ce,0):ce.isDataArrayTexture||ce.isCompressedArrayTexture?se.setTexture2DArray(ce,0):se.setTexture2D(ce,0),ie.unbindTexture()},this.resetState=function(){T=0,C=0,N=null,ie.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===VO?"display-p3":"srgb",n.unpackColorSpace=or.workingColorSpace===oE?"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===sa?Gh:mQ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Gh?sa:Zc}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 MUe extends lj{}MUe.prototype.isWebGL1Renderer=!0;class YO{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 YO(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class EUe extends La{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 AUe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=ij,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 Na=new Le;class id{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++)Na.fromBufferAttribute(this,n),Na.applyMatrix4(e),this.setXYZ(n,Na.x,Na.y,Na.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Na.fromBufferAttribute(this,n),Na.applyNormalMatrix(e),this.setXYZ(n,Na.x,Na.y,Na.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Na.fromBufferAttribute(this,n),Na.transformDirection(e),this.setXYZ(n,Na.x,Na.y,Na.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 id(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 TUe extends is{constructor(e=null,n=1,r=1,i,a,s,l,c,u=aa,d=aa,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 NUe(t,e){return t.z-e.z}function CUe(t,e){return e.z-t.z}class kUe{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",Fu=new yr,VV=new yr,PUe=new yr,GV=new yr,$C=new lE,z_=new fo,fh=new bl,zx=new Le,VC=new kUe,xa=new Uo,B_=[];function jUe(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 RUe extends Uo{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new Ea,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 TUe(n,e,e,io,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 fo);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,Fu),this.getBoundingBoxAt(i,z_).applyMatrix4(Fu),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,Fu),this.getBoundingSphereAt(i,fh).applyMatrix4(Fu),n.union(fh))}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,b=this._matricesTexture.image.data;f.push(!0),g.push(!0);const v=this._geometryCount;this._geometryCount++,PUe.toArray(b,v*16),p.needsUpdate=!0,s.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new fo,sphereInitialized:!1,sphere:new bl});const x=this.geometry.getAttribute(Wm);for(let y=0;y<i.vertexCount;y++)x.setX(i.vertexStart+y,v);return x.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 b=n.getAttribute(p),v=r.getAttribute(p);jUe(b,v,c);const x=b.itemSize;for(let y=b.count,E=u;y<E;y++){const w=c+y;for(let A=0;A<x;A++)v.setComponent(w,A,0)}v.needsUpdate=!0}if(i){const p=l.indexStart;for(let b=0;b<s.count;b++)a.setX(p+b,c+s.getX(b));for(let b=s.count,v=l.indexCount;b<v;b++)a.setX(p+b,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;xa.material=this.material,xa.geometry.index=c.index,xa.geometry.attributes=c.attributes,xa.geometry.boundingBox===null&&(xa.geometry.boundingBox=new fo),xa.geometry.boundingSphere===null&&(xa.geometry.boundingSphere=new bl);for(let u=0;u<s;u++){if(!r[u]||!i[u])continue;const d=a[u];xa.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,xa.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,xa.geometry.boundingBox),this.getBoundingSphereAt(u,xa.geometry.boundingSphere),xa.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}xa.material=null,xa.geometry.index=null,xa.geometry.attributes={},xa.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&&(GV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),$C.setFromProjectionMatrix(GV,e.isWebGPURenderer?sb:gl));let p=0;if(this.sortObjects){VV.copy(this.matrixWorld).invert(),zx.setFromMatrixPosition(r.matrixWorld).applyMatrix4(VV);for(let x=0,y=c.length;x<y;x++)if(c[x]){this.getMatrixAt(x,Fu),this.getBoundingSphereAt(x,fh).applyMatrix4(Fu);let E=!1;if(g&&(E=!$C.intersectsSphere(fh)),!E){const w=zx.distanceTo(fh.center);VC.push(f[x],w)}}const b=VC.list,v=this.customSort;v===null?b.sort(a.transparent?CUe:NUe):v.call(this,b,r);for(let x=0,y=b.length;x<y;x++){const E=b[x];u[p]=E.start*l,d[p]=E.count,p++}VC.reset()}else for(let b=0,v=c.length;b<v;b++)if(c[b]){let x=!1;if(g&&(this.getMatrixAt(b,Fu),this.getBoundingSphereAt(b,fh).applyMatrix4(Fu),x=!$C.intersectsSphere(fh)),!x){const y=f[b];u[p]=y.start*l,d[p]=y.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 WV=new Le,qV=new Le,KV=new yr,GC=new WO,H_=new bl;class DUe extends La{constructor(e=new Ea,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++)WV.fromBufferAttribute(n,i-1),qV.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=WV.distanceTo(qV);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;KV.copy(i).invert(),GC.copy(e.ray).applyMatrix4(KV);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new Le,d=new Le,f=new Le,g=new Le,p=this.isLineSegments?2:1,b=r.index,x=r.attributes.position;if(b!==null){const y=Math.max(0,s.start),E=Math.min(b.count,s.start+s.count);for(let w=y,A=E-1;w<A;w+=p){const T=b.getX(w),C=b.getX(w+1);if(u.fromBufferAttribute(x,T),d.fromBufferAttribute(x,C),GC.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 y=Math.max(0,s.start),E=Math.min(x.count,s.start+s.count);for(let w=y,A=E-1;w<A;w+=p){if(u.fromBufferAttribute(x,w),d.fromBufferAttribute(x,w+1),GC.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 XV=new Le,YV=new Le;class uE extends DUe{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)XV.fromBufferAttribute(n,i),YV.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+XV.distanceTo(YV);e.setAttribute("lineDistance",new ei(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class OUe extends Ea{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new Le,a=new Le;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 b=g,v=g+p;b<v;b+=3)for(let x=0;x<3;x++){const y=l.getX(b+x),E=l.getX(b+(x+1)%3);i.fromBufferAttribute(s,y),a.fromBufferAttribute(s,E),ZV(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),ZV(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 ZV(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 LUe 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=pQ,this.normalScale=new rn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=HO,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 IUe 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 IQ extends La{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 WC=new yr,QV=new Le,JV=new Le;class FUe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new rn(512,512),this.map=null,this.mapPass=null,this.matrix=new yr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new lE,this._frameExtents=new rn(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;QV.setFromMatrixPosition(e.matrixWorld),n.position.copy(QV),JV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(JV),n.updateMatrixWorld(),WC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(WC),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(WC)}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 e7=new yr,Bx=new Le,qC=new Le;class UUe extends FUe{constructor(){super(new Ss(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new rn(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 Le(1,0,0),new Le(-1,0,0),new Le(0,0,1),new Le(0,0,-1),new Le(0,1,0),new Le(0,-1,0)],this._cubeUps=[new Le(0,1,0),new Le(0,1,0),new Le(0,1,0),new Le(0,1,0),new Le(0,0,1),new Le(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),qC.copy(r.position),qC.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(qC),r.updateMatrixWorld(),i.makeTranslation(-Bx.x,-Bx.y,-Bx.z),e7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(e7)}}class zUe extends IQ{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 UUe}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 BUe extends IQ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class HUe extends Ea{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 cj extends AUe{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 t7{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(oa(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const n7=new Le,$_=new Le;class $Ue{constructor(e=new Le,n=new Le){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){n7.subVectors(e,this.start),$_.subVectors(this.end,this.start);const r=$_.dot($_);let a=$_.dot(n7)/r;return n&&(a=oa(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 VUe extends uE{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 Ea;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:aE}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=aE);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 GUe 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 uj(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 WUe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:uj,toHexString:uj},lb={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},qUe={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)}},KUe={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)}},XUe=[WUe,lb,qUe,KUe];function YUe(t){return XUe.find(e=>e.match(t))}class ZUe 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=YUe(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=uj(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 KC 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 QUe 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",b),window.addEventListener("mouseup",v)},b=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",b),window.removeEventListener("mouseup",v)},x=()=>{this._inputFocused=!0},y=()=>{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",x),this.$input.addEventListener("blur",y)}_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=(y,E,w,A,T)=>(y-E)/(w-E)*(T-A)+A,n=y=>{const E=this.$slider.getBoundingClientRect();let w=e(y,E.left,E.right,this._min,this._max);this._snapClampSetValue(w)},r=y=>{this._setDraggingStyle(!0),n(y.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=y=>{n(y.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let s=!1,l,c;const u=y=>{y.preventDefault(),this._setDraggingStyle(!0),n(y.touches[0].clientX),s=!1},d=y=>{y.touches.length>1||(this._hasScrollBar?(l=y.touches[0].clientX,c=y.touches[0].clientY,s=!0):u(y),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",g))},f=y=>{if(s){const E=y.touches[0].clientX-l,w=y.touches[0].clientY-c;Math.abs(E)>Math.abs(w)?u(y):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g))}else y.preventDefault(),n(y.touches[0].clientX)},g=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g)},p=this._callOnFinishChange.bind(this),b=400;let v;const x=y=>{if(Math.abs(y.deltaX)<Math.abs(y.deltaY)&&this._hasScrollBar)return;y.preventDefault();const w=this._normalizeMouseWheel(y)*this._step;this._snapClampSetValue(this.getValue()+w),this.$input.value=this.getValue(),clearTimeout(v),v=setTimeout(p,b)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",x,{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 JUe 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 eze 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 tze=`.lil-gui {
  7477. font-family: var(--font-family);
  7478. font-size: var(--font-size);
  7479. line-height: 1;
  7480. font-weight: normal;
  7481. font-style: normal;
  7482. text-align: left;
  7483. color: var(--text-color);
  7484. user-select: none;
  7485. -webkit-user-select: none;
  7486. touch-action: manipulation;
  7487. --background-color: #1f1f1f;
  7488. --text-color: #ebebeb;
  7489. --title-background-color: #111111;
  7490. --title-text-color: #ebebeb;
  7491. --widget-color: #424242;
  7492. --hover-color: #4f4f4f;
  7493. --focus-color: #595959;
  7494. --number-color: #2cc9ff;
  7495. --string-color: #a2db3c;
  7496. --font-size: 11px;
  7497. --input-font-size: 11px;
  7498. --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  7499. --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
  7500. --padding: 4px;
  7501. --spacing: 4px;
  7502. --widget-height: 20px;
  7503. --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
  7504. --name-width: 45%;
  7505. --slider-knob-width: 2px;
  7506. --slider-input-width: 27%;
  7507. --color-input-width: 27%;
  7508. --slider-input-min-width: 45px;
  7509. --color-input-min-width: 45px;
  7510. --folder-indent: 7px;
  7511. --widget-padding: 0 0 0 3px;
  7512. --widget-border-radius: 2px;
  7513. --checkbox-size: calc(0.75 * var(--widget-height));
  7514. --scrollbar-width: 5px;
  7515. }
  7516. .lil-gui, .lil-gui * {
  7517. box-sizing: border-box;
  7518. margin: 0;
  7519. padding: 0;
  7520. }
  7521. .lil-gui.root {
  7522. width: var(--width, 245px);
  7523. display: flex;
  7524. flex-direction: column;
  7525. background: var(--background-color);
  7526. }
  7527. .lil-gui.root > .title {
  7528. background: var(--title-background-color);
  7529. color: var(--title-text-color);
  7530. }
  7531. .lil-gui.root > .children {
  7532. overflow-x: hidden;
  7533. overflow-y: auto;
  7534. }
  7535. .lil-gui.root > .children::-webkit-scrollbar {
  7536. width: var(--scrollbar-width);
  7537. height: var(--scrollbar-width);
  7538. background: var(--background-color);
  7539. }
  7540. .lil-gui.root > .children::-webkit-scrollbar-thumb {
  7541. border-radius: var(--scrollbar-width);
  7542. background: var(--focus-color);
  7543. }
  7544. @media (pointer: coarse) {
  7545. .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
  7546. --widget-height: 28px;
  7547. --padding: 6px;
  7548. --spacing: 6px;
  7549. --font-size: 13px;
  7550. --input-font-size: 16px;
  7551. --folder-indent: 10px;
  7552. --scrollbar-width: 7px;
  7553. --slider-input-min-width: 50px;
  7554. --color-input-min-width: 65px;
  7555. }
  7556. }
  7557. .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
  7558. --widget-height: 28px;
  7559. --padding: 6px;
  7560. --spacing: 6px;
  7561. --font-size: 13px;
  7562. --input-font-size: 16px;
  7563. --folder-indent: 10px;
  7564. --scrollbar-width: 7px;
  7565. --slider-input-min-width: 50px;
  7566. --color-input-min-width: 65px;
  7567. }
  7568. .lil-gui.autoPlace {
  7569. max-height: 100%;
  7570. position: fixed;
  7571. top: 0;
  7572. right: 15px;
  7573. z-index: 1001;
  7574. }
  7575. .lil-gui .controller {
  7576. display: flex;
  7577. align-items: center;
  7578. padding: 0 var(--padding);
  7579. margin: var(--spacing) 0;
  7580. }
  7581. .lil-gui .controller.disabled {
  7582. opacity: 0.5;
  7583. }
  7584. .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
  7585. pointer-events: none !important;
  7586. }
  7587. .lil-gui .controller > .name {
  7588. min-width: var(--name-width);
  7589. flex-shrink: 0;
  7590. white-space: pre;
  7591. padding-right: var(--spacing);
  7592. line-height: var(--widget-height);
  7593. }
  7594. .lil-gui .controller .widget {
  7595. position: relative;
  7596. display: flex;
  7597. align-items: center;
  7598. width: 100%;
  7599. min-height: var(--widget-height);
  7600. }
  7601. .lil-gui .controller.string input {
  7602. color: var(--string-color);
  7603. }
  7604. .lil-gui .controller.boolean {
  7605. cursor: pointer;
  7606. }
  7607. .lil-gui .controller.color .display {
  7608. width: 100%;
  7609. height: var(--widget-height);
  7610. border-radius: var(--widget-border-radius);
  7611. position: relative;
  7612. }
  7613. @media (hover: hover) {
  7614. .lil-gui .controller.color .display:hover:before {
  7615. content: " ";
  7616. display: block;
  7617. position: absolute;
  7618. border-radius: var(--widget-border-radius);
  7619. border: 1px solid #fff9;
  7620. top: 0;
  7621. right: 0;
  7622. bottom: 0;
  7623. left: 0;
  7624. }
  7625. }
  7626. .lil-gui .controller.color input[type=color] {
  7627. opacity: 0;
  7628. width: 100%;
  7629. height: 100%;
  7630. cursor: pointer;
  7631. }
  7632. .lil-gui .controller.color input[type=text] {
  7633. margin-left: var(--spacing);
  7634. font-family: var(--font-family-mono);
  7635. min-width: var(--color-input-min-width);
  7636. width: var(--color-input-width);
  7637. flex-shrink: 0;
  7638. }
  7639. .lil-gui .controller.option select {
  7640. opacity: 0;
  7641. position: absolute;
  7642. width: 100%;
  7643. max-width: 100%;
  7644. }
  7645. .lil-gui .controller.option .display {
  7646. position: relative;
  7647. pointer-events: none;
  7648. border-radius: var(--widget-border-radius);
  7649. height: var(--widget-height);
  7650. line-height: var(--widget-height);
  7651. max-width: 100%;
  7652. overflow: hidden;
  7653. word-break: break-all;
  7654. padding-left: 0.55em;
  7655. padding-right: 1.75em;
  7656. background: var(--widget-color);
  7657. }
  7658. @media (hover: hover) {
  7659. .lil-gui .controller.option .display.focus {
  7660. background: var(--focus-color);
  7661. }
  7662. }
  7663. .lil-gui .controller.option .display.active {
  7664. background: var(--focus-color);
  7665. }
  7666. .lil-gui .controller.option .display:after {
  7667. font-family: "lil-gui";
  7668. content: "↕";
  7669. position: absolute;
  7670. top: 0;
  7671. right: 0;
  7672. bottom: 0;
  7673. padding-right: 0.375em;
  7674. }
  7675. .lil-gui .controller.option .widget,
  7676. .lil-gui .controller.option select {
  7677. cursor: pointer;
  7678. }
  7679. @media (hover: hover) {
  7680. .lil-gui .controller.option .widget:hover .display {
  7681. background: var(--hover-color);
  7682. }
  7683. }
  7684. .lil-gui .controller.number input {
  7685. color: var(--number-color);
  7686. }
  7687. .lil-gui .controller.number.hasSlider input {
  7688. margin-left: var(--spacing);
  7689. width: var(--slider-input-width);
  7690. min-width: var(--slider-input-min-width);
  7691. flex-shrink: 0;
  7692. }
  7693. .lil-gui .controller.number .slider {
  7694. width: 100%;
  7695. height: var(--widget-height);
  7696. background: var(--widget-color);
  7697. border-radius: var(--widget-border-radius);
  7698. padding-right: var(--slider-knob-width);
  7699. overflow: hidden;
  7700. cursor: ew-resize;
  7701. touch-action: pan-y;
  7702. }
  7703. @media (hover: hover) {
  7704. .lil-gui .controller.number .slider:hover {
  7705. background: var(--hover-color);
  7706. }
  7707. }
  7708. .lil-gui .controller.number .slider.active {
  7709. background: var(--focus-color);
  7710. }
  7711. .lil-gui .controller.number .slider.active .fill {
  7712. opacity: 0.95;
  7713. }
  7714. .lil-gui .controller.number .fill {
  7715. height: 100%;
  7716. border-right: var(--slider-knob-width) solid var(--number-color);
  7717. box-sizing: content-box;
  7718. }
  7719. .lil-gui-dragging .lil-gui {
  7720. --hover-color: var(--widget-color);
  7721. }
  7722. .lil-gui-dragging * {
  7723. cursor: ew-resize !important;
  7724. }
  7725. .lil-gui-dragging.lil-gui-vertical * {
  7726. cursor: ns-resize !important;
  7727. }
  7728. .lil-gui .title {
  7729. height: var(--title-height);
  7730. line-height: calc(var(--title-height) - 4px);
  7731. font-weight: 600;
  7732. padding: 0 var(--padding);
  7733. -webkit-tap-highlight-color: transparent;
  7734. cursor: pointer;
  7735. outline: none;
  7736. text-decoration-skip: objects;
  7737. }
  7738. .lil-gui .title:before {
  7739. font-family: "lil-gui";
  7740. content: "▾";
  7741. padding-right: 2px;
  7742. display: inline-block;
  7743. }
  7744. .lil-gui .title:active {
  7745. background: var(--title-background-color);
  7746. opacity: 0.75;
  7747. }
  7748. @media (hover: hover) {
  7749. body:not(.lil-gui-dragging) .lil-gui .title:hover {
  7750. background: var(--title-background-color);
  7751. opacity: 0.85;
  7752. }
  7753. .lil-gui .title:focus {
  7754. text-decoration: underline var(--focus-color);
  7755. }
  7756. }
  7757. .lil-gui.root > .title:focus {
  7758. text-decoration: none !important;
  7759. }
  7760. .lil-gui.closed > .title:before {
  7761. content: "▸";
  7762. }
  7763. .lil-gui.closed > .children {
  7764. transform: translateY(-7px);
  7765. opacity: 0;
  7766. }
  7767. .lil-gui.closed:not(.transition) > .children {
  7768. display: none;
  7769. }
  7770. .lil-gui.transition > .children {
  7771. transition-duration: 300ms;
  7772. transition-property: height, opacity, transform;
  7773. transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  7774. overflow: hidden;
  7775. pointer-events: none;
  7776. }
  7777. .lil-gui .children:empty:before {
  7778. content: "Empty";
  7779. padding: 0 var(--padding);
  7780. margin: var(--spacing) 0;
  7781. display: block;
  7782. height: var(--widget-height);
  7783. font-style: italic;
  7784. line-height: var(--widget-height);
  7785. opacity: 0.5;
  7786. }
  7787. .lil-gui.root > .children > .lil-gui > .title {
  7788. border: 0 solid var(--widget-color);
  7789. border-width: 1px 0;
  7790. transition: border-color 300ms;
  7791. }
  7792. .lil-gui.root > .children > .lil-gui.closed > .title {
  7793. border-bottom-color: transparent;
  7794. }
  7795. .lil-gui + .controller {
  7796. border-top: 1px solid var(--widget-color);
  7797. margin-top: 0;
  7798. padding-top: var(--spacing);
  7799. }
  7800. .lil-gui .lil-gui .lil-gui > .title {
  7801. border: none;
  7802. }
  7803. .lil-gui .lil-gui .lil-gui > .children {
  7804. border: none;
  7805. margin-left: var(--folder-indent);
  7806. border-left: 2px solid var(--widget-color);
  7807. }
  7808. .lil-gui .lil-gui .controller {
  7809. border: none;
  7810. }
  7811. .lil-gui label, .lil-gui input, .lil-gui button {
  7812. -webkit-tap-highlight-color: transparent;
  7813. }
  7814. .lil-gui input {
  7815. border: 0;
  7816. outline: none;
  7817. font-family: var(--font-family);
  7818. font-size: var(--input-font-size);
  7819. border-radius: var(--widget-border-radius);
  7820. height: var(--widget-height);
  7821. background: var(--widget-color);
  7822. color: var(--text-color);
  7823. width: 100%;
  7824. }
  7825. @media (hover: hover) {
  7826. .lil-gui input:hover {
  7827. background: var(--hover-color);
  7828. }
  7829. .lil-gui input:active {
  7830. background: var(--focus-color);
  7831. }
  7832. }
  7833. .lil-gui input:disabled {
  7834. opacity: 1;
  7835. }
  7836. .lil-gui input[type=text],
  7837. .lil-gui input[type=number] {
  7838. padding: var(--widget-padding);
  7839. -moz-appearance: textfield;
  7840. }
  7841. .lil-gui input[type=text]:focus,
  7842. .lil-gui input[type=number]:focus {
  7843. background: var(--focus-color);
  7844. }
  7845. .lil-gui input[type=checkbox] {
  7846. appearance: none;
  7847. width: var(--checkbox-size);
  7848. height: var(--checkbox-size);
  7849. border-radius: var(--widget-border-radius);
  7850. text-align: center;
  7851. cursor: pointer;
  7852. }
  7853. .lil-gui input[type=checkbox]:checked:before {
  7854. font-family: "lil-gui";
  7855. content: "✓";
  7856. font-size: var(--checkbox-size);
  7857. line-height: var(--checkbox-size);
  7858. }
  7859. @media (hover: hover) {
  7860. .lil-gui input[type=checkbox]:focus {
  7861. box-shadow: inset 0 0 0 1px var(--focus-color);
  7862. }
  7863. }
  7864. .lil-gui button {
  7865. outline: none;
  7866. cursor: pointer;
  7867. font-family: var(--font-family);
  7868. font-size: var(--font-size);
  7869. color: var(--text-color);
  7870. width: 100%;
  7871. height: var(--widget-height);
  7872. text-transform: none;
  7873. background: var(--widget-color);
  7874. border-radius: var(--widget-border-radius);
  7875. border: none;
  7876. }
  7877. @media (hover: hover) {
  7878. .lil-gui button:hover {
  7879. background: var(--hover-color);
  7880. }
  7881. .lil-gui button:focus {
  7882. box-shadow: inset 0 0 0 1px var(--focus-color);
  7883. }
  7884. }
  7885. .lil-gui button:active {
  7886. background: var(--focus-color);
  7887. }
  7888. @font-face {
  7889. font-family: "lil-gui";
  7890. 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");
  7891. }`;function nze(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 r7=!1;class rS{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"),!r7&&l&&(nze(tze),r7=!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 JUe(this,e,n,r);const s=e[n];switch(typeof s){case"number":return new QUe(this,e,n,r,i,a);case"boolean":return new GUe(this,e,n);case"string":return new eze(this,e,n);case"function":return new KC(this,e,n)}console.error(`gui.add failed
  7892. property:`,n,`
  7893. object:`,e,`
  7894. value:`,s)}addColor(e,n,r=1){return new ZUe(this,e,n,r)}addFolder(e){const n=new rS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof KC||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 KC)){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 XC(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 ZO{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 ZO(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 QO{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class i7 extends QO{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Uu extends QO{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class a7{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class iS{constructor(e){this.lines=[],this.preamble=new a7(-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(`
  7895. `);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 i7(e,c,u,s);case"t0":return new Uu(e,c,s,0);case"t1":return new Uu(e,c,s,1);case"t2":return new Uu(e,c,s,2);case"t3":return new Uu(e,c,s,3);case"t4":return new Uu(e,c,s,4);case"t5":return new Uu(e,c,s,5);case"t6":return new Uu(e,c,s,6);case"t7":return new Uu(e,c,s,7);default:return new QO(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 i7){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 a7(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=ZO.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}}}iS.prototype.parseGcode=iS.prototype.parseGCode;const s7={type:"change"},YC={type:"start"},o7={type:"end"},V_=new WO,l7=new Wu,rze=Math.cos(70*xQ.DEG2RAD);class ize extends Cf{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Le,this.cursor=new Le,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($){$.addEventListener("keydown",Ae),this._domElementKeyEvents=$},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Ae),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(s7),r.update(),a=i.NONE},this.update=(function(){const $=new Le,ie=new yf().setFromUnitVectors(e.up,new Le(0,1,0)),H=ie.clone().invert(),Y=new Le,se=new yf,ve=new Le,Ne=2*Math.PI;return function(Se=null){const U=r.object.position;$.copy(U).sub(r.target),$.applyQuaternion(ie),l.setFromVector3($),r.autoRotate&&a===i.NONE&&j((function(Me){return Me!==null?2*Math.PI/60*r.autoRotateSpeed*Me:2*Math.PI/60/60*r.autoRotateSpeed})(Se)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let L=r.minAzimuthAngle,te=r.maxAzimuthAngle;isFinite(L)&&isFinite(te)&&(L<-Math.PI?L+=Ne:L>Math.PI&&(L-=Ne),te<-Math.PI?te+=Ne:te>Math.PI&&(te-=Ne),l.theta=L<=te?Math.max(L,Math.min(te,l.theta)):l.theta>(L+te)/2?Math.max(L,l.theta):Math.min(te,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),$.setFromSpherical(l),$.applyQuaternion(H),U.copy(r.target).add($),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 ye=!1;if(r.zoomToCursor&&C){let Me=null;if(r.object.isPerspectiveCamera){const be=$.length();Me=J(be*u);const qe=be-Me;r.object.position.addScaledVector(A,qe),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const be=new Le(T.x,T.y,0);be.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ye=!0;const qe=new Le(T.x,T.y,0);qe.unproject(r.object),r.object.position.sub(qe).add(be),r.object.updateMatrixWorld(),Me=$.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;Me!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(Me).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))<rze?e.lookAt(r.target):(l7.setFromNormalAndCoplanarPoint(r.object.up,r.target),V_.intersectPlane(l7,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ye=!0);return u=1,C=!1,!!(ye||Y.distanceToSquared(r.object.position)>s||8*(1-se.dot(r.object.quaternion))>s||ve.distanceToSquared(r.target)>0)&&(r.dispatchEvent(s7),Y.copy(r.object.position),se.copy(r.object.quaternion),ve.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",fe),r.domElement.removeEventListener("pointerdown",Q),r.domElement.removeEventListener("pointercancel",he),r.domElement.removeEventListener("wheel",ue),r.domElement.removeEventListener("pointermove",Ee),r.domElement.removeEventListener("pointerup",he),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Ae),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 t7,c=new t7;let u=1;const d=new Le,f=new rn,g=new rn,p=new rn,b=new rn,v=new rn,x=new rn,y=new rn,E=new rn,w=new rn,A=new Le,T=new rn;let C=!1;const N=[],O={};function k(){return Math.pow(.95,r.zoomSpeed)}function j($){c.theta-=$}function z($){c.phi-=$}const I=(function(){const $=new Le;return function(ie,H){$.setFromMatrixColumn(H,0),$.multiplyScalar(-ie),d.add($)}})(),q=(function(){const $=new Le;return function(ie,H){r.screenSpacePanning===!0?$.setFromMatrixColumn(H,1):($.setFromMatrixColumn(H,0),$.crossVectors(r.object.up,$)),$.multiplyScalar(ie),d.add($)}})(),R=(function(){const $=new Le;return function(ie,H){const Y=r.domElement;if(r.object.isPerspectiveCamera){const se=r.object.position;$.copy(se).sub(r.target);let ve=$.length();ve*=Math.tan(r.object.fov/2*Math.PI/180),I(2*ie*ve/Y.clientHeight,r.object.matrix),q(2*H*ve/Y.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(I(ie*(r.object.right-r.object.left)/r.object.zoom/Y.clientWidth,r.object.matrix),q(H*(r.object.top-r.object.bottom)/r.object.zoom/Y.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function W($){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=$:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K($){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=$:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function G($){if(!r.zoomToCursor)return;C=!0;const ie=r.domElement.getBoundingClientRect(),H=$.clientX-ie.left,Y=$.clientY-ie.top,se=ie.width,ve=ie.height;T.x=H/se*2-1,T.y=-Y/ve*2+1,A.set(T.x,T.y,1).unproject(r.object).sub(r.object.position).normalize()}function J($){return Math.max(r.minDistance,Math.min(r.maxDistance,$))}function ee($){f.set($.clientX,$.clientY)}function Z($){b.set($.clientX,$.clientY)}function F(){if(N.length===1)f.set(N[0].pageX,N[0].pageY);else{const $=.5*(N[0].pageX+N[1].pageX),ie=.5*(N[0].pageY+N[1].pageY);f.set($,ie)}}function V(){if(N.length===1)b.set(N[0].pageX,N[0].pageY);else{const $=.5*(N[0].pageX+N[1].pageX),ie=.5*(N[0].pageY+N[1].pageY);b.set($,ie)}}function ne(){const $=N[0].pageX-N[1].pageX,ie=N[0].pageY-N[1].pageY,H=Math.sqrt($*$+ie*ie);y.set(0,H)}function le($){if(N.length==1)g.set($.pageX,$.pageY);else{const H=B($),Y=.5*($.pageX+H.x),se=.5*($.pageY+H.y);g.set(Y,se)}p.subVectors(g,f).multiplyScalar(r.rotateSpeed);const ie=r.domElement;j(2*Math.PI*p.x/ie.clientHeight),z(2*Math.PI*p.y/ie.clientHeight),f.copy(g)}function oe($){if(N.length===1)v.set($.pageX,$.pageY);else{const ie=B($),H=.5*($.pageX+ie.x),Y=.5*($.pageY+ie.y);v.set(H,Y)}x.subVectors(v,b).multiplyScalar(r.panSpeed),R(x.x,x.y),b.copy(v)}function pe($){const ie=B($),H=$.pageX-ie.x,Y=$.pageY-ie.y,se=Math.sqrt(H*H+Y*Y);E.set(0,se),w.set(0,Math.pow(E.y/y.y,r.zoomSpeed)),W(w.y),y.copy(E)}function Q($){r.enabled!==!1&&(N.length===0&&(r.domElement.setPointerCapture($.pointerId),r.domElement.addEventListener("pointermove",Ee),r.domElement.addEventListener("pointerup",he)),(function(ie){N.push(ie)})($),$.pointerType==="touch"?(function(ie){switch(at(ie),N.length){case 1:switch(r.touches.ONE){case Cm.ROTATE:if(r.enableRotate===!1)return;F(),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&&ne(),r.enablePan&&V(),a=i.TOUCH_DOLLY_PAN;break;case Cm.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ne(),r.enableRotate&&F(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(YC)})($):(function(ie){let H;switch(ie.button){case 0:H=r.mouseButtons.LEFT;break;case 1:H=r.mouseButtons.MIDDLE;break;case 2:H=r.mouseButtons.RIGHT;break;default:H=-1}switch(H){case Nm.DOLLY:if(r.enableZoom===!1)return;(function(Y){G(Y),y.set(Y.clientX,Y.clientY)})(ie),a=i.DOLLY;break;case Nm.ROTATE:if(ie.ctrlKey||ie.metaKey||ie.shiftKey){if(r.enablePan===!1)return;Z(ie),a=i.PAN}else{if(r.enableRotate===!1)return;ee(ie),a=i.ROTATE}break;case Nm.PAN:if(ie.ctrlKey||ie.metaKey||ie.shiftKey){if(r.enableRotate===!1)return;ee(ie),a=i.ROTATE}else{if(r.enablePan===!1)return;Z(ie),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(YC)})($))}function Ee($){r.enabled!==!1&&($.pointerType==="touch"?(function(ie){switch(at(ie),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;le(ie),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;oe(ie),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(H){r.enableZoom&&pe(H),r.enablePan&&oe(H)})(ie),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(H){r.enableZoom&&pe(H),r.enableRotate&&le(H)})(ie),r.update();break;default:a=i.NONE}})($):(function(ie){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(H){g.set(H.clientX,H.clientY),p.subVectors(g,f).multiplyScalar(r.rotateSpeed);const Y=r.domElement;j(2*Math.PI*p.x/Y.clientHeight),z(2*Math.PI*p.y/Y.clientHeight),f.copy(g),r.update()})(ie);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(H){E.set(H.clientX,H.clientY),w.subVectors(E,y),w.y>0?W(k()):w.y<0&&K(k()),y.copy(E),r.update()})(ie);break;case i.PAN:if(r.enablePan===!1)return;(function(H){v.set(H.clientX,H.clientY),x.subVectors(v,b).multiplyScalar(r.panSpeed),R(x.x,x.y),b.copy(v),r.update()})(ie)}})($))}function he($){(function(ie){delete O[ie.pointerId];for(let H=0;H<N.length;H++)if(N[H].pointerId==ie.pointerId)return void N.splice(H,1)})($),N.length===0&&(r.domElement.releasePointerCapture($.pointerId),r.domElement.removeEventListener("pointermove",Ee),r.domElement.removeEventListener("pointerup",he)),r.dispatchEvent(o7),a=i.NONE}function ue($){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&($.preventDefault(),r.dispatchEvent(YC),(function(ie){G(ie),ie.deltaY<0?K(k()):ie.deltaY>0&&W(k()),r.update()})($),r.dispatchEvent(o7))}function Ae($){r.enabled!==!1&&r.enablePan!==!1&&(function(ie){let H=!1;switch(ie.code){case r.keys.UP:ie.ctrlKey||ie.metaKey||ie.shiftKey?z(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,r.keyPanSpeed),H=!0;break;case r.keys.BOTTOM:ie.ctrlKey||ie.metaKey||ie.shiftKey?z(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,-r.keyPanSpeed),H=!0;break;case r.keys.LEFT:ie.ctrlKey||ie.metaKey||ie.shiftKey?j(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(r.keyPanSpeed,0),H=!0;break;case r.keys.RIGHT:ie.ctrlKey||ie.metaKey||ie.shiftKey?j(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(-r.keyPanSpeed,0),H=!0}H&&(ie.preventDefault(),r.update())})($)}function fe($){r.enabled!==!1&&$.preventDefault()}function at($){let ie=O[$.pointerId];ie===void 0&&(ie=new rn,O[$.pointerId]=ie),ie.set($.pageX,$.pageY)}function B($){const ie=$.pointerId===N[0].pointerId?N[1]:N[0];return O[ie.pointerId]}r.domElement.addEventListener("contextmenu",fe),r.domElement.addEventListener("pointerdown",Q),r.domElement.addEventListener("pointercancel",he),r.domElement.addEventListener("wheel",ue,{passive:!1}),this.update()}}kt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new rn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Ja.line={uniforms:qO.merge([kt.common,kt.fog,kt.line]),vertexShader:`
  7896. #include <common>
  7897. #include <color_pars_vertex>
  7898. #include <fog_pars_vertex>
  7899. #include <logdepthbuf_pars_vertex>
  7900. #include <clipping_planes_pars_vertex>
  7901. uniform float linewidth;
  7902. uniform vec2 resolution;
  7903. attribute vec3 instanceStart;
  7904. attribute vec3 instanceEnd;
  7905. attribute vec3 instanceColorStart;
  7906. attribute vec3 instanceColorEnd;
  7907. #ifdef WORLD_UNITS
  7908. varying vec4 worldPos;
  7909. varying vec3 worldStart;
  7910. varying vec3 worldEnd;
  7911. #ifdef USE_DASH
  7912. varying vec2 vUv;
  7913. #endif
  7914. #else
  7915. varying vec2 vUv;
  7916. #endif
  7917. #ifdef USE_DASH
  7918. uniform float dashScale;
  7919. attribute float instanceDistanceStart;
  7920. attribute float instanceDistanceEnd;
  7921. varying float vLineDistance;
  7922. #endif
  7923. void trimSegment( const in vec4 start, inout vec4 end ) {
  7924. // trim end segment so it terminates between the camera plane and the near plane
  7925. // conservative estimate of the near plane
  7926. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  7927. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  7928. float nearEstimate = - 0.5 * b / a;
  7929. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  7930. end.xyz = mix( start.xyz, end.xyz, alpha );
  7931. }
  7932. void main() {
  7933. #ifdef USE_COLOR
  7934. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  7935. #endif
  7936. #ifdef USE_DASH
  7937. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  7938. vUv = uv;
  7939. #endif
  7940. float aspect = resolution.x / resolution.y;
  7941. // camera space
  7942. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  7943. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  7944. #ifdef WORLD_UNITS
  7945. worldStart = start.xyz;
  7946. worldEnd = end.xyz;
  7947. #else
  7948. vUv = uv;
  7949. #endif
  7950. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  7951. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  7952. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  7953. // perhaps there is a more elegant solution -- WestLangley
  7954. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  7955. if ( perspective ) {
  7956. if ( start.z < 0.0 && end.z >= 0.0 ) {
  7957. trimSegment( start, end );
  7958. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  7959. trimSegment( end, start );
  7960. }
  7961. }
  7962. // clip space
  7963. vec4 clipStart = projectionMatrix * start;
  7964. vec4 clipEnd = projectionMatrix * end;
  7965. // ndc space
  7966. vec3 ndcStart = clipStart.xyz / clipStart.w;
  7967. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  7968. // direction
  7969. vec2 dir = ndcEnd.xy - ndcStart.xy;
  7970. // account for clip-space aspect ratio
  7971. dir.x *= aspect;
  7972. dir = normalize( dir );
  7973. #ifdef WORLD_UNITS
  7974. // get the offset direction as perpendicular to the view vector
  7975. vec3 worldDir = normalize( end.xyz - start.xyz );
  7976. vec3 offset;
  7977. if ( position.y < 0.5 ) {
  7978. offset = normalize( cross( start.xyz, worldDir ) );
  7979. } else {
  7980. offset = normalize( cross( end.xyz, worldDir ) );
  7981. }
  7982. // sign flip
  7983. if ( position.x < 0.0 ) offset *= - 1.0;
  7984. float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
  7985. // don't extend the line if we're rendering dashes because we
  7986. // won't be rendering the endcaps
  7987. #ifndef USE_DASH
  7988. // extend the line bounds to encompass endcaps
  7989. start.xyz += - worldDir * linewidth * 0.5;
  7990. end.xyz += worldDir * linewidth * 0.5;
  7991. // shift the position of the quad so it hugs the forward edge of the line
  7992. offset.xy -= dir * forwardOffset;
  7993. offset.z += 0.5;
  7994. #endif
  7995. // endcaps
  7996. if ( position.y > 1.0 || position.y < 0.0 ) {
  7997. offset.xy += dir * 2.0 * forwardOffset;
  7998. }
  7999. // adjust for linewidth
  8000. offset *= linewidth * 0.5;
  8001. // set the world position
  8002. worldPos = ( position.y < 0.5 ) ? start : end;
  8003. worldPos.xyz += offset;
  8004. // project the worldpos
  8005. vec4 clip = projectionMatrix * worldPos;
  8006. // shift the depth of the projected points so the line
  8007. // segments overlap neatly
  8008. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  8009. clip.z = clipPose.z * clip.w;
  8010. #else
  8011. vec2 offset = vec2( dir.y, - dir.x );
  8012. // undo aspect ratio adjustment
  8013. dir.x /= aspect;
  8014. offset.x /= aspect;
  8015. // sign flip
  8016. if ( position.x < 0.0 ) offset *= - 1.0;
  8017. // endcaps
  8018. if ( position.y < 0.0 ) {
  8019. offset += - dir;
  8020. } else if ( position.y > 1.0 ) {
  8021. offset += dir;
  8022. }
  8023. // adjust for linewidth
  8024. offset *= linewidth;
  8025. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  8026. offset /= resolution.y;
  8027. // select end
  8028. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  8029. // back to clip space
  8030. offset *= clip.w;
  8031. clip.xy += offset;
  8032. #endif
  8033. gl_Position = clip;
  8034. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  8035. #include <logdepthbuf_vertex>
  8036. #include <clipping_planes_vertex>
  8037. #include <fog_vertex>
  8038. }
  8039. `,fragmentShader:`
  8040. uniform vec3 diffuse;
  8041. uniform float opacity;
  8042. uniform float linewidth;
  8043. #ifdef USE_DASH
  8044. uniform float dashOffset;
  8045. uniform float dashSize;
  8046. uniform float gapSize;
  8047. #endif
  8048. varying float vLineDistance;
  8049. #ifdef WORLD_UNITS
  8050. varying vec4 worldPos;
  8051. varying vec3 worldStart;
  8052. varying vec3 worldEnd;
  8053. #ifdef USE_DASH
  8054. varying vec2 vUv;
  8055. #endif
  8056. #else
  8057. varying vec2 vUv;
  8058. #endif
  8059. #include <common>
  8060. #include <color_pars_fragment>
  8061. #include <fog_pars_fragment>
  8062. #include <logdepthbuf_pars_fragment>
  8063. #include <clipping_planes_pars_fragment>
  8064. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  8065. float mua;
  8066. float mub;
  8067. vec3 p13 = p1 - p3;
  8068. vec3 p43 = p4 - p3;
  8069. vec3 p21 = p2 - p1;
  8070. float d1343 = dot( p13, p43 );
  8071. float d4321 = dot( p43, p21 );
  8072. float d1321 = dot( p13, p21 );
  8073. float d4343 = dot( p43, p43 );
  8074. float d2121 = dot( p21, p21 );
  8075. float denom = d2121 * d4343 - d4321 * d4321;
  8076. float numer = d1343 * d4321 - d1321 * d4343;
  8077. mua = numer / denom;
  8078. mua = clamp( mua, 0.0, 1.0 );
  8079. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  8080. mub = clamp( mub, 0.0, 1.0 );
  8081. return vec2( mua, mub );
  8082. }
  8083. void main() {
  8084. #include <clipping_planes_fragment>
  8085. #ifdef USE_DASH
  8086. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  8087. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  8088. #endif
  8089. float alpha = opacity;
  8090. #ifdef WORLD_UNITS
  8091. // Find the closest points on the view ray and the line segment
  8092. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  8093. vec3 lineDir = worldEnd - worldStart;
  8094. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  8095. vec3 p1 = worldStart + lineDir * params.x;
  8096. vec3 p2 = rayEnd * params.y;
  8097. vec3 delta = p1 - p2;
  8098. float len = length( delta );
  8099. float norm = len / linewidth;
  8100. #ifndef USE_DASH
  8101. #ifdef USE_ALPHA_TO_COVERAGE
  8102. float dnorm = fwidth( norm );
  8103. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  8104. #else
  8105. if ( norm > 0.5 ) {
  8106. discard;
  8107. }
  8108. #endif
  8109. #endif
  8110. #else
  8111. #ifdef USE_ALPHA_TO_COVERAGE
  8112. // artifacts appear on some hardware if a derivative is taken within a conditional
  8113. float a = vUv.x;
  8114. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8115. float len2 = a * a + b * b;
  8116. float dlen = fwidth( len2 );
  8117. if ( abs( vUv.y ) > 1.0 ) {
  8118. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  8119. }
  8120. #else
  8121. if ( abs( vUv.y ) > 1.0 ) {
  8122. float a = vUv.x;
  8123. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8124. float len2 = a * a + b * b;
  8125. if ( len2 > 1.0 ) discard;
  8126. }
  8127. #endif
  8128. #endif
  8129. vec4 diffuseColor = vec4( diffuse, alpha );
  8130. #include <logdepthbuf_fragment>
  8131. #include <color_fragment>
  8132. gl_FragColor = vec4( diffuseColor.rgb, alpha );
  8133. #include <tonemapping_fragment>
  8134. #include <colorspace_fragment>
  8135. #include <fog_fragment>
  8136. #include <premultiplied_alpha_fragment>
  8137. }
  8138. `};class FQ extends kd{constructor(e){super({type:"LineMaterial",uniforms:qO.clone(Ja.line.uniforms),vertexShader:Ja.line.vertexShader,fragmentShader:Ja.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 c7=new fo,G_=new Le;class UQ extends HUe{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 cj(n,6,1);return this.setAttribute("instanceStart",new id(r,3,0)),this.setAttribute("instanceEnd",new id(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 cj(n,6,1);return this.setAttribute("instanceColorStart",new id(r,3,0)),this.setAttribute("instanceColorEnd",new id(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 OUe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new fo);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),c7.setFromBufferAttribute(n),this.boundingBox.union(c7))}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 u7=new Le,d7=new Le,ea=new cr,ta=new cr,rl=new cr,ZC=new Le,QC=new yr,na=new $Ue,h7=new Le,W_=new fo,q_=new bl,il=new cr;let al,Eh;function f7(t,e,n){return il.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),il.multiplyScalar(1/il.w),il.x=Eh/n.width,il.y=Eh/n.height,il.applyMatrix4(t.projectionMatrixInverse),il.multiplyScalar(1/il.w),Math.abs(Math.max(il.x,il.y))}class aze extends Uo{constructor(e=new UQ,n=new FQ({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)u7.fromBufferAttribute(n,s),d7.fromBufferAttribute(r,s),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+u7.distanceTo(d7);const a=new cj(i,2,1);return e.setAttribute("instanceDistanceStart",new id(a,1,0)),e.setAttribute("instanceDistanceEnd",new id(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;Eh=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),q_.copy(l.boundingSphere).applyMatrix4(s),r?u=.5*Eh:u=f7(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*Eh:d=f7(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,b=f.geometry,v=b.attributes.instanceStart,x=b.attributes.instanceEnd;for(let y=0,E=Math.min(b.instanceCount,v.count);y<E;y++){na.start.fromBufferAttribute(v,y),na.end.fromBufferAttribute(x,y),na.applyMatrix4(p);const w=new Le,A=new Le;al.distanceSqToSegment(na.start,na.end,A,w),A.distanceTo(w)<.5*Eh&&g.push({point:A,pointOnLine:w,distance:al.origin.distanceTo(A),object:f,face:null,faceIndex:y,uv:null,uv1:null})}})(this,n):(function(f,g,p){const b=g.projectionMatrix,v=f.material.resolution,x=f.matrixWorld,y=f.geometry,E=y.attributes.instanceStart,w=y.attributes.instanceEnd,A=Math.min(y.instanceCount,E.count),T=-g.near;al.at(1,rl),rl.w=1,rl.applyMatrix4(g.matrixWorldInverse),rl.applyMatrix4(b),rl.multiplyScalar(1/rl.w),rl.x*=v.x/2,rl.y*=v.y/2,rl.z=0,ZC.copy(rl),QC.multiplyMatrices(g.matrixWorldInverse,x);for(let C=0,N=A;C<N;C++){if(ea.fromBufferAttribute(E,C),ta.fromBufferAttribute(w,C),ea.w=1,ta.w=1,ea.applyMatrix4(QC),ta.applyMatrix4(QC),ea.z>T&&ta.z>T)continue;if(ea.z>T){const I=ea.z-ta.z,q=(ea.z-T)/I;ea.lerp(ta,q)}else if(ta.z>T){const I=ta.z-ea.z,q=(ta.z-T)/I;ta.lerp(ea,q)}ea.applyMatrix4(b),ta.applyMatrix4(b),ea.multiplyScalar(1/ea.w),ta.multiplyScalar(1/ta.w),ea.x*=v.x/2,ea.y*=v.y/2,ta.x*=v.x/2,ta.y*=v.y/2,na.start.copy(ea),na.start.z=0,na.end.copy(ta),na.end.z=0;const O=na.closestPointToPointParameter(ZC,!0);na.at(O,h7);const k=xQ.lerp(ea.z,ta.z,O),j=k>=-1&&k<=1,z=ZC.distanceTo(h7)<.5*Eh;if(j&&z){na.start.fromBufferAttribute(E,C),na.end.fromBufferAttribute(w,C),na.start.applyMatrix4(x),na.end.applyMatrix4(x);const I=new Le,q=new Le;al.distanceSqToSegment(na.start,na.end,q,I),p.push({point:q,pointOnLine:I,distance:al.origin.distanceTo(q),object:f,face:null,faceIndex:C,uv:null,uv1:null})}}})(this,i,n)))}}class sze extends uE{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 Ea;f.setAttribute("position",new ei(c,3)),f.setAttribute("color",new ei(u,3)),super(f,new ly({vertexColors:!0,toneMapped:!1}))}}function oze(t,e,n,r){const i=(function(s,l,c){s*=.5,l*=.5,c*=.5;const u=new Ea,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 uE(i,new IUe({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,b=30*s,v=document.createElement("canvas");v.width=l,v.height=c,v.style.cssText="width:80px;height:48px";var x=v.getContext("2d");return x.font="bold "+9*s+"px Helvetica,Arial,sans-serif",x.textBaseline="top",x.fillStyle=n,x.fillRect(0,0,l,c),x.fillStyle=e,x.fillText(t,u,d),x.fillRect(f,g,p,b),x.fillStyle=n,x.globalAlpha=.9,x.fillRect(f,g,p,b),{dom:v,update:function(y,E){r=Math.min(r,y),i=Math.max(i,y),x.fillStyle=n,x.globalAlpha=1,x.fillRect(0,0,l,g),x.fillStyle=e,x.fillText(a(y)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),x.drawImage(v,f+s,g,p-s,b,f,g,p-s,b),x.fillRect(f+p-s,g,s,b),x.fillStyle=n,x.globalAlpha=.9,x.fillRect(f+p-s,g,s,a((1-y/E)*b))}}};var lze=h0;class m7{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new rS,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 rS,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 cze extends Ea{constructor(e=[new Le],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 Le,s=new Le,l=new rn,c=[],u=[],d=[],f=[];function g(p){const[b,v,x]=(function(y){const E=e[y],w=new Le,A=new Le,T=new Le,C=new Le;w.copy(E).sub(e[y-1]||E).normalize().add((e[y+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 y=0;y<=i;y++){const E=y/i*Math.PI*2,w=Math.sin(E),A=-Math.cos(E);s.x=A*v.x+w*x.x,s.y=A*v.y+w*x.y,s.z=A*v.z+w*x.z,s.normalize(),u.push(s.x,s.y,s.z),a.x=b.x+n*s.x*.5,a.y=b.y+n*s.y*.5,a.z=b.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 b=0;b<=i;b++)l.x=p/e.length,l.y=b/i,d.push(l.x,l.y)})(),(function(){for(let p=1;p<e.length;p++)for(let b=1;b<=i;b++){const v=(i+1)*(p-1)+(b-1),x=(i+1)*p+(b-1),y=(i+1)*p+b,E=(i+1)*(p-1)+b;f.push(v,x,E),f.push(x,y,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 JC={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 iS(this.minLayerThreshold),this.scene=new EUe,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 lze: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,b]of Object.entries(e.toolColors))this._toolColors[parseInt(p)]=new Kt(b)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+aE),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 lj({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 lj({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 YO(this._backgroundColor,g,f),this.resize(),this.controls=new ize(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 VUe(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 BUe(13421772,.3*Math.PI),n=new zUe(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 XC(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,b={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;(b.x!=this.state.x||b.y!=this.state.y||b.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,b,v,g.gcode=="g2"||g.gcode=="g02"):this.addLineSegment(f,this.state,b,v))}this.state.x=b.x,this.state.y=b.y,this.state.z=b.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(JC),a=new Kt().setHSL(JC.h,JC.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 sze(this.buildVolume.x,10,this.buildVolume.y,10));const e=oze(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 iS(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,b=r.i,v=r.j;if(p){const W=d-l,K=f-c,G=Math.sqrt(Math.pow(W/2,2)+Math.pow(K/2,2));p=Math.max(p,G);const J=Math.pow(W,2)+Math.pow(K,2),ee=Math.pow(p,2)-J/4;let Z=Math.sqrt(ee/J);(a&&p<0||!a&&p>0)&&(Z=-Z),b=W/2+K*Z,v=K/2-W*Z}const x=l==d&&c==f,y=l+b,E=c+v,w=Math.sqrt(b*b+v*v),A=Math.atan2(-v,-b),T=Math.atan2(f-E,d-y);let C;x?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 z=l,I=c,q=u,R=A;for(let W=0;W<N-1;W++)R+=O,z=y+w*Math.cos(R),I=E+w*Math.sin(R),q+=j,k.push({x:z,y:I,z:q});k.push({x:r.x,y:r.y,z:r.z});for(let W=0;W<k.length-1;W++)s.push(k[W].x,k[W].y,k[W].z,k[W+1].x,k[W+1].y,k[W+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new Ea;i.setAttribute("position",new ei(e,3)),this.disposables.push(i);const a=new ly({color:n});this.disposables.push(a);const s=new uE(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 Le(l[0],l[1],l[2]),u=new Le(l[3],l[4],l[5]),d=new Le(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 cze(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 UQ;this.disposables.push(i);const a=new FQ({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const s=new aze(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=>XC(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 LUe({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),s=new RUe(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 XC(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(`
  8139. `),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 m7(this):typeof this.devMode=="object"&&(this.devGui=new m7(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");function uze({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=S.useRef(!1),[c,u]=S.useState(!0),[d,f]=S.useState(null),[g,p]=S.useState(!1),[b,v]=S.useState(0),[x,y]=S.useState(0),E=S.useMemo(()=>JSON.stringify(n),[n]);S.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const T=i.current,C=T.parentElement?.getBoundingClientRect();C&&(T.width=C.width,T.height=C.height);const N=n&&n.length>1,O=n?.[0]||"#00ae42",k=new vp({canvas:T,buildVolume:e,backgroundColor:1710618,extrusionColor:N?n:O,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=k,fetch(t).then(async z=>{if(!z.ok)throw z.status===404&&(await z.json().catch(()=>({}))).detail?.includes("sliced")?(p(!0),new Error("not_sliced")):new Error("Failed to load G-code");return z.text()}).then(z=>{const I=new Set,q=/^(\s*)T(\d+)(\s*;.*)?$/gim;let R;for(;(R=q.exec(z))!==null;){const Z=parseInt(R[2],10);Z<=15&&I.add(Z)}const W=new Map,K=Array.from(I).sort((Z,F)=>Z-F);K.forEach((Z,F)=>{W.set(Z,F%8)});const G=[];K.forEach((Z,F)=>{const V=n?.[Z]||"#00ae42";G[F%8]=V});const J=z.split(`
  8140. `).map(Z=>{const F=Z.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(F){const V=parseInt(F[2],10);if(V>15)return`; FILTERED: ${Z.trim()}`;const ne=W.get(V)??0;return`${F[1]}T${ne}${F[3]||""}`}return Z}).join(`
  8141. `);G.length>0&&(k.extrusionColor=G),k.processGCode(J);const ee=k.layers?.length||0;y(ee),v(ee),k.render(),u(!1)}).catch(z=>{z.message!=="not_sliced"&&f(z.message),u(!1)});const j=()=>{if(T.parentElement&&a.current){const z=T.parentElement.getBoundingClientRect();T.width=z.width,T.height=z.height,a.current.resize()}};return window.addEventListener("resize",j),()=>{window.removeEventListener("resize",j),s.current&&cancelAnimationFrame(s.current),a.current&&(a.current.dispose(),a.current=null),l.current=!1}},[t,E]);const w=S.useCallback(T=>{if(!a.current)return;const C=Math.max(1,Math.min(T,x));v(C),s.current&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=C,a.current.render())})},[x]),A=T=>{w(parseInt(T.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"}),c&&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(xt,{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..."})]})}),g&&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(Kle,{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 in Bambu Studio or Orca Slicer."})]})}),d&&!g&&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:d})})})]}),!c&&!d&&!g&&x>0&&o.jsx("div",{className:"mt-4 px-2",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(vd,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),o.jsx("button",{onClick:()=>w(b-1),disabled:b<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:o.jsx(ef,{className:"w-4 h-4"})}),o.jsx("input",{type:"range",min:1,max:x,value:b,onChange:A,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),o.jsx("button",{onClick:()=>w(b+1),disabled:b>=x,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:[b," / ",x]})]})})]})}function dze({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,has_source:!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)}`;vh(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(Pe,{variant:"secondary",size:"sm",onClick:u,children:[o.jsx(ui,{className:"w-4 h-4"}),"Open in Slicer"]}),o.jsx(Pe,{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(bd,{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(wle,{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(xt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?o.jsx(oOe,{url:a.has_source?_e.getSource3mfDownloadUrl(t):_e.getArchiveDownload(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):r==="gcode"&&a?o.jsx(uze,{gcodeUrl:_e.getArchiveGcode(t),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 hze({archiveId:t,archiveName:e,onClose:n,onSuccess:r}){const i=dn(),[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}=pt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:f}=pt({queryKey:["archive-filaments",t],queryFn:()=>_e.getArchiveFilamentRequirements(t)}),{data:g}=pt({queryKey:["printer-status",a],queryFn:()=>_e.getPrinterStatus(a),enabled:!!a}),p=_t({mutationFn:()=>{if(!a)throw new Error("No printer selected");return _e.reprintArchive(t,a)},onSuccess:()=>{r(),n()}}),b=u?.filter(A=>A.is_active)||[],v=A=>A?`#${A.replace("#","").substring(0,6)}`:"#808080",x=(A,T,C,N)=>{const O=String.fromCharCode(65+(A>=128?A-128:A));return C?`HT-${O}`:`AMS-${O} Slot ${T+1}`},y=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:x(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 z=parseInt(k.substring(0,2),16),I=parseInt(k.substring(2,4),16),q=parseInt(k.substring(4,6),16),R=parseInt(j.substring(0,2),16),W=parseInt(j.substring(2,4),16),K=parseInt(j.substring(4,6),16);return Math.abs(z-R)<=O&&Math.abs(I-W)<=O&&Math.abs(q-K)<=O};return f.filaments.map(C=>{const N=y.find(W=>W.type?.toUpperCase()===C.type?.toUpperCase()&&A(W.color)===A(C.color)),O=!N&&y.find(W=>W.type?.toUpperCase()===C.type?.toUpperCase()&&T(W.color,C.color)),k=!N&&!O&&y.find(W=>W.type?.toUpperCase()===C.type?.toUpperCase()),j=N||O||k||void 0,z=!!j,I=z,q=!!N||!!O;let R;return N||O?R="match":k?R="type_only":R="mismatch",{...C,loaded:j,hasFilament:z,typeMatch:I,colorMatch:q,status:R}})},[f,y]),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(At,{className:"w-full max-w-md",children:o.jsxs(Tt,{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(Pe,{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(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):b.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:b.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(qi,{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(qn,{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(qn,{className:"w-3 h-3"}),"Color mismatch"]}):o.jsxs("span",{className:"text-xs text-bambu-green flex items-center gap-1",children:[o.jsx(go,{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(MU,{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(MU,{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(go,{className:"w-3 h-3 text-bambu-green"}):A.status==="type_only"?o.jsx("span",{title:"Same type, different color",children:o.jsx(qn,{className:"w-3 h-3 text-yellow-400"})}):o.jsx("span",{title:"Filament type not loaded",children:o.jsx(qn,{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(Pe,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),o.jsx(Pe,{onClick:()=>p.mutate(),disabled:!a||p.isPending,className:"flex-1",children:p.isPending?o.jsxs(o.Fragment,{children:[o.jsx(xt,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):o.jsxs(o.Fragment,{children:[o.jsx(qi,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function fze({onClose:t,initialFiles:e}){const n=dn(),{showToast:r}=vr(),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}=pt({queryKey:["printers"],queryFn:_e.getPrinters}),b=_t({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(I=>I.filename===k.file.name),z=N.errors.find(I=>I.filename===k.file.name);return j?{...k,status:"success",archiveId:j.id}:z?{...k,status:"error",error:z.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)},[]),x=S.useCallback(N=>{N.preventDefault(),c(!1)},[]),y=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)),b.mutate(N.map(O=>O.file)))},T=a.filter(N=>N.status==="pending").length,C=b.isPending;return o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:o.jsx(At,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:o.jsxs(Tt,{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:x,onDrop:y,children:[o.jsx(ua,{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(Pe,{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(hR,{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(xt,{className:"w-4 h-4 text-bambu-green animate-spin"}),N.status==="success"&&o.jsx(Ar,{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(Sa,{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(Pe,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&o.jsx(Pe,{onClick:A,disabled:T===0||C,className:"flex-1",children:C?o.jsxs(o.Fragment,{children:[o.jsx(xt,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):o.jsxs(o.Fragment,{children:[o.jsx(ua,{className:"w-4 h-4"}),"Upload ",T>0&&`(${T})`]})})]})]})})})}const mze=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],pze=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function gze({archive:t,onClose:e,existingTags:n=[]}){S.useEffect(()=>{const oe=pe=>{pe.key==="Escape"&&e()};return window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)},[e]);const r=dn(),[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||""),[b,v]=S.useState(t.failure_reason||""),[x,y]=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),z=S.useRef(null),I=S.useRef(null),{data:q}=pt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:R}=pt({queryKey:["projects"],queryFn:()=>_e.getProjects()}),{data:W}=pt({queryKey:["archives"],queryFn:()=>_e.getArchives(void 0,1e3,0),enabled:n.length===0}),K=n.length>0?n:[...new Set(W?.flatMap(oe=>oe.tags?.split(",").map(pe=>pe.trim())||[]).filter(Boolean)||[])].sort(),G=g.split(",").map(oe=>oe.trim()).filter(Boolean),J=K.filter(oe=>!G.includes(oe)),ee=oe=>{if(!G.includes(oe)){const pe=[...G,oe].join(", ");p(pe)}I.current!==null&&clearTimeout(I.current),j.current?.focus()},Z=oe=>{const pe=G.filter(Q=>Q!==oe).join(", ");p(pe)},F=_t({mutationFn:oe=>_e.updateArchive(t.id,oe),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),V=async oe=>{const pe=oe.target.files?.[0];if(pe){N(!0);try{const Q=await _e.uploadArchivePhoto(t.id,pe);T(Q.photos),r.invalidateQueries({queryKey:["archives"]})}catch(Q){console.error("Failed to upload photo:",Q)}finally{N(!1),z.current&&(z.current.value="")}}},ne=async oe=>{try{const pe=await _e.deleteArchivePhoto(t.id,oe);T(pe.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(pe){console.error("Failed to delete photo:",pe)}},le=oe=>{oe.preventDefault();const pe={print_name:i||void 0,printer_id:s,project_id:c,notes:d||void 0,tags:g||void 0,quantity:E};x!==t.status&&(pe.status=x),x==="failed"||x==="aborted"?pe.failure_reason=b||void 0:(t.status==="failed"||t.status==="aborted")&&(pe.failure_reason=null),F.mutate(pe)};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:oe=>oe.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:le,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:oe=>a(oe.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:oe=>l(oe.target.value?Number(oe.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"}),q?.map(oe=>o.jsx("option",{value:oe.id,children:oe.name},oe.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:oe=>u(oe.target.value?Number(oe.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(oe=>o.jsx("option",{value:oe.id,children:oe.name},oe.id))]})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[o.jsx(bce,{className:"w-4 h-4 inline mr-1"}),"Items Printed"]}),o.jsx("input",{type:"number",min:1,value:E,onChange:oe=>w(Math.max(1,parseInt(oe.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:oe=>f(oe.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"}),G.length>0&&o.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:G.map(oe=>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"}),oe,o.jsx("button",{type:"button",onClick:()=>Z(oe),className:"ml-0.5 text-bambu-gray hover:text-white",children:o.jsx(Wt,{className:"w-3 h-3"})})]},oe))}),o.jsxs("div",{className:"relative",children:[o.jsx("input",{ref:j,type:"text",value:g,onChange:oe=>p(oe.target.value),onFocus:()=>{I.current!==null&&clearTimeout(I.current),k(!0)},onBlur:()=>{I.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:G.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(oe=>o.jsx("button",{type:"button",onClick:()=>ee(oe),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:oe},oe))})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),o.jsx("select",{value:x,onChange:oe=>{y(oe.target.value),oe.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:pze.map(oe=>o.jsx("option",{value:oe.value,children:oe.label},oe.value))})]}),(x==="failed"||x==="aborted")&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),o.jsxs("select",{value:b,onChange:oe=>v(oe.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..."}),mze.map(oe=>o.jsx("option",{value:oe,children:oe},oe))]})]}),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(oe=>o.jsxs("div",{className:"relative group",children:[o.jsx("img",{src:_e.getArchivePhotoUrl(t.id,oe),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),o.jsx("button",{type:"button",onClick:()=>ne(oe),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(Rn,{className:"w-3 h-3 text-white"})})]},oe)),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:z,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:V,className:"hidden",disabled:C}),C?o.jsx(xt,{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(Pe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsxs(Pe,{type:"submit",disabled:F.isPending,className:"flex-1",children:[o.jsx(Ts,{className:"w-4 h-4"}),F.isPending?"Saving...":"Save"]})]})]})]})})}function xze({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),[g,p]=S.useState({});S.useEffect(()=>{const x=w=>{i.current&&!i.current.contains(w.target)&&r()},y=w=>{w.key==="Escape"&&r()},E=()=>{r()};return document.addEventListener("mousedown",x),document.addEventListener("keydown",y),document.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",y),document.removeEventListener("scroll",E,!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(),y=window.innerWidth,E=window.innerHeight,w=8;let A=t,T=e;t+x.width>y-w&&(A=Math.max(w,y-x.width-w)),A<w&&(A=w),e+x.height>E-w&&(T=Math.max(w,E-x.height-w)),T<w&&(T=w);const C=180,N=y-A-x.width,O=A;f(N<C&&O>C),u({x:A,y:T,visible:!0})}},[t,e]);const b=(x,y)=>{l.current&&(clearTimeout(l.current),l.current=null);const E=y.getBoundingClientRect(),w=window.innerHeight,A=300,N=w-E.top-8<A&&E.top>A;p(O=>({...O,[x]:N?"bottom":"top"})),s(x)},v=()=>{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,y)=>{if(x.divider)return o.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},y);const E=x.submenu&&x.submenu.length>0;return o.jsxs("div",{className:"relative",onMouseEnter:w=>E&&b(y,w.currentTarget),onMouseLeave:()=>E&&v(),children:[o.jsxs("button",{onMouseEnter:w=>E&&b(y,w.currentTarget.parentElement),onClick:()=>{E?s(a===y?null:y):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"} ${E&&a===y?"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}),E&&o.jsx(Ko,{className:"w-4 h-4 text-bambu-gray"})]}),E&&a===y&&o.jsx("div",{className:`absolute 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"} ${g[y]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>v(),children:x.submenu.map((w,A)=>o.jsxs("button",{onClick:()=>{w.disabled||(w.onClick(),r())},disabled:w.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${w.disabled?"text-bambu-gray cursor-not-allowed":w.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[w.icon&&o.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:w.icon}),w.label]},A))})]},y)})})}function bze({selectedIds:t,existingTags:e,onClose:n}){const r=dn(),{showToast:i}=vr(),[a,s]=S.useState(""),[l,c]=S.useState(new Set),[u,d]=S.useState("add");S.useEffect(()=>{const v=x=>{x.key==="Escape"&&n()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n]);const f=_t({mutationFn:async()=>{const v=Array.from(l);let x=0;for(const y of t)try{const E=await _e.getArchive(y),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(y,{tags:A.join(", ")}),x++}catch(E){throw console.error(`Failed to update archive ${y}:`,E),new Error(`Failed on archive ${y}: ${E instanceof Error?E.message:"Unknown error"}`)}return{count:x,mode:u,tags:v}},onSuccess:({count:v,mode:x,tags:y})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${x==="add"?"Added":"Removed"} ${y.length} tag${y.length!==1?"s":""} ${x==="add"?"to":"from"} ${v} archive${v!==1?"s":""}`),n()},onError:v=>{i(v.message||"Failed to update tags","error")}}),g=v=>{c(x=>{const y=new Set(x);return y.has(v)?y.delete(v):y.add(v),y})},p=()=>{a.trim()&&!l.has(a.trim())&&(c(v=>new Set([...v,a.trim()])),s(""))},b=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(At,{className:"w-full max-w-md",children:o.jsxs(Tt,{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(Pe,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),o.jsx(Pe,{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:b}),o.jsx(Pe,{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(Pe,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),o.jsx(Pe,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?o.jsxs(o.Fragment,{children:[o.jsx(xt,{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 yze(t,e){return new Date(t,e+1,0).getDate()}function vze(t,e){return new Date(t,e,1).getDay()}const _ze=["January","February","March","April","May","June","July","August","September","October","November","December"],wze=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Sze({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 y=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=y.get(A)||[];T.push(E),y.set(A,T)}),y},[t]),d=yze(a,r),f=vze(a,r),g=()=>{r===0?(i(11),s(a-1)):i(r-1)},p=()=>{r===11?(i(0),s(a+1)):i(r+1)},b=()=>{i(n.getMonth()),s(n.getFullYear())},v=[];for(let y=0;y<f;y++)v.push(null);for(let y=1;y<=d;y++)v.push(y);const x=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(ef,{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:[_ze[r]," ",a]}),o.jsx("button",{onClick:b,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:wze.map(y=>o.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:y},y))}),o.jsx("div",{className:"grid grid-cols-7 gap-1",children:v.map((y,E)=>{if(y===null)return o.jsx("div",{className:"aspect-square"},`empty-${E}`);const w=`${a}-${String(r+1).padStart(2,"0")}-${String(y).padStart(2,"0")}`,A=u.get(w)||[],T=A.length>0,C=y===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:y}),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})]})]},y)})}),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(y=>{const E=new Date(y.completed_at||y.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(y=>{const E=new Date(y.completed_at||y.created_at);return E.getMonth()===r&&E.getFullYear()===a&&y.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(y=>{const E=new Date(y.completed_at||y.created_at);return E.getMonth()===r&&E.getFullYear()===a&&y.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"})}),x.length>0?o.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:x.map(y=>o.jsxs("button",{onClick:()=>e?.(y),className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-left",children:[y.thumbnail_path?o.jsx("img",{src:_e.getArchiveThumbnail(y.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:y.print_name||y.filename}),o.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[o.jsx("span",{className:y.status==="failed"?"text-red-400":"text-green-400",children:y.status==="failed"?"Failed":"Completed"}),y.filament_color&&o.jsx("div",{className:"flex gap-0.5",children:y.filament_color.split(",").map((E,w)=>o.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:E}},w))})]})]})]},y.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 Mze({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(Pe,{onClick:i,className:"w-full",children:[o.jsx(Wi,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function Eze({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=b=>{b.key==="Escape"&&r(),b.key==="ArrowLeft"&&s(v=>Math.max(0,v-1)),b.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(Pe,{variant:"secondary",size:"sm",onClick:f,children:[o.jsx(Wi,{className:"w-4 h-4"}),"Download"]}),i&&o.jsx(Pe,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:o.jsx(Rn,{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(ef,{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,b)=>o.jsx("button",{onClick:()=>s(b),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${b===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:o.jsx("img",{src:_e.getArchivePhotoUrl(t,p),alt:`Thumbnail ${b+1}`,className:"w-full h-full object-cover"})},p))})]}),l&&o.jsx(mr,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function ia(t){this.content=t}ia.prototype={constructor:ia,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 ia(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 ia(n)},addToStart:function(t,e){return new ia([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ia(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 ia(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=ia.from(t),t.size?new ia(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=ia.from(t),t.size?new ia(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ia.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}};ia.from=function(t){if(t instanceof ia)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ia(e)};function zQ(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=zQ(i.content,a.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function BQ(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=BQ(s.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class vt{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 vt(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 vt(r,i)}cutByIndex(e,n){return e==n?vt.empty:e==0&&n==this.content.length?this:new vt(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 vt(i,a)}addToStart(e){return new vt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new vt(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 zQ(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return BQ(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 vt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new vt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return vt.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 vt(n||e,r)}static from(e){if(!e)return vt.empty;if(e instanceof vt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new vt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}vt.empty=new vt([],0);const ek={index:0,offset:0};function K_(t,e){return ek.index=t,ek.offset=e,ek}function aS(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(!aS(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!aS(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let pr=class dj{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&&aS(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 dj.none;if(e instanceof dj)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};pr.none=[];class sS extends Error{}class Dt{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=$Q(this.content,e+this.openStart,n);return r&&new Dt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Dt(HQ(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 Dt.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 Dt(vt.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 Dt(e,r,i)}}Dt.empty=new Dt(vt.empty,0,0);function HQ(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(HQ(a.content,e-i-1,n-i-1)))}function $Q(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=$Q(s.content,e-a-1,n,s);return l&&t.replaceChild(i,s.copy(l))}function Aze(t,e,n){if(n.openStart>t.depth)throw new sS("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new sS("Inconsistent open depths");return VQ(t,e,n,0)}function VQ(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=VQ(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 qh(s,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=Tze(n,t);return qh(a,WQ(t,s,l,e,r))}else return qh(a,oS(t,e,r))}function GQ(t,e){if(!e.type.compatibleContent(t.type))throw new sS("Cannot join "+e.type.name+" onto "+t.type.name)}function hj(t,e,n){let r=t.node(n);return GQ(r,e.node(n)),r}function Wh(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&&(Wh(t.nodeAfter,r),a++));for(let l=a;l<s;l++)Wh(i.child(l),r);e&&e.depth==n&&e.textOffset&&Wh(e.nodeBefore,r)}function qh(t,e){return t.type.checkContent(e),t.copy(e)}function WQ(t,e,n,r,i){let a=t.depth>i&&hj(t,e,i+1),s=r.depth>i&&hj(n,r,i+1),l=[];return m0(null,t,i,l),a&&s&&e.index(i)==n.index(i)?(GQ(a,s),Wh(qh(a,WQ(t,e,n,r,i+1)),l)):(a&&Wh(qh(a,oS(t,e,i+1)),l),m0(e,n,i,l),s&&Wh(qh(s,oS(n,r,i+1)),l)),m0(r,null,i,l),new vt(l)}function oS(t,e,n){let r=[];if(m0(null,t,n,r),t.depth>n){let i=hj(t,e,n+1);Wh(qh(i,oS(t,e,n+1)),r)}return m0(e,null,n,r),new vt(r)}function Tze(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(vt.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 pr.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 lS(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=p7.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 p7.set(e,r=new Nze);let i=r.elts[r.i]=cb.resolve(e,n);return r.i=(r.i+1)%Cze,i}}class Nze{constructor(){this.elts=[],this.i=0}}const Cze=12,p7=new WeakMap;class lS{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 kze=Object.create(null);let md=class fj{constructor(e,n,r,i=pr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||vt.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&&aS(this.attrs,n||e.defaultAttrs||kze)&&pr.sameSet(this.marks,r||pr.none)}copy(e=null){return e==this.content?this:new fj(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new fj(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 Dt.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 Dt(u,i.depth-s,a.depth-s)}replace(e,n,r){return Aze(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()+")"),qQ(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=vt.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=pr.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(!pr.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=vt.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};md.prototype.text=void 0;class cS extends md{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):qQ(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 cS(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new cS(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 qQ(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 Pze(e,n);if(r.next==null)return vf.empty;let i=KQ(r);r.next&&r.err("Unexpected trailing text");let a=Fze(Ize(i));return Uze(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 vt.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(`
  8142. `)}}vf.empty=new vf(!0);class Pze{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 KQ(t){let e=[];do e.push(jze(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function jze(t){let e=[];do e.push(Rze(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Rze(t){let e=Lze(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=Dze(t,e);else break;return e}function g7(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Dze(t,e){let n=g7(t),r=n;return t.eat(",")&&(t.next!="}"?r=g7(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Oze(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 Lze(t){if(t.eat("(")){let e=KQ(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=Oze(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 Ize(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 XQ(t,e){return e-t}function x7(t,e){let n=[];return r(e),n.sort(XQ);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 Fze(t){let e=Object.create(null);return n(x7(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]);x7(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(XQ);a.next.push({type:i[s][0],next:e[l.join(",")]||n(l)})}return a}}function Uze(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 YQ(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 ZQ(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 QQ(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 JQ(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new Bze(t,r,e[r]);return n}let b7=class eJ{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=JQ(e,r.attrs),this.defaultAttrs=YQ(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:ZQ(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new md(this,this.computeAttrs(e),vt.from(n),pr.setFrom(r))}createChecked(e=null,n,r){return n=vt.from(n),this.checkContent(n),new md(this,this.computeAttrs(e),n,pr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=vt.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(vt.empty,!0);return a?new md(this,e,n.append(a),pr.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){QQ(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:pr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,s)=>r[a]=new eJ(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 zze(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 Bze{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?zze(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class dE{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=JQ(e,i.attrs),this.excluded=null;let a=YQ(this.attrs);this.instance=a?new pr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new pr(this,ZQ(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,s)=>r[a]=new dE(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){QQ(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class tJ{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=ia.from(e.nodes),n.marks=ia.from(e.marks||{}),this.nodes=b7.compile(this.spec.nodes,this),this.marks=dE.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?y7(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==""?[]:y7(this,s.split(" "))}this.nodeFromJSON=i=>md.fromJSON(this,i),this.markFromJSON=i=>pr.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 b7){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 cS(r,r.defaultAttrs,e,pr.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 y7(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 Hze(t){return t.tag!=null}function $ze(t){return t.style!=null}let p0=class mj{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(Hze(i))this.tags.push(i);else if($ze(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 _7(this,n,!1);return r.addAll(e,pr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new _7(this,n,!0);return r.addAll(e,pr.none,n.from,n.to),Dt.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(Wze(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=w7(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=w7(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new mj(e,mj.schemaRules(e)))}};const nJ={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},Vze={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},rJ={ol:!0,ul:!0},ub=1,pj=2,g0=4;function v7(t,e,n){return e!=null?(e?ub:0)|(e==="full"?pj:0):t&&t.whitespace=="pre"?ub|pj: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=pr.none,this.match=a||(s&g0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(vt.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=vt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(vt.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&&!nJ.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class _7{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=v7(null,n.preserveWhitespace,0)|(r?g0:0);i?a=new X_(i.type,i.attrs,pr.none,!0,n.topMatch||i.type.contentMatch,s):r?a=new X_(null,null,pr.none,!0,null,s):a=new X_(e.schema.topNodeType,null,pr.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&pj?"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,`
  8143. `);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;rJ.hasOwnProperty(s)&&this.parser.normalizeLists&&Gze(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:Vze.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(nJ.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(`
  8144. `),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=pr.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):S7(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=v7(e,a,s.options);s.options&g0&&s.content.length==0&&(l|=g0);let c=pr.none;return r=r.filter(u=>(s.type?s.type.allowsMarkType(u.type):S7(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 Gze(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&rJ.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Wze(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function w7(t){let e={};for(let n in t)e[n]=t[n];return e}function S7(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=tk(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}=j1(tk(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&&j1(tk(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return j1(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=M7(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return M7(e.marks)}}function M7(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function tk(t){return t.document||window.document}const E7=new WeakMap;function qze(t){let e=E7.get(t);return e===void 0&&E7.set(t,e=Kze(t)),e}function Kze(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 j1(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=qze(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:b}=j1(t,g,n,r);if(c.appendChild(p),b){if(l)throw new RangeError("Multiple content holes");l=b}}}return{dom:c,contentDOM:l}}const iJ=65535,aJ=Math.pow(2,16);function Xze(t,e){return t+e*aJ}function A7(t){return t&iJ}function Yze(t){return(t-(t&iJ))/aJ}const sJ=1,oJ=2,R1=4,lJ=8;class gj{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&lJ)>0}get deletedBefore(){return(this.delInfo&(sJ|R1))>0}get deletedAfter(){return(this.delInfo&(oJ|R1))>0}get deletedAcross(){return(this.delInfo&R1)>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=A7(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+Yze(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 b=e==(n<0?c:f)?null:Xze(l/3,e-c),v=e==c?oJ:e==f?sJ:R1;return(n<0?e!=c:e!=f)&&(v|=lJ),new gj(p,v,b)}i+=d-u}return r?e+i:new gj(e+i,0,null)}touches(e,n){let r=0,i=A7(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 gj(e,i,null)}}const nk=Object.create(null);class Aa{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=nk[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 nk)throw new RangeError("Duplicate use of step JSON ID "+e);return nk[e]=n,n.prototype.jsonID=e,n}}class hi{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new hi(e,null)}static fail(e){return new hi(null,e)}static fromReplace(e,n,r,i){try{return hi.ok(e.replace(n,r,i))}catch(a){if(a instanceof sS)return hi.fail(a.message);throw a}}}function JO(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(JO(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return vt.fromArray(r)}class ad extends Aa{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 Dt(JO(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 hi.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 ad(n.pos,r.pos,this.mark)}merge(e){return e instanceof ad&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ad(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 ad(n.from,n.to,e.markFromJSON(n.mark))}}Aa.jsonID("addMark",ad);class zo extends Aa{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 Dt(JO(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return hi.fromReplace(e,this.from,this.to,r)}invert(){return new ad(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))}}Aa.jsonID("removeMark",zo);class sd extends Aa{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return hi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return hi.fromReplace(e,this.pos,this.pos+1,new Dt(vt.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 sd(this.pos,n.marks[i]);return new sd(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 sd(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 sd(n.pos,e.markFromJSON(n.mark))}}Aa.jsonID("addNodeMark",sd);class _f extends Aa{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return hi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return hi.fromReplace(e,this.pos,this.pos+1,new Dt(vt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new sd(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))}}Aa.jsonID("removeNodeMark",_f);class Hi extends Aa{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&xj(e,this.from,this.to)?hi.fail("Structure replace would overwrite content"):hi.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 Hi(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 Hi(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Hi)||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?Dt.empty:new Dt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Hi(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?Dt.empty:new Dt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Hi(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 Hi(n.from,n.to,Dt.fromJSON(e,n.slice),!!n.structure)}}Aa.jsonID("replace",Hi);class Vi extends Aa{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&&(xj(e,this.from,this.gapFrom)||xj(e,this.gapTo,this.to)))return hi.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return hi.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?hi.fromReplace(e,this.from,this.to,r):hi.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 Vi(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 Vi(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 Vi(n.from,n.to,n.gapFrom,n.gapTo,Dt.fromJSON(e,n.slice),n.insert,!!n.structure)}}Aa.jsonID("replaceAround",Vi);function xj(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 Zze(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),b=r.addToSet(f);for(let v=0;v<f.length;v++)f[v].isInSet(b)||(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 ad(g,p,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function Qze(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 dE){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 b=i[p];b.step==a-1&&f.eq(i[p].style)&&(g=b)}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 eL(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 Hi(l,d,Dt.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,b;for(;g=p.exec(u.text);)b||(b=new Dt(vt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),s.push(new Hi(l+g.index,l+g.index+g[0].length,b))}}l=d}if(!r.validEnd){let c=r.fillBefore(vt.empty,!0);t.replace(l,l,new Dt(c,0,0))}for(let c=s.length-1;c>=0;c--)t.step(s[c])}function Jze(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||!Jze(s,l,c))break;l&&(i=1),c<s.childCount&&(a=1)}return null}function eBe(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=vt.empty,f=0;for(let b=a,v=!1;b>n;b--)v||r.index(b)>0?(v=!0,d=vt.from(r.node(b).copy(d)),f++):c--;let g=vt.empty,p=0;for(let b=a,v=!1;b>n;b--)v||i.after(b+1)<i.end(b)?(v=!0,g=vt.from(i.node(b).copy(g)),p++):u++;t.step(new Vi(c,u,s,l,new Dt(d.append(g),f,p),d.size-f,!0))}function tL(t,e,n=null,r=t){let i=tBe(t,e),a=i&&nBe(r,e);return a?i.map(T7).concat({type:e,attrs:n}).concat(a.map(T7)):null}function T7(t){return{type:t,attrs:null}}function tBe(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 nBe(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 rBe(t,e,n){let r=vt.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=vt.from(n[s].type.create(n[s].attrs,r))}let i=e.start,a=e.end;t.step(new Vi(i,a,i,a,new Dt(r,0,0),n.length,!0))}function iBe(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)&&aBe(t.doc,t.mapping.slice(a).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",b=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!b?u=!1:!p&&b&&(u=!0)}u===!1&&uJ(t,s,l,a),eL(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 Vi(f,g,f+1,g-1,new Dt(vt.from(r.create(c,null,s.marks)),0,0),1,!0)),u===!0&&cJ(t,s,l,a),!1}})}function cJ(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 uJ(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(`
  8145. `))}})}function aBe(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function sBe(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 Vi(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Dt(vt.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),b=r&&r[d+1];b&&(p=p.replaceChild(0,b.type.create(b.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 oBe(t,e,n=1,r){let i=t.doc.resolve(e),a=vt.empty,s=vt.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=vt.from(i.node(l).copy(a));let d=r&&r[u];s=vt.from(d?d.type.create(d.attrs,s):i.node(l).copy(s))}t.step(new Hi(e,e,new Dt(a.append(s),n,n),!0))}function Fd(t,e){let n=t.resolve(e),r=n.index();return dJ(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function lBe(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 dJ(t,e){return!!(t&&e&&!t.isLeaf&&lBe(t,e))}function hE(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&&dJ(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 cBe(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);uJ(t,d.node(),d.before(),l)}s.inlineContent&&eL(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 Hi(u,c.map(e+n,-1),Dt.empty,!0)),r===!0){let d=t.doc.resolve(u);cJ(t,d.node(),d.before(),t.steps.length)}return t}function uBe(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 hJ(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 fE(t,e,n=e,r=Dt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return fJ(i,a,r)?new Hi(e,n,r):new dBe(i,a,r).fit()}function fJ(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class dBe{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=vt.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=vt.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 Dt(a,s,l);return e>-1?new Vi(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Hi(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=rk(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(vt.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=rk(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Dt(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=rk(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Dt(Jx(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Dt(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),x=f.matchType(v.type);if(!x)break;u++,(u>1||c==0||v.content.size)&&(f=x,d.push(mJ(v.mark(g.allowedMarks(v.marks)),u==1?c:0,u==l.childCount?p:-1)))}let b=u==l.childCount;b||(p=-1),this.placed=e0(this.placed,n,vt.from(d)),this.frontier[n].match=f,b&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let v=0,x=l;v<p;v++){let y=x.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),x=y.content}this.unplaced=b?e==0?Dt.empty:new Dt(Jx(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new Dt(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||!ik(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=ik(e,n,i,r,a);if(s){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=ik(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,vt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(vt.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 rk(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function mJ(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,mJ(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(vt.empty,!0)))),t.copy(r)}function ik(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&&!hBe(n,a.content,s)?l:null}function hBe(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function fBe(t){return t.spec.defining||t.spec.definingForContent}function mBe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(fJ(i,a,r))return t.step(new Hi(e,n,r));let s=gJ(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 b=i.node(g).type.spec;if(b.defining||b.definingAsContext||b.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 b=g.firstChild;if(u.push(b),p==r.openStart)break;g=b.content}for(let g=d-1;g>=0;g--){let p=u[g],b=fBe(p.type);if(b&&!p.sameMarkup(i.node(Math.abs(l)-1)))d=g;else if(b||!p.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let p=(g+d+1)%(r.openStart+1),b=u[p];if(b)for(let v=0;v<s.length;v++){let x=s[(v+c)%s.length],y=!0;x<0&&(y=!1,x=-x);let E=i.node(x-1),w=i.index(x-1);if(E.canReplaceWith(w,w,b.type,b.marks))return t.replace(i.before(x),y?a.after(x):n,new Dt(pJ(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 pJ(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(pJ(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(vt.empty,!0))}return t}function pBe(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=uBe(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Dt(vt.from(r),0,0))}function gBe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=gJ(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 gJ(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 Aa{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 hi.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 hi.fromReplace(e,this.pos,this.pos+1,new Dt(vt.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)}}Aa.jsonID("attr",_p);class hb extends Aa{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 hi.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)}}Aa.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 xJ{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=Dt.empty){let i=fE(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Dt(vt.from(r),0,0))}delete(e,n){return this.replace(e,n,Dt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return mBe(this,e,n,r),this}replaceRangeWith(e,n,r){return pBe(this,e,n,r),this}deleteRange(e,n){return gBe(this,e,n),this}lift(e,n){return eBe(this,e,n),this}join(e,n=1){return cBe(this,e,n),this}wrap(e,n){return rBe(this,e,n),this}setBlockType(e,n=e,r,i=null){return iBe(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return sBe(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 sd(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 pr)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 oBe(this,e,n,r),this}addMark(e,n,r){return Zze(this,e,n,r),this}removeMark(e,n,r){return Qze(this,e,n,r),this}clearIncompatible(e,n,r){return eL(this,e,n,r),this}}const ak=Object.create(null);class yn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new xBe(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=Dt.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?Dt.empty:n),l==0&&k7(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),k7(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new en(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=ak[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 ak)throw new RangeError("Duplicate use of selection JSON ID "+e);return ak[e]=n,n.prototype.jsonID=e,n}getBookmark(){return en.between(this.$anchor,this.$head).getBookmark()}}yn.prototype.visible=!0;class xBe{constructor(e,n){this.$from=e,this.$to=n}}let N7=!1;function C7(t){!N7&&!t.parent.inlineContent&&(N7=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class en extends yn{constructor(e,n=e){C7(e),C7(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 yn.near(r);let i=e.resolve(n.map(this.anchor));return new en(i.parent.inlineContent?i:r,r)}replace(e,n=Dt.empty){if(super.replace(e,n),n==Dt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof en&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new mE(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 en(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=yn.findFrom(n,r,!0)||yn.findFrom(n,-r,!0);if(a)n=a.$head;else return yn.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(yn.findFrom(e,-r,!0)||yn.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new en(e,n)}}yn.jsonID("text",en);class mE{constructor(e,n){this.anchor=e,this.head=n}map(e){return new mE(e.map(this.anchor),e.map(this.head))}resolve(e){return en.between(e.resolve(this.anchor),e.resolve(this.head))}}class qt extends yn{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?yn.near(a):new qt(a)}content(){return new Dt(vt.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 nL(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;yn.jsonID("node",qt);class nL{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new mE(r,r):new nL(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&qt.isSelectable(r)?new qt(n):yn.near(n)}}class js extends yn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Dt.empty){if(n==Dt.empty){e.delete(0,e.doc.content.size);let r=yn.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 bBe}}yn.jsonID("all",js);const bBe={map(){return this},resolve(t){return new js(t)}};function ep(t,e,n,r,i,a=!1){if(e.inlineContent)return en.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 k7(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Hi||i instanceof Vi))return;let a=t.mapping.maps[r],s;a.forEach((l,c,u,d)=>{s==null&&(s=d)}),t.setSelection(yn.near(t.doc.resolve(s),n))}const P7=1,Y_=2,j7=4;class yBe extends xJ{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|P7)&~Y_,this.storedMarks=null,this}get selectionSet(){return(this.updated&P7)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Y_,this}ensureMarks(e){return pr.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)||pr.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(yn.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|=j7,this}get scrolledIntoView(){return(this.updated&j7)>0}}function R7(t,e){return!e||!t?t:t.bind(e)}class t0{constructor(e,n,r){this.name=e,this.init=R7(n.init,r),this.apply=R7(n.apply,r)}}const vBe=[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||yn.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 sk{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=vBe.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 yBe(this)}static create(e){let n=new sk(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 sk(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 sk(e.schema,e.plugins),a=new up(i);return i.fields.forEach(s=>{if(s.name=="doc")a.doc=md.fromJSON(e.schema,n.doc);else if(s.name=="selection")a.selection=yn.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 bJ(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=bJ(i,e,{})),n[r]=i}return n}class Fr{constructor(e){this.spec=e,this.props={},e.props&&bJ(e.props,this,this.props),this.key=e.key?e.key.key:yJ("plugin")}getState(e){return e[this.key]}}const ok=Object.create(null);function yJ(t){return t in ok?t+"$"+ ++ok[t]:(ok[t]=0,t+"$")}class Pi{constructor(e="key"){this.key=yJ(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const rL=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function vJ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const _J=(t,e,n)=>{let r=vJ(t,n);if(!r)return!1;let i=iL(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(kJ(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=fE(t.doc,r.before(s),r.after(s),Dt.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(Kp(a,"end")?yn.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},_Be=(t,e,n)=>{let r=vJ(t,n);if(!r)return!1;let i=iL(r);return i?wJ(t,i,e):!1},wBe=(t,e,n)=>{let r=MJ(t,n);if(!r)return!1;let i=aL(r);return i?wJ(t,i,e):!1};function wJ(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=fE(t.doc,a,c,Dt.empty);if(!u||u.from!=a||u instanceof Hi&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(en.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 SJ=(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=iL(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 iL(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 MJ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const EJ=(t,e,n)=>{let r=MJ(t,n);if(!r)return!1;let i=aL(r);if(!i)return!1;let a=i.nodeAfter;if(kJ(t,i,e,1))return!0;if(r.parent.content.size==0&&(Kp(a,"start")||qt.isSelectable(a))){let s=fE(t.doc,r.before(),r.after(),Dt.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=t.tr.step(s);l.setSelection(Kp(a,"start")?yn.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},AJ=(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=aL(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 aL(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 SBe=(t,e)=>{let n=t.selection,r=n instanceof qt,i;if(r){if(n.node.isTextblock||!Fd(t.doc,n.from))return!1;i=n.from}else if(i=hE(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},MBe=(t,e)=>{let n=t.selection,r;if(n instanceof qt){if(n.node.isTextblock||!Fd(t.doc,n.to))return!1;r=n.to}else if(r=hE(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},EBe=(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)},TJ=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
  8146. `).scrollIntoView()),!0)};function sL(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 ABe=(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=sL(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(yn.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},NJ=(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=sL(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(en.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},CJ=(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 TBe(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=sL(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 en||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)),b=d.doc.resolve(p);l&&r.node(s-1).canReplaceWith(b.index(),b.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(s)),l)}return n&&n(d.scrollIntoView()),!0}}const NBe=TBe(),CBe=(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 kBe(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||Fd(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function kJ(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,s,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&kBe(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,b=vt.empty;for(let y=s.length-1;y>=0;y--)b=vt.from(s[y].create(null,b));b=vt.from(i.copy(b));let v=t.tr.step(new Vi(e.pos-1,p,e.pos,p,new Dt(b,1,0),s.length,!0)),x=v.doc.resolve(p+2*s.length);x.nodeAfter&&x.nodeAfter.type==i.type&&Fd(v.doc,x.pos)&&v.join(x.pos),n(v.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:yn.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,b=[];for(;b.push(p),!p.isTextblock;)p=p.lastChild;let v=a,x=1;for(;!v.isTextblock;v=v.firstChild)x++;if(p.canReplace(p.childCount,p.childCount,v.content)){if(n){let y=vt.empty;for(let w=b.length-1;w>=0;w--)y=vt.from(b[w].copy(y));let E=t.tr.step(new Vi(e.pos-b.length,e.pos+a.nodeSize,e.pos+x,e.pos+a.nodeSize-x,new Dt(y,b.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function PJ(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(en.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const PBe=PJ(-1),jBe=PJ(1);function RBe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,s=i.blockRange(a),l=s&&tL(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function D7(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 oL(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}oL(rL,_J,SJ);oL(rL,EJ,AJ);oL(TJ,NJ,CJ,NBe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function DBe(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 OBe(l,s,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function OBe(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 lS(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new lS(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=tL(a,n,r,e);return l?(t&&LBe(t,e,l,i,n),!0):!1}function LBe(t,e,n,r,i){let a=vt.empty;for(let d=n.length-1;d>=0;d--)a=vt.from(n[d].type.create(n[d].attrs,a));t.step(new Vi(e.start-(r?2:0),e.end,e.start,e.end,new Dt(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 IBe(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?FBe(e,n,t,a):UBe(e,n,a):!0:!1}}function FBe(t,e,n,r){let i=t.tr,a=r.end,s=r.$to.end(r.depth);a<s&&(i.step(new Vi(a-1,s,a,s,new Dt(vt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new lS(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 Fd(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function UBe(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,b=n.endIndex-1,v=n.startIndex;b>v;b--)p-=i.child(b).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?vt.empty:vt.from(i))))return!1;let f=a.pos,g=f+s.nodeSize;return r.step(new Vi(f-(l?1:0),g+(c?1:0),f+1,g-1,new Dt((l?vt.empty:vt.from(i.copy(vt.empty))).append(c?vt.empty:vt.from(i.copy(vt.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function zBe(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=vt.from(u?t.create():null),f=new Dt(vt.from(t.create(null,vt.from(l.type.create(null,d)))),u?3:1,0),g=a.start,p=a.end;n(e.tr.step(new Vi(g-(u?3:1),p,g,p,f,1,!0)).scrollIntoView())}return!0}}const la=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 bj=null;const bc=function(t,e,n){let r=bj||(bj=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},BBe=function(){bj=null},wf=function(t,e,n,r){return n&&(O7(t,e,n,r,-1)||O7(t,e,n,r,1))},HBe=/^(img|br|input|textarea|hr)$/i;function O7(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:so(t))){let s=t.parentNode;if(!s||s.nodeType!=1||cy(t)||HBe.test(t.nodeName)||t.contentEditable=="false")return!1;e=la(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?so(t):0}else return!1}}function so(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function $Be(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=so(t)}else if(t.parentNode&&!cy(t))e=la(t),t=t.parentNode;else return null}}function VBe(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=la(t)+1,t=t.parentNode;else return null}}function GBe(t,e,n){for(let r=e==0,i=e==so(t);r||i;){if(t==n)return!0;let a=la(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==so(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 pE=function(t){return t.focusNode&&wf(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Ah(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function WBe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function qBe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(so(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(so(r.startContainer),r.startOffset)}}}const Nl=typeof navigator<"u"?navigator:null,L7=typeof document<"u"?document:null,Ud=Nl&&Nl.userAgent||"",yj=/Edge\/(\d+)/.exec(Ud),jJ=/MSIE \d/.exec(Ud),vj=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ud),as=!!(jJ||vj||yj),pd=jJ?document.documentMode:vj?+vj[1]:yj?+yj[1]:0,mo=!as&&/gecko\/(\d+)/i.test(Ud);mo&&+(/Firefox\/(\d+)/.exec(Ud)||[0,0])[1];const _j=!as&&/Chrome\/(\d+)/.exec(Ud),_a=!!_j,RJ=_j?+_j[1]:0,Ua=!as&&!!Nl&&/Apple Computer/.test(Nl.vendor),Yp=Ua&&(/Mobile\/\w+/.test(Ud)||!!Nl&&Nl.maxTouchPoints>2),eo=Yp||(Nl?/Mac/.test(Nl.platform):!1),KBe=Nl?/Win/.test(Nl.platform):!1,kc=/Android \d/.test(Ud),uy=!!L7&&"webkitFontSmoothing"in L7.documentElement.style,XBe=uy?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function YBe(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 ZBe(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 I7(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?YBe(a):ZBe(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,b=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let v=l.scrollLeft-p,x=l.scrollTop-b;e={left:e.left-v,top:e.top-x,right:e.right-v,bottom:e.bottom-x}}let g=c?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(g))break;s=g=="absolute"?s.offsetParent:Xp(s)}}function QBe(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:DJ(t.dom)}}function DJ(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 JBe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;OJ(n,r==0?0:r-e)}function OJ(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 e8e(t){if(t.setActive)return t.setActive();if(qm)return t.focus(qm);let e=DJ(t);t.focus(qm==null?{get preventScroll(){return qm={preventScroll:!0},!0}}:void 0),qm||(qm=!1,OJ(e,0))}function LJ(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 b=g[p];if(b.top<=s&&b.bottom>=l){s=Math.max(b.bottom,s),l=Math.min(b.top,l);let v=b.left>e.left?b.left-e.left:b.right<e.left?e.left-b.right:0;if(v<r){n=d,r=v,i=v&&n.nodeType==3?{left:b.right<e.left?b.right:b.left,top:e.top}:e,d.nodeType==1&&v&&(a=f+(e.left>=(b.left+b.right)/2?1:0));continue}}else b.top>e.top&&!c&&b.left<=e.left&&b.right>=e.left&&(c=d,u={left:Math.max(b.left,Math.min(b.right,e.left)),top:b.top});!n&&(e.left>=b.right&&e.top>=b.top||e.left>=b.left&&e.top>=b.bottom)&&(a=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?t8e(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:LJ(n,i)}function t8e(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=Hu(r,1);if(a.top!=a.bottom&&lL(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function lL(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function n8e(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function r8e(t,e,n){let{node:r,offset:i}=LJ(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 i8e(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 IJ(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(lL(e,u))return IJ(s,e,u)}}if((a=(a+1)%r)==i)break}return t}function a8e(t,e){let n=t.dom.ownerDocument,r,i=0,a=qBe(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(!lL(e,u)||(s=IJ(t.dom,e,u),!s))return null}if(Ua)for(let u=s;r&&u;u=Xp(u))u.draggable&&(r=void 0);if(s=n8e(s,e),r){if(mo&&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=i8e(t,r,i,e))}l==null&&(l=r8e(t,s,e));let c=t.docView.nearestDesc(s,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function F7(t){return t.top<t.bottom||t.left<t.right}function Hu(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(F7(r))return r}return Array.prototype.find.call(n,F7)||t.getBoundingClientRect()}const s8e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function FJ(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),s=uy||mo;if(r.nodeType==3)if(s&&(s8e.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=Hu(bc(r,i,i),n);if(mo&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Hu(bc(r,i-1,i-1),-1);if(u.top==c.top){let d=Hu(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(Hu(bc(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==so(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return lk(c.getBoundingClientRect(),!1)}if(a==null&&i<so(r)){let c=r.childNodes[i];if(c.nodeType==1)return lk(c.getBoundingClientRect(),!0)}return lk(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==so(r))){let c=r.childNodes[i-1],u=c.nodeType==3?bc(c,so(c)-(s?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Hx(Hu(u,1),!1)}if(a==null&&i<so(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(Hu(u,-1),!0)}return Hx(Hu(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 lk(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 UJ(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 o8e(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return UJ(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=FJ(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 l8e=/[\u0590-\u08ac]/;function c8e(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?!l8e.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:s:UJ(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:b,focusOffset:v}=t.domSelectionRange(),x=b&&!p.contains(b.nodeType==1?b:b.parentNode)||c==b&&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),x}):r.pos==r.start()||r.pos==r.end()}let U7=null,z7=null,B7=!1;function u8e(t,e,n){return U7==e&&z7==n?B7:(U7=e,z7=n,B7=n=="up"||n=="down"?o8e(t,e,n):c8e(t,e,n))}const po=0,H7=1,jh=2,Cl=3;class dy{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=po,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>la(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 BJ){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 zJ&&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?la(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?la(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=la(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=la(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,b=0;p<this.children.length;p++){let v=this.children[p],x=b+v.size;if(a>b&&s<x)return v.setSelection(e-b-v.border,n-b-v.border,r,i);b=x}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((mo||Ua)&&e==n){let{node:p,offset:b}=l;if(p.nodeType==3){if(f=!!(b&&p.nodeValue[b-1]==`
  8147. `),f&&b==p.nodeValue.length)for(let v=p,x;v;v=v.parentNode){if(x=v.nextSibling){x.nodeName=="BR"&&(l=c={node:x.parentNode,offset:la(x)+1});break}let y=v.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let v=p.childNodes[b-1];f=v&&(v.nodeName=="BR"||v.contentEditable=="false")}}if(mo&&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&&Ua)&&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&&mo)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),g=!0}catch{}}if(!g){if(e>n){let b=l;l=c,c=b}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?jh:H7,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?jh:Cl}r=s}this.dirty=jh}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?jh:H7;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class zJ 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==po&&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 d8e 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!=po){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=po}}slice(e,n,r){let i=Sf.create(this.parent,this.mark,!0,r),a=this.children,s=this.size;n<s&&(a=Sj(a,n,s,r)),e>0&&(a=Sj(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 gd 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=VJ(d,r,n),u?c=new h8e(e,n,r,i,d,f||null,g,u,a,s+1):n.isText?new gE(e,n,r,i,d,g,a):new gd(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=()=>vt.empty)}return e}matchesNode(e,n,r){return this.dirty==po&&e.eq(this.node)&&uS(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 m8e(this,s&&s.node,e);x8e(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?pr.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==jh)&&(s&&this.protectLocalComposition(e,s),HJ(this.contentDOM,this.children,e),Yp&&b8e(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof en)||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=y8e(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 d8e(this,a,n,i);e.input.compositionNodes.push(s),this.children=Sj(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=po}updateOuterDeco(e){if(uS(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=$J(this.dom,this.nodeDOM,wj(this.outerDeco,this.node,n),wj(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 $7(t,e,n,r,i){VJ(r,e,t);let a=new gd(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class gE extends gd{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!=po&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=po||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=po,!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 gE(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 BJ extends dy{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==po&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class h8e extends gd{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 HJ(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=V7(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(s instanceof Sf){let c=r?r.previousSibling:t.lastChild;HJ(s.contentDOM,s.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=V7(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const x0=function(t){t&&(this.nodeName=t)};x0.prototype=Object.create(null);const Rh=[new x0];function wj(t,e,n){if(t.length==0)return Rh;let r=n?Rh[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 $J(t,e,n,r){if(n==Rh&&r==Rh)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=Rh[0]),i=c}f8e(i,l||Rh[0],s)}return i}function f8e(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 VJ(t,e,n){return $J(t,t,Rh,wj(e,n,t.nodeType!=1))}function uS(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 V7(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class m8e{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=p8e(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=po,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=jh),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 gd){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&&uS(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=jh,f.updateChildren(i,s+1),f.dirty=po),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)||!uS(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=gd.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=gd.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 zJ(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 gE)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ua||_a)&&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 BJ(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 p8e(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 g8e(t,e){return t.type.side-e.type.side}function x8e(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 x=i[s++];x.widget&&(d?(f||(f=[d])).push(x):d=x)}if(d)if(f){f.sort(g8e);for(let x=0;x<f.length;x++)n(f[x],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 x=0;x<l.length;x++)l[x].to<=a&&l.splice(x--,1);for(;s<i.length&&i[s].from<=a&&i[s].to>a;)l.push(i[s++]);let b=a+g.nodeSize;if(g.isText){let x=b;s<i.length&&i[s].from<x&&(x=i[s].from);for(let y=0;y<l.length;y++)l[y].to<x&&(x=l[y].to);x<b&&(c=g.cut(x-a),g=g.cut(0,x-a),b=x,p=-1)}else for(;s<i.length&&i[s].to<b;)s++;let v=g.isInline&&!g.isLeaf?l.filter(x=>!x.inline):l.slice();r(g,v,e.forChild(a,g),p),a=b}}function b8e(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 y8e(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 Sj(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 cL(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(pE(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&&GBe(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 b=n.getRangeAt(p);f=Math.min(f,t.docView.posFromDOM(b.startContainer,b.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(b.endContainer,b.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=uL(t,d,l,f)}return u}function GJ(t){return t.editable?t.hasFocus():qJ(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Fc(t,e=!1){let n=t.state.selection;if(WJ(t,n),!!GJ(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&_a){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)_8e(t);else{let{anchor:r,head:i}=n,a,s;G7&&!(n instanceof en)&&(n.$from.parent.inlineContent||(a=W7(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=W7(t,n.to))),t.docView.setSelection(r,i,t,e),G7&&(a&&q7(a),s&&q7(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&v8e(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const G7=Ua||_a&&RJ<63;function W7(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(Ua&&i&&i.contentEditable=="false")return ck(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return ck(i);if(a)return ck(a)}}function ck(t){return t.contentEditable="true",Ua&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function q7(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function v8e(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(()=>{(!GJ(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function _8e(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,la(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&as&&pd<=11&&(n.disabled=!0,n.disabled=!1)}function WJ(t,e){if(e instanceof qt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(K7(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else K7(t)}function K7(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function uL(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||en.between(e,n,r)}function X7(t){return t.editable&&!t.hasFocus()?!1:qJ(t)}function qJ(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 w8e(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 Mj(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&&yn.findFrom(a,e)}function qu(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Y7(t,e,n){let r=t.state.selection;if(r instanceof en)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 qu(t,new en(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Mj(t.state,e);return i&&i instanceof qt?qu(t,i):!1}else if(!(eo&&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)?qu(t,new qt(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):uy?qu(t,new en(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof qt&&r.node.isInline)return qu(t,new en(e>0?r.$to:r.$from));{let i=Mj(t.state,e);return i?qu(t,i):!1}}}function dS(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?S8e(t):M8e(t)}function S8e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,s=!1;for(mo&&n.nodeType==1&&r<dS(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(KJ(n))break;{let l=n.previousSibling;for(;l&&b0(l,-1);)i=n.parentNode,a=la(l),l=l.previousSibling;if(l)n=l,r=dS(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?Ej(t,n,r):i&&Ej(t,i,a)}function M8e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=dS(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(KJ(n))break;{let l=n.nextSibling;for(;l&&b0(l,1);)a=l.parentNode,s=la(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=dS(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&Ej(t,a,s)}function KJ(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function E8e(t,e){for(;t&&e==t.childNodes.length&&!cy(t);)e=la(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 A8e(t,e){for(;t&&!e&&!cy(t);)e=la(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 Ej(t,e,n){if(e.nodeType!=3){let a,s;(s=E8e(e,n))?(e=s,n=0):(a=A8e(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(pE(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 Z7(t,e){let n=t.state.doc.resolve(e);if(!(_a||KBe)&&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 Q7(t,e,n){let r=t.state.selection;if(r instanceof en&&!r.empty||n.indexOf("s")>-1||eo&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Mj(t.state,e);if(s&&s instanceof qt)return qu(t,s)}if(!i.parent.inlineContent){let s=e<0?i:a,l=r instanceof js?yn.near(s,e):yn.findFrom(s,e);return l?qu(t,l):!1}return!1}function J7(t,e){if(!(t.state.selection instanceof en))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 eG(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function T8e(t){if(!Ua||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;eG(t,r,"true"),setTimeout(()=>eG(t,r,"false"),20)}return!1}function N8e(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function C8e(t,e){let n=e.keyCode,r=N8e(e);if(n==8||eo&&n==72&&r=="c")return J7(t,-1)||Km(t,-1);if(n==46&&!e.shiftKey||eo&&n==68&&r=="c")return J7(t,1)||Km(t,1);if(n==13||n==27)return!0;if(n==37||eo&&n==66&&r=="c"){let i=n==37?Z7(t,t.state.selection.from)=="ltr"?-1:1:-1;return Y7(t,i,r)||Km(t,i)}else if(n==39||eo&&n==70&&r=="c"){let i=n==39?Z7(t,t.state.selection.from)=="ltr"?1:-1:1;return Y7(t,i,r)||Km(t,i)}else{if(n==38||eo&&n==80&&r=="c")return Q7(t,-1,r)||Km(t,-1);if(n==40||eo&&n==78&&r=="c")return T8e(t)||Q7(t,1,r)||Km(t,1);if(r==(eo?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function dL(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=eee(),c=l.createElement("div");c.appendChild(s.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=JJ[u.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let b=l.createElement(d[p]);for(;c.firstChild;)b.appendChild(c.firstChild);c.appendChild(b),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,`
  8148. `);return{dom:c,text:g,slice:e}}function XJ(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 Dt(vt.from(t.state.schema.text(e.replace(/\r\n?/g,`
  8149. `))),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,b=kf.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let x=s.appendChild(document.createElement("p"));v&&x.appendChild(b.serializeNode(p.text(v,g)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=R8e(n),uy&&D8e(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&&!k8e.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)l=O8e(tG(l,+d[1],+d[2]),d[4]);else if(l=Dt.maxOpen(P8e(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=tG(l,f,g)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const k8e=/^(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 P8e(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&&ZJ(c,a,l,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=QJ(s[s.length-1],a.length));let d=YJ(l,c);s.push(d),i=i.matchType(d.type),a=c}}),s)return vt.from(s)}return t}function YJ(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,vt.from(t));return t}function ZJ(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=ZJ(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(vt.from(YJ(n,t,i+1))))}}function QJ(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,QJ(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(vt.empty,!0);return t.copy(n.append(r))}function Aj(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=Aj(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(vt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function tG(t,e,n){return e<t.openStart&&(t=new Dt(Aj(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Dt(Aj(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const JJ={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 nG=null;function eee(){return nG||(nG=document.implementation.createHTMLDocument("title"))}let uk=null;function j8e(t){let e=window.trustedTypes;return e?(uk||(uk=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),uk.createHTML(t)):t}function R8e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=eee().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&JJ[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=j8e(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function D8e(t){let e=t.querySelectorAll(_a?"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 O8e(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=vt.from(c.create(r[l+1],i)),a++,s++}return new Dt(i,a,s)}const za={},Ba={},L8e={touchstart:!0,touchmove:!0};class I8e{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 F8e(t){for(let e in za){let n=za[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{z8e(t,r)&&!hL(t,r)&&(t.editable||!(r.type in Ba))&&n(t,r)},L8e[e]?{passive:!0}:void 0)}Ua&&t.dom.addEventListener("input",()=>null),Tj(t)}function od(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function U8e(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 Tj(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>hL(t,r))})}function hL(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function z8e(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 B8e(t,e){!hL(t,e)&&za[e.type]&&(t.editable||!(e.type in Ba))&&za[e.type](t,e)}Ba.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!nee(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(kc&&_a&&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,Ah(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||C8e(t,n)?n.preventDefault():od(t,"key")};Ba.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ba.keypress=(t,e)=>{let n=e;if(nee(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||eo&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof en)||!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 xE(t){return{left:t.clientX,top:t.clientY}}function H8e(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function fL(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 $8e(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 V8e(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 G8e(t,e,n,r,i){return fL(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?V8e(t,n):$8e(t,n))}function W8e(t,e,n,r){return fL(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function q8e(t,e,n,r){return fL(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||K8e(t,n,r)}function K8e(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(wp(t,en.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,en.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 mL(t){return hS(t)}const tee=eo?"metaKey":"ctrlKey";za.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=mL(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&H8e(n,t.input.lastClick)&&!n[tee]&&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(xE(n));s&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new X8e(t,s,n,!!r)):(a=="doubleClick"?W8e:q8e)(t,s.pos,s.inside,n)?n.preventDefault():od(t,"pointer"))};class X8e{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[tee],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&&mo&&!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)),od(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(xE(e))),this.updateAllowDefault(e),this.allowDefault||!n?od(this.view,"pointer"):G8e(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ua&&this.mightDrag&&!this.mightDrag.node.isAtom||_a&&!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,yn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):od(this.view,"pointer")}move(e){this.updateAllowDefault(e),od(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)}}za.touchstart=t=>{t.input.lastTouch=Date.now(),mL(t),od(t,"pointer")};za.touchmove=t=>{t.input.lastTouch=Date.now(),od(t,"pointer")};za.contextmenu=t=>mL(t);function nee(t,e){return t.composing?!0:Ua&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Y8e=kc?5e3:-1;Ba.compositionstart=Ba.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof en&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),hS(t,!0),t.markCursor=null;else if(hS(t,!e.selection.empty),mo&&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}ree(t,Y8e)};Ba.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++,ree(t,20))};function ree(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>hS(t),e))}function iee(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Q8e());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Z8e(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=$Be(e.focusNode,e.focusOffset),r=VBe(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 Q8e(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function hS(t,e=!1){if(!(kc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),iee(t),e||t.docView&&t.docView.dirty){let n=cL(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 J8e(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=as&&pd<15||Yp&&XBe<604;za.copy=Ba.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}=dL(t,s);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):J8e(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function e6e(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function t6e(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=XJ(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||Dt.empty)))return!0;if(!a)return!1;let s=e6e(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 aee(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," "):""}Ba.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,aee(r),r.getData("text/html"),i,n)?n.preventDefault():t6e(t,n)};class see{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const n6e=eo?"altKey":"ctrlKey";function oee(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[n6e]}za.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(xE(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}=dL(t,l);(!n.dataTransfer.files.length||!_a||RJ>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 see(d,oee(t,n),s)};za.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ba.dragover=Ba.dragenter=(t,e)=>e.preventDefault();Ba.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(xE(n));if(!i)return;let a=t.state.doc.resolve(i.pos),s=r&&r.slice;s?t.someProp("transformPasted",b=>{s=b(s,t,!1)}):s=XJ(t,aee(n.dataTransfer),fb?null:n.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&oee(t,n));if(t.someProp("handleDrop",b=>b(t,n,s||Dt.empty,l))){n.preventDefault();return}if(!s)return;n.preventDefault();let c=s?hJ(t.state.doc,a.pos,s):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(l){let{node:b}=r;b?b.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 b=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((v,x,y,E)=>b=E),u.setSelection(uL(t,p,u.doc.resolve(b)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};za.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))};za.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)};za.beforeinput=(t,e)=>{if(_a&&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,Ah(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 Ba)za[t]=Ba[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 fS{constructor(e,n){this.toDOM=e,this.spec=n||Kh,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 Oa(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof fS&&(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 xd{constructor(e,n){this.attrs=e,this.spec=n||Kh}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 Oa(a,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof xd&&pb(this.attrs,e.attrs)&&pb(this.spec,e.spec)}static is(e){return e.type instanceof xd}destroy(){}}class pL{constructor(e,n){this.attrs=e,this.spec=n||Kh}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 Oa(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 pL&&pb(this.attrs,e.attrs)&&pb(this.spec,e.spec)}destroy(){}}class Oa{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Oa(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 Oa(e,e,new fS(n,r))}static inline(e,n,r,i){return new Oa(e,n,new xd(r,i))}static node(e,n,r,i){return new Oa(e,n,new pL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof xd}get widget(){return this.type instanceof fS}}const tp=[],Kh={};class Rr{constructor(e,n){this.local=e.length?e:tp,this.children=n.length?n:tp}static create(e,n){return n.length?mS(n,e,0,Kh):ya}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==ya||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Kh)}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?r6e(this.children,s||[],e,n,r,i,a):s?new Rr(s.sort(Xh),tp):ya}add(e,n){return n.length?this==ya?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=cee(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,mS(d,l,u+1,Kh)),a+=3}});let s=lee(a?uee(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(Xh):this.local,i||this.children)}remove(e){return e.length==0||this==ya?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!=ya?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):ya}forChild(e,n){if(this==ya)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 xd){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(Xh),tp);return r?new Ju([l,r]):l}return r||ya}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 gL(this.localsInner(e))}localsInner(e){if(this==ya)return tp;if(e.inlineContent||!this.local.some(xd.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof xd||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Rr.empty=new Rr([],[]);Rr.removeOverlap=gL;const ya=Rr.empty;class Ju{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Kh));return Ju.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!=ya&&(a instanceof Ju?r=r.concat(a.members):r.push(a))}return Ju.from(r)}eq(e){if(!(e instanceof Ju)||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?gL(r?n:n.sort(Xh)):tp}static from(e){switch(e.length){case 0:return ya;case 1:return e[0];default:return new Ju(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 r6e(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,b,v)=>{let x=v-b-(p-g);for(let y=0;y<l.length;y+=3){let E=l[y+1];if(E<0||g>E+d-f)continue;let w=l[y]+d-f;p>=w?l[y+1]=g<=w?-2:-1:g>=d&&x&&(l[y]+=x,l[y+1]+=x)}f+=x}),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:b,offset:v}=r.content.findIndex(f),x=r.maybeChild(b);if(x&&v==f&&v+x.nodeSize==p){let y=l[u+2].mapInner(n,x,d+1,t[u]+a+1,s);y!=ya?(l[u]=f,l[u+1]=p,l[u+2]=y):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=i6e(l,t,e,n,i,a,s),d=mS(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(Xh),l)}function lee(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 Oa(i.from+e,i.to+e,i.type))}return n}function i6e(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 cee(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 uee(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function mS(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=cee(t,l,c+n);if(u){a=!0;let d=mS(u,l,n+c+1,r);d!=ya&&i.push(c,c+l.nodeSize,d)}});let s=lee(a?uee(t):t,-n).sort(Xh);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):ya}function Xh(t,e){return t.from-e.from||t.to-e.to}function gL(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),rG(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),rG(e,i,r.copy(a.from,r.to)));break}}}return e}function rG(t,e,n){for(;e<t.length&&Xh(n,t[e])>0;)e++;t.splice(e,0,n)}function dk(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ya&&e.push(r)}),t.cursorWrapper&&e.push(Rr.create(t.state.doc,[t.cursorWrapper.deco])),Ju.from(e)}const a6e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},s6e=as&&pd<=11;class o6e{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 l6e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new o6e,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]);as&&pd<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),s6e&&(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,a6e)),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(X7(this.view)){if(this.suppressingSelectionUpdates)return Fc(this.view);if(as&&pd<=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)&&X7(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(mo&&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||d6e(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&&pE(r)&&(u=cL(e))&&u.eq(yn.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),c6e(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(as&&pd<=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?la(i)+1:0,l=r.localPosFromDOM(e.target,s,-1),c=a&&a.parentNode==e.target?la(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 iG=new WeakMap,aG=!1;function c6e(t){if(!iG.has(t)&&(iG.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=mo,aG)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."),aG=!0}}function sG(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 u6e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return sG(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?sG(t,n):null}function d6e(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 h6e(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}],pE(c)||u.push({node:c.focusNode,offset:c.focusOffset})),_a&&t.input.lastKeyCode===8)for(let x=a;x>i;x--){let y=r.childNodes[x-1],E=y.pmViewDesc;if(y.nodeName=="BR"&&!E){a=x;break}if(!E||E.size)break}let f=t.state.doc,g=t.someProp("domParser")||p0.fromSchema(t.state.schema),p=f.resolve(s),b=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:f6e,context:p});if(u&&u[0].pos!=null){let x=u[0].pos,y=u[1]&&u[1].pos;y==null&&(y=x),b={anchor:x+s,head:y+s}}return{doc:v,sel:b,from:s,to:l}}function f6e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ua&&/^(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||Ua&&/^(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 m6e=/^(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 p6e(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=cL(t,N);if(O&&!t.state.selection.eq(O)){if(_a&&kc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",j=>j(t,Ah(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=h6e(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 b=b6e(f.content,u.doc.content,u.from,g,p);if(b&&t.input.domChangeCount++,(Yp&&t.input.lastIOSEnter>Date.now()-225||kc)&&i.some(N=>N.nodeType==1&&!m6e.test(N.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",N=>N(t,Ah(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(r&&c instanceof en&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))b={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let N=oG(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&&b.start==b.endB&&t.state.selection instanceof en&&(b.start>t.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?b.start=t.state.selection.from:b.endA<t.state.selection.to&&b.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),as&&pd<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>u.from&&u.doc.textBetween(b.start-u.from-1,b.start-u.from+1)=="  "&&(b.start--,b.endA--,b.endB--);let v=u.doc.resolveNoCache(b.start-u.from),x=u.doc.resolveNoCache(b.endB-u.from),y=d.resolve(b.start),E=v.sameParent(x)&&v.parent.inlineContent&&y.end()>=b.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(x)||!v.parent.inlineContent)&&v.pos<x.pos&&!/\S/.test(u.doc.textBetween(v.pos,x.pos,"","")))&&t.someProp("handleKeyDown",N=>N(t,Ah(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&x6e(d,b.start,b.endA,v,x)&&t.someProp("handleKeyDown",N=>N(t,Ah(8,"Backspace")))){kc&&_a&&t.domObserver.suppressSelectionUpdates();return}_a&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),kc&&!E&&v.start()!=x.start()&&x.parentOffset==0&&v.depth==x.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==b.endA&&(b.endB-=2,x=u.doc.resolveNoCache(b.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(N){return N(t,Ah(13,"Enter"))})},20));let w=b.start,A=b.endA,T=N=>{let O=N||t.state.tr.replace(w,A,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let k=oG(t,O.doc,u.sel);k&&!(_a&&t.composing&&k.empty&&(b.start!=b.endB||t.input.lastChromeDelete<Date.now()-100)&&(k.head==w||k.head==O.mapping.map(A)-1)||as&&k.empty&&k.head==w)&&O.setSelection(k)}return a&&O.setMeta("composition",a),O.scrollIntoView()},C;if(E)if(v.pos==x.pos){as&&pd<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Fc(t),20));let N=T(t.state.tr.delete(w,A)),O=d.resolve(b.start).marksAcross(d.resolve(b.endA));O&&N.ensureMarks(O),t.dispatch(N)}else if(b.endA==b.endB&&(C=g6e(v.parent.content.cut(v.parentOffset,x.parentOffset),y.parent.content.cut(y.parentOffset,b.endA-y.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()==x.index()-(x.textOffset?0:1)){let N=v.parent.textBetween(v.parentOffset,x.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 oG(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:uL(t,e.resolve(n.anchor),e.resolve(n.head))}function g6e(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(vt.from(u).eq(t))return{mark:l,type:s}}function x6e(t,e,n,r,i){if(n-e<=i.pos-r.pos||hk(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(hk(a,!0,!0));return!s.parent.isTextblock||s.pos>n||hk(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function hk(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 b6e(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&&lG(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&&lG(t.textBetween(a-1,a+1))&&(a+=c?1:-1),s=a+(s-l),l=a}return{start:a,endA:s,endB:l}}function lG(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 dee{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 I8e,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(fG),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=dG(this),uG(this),this.nodeViews=hG(this),this.docView=$7(this.state.doc,cG(this),dk(this),this.dom,this),this.domObserver=new l6e(this,(r,i,a,s)=>p6e(this,r,i,a,s)),this.domObserver.start(),F8e(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&&Tj(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(fG),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&&(iee(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=hG(this);v6e(p,this.nodeViews)&&(this.nodeViews=p,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Tj(this),this.editable=dG(this),uG(this);let c=dk(this),u=cG(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&&QBe(this);if(s){this.domObserver.stop();let p=f&&(as||_a)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&y6e(i.selection,e.selection);if(f){let b=_a?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Z8e(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=$7(e.doc,u,c,this.dom,this)),b&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&w8e(this))?Fc(this,p):(WJ(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&&JBe(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&&I7(this,n.getBoundingClientRect(),e)}else I7(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 see(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(as){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&&e8e(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 a8e(this,e)}coordsAtPos(e,n=1){return FJ(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 u8e(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 dL(this,e)}destroy(){this.docView&&(U8e(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],dk(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,BBe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return B8e(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ua&&this.root.nodeType===11&&WBe(this.dom.ownerDocument)==this.dom&&u6e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}dee.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function cG(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"),[Oa.node(0,t.state.doc.content.size,e)]}function uG(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:Oa.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function dG(t){return!t.someProp("editable",e=>e(t.state)===!1)}function y6e(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 hG(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 v6e(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 fG(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 Pd={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:"'"},pS={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},_6e=typeof navigator<"u"&&/Mac/.test(navigator.platform),w6e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ca=0;ca<10;ca++)Pd[48+ca]=Pd[96+ca]=String(ca);for(var ca=1;ca<=24;ca++)Pd[ca+111]="F"+ca;for(var ca=65;ca<=90;ca++)Pd[ca]=String.fromCharCode(ca+32),pS[ca]=String.fromCharCode(ca);for(var fk in Pd)pS.hasOwnProperty(fk)||(pS[fk]=Pd[fk]);function S6e(t){var e=_6e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||w6e&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?pS:Pd)[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 M6e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),E6e=typeof navigator<"u"&&/Win/.test(navigator.platform);function A6e(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))M6e?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 T6e(t){let e=Object.create(null);for(let n in t)e[A6e(n)]=t[n];return e}function mk(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 N6e(t){return new Fr({props:{handleKeyDown:hee(t)}})}function hee(t){let e=T6e(t);return function(n,r){let i=S6e(r),a,s=e[mk(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[mk(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(E6e&&r.ctrlKey&&r.altKey)&&(a=Pd[r.keyCode])&&a!=i){let l=e[mk(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var C6e=Object.defineProperty,xL=(t,e)=>{for(var n in e)C6e(t,n,{get:e[n],enumerable:!0})};function bE(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 yE=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,(...b)=>{const v=this.buildProps(c,e),x=g(...b)(v);return s.push(x),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:bE({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}},fee={};xL(fee,{blur:()=>k6e,clearContent:()=>P6e,clearNodes:()=>j6e,command:()=>R6e,createParagraphNear:()=>D6e,cut:()=>O6e,deleteCurrentNode:()=>L6e,deleteNode:()=>I6e,deleteRange:()=>F6e,deleteSelection:()=>U6e,enter:()=>z6e,exitCode:()=>B6e,extendMarkRange:()=>H6e,first:()=>$6e,focus:()=>G6e,forEach:()=>W6e,insertContent:()=>q6e,insertContentAt:()=>Y6e,joinBackward:()=>J6e,joinDown:()=>Q6e,joinForward:()=>eHe,joinItemBackward:()=>tHe,joinItemForward:()=>nHe,joinTextblockBackward:()=>rHe,joinTextblockForward:()=>iHe,joinUp:()=>Z6e,keyboardShortcut:()=>sHe,lift:()=>oHe,liftEmptyBlock:()=>lHe,liftListItem:()=>cHe,newlineInCode:()=>uHe,resetAttributes:()=>dHe,scrollIntoView:()=>hHe,selectAll:()=>fHe,selectNodeBackward:()=>mHe,selectNodeForward:()=>pHe,selectParentNode:()=>gHe,selectTextblockEnd:()=>xHe,selectTextblockStart:()=>bHe,setContent:()=>yHe,setMark:()=>IHe,setMeta:()=>FHe,setNode:()=>UHe,setNodeSelection:()=>zHe,setTextDirection:()=>BHe,setTextSelection:()=>HHe,sinkListItem:()=>$He,splitBlock:()=>VHe,splitListItem:()=>GHe,toggleList:()=>WHe,toggleMark:()=>qHe,toggleNode:()=>KHe,toggleWrap:()=>XHe,undoInputRule:()=>YHe,unsetAllMarks:()=>ZHe,unsetMark:()=>QHe,unsetTextDirection:()=>JHe,updateAttributes:()=>e$e,wrapIn:()=>t$e,wrapInList:()=>n$e});var k6e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),P6e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),j6e=()=>({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 b=Mg(p);if(l.type.isTextblock){const{defaultType:v}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,v)}(b||b===0)&&e.lift(p,b)})}),!0},R6e=t=>e=>t(e),D6e=()=>({state:t,dispatch:e})=>NJ(t,e),O6e=(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 en(r.doc.resolve(Math.max(s-1,0)))),!0},L6e=()=>({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 pi(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 I6e=t=>({tr:e,state:n,dispatch:r})=>{const i=pi(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},F6e=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},U6e=()=>({state:t,dispatch:e})=>rL(t,e),z6e=()=>({commands:t})=>t.keyboardShortcut("Enter"),B6e=()=>({state:t,dispatch:e})=>ABe(t,e);function bL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function gS(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:bL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function mee(t,e,n={}){return t.find(r=>r.type===e&&gS(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function mG(t,e,n={}){return!!mee(t,e,n)}function yL(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),!mee([...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&&mG([...t.parent.child(s-1).marks],e,n);)s-=1,l-=t.parent.child(s).nodeSize;for(;c<t.parent.childCount&&mG([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function nu(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 H6e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=nu(t,r.schema),{doc:s,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=yL(c,a,e);if(f&&f.from<=u&&f.to>=d){const g=en.create(s,f.from,f.to);n.setSelection(g)}}return!0},$6e=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 pee(t){return t instanceof en}function Dh(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function gee(t,e=null){if(!e)return null;const n=yn.atStart(t),r=yn.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?en.create(t,Dh(0,i,a),Dh(t.content.size,i,a)):en.create(t,Dh(e,i,a),Dh(e,i,a))}function V6e(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function vL(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var G6e=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const s=()=>{(vL()||V6e())&&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&&!pee(n.state.selection))return s(),!0;const l=gee(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},W6e=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),q6e=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),xee=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&&xee(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 xee(n)}function gb(t,e,n){if(t instanceof md||t instanceof vt)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 vt.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 tJ({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 K6e(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Hi||i instanceof Vi))return;const a=t.mapping.maps[r];let s=0;a.forEach((l,c,u,d)=>{s===0&&(s=d)}),t.setSelection(yn.near(t.doc.resolve(s),n))}var X6e=t=>!("type"in t),Y6e=(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=x=>{a.emit("contentError",{editor:a,error:x,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(x){c(x)}try{l=gb(e,a.schema,{parseOptions:u,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:a.options.enableContentCheck})}catch(x){return c(x),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,p=!0;if((X6e(l)?l:[l]).forEach(x=>{x.check(),g=g?x.isText&&x.marks.length===0:!1,p=p?x.isBlock:!1}),d===f&&p){const{parent:x}=r.doc.resolve(d);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(d-=1,f+=1)}let v;if(g){if(Array.isArray(e))v=e.map(x=>x.text||"").join("");else if(e instanceof vt){let x="";e.forEach(y=>{y.text&&(x+=y.text)}),v=x}else typeof e=="object"&&e&&e.text?v=e.text:v=e;r.insertText(v,d,f)}else{v=l;const x=r.doc.resolve(d),y=x.node(),E=x.parentOffset===0,w=y.isText||y.isTextblock,A=y.content.size>0;E&&w&&A&&(d=Math.max(0,d-1)),r.replaceWith(d,f,v)}n.updateSelection&&K6e(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},Z6e=()=>({state:t,dispatch:e})=>SBe(t,e),Q6e=()=>({state:t,dispatch:e})=>MBe(t,e),J6e=()=>({state:t,dispatch:e})=>_J(t,e),eHe=()=>({state:t,dispatch:e})=>EJ(t,e),tHe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=hE(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},nHe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=hE(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},rHe=()=>({state:t,dispatch:e})=>_Be(t,e),iHe=()=>({state:t,dispatch:e})=>wBe(t,e);function bee(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function aHe(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))vL()||bee()?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 sHe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=aHe(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 jd(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,s=e?pi(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,g)=>{if(f.isText)return;const p=Math.max(r,g),b=Math.min(i,g+f.nodeSize);l.push({node:f,from:p,to:b})});const c=i-r,u=l.filter(f=>s?s.name===f.node.type.name:!0).filter(f=>gS(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=c}var oHe=(t,e={})=>({state:n,dispatch:r})=>{const i=pi(t,n.schema);return jd(n,i,e)?EBe(n,r):!1},lHe=()=>({state:t,dispatch:e})=>CJ(t,e),cHe=t=>({state:e,dispatch:n})=>{const r=pi(t,e.schema);return IBe(r)(e,n)},uHe=()=>({state:t,dispatch:e})=>TJ(t,e);function vE(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function pG(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 dHe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const l=vE(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=pi(t,r.schema)),l==="mark"&&(s=nu(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,pG(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(pG(g.attrs,e))))})})}),c},hHe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),fHe=()=>({tr:t,dispatch:e})=>{if(e){const n=new js(t.doc);t.setSelection(n)}return!0},mHe=()=>({state:t,dispatch:e})=>SJ(t,e),pHe=()=>({state:t,dispatch:e})=>AJ(t,e),gHe=()=>({state:t,dispatch:e})=>CBe(t,e),xHe=()=>({state:t,dispatch:e})=>jBe(t,e),bHe=()=>({state:t,dispatch:e})=>PBe(t,e);function Nj(t,e,n={},r={}){return gb(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var yHe=(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=Nj(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 yee(t,e){const n=nu(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 vee(t,e){const n=new xJ(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function vHe(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 _He(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function wHe(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 _E(t){return e=>wHe(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 _L(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Gt(e,"addExtensions",n);return r?[e,..._L(r())]:e}).flat(10)}function wL(t,e){const n=kf.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function _ee(t){return typeof t=="function"}function Zn(t,e=void 0,...n){return _ee(t)?e?t.bind(e)(...n):t(...n):t}function SHe(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 wee(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 xS(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 MHe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function gG(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):MHe(n.getAttribute(s.name));return l==null?a:{...a,[s.name]:l}},{});return{...r,...i}}}}function xG(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&SHe(n)?!1:n!=null))}function bG(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 EHe(t,e){var n;const r=wee(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(y=>y.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((y,E)=>{const w=Gt(E,"extendNodeSchema",f);return{...y,...w?w(u):{}}},{}),p=xG({...g,content:Zn(Gt(u,"content",f)),marks:Zn(Gt(u,"marks",f)),group:Zn(Gt(u,"group",f)),inline:Zn(Gt(u,"inline",f)),atom:Zn(Gt(u,"atom",f)),selectable:Zn(Gt(u,"selectable",f)),draggable:Zn(Gt(u,"draggable",f)),code:Zn(Gt(u,"code",f)),whitespace:Zn(Gt(u,"whitespace",f)),linebreakReplacement:Zn(Gt(u,"linebreakReplacement",f)),defining:Zn(Gt(u,"defining",f)),isolating:Zn(Gt(u,"isolating",f)),attrs:Object.fromEntries(d.map(bG))}),b=Zn(Gt(u,"parseHTML",f));b&&(p.parseDOM=b.map(y=>gG(y,d)));const v=Gt(u,"renderHTML",f);v&&(p.toDOM=y=>v({node:y,HTMLAttributes:xS(y,d)}));const x=Gt(u,"renderText",f);return x&&(p.toText=x),[u.name,p]})),c=Object.fromEntries(a.map(u=>{const d=r.filter(x=>x.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((x,y)=>{const E=Gt(y,"extendMarkSchema",f);return{...x,...E?E(u):{}}},{}),p=xG({...g,inclusive:Zn(Gt(u,"inclusive",f)),excludes:Zn(Gt(u,"excludes",f)),group:Zn(Gt(u,"group",f)),spanning:Zn(Gt(u,"spanning",f)),code:Zn(Gt(u,"code",f)),attrs:Object.fromEntries(d.map(bG))}),b=Zn(Gt(u,"parseHTML",f));b&&(p.parseDOM=b.map(x=>gG(x,d)));const v=Gt(u,"renderHTML",f);return v&&(p.toDOM=x=>v({mark:x,HTMLAttributes:xS(x,d)})),[u.name,p]}));return new tJ({topNode:s,nodes:l,marks:c})}function AHe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function SL(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 See(t){const e=SL(_L(t)),n=AHe(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 Mee(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
  8150. `,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 THe(t,e){const n={from:0,to:t.content.size};return Mee(t,n,e)}function Eee(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function NHe(t,e){const n=pi(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 Aee(t,e){const n=vE(typeof e=="string"?e:e.name,t.schema);return n==="node"?NHe(t,e):n==="mark"?yee(t,e):{}}function CHe(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 kHe(t){const e=CHe(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 Tee(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}})})}),kHe(r)}function ML(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),s=yL(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 PHe=(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 pk(t,e){return e.nodes[t]||e.marks[t]||null}function D1(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 jHe=(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 Cj(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?nu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>gS(f.attrs,n,{strict:!1}));let s=0;const l=[];if(i.forEach(({$from:f,$to:g})=>{const p=f.pos,b=g.pos;t.doc.nodesBetween(p,b,(v,x)=>{if(!v.isText&&!v.marks.length)return;const y=Math.max(p,x),E=Math.min(b,x+v.nodeSize),w=E-y;s+=w,l.push(...v.marks.map(A=>({mark:A,from:y,to:E})))})}),s===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>gS(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 RHe(t,e,n={}){if(!e)return jd(t,null,n)||Cj(t,null,n);const r=vE(e,t.schema);return r==="node"?jd(t,e,n):r==="mark"?Cj(t,e,n):!1}var DHe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=_E(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)},OHe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function yG(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function vG(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=Zn(Gt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function wE(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&&(wE(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Nee(t){return t instanceof qt}function LHe(t,e,n){var r;const{selection:i}=e;let a=null;if(pee(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),b=!!n.isInSet(d.marks)||!d.marks.some(v=>v.type.excludes(n));u=p&&b}return!u}),u})}var IHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:s,ranges:l}=a,c=nu(t,r.schema);if(i)if(s){const u=yee(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 b=Math.max(p,d),v=Math.min(p+g.nodeSize,f);g.marks.find(y=>y.type===c)?g.marks.forEach(y=>{c===y.type&&n.addMark(b,v,c.create({...y.attrs,...e}))}):n.addMark(b,v,c.create(e))})});return LHe(r,n,c)},FHe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),UHe=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=pi(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})=>D7(a,{...s,...e})(n)?!0:l.clearNodes()).command(({state:l})=>D7(a,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},zHe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Dh(t,0,r.content.size),a=qt.create(r,i);e.setSelection(a)}return!0},BHe=(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},HHe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,s=en.atStart(r).from,l=en.atEnd(r).to,c=Dh(i,s,l),u=Dh(a,s,l),d=en.create(r,c,u);e.setSelection(d)}return!0},$He=t=>({state:e,dispatch:n})=>{const r=pi(t,e.schema);return zBe(r)(e,n)};function _G(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 VHe=({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=D1(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&&_G(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:vHe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=f&&g?[{type:g,attrs:d}]:void 0,b=Ic(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!b&&Ic(e.doc,e.mapping.map(l.pos),1,g?[{type:g}]:void 0)&&(b=!0,p=g?[{type:g,attrs:d}]:void 0),r){if(b&&(a instanceof en&&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()),x=e.doc.resolve(v);l.node(-1).canReplaceWith(x.index(),x.index()+1,g)&&e.setNodeMarkup(e.mapping.map(l.before()),g)}t&&_G(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return b},GHe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var s;const l=pi(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 y=vt.empty;const E=c.index(-1)?1:c.index(-2)?2:3;for(let O=c.depth-E;O>=c.depth-3;O-=1)y=vt.from(c.node(O).copy(y));const w=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...D1(g,c.node().type.name,c.node().attrs),...e},T=((s=l.contentMatch.defaultType)==null?void 0:s.createAndFill(A))||void 0;y=y.append(vt.from(l.createAndFill(null,T)||void 0));const C=c.before(c.depth-(E-1));n.replace(C,c.after(-w),new Dt(y,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(en.near(n.doc.resolve(N))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,b={...D1(g,f.type.name,f.attrs),...e},v={...D1(g,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const x=p?[{type:l,attrs:b},{type:p,attrs:v}]:[{type:l,attrs:b}];if(!Ic(n.doc,c.pos,2))return!1;if(i){const{selection:y,storedMarks:E}=r,{splittableMarks:w}=a.extensionManager,A=E||y.$to.parentOffset&&y.$from.marks();if(n.split(c.pos,2,x).scrollIntoView(),!A||!i)return!0;const T=A.filter(C=>w.includes(C.type.name));n.ensureMarks(T)}return!0},gk=(t,e)=>{const n=_E(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&&Fd(t.doc,n.pos)&&t.join(n.pos),!0},xk=(t,e)=>{const n=_E(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&&Fd(t.doc,r)&&t.join(r),!0},WHe=(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=pi(t,s.schema),b=pi(e,s.schema),{selection:v,storedMarks:x}=s,{$from:y,$to:E}=v,w=y.blockRange(E),A=x||v.$to.parentOffset&&v.$from.marks();if(!w)return!1;const T=_E(C=>vG(C.type.name,f))(v);if(w.depth>=1&&T&&w.depth-T.depth<=1){if(T.node.type===p)return u.liftListItem(b);if(vG(T.node.type.name,f)&&p.validContent(T.node.content)&&l)return c().command(()=>(a.setNodeMarkup(T.pos,p),!0)).command(()=>gk(a,p)).command(()=>xk(a,p)).run()}return!n||!A||!l?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>gk(a,p)).command(()=>xk(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(()=>gk(a,p)).command(()=>xk(a,p)).run()},qHe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,s=nu(t,r.schema);return Cj(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:a}):i.setMark(s,e)},KHe=(t,e,n={})=>({state:r,commands:i})=>{const a=pi(t,r.schema),s=pi(e,r.schema),l=jd(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})},XHe=(t,e={})=>({state:n,commands:r})=>{const i=pi(t,n.schema);return jd(n,i,e)?r.lift(i):r.wrapIn(i,e)},YHe=()=>({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},ZHe=()=>({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},QHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:s=!1}=e,{selection:l}=n,c=nu(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&s){let{from:g,to:p}=l;const b=(a=u.marks().find(x=>x.type===c))==null?void 0:a.attrs,v=yL(u,c,b);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},JHe=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},e$e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,s=null;const l=vE(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=pi(t,r.schema)),l==="mark"&&(s=nu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let g,p,b,v;n.selection.empty?r.doc.nodesBetween(d,f,(x,y)=>{a&&a===x.type&&(c=!0,b=Math.max(y,d),v=Math.min(y+x.nodeSize,f),g=y,p=x)}):r.doc.nodesBetween(d,f,(x,y)=>{y<d&&a&&a===x.type&&(c=!0,b=Math.max(y,d),v=Math.min(y+x.nodeSize,f),g=y,p=x),y>=d&&y<=f&&(a&&a===x.type&&(c=!0,i&&n.setNodeMarkup(y,void 0,{...x.attrs,...e})),s&&x.marks.length&&x.marks.forEach(E=>{if(s===E.type&&(c=!0,i)){const w=Math.max(y,d),A=Math.min(y+x.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(x=>{s===x.type&&i&&n.addMark(b,v,s.create({...x.attrs,...e}))}))}),c},t$e=(t,e={})=>({state:n,dispatch:r})=>{const i=pi(t,n.schema);return RBe(i,e)(n,r)},n$e=(t,e={})=>({state:n,dispatch:r})=>{const i=pi(t,n.schema);return DBe(i,e)(n,r)},r$e=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={}}},SE=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},i$e=(t,e)=>{if(bL(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=jHe(u)+a;return s.forEach(g=>{if(d)return;const p=i$e(f,g.find);if(!p)return;const b=c.state.tr,v=bE({state:c.state,transaction:b}),x={from:r-(p[0].length-a.length),to:i},{commands:y,chain:E,can:w}=new yE({editor:n,state:v});g.handler({state:v,range:x,match:p,commands:y,chain:E,can:w})===null||!b.steps.length||(g.undoable&&b.setMeta(l,{transform:b,from:r,to:i,text:a}),c.dispatch(b),d=!0)}),d}function a$e(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=wL(vt.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:`
  8151. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function s$e(t){return Object.prototype.toString.call(t).slice(8,-1)}function J_(t){return s$e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Cee(t,e){const n={...t};return J_(t)&&J_(e)&&Object.keys(e).forEach(r=>{J_(e[r])&&J_(t[r])?n[r]=Cee(t[r],e[r]):n[r]=e[r]}),n}var EL=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{...Zn(Gt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Zn(Gt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Cee(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}},zd=class kee extends EL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new kee(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 o$e(t){return typeof t=="number"}var l$e=class{constructor(t){this.find=t.find,this.handler=t.handler}},c$e=(t,e,n)=>{if(bL(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 u$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 yE({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(p,b)=>{var v,x,y,E,w;if((x=(v=p.type)==null?void 0:v.spec)!=null&&x.code||!(p.isText||p.isTextblock||p.isInline))return;const A=(w=(E=(y=p.content)==null?void 0:y.size)!=null?E:p.nodeSize)!=null?w:0,T=Math.max(r,b),C=Math.min(i,b+A);if(T>=C)return;const N=p.isText?p.text||"":p.textBetween(T-b,C-b,void 0,"");c$e(N,a.find,s).forEach(k=>{if(k.index===void 0)return;const j=T+k.index+1,z=j+k[0].length,I={from:n.tr.mapping.map(j),to:n.tr.mapping.map(z)},q=a.handler({state:n,range:I,match:k,commands:c,chain:u,can:d,pasteEvent:s,dropEvent:l});f.push(q)})}),f.every(p=>p!==null)}var e1=null,d$e=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function h$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:b})=>{const v=d.tr,x=bE({state:d,transaction:v});if(!(!u$e({editor:e,state:x,from:Math.max(f-1,0),to:g.b-1,rule:p,pasteEvent:b,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=b=>{var v;r=(v=f.dom.parentElement)!=null&&v.contains(b.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 b=p.state.selection;b&&p.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(f,g)=>{var p;const b=(p=g.clipboardData)==null?void 0:p.getData("text/html");return s=g,i=!!b?.includes("data-pm-slice"),!1}}},appendTransaction:(f,g,p)=>{const b=f[0],v=b.getMeta("uiEvent")==="paste"&&!i,x=b.getMeta("uiEvent")==="drop"&&!a,y=b.getMeta("applyPasteRules"),E=!!y;if(!v&&!x&&!E)return;if(E){let{text:T}=y;typeof T=="string"?T=T:T=wL(vt.from(T),p.schema);const{from:C}=y,N=C+T.length,O=d$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(!(!o$e(w)||!A||w===A.b))return c({rule:d,state:p,from:w,to:A,pasteEvt:s})}}))}var ME=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=See(t),this.schema=EHe(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:pk(e.name,this.schema)},r=Gt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return SL([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:pk(r.name,this.schema)},a=[],s=Gt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Gt(r,"exitable",i)&&(l.ArrowRight=()=>zd.handleExit({editor:t,mark:r})),s){const g=Object.fromEntries(Object.entries(s()).map(([p,b])=>[p,()=>b({editor:t})]));l={...l,...g}}const c=N6e(l);a.push(c);const u=Gt(r,"addInputRules",i);if(yG(r,t.options.enableInputRules)&&u){const g=u();if(g&&g.length){const p=a$e({editor:t,rules:g}),b=Array.isArray(p)?p:[p];a.push(...b)}}const d=Gt(r,"addPasteRules",i);if(yG(r,t.options.enablePasteRules)&&d){const g=d();if(g&&g.length){const p=h$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 wee(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:pi(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=xS(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:nu(n.name,this.schema)},a=Gt(n,"addMarkView",i);if(!a)return[];const s=(l,c,u)=>{const d=xS(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{T$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:pk(e.name,this.schema)};e.type==="mark"&&((n=Zn(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)})}};ME.resolve=See;ME.sort=SL;ME.flatten=_L;var f$e={};xL(f$e,{ClipboardTextSerializer:()=>jee,Commands:()=>Ree,Delete:()=>Dee,Drop:()=>Oee,Editable:()=>Lee,FocusEvents:()=>Fee,Keymap:()=>Uee,Paste:()=>zee,Tabindex:()=>Bee,TextDirection:()=>Hee,focusEventsPluginKey:()=>Iee});var dr=class Pee extends EL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Pee(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},jee=dr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Fr({key:new Pi("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=Eee(n);return Mee(r,{from:s,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Ree=dr.create({name:"commands",addCommands(){return{...fee}}}),Dee=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=vee(t.before,[t,...e]);Tee(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,(b,v)=>{const x=v+b.nodeSize-2,y=p.oldRange.from<=v&&x<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:b,from:v,to:x,newFrom:d.mapping.map(v),newTo:d.mapping.map(x),deletedRange:p.oldRange,newRange:p.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:d})})});const g=d.mapping;d.steps.forEach((p,b)=>{var v,x;if(p instanceof zo){const y=g.slice(b).map(p.from,-1),E=g.slice(b).map(p.to),w=g.invert().map(y,-1),A=g.invert().map(E),T=(v=d.doc.nodeAt(y-1))==null?void 0:v.marks.some(N=>N.eq(p.mark)),C=(x=d.doc.nodeAt(E))==null?void 0:x.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:y,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()}}),Oee=dr.create({name:"drop",addProseMirrorPlugins(){return[new Fr({key:new Pi("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Lee=dr.create({name:"editable",addProseMirrorPlugins(){return[new Fr({key:new Pi("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Iee=new Pi("focusEvents"),Fee=dr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Fr({key:Iee,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}}}})]}}),Uee=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,b=f.parent.isTextblock&&g>0?l.doc.resolve(g-1):f,v=b.parent.type.spec.isolating,x=f.pos-f.parentOffset,y=v&&b.parent.childCount===1?x===f.pos:yn.atStart(u).from===g;return!d||!p.type.isTextblock||p.textContent.length||!y||y&&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 vL()||bee()?a:i},addProseMirrorPlugins(){return[new Fr({key:new Pi("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=yn.atStart(e.doc).from,u=yn.atEnd(e.doc).to;if(a||!(s===c&&l===u)||!wE(n.doc))return;const g=n.tr,p=bE({state:n,transaction:g}),{commands:b}=new yE({editor:this.editor,state:p});if(b.clearNodes(),!!g.steps.length)return g}})]}}),zee=dr.create({name:"paste",addProseMirrorPlugins(){return[new Fr({key:new Pi("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Bee=dr.create({name:"tabindex",addProseMirrorPlugins(){return[new Fr({key:new Pi("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Hee=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 Pi("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),m$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)}},p$e=`.ProseMirror {
  8152. position: relative;
  8153. }
  8154. .ProseMirror {
  8155. word-wrap: break-word;
  8156. white-space: pre-wrap;
  8157. white-space: break-spaces;
  8158. -webkit-font-variant-ligatures: none;
  8159. font-variant-ligatures: none;
  8160. font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
  8161. }
  8162. .ProseMirror [contenteditable="false"] {
  8163. white-space: normal;
  8164. }
  8165. .ProseMirror [contenteditable="false"] [contenteditable="true"] {
  8166. white-space: pre-wrap;
  8167. }
  8168. .ProseMirror pre {
  8169. white-space: pre-wrap;
  8170. }
  8171. img.ProseMirror-separator {
  8172. display: inline !important;
  8173. border: none !important;
  8174. margin: 0 !important;
  8175. width: 0 !important;
  8176. height: 0 !important;
  8177. }
  8178. .ProseMirror-gapcursor {
  8179. display: none;
  8180. pointer-events: none;
  8181. position: absolute;
  8182. margin: 0;
  8183. }
  8184. .ProseMirror-gapcursor:after {
  8185. content: "";
  8186. display: block;
  8187. position: absolute;
  8188. top: -2px;
  8189. width: 20px;
  8190. border-top: 1px solid black;
  8191. animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
  8192. }
  8193. @keyframes ProseMirror-cursor-blink {
  8194. to {
  8195. visibility: hidden;
  8196. }
  8197. }
  8198. .ProseMirror-hideselection *::selection {
  8199. background: transparent;
  8200. }
  8201. .ProseMirror-hideselection *::-moz-selection {
  8202. background: transparent;
  8203. }
  8204. .ProseMirror-hideselection * {
  8205. caret-color: transparent;
  8206. }
  8207. .ProseMirror-focused .ProseMirror-gapcursor {
  8208. display: block;
  8209. }`;function g$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 x$e=class extends r$e{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=gee(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=g$e(p$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=_ee(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?[Lee,jee.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Ree,Fee,Uee,Bee,Oee,zee,Dee,Hee.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 ME(r,this)}createCommandManager(){this.commandManager=new yE({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Nj(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=Nj(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new dee(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 Aee(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return RHe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return wL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8210. `,textSerializers:n={}}=t||{};return THe(this.state.doc,{blockSeparator:e,textSerializers:{...Eee(this.schema),...n}})}get isEmpty(){return wE(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 m$e(e,this)}get $doc(){return this.$pos(0)}};function Qp(t){return new SE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Zn(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(ML(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 $ee(t){return new SE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Zn(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 kj(t){return new SE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=Zn(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 SE({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=Zn(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),c=s.doc.resolve(n.from).blockRange(),u=c&&tL(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,b=g||f.$to.parentOffset&&f.$from.marks();if(b){const v=b.filter(x=>p.includes(x.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&&Fd(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&s.join(n.from-1)},undoable:t.undoable})}var b$e=t=>"touches"in t,y$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,b$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 v$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 _$e={};xL(_$e,{createAtomBlockMarkdownSpec:()=>w$e,createBlockMarkdownSpec:()=>S$e,createInlineMarkdownSpec:()=>A$e,parseAttributes:()=>AL,parseIndentedBlocks:()=>Pj,renderNestedMarkdownContent:()=>NL,serializeAttributes:()=>TL});function AL(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 TL(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 w$e(t){const{nodeName:e,name:n,parseAttributes:r=AL,serializeAttributes:i=TL,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|$)`),b=d.match(p);if(!b)return;const v=b[1]||"",x=r(v);if(!s.find(E=>!(E in x)))return{type:e,raw:b[0],attributes:x}}},renderMarkdown:d=>{const f=u(d.attrs||{}),g=i(f),p=g?` {${g}}`:"";return`:::${c}${p} :::`}}}function S$e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=AL,serializeAttributes:a=TL,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 b={...s,...f.attributes};return g.createNode(e,b,p)},markdownTokenizer:{name:e,level:"block",start(f){var g;const p=new RegExp(`^:::${u}`,"m"),b=(g=f.match(p))==null?void 0:g.index;return b!==void 0?b:-1},tokenize(f,g,p){var b;const v=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=f.match(v);if(!x)return;const[y,E=""]=x,w=i(E);let A=1;const T=y.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,z=k[1];if(!((b=k[2])!=null&&b.endsWith(":::"))){if(z)A+=1;else if(A-=1,A===0){const I=O.slice(0,j);C=I.trim();const q=f.slice(0,T+j+k[0].length);let R=[];if(C)if(l==="block")for(R=p.blockTokens(I),R.forEach(W=>{W.text&&(!W.tokens||W.tokens.length===0)&&(W.tokens=p.inlineTokens(W.text))});R.length>0;){const W=R[R.length-1];if(W.type==="paragraph"&&(!W.text||W.text.trim()===""))R.pop();else break}else R=p.inlineTokens(C);return{type:e,raw:q,attributes:w,content:C,tokens:R}}}}}},renderMarkdown:(f,g)=>{const p=d(f.attrs||{}),b=a(p),v=b?` {${b}}`:"",x=g.renderChildren(f.content||[],`
  8211. `);return`:::${u}${v}
  8212. ${x}
  8213. :::`}}}function M$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 E$e(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function A$e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=M$e,serializeAttributes:a=E$e,defaultAttributes:s={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=g=>{if(!c)return g;const p={};return c.forEach(b=>{b in g&&(p[b]=g[b])}),p},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,p)=>{const b={...s,...g.attributes};if(l)return p.createNode(e,b);const v=r?r(g):g.content||"";return v?p.createNode(e,b,[p.createTextNode(v)]):p.createNode(e,b,[])},markdownTokenizer:{name:e,level:"inline",start(g){const p=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),b=g.match(p),v=b?.index;return v!==void 0?v:-1},tokenize(g,p,b){const v=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),x=g.match(v);if(!x)return;let y="",E="";if(l){const[,A]=x;E=A}else{const[,A,T]=x;E=A,y=T||""}const w=i(E.trim());return{type:e,raw:x[0],content:y.trim(),attributes:w}}},renderMarkdown:g=>{let p="";r?p=r(g):g.content&&g.content.length>0&&(p=g.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const b=d(g.attrs||{}),v=a(b),x=v?` ${v}`:"";return l?`[${u}${x}]`:`[${u}${x}]${p}[/${u}]`}}}function Pj(t,e,n){var r,i,a,s;const l=t.split(`
  8214. `),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}
  8215. `;continue}else return}const b=e.extractItemData(p),{indentLevel:v,mainContent:x}=b;u=`${u}${g}
  8216. `;const y=[x];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){y.push(T),u=`${u}${T}
  8217. `,d+=1;continue}else break}if((((s=(a=T.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:s.length)||0)>v)y.push(T),u=`${u}${T}
  8218. `,d+=1;else break}let E;const w=y.slice(1);if(w.length>0){const T=w.map(C=>C.slice(v+f)).join(`
  8219. `);T.trim()&&(e.customNestedParser?E=e.customNestedParser(T):E=n.blockTokens(T))}const A=e.createToken(b,E);c.push(A)}if(c.length!==0)return{items:c,raw:u}}function NL(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(`
  8220. `).map(g=>g?e.indent(g):"").join(`
  8221. `);c.push(f)}}),c.join(`
  8222. `)}function T$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 Vee extends EL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Vee(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 l$e({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=Zn(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(ML(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(x=>x===t.type&&x!==b.mark.type)).filter(b=>b.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 bk,wG;function N$e(){return wG||(wG=1,bk=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}),bk}var C$e=N$e();const k$e=vo(C$e);var P$e=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},j$e=({contentComponent:t})=>{const e=Qj.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return o.jsx(o.Fragment,{children:Object.values(e)})};function R$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]:Vse.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 D$e=class extends kr.Component{constructor(t){var e;super(t),this.editorContentRef=kr.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=R$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:P$e(e,this.editorContentRef),...n}),t?.contentComponent&&o.jsx(j$e,{contentComponent:t.contentComponent})]})}},O$e=S.forwardRef((t,e)=>{const n=kr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return kr.createElement(D$e,{key:n,innerRef:e,...t})}),L$e=kr.memo(O$e),I$e=typeof window<"u"?S.useLayoutEffect:S.useEffect,F$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 U$e(t){var e;const[n]=S.useState(()=>new F$e(t.editor)),r=HW.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:k$e);return I$e(()=>n.watch(t.editor),[t.editor,n]),S.useDebugValue(r),r}var z$e=!1,jj=typeof window>"u",B$e=jj||!!(typeof window<"u"&&window.next),H$e=class Gee{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?jj||B$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 x$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?Gee.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 $$e(t={},e=[]){const n=S.useRef(t);n.current=t;const[r]=S.useState(()=>new H$e(n)),i=Qj.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return S.useDebugValue(i),S.useEffect(r.onRender(e)),U$e({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var V$e=S.createContext({editor:null});V$e.Consumer;var G$e=S.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),W$e=()=>S.useContext(G$e);kr.forwardRef((t,e)=>{const{onDragStart:n}=W$e(),r=t.as||"div";return o.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});kr.createContext({markViewContentRef:()=>{}});var bS=(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]},q$e=/^\s*>\s$/,K$e=cs.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return bS("blockquote",{...Wr(this.options.HTMLAttributes,t),children:bS("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(`
  8223. `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
  8224. `))}),r.join(`
  8225. ${n}
  8226. `)},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:q$e,type:this.type})]}}),X$e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Y$e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Z$e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Q$e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,J$e=zd.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 bS("strong",{...Wr(this.options.HTMLAttributes,t),children:bS("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:X$e,type:this.type}),Qp({find:Z$e,type:this.type})]},addPasteRules(){return[Mf({find:Y$e,type:this.type}),Mf({find:Q$e,type:this.type})]}}),eVe=/(^|[^`])`([^`]+)`(?!`)$/,tVe=/(^|[^`])`([^`]+)`(?!`)/g,nVe=zd.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:eVe,type:this.type})]},addPasteRules(){return[Mf({find:tVe,type:this.type})]}}),yk=4,rVe=/^```([a-z]+)?[\s\n]$/,iVe=/^~~~([a-z]+)?[\s\n]$/,aVe=cs.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:yk,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(`
  8227. `):r=`\`\`\`${i}
  8228. \`\`\``,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:yk,{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,`
  8229. `,`
  8230. `).split(`
  8231. `).map(b=>l+b).join(`
  8232. `);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:yk,{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,`
  8233. `,`
  8234. `).split(`
  8235. `);let b=0,v=0;const x=u-d;for(let C=0;C<p.length;C+=1){if(v+p[C].length>=x){b=C;break}v+=p[C].length+1}const E=((c=p[b].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<b;C+=1)A+=p[C].length+1;return l.delete(A,A+w),u-A<=w&&l.setSelection(en.create(l.doc,A)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,g=r.doc.textBetween(c,u,`
  8236. `,`
  8237. `).split(`
  8238. `).map(p=>{var b;const v=((b=p.match(/^ */))==null?void 0:b[0])||"",x=Math.min(v.length,n);return p.slice(x)}).join(`
  8239. `);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(`
  8240. `);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(yn.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[kj({find:rVe,type:this.type,getAttributes:t=>({language:t[1]})}),kj({find:iVe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Fr({key:new Pi("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,`
  8241. `));return s.replaceSelectionWith(this.type.create({language:a},c)),s.selection.$from.parent.type!==this.type&&s.setSelection(en.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),sVe=cs.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8242. `):""}),oVe=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`
  8243. `},renderMarkdown:()=>`
  8244. `,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()}}}),lVe=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=>kj({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),cVe=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(!v$e(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Nee(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(en.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(qt.create(s.doc,c.pos)):s.setSelection(en.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(en.create(s.doc,u+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[$ee({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),uVe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,dVe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,hVe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,fVe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,mVe=zd.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:uVe,type:this.type}),Qp({find:hVe,type:this.type})]},addPasteRules(){return[Mf({find:dVe,type:this.type}),Mf({find:fVe,type:this.type})]}});const pVe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",gVe="ελ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",Rj="numeric",Dj="ascii",Oj="alpha",y0="asciinumeric",n0="alphanumeric",Lj="domain",Wee="emoji",xVe="scheme",bVe="slashscheme",vk="whitespace";function yVe(t,e){return t in e||(e[t]=[]),e[t]}function Oh(t,e,n){e[Rj]&&(e[y0]=!0,e[n0]=!0),e[Dj]&&(e[y0]=!0,e[Oj]=!0),e[y0]&&(e[n0]=!0),e[Oj]&&(e[n0]=!0),e[n0]&&(e[Lj]=!0),e[Wee]&&(e[Lj]=!0);for(const r in e){const i=yVe(r,n);i.indexOf(t)<0&&i.push(t)}}function vVe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function es(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}es.groups={};es.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||es.groups;let i;return e&&e.j?i=e:(i=new es(e),n&&r&&Oh(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||es.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 es,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new es,a){if(r)if(s.t&&typeof s.t=="string"){const c=Object.assign(vVe(s.t,r),n);Oh(a,c,r)}else n&&Oh(a,n,r);s.t=a}return i.j[t]=s,s}};const pn=(t,e,n,r,i)=>t.ta(e,n,r,i),Hr=(t,e,n,r,i)=>t.tr(e,n,r,i),SG=(t,e,n,r,i)=>t.ts(e,n,r,i),Mt=(t,e,n,r,i)=>t.tt(e,n,r,i),xc="WORD",Ij="UWORD",qee="ASCIINUMERICAL",Kee="ALPHANUMERICAL",xb="LOCALHOST",Fj="TLD",Uj="UTLD",O1="SCHEME",rp="SLASH_SCHEME",CL="NUM",zj="WS",kL="NL",v0="OPENBRACE",_0="CLOSEBRACE",yS="OPENBRACKET",vS="CLOSEBRACKET",_S="OPENPAREN",wS="CLOSEPAREN",SS="OPENANGLEBRACKET",MS="CLOSEANGLEBRACKET",ES="FULLWIDTHLEFTPAREN",AS="FULLWIDTHRIGHTPAREN",TS="LEFTCORNERBRACKET",NS="RIGHTCORNERBRACKET",CS="LEFTWHITECORNERBRACKET",kS="RIGHTWHITECORNERBRACKET",PS="FULLWIDTHLESSTHAN",jS="FULLWIDTHGREATERTHAN",RS="AMPERSAND",DS="APOSTROPHE",OS="ASTERISK",Ku="AT",LS="BACKSLASH",IS="BACKTICK",FS="CARET",ed="COLON",PL="COMMA",US="DOLLAR",sl="DOT",zS="EQUALS",jL="EXCLAMATION",Zs="HYPHEN",w0="PERCENT",BS="PIPE",HS="PLUS",$S="POUND",S0="QUERY",RL="QUOTE",Xee="FULLWIDTHMIDDLEDOT",DL="SEMI",ol="SLASH",M0="TILDE",VS="UNDERSCORE",Yee="EMOJI",GS="SYM";var Zee=Object.freeze({__proto__:null,ALPHANUMERICAL:Kee,AMPERSAND:RS,APOSTROPHE:DS,ASCIINUMERICAL:qee,ASTERISK:OS,AT:Ku,BACKSLASH:LS,BACKTICK:IS,CARET:FS,CLOSEANGLEBRACKET:MS,CLOSEBRACE:_0,CLOSEBRACKET:vS,CLOSEPAREN:wS,COLON:ed,COMMA:PL,DOLLAR:US,DOT:sl,EMOJI:Yee,EQUALS:zS,EXCLAMATION:jL,FULLWIDTHGREATERTHAN:jS,FULLWIDTHLEFTPAREN:ES,FULLWIDTHLESSTHAN:PS,FULLWIDTHMIDDLEDOT:Xee,FULLWIDTHRIGHTPAREN:AS,HYPHEN:Zs,LEFTCORNERBRACKET:TS,LEFTWHITECORNERBRACKET:CS,LOCALHOST:xb,NL:kL,NUM:CL,OPENANGLEBRACKET:SS,OPENBRACE:v0,OPENBRACKET:yS,OPENPAREN:_S,PERCENT:w0,PIPE:BS,PLUS:HS,POUND:$S,QUERY:S0,QUOTE:RL,RIGHTCORNERBRACKET:NS,RIGHTWHITECORNERBRACKET:kS,SCHEME:O1,SEMI:DL,SLASH:ol,SLASH_SCHEME:rp,SYM:GS,TILDE:M0,TLD:Fj,UNDERSCORE:VS,UTLD:Uj,UWORD:Ij,WORD:xc,WS:zj});const fc=/[a-z]/,$x=new RegExp("\\p{L}","u"),_k=new RegExp("\\p{Emoji}","u"),mc=/\d/,wk=/\s/,MG="\r",Sk=`
  8245. `,_Ve="️",wVe="‍",Mk="";let t1=null,n1=null;function SVe(t=[]){const e={};es.groups=e;const n=new es;t1==null&&(t1=EG(pVe)),n1==null&&(n1=EG(gVe)),Mt(n,"'",DS),Mt(n,"{",v0),Mt(n,"}",_0),Mt(n,"[",yS),Mt(n,"]",vS),Mt(n,"(",_S),Mt(n,")",wS),Mt(n,"<",SS),Mt(n,">",MS),Mt(n,"(",ES),Mt(n,")",AS),Mt(n,"「",TS),Mt(n,"」",NS),Mt(n,"『",CS),Mt(n,"』",kS),Mt(n,"<",PS),Mt(n,">",jS),Mt(n,"&",RS),Mt(n,"*",OS),Mt(n,"@",Ku),Mt(n,"`",IS),Mt(n,"^",FS),Mt(n,":",ed),Mt(n,",",PL),Mt(n,"$",US),Mt(n,".",sl),Mt(n,"=",zS),Mt(n,"!",jL),Mt(n,"-",Zs),Mt(n,"%",w0),Mt(n,"|",BS),Mt(n,"+",HS),Mt(n,"#",$S),Mt(n,"?",S0),Mt(n,'"',RL),Mt(n,"/",ol),Mt(n,";",DL),Mt(n,"~",M0),Mt(n,"_",VS),Mt(n,"\\",LS),Mt(n,"・",Xee);const r=Hr(n,mc,CL,{[Rj]:!0});Hr(r,mc,r);const i=Hr(r,fc,qee,{[y0]:!0}),a=Hr(r,$x,Kee,{[n0]:!0}),s=Hr(n,fc,xc,{[Dj]:!0});Hr(s,mc,i),Hr(s,fc,s),Hr(i,mc,i),Hr(i,fc,i);const l=Hr(n,$x,Ij,{[Oj]:!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=Mt(n,Sk,kL,{[vk]:!0}),u=Mt(n,MG,zj,{[vk]:!0}),d=Hr(n,wk,zj,{[vk]:!0});Mt(n,Mk,d),Mt(u,Sk,c),Mt(u,Mk,d),Hr(u,wk,d),Mt(d,MG),Mt(d,Sk),Hr(d,wk,d),Mt(d,Mk,d);const f=Hr(n,_k,Yee,{[Wee]:!0});Mt(f,"#"),Hr(f,_k,f),Mt(f,_Ve,f);const g=Mt(f,wVe);Mt(g,"#"),Hr(g,_k,f);const p=[[fc,s],[mc,i]],b=[[fc,null],[$x,l],[mc,a]];for(let v=0;v<t1.length;v++)zu(n,t1[v],Fj,xc,p);for(let v=0;v<n1.length;v++)zu(n,n1[v],Uj,Ij,b);Oh(Fj,{tld:!0,ascii:!0},e),Oh(Uj,{utld:!0,alpha:!0},e),zu(n,"file",O1,xc,p),zu(n,"mailto",O1,xc,p),zu(n,"http",rp,xc,p),zu(n,"https",rp,xc,p),zu(n,"ftp",rp,xc,p),zu(n,"ftps",rp,xc,p),Oh(O1,{scheme:!0,ascii:!0},e),Oh(rp,{slashscheme:!0,ascii:!0},e),t=t.sort((v,x)=>v[0]>x[0]?1:-1);for(let v=0;v<t.length;v++){const x=t[v][0],E=t[v][1]?{[xVe]:!0}:{[bVe]:!0};x.indexOf("-")>=0?E[Lj]=!0:fc.test(x)?mc.test(x)?E[y0]=!0:E[Dj]=!0:E[Rj]=!0,SG(n,x,x,E)}return SG(n,"localhost",xb,{ascii:!0}),n.jd=new es(GS),{start:n,tokens:Object.assign({groups:e},Zee)}}function Qee(t,e){const n=MVe(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 MVe(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 zu(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 es(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new es(n),a.jr=i.slice(),t.j[e[s-1]]=a,a}function EG(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:AG,formatHref:AG,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function OL(t,e=null){let n=Object.assign({},bb);t&&(n=Object.assign(n,t instanceof OL?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}OL.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 AG(t){return t}function Jee(t,e){this.t="token",this.v=t,this.tk=e}Jee.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 EE(t,e){class n extends Jee{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 TG=EE("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),NG=EE("text"),EVe=EE("nl"),r1=EE("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===ed}}),Ks=t=>new es(t);function AVe({groups:t}){const e=t.domain.concat([RS,OS,Ku,LS,IS,FS,US,zS,Zs,CL,w0,BS,HS,$S,ol,GS,M0,VS]),n=[DS,ed,PL,sl,jL,w0,S0,RL,DL,SS,MS,v0,_0,vS,yS,_S,wS,ES,AS,TS,NS,CS,kS,PS,jS],r=[RS,DS,OS,LS,IS,FS,US,zS,Zs,v0,_0,w0,BS,HS,$S,S0,ol,GS,M0,VS],i=Ks(),a=Mt(i,M0);pn(a,r,a),pn(a,t.domain,a);const s=Ks(),l=Ks(),c=Ks();pn(i,t.domain,s),pn(i,t.scheme,l),pn(i,t.slashscheme,c),pn(s,r,a),pn(s,t.domain,s);const u=Mt(s,Ku);Mt(a,Ku,u),Mt(l,Ku,u),Mt(c,Ku,u);const d=Mt(a,sl);pn(d,r,a),pn(d,t.domain,a);const f=Ks();pn(u,t.domain,f),pn(f,t.domain,f);const g=Mt(f,sl);pn(g,t.domain,f);const p=Ks(TG);pn(g,t.tld,p),pn(g,t.utld,p),Mt(u,xb,p);const b=Mt(f,Zs);Mt(b,Zs,b),pn(b,t.domain,f),pn(p,t.domain,f),Mt(p,sl,g),Mt(p,Zs,b);const v=Mt(p,ed);pn(v,t.numeric,TG);const x=Mt(s,Zs),y=Mt(s,sl);Mt(x,Zs,x),pn(x,t.domain,s),pn(y,r,a),pn(y,t.domain,s);const E=Ks(r1);pn(y,t.tld,E),pn(y,t.utld,E),pn(E,t.domain,s),pn(E,r,a),Mt(E,sl,y),Mt(E,Zs,x),Mt(E,Ku,u);const w=Mt(E,ed),A=Ks(r1);pn(w,t.numeric,A);const T=Ks(r1),C=Ks();pn(T,e,T),pn(T,n,C),pn(C,e,T),pn(C,n,C),Mt(E,ol,T),Mt(A,ol,T);const N=Mt(l,ed),O=Mt(c,ed),k=Mt(O,ol),j=Mt(k,ol);pn(l,t.domain,s),Mt(l,sl,y),Mt(l,Zs,x),pn(c,t.domain,s),Mt(c,sl,y),Mt(c,Zs,x),pn(N,t.domain,T),Mt(N,ol,T),Mt(N,S0,T),pn(j,t.domain,T),pn(j,e,T),Mt(j,ol,T);const z=[[v0,_0],[yS,vS],[_S,wS],[SS,MS],[ES,AS],[TS,NS],[CS,kS],[PS,jS]];for(let I=0;I<z.length;I++){const[q,R]=z[I],W=Mt(T,q);Mt(C,q,W),Mt(W,R,T);const K=Ks(r1);pn(W,e,K);const G=Ks();pn(W,n),pn(K,e,K),pn(K,n,G),pn(G,e,K),pn(G,n,G),Mt(K,R,T),Mt(G,R,T)}return Mt(i,xb,E),Mt(i,kL,EVe),{start:i,tokens:Zee}}function TVe(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(Ek(NG,e,s)),s=[]),i-=g,d-=g;const p=f.t,b=n.slice(i-d,i);a.push(Ek(p,e,b))}}return s.length>0&&a.push(Ek(NG,e,s)),a}function Ek(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 NVe=typeof console<"u"&&console&&console.warn||(()=>{}),CVe="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Mr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function kVe(){return es.groups={},Mr.scanner=null,Mr.parser=null,Mr.tokenQueue=[],Mr.pluginQueue=[],Mr.customSchemes=[],Mr.initialized=!1,Mr}function CG(t,e=!1){if(Mr.initialized&&NVe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${CVe}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
  8246. 1. Must only contain digits, lowercase ASCII letters or "-"
  8247. 2. Cannot start or end with "-"
  8248. 3. "-" cannot repeat`);Mr.customSchemes.push([t,e])}function PVe(){Mr.scanner=SVe(Mr.customSchemes);for(let t=0;t<Mr.tokenQueue.length;t++)Mr.tokenQueue[t][1]({scanner:Mr.scanner});Mr.parser=AVe(Mr.scanner.tokens);for(let t=0;t<Mr.pluginQueue.length;t++)Mr.pluginQueue[t][1]({scanner:Mr.scanner,parser:Mr.parser});return Mr.initialized=!0,Mr}function LL(t){return Mr.initialized||PVe(),TVe(Mr.parser.start,t,Qee(Mr.scanner.start,t))}LL.scan=Qee;function ete(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 OL(n),i=LL(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 IL="[\0-   ᠎ -\u2029  ]",jVe=new RegExp(IL),RVe=new RegExp(`${IL}$`),DVe=new RegExp(IL,"g");function OVe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function LVe(t){return new Fr({key:new Pi("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=vee(n.doc,[...e]);if(Tee(l).forEach(({newRange:u})=>{const d=_He(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(!RVe.test(p))return;f=d[0],g=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const p=g.split(jVe).filter(Boolean);if(p.length<=0)return!1;const b=p[p.length-1],v=f.pos+g.lastIndexOf(b);if(!b)return!1;const x=LL(b).map(y=>y.toObject(t.defaultProtocol));if(!OVe(x))return!1;x.filter(y=>y.isLink).map(y=>({...y,from:v+y.start+1,to:v+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{ML(y.from,y.to,r.doc).some(E=>E.mark.type===t.type)||s.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!s.steps.length)return s}})}function IVe(t){return new Fr({key:new Pi("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=Aee(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 FVe(t){return new Fr({key:new Pi("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=ete(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 mh(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(DVe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var tte=zd.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"){CG(t);return}CG(t.scheme,t.optionalSlashes)})},onDestroy(){kVe()},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)=>!!mh(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=>!!mh(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=>!!mh(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=>!!mh(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=>!!mh(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=ete(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:s=>!!mh(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(LVe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!mh(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(IVe({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(FVe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),UVe=tte,zVe=Object.defineProperty,BVe=(t,e)=>{for(var n in e)zVe(t,n,{get:e[n],enumerable:!0})},HVe="listItem",kG="textStyle",PG=/^\s*([-+*])\s$/,nte=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,`
  8249. `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(HVe,this.editor.getAttributes(kG)).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:PG,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Jp({find:PG,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(kG),editor:this.editor})),[t]}}),rte=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)=>NL(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)}}}),$Ve={};BVe($Ve,{findListItemPos:()=>hy,getNextListDepth:()=>FL,handleBackspace:()=>Bj,handleDelete:()=>Hj,hasListBefore:()=>ite,hasListItemAfter:()=>VVe,hasListItemBefore:()=>ate,listItemHasSubList:()=>ste,nextListIsDeeper:()=>ote,nextListIsHigher:()=>lte});var hy=(t,e)=>{const{$from:n}=e.selection,r=pi(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}},FL=(t,e)=>{const n=hy(t,e);if(!n)return!1;const[,r]=PHe(e,t,n.$pos.pos+4);return r},ite=(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))},ate=(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)},ste=(t,e,n)=>{if(!n)return!1;const r=pi(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},Bj=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!jd(t.state,e)&&ite(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(!jd(t.state,e)||!OHe(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=ste(e,t.state,a);return ate(e,t.state)&&!s?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},ote=(t,e)=>{const n=FL(t,e),r=hy(t,e);return!r||!n?!1:n>r.depth},lte=(t,e)=>{const n=FL(t,e),r=hy(t,e);return!r||!n?!1:n<r.depth},Hj=(t,e)=>{if(!jd(t.state,e)||!DHe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:ote(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():lte(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},VVe=(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)},cte=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&&Hj(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&&Hj(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&&Bj(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&&Bj(t,n,r)&&(e=!0)}),e}}}}),jG=/^(\s*)(\d+)\.\s+(.*)$/,GVe=/^\s/;function WVe(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(jG);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(jG))break;if(p.trim()==="")g.push(p),d+=`
  8250. `,f+=1;else if(p.match(GVe))g.push(p),d+=`
  8251. ${p.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:g.join(`
  8252. `)}),r=f,n=f}return[e,r]}function ute(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(`
  8253. `),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(`
  8254. `).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)),b=ute(g,p,n);u.push({type:"list",ordered:!0,start:g[0].number,items:b,raw:g.map(v=>v.raw).join(`
  8255. `)})}i.push({type:"list_item",raw:s.raw,tokens:u}),a=f}else a+=1}return i}function qVe(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 KVe="listItem",RG="textStyle",DG=/^(\d+)\.\s$/,dte=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?qVe(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,`
  8256. `):"",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(`
  8257. `),[a,s]=WVe(i);if(a.length===0)return;const l=ute(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(`
  8258. `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(KVe,this.editor.getAttributes(RG)).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:DG,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:DG,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(RG)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),XVe=/^\s*(\[([( |x])?\])\s$/,YVe=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 NL(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 b=g.doc.nodeAt(p);return g.setNodeMarkup(p,void 0,{...b?.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:XVe,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),ZVe=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,`
  8259. `):"",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=Pj(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=Pj(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(nte.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(rte.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(cte.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(dte.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(YVe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(ZVe.configure(this.options.taskList)),t}});var QVe=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()}}}),JVe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,e7e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,t7e=zd.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:JVe,type:this.type})]},addPasteRules(){return[Mf({find:e7e,type:this.type})]}}),n7e=cs.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),hte=zd.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()}}}),r7e=hte;function i7e(t={}){return new Fr({view(e){return new a7e(e,t)}})}class a7e{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 b=p.getBoundingClientRect(),v=f?b.bottom:b.top;f&&g&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*l;r={left:b.left,right:b.right,top:v-x,bottom:v+x}}}}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=hJ(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 yn{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Vr.valid(r)?new Vr(r):yn.near(r)}content(){return Dt.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 UL(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!s7e(e)||!o7e(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;yn.jsonID("gapcursor",Vr);class UL{constructor(e){this.pos=e}map(e){return new UL(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Vr.valid(n)?new Vr(n):yn.near(n)}}function fte(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function s7e(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||fte(i.type))return!0;if(i.inlineContent)return!1}}return!0}function o7e(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||fte(i.type))return!0;if(i.inlineContent)return!1}}return!0}function l7e(){return new Fr({props:{decorations:h7e,createSelectionBetween(t,e,n){return e.pos==n.pos&&Vr.valid(n)?new Vr(n):null},handleClick:u7e,handleKeyDown:c7e,handleDOMEvents:{beforeinput:d7e}}})}const c7e=hee({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 en){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 u7e(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 d7e(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=vt.empty;for(let s=r.length-1;s>=0;s--)i=vt.from(r[s].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Dt(i,0,0));return a.setSelection(en.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function h7e(t){if(!(t.selection instanceof Vr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Rr.create(t.doc,[Oa.widget(t.selection.head,e,{key:"gapcursor"})])}var WS=200,Gi=function(){};Gi.prototype.append=function(e){return e.length?(e=Gi.from(e),!this.length&&e||e.length<WS&&this.leafAppend(e)||this.length<WS&&e.leafPrepend(this)||this.appendInner(e)):this};Gi.prototype.prepend=function(e){return e.length?Gi.from(e).append(this):this};Gi.prototype.appendInner=function(e){return new f7e(this,e)};Gi.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Gi.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Gi.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Gi.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)};Gi.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};Gi.from=function(e){return e instanceof Gi?e:e&&e.length?new mte(e):Gi.empty};var mte=(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<=WS)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=WS)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})(Gi);Gi.empty=new mte([]);var f7e=(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})(Gi);const m7e=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)),b;p&&s.maybeStep(p).doc&&(b=s.mapping.maps[s.mapping.maps.length-1],u.push(new ll(b,void 0,void 0,u.length+d.length))),a--,b&&i.appendMap(b,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>g7e&&(l=p7e(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 b=a.maps[p];if(g.step){let v=e.steps[p].invert(e.docs[p]),x=g.selection&&g.selection.map(a.slice(c+1,p));x&&l++,r.push(new ll(b,v,x))}else r.push(new ll(b))},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()>m7e&&(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(Gi.from(i.reverse()),a)}}Io.empty=new Io(Gi.empty,0);function p7e(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 Xu{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const g7e=20;function x7e(t,e,n,r){let i=n.getMeta(Yh),a;if(i)return i.historyState;n.getMeta(v7e)&&(t=new Xu(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Yh))return s.getMeta(Yh).redo?new Xu(t.done.addTransform(n,void 0,r,L1(e)),t.undone,OG(n.mapping.maps),t.prevTime,t.prevComposition):new Xu(t.done,t.undone.addTransform(n,void 0,r,L1(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||!b7e(n,t.prevRanges)),u=s?Ak(t.prevRanges,n.mapping):OG(n.mapping.maps);return new Xu(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,L1(e)),Io.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Xu(t.done.rebased(n,a),t.undone.rebased(n,a),Ak(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Xu(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Ak(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function b7e(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 OG(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 Ak(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 y7e(t,e,n){let r=L1(e),i=Yh.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 Xu(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(s).setMeta(Yh,{redo:n,historyState:c})}let Tk=!1,LG=null;function L1(t){let e=t.plugins;if(LG!=e){Tk=!1,LG=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Tk=!0;break}}return Tk}const Yh=new Pi("history"),v7e=new Pi("closeHistory");function _7e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Fr({key:Yh,state:{init(){return new Xu(Io.empty,Io.empty,null,0,-1)},apply(e,n,r){return x7e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?gte:r=="historyRedo"?xte:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function pte(t,e){return(n,r)=>{let i=Yh.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=y7e(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const gte=pte(!1,!0),xte=pte(!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 Pi("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 w7e=dr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[i7e(this.options)]}});dr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Fr({key:new Pi("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(Oa.node(u,u+c.nodeSize,{class:this.options.className}))}),Rr.create(t,a)}}})]}});var S7e=dr.create({name:"gapCursor",addProseMirrorPlugins(){return[l7e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Zn(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 Pi("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&&wE(s);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=Oa.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 Pi("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Nee(n.selection)||t.view.dragging?null:Rr.create(n.doc,[Oa.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function IG({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var M7e=dr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Pi(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!IG({node:s,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const s=i.doc.lastChild;return!IG({node:s,types:r})}}})]}}),E7e=dr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>gte(t,e),redo:()=>({state:t,dispatch:e})=>xte(t,e)}},addProseMirrorPlugins(){return[_7e(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()}}}),A7e=dr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(J$e.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(K$e.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(nte.configure(this.options.bulletList)),this.options.code!==!1&&i.push(nVe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(aVe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(sVe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(w7e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(S7e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(oVe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(lVe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(E7e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(cVe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(mVe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(rte.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(cte.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(tte.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(dte.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(QVe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(t7e.configure(this.options.strike)),this.options.text!==!1&&i.push(n7e.configure(this.options.text)),this.options.underline!==!1&&i.push(hte.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(M7e.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),T7e=A7e,N7e=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")}}}),C7e=N7e,k7e=20,bte=(t,e=0)=>{const n=[];return!t.children.length||e>k7e||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...bte(r,e+1))}),n},P7e=t=>{if(!t.children.length)return;const e=bte(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}`)})},yte=zd.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&P7e(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}}}}),j7e=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()}}}),vte=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()}}}),R7e=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()}}}),D7e=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()}}}),O7e=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(j7e.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(vte.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(R7e.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(D7e.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(O7e.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(yte.configure(this.options.textStyle)),t}});var L7e=vte,I7e=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,F7e=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?`![${c}](${l} "${u}")`:`![${c}](${l})`},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 y$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[$ee({find:I7e,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),U7e=F7e;function $j({content:t,onChange:e,placeholder:n}){const r=$$e({extensions:[T7e.configure({heading:!1,codeBlock:!1,code:!1}),r7e,UVe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),C7e.configure({types:["paragraph"]}),yte,L7e,U7e.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($oe,{className:"w-4 h-4"})}),o.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:o.jsx(Cce,{className:"w-4 h-4"})}),o.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:o.jsx(_de,{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(xR,{className:"w-4 h-4"})}),o.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:o.jsx(W9,{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(fde,{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(cde,{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(dde,{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(J9,{className:"w-4 h-4"})})]}),o.jsx(L$e,{editor:r})]})}function z7e({archiveId:t,archiveName:e,onClose:n}){const r=dn(),[i,a]=S.useState(!1),[s,l]=S.useState(null),[c,u]=S.useState({}),{data:d,isLoading:f,error:g}=pt({queryKey:["archive-project-page",t],queryFn:()=>_e.getArchiveProjectPage(t)}),p=_t({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?y():n())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[s,i,n]);const b=[...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)},x=()=>{p.mutate(c)},y=()=>{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,z=j.tagName.toLowerCase();if(!C.includes(z))return Array.from(j.childNodes).map(O).join("");let I="";if(z==="a"&&j.getAttribute("href")){const R=j.getAttribute("href");R?.toLowerCase().startsWith("http")&&(I=` href="${R}" target="_blank" rel="noopener noreferrer"`)}if(z==="img"){const R=j.getAttribute("src");if(!R?.toLowerCase().startsWith("http"))return"";I=` src="${R}" style="max-width: 100%; height: auto;"`}const q=Array.from(j.childNodes).map(O).join("");return["br","img"].includes(z)?`<${z}${I} />`:`<${z}${I}>${q}</${z}>`}return""};return Array.from(N.body.childNodes).map(O).join("")},w=d&&(d.title||d.description||d.designer||d.profile_title||b.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(Pe,{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(Pe,{variant:"ghost",size:"sm",onClick:y,children:"Cancel"}),o.jsxs(Pe,{variant:"primary",size:"sm",onClick:x,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(i3,{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(i3,{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(ui,{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($j,{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($j,{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]})]})]}),b.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 (",b.length,")"]}),o.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:b.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(ui,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),s!==null&&b[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(ef,{className:"w-6 h-6 text-white"})}),o.jsx("img",{src:b[s].url,alt:b[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(b.length-1,s+1))},disabled:s===b.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," / ",b.length]})]})]})}const B7e=[.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 H7e({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=vr(),a=S.useRef(null),s=S.useRef(null),[l,c]=S.useState(!1),[u,d]=S.useState(0),[f,g]=S.useState(0),[p,b]=S.useState(0),[v,x]=S.useState(0),[y,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:z,isLoading:I}=pt({queryKey:["timelapse-info",t],queryFn:()=>_e.getTimelapseInfo(t)}),{data:q}=pt({queryKey:["timelapse-thumbnails",t],queryFn:()=>_e.getTimelapseThumbnails(t,15)}),R=_t({mutationFn:()=>_e.processTimelapse(t,{trimStart:p,trimEnd:v,speed:y,saveMode:"replace"},w||void 0),onSuccess:F=>{i(F.message,"success"),r?.(),n()},onError:F=>{i(F.message||"Processing failed","error")}});S.useEffect(()=>{z?.duration&&v===0&&x(z.duration)},[z?.duration,v]),S.useEffect(()=>{const F=V=>{V.key==="Escape"&&n()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[n]),S.useEffect(()=>{const F=a.current;if(!F)return;const V=()=>{const pe=F.currentTime;d(pe),pe>=v&&(F.currentTime=p)},ne=()=>{g(F.duration),v===0&&x(F.duration)},le=()=>c(!0),oe=()=>c(!1);return F.addEventListener("timeupdate",V),F.addEventListener("durationchange",ne),F.addEventListener("play",le),F.addEventListener("pause",oe),()=>{F.removeEventListener("timeupdate",V),F.removeEventListener("durationchange",ne),F.removeEventListener("play",le),F.removeEventListener("pause",oe)}},[p,v]),S.useEffect(()=>{const F=s.current,V=a.current;!F||!V||!T||(F.currentTime=V.currentTime,F.playbackRate=V.playbackRate,l&&!k?F.play().catch(()=>{}):F.pause())},[l,T,k]),S.useEffect(()=>{s.current&&(s.current.volume=k?0:N)},[N,k]),S.useEffect(()=>{a.current&&(a.current.playbackRate=y),s.current&&(s.current.playbackRate=y)},[y]);const W=S.useCallback(()=>{const F=a.current;F&&(l?F.pause():(F.currentTime<p&&(F.currentTime=p),F.play()))},[l,p]),K=F=>{const V=a.current;V&&(V.currentTime=Math.max(p,Math.min(v,F)))},G=F=>{const V=F.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,Z=ee/y;return I?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(xt,{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(Ih,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Pe,{variant:"primary",size:"sm",onClick:()=>R.mutate(),disabled:R.isPending,children:R.isPending?o.jsxs(o.Fragment,{children:[o.jsx(xt,{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:W,muted:!!T}),!l&&o.jsx("button",{onClick:W,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(Hc,{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(Fue,{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:q?.thumbnails.map((F,V)=>o.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${F})`}},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:F=>{const V=parseFloat(F.target.value);V<v-1&&(b(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:F=>{const V=parseFloat(F.target.value);V>p+1&&x(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:F=>K(parseFloat(F.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8260. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8261. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8262. [&::-webkit-slider-thumb]:cursor-pointer`}),o.jsx("div",{className:"flex items-center justify-center gap-2",children:o.jsx("button",{onClick:W,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?o.jsx(yR,{className:"w-5 h-5 text-white"}):o.jsx(Hc,{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(rM,{className:"w-4 h-4"}),o.jsx("span",{children:"Speed"}),o.jsxs("span",{className:"ml-auto",children:[y,"x (output: ",Xm(Z),")"]})]}),o.jsx("div",{className:"flex gap-1",children:B7e.map(F=>o.jsxs("button",{onClick:()=>E(F),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${y===F?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[F,"x"]},F))})]}),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(r3,{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(r3,{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(Pde,{className:"w-4 h-4 text-bambu-gray"}):o.jsx(Cde,{className:"w-4 h-4 text-bambu-green"})}),o.jsx("input",{type:"range",min:0,max:1,step:.1,value:N,onChange:F=>O(parseFloat(F.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8263. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8264. [&::-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(Rn,{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(ua,{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:G,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)," @ ",z?.width,"x",z?.height]}),o.jsxs("p",{className:"text-bambu-gray",children:[o.jsx("span",{className:"text-white",children:"Output:"})," ",Xm(Z)," @ ",y,"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(xt,{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 $7e=[.25,.5,.75,1,1.5,2,3,4];function V7e({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,b]=S.useState(0),[v,x]=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=()=>b(N.duration),j=()=>c(!0),z=()=>c(!1);return N.addEventListener("timeupdate",O),N.addEventListener("durationchange",k),N.addEventListener("play",j),N.addEventListener("pause",z),()=>{N.removeEventListener("timeupdate",O),N.removeEventListener("durationchange",k),N.removeEventListener("play",j),N.removeEventListener("pause",z)}},[]);const y=()=>{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(Ih,{className:"w-5 h-5 text-bambu-green"}),e]}),o.jsxs("div",{className:"flex items-center gap-2",children:[r&&o.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>x(!0),children:[o.jsx(Bc,{className:"w-4 h-4"}),"Edit"]}),o.jsxs(Pe,{variant:"secondary",size:"sm",onClick:C,children:[o.jsx(Wi,{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:y}),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
  8265. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8266. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8267. [&::-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(Yue,{className:"w-5 h-5 text-bambu-gray"})}),o.jsx("button",{onClick:y,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?o.jsx(yR,{className:"w-5 h-5 text-white"}):o.jsx(Hc,{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(q1,{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:$7e.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(H7e,{archiveId:r,timelapseSrc:t,onClose:()=>x(!1),onSave:a})]})}function _te({archiveId:t,archiveName:e,onClose:n}){const r=dn(),{showToast:i}=vr(),[a,s]=S.useState(null),[l,c]=S.useState("asap"),[u,d]=S.useState(""),[f,g]=S.useState(!1),[p,b]=S.useState(!1),{data:v}=pt({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 x=_t({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")}}),y=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,manual_start:l==="manual"};l==="scheduled"&&u&&(A.scheduled_time=new Date(u).toISOString()),x.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(At,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:o.jsxs(Tt,{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:y,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(Sa,{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-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 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"]}),o.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 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"]}),o.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${l==="manual"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("manual"),children:[o.jsx(mR,{className:"w-4 h-4"}),"Queue Only"]})]})]}),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=>b(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.":l==="scheduled"?"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available.":"Print will be staged but won't start automatically. Use the Start button to release it to the queue."}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(Pe,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),o.jsx(Pe,{type:"submit",className:"flex-1",disabled:x.isPending||!a||v?.length===0,children:x.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function G7e({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}=pt({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(xt,{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(qn,{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(W7e,{comparison:n}):null}),o.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:o.jsx(Pe,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function W7e({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(qn,{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(qn,{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(go,{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 q7e(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function K7e(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 X7e({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),[b,v]=S.useState(!1);return o.jsx(At,{children:o.jsxs(Tt,{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(V9,{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:q7e(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"}),K7e(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(Os,{className:"w-5 h-5"})}),o.jsx(Pe,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:g||void 0}),disabled:i,children:i?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsxs(o.Fragment,{children:[o.jsx(co,{className:"w-4 h-4"}),"Archive"]})}),o.jsx(Pe,{variant:"secondary",size:"sm",onClick:()=>v(!0),disabled:a,children:a?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Rn,{className:"w-4 h-4 text-red-400"})})]})]}),b&&o.jsx(mr,{title:"Discard Upload",message:`Are you sure you want to discard "${t.filename}"? This cannot be undone.`,confirmText:"Discard",variant:"danger",onConfirm:()=>{r(t.id),v(!1)},onCancel:()=>v(!1)}),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 Y7e(){const t=dn(),{showToast:e}=vr(),[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}=pt({queryKey:["pending-uploads"],queryFn:yx.list,refetchInterval:1e4}),{data:g}=pt({queryKey:["projects"],queryFn:()=>_e.getProjects()}),p=_t({mutationFn:({id:y,data:E})=>yx.archive(y,E),onMutate:({id:y})=>{l(E=>new Set(E).add(y))},onSettled:(y,E,{id:w})=>{l(A=>{const T=new Set(A);return T.delete(w),T})},onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${y.print_name}`)},onError:y=>{e(y.message||"Failed to archive","error")}}),b=_t({mutationFn:y=>yx.discard(y),onMutate:y=>{u(E=>new Set(E).add(y))},onSettled:(y,E,w)=>{u(A=>{const T=new Set(A);return T.delete(w),T})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:y=>{e(y.message||"Failed to discard","error")}}),v=_t({mutationFn:yx.archiveAll,onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${y.archived} files${y.failed>0?`, ${y.failed} failed`:""}`)},onError:y=>{e(y.message||"Failed to archive all","error")}}),x=_t({mutationFn:yx.discardAll,onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${y.discarded} files`)},onError:y=>{e(y.message||"Failed to discard all","error")}});return f?o.jsx(At,{children:o.jsx(Tt,{className:"py-8 flex justify-center",children:o.jsx(xt,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:o.jsxs("div",{className:"mb-6",children:[o.jsxs(At,{className:"border-l-4 border-l-yellow-500",children:[o.jsx(Ui,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ua,{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(Pe,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:v.isPending,children:v.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsxs(o.Fragment,{children:[o.jsx(co,{className:"w-4 h-4"}),"Archive All"]})}),o.jsx(Pe,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:x.isPending,children:x.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsxs(o.Fragment,{children:[o.jsx(Rn,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),o.jsxs(Tt,{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(y=>o.jsx(X7e,{upload:y,projects:g||[],onArchive:(E,w)=>p.mutate({id:E,data:w}),onDiscard:E=>b.mutate(E),isArchiving:s.has(y.id),isDiscarding:c.has(y.id)},y.id))})]})]}),n&&o.jsx(mr,{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(mr,{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:()=>{x.mutate(),a(!1)},onCancel:()=>a(!1)})]})}function Vj(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 FG(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Z7e({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a}){const s=dn(),{showToast:l}=vr(),c=iW(),[u,d]=S.useState(!1),[f,g]=S.useState(!1),[p,b]=S.useState(!1),[v,x]=S.useState(!1),[y,E]=S.useState(!1),[w,A]=S.useState(!1),[T,C]=S.useState([]),[N,O]=S.useState(!1),[k,j]=S.useState(!1),[z,I]=S.useState(!1),[q,R]=S.useState(!1),[W,K]=S.useState(!1),[G,J]=S.useState(null),ee=S.useRef(null),Z=_t({mutationFn:ue=>_e.uploadSource3mf(t.id,ue),onSuccess:ue=>{s.invalidateQueries({queryKey:["archives"]}),l(`Source 3MF attached: ${ue.filename}`)},onError:ue=>{l(ue.message||"Failed to upload source 3MF","error")}}),F=_t({mutationFn:()=>_e.deleteSource3mf(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),l("Source 3MF removed")},onError:ue=>{l(ue.message||"Failed to remove source 3MF","error")}}),V=_t({mutationFn:()=>_e.scanArchiveTimelapse(t.id),onSuccess:ue=>{ue.status==="attached"?(s.invalidateQueries({queryKey:["archives"]}),l(`Timelapse attached: ${ue.filename}`)):ue.status==="exists"?l("Timelapse already attached"):ue.status==="not_found"&&ue.available_files&&ue.available_files.length>0?(C(ue.available_files),A(!0)):l(ue.message||"No matching timelapse found","warning")},onError:ue=>{l(ue.message||"Failed to scan for timelapse","error")}}),ne=_t({mutationFn:ue=>_e.selectArchiveTimelapse(t.id,ue),onSuccess:ue=>{s.invalidateQueries({queryKey:["archives"]}),l(`Timelapse attached: ${ue.filename}`),A(!1),C([])},onError:ue=>{l(ue.message||"Failed to attach timelapse","error")}}),le=_t({mutationFn:()=>_e.deleteArchive(t.id),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),l("Archive deleted")},onError:()=>{l("Failed to delete archive","error")}}),oe=_t({mutationFn:()=>_e.toggleFavorite(t.id),onSuccess:ue=>{s.invalidateQueries({queryKey:["archives"]}),l(ue.is_favorite?"Added to favorites":"Removed from favorites")}}),pe=_t({mutationFn:ue=>_e.updateArchive(t.id,{project_id:ue}),onSuccess:()=>{s.invalidateQueries({queryKey:["archives"]}),s.invalidateQueries({queryKey:["projects"]}),l("Project updated")},onError:()=>{l("Failed to update project","error")}}),Q=ue=>{ue.preventDefault(),J({x:ue.clientX,y:ue.clientY})},he=[...t.filename?.toLowerCase().includes(".gcode.")?[{label:"Print",icon:o.jsx(qi,{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(ui,{className:"w-4 h-4"}),onClick:()=>{const ue=t.print_name||t.filename||"model",Ae=`${window.location.origin}${_e.getArchiveForSlicer(t.id,ue)}`;vh(Ae)}}]:[{label:"Slice",icon:o.jsx(ui,{className:"w-4 h-4"}),onClick:()=>{const ue=t.print_name||t.filename||"model",Ae=`${window.location.origin}${_e.getArchiveForSlicer(t.id,ue)}`;vh(Ae)}}],{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(bd,{className:"w-4 h-4"}),onClick:()=>d(!0)},{label:"View Timelapse",icon:o.jsx(Ih,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:o.jsx(Lue,{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(Jk,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const ue=document.createElement("a");ue.href=_e.getSource3mfDownloadUrl(t.id),ue.download=`${t.print_name||t.filename}_source.3mf`,ue.click()}else ee.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:o.jsx(ua,{className:"w-4 h-4"}),onClick:()=>ee.current?.click()},{label:"Remove Source 3MF",icon:o.jsx(Rn,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:o.jsx(Wi,{className:"w-4 h-4"}),onClick:()=>{const ue=document.createElement("a");ue.href=_e.getArchiveDownload(t.id),ue.download=`${t.print_name||t.filename}.3mf`,ue.click()}},{label:"Copy Download Link",icon:o.jsx(vl,{className:"w-4 h-4"}),onClick:()=>{const ue=`${window.location.origin}${_e.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(ue).then(()=>{l("Link copied to clipboard")}).catch(()=>{l("Failed to copy link","error")})}},{label:"QR Code",icon:o.jsx(Cue,{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:()=>I(!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:()=>oe.mutate()},{label:"Edit",icon:o.jsx(Bc,{className:"w-4 h-4"}),onClick:()=>x(!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 ue=[];if(t.project_id&&ue.push({label:"Remove from Project",icon:o.jsx(Wt,{className:"w-4 h-4"}),onClick:()=>pe.mutate(null)}),!a)ue.push({label:"Loading...",icon:o.jsx(xt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const Ae=a.filter(fe=>fe.status==="active");Ae.length===0?ue.push({label:"No projects available",icon:o.jsx(Bo,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):Ae.forEach(fe=>{ue.push({label:fe.name,icon:o.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:fe.color||"#888"}}),onClick:()=>pe.mutate(fe.id),disabled:t.project_id===fe.id})})}return ue})()},{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(Rn,{className:"w-4 h-4"}),onClick:()=>b(!0),danger:!0}];return o.jsxs(At,{className:`relative flex flex-col ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,onContextMenu:Q,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:ue=>{ue.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:ue=>{ue.stopPropagation();const Ae=ue.currentTarget.getBoundingClientRect();J({x:Ae.left,y:Ae.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:ue=>{ue.stopPropagation(),oe.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:ue=>{ue.stopPropagation();const Ae=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",fe=`${window.location.origin}${_e.getSource3mfForSlicer(t.id,Ae)}`;vh(fe)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:o.jsx(Jk,{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:ue=>{ue.stopPropagation(),E(!0)},title:"View timelapse",children:o.jsx(Ih,{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:ue=>{ue.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(Tt,{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(ue=>ue.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(ue=>ue.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)}
  8268. Actual: ${Vx(t.actual_time_seconds||0)}
  8269. 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(vd,{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((ue,Ae)=>o.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:ue},title:ue},Ae))})]})]}),(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(K9,{className:"w-3 h-3"})}),t.tags?.split(",").map((ue,Ae)=>o.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:ue.trim()},Ae))]}),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:FG(t.created_at)}),o.jsx("span",{children:Vj(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(Pe,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>g(!0),children:[o.jsx(qi,{className:"w-3 h-3 flex-shrink-0"}),o.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),o.jsx(Pe,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ue=t.print_name||t.filename||"model",Ae=`${window.location.origin}${_e.getArchiveForSlicer(t.id,ue)}`;vh(Ae)},title:"Open in Bambu Studio",children:o.jsx(ui,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):o.jsxs(Pe,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const ue=t.print_name||t.filename||"model",Ae=`${window.location.origin}${_e.getArchiveForSlicer(t.id,ue)}`;vh(Ae)},title:"Open in Bambu Studio to slice",children:[o.jsx(ui,{className:"w-3 h-3 flex-shrink-0"}),o.jsx("span",{className:"hidden sm:inline",children:"Slice"})]}),o.jsx(Pe,{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(Pe,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>d(!0),title:"3D Preview",children:o.jsx(bd,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),o.jsx(Pe,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ue=document.createElement("a");ue.href=_e.getArchiveDownload(t.id),ue.download=`${t.print_name||t.filename}.3mf`,ue.click()},title:"Download",children:o.jsx(Wi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),o.jsx(Pe,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:"Edit",children:o.jsx(Bc,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),o.jsx(Pe,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>b(!0),title:"Delete",children:o.jsx(Rn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),v&&o.jsx(gze,{archive:t,onClose:()=>x(!1)}),u&&o.jsx(dze,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>d(!1)}),f&&o.jsx(hze,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>g(!1),onSuccess:()=>{}}),p&&o.jsx(mr,{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:()=>{le.mutate(),b(!1)},onCancel:()=>b(!1)}),W&&o.jsx(mr,{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:()=>{F.mutate(),K(!1)},onCancel:()=>K(!1)}),G&&o.jsx(xze,{x:G.x,y:G.y,items:he,onClose:()=>J(null)}),y&&t.timelapse_path&&o.jsx(V7e,{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(ue=>o.jsxs("button",{onClick:()=>ne.mutate(ue.name),disabled:ne.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(Ih,{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:ue.name}),o.jsxs("p",{className:"text-sm text-gray-400",children:[Vj(ue.size),ue.mtime&&` • ${FG(ue.mtime)}`]})]})]},ue.name))}),o.jsx("div",{className:"p-4 border-t border-gray-700",children:o.jsx(Pe,{variant:"secondary",onClick:()=>{A(!1),C([])},className:"w-full",children:"Cancel"})})]})}),N&&o.jsx(Mze,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>O(!1)}),k&&t.photos&&t.photos.length>0&&o.jsx(Eze,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>j(!1),onDelete:async ue=>{try{await _e.deleteArchivePhoto(t.id,ue),s.invalidateQueries({queryKey:["archives"]}),l("Photo deleted")}catch{l("Failed to delete photo","error")}}}),z&&o.jsx(z7e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>I(!1)}),q&&o.jsx(_te,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),o.jsx("input",{ref:ee,type:"file",accept:".3mf",className:"hidden",onChange:ue=>{const Ae=ue.target.files?.[0];Ae&&Z.mutate(Ae),ue.target.value=""}})]})}const Q7e=[{id:"all",label:"All Archives",icon:o.jsx(rce,{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(Sa,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:o.jsx(vl,{className:"w-4 h-4"})}];function J7e(){const t=dn(),{showToast:e}=vr(),n=S.useRef(null),[r,i]=S.useState(""),[a,s]=S.useState(()=>{const me=localStorage.getItem("archiveFilterPrinter");return me?Number(me):null}),[l,c]=S.useState(()=>localStorage.getItem("archiveFilterMaterial")),[u,d]=S.useState(()=>{const me=localStorage.getItem("archiveFilterColors");return me?new Set(JSON.parse(me)):new Set}),[f,g]=S.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[p,b]=S.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[v,x]=S.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[y,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),[z,I]=S.useState(new Set),[q,R]=S.useState(!1),[W,K]=S.useState(!1),[G,J]=S.useState(!1),[ee,Z]=S.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[F,V]=S.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[ne,le]=S.useState(()=>localStorage.getItem("archiveCollection")||"all"),[oe,pe]=S.useState(!1),[Q,Ee]=S.useState(!1),[he,ue]=S.useState(!1),{data:Ae,isLoading:fe}=pt({queryKey:["archives",a],queryFn:()=>_e.getArchives(a||void 0)}),{data:at}=pt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:B}=pt({queryKey:["projects"],queryFn:()=>_e.getProjects()}),$=_t({mutationFn:async me=>(await Promise.all(me.map(ae=>_e.deleteArchive(ae))),me.length),onSuccess:me=>{t.invalidateQueries({queryKey:["archives"]}),I(new Set),e(`${me} archive${me!==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(()=>{y?localStorage.setItem("archiveFilterTag",y):localStorage.removeItem("archiveFilterTag")},[y]),S.useEffect(()=>{localStorage.setItem("archiveFilterFileType",w)},[w]),S.useEffect(()=>{localStorage.setItem("archiveViewMode",ee)},[ee]),S.useEffect(()=>{localStorage.setItem("archiveSortBy",F)},[F]),S.useEffect(()=>{localStorage.setItem("archiveCollection",ne)},[ne]);const ie=new Map(at?.map(me=>[me.id,me.name])||[]),H=[...new Set(Ae?.flatMap(me=>me.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),Y=[...new Set(Ae?.flatMap(me=>me.filament_color?.split(",")||[]).filter(Boolean)||[])],se=[...new Set(Ae?.flatMap(me=>me.tags?.split(",").map(ae=>ae.trim())||[]).filter(Boolean)||[])].sort(),ve=Ae?.filter(me=>{const ae=new Date,He=new Date(me.created_at);let Be=!0;switch(ne){case"recent":Be=ae.getTime()-He.getTime()<1440*60*1e3;break;case"this-week":Be=ae.getTime()-He.getTime()<10080*60*1e3;break;case"this-month":Be=He.getMonth()===ae.getMonth()&&He.getFullYear()===ae.getFullYear();break;case"favorites":Be=me.is_favorite===!0;break;case"failed":Be=me.status==="failed"||me.status==="aborted";break;case"duplicates":Be=me.duplicate_count>0;break}const Ye=(me.print_name||me.filename).toLowerCase().includes(r.toLowerCase()),ot=!l||me.filament_type?.split(", ").includes(l),ge=me.filament_color?.split(",")||[],nt=u.size===0||(f==="or"?ge.some(Et=>u.has(Et)):[...u].every(Et=>ge.includes(Et))),xe=ne==="favorites"||!p||me.is_favorite,ze=ne==="failed"||!v||me.status!=="failed"&&me.status!=="aborted",Re=me.tags?.split(",").map(Et=>Et.trim())||[],we=!y||Re.includes(y),Ke=me.filename?.toLowerCase().includes(".gcode.");return Be&&Ye&&ot&&nt&&xe&&ze&&we&&(w==="all"||w==="gcode"&&Ke||w==="source"&&!Ke)}).sort((me,ae)=>{switch(F){case"date-desc":return new Date(ae.created_at).getTime()-new Date(me.created_at).getTime();case"date-asc":return new Date(me.created_at).getTime()-new Date(ae.created_at).getTime();case"name-asc":return(me.print_name||me.filename).localeCompare(ae.print_name||ae.filename);case"name-desc":return(ae.print_name||ae.filename).localeCompare(me.print_name||me.filename);case"size-desc":return ae.file_size-me.file_size;case"size-asc":return me.file_size-ae.file_size;default:return 0}}),Ne=q||z.size>0,Se=me=>{I(ae=>{const He=new Set(ae);return He.has(me)?He.delete(me):He.add(me),He})},U=()=>{ve&&I(new Set(ve.map(me=>me.id)))},L=()=>{I(new Set),R(!1)},te=me=>{d(ae=>{const He=new Set(ae);return He.has(me)?He.delete(me):He.add(me),He})},ye=()=>{d(new Set)},Me=()=>{i(""),s(null),c(null),b(!1),x(!1),E(null),A("all")},be=r||a||l||p||v||y||w!=="all",qe=S.useCallback(me=>{me.preventDefault(),me.dataTransfer.types.includes("Files")&&j(!0)},[]),Ve=S.useCallback(me=>{me.preventDefault(),me.currentTarget===me.target&&j(!1)},[]),We=S.useCallback(me=>{me.preventDefault(),j(!1);const ae=Array.from(me.dataTransfer.files).filter(He=>He.name.endsWith(".3mf"));ae.length>0?(O(ae),C(!0)):me.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),lt=S.useCallback(me=>{const ae=me.target;if(ae.tagName==="INPUT"||ae.tagName==="TEXTAREA"||ae.isContentEditable){me.key==="Escape"&&ae.blur();return}switch(me.key){case"/":me.preventDefault(),n.current?.focus();break;case"u":case"U":!me.metaKey&&!me.ctrlKey&&(me.preventDefault(),C(!0));break;case"Escape":Ne&&L();break}},[Ne]);return S.useEffect(()=>(document.addEventListener("keydown",lt),()=>document.removeEventListener("keydown",lt)),[lt]),o.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:qe,onDragLeave:Ve,onDrop:We,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(ua,{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"})]})}),Ne&&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(Pe,{variant:"secondary",size:"sm",onClick:L,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:[z.size," selected"]}),o.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),o.jsx(Pe,{variant:"secondary",size:"sm",onClick:U,children:"Select All"}),o.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),o.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>J(!0),children:[o.jsx(Cp,{className:"w-4 h-4"}),"Tags"]}),o.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>{const me=Array.from(z);Promise.all(me.map(ae=>_e.toggleFavorite(ae))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${me.length} archive${me.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[o.jsx(Np,{className:"w-4 h-4"}),"Favorite"]}),o.jsxs(Pe,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>K(!0),children:[o.jsx(Rn,{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:ne,onChange:me=>le(me.target.value),children:Q7e.map(me=>o.jsx("option",{value:me.id,children:me.label},me.id))})]}),o.jsxs("p",{className:"text-bambu-gray",children:[ve?.length||0," of ",Ae?.length||0," prints"]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"relative",children:[o.jsxs(Pe,{variant:"secondary",onClick:()=>pe(!oe),disabled:Q,children:[Q?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(V1,{className:"w-4 h-4"}),"Export"]}),oe&&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()=>{pe(!1),Ee(!0);try{const{blob:me,filename:ae}=await _e.exportArchives({format:"csv",printerId:a||void 0,status:ne==="failed"?"failed":void 0,search:r||void 0}),He=URL.createObjectURL(me),Be=document.createElement("a");Be.href=He,Be.download=ae,Be.click(),URL.revokeObjectURL(He),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()=>{pe(!1),Ee(!0);try{const{blob:me,filename:ae}=await _e.exportArchives({format:"xlsx",printerId:a||void 0,status:ne==="failed"?"failed":void 0,search:r||void 0}),He=URL.createObjectURL(me),Be=document.createElement("a");Be.href=He,Be.download=ae,Be.click(),URL.revokeObjectURL(He),e("Export downloaded")}catch{e("Export failed","error")}finally{Ee(!1)}},children:[o.jsx(V1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),z.size>=2&&z.size<=5&&o.jsxs(Pe,{variant:"secondary",onClick:()=>ue(!0),children:[o.jsx(dp,{className:"w-4 h-4"}),"Compare (",z.size,")"]}),!Ne&&o.jsxs(Pe,{variant:"secondary",onClick:()=>R(!0),children:[o.jsx(rf,{className:"w-4 h-4"}),"Select"]}),o.jsxs(Pe,{onClick:()=>C(!0),children:[o.jsx(ua,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),o.jsx(At,{className:"mb-6",children:o.jsxs(Tt,{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:me=>i(me.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(fR,{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:me=>s(me.target.value?Number(me.target.value):null),children:[o.jsx("option",{value:"",children:"All Printers"}),at?.map(me=>o.jsx("option",{value:me.id,children:me.name},me.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:me=>c(me.target.value||null),children:[o.jsx("option",{value:"",children:"All Materials"}),H.map(me=>o.jsx("option",{value:me,children:me},me))]})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx(Jk,{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:me=>A(me.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:()=>b(!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:()=>x(!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(Sa,{className:"w-4 h-4 "}),o.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),se.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:y||"",onChange:me=>E(me.target.value||null),children:[o.jsx("option",{value:"",children:"All Tags"}),se.map(me=>o.jsx("option",{value:me,children:me},me))]})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx(Uoe,{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:F,onChange:me=>V(me.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:()=>Z("grid"),title:"Grid view",children:o.jsx(gR,{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:()=>Z("list"),title:"List view",children:o.jsx(xR,{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:()=>Z("calendar"),title:"Calendar view",children:o.jsx(Joe,{className:"w-4 h-4"})})]})]}),be&&o.jsxs(Pe,{variant:"ghost",size:"sm",onClick:Me,className:"text-bambu-gray hover:text-white",children:[o.jsx(Wt,{className:"w-4 h-4"}),"Reset"]})]}),Y.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(me=>me==="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:Y.map(me=>o.jsx("button",{onClick:()=>te(me),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(me)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:me},title:me},me))}),u.size>0&&o.jsxs("button",{onClick:ye,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(Y7e,{}),fe?o.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):ve?.length===0?o.jsx(At,{children:o.jsxs(Tt,{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(At,{className:"p-6",children:o.jsx(Sze,{archives:ve||[],onArchiveClick:me=>{i(me.print_name||me.filename),Z("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:ve?.map(me=>o.jsx(Z7e,{archive:me,printerName:me.printer_id?ie.get(me.printer_id)||"Unknown":"No Printer",isSelected:z.has(me.id),onSelect:Se,selectionMode:Ne,projects:B},me.id))}):ee==="list"?o.jsx(At,{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"})]}),ve?.map(me=>o.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${z.has(me.id)?"bg-bambu-green/10":""}`,children:[o.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[Ne&&o.jsx("button",{onClick:()=>Se(me.id),children:z.has(me.id)?o.jsx(rf,{className:"w-4 h-4 text-bambu-green"}):o.jsx(af,{className:"w-4 h-4 text-bambu-gray"})}),me.thumbnail_path?o.jsx("img",{src:_e.getArchiveThumbnail(me.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:me.print_name||me.filename}),me.timelapse_path&&o.jsx("span",{title:"Has timelapse",children:o.jsx(Ih,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),me.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:me.filament_type}),me.filament_color&&o.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:me.filament_color.split(",").map((ae,He)=>o.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:ae},title:ae},He))})]})]}),o.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:me.printer_id?ie.get(me.printer_id)||"Unknown":"No Printer"}),o.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(me.created_at).toLocaleDateString()}),o.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:Vj(me.file_size)}),o.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[o.jsx(Pe,{variant:"ghost",size:"sm",onClick:()=>{const ae=me.print_name||me.filename||"model",He=`${window.location.origin}${_e.getArchiveForSlicer(me.id,ae)}`;vh(He)},title:"Slice",children:o.jsx(ui,{className:"w-4 h-4"})}),me.makerworld_url&&o.jsx(Pe,{variant:"ghost",size:"sm",onClick:()=>window.open(me.makerworld_url,"_blank"),title:"MakerWorld",children:o.jsx(Ap,{className:"w-4 h-4"})}),o.jsx(Pe,{variant:"ghost",size:"sm",onClick:()=>{const ae=document.createElement("a");ae.href=_e.getArchiveDownload(me.id),ae.download=`${me.print_name||me.filename}.3mf`,ae.click()},title:"Download",children:o.jsx(Wi,{className:"w-4 h-4"})})]})]},me.id))]})}):null,T&&o.jsx(fze,{onClose:()=>{C(!1),O([])},initialFiles:N}),W&&o.jsx(mr,{title:"Delete Archives",message:`Are you sure you want to delete ${z.size} archive${z.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${z.size}`,variant:"danger",onConfirm:()=>{$.mutate(Array.from(z)),K(!1)},onCancel:()=>K(!1)}),G&&o.jsx(bze,{selectedIds:Array.from(z),existingTags:se,onClose:()=>J(!1)}),he&&z.size>=2&&z.size<=5&&o.jsx(G7e,{archiveIds:Array.from(z),onClose:()=>{ue(!1),I(new Set),R(!1)}})]})}function eGe(){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 AE=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 zL(t){return"nodeType"in t}function us(t){var e,n;return t?Eg(t)?t:zL(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function BL(t){const{Document:e}=us(t);return t instanceof e}function fy(t){return Eg(t)?!1:t instanceof us(t).HTMLElement}function wte(t){return t instanceof us(t).SVGElement}function Ag(t){return t?Eg(t)?t.document:zL(t)?BL(t)?t:fy(t)||wte(t)?t.ownerDocument:document:document:document}const kl=AE?S.useLayoutEffect:S.useEffect;function HL(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 tGe(){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 qS(t){const e=HL(t),n=S.useRef(null),r=S.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function Gj(t){const e=S.useRef();return S.useEffect(()=>{e.current=t},[t]),e.current}let Nk={};function py(t,e){return S.useMemo(()=>{if(e)return e;const n=Nk[t]==null?0:Nk[t]+1;return Nk[t]=n,t+"-"+n},[t,e])}function Ste(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=Ste(1),vb=Ste(-1);function nGe(t){return"clientX"in t&&"clientY"in t}function $L(t){if(!t)return!1;const{KeyboardEvent:e}=us(t.target);return e&&t instanceof e}function rGe(t){if(!t)return!1;const{TouchEvent:e}=us(t.target);return e&&t instanceof e}function Wj(t){if(rGe(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 nGe(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}}}),UG="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function iGe(t){return t.matches(UG)?t:t.querySelector(UG)}const aGe={display:"none"};function sGe(t){let{id:e,value:n}=t;return kr.createElement("div",{id:e,style:aGe},n)}function oGe(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 kr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function lGe(){const[t,e]=S.useState("");return{announce:S.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const Mte=S.createContext(null);function cGe(t){const e=S.useContext(Mte);S.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function uGe(){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 dGe={draggable:`
  8270. To pick up a draggable item, press the space bar.
  8271. While dragging, use the arrow keys to move the item.
  8272. Press space again to drop the item in its new position, or press escape to cancel.
  8273. `},hGe={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 fGe(t){let{announcements:e=hGe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=dGe}=t;const{announce:a,announcement:s}=lGe(),l=py("DndLiveRegion"),[c,u]=S.useState(!1);if(S.useEffect(()=>{u(!0)},[]),cGe(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=kr.createElement(kr.Fragment,null,kr.createElement(sGe,{id:r,value:i.draggable}),kr.createElement(oGe,{id:l,announcement:s}));return n?Mc.createPortal(d,n):d}var vi;(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"})(vi||(vi={}));function KS(){}function XS(t,e){return S.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Ete(){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 Ate(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Tte(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function mGe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function zG(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 Nte(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function BG(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 Cte=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=BG(e,e.left,e.top),a=[];for(const s of r){const{id:l}=s,c=n.get(l);if(c){const u=Ate(BG(c),i);a.push({id:l,data:{droppableContainer:s,value:u}})}}return a.sort(Tte)},pGe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=zG(e),a=[];for(const s of r){const{id:l}=s,c=n.get(l);if(c){const u=zG(c),d=i.reduce((g,p,b)=>g+Ate(u[b],p),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:s,value:f}})}}return a.sort(Tte)};function gGe(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 xGe=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=gGe(l,e);c>0&&i.push({id:s,data:{droppableContainer:a,value:c}})}}return i.sort(mGe)};function bGe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function kte(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Wo}function yGe(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 vGe=yGe(1);function _Ge(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 wGe(t,e,n){const r=_Ge(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 SGe={ignoreTransform:!1};function Tg(t,e){e===void 0&&(e=SGe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=us(t).getComputedStyle(t);u&&(n=wGe(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 HG(t){return Tg(t,{ignoreTransform:!0})}function MGe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function EGe(t,e){return e===void 0&&(e=us(t).getComputedStyle(t)),e.position==="fixed"}function AGe(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 TE(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(BL(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!fy(i)||wte(i)||n.includes(i))return n;const a=us(t).getComputedStyle(i);return i!==t&&AGe(i,a)&&n.push(i),EGe(i,a)?n:r(i.parentNode)}return t?r(t):n}function Pte(t){const[e]=TE(t,1);return e??null}function Ck(t){return!AE||!t?null:Eg(t)?t:zL(t)?BL(t)||t===Ag(t).scrollingElement?window:fy(t)?t:null:null}function jte(t){return Eg(t)?t.scrollX:t.scrollLeft}function Rte(t){return Eg(t)?t.scrollY:t.scrollTop}function qj(t){return{x:jte(t),y:Rte(t)}}var Bi;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Bi||(Bi={}));function Dte(t){return!AE||!t?!1:t===document.scrollingElement}function Ote(t){const e={x:0,y:0},n=Dte(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 TGe={x:.2,y:.2};function NGe(t,e,n,r,i){let{top:a,left:s,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=TGe);const{isTop:u,isBottom:d,isLeft:f,isRight:g}=Ote(t),p={x:0,y:0},b={x:0,y:0},v={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+v.height?(p.y=Bi.Backward,b.y=r*Math.abs((e.top+v.height-a)/v.height)):!d&&c>=e.bottom-v.height&&(p.y=Bi.Forward,b.y=r*Math.abs((e.bottom-v.height-c)/v.height)),!g&&l>=e.right-v.width?(p.x=Bi.Forward,b.x=r*Math.abs((e.right-v.width-l)/v.width)):!f&&s<=e.left+v.width&&(p.x=Bi.Backward,b.x=r*Math.abs((e.left+v.width-s)/v.width)),{direction:p,speed:b}}function CGe(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 Lte(t){return t.reduce((e,n)=>Sp(e,qj(n)),Wo)}function kGe(t){return t.reduce((e,n)=>e+jte(n),0)}function PGe(t){return t.reduce((e,n)=>e+Rte(n),0)}function jGe(t,e){if(e===void 0&&(e=Tg),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);Pte(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const RGe=[["x",["left","right"],kGe],["y",["top","bottom"],PGe]];class VL{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=TE(n),i=Lte(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,s,l]of RGe)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 DGe(t){const{EventTarget:e}=us(t);return t instanceof e?t:Ag(t)}function kk(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 to;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(to||(to={}));function $G(t){t.preventDefault()}function OGe(t){t.stopPropagation()}var On;(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"})(On||(On={}));const Ite={start:[On.Space,On.Enter],cancel:[On.Esc],end:[On.Space,On.Enter,On.Tab]},LGe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case On.Right:return{...n,x:n.x+25};case On.Left:return{...n,x:n.x-25};case On.Down:return{...n,y:n.y+25};case On.Up:return{...n,y:n.y-25}}};class NE{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(to.Resize,this.handleCancel),this.windowListeners.add(to.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(to.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&jGe(r),n(Wo)}handleKeyDown(e){if($L(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=Ite,coordinateGetter:s=LGe,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:b}=r.current;for(const v of b){const x=e.code,{isTop:y,isRight:E,isLeft:w,isBottom:A,maxScroll:T,minScroll:C}=Ote(v),N=CGe(v),O={x:Math.min(x===On.Right?N.right-N.width/2:N.right,Math.max(x===On.Right?N.left:N.left+N.width/2,f.x)),y:Math.min(x===On.Down?N.bottom-N.height/2:N.bottom,Math.max(x===On.Down?N.top:N.top+N.height/2,f.y))},k=x===On.Right&&!E||x===On.Left&&!w,j=x===On.Down&&!A||x===On.Up&&!y;if(k&&O.x!==f.x){const z=v.scrollLeft+g.x,I=x===On.Right&&z<=T.x||x===On.Left&&z>=C.x;if(I&&!g.y){v.scrollTo({left:z,behavior:l});return}I?p.x=v.scrollLeft-z:p.x=x===On.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 z=v.scrollTop+g.y,I=x===On.Down&&z<=T.y||x===On.Up&&z>=C.y;if(I&&!g.x){v.scrollTo({top:z,behavior:l});return}I?p.y=v.scrollTop-z:p.y=x===On.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()}}NE.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Ite,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 VG(t){return!!(t&&"distance"in t)}function GG(t){return!!(t&&"delay"in t)}class GL{constructor(e,n,r){var i;r===void 0&&(r=DGe(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=Wj(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(to.Resize,this.handleCancel),this.windowListeners.add(to.DragStart,$G),this.windowListeners.add(to.VisibilityChange,this.handleCancel),this.windowListeners.add(to.ContextMenu,$G),this.documentListeners.add(to.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(GG(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(VG(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(to.Click,OGe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(to.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=Wj(e))!=null?n:Wo,u=vb(i,c);if(!r&&l){if(VG(l)){if(l.tolerance!=null&&kk(u,l.tolerance))return this.handleCancel();if(kk(u,l.distance))return this.handleStart()}if(GG(l)&&kk(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===On.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const IGe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class CE extends GL{constructor(e){const{event:n}=e,r=Ag(n.target);super(e,IGe,r)}}CE.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 FGe={move:{name:"mousemove"},end:{name:"mouseup"}};var Kj;(function(t){t[t.RightClick=2]="RightClick"})(Kj||(Kj={}));class UGe extends GL{constructor(e){super(e,FGe,Ag(e.event.target))}}UGe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===Kj.RightClick?!1:(r?.({event:n}),!0)}}];const Pk={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class zGe extends GL{constructor(e){super(e,Pk)}static setup(){return window.addEventListener(Pk.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Pk.move.name,e)};function e(){}}}zGe.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 YS;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(YS||(YS={}));function BGe(t){let{acceleration:e,activator:n=A0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:s=5,order:l=YS.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:g}=t;const p=$Ge({delta:f,disabled:!a}),[b,v]=tGe(),x=S.useRef({x:0,y:0}),y=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=x.current.x*y.current.x,O=x.current.y*y.current.y;C.scrollBy(N,O)},[]),T=S.useMemo(()=>l===YS.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}=NGe(C,O,E,e,g);for(const z of["x","y"])p[z][k[z]]||(j[z]=0,k[z]=0);if(j.x>0||j.y>0){v(),w.current=C,b(A,s),x.current=j,y.current=k;return}}x.current={x:0,y:0},y.current={x:0,y:0},v()},[e,A,r,v,a,s,JSON.stringify(E),JSON.stringify(p),b,u,T,d,JSON.stringify(g)])}const HGe={x:{[Bi.Backward]:!1,[Bi.Forward]:!1},y:{[Bi.Backward]:!1,[Bi.Forward]:!1}};function $Ge(t){let{delta:e,disabled:n}=t;const r=Gj(e);return my(i=>{if(n||!r||!i)return HGe;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Bi.Backward]:i.x[Bi.Backward]||a.x===-1,[Bi.Forward]:i.x[Bi.Forward]||a.x===1},y:{[Bi.Backward]:i.y[Bi.Backward]||a.y===-1,[Bi.Forward]:i.y[Bi.Forward]||a.y===1}}},[n,e,r])}function VGe(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 GGe(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 Xj;(function(t){t.Optimized="optimized"})(Xj||(Xj={}));const WG=new Map;function WGe(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=x(),g=yb(f),p=S.useCallback(function(y){y===void 0&&(y=[]),!g.current&&s(E=>E===null?y:E.concat(y.filter(w=>!E.includes(w))))},[g]),b=S.useRef(null),v=my(y=>{if(f&&!n)return WG;if(!y||y===WG||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 VL(c(A),A):null;w.rect.current=T,T&&E.set(w.id,T)}return E}return y},[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"||b.current!==null||(b.current=setTimeout(()=>{p(),b.current=null},l))},[l,f,p,...r]),{droppableRects:v,measureDroppableContainers:p,measuringScheduled:a!=null};function x(){switch(u){case _b.Always:return!1;case _b.BeforeDragging:return n;default:return!n}}}function Fte(t,e){return my(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function qGe(t,e){return Fte(t,e)}function KGe(t){let{callback:e,disabled:n}=t;const r=HL(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 kE(t){let{callback:e,disabled:n}=t;const r=HL(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 XGe(t){return new VL(Tg(t),t)}function qG(t,e,n){e===void 0&&(e=XGe);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=KGe({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=kE({callback:a});return kl(()=>{a(),t?(l?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),s?.disconnect())},[t]),r}function YGe(t){const e=Fte(t);return kte(t,e)}const KG=[];function ZGe(t){const e=S.useRef(t),n=my(r=>t?r&&r!==KG&&t&&e.current&&t.parentNode===e.current.parentNode?r:TE(t):KG,[t]);return S.useEffect(()=>{e.current=t},[t]),n}function QGe(t){const[e,n]=S.useState(null),r=S.useRef(t),i=S.useCallback(a=>{const s=Ck(a.target);s&&n(l=>l?(l.set(s,qj(s)),new Map(l)):null)},[]);return S.useEffect(()=>{const a=r.current;if(t!==a){s(a);const l=t.map(c=>{const u=Ck(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,qj(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=Ck(c);u?.removeEventListener("scroll",i)})}},[i,t]),S.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,s)=>Sp(a,s),Wo):Lte(t):Wo,[t,e])}function XG(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 JGe(t){S.useEffect(()=>{if(!AE)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 e9e(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 Ute(t){return S.useMemo(()=>t?MGe(t):null,[t])}const YG=[];function t9e(t,e){e===void 0&&(e=Tg);const[n]=t,r=Ute(n?us(n):null),[i,a]=S.useState(YG);function s(){a(()=>t.length?t.map(c=>Dte(c)?r:new VL(e(c),c)):YG)}const l=kE({callback:s});return kl(()=>{l?.disconnect(),s(),t.forEach(c=>l?.observe(c))},[t]),i}function n9e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return fy(e)?e:t}function r9e(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=kE({callback:i}),s=S.useCallback(u=>{const d=n9e(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=qS(s);return S.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const i9e=[{sensor:CE,options:{}},{sensor:NE,options:{}}],a9e={current:{}},I1={draggable:{measure:HG},droppable:{measure:HG,strategy:_b.WhileDragging,frequency:Xj.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 s9e={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:KS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:I1,measureDroppableContainers:KS,windowRect:null,measuringScheduled:!1},o9e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:KS,draggableNodes:new Map,over:null,measureDroppableContainers:KS},PE=S.createContext(o9e),zte=S.createContext(s9e);function l9e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new T0}}}function c9e(t,e){switch(e.type){case vi.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case vi.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 vi.DragEnd:case vi.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case vi.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 vi.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 vi.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 u9e(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=S.useContext(PE),a=Gj(r),s=Gj(n?.id);return S.useEffect(()=>{if(!e&&!r&&a&&s!=null){if(!$L(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=iGe(d);if(f){f.focus();break}}})}},[r,e,i,s,a]),null}function d9e(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function h9e(t){return S.useMemo(()=>({draggable:{...I1.draggable,...t?.draggable},droppable:{...I1.droppable,...t?.droppable},dragOverlay:{...I1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function f9e(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=kte(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=Pte(u);g&&g.scrollBy({top:f.y,left:f.x})}},[e,s,l,r,n])}const Bte=S.createContext({...Wo,scaleX:1,scaleY:1});var Yu;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Yu||(Yu={}));const Hte=S.memo(function(e){var n,r,i,a;let{id:s,accessibility:l,autoScroll:c=!0,children:u,sensors:d=i9e,collisionDetection:f=xGe,measuring:g,modifiers:p,...b}=e;const v=S.useReducer(c9e,void 0,l9e),[x,y]=v,[E,w]=uGe(),[A,T]=S.useState(Yu.Uninitialized),C=A===Yu.Initialized,{draggable:{active:N,nodes:O,translate:k},droppable:{containers:j}}=x,z=N!=null?O.get(N):null,I=S.useRef({initial:null,translated:null}),q=S.useMemo(()=>{var ze;return N!=null?{id:N,data:(ze=z?.data)!=null?ze:a9e,rect:I}:null},[N,z]),R=S.useRef(null),[W,K]=S.useState(null),[G,J]=S.useState(null),ee=yb(b,Object.values(b)),Z=py("DndDescribedBy",s),F=S.useMemo(()=>j.getEnabled(),[j]),V=h9e(g),{droppableRects:ne,measureDroppableContainers:le,measuringScheduled:oe}=WGe(F,{dragging:C,dependencies:[k.x,k.y],config:V.droppable}),pe=VGe(O,N),Q=S.useMemo(()=>G?Wj(G):null,[G]),Ee=xe(),he=qGe(pe,V.draggable.measure);f9e({activeNode:N!=null?O.get(N):null,config:Ee.layoutShiftCompensation,initialRect:he,measure:V.draggable.measure});const ue=qG(pe,V.draggable.measure,he),Ae=qG(pe?pe.parentElement:null),fe=S.useRef({activatorEvent:null,active:null,activeNode:pe,collisionRect:null,collisions:null,droppableRects:ne,draggableNodes:O,draggingNode:null,draggingNodeRect:null,droppableContainers:j,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),at=j.getNodeFor((n=fe.current.over)==null?void 0:n.id),B=r9e({measure:V.dragOverlay.measure}),$=(r=B.nodeRef.current)!=null?r:pe,ie=C?(i=B.rect)!=null?i:ue:null,H=!!(B.nodeRef.current&&B.rect),Y=YGe(H?null:ue),se=Ute($?us($):null),ve=ZGe(C?at??pe:null),Ne=t9e(ve),Se=d9e(p,{transform:{x:k.x-Y.x,y:k.y-Y.y,scaleX:1,scaleY:1},activatorEvent:G,active:q,activeNodeRect:ue,containerNodeRect:Ae,draggingNodeRect:ie,over:fe.current.over,overlayNodeRect:B.rect,scrollableAncestors:ve,scrollableAncestorRects:Ne,windowRect:se}),U=Q?Sp(Q,k):null,L=QGe(ve),te=XG(L),ye=XG(L,[ue]),Me=Sp(Se,te),be=ie?vGe(ie,Se):null,qe=q&&be?f({active:q,collisionRect:be,droppableRects:ne,droppableContainers:F,pointerCoordinates:U}):null,Ve=Nte(qe,"id"),[We,lt]=S.useState(null),me=H?Se:Sp(Se,ye),ae=bGe(me,(a=We?.rect)!=null?a:null,ue),He=S.useRef(null),Be=S.useCallback((ze,Re)=>{let{sensor:we,options:Ke}=Re;if(R.current==null)return;const ft=O.get(R.current);if(!ft)return;const Et=ze.nativeEvent,wt=new we({active:R.current,activeNode:ft,event:Et,options:Ke,context:fe,onAbort(Ft){if(!O.get(Ft))return;const{onDragAbort:Hn}=ee.current,bt={id:Ft};Hn?.(bt),E({type:"onDragAbort",event:bt})},onPending(Ft,hn,Hn,bt){if(!O.get(Ft))return;const{onDragPending:an}=ee.current,mt={id:Ft,constraint:hn,initialCoordinates:Hn,offset:bt};an?.(mt),E({type:"onDragPending",event:mt})},onStart(Ft){const hn=R.current;if(hn==null)return;const Hn=O.get(hn);if(!Hn)return;const{onDragStart:bt}=ee.current,Ht={activatorEvent:Et,active:{id:hn,data:Hn.data,rect:I}};Mc.unstable_batchedUpdates(()=>{bt?.(Ht),T(Yu.Initializing),y({type:vi.DragStart,initialCoordinates:Ft,active:hn}),E({type:"onDragStart",event:Ht}),K(He.current),J(Et)})},onMove(Ft){y({type:vi.DragMove,coordinates:Ft})},onEnd:Qt(vi.DragEnd),onCancel:Qt(vi.DragCancel)});He.current=wt;function Qt(Ft){return async function(){const{active:Hn,collisions:bt,over:Ht,scrollAdjustedTranslate:an}=fe.current;let mt=null;if(Hn&&an){const{cancelDrop:Zt}=ee.current;mt={activatorEvent:Et,active:Hn,collisions:bt,delta:an,over:Ht},Ft===vi.DragEnd&&typeof Zt=="function"&&await Promise.resolve(Zt(mt))&&(Ft=vi.DragCancel)}R.current=null,Mc.unstable_batchedUpdates(()=>{y({type:Ft}),T(Yu.Uninitialized),lt(null),K(null),J(null),He.current=null;const Zt=Ft===vi.DragEnd?"onDragEnd":"onDragCancel";if(mt){const sn=ee.current[Zt];sn?.(mt),E({type:Zt,event:mt})}})}}},[O]),Ye=S.useCallback((ze,Re)=>(we,Ke)=>{const ft=we.nativeEvent,Et=O.get(Ke);if(R.current!==null||!Et||ft.dndKit||ft.defaultPrevented)return;const wt={active:Et};ze(we,Re.options,wt)===!0&&(ft.dndKit={capturedBy:Re.sensor},R.current=Ke,Be(we,Re))},[O,Be]),ot=GGe(d,Ye);JGe(d),kl(()=>{ue&&A===Yu.Initializing&&T(Yu.Initialized)},[ue,A]),S.useEffect(()=>{const{onDragMove:ze}=ee.current,{active:Re,activatorEvent:we,collisions:Ke,over:ft}=fe.current;if(!Re||!we)return;const Et={active:Re,activatorEvent:we,collisions:Ke,delta:{x:Me.x,y:Me.y},over:ft};Mc.unstable_batchedUpdates(()=>{ze?.(Et),E({type:"onDragMove",event:Et})})},[Me.x,Me.y]),S.useEffect(()=>{const{active:ze,activatorEvent:Re,collisions:we,droppableContainers:Ke,scrollAdjustedTranslate:ft}=fe.current;if(!ze||R.current==null||!Re||!ft)return;const{onDragOver:Et}=ee.current,wt=Ke.get(Ve),Qt=wt&&wt.rect.current?{id:wt.id,rect:wt.rect.current,data:wt.data,disabled:wt.disabled}:null,Ft={active:ze,activatorEvent:Re,collisions:we,delta:{x:ft.x,y:ft.y},over:Qt};Mc.unstable_batchedUpdates(()=>{lt(Qt),Et?.(Ft),E({type:"onDragOver",event:Ft})})},[Ve]),kl(()=>{fe.current={activatorEvent:G,active:q,activeNode:pe,collisionRect:be,collisions:qe,droppableRects:ne,draggableNodes:O,draggingNode:$,draggingNodeRect:ie,droppableContainers:j,over:We,scrollableAncestors:ve,scrollAdjustedTranslate:Me},I.current={initial:ie,translated:be}},[q,pe,qe,be,O,$,ie,ne,j,We,ve,Me]),BGe({...Ee,delta:k,draggingRect:be,pointerCoordinates:U,scrollableAncestors:ve,scrollableAncestorRects:Ne});const ge=S.useMemo(()=>({active:q,activeNode:pe,activeNodeRect:ue,activatorEvent:G,collisions:qe,containerNodeRect:Ae,dragOverlay:B,draggableNodes:O,droppableContainers:j,droppableRects:ne,over:We,measureDroppableContainers:le,scrollableAncestors:ve,scrollableAncestorRects:Ne,measuringConfiguration:V,measuringScheduled:oe,windowRect:se}),[q,pe,ue,G,qe,Ae,B,O,j,ne,We,le,ve,Ne,V,oe,se]),nt=S.useMemo(()=>({activatorEvent:G,activators:ot,active:q,activeNodeRect:ue,ariaDescribedById:{draggable:Z},dispatch:y,draggableNodes:O,over:We,measureDroppableContainers:le}),[G,ot,q,ue,y,Z,O,We,le]);return kr.createElement(Mte.Provider,{value:w},kr.createElement(PE.Provider,{value:nt},kr.createElement(zte.Provider,{value:ge},kr.createElement(Bte.Provider,{value:ae},u)),kr.createElement(u9e,{disabled:l?.restoreFocus===!1})),kr.createElement(fGe,{...l,hiddenTextDescribedById:Z}));function xe(){const ze=W?.autoScrollEnabled===!1,Re=typeof c=="object"?c.enabled===!1:c===!1,we=C&&!ze&&!Re;return typeof c=="object"?{...c,enabled:we}:{enabled:we}}}),m9e=S.createContext(null),ZG="button",p9e="Draggable";function g9e(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=py(p9e),{activators:s,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:g}=S.useContext(PE),{role:p=ZG,roleDescription:b="draggable",tabIndex:v=0}=i??{},x=c?.id===e,y=S.useContext(x?Bte:m9e),[E,w]=qS(),[A,T]=qS(),C=e9e(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":x&&p===ZG?!0:void 0,"aria-roledescription":b,"aria-describedby":d.draggable}),[r,p,v,x,b,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:O,isDragging:x,listeners:r?void 0:C,node:E,over:g,setNodeRef:w,setActivatorNodeRef:T,transform:y}}function x9e(){return S.useContext(zte)}const b9e="Droppable",y9e={timeout:25};function v9e(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=py(b9e),{active:s,dispatch:l,over:c,measureDroppableContainers:u}=S.useContext(PE),d=S.useRef({disabled:n}),f=S.useRef(!1),g=S.useRef(null),p=S.useRef(null),{disabled:b,updateMeasurementsFor:v,timeout:x}={...y9e,...i},y=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(y.current)?y.current:[y.current]),p.current=null},x)},[x]),w=kE({callback:E,disabled:b||!s}),A=S.useCallback((O,k)=>{w&&(k&&(w.unobserve(k),f.current=!1),O&&w.observe(O))},[w]),[T,C]=qS(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:vi.RegisterDroppable,element:{id:r,key:a,disabled:n,node:T,rect:g,data:N}}),()=>l({type:vi.UnregisterDroppable,key:a,id:r})),[r]),S.useEffect(()=>{n!==d.current.disabled&&(l({type:vi.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 jE(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function _9e(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 w9e(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 S9e(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const WL=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=jE(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},M9e=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=E9e(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 E9e(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 $te="Sortable",Vte=kr.createContext({activeIndex:-1,containerId:$te,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:WL,disabled:{draggable:!1,droppable:!1}});function Gte(t){let{children:e,id:n,items:r,strategy:i=WL,disabled:a=!1}=t;const{active:s,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=x9e(),f=py($te,n),g=l.rect!==null,p=S.useMemo(()=>r.map(C=>typeof C=="object"&&"id"in C?C.id:C),[r]),b=s!=null,v=s?p.indexOf(s.id):-1,x=u?p.indexOf(u.id):-1,y=S.useRef(p),E=!w9e(p,y.current),w=x!==-1&&v===-1||E,A=S9e(a);kl(()=>{E&&b&&d(p)},[E,p,b,d]),S.useEffect(()=>{y.current=p},[p]);const T=S.useMemo(()=>({activeIndex:v,containerId:f,disabled:A,disableTransforms:w,items:p,overIndex:x,useDragOverlay:g,sortedRects:_9e(p,c),strategy:i}),[v,f,A.draggable,A.droppable,w,p,x,c,g,i]);return kr.createElement(Vte.Provider,{value:T},e)}const A9e=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return jE(n,r,i).indexOf(e)},T9e=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},N9e={duration:200,easing:"ease"},Wte="transform",C9e=eg.Transition.toString({property:Wte,duration:0,easing:"linear"}),k9e={roleDescription:"sortable"};function P9e(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 qte(t){let{animateLayoutChanges:e=T9e,attributes:n,disabled:r,data:i,getNewIndex:a=A9e,id:s,strategy:l,resizeObserverConfig:c,transition:u=N9e}=t;const{items:d,containerId:f,activeIndex:g,disabled:p,disableTransforms:b,sortedRects:v,overIndex:x,useDragOverlay:y,strategy:E}=S.useContext(Vte),w=j9e(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}=v9e({id:s,data:T,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:z,activatorEvent:I,activeNodeRect:q,attributes:R,setNodeRef:W,listeners:K,isDragging:G,over:J,setActivatorNodeRef:ee,transform:Z}=g9e({id:s,data:T,attributes:{...k9e,...n},disabled:w.draggable}),F=eGe(j,W),V=!!z,ne=V&&!b&&a1(g)&&a1(x),le=!y&&G,oe=le&&ne?Z:null,Q=ne?oe??(l??E)({rects:v,activeNodeRect:q,activeIndex:g,overIndex:x,index:A}):null,Ee=a1(g)&&a1(x)?a({id:s,items:d,activeIndex:g,overIndex:x}):A,he=z?.id,ue=S.useRef({activeId:he,items:d,newIndex:Ee,containerId:f}),Ae=d!==ue.current.items,fe=e({active:z,containerId:f,isDragging:G,isSorting:V,id:s,index:A,items:d,newIndex:ue.current.newIndex,previousItems:ue.current.items,previousContainerId:ue.current.containerId,transition:u,wasDragging:ue.current.activeId!=null}),at=P9e({disabled:!fe,index:A,node:O,rect:N});return S.useEffect(()=>{V&&ue.current.newIndex!==Ee&&(ue.current.newIndex=Ee),f!==ue.current.containerId&&(ue.current.containerId=f),d!==ue.current.items&&(ue.current.items=d)},[V,Ee,f,d]),S.useEffect(()=>{if(he===ue.current.activeId)return;if(he!=null&&ue.current.activeId==null){ue.current.activeId=he;return}const $=setTimeout(()=>{ue.current.activeId=he},50);return()=>clearTimeout($)},[he]),{active:z,activeIndex:g,attributes:R,data:T,rect:N,index:A,newIndex:Ee,items:d,isOver:k,isSorting:V,isDragging:G,listeners:K,node:O,overIndex:x,over:J,setNodeRef:F,setActivatorNodeRef:ee,setDroppableNodeRef:j,setDraggableNodeRef:W,transform:at??Q,transition:B()};function B(){if(at||Ae&&ue.current.newIndex===A)return C9e;if(!(le&&!$L(I)||!u)&&(V||fe))return eg.Transition.toString({...u,property:Wte})}}function j9e(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 ZS(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 R9e=[On.Down,On.Right,On.Up,On.Left],Kte=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:s,scrollableAncestors:l}}=e;if(R9e.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 On.Down:r.top<g.top&&c.push(f);break;case On.Up:r.top>g.top&&c.push(f);break;case On.Left:r.left>g.left&&c.push(f);break;case On.Right:r.left<g.left&&c.push(f);break}});const u=pGe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=Nte(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,b=g?.node.current;if(b&&p&&f&&g){const x=TE(b).some((C,N)=>l[N]!==C),y=Xte(f,g),E=D9e(f,g),w=x||!y?{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 Xte(t,e){return!ZS(t)||!ZS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function D9e(t,e){return!ZS(t)||!ZS(e)||!Xte(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function O9e({item:t,onClose:e}){const n=dn(),{showToast:r}=vr(),[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.manual_start?"manual":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,b]=S.useState(t.auto_off_after),{data:v}=pt({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 x=_t({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")}}),y=w=>{w.preventDefault();const A={printer_id:i,require_previous_success:f,auto_off_after:p,manual_start:l==="manual"};l==="scheduled"&&u?A.scheduled_time=new Date(u).toISOString():A.scheduled_time=null,x.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(At,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:o.jsxs(Tt,{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:y,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(Sa,{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-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 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"]}),o.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 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"]}),o.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${l==="manual"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("manual"),children:[o.jsx(mR,{className:"w-4 h-4"}),"Queue Only"]})]})]}),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=>b(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.":l==="scheduled"?"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available.":"Print will be staged but won't start automatically. Use the Start button to release it to the queue."}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(Pe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsx(Pe,{type:"submit",className:"flex-1",disabled:x.isPending||v?.length===0,children:x.isPending?"Saving...":"Save Changes"})]})]})]})})})}function Yte(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 L9e(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 I9e({status:t}){const e={pending:{icon:ur,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:Hc,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:Ar,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:Ra,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:q1,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 jk({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:s,onStart:l}){const{attributes:c,listeners:u,setNodeRef:d,transform:f,transition:g,isDragging:p}=qte({id:t.id,disabled:t.status!=="pending"}),b={transform:eg.Transform.toString(f),transition:g},v=t.status==="printing",x=t.status==="pending",y=["completed","failed","skipped","cancelled"].includes(t.status);return o.jsx("div",{ref:d,style:b,className:`
  8274. group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
  8275. transition-all duration-200 hover:border-bambu-dark-tertiary/80
  8276. ${p?"opacity-50 scale-[1.02] shadow-xl z-50":""}
  8277. ${v?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
  8278. `,children:o.jsxs("div",{className:"flex items-center gap-4 p-4",children:[x?o.jsx("div",{...c,...u,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(vd,{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(ui,{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(qi,{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(td,{className:"w-3.5 h-3.5"}),Yte(t.print_time_seconds)]}),x&&!t.manual_start&&o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(ur,{className:"w-3.5 h-3.5"}),L9e(t.scheduled_time)]})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.manual_start&&o.jsxs("span",{className:"text-xs px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded-full border border-purple-500/20 flex items-center gap-1",children:[o.jsx(mR,{className:"w-3 h-3"}),"Staged"]}),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"]})]}),v&&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(Sa,{className:"w-3 h-3"}),t.error_message]})]}),o.jsx(I9e,{status:t.status}),o.jsxs("div",{className:"flex items-center gap-1",children:[v&&o.jsx(Pe,{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(gle,{className:"w-4 h-4"})}),x&&o.jsxs(o.Fragment,{children:[t.manual_start&&o.jsx(Pe,{variant:"ghost",size:"sm",onClick:l,title:"Start Print",className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10",children:o.jsx(Hc,{className:"w-4 h-4"})}),o.jsx(Pe,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:o.jsx(Bc,{className:"w-4 h-4"})}),o.jsx(Pe,{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(Pe,{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(Pe,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:o.jsx(Rn,{className:"w-4 h-4"})})]})]})]})})}function F9e(){const t=dn(),{showToast:e}=vr(),[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),[b,v]=S.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[x,y]=S.useState(()=>{const F=localStorage.getItem("queue.historySortAsc");return F!==null?F==="true":!1}),[E,w]=S.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[A,T]=S.useState(()=>{const F=localStorage.getItem("queue.pendingSortAsc");return F!==null?F==="true":!0});S.useEffect(()=>{localStorage.setItem("queue.historySortBy",b)},[b]),S.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(x))},[x]),S.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",E)},[E]),S.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(A))},[A]);const C=Ete(XS(CE,{activationConstraint:{distance:8}}),XS(NE,{coordinateGetter:Kte})),{data:N,isLoading:O}=pt({queryKey:["queue",n,i],queryFn:()=>_e.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:k}=pt({queryKey:["printers"],queryFn:()=>_e.getPrinters()}),j=_t({mutationFn:F=>_e.cancelQueueItem(F),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),z=_t({mutationFn:F=>_e.removeFromQueue(F),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),I=_t({mutationFn:F=>_e.stopQueueItem(F),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),q=_t({mutationFn:F=>_e.startQueueItem(F),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print released to queue")},onError:()=>e("Failed to start print","error")}),R=_t({mutationFn:F=>_e.reorderQueue(F),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),W=_t({mutationFn:async()=>{const F=N?.filter(V=>["completed","failed","skipped","cancelled"].includes(V.status))||[];for(const V of F)await _e.removeFromQueue(V.id);return F.length},onSuccess:F=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${F} history item${F!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),K=S.useMemo(()=>{const F=N?.filter(ne=>ne.status==="pending")||[],V=ne=>{if(!ne.scheduled_time)return 0;const le=new Date(ne.scheduled_time).getTime(),oe=Date.now()+4320*60*60*1e3;return le>oe?0:le};return[...F].sort((ne,le)=>{let oe;return E==="name"?oe=(ne.archive_name||"").localeCompare(le.archive_name||""):E==="printer"?oe=(ne.printer_name||"").localeCompare(le.printer_name||""):E==="time"?oe=V(ne)-V(le):oe=ne.position-le.position,A?oe:-oe})},[N,E,A]),G=N?.filter(F=>F.status==="printing")||[],J=S.useMemo(()=>[...N?.filter(V=>["completed","failed","skipped","cancelled"].includes(V.status))||[]].sort((V,ne)=>{let le;return b==="name"?le=(V.archive_name||"").localeCompare(ne.archive_name||""):b==="printer"?le=(V.printer_name||"").localeCompare(ne.printer_name||""):le=new Date(ne.completed_at||ne.created_at).getTime()-new Date(V.completed_at||V.created_at).getTime(),x?-le:le}),[N,b,x]),ee=S.useMemo(()=>K.reduce((F,V)=>F+(V.print_time_seconds||0),0),[K]),Z=F=>{const{active:V,over:ne}=F;if(!ne||V.id===ne.id)return;const le=K.findIndex(pe=>pe.id===V.id),oe=K.findIndex(pe=>pe.id===ne.id);if(le!==-1&&oe!==-1){const Q=jE(K,le,oe).map((Ee,he)=>({id:Ee.id,position:he+1}));R.mutate(Q)}};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(W9,{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(At,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:o.jsx(Tt,{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(Hc,{className:"w-5 h-5 text-blue-400"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-2xl font-bold text-white",children:G.length}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),o.jsx(At,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:o.jsx(Tt,{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:K.length}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),o.jsx(At,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:o.jsx(Tt,{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(td,{className:"w-5 h-5 text-bambu-green"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-2xl font-bold text-white",children:Yte(ee)}),o.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),o.jsx(At,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:o.jsx(Tt,{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(Ar,{className:"w-5 h-5 text-gray-400"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-2xl font-bold text-white",children:J.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:F=>r(F.target.value?Number(F.target.value):null),children:[o.jsx("option",{value:"",children:"All Printers"}),k?.map(F=>o.jsx("option",{value:F.id,children:F.name},F.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:F=>a(F.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"}),J.length>0&&o.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:[o.jsx(Rn,{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(At,{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:[G.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:G.map(F=>o.jsx(jk,{item:F,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>p({type:"stop",item:F}),onRequeue:()=>{},onStart:()=>{}},F.id))})]}),K.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:["(",K.length," item",K.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:F=>w(F.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(Pe,{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(Hte,{sensors:C,collisionDetection:Cte,onDragEnd:Z,children:o.jsx(Gte,{items:K.map(F=>F.id),strategy:M9e,children:o.jsx("div",{className:"space-y-3",children:K.map((F,V)=>o.jsx(jk,{item:F,position:V+1,onEdit:()=>u(F),onCancel:()=>p({type:"cancel",item:F}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>q.mutate(F.id)},F.id))})})})]}),J.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(Ar,{className:"w-5 h-5 text-bambu-gray"}),"History",o.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",J.length," item",J.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:b,onChange:F=>v(F.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(Pe,{variant:"ghost",size:"sm",onClick:()=>y(!x),title:x?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:x?o.jsx(Mp,{className:"w-4 h-4"}):o.jsx(j0,{className:"w-4 h-4"})})]})]}),o.jsx("div",{className:"space-y-3",children:J.slice(0,20).map((F,V)=>o.jsx(jk,{item:F,position:V+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>p({type:"remove",item:F}),onStop:()=>{},onRequeue:()=>f(F),onStart:()=>{}},F.id))})]})]}),c&&o.jsx(O9e,{item:c,onClose:()=>u(null)}),d&&o.jsx(_te,{archiveId:d.archive_id,archiveName:d.archive_name||`Archive #${d.archive_id}`,onClose:()=>f(null)}),g&&o.jsx(mr,{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"?I.mutate(g.item.id):z.mutate(g.item.id),p(null)},onCancel:()=>p(null)}),s&&o.jsx(mr,{title:"Clear History",message:`Are you sure you want to remove all ${J.length} item${J.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{W.mutate(),l(!1)},onCancel:()=>l(!1)})]})}function U9e({printDates:t,months:e=3}){const{weeks:n,monthLabels:r,printCounts:i}=S.useMemo(()=>{const c={};t.forEach(y=>{const E=y.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=[],b=-1;const v=new Date(d);let x=0;for(;v<=u;)v.getDay()===0&&p.length>0&&(f.push(p),p=[],x++),v.getMonth()!==b&&(g.push({month:v.toLocaleDateString("en-US",{month:"short"}),weekIndex:x}),b=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,b=g===new Date().toISOString().split("T")[0];return o.jsx("div",{className:`w-3 h-3 rounded-sm ${s(p)} ${b?"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 z9e(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 B9e({archives:t,currency:e="$"}){const[n,r]=S.useState("30d"),i=S.useMemo(()=>{const g=z9e(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],x=g.get(v)||{date:v,filament:0,cost:0,prints:0};x.filament+=p.filament_used_grams||0,x.cost+=p.cost||0,x.prints+=1,g.set(v,x)}),Array.from(g.values()).sort((p,b)=>p.date.localeCompare(b.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 b=new Date(p.completed_at||p.created_at),v=new Date(b);v.setDate(b.getDate()-b.getDay());const x=v.toISOString().split("T")[0],y=g.get(x)||{week:x,filament:0,cost:0,prints:0};y.filament+=p.filament_used_grams||0,y.cost+=p.cost||0,y.prints+=1,g.set(x,y)}),Array.from(g.values()).sort((p,b)=>p.week.localeCompare(b.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(x=>{const y=(p.filament_used_grams||0)/v.length;g.set(x,(g.get(x)||0)+y)})}),Array.from(g.entries()).map(([p,b])=>({name:p,value:Math.round(b)})).sort((p,b)=>b.value-p.value)},[i]),c=S.useMemo(()=>{const g=new Date,p=[];for(let b=5;b>=0;b--){const v=new Date(g.getFullYear(),g.getMonth()-b,1),x=new Date(g.getFullYear(),g.getMonth()-b+1,0),y=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<=x});p.push({month:y,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(y1,{width:"100%",height:250,children:o.jsxs(eCe,{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(zw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),o.jsx(Hw,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),o.jsx($w,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),o.jsx(_1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),o.jsx(rZ,{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(y1,{width:160,height:160,children:o.jsxs(QNe,{children:[o.jsx(TY,{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(_1,{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 b=l.reduce((x,y)=>x+y.value,0),v=b>0?(g.value/b*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(y1,{width:"100%",height:200,children:o.jsxs(zNe,{data:c,children:[o.jsx(zw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),o.jsx(Hw,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),o.jsx($w,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),o.jsx(_1,{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(YR,{}),o.jsx(RY,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function H9e({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}=qte({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(iue,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):o.jsx(Yce,{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(nM,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),o.jsx("div",{className:"p-4",children:n})]})}function $9e({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=Ete(XS(CE,{activationConstraint:{distance:8}}),XS(NE,{coordinateGetter:Kte})),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:jE(N.order,O,k)}})},p=A=>{c(T=>({...T,hidden:T.hidden.includes(A)?T.hidden.filter(C=>C!==A):[...T.hidden,A]}))},b=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?.()},x=l.order.map(A=>t.find(T=>T.id===A)).filter(Boolean),y=x.filter(A=>!l.hidden.includes(A.id)),E=x.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(Pe,{variant:"secondary",size:"sm",onClick:v,children:[o.jsx(sg,{className:"w-4 h-4"}),"Reset Layout"]}),E.length>0&&o.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[o.jsx(tf,{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(tf,{className:"w-3 h-3"}),A.title]},A.id))})]}),o.jsx(Hte,{sensors:f,collisionDetection:Cte,onDragEnd:g,children:o.jsx(Gte,{items:y.map(A=>A.id),strategy:WL,children:o.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:y.map(A=>o.jsx(H9e,{id:A.id,title:A.title,isHidden:l.hidden.includes(A.id),size:l.sizes[A.id]||2,onToggleVisibility:()=>p(A.id),onToggleSize:()=>b(A.id),children:A.component},A.id))})})}),y.length===0&&o.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[o.jsx("p",{children:"All widgets are hidden."}),o.jsx(Pe,{className:"mt-4",onClick:v,children:"Reset Layout"})]})]})}function V9e({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(Qk,{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(Qk,{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 G9e({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(Ar,{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(Ra,{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 W9e({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(X9,{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 q9e({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 K9e({printDates:t}){return o.jsx(U9e,{printDates:t,months:4})}function X9e({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(qi,{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 Y9e({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(B9e,{archives:t,currency:e})}function Z9e(){const{data:t,isLoading:e}=pt({queryKey:["failureAnalysis"],queryFn:()=>_e.getFailureAnalysis({days:30})});if(e)return o.jsx("div",{className:"flex justify-center py-4",children:o.jsx(xt,{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(qn,{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(Z9,{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 Q9e(){const{showToast:t}=vr(),[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}=pt({queryKey:["archiveStats"],queryFn:_e.getArchiveStats}),{data:f}=pt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:g}=pt({queryKey:["archives"],queryFn:()=>_e.getArchives(void 0,void 0,1e3,0)}),{data:p}=pt({queryKey:["settings"],queryFn:_e.getSettings}),b=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||"$",x=new Map(f?.map(w=>[String(w.id),w.name])||[]),y=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(V9e,{stats:u,currency:v}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:o.jsx(G9e,{stats:u}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:o.jsx(W9e,{stats:u,printerMap:x}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:o.jsx(q9e,{stats:u}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:o.jsx(Z9e,{}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:o.jsx(K9e,{printDates:y}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:o.jsx(X9e,{stats:u,printerMap:x}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:o.jsx(Y9e,{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(Pe,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[o.jsx(tf,{className:"w-4 h-4"}),l," Hidden"]}),o.jsxs(Pe,{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(Pe,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(V1,{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:()=>b("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:()=>b("xlsx"),children:[o.jsx(V1,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),o.jsx($9e,{widgets:E,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function J9e({plug:t,onEdit:e}){const n=dn(),[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}=pt({queryKey:["smart-plug-status",t.id],queryFn:()=>_e.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:b}=pt({queryKey:["printers"],queryFn:_e.getPrinters}),v=b?.find(N=>N.id===t.printer_id),x=_t({mutationFn:N=>_e.controlSmartPlug(t.id,N),onSuccess:()=>{p()}}),y=_t({mutationFn:N=>_e.updateSmartPlug(t.id,N),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),E=_t({mutationFn:()=>_e.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=f?.state==="ON",A=f?.reachable??!1,T=x.isPending,C=()=>{const N=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${N}/`:`http://${N}/`};return o.jsxs(o.Fragment,{children:[o.jsx(At,{className:"relative",children:o.jsxs(Tt,{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(uo,{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.jsxs("div",{className:"flex flex-col items-end gap-1",children:[g?o.jsx(xt,{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(SR,{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"})]}),o.jsxs("a",{href:C(),target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors",title:"Open plug admin page",children:[o.jsx(ui,{className:"w-3 h-3"}),"Admin"]})]})]}),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(Lh,{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(Pe,{size:"sm",variant:w?"primary":"secondary",disabled:!A||T,onClick:()=>s(!0),className:"flex-1",children:[T?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(jl,{className:"w-4 h-4"}),"On"]}),o.jsxs(Pe,{size:"sm",variant:w?"secondary":"primary",disabled:!A||T,onClick:()=>c(!0),className:"flex-1",children:[T?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(iM,{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(aM,{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(gR,{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:N=>y.mutate({show_in_switchbar:N.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:N=>y.mutate({enabled:N.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:N=>y.mutate({auto_on:N.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:N=>y.mutate({auto_off:N.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:()=>y.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:()=>y.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(sM,{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:N=>y.mutate({off_delay_minutes:parseInt(N.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:N=>y.mutate({off_temp_threshold:parseInt(N.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(Pe,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[o.jsx(vR,{className:"w-4 h-4"}),"Edit"]}),o.jsx(Pe,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:o.jsx(Rn,{className:"w-4 h-4"})})]})]})]})}),r&&o.jsx(mr,{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(mr,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{x.mutate("on"),s(!1)},onCancel:()=>s(!1)}),l&&o.jsx(mr,{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:()=>{x.mutate("off"),c(!1)},onCancel:()=>c(!1)})]})}function eWe({plug:t,onClose:e}){const n=dn(),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),[b,v]=S.useState(null),[x,y]=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,z]=S.useState(t?.schedule_on_time||""),[I,q]=S.useState(t?.schedule_off_time||""),[R,W]=S.useState(t?.show_in_switchbar||!1),[K,G]=S.useState(!1),[J,ee]=S.useState({scanned:0,total:0}),[Z,F]=S.useState([]),V=S.useRef(null),{data:ne}=pt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:le}=pt({queryKey:["smart-plugs"],queryFn:_e.getSmartPlugs});S.useEffect(()=>{const B=$=>{$.key==="Escape"&&e()};return window.addEventListener("keydown",B),()=>{window.removeEventListener("keydown",B),V.current&&clearInterval(V.current)}},[e]);const oe=async()=>{G(!0),F([]),ee({scanned:0,total:0}),y(null);try{await _e.startTasmotaScan();const B=async()=>{try{const $=await _e.getTasmotaScanStatus();ee({scanned:$.scanned,total:$.total});const ie=await _e.getDiscoveredTasmotaDevices();F(ie),$.running||(G(!1),V.current&&(clearInterval(V.current),V.current=null))}catch($){console.error("Polling error:",$)}};await B(),V.current=setInterval(B,500)}catch(B){G(!1);const $=B instanceof Error?B.message:typeof B=="string"?B:JSON.stringify(B);y($||"Failed to start scan")}},pe=async()=>{try{await _e.stopTasmotaScan()}catch{}G(!1),V.current&&(clearInterval(V.current),V.current=null)},Q=B=>{l(B.ip_address),a(B.name),v(null)},Ee=_t({mutationFn:()=>_e.testSmartPlugConnection(s,c||null,d||null),onSuccess:B=>{v(B),y(null),!i&&B.device_name&&a(B.device_name)},onError:B=>{v(null),y(B.message)}}),he=_t({mutationFn:B=>_e.createSmartPlug(B),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:B=>{y(B.message)}}),ue=_t({mutationFn:B=>_e.updateSmartPlug(t.id,B),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:B=>{y(B.message)}}),Ae=ne?.filter(B=>!le?.some(ie=>ie.printer_id===B.id&&ie.id!==t?.id)),fe=B=>{if(B.preventDefault(),y(null),!i.trim()){y("Name is required");return}if(!s.trim()){y("IP address is required");return}const $={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:I||null,show_in_switchbar:R};r?ue.mutate($):he.mutate($)},at=he.isPending||ue.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:B=>B.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:[x&&o.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:x}),!r&&o.jsxs("div",{className:"space-y-3",children:[K?o.jsxs(Pe,{type:"button",variant:"secondary",onClick:pe,className:"w-full",children:[o.jsx(Wt,{className:"w-4 h-4"}),"Stop Scanning"]}):o.jsxs(Pe,{type:"button",variant:"primary",onClick:oe,className:"w-full",children:[o.jsx(_l,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),K&&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}%`}})})]}),Z.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",Z.length," device(s) - click to select:"]}),o.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:Z.map(B=>o.jsxs("button",{type:"button",onClick:()=>Q(B),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(uo,{className:"w-4 h-4 text-bambu-green"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm text-white",children:B.name}),o.jsx("p",{className:"text-xs text-bambu-gray",children:B.ip_address})]})]}),B.state&&o.jsxs("span",{className:`flex items-center gap-1 text-xs ${B.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[o.jsx(jl,{className:"w-3 h-3"}),B.state]})]},B.ip_address))})]}),!K&&Z.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:B=>{l(B.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(Pe,{type:"button",variant:"secondary",onClick:()=>Ee.mutate(),disabled:!s.trim()||Ee.isPending,children:[Ee.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(SR,{className:"w-4 h-4"}),"Test"]})]})]}),b&&o.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${b.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:b.success?o.jsxs(o.Fragment,{children:[o.jsx(Ar,{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:[b.device_name&&`Device: ${b.device_name} - `,"State: ",b.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:B=>a(B.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:B=>u(B.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:B=>f(B.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:B=>p(B.target.value?Number(B.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)"}),Ae?.map(B=>o.jsx("option",{value:B.id,children:B.name},B.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(Lh,{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:B=>w(B.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:B=>T(B.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:B=>N(B.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:B=>k(B.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:B=>z(B.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:I,onChange:B=>q(B.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(gR,{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:B=>W(B.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(Pe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsxs(Pe,{type:"submit",disabled:at,className:"flex-1",children:[at?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Ts,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Vn({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 tWe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function nWe({provider:t,onEdit:e}){const n=dn(),[r,i]=S.useState(!1),[a,s]=S.useState(!1),[l,c]=S.useState(null),{data:u}=pt({queryKey:["printers"],queryFn:_e.getPrinters}),d=u?.find(v=>v.id===t.printer_id),f=_t({mutationFn:v=>_e.updateNotificationProvider(t.id,v),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=_t({mutationFn:()=>_e.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=_t({mutationFn:()=>_e.testNotificationProvider(t.id),onSuccess:v=>{c(v),n.invalidateQueries({queryKey:["notification-providers"]})},onError:v=>{c({success:!1,message:v.message})}}),b=v=>v||"";return o.jsxs(o.Fragment,{children:[o.jsx(At,{className:"relative",children:o.jsxs(Tt,{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(Lh,{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:tWe[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(Vn,{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(W1,{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(Pe,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(_R,{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(Ar,{className:"w-4 h-4"}):o.jsx(Ra,{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(aM,{className:"w-4 h-4"}),"Event Settings"]}),a?o.jsx(Tb,{className:"w-4 h-4"}):o.jsx(Os,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(W1,{className:"w-4 h-4 text-purple-400"}),o.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),o.jsx(Vn,{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:[b(t.quiet_hours_start)||"22:00"," - ",b(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(Vn,{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 ",b(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(Pe,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[o.jsx(vR,{className:"w-4 h-4"}),"Edit"]}),o.jsx(Pe,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:o.jsx(Rn,{className:"w-4 h-4"})})]})]})]})}),r&&o.jsx(mr,{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 QG=[{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 rWe({provider:t,onClose:e}){const n=dn(),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"),[b,v]=S.useState(t?.quiet_hours_end||"07:00"),[x,y]=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,z]=S.useState(t?.on_print_stopped??!0),[I,q]=S.useState(t?.on_print_progress??!1),[R,W]=S.useState(t?.on_printer_offline??!1),[K,G]=S.useState(t?.on_printer_error??!1),[J,ee]=S.useState(t?.on_filament_low??!1),[Z,F]=S.useState(t?.on_maintenance_due??!1),[V,ne]=S.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([H,Y])=>[H,String(Y)])):{}),[le,oe]=S.useState(null),[pe,Q]=S.useState(null),{data:Ee}=pt({queryKey:["printers"],queryFn:_e.getPrinters});S.useEffect(()=>{const H=Y=>{Y.key==="Escape"&&e()};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[e]);const he=_t({mutationFn:()=>_e.testNotificationConfig({provider_type:s,config:V}),onSuccess:H=>{oe(H),Q(null)},onError:H=>{oe({success:!1,message:H.message})}}),ue=_t({mutationFn:H=>_e.createNotificationProvider(H),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:H=>{Q(H.message)}}),Ae=_t({mutationFn:H=>_e.updateNotificationProvider(t.id,H),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:H=>{Q(H.message)}}),fe=H=>{if(H.preventDefault(),Q(null),!i.trim()){Q("Name is required");return}const Y=$(s);for(const ve of Y)if(!V[ve.key]?.trim()){Q(`${ve.label} is required`);return}const se={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?b:null,daily_digest_enabled:x,daily_digest_time:x?E:null,on_print_start:A,on_print_complete:C,on_print_failed:O,on_print_stopped:j,on_print_progress:I,on_printer_offline:R,on_printer_error:K,on_filament_low:J,on_maintenance_due:Z};r?Ae.mutate(se):ue.mutate(se)},at=ue.isPending||Ae.isPending,B=H=>{switch(H){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=>B(H).filter(Y=>Y.required),ie=B(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:H=>H.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:[pe&&o.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:pe}),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:H=>a(H.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:H=>{l(H.target.value),ne({}),oe(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:QG.map(H=>o.jsx("option",{value:H.value,children:H.label},H.value))}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:QG.find(H=>H.value===s)?.description})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),ie.map(H=>o.jsxs("div",{children:[o.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[H.label," ",H.required&&"*"]}),H.type==="select"&&H.options?o.jsx("select",{value:V[H.key]||H.options[0]?.value||"",onChange:Y=>{ne({...V,[H.key]:Y.target.value}),oe(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:H.options.map(Y=>o.jsx("option",{value:Y.value,children:Y.label},Y.value))}):o.jsx("input",{type:H.type,value:V[H.key]||"",onChange:Y=>{ne({...V,[H.key]:Y.target.value}),oe(null)},placeholder:H.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"})]},H.key))]}),o.jsx("div",{className:"flex gap-2",children:o.jsxs(Pe,{type:"button",variant:"secondary",onClick:()=>{oe(null),he.mutate()},disabled:he.isPending||!V[$(s)[0]?.key],className:"flex-1",children:[he.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(_R,{className:"w-4 h-4"}),"Test Configuration"]})}),le&&o.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${le.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:le.success?o.jsxs(o.Fragment,{children:[o.jsx(Ar,{className:"w-5 h-5"}),o.jsx("span",{children:le.message})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ra,{className:"w-5 h-5"}),o.jsx("span",{children:le.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:H=>u(H.target.value?Number(H.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(H=>o.jsx("option",{value:H.id,children:H.name},H.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(Vn,{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:H=>p(H.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:b,onChange:H=>v(H.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(Vn,{checked:x,onChange:y})]}),x&&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:H=>w(H.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(Vn,{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(Vn,{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(Vn,{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(Vn,{checked:j,onChange:z})]}),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(Vn,{checked:I,onChange:q})]})]})]}),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(Vn,{checked:R,onChange:W})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Error"}),o.jsx(Vn,{checked:K,onChange:G})]}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),o.jsx(Vn,{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(Vn,{checked:Z,onChange:F})]})]})]})]}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(Pe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsxs(Pe,{type:"submit",disabled:at,className:"flex-1",children:[at?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Ts,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function iWe({template:t,onClose:e}){const n=dn(),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}=pt({queryKey:["template-variables"],queryFn:_e.getTemplateVariables}),p=g?.find(T=>T.event_type===t.event_type),{data:b,isLoading:v}=pt({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 x=_t({mutationFn:T=>_e.updateNotificationTemplate(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:T=>{u(T.message)}}),y=_t({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}x.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),z=k.substring(O),I=j+`{${T}}`+z;l(I),setTimeout(()=>{C.focus();const q=N+T.length+2;C.setSelectionRange(q,q)},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(tf,{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(xt,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):b?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:b.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:b.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(Pe,{type:"button",variant:"ghost",onClick:()=>y.mutate(),disabled:y.isPending,className:"text-orange-400 hover:text-orange-300",children:[y.isPending?o.jsx(xt,{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(Pe,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),o.jsxs(Pe,{onClick:E,disabled:x.isPending||!A,children:[x.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Ts,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const aWe={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"},sWe={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 oWe({onClose:t}){const e=dn(),{showToast:n}=vr(),[r,i]=S.useState(7),[a,s]=S.useState(null),[l,c]=S.useState(!1),{data:u,isLoading:d,refetch:f,isRefetching:g}=pt({queryKey:["notification-logs",r,l],queryFn:()=>_e.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:p}=pt({queryKey:["notification-log-stats",r],queryFn:()=>_e.getNotificationLogStats(r)}),b=_t({mutationFn:()=>_e.clearNotificationLogs(30),onSuccess:x=>{n(x.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:x=>{n(`Failed to clear logs: ${x.message}`,"error")}}),v=x=>{const y=new Date(x),w=new Date().getTime()-y.getTime();return w<6e4?"Just now":w<36e5?`${Math.floor(w/6e4)}m ago`:w<864e5?`${Math.floor(w/36e5)}h ago`:y.toLocaleDateString()+" "+y.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(G1,{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(Ar,{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(Ra,{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:x=>i(Number(x.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:x=>c(x.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(Pe,{size:"sm",variant:"secondary",onClick:()=>f(),disabled:g,children:[g?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(li,{className:"w-4 h-4"}),"Refresh"]}),o.jsxs(Pe,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-red-400 hover:text-red-300",children:[b.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Rn,{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(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?o.jsx("div",{className:"space-y-2",children:u.map(x=>o.jsx(lWe,{log:x,isExpanded:a===x.id,onToggle:()=>s(a===x.id?null:x.id),formatDate:v},x.id))}):o.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[o.jsx(G1,{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 lWe({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(Ar,{className:"w-4 h-4 text-bambu-green shrink-0"}):o.jsx(Ra,{className:"w-4 h-4 text-red-400 shrink-0"}),o.jsx("span",{className:`text-xs font-medium ${sWe[t.event_type]||"text-bambu-gray"}`,children:aWe[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(Os,{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(wR,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:o.jsx(Lh,{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(uo,{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(qi,{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(bR,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:o.jsx(_d,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:o.jsx(co,{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(ua,{className:"w-4 h-4"}),default:!1,description:"Virtual printer uploads awaiting review"}];function cWe({onClose:t,onExport:e}){const{t:n}=ng(),[r,i]=S.useState(()=>{const b={};return l1.forEach(v=>{b[v.id]=v.default}),b}),[a,s]=S.useState(!1),[l,c]=S.useState(!1);S.useEffect(()=>{const b=v=>{v.key==="Escape"&&t()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[t]);const u=b=>{i(v=>({...v,[b]:!v[b]}))},d=()=>{const b={};l1.forEach(v=>{b[v.id]=!0}),i(b)},f=()=>{const b={};l1.forEach(v=>{b[v.id]=!1}),i(b)},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(At,{className:"w-full max-w-lg",onClick:b=>b.stopPropagation(),children:o.jsxs(Tt,{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(Wi,{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(b=>o.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[b.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[b.id],onChange:()=>u(b.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[b.id]?"text-bambu-green":"text-bambu-gray"}`,children:b.icon}),o.jsxs("div",{className:"flex-1",children:[o.jsx("div",{className:"text-white text-sm font-medium",children:n(b.labelKey,{defaultValue:b.defaultLabel})}),o.jsx("div",{className:"text-xs text-bambu-gray",children:b.description})]})]},b.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(co,{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(Vn,{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(qn,{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(Pe,{variant:"secondary",onClick:t,disabled:l,children:n("common.cancel",{defaultValue:"Cancel"})}),o.jsx(Pe,{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(xt,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):o.jsxs(o.Fragment,{children:[o.jsx(Wi,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const JG={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 uWe({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 b=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")}}},x=w=>{g(A=>{const T=new Set(A);return T.has(w)?T.delete(w):T.add(w),T})},y=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(At,{className:"w-full max-w-lg",children:o.jsxs(Tt,{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(Ar,{className:"w-5 h-5"}):r==="result"&&!u?.success?o.jsx(qn,{className:"w-5 h-5"}):o.jsx(ua,{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:b}),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(Ar,{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(ua,{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(qn,{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(q1,{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(Vn,{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(qn,{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(Pe,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),o.jsxs(Pe,{type:"button",onClick:v,disabled:!l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[o.jsx(ua,{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(xt,{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:y}),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(Ar,{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:JG[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(q1,{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&&x(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:[JG[w]||w,T.length>0&&(C?o.jsx(Tb,{className:"w-3 h-3"}):o.jsx(Os,{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)})})]}),y===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(Pe,{onClick:t,children:"Close"})})]})]})})})}async function dWe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function hWe(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 fWe(){const t=dn(),[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,b]=S.useState(!1),{data:v,isLoading:x}=pt({queryKey:["spoolman-settings"],queryFn:dWe}),{data:y,isLoading:E,refetch:w}=pt({queryKey:["spoolman-status"],queryFn:_e.getSpoolmanStatus,refetchInterval:3e4}),{data:A}=pt({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 W=setTimeout(()=>{T.mutate()},500);return()=>clearTimeout(W)}},[e,r,a,f]);const T=_t({mutationFn:()=>hWe({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=_t({mutationFn:_e.connectSpoolman,onSuccess:()=>{w()}}),N=_t({mutationFn:_e.disconnectSpoolman,onSuccess:()=>{w()}}),O=_t({mutationFn:_e.syncAllPrintersAms,onSuccess:R=>{R.success}}),k=_t({mutationFn:R=>_e.syncPrinterAms(R),onSuccess:R=>{R.success}}),j=()=>{u==="all"?O.mutate():k.mutate(u)},z=O.isPending||k.isPending,I=u==="all"?O.data:k.data,q=u==="all"?O.isSuccess:k.isSuccess;return x?o.jsxs(At,{children:[o.jsx(Ui,{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(Tt,{children:o.jsx("div",{className:"flex justify-center py-8",children:o.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):o.jsxs(At,{children:[o.jsx(Ui,{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(xt,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&o.jsx(go,{className:"w-4 h-4 text-bambu-green"})]})}),o.jsxs(Tt,{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(yd,{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(xt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?o.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[o.jsx(go,{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:y?.connected?o.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>N.mutate(),disabled:N.isPending,children:[N.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Oce,{className:"w-4 h-4"}),"Disconnect"]}):o.jsxs(Pe,{size:"sm",onClick:()=>C.mutate(),disabled:C.isPending||!r,children:[C.isPending?o.jsx(xt,{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}),y?.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(Os,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),o.jsxs(Pe,{variant:"secondary",size:"sm",onClick:j,disabled:z,children:[z?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(li,{className:"w-4 h-4"}),"Sync"]})]})]}),q&&I&&o.jsxs("div",{className:"mt-3 space-y-2",children:[o.jsx("div",{className:`p-2 rounded text-sm ${I.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:I.success?`Synced ${I.synced_count} spool${I.synced_count!==1?"s":""} successfully`:`Synced ${I.synced_count} spool${I.synced_count!==1?"s":""} with ${I.errors.length} error${I.errors.length!==1?"s":""}`}),I.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(qn,{className:"w-3.5 h-3.5"}),o.jsxs("span",{className:"font-medium",children:[I.skipped_count," spool",I.skipped_count!==1?"s":""," skipped"]})]}),I.skipped_count>5&&o.jsx("button",{onClick:()=>b(!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?I.skipped:I.skipped.slice(0,5)).map((R,W)=>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]})]},W)),!p&&I.skipped_count>5&&o.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",I.skipped_count-5," more"]})]})]}),I.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:I.errors.map((R,W)=>o.jsx("li",{children:R},W))})]})]})]})]})]})}function mWe({link:t,onClose:e}){const n=dn(),{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),[b,v]=S.useState(t?.custom_icon?_e.getExternalLinkIconUrl(t.id):null),[x,y]=S.useState(null),[E,w]=S.useState(null);S.useEffect(()=>{const z=I=>{I.key==="Escape"&&e()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[e]);const A=_t({mutationFn:async z=>{const I=await _e.createExternalLink(z);return x?await _e.uploadExternalLinkIcon(I.id,x):I},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:z=>{w(z.message)}}),T=_t({mutationFn:async z=>{let I=await _e.updateExternalLink(t.id,z);return x?I=await _e.uploadExternalLinkIcon(t.id,x):!g&&t?.custom_icon&&(I=await _e.deleteExternalLinkIcon(t.id)),I},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:z=>{w(z.message)}}),C=z=>{const I=z.target.files?.[0];if(I){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(I.type)){w("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(I.size>1024*1024){w("Image file must be less than 1MB");return}y(I),p(!0);const R=new FileReader;R.onload=W=>{v(W.target?.result)},R.readAsDataURL(I)}},N=()=>{y(null),v(null),p(!1),a.current&&(a.current.value="")},O=z=>{if(z.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 I={name:s.trim(),url:c.trim(),icon:d};i?T.mutate(I):A.mutate(I)},k=A.isPending||T.isPending,j=oM(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:z=>z.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&&b?o.jsx("img",{src:b,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:z=>l(z.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:z=>u(z.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&&b?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("img",{src:b,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(Rn,{className:"w-4 h-4"})})]}):o.jsxs(Pe,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[o.jsx(ua,{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(Wde,{value:d,onChange:f})]})]}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx(Pe,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),o.jsxs(Pe,{type:"submit",disabled:k,className:"flex-1",children:[k?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Ts,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function pWe(){const t=dn(),[e,n]=S.useState(!1),[r,i]=S.useState(null),[a,s]=S.useState(null),[l,c]=S.useState(null),{data:u,isLoading:d}=pt({queryKey:["external-links"],queryFn:_e.getExternalLinks}),f=_t({mutationFn:E=>_e.deleteExternalLink(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),g=_t({mutationFn:E=>_e.reorderExternalLinks(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=(E,w)=>{c(w),E.dataTransfer.effectAllowed="move"},b=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)},x=E=>{s(E)},y=()=>{a&&(f.mutate(a.id),s(null))};return o.jsxs(o.Fragment,{children:[o.jsxs(At,{children:[o.jsx(Ui,{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(Pe,{size:"sm",onClick:()=>n(!0),children:[o.jsx(fr,{className:"w-4 h-4"}),"Add Link"]})]})}),o.jsxs(Tt,{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(xt,{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=oM(E.icon);return o.jsxs("div",{draggable:!0,onDragStart:A=>p(A,E.id),onDragOver:b,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(ui,{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:()=>x(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(Rn,{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(mWe,{link:r,onClose:()=>{n(!1),i(null)}}),a&&o.jsx(mr,{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:y,onCancel:()=>s(null)})]})}function gWe(){const t=dn(),{showToast:e}=vr(),[n,r]=S.useState(!1),[i,a]=S.useState(""),[s,l]=S.useState("immediate"),[c,u]=S.useState("3DPrinter-X1-Carbon"),[d,f]=S.useState(!1),[g,p]=S.useState(null),{data:b,isLoading:v}=pt({queryKey:["virtual-printer-settings"],queryFn:f1.getSettings,refetchInterval:1e4}),{data:x}=pt({queryKey:["virtual-printer-models"],queryFn:f1.getModels});S.useEffect(()=>{b&&(r(b.enabled),l(b.mode),u(b.model))},[b]);const y=_t({mutationFn:O=>f1.updateSettings(O),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated"),p(null)},onError:O=>{e(O.message||"Failed to update settings","error"),b&&(r(b.enabled),l(b.mode),u(b.model)),p(null)}}),E=()=>{const O=!n;if(O&&!i&&!b?.access_code_set){e("Please set an access code first","error");return}r(O),p("toggle"),y.mutate({enabled:O,access_code:i||void 0,mode:s})},w=()=>{if(!i){e("Access code cannot be empty","error");return}if(i.length!==8){e("Access code must be exactly 8 characters","error");return}p("accessCode"),y.mutate({access_code:i}),a("")},A=O=>{l(O),p("mode"),y.mutate({mode:O})},T=O=>{u(O),p("model"),y.mutate({model:O})};if(v)return o.jsx(At,{children:o.jsx(Tt,{className:"py-8 flex justify-center",children:o.jsx(xt,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const C=b?.status,N=C?.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(At,{children:[o.jsx(Ui,{children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(qi,{className:"w-5 h-5 text-bambu-green"}),o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Virtual Printer"})]}),C&&o.jsxs("div",{className:`flex items-center gap-2 text-sm ${N?"text-green-400":"text-bambu-gray"}`,children:[o.jsx("span",{className:`w-2 h-2 rounded-full ${N?"bg-green-400 animate-pulse":"bg-gray-500"}`}),N?"Running":"Stopped"]})]})}),o.jsxs(Tt,{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:N?'Visible as "Bambuddy" in slicer discovery':"Not visible to slicers"})]}),o.jsx("button",{onClick:E,disabled:g==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${n?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${g==="toggle"?"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:"Printer Model"}),o.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:"Select which printer model to emulate."}),o.jsxs("div",{className:"relative",children:[o.jsx("select",{value:c,onChange:O=>T(O.target.value),disabled:g==="model",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white appearance-none cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed pr-10",children:x?.models&&Object.entries(x.models).sort(([,O],[,k])=>O.localeCompare(k)).map(([O,k])=>o.jsx("option",{value:O,children:k},O))}),o.jsx(Os,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),n&&N&&o.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[o.jsx(yd,{className:"w-3 h-3 inline mr-1"}),"Changing the model will restart the virtual printer"]})]}),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:b?.access_code_set?o.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[o.jsx(go,{className:"w-4 h-4"}),"Access code is set"]}):o.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[o.jsx(qn,{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:d?"text":"password",value:i,onChange:O=>a(O.target.value),placeholder:b?.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:()=>f(!d),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:d?o.jsx(nM,{className:"w-4 h-4"}):o.jsx(tf,{className:"w-4 h-4"})})]}),o.jsx(Pe,{onClick:w,disabled:!i||g==="accessCode",variant:"primary",children:g==="accessCode"?o.jsx(xt,{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:()=>A("immediate"),disabled:g==="mode",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:()=>A("queue"),disabled:g==="mode",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(At,{className:"border-l-4 border-l-yellow-500",children:o.jsx(Tt,{className:"py-4",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(qn,{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-white font-medium mb-2",children:"Setup Required"}),o.jsx("p",{className:"text-bambu-gray mb-3",children:"The virtual printer feature requires additional system configuration before it will work. This includes port forwarding, firewall rules, and platform-specific settings."}),o.jsxs("a",{href:"https://wiki.bambuddy.cool/features/virtual-printer/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-yellow-500/20 border border-yellow-500/50 rounded-md text-yellow-400 hover:bg-yellow-500/30 transition-colors",children:[o.jsx(ui,{className:"w-4 h-4"}),"Read the setup guide before enabling"]})]})]})})}),o.jsx(At,{children:o.jsx(Tt,{className:"py-4",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(yd,{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:"Complete the setup guide for your platform"}),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'})]})]})]})})}),C&&N&&o.jsxs(At,{children:[o.jsx(Ui,{children:o.jsx("h3",{className:"text-md font-semibold text-white",children:"Status Details"})}),o.jsx(Tt,{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:C.name})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-bambu-gray",children:"Model"}),o.jsx("div",{className:"text-white",children:C.model_name||C.model})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-bambu-gray",children:"Serial Number"}),o.jsx("div",{className:"text-white font-mono",children:C.serial})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-bambu-gray",children:"Mode"}),o.jsx("div",{className:"text-white capitalize",children:C.mode})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-bambu-gray",children:"Pending Files"}),o.jsx("div",{className:"text-white",children:C.pending_files})]})]})})]})]})]})}const xWe={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 bWe(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,bWe(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 yWe({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,b]=S.useState(!1),[v,x]=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}b(!0),g(null);try{let O=t;const k=new URLSearchParams;for(const Z of n.parameters||[]){const F=l[Z.name];F!==void 0&&F!==""&&(Z.in==="path"?O=O.replace(`{${Z.name}}`,encodeURIComponent(F)):Z.in==="query"&&k.append(Z.name,F))}const j=k.toString(),z=`${O}${j?`?${j}`:""}`,I={"Content-Type":"application/json"};i&&(I["X-API-Key"]=i);const q={method:e.toUpperCase(),headers:I};["post","put","patch"].includes(e)&&u&&(q.body=u);const R=performance.now(),W=await fetch(z,q),K=Math.round(performance.now()-R),G={};W.headers.forEach((Z,F)=>{G[F]=Z});let J;W.headers.get("content-type")?.includes("application/json")?J=await W.json():J=await W.text(),g({status:W.status,statusText:W.statusText,headers:G,body:J,duration:K})}catch(O){g({status:0,statusText:"Network Error",headers:{},body:O instanceof Error?O.message:"Unknown error",duration:0})}finally{b(!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),x(!0),setTimeout(()=>x(!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),x(!0),setTimeout(()=>x(!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(Os,{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 ${xWe[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(Pe,{onClick:w,disabled:p,children:[p?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Hc,{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(Sa,{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(Pe,{variant:"secondary",size:"sm",onClick:A,children:v?o.jsx(Ar,{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 vWe({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 x(){try{const y=await fetch("/openapi.json");if(!y.ok)throw new Error("Failed to fetch OpenAPI schema");const E=await y.json();n(E)}catch(y){s(y instanceof Error?y.message:"Unknown error")}finally{i(!1)}}x()},[]),r)return o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(a||!e)return o.jsx(At,{children:o.jsx(Tt,{className:"py-8",children:o.jsxs("div",{className:"text-center text-red-400",children:[o.jsx(Sa,{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[x,y]of Object.entries(e.paths))for(const[E,w]of Object.entries(y)){if(E==="parameters")continue;const A=w.tags||["Other"];for(const T of A)f[T]||(f[T]=[]),f[T].push({path:x,method:E,spec:w})}const g=Object.entries(f).map(([x,y])=>{if(!u)return{tag:x,endpoints:y};const E=y.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:x,endpoints:E}}).filter(({endpoints:x})=>x.length>0).sort((x,y)=>x.tag.localeCompare(y.tag)),p=x=>{c(y=>{const E=new Set(y);return E.has(x)?E.delete(x):E.add(x),E})},b=()=>{c(new Set(g.map(x=>x.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:x=>d(x.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(Pe,{variant:"secondary",size:"sm",onClick:b,children:"Expand All"}),o.jsx(Pe,{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(ui,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),o.jsxs("p",{className:"text-sm text-bambu-gray",children:[g.reduce((x,y)=>x+y.endpoints.length,0)," endpoints in ",g.length," categories"]}),o.jsx("div",{className:"space-y-3",children:g.map(({tag:x,endpoints:y})=>o.jsxs(At,{children:[o.jsx("button",{onClick:()=>p(x),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(x)?o.jsx(Os,{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:x.replace(/-/g," ")}),o.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:y.length})]})}),l.has(x)&&o.jsx(Tt,{className:"pt-0 space-y-2",children:y.map(({path:E,method:w,spec:A})=>o.jsx(yWe,{path:E,method:w,spec:A,schema:e,apiKey:t},`${w}-${E}`))})]},x))})]})}function _We(){const t=dn(),{t:e,i18n:n}=ng(),{showToast:r,showPersistentToast:i,dismissToast:a}=vr(),{mode:s,darkStyle:l,darkBackground:c,darkAccent:u,lightStyle:d,lightBackground:f,lightAccent:g,setDarkStyle:p,setDarkBackground:b,setDarkAccent:v,setLightStyle:x,setLightBackground:y,setLightAccent:E}=og(),[w,A]=S.useState(null),[T,C]=S.useState(!1),[N,O]=S.useState(null),[k,j]=S.useState(!1),[z,I]=S.useState(null),[q,R]=S.useState(null),[W,K]=S.useState(!1),[G,J]=S.useState(aW()),[ee,Z]=S.useState("general"),[F,V]=S.useState(!1),[ne,le]=S.useState(""),[oe,pe]=S.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[Q,Ee]=S.useState(null),[he,ue]=S.useState(null),[Ae,fe]=S.useState(""),[at,B]=S.useState(!1),[$,ie]=S.useState(!1),[H,Y]=S.useState(null),[se,ve]=S.useState(!1),[Ne,Se]=S.useState(!1),[U,L]=S.useState(!1),[te,ye]=S.useState(!1),Me=Ce=>{J(Ce),Xde(Ce)},be=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:qe,isLoading:Ve}=pt({queryKey:["settings"],queryFn:_e.getSettings}),{data:We,isLoading:lt}=pt({queryKey:["smart-plugs"],queryFn:_e.getSmartPlugs}),{data:me,isLoading:ae}=pt({queryKey:["smart-plugs-energy",We?.map(Ce=>Ce.id)],queryFn:async()=>{if(!We||We.length===0)return null;const Ce=await Promise.all(We.filter(gt=>gt.enabled).map(async gt=>{try{const re=await _e.getSmartPlugStatus(gt.id);return{plug:gt,status:re}}catch{return{plug:gt,status:null}}}));let ce=0,Ue=0,Xe=0,rt=0,et=0;for(const{status:gt}of Ce)gt?.reachable&&gt.energy&&(et++,gt.energy.power!=null&&(ce+=gt.energy.power),gt.energy.today!=null&&(Ue+=gt.energy.today),gt.energy.yesterday!=null&&(Xe+=gt.energy.yesterday),gt.energy.total!=null&&(rt+=gt.energy.total));return{totalPower:ce,totalToday:Ue,totalYesterday:Xe,totalLifetime:rt,reachableCount:et,totalPlugs:We.filter(gt=>gt.enabled).length}},enabled:ee==="plugs"&&!!We&&We.length>0,refetchInterval:ee==="plugs"?1e4:!1}),{data:He,isLoading:Be}=pt({queryKey:["notification-providers"],queryFn:_e.getNotificationProviders}),{data:Ye,isLoading:ot}=pt({queryKey:["api-keys"],queryFn:_e.getAPIKeys}),ge=_t({mutationFn:Ce=>_e.createAPIKey(Ce),onSuccess:Ce=>{Ee(Ce.key||null),V(!1),le(""),t.invalidateQueries({queryKey:["api-keys"]}),r("API key created")},onError:Ce=>{r(`Failed to create API key: ${Ce.message}`,"error")}}),nt=_t({mutationFn:Ce=>_e.deleteAPIKey(Ce),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),r("API key deleted")},onError:Ce=>{r(`Failed to delete API key: ${Ce.message}`,"error")}}),{data:xe}=pt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:ze,isLoading:Re}=pt({queryKey:["notification-templates"],queryFn:_e.getNotificationTemplates}),{data:we}=pt({queryKey:["virtual-printer-settings"],queryFn:f1.getSettings,refetchInterval:1e4}),Ke=we?.status?.running??!1,{data:ft}=pt({queryKey:["ffmpeg-status"],queryFn:_e.checkFfmpeg}),{data:Et}=pt({queryKey:["version"],queryFn:_e.getVersion}),{data:wt,refetch:Qt,isRefetching:Ft}=pt({queryKey:["updateCheck"],queryFn:_e.checkForUpdates,staleTime:300*1e3}),{data:hn,refetch:Hn}=pt({queryKey:["updateStatus"],queryFn:_e.getUpdateStatus,refetchInterval:Ce=>{const ce=Ce.state.data;return ce?.status==="downloading"||ce?.status==="installing"?1e3:!1}}),bt=_t({mutationFn:_e.applyUpdate,onSuccess:Ce=>{Ce.is_docker?r(Ce.message,"error"):Hn()}}),[Ht,an]=S.useState(null),mt=_t({mutationFn:_e.testAllNotificationProviders,onSuccess:Ce=>{an(Ce),t.invalidateQueries({queryKey:["notification-providers"]}),Ce.failed===0?r(`All ${Ce.tested} providers tested successfully!`,"success"):r(`${Ce.success}/${Ce.tested} providers succeeded`,Ce.failed>0?"error":"success")},onError:Ce=>{r(`Failed to test providers: ${Ce.message}`,"error")}}),Zt=_t({mutationFn:async Ce=>{if(!We)return{success:0,failed:0};const ce=We.filter(Xe=>Xe.enabled),Ue=await Promise.all(ce.map(async Xe=>{try{return await _e.controlSmartPlug(Xe.id,Ce),{success:!0}}catch{return{success:!1}}}));return{success:Ue.filter(Xe=>Xe.success).length,failed:Ue.filter(Xe=>!Xe.success).length}},onSuccess:(Ce,ce)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),Ce.failed===0?r(`All ${Ce.success} plugs turned ${ce}`,"success"):r(`${Ce.success} plugs turned ${ce}, ${Ce.failed} failed`,"error")},onError:Ce=>{r(`Failed: ${Ce.message}`,"error")}}),sn=S.useRef(null),Yt=S.useRef(!0);S.useEffect(()=>{qe&&!w&&(A(qe),setTimeout(()=>{Yt.current=!1},100))},[qe,w]);const _n=_t({mutationFn:_e.updateSettings,onSuccess:Ce=>{t.setQueryData(["settings"],Ce),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:Ce=>{r(`Failed to save: ${Ce.message}`,"error")}});S.useEffect(()=>{if(!(Yt.current||!w||!qe||!(qe.auto_archive!==w.auto_archive||qe.save_thumbnails!==w.save_thumbnails||qe.capture_finish_photo!==w.capture_finish_photo||qe.default_filament_cost!==w.default_filament_cost||qe.currency!==w.currency||qe.energy_cost_per_kwh!==w.energy_cost_per_kwh||qe.energy_tracking_mode!==w.energy_tracking_mode||qe.check_updates!==w.check_updates||qe.notification_language!==w.notification_language||qe.telemetry_enabled!==w.telemetry_enabled||qe.ams_humidity_good!==w.ams_humidity_good||qe.ams_humidity_fair!==w.ams_humidity_fair||qe.ams_temp_good!==w.ams_temp_good||qe.ams_temp_fair!==w.ams_temp_fair||qe.ams_history_retention_days!==w.ams_history_retention_days||qe.date_format!==w.date_format||qe.time_format!==w.time_format||qe.default_printer_id!==w.default_printer_id)))return sn.current&&clearTimeout(sn.current),sn.current=setTimeout(()=>{const ce={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};_n.mutate(ce)},500),()=>{sn.current&&clearTimeout(sn.current)}},[w,qe,_n]);const wn=S.useCallback((Ce,ce)=>{A(Ue=>Ue?{...Ue,[Ce]:ce}:null)},[]);return Ve||!w?o.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:o.jsx(xt,{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:()=>Z("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:()=>Z("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(uo,{className:"w-4 h-4"}),"Smart Plugs",We&&We.length>0&&o.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:We.length})]}),o.jsxs("button",{onClick:()=>Z("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(Lh,{className:"w-4 h-4"}),"Notifications",He&&He.length>0&&o.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:He.length})]}),o.jsxs("button",{onClick:()=>Z("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(Rle,{className:"w-4 h-4"}),"Filament"]}),o.jsxs("button",{onClick:()=>Z("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",Ye&&Ye.length>0&&o.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ye.length})]}),o.jsxs("button",{onClick:()=>Z("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(qi,{className:"w-4 h-4"}),"Virtual Printer",o.jsx("span",{className:`w-2 h-2 rounded-full ${Ke?"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(At,{children:[o.jsx(Ui,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),o.jsxs(Tt,{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:Ce=>n.changeLanguage(Ce.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:aU.map(Ce=>o.jsxs("option",{value:Ce.code,children:[Ce.nativeName," (",Ce.name,")"]},Ce.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:G,onChange:Ce=>Me(Ce.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(Ce=>o.jsx("option",{value:Ce.to,children:e(Ce.labelKey)},Ce.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:Ce=>wn("date_format",Ce.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:Ce=>wn("time_format",Ce.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:Ce=>wn("default_printer_id",Ce.target.value?Number(Ce.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(Ce=>o.jsx("option",{value:Ce.id,children:Ce.name},Ce.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(Pe,{variant:"secondary",size:"sm",onClick:be,children:[o.jsx(sg,{className:"w-4 h-4"}),"Reset"]})]})]})]}),o.jsxs(At,{children:[o.jsx(Ui,{children:o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[o.jsx(bR,{className:"w-5 h-5"}),"Appearance"]})}),o.jsxs(Tt,{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:Ce=>{b(Ce.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:Ce=>{v(Ce.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:Ce=>{p(Ce.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:Ce=>{y(Ce.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:Ce=>{E(Ce.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:Ce=>{x(Ce.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(At,{children:[o.jsx(Ui,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),o.jsxs(Tt,{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:Ce=>wn("auto_archive",Ce.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:Ce=>wn("save_thumbnails",Ce.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:Ce=>wn("capture_finish_photo",Ce.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&&ft&&!ft.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(qn,{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(At,{children:[o.jsx(Ui,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),o.jsxs(Tt,{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:Ce=>wn("default_filament_cost",parseFloat(Ce.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:Ce=>wn("currency",Ce.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:Ce=>wn("energy_cost_per_kwh",parseFloat(Ce.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:Ce=>wn("energy_tracking_mode",Ce.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(At,{children:[o.jsx(Ui,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),o.jsxs(Tt,{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(dR,{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:Ce=>wn("ams_humidity_good",parseInt(Ce.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:Ce=>wn("ams_humidity_fair",parseInt(Ce.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(sM,{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:Ce=>wn("ams_temp_good",parseFloat(Ce.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:Ce=>wn("ams_temp_fair",parseFloat(Ce.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:Ce=>wn("ams_history_retention_days",parseInt(Ce.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(pWe,{}),o.jsxs(At,{children:[o.jsx(Ui,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),o.jsxs(Tt,{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:Ce=>wn("check_updates",Ce.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:()=>L(!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(yd,{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:Ce=>wn("telemetry_enabled",Ce.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",Et?.version||"..."]})]}),o.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>Qt(),disabled:Ft,children:[Ft?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(li,{className:"w-4 h-4"}),"Check now"]})]}),wt?.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",wt.latest_version]}),wt.release_name&&wt.release_name!==wt.latest_version&&o.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:wt.release_name})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[wt.release_notes&&o.jsx("button",{onClick:()=>ye(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),wt.release_url&&o.jsx("a",{href:wt.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:o.jsx(ui,{className:"w-4 h-4"})})]})]}),hn?.status==="downloading"||hn?.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(xt,{className:"w-4 h-4 animate-spin"}),o.jsx("span",{children:hn.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:`${hn.progress}%`}})})]}):hn?.status==="complete"?o.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:hn.message}):hn?.status==="error"?o.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:hn.error||hn.message}):wt?.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(Pe,{className:"mt-3",onClick:()=>bt.mutate(),disabled:bt.isPending,children:[bt.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Wi,{className:"w-4 h-4"}),"Install Update"]})]}):wt?.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: ",wt.error]}):wt&&!wt.update_available?o.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),o.jsxs(At,{children:[o.jsx(Ui,{children:o.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),o.jsxs(Tt,{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(Pe,{variant:"secondary",size:"sm",onClick:()=>ve(!0),children:[o.jsx(Wi,{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(Pe,{variant:"secondary",size:"sm",onClick:()=>Se(!0),children:[o.jsx(ua,{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(Pe,{variant:"secondary",size:"sm",onClick:()=>B(!0),children:[o.jsx(Rn,{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(Pe,{variant:"secondary",size:"sm",onClick:()=>ie(!0),children:[o.jsx(Rn,{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(uo,{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:[We&&We.filter(Ce=>Ce.enabled).length>1&&o.jsxs(o.Fragment,{children:[o.jsxs(Pe,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>Y("on"),disabled:Zt.isPending,title:"Turn all plugs on",children:[Zt.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(jl,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),o.jsxs(Pe,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>Y("off"),disabled:Zt.isPending,title:"Turn all plugs off",children:[Zt.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(iM,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),o.jsxs(Pe,{className:"whitespace-nowrap",onClick:()=>{O(null),C(!0)},children:[o.jsx(fr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),We&&We.length>0&&o.jsxs(At,{className:"mb-6",children:[o.jsx(Ui,{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",ae&&o.jsx(xt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),o.jsx(Tt,{children:me?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:[me.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:[me.reachableCount,"/",me.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:[me.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:["~",(me.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:[me.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:["~",(me.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(Qk,{className:"w-3 h-3"}),"Total"]}),o.jsxs("div",{className:"text-xl font-bold text-white",children:[me.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:["~",(me.totalLifetime*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]})]}):ae?null:o.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),lt?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):We&&We.length>0?o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:We.map(Ce=>o.jsx(J9e,{plug:Ce,onEdit:ce=>{O(ce),C(!0)}},Ce.id))}):o.jsx(At,{children:o.jsx(Tt,{className:"py-12",children:o.jsxs("div",{className:"text-center text-bambu-gray",children:[o.jsx(uo,{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(Pe,{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(Lh,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(Pe,{size:"sm",variant:"secondary",onClick:()=>K(!0),children:[o.jsx(G1,{className:"w-4 h-4"}),"Log"]}),He&&He.length>0&&o.jsxs(Pe,{size:"sm",variant:"secondary",onClick:()=>{an(null),mt.mutate()},disabled:mt.isPending,children:[mt.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(_R,{className:"w-4 h-4"}),"Test All"]}),o.jsxs(Pe,{size:"sm",onClick:()=>{I(null),j(!0)},children:[o.jsx(fr,{className:"w-4 h-4"}),"Add"]})]})]}),o.jsx(At,{className:"mb-4",children:o.jsx(Tt,{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:Ce=>wn("notification_language",Ce.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:aU.map(Ce=>o.jsx("option",{value:Ce.code,children:Ce.nativeName},Ce.code))})]})})}),Ht&&o.jsx(At,{className:"mb-4",children:o.jsxs(Tt,{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:()=>an(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(Ar,{className:"w-4 h-4"}),Ht.success," passed"]}),Ht.failed>0&&o.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[o.jsx(Ra,{className:"w-4 h-4"}),Ht.failed," failed"]})]}),Ht.results.filter(Ce=>!Ce.success).length>0&&o.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Ht.results.filter(Ce=>!Ce.success).map(Ce=>o.jsxs("div",{className:"text-xs text-red-400",children:[o.jsxs("span",{className:"font-medium",children:[Ce.provider_name,":"]})," ",Ce.message]},Ce.provider_id))})]})}),Be?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):He&&He.length>0?o.jsx("div",{className:"space-y-3",children:He.map(Ce=>o.jsx(nWe,{provider:Ce,onEdit:ce=>{I(ce),j(!0)}},Ce.id))}):o.jsx(At,{children:o.jsx(Tt,{className:"py-8",children:o.jsxs("div",{className:"text-center text-bambu-gray",children:[o.jsx(Lh,{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(Pe,{size:"sm",onClick:()=>{I(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."}),Re?o.jsx("div",{className:"flex justify-center py-8",children:o.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):ze&&ze.length>0?o.jsx("div",{className:"space-y-2",children:ze.map(Ce=>o.jsx(At,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>R(Ce),children:o.jsx(Tt,{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:Ce.name}),o.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:Ce.title_template})]}),o.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:ce=>{ce.stopPropagation(),R(Ce)},children:o.jsx(vR,{className:"w-4 h-4 text-bambu-gray"})})]})})},Ce.id))}):o.jsx(At,{children:o.jsx(Tt,{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(Pe,{size:"sm",onClick:()=>V(!0),className:"flex-shrink-0",children:[o.jsx(fr,{className:"w-4 h-4"}),"Create Key"]})]}),Q&&o.jsx(At,{className:"mb-6 border-bambu-green",children:o.jsx(Tt,{className:"py-4",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(Ar,{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:Q}),o.jsx(Pe,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(Q);else{const Ce=document.createElement("textarea");Ce.value=Q,Ce.style.position="fixed",Ce.style.left="-999999px",document.body.appendChild(Ce),Ce.select(),document.execCommand("copy"),document.body.removeChild(Ce)}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(Pe,{variant:"secondary",size:"sm",onClick:()=>{fe(Q),r("Key added to API Browser")},children:"Use in API Browser"}),o.jsx(Pe,{variant:"secondary",size:"sm",onClick:()=>Ee(null),children:"Dismiss"})]})]})]})})}),F&&o.jsxs(At,{className:"mb-6",children:[o.jsx(Ui,{children:o.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),o.jsxs(Tt,{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:ne,onChange:Ce=>le(Ce.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:oe.can_read_status,onChange:Ce=>pe(ce=>({...ce,can_read_status:Ce.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:oe.can_queue,onChange:Ce=>pe(ce=>({...ce,can_queue:Ce.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:oe.can_control_printer,onChange:Ce=>pe(ce=>({...ce,can_control_printer:Ce.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(Pe,{onClick:()=>ge.mutate({name:ne||"Unnamed Key",...oe}),disabled:ge.isPending,children:[ge.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(fr,{className:"w-4 h-4"}),"Create Key"]}),o.jsx(Pe,{variant:"secondary",onClick:()=>V(!1),children:"Cancel"})]})]})]}),ot?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Ye&&Ye.length>0?o.jsx("div",{className:"space-y-3",children:Ye.map(Ce=>o.jsx(At,{children:o.jsx(Tt,{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 ${Ce.enabled?"text-bambu-green":"text-bambu-gray"}`}),o.jsxs("div",{children:[o.jsx("p",{className:"text-white font-medium",children:Ce.name}),o.jsxs("p",{className:"text-xs text-bambu-gray",children:[Ce.key_prefix,"••••••••",Ce.last_used&&` · Last used: ${new Date(Ce.last_used).toLocaleDateString()}`]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"flex gap-1 text-xs",children:[Ce.can_read_status&&o.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),Ce.can_queue&&o.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),Ce.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(Pe,{variant:"secondary",size:"sm",onClick:()=>ue(Ce.id),children:o.jsx(Rn,{className:"w-4 h-4 text-red-400"})})]})]})})},Ce.id))}):o.jsx(At,{children:o.jsx(Tt,{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(Pe,{onClick:()=>V(!0),children:[o.jsx(fr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),o.jsxs(At,{className:"mt-6",children:[o.jsx(Ui,{children:o.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),o.jsxs(Tt,{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(At,{className:"mb-4",children:o.jsxs(Tt,{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:Ae,onChange:Ce=>fe(Ce.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(vWe,{apiKey:Ae})]})]}),ee==="virtual-printer"&&o.jsx(gWe,{}),ee==="filament"&&o.jsx("div",{className:"max-w-2xl",children:o.jsx(fWe,{})}),he!==null&&o.jsx(mr,{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(he),ue(null)},onCancel:()=>ue(null)}),T&&o.jsx(eWe,{plug:N,onClose:()=>{C(!1),O(null)}}),k&&o.jsx(rWe,{provider:z,onClose:()=>{j(!1),I(null)}}),q&&o.jsx(iWe,{template:q,onClose:()=>R(null)}),W&&o.jsx(oWe,{onClose:()=>K(!1)}),at&&o.jsx(mr,{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()=>{B(!1);try{const Ce=await _e.clearNotificationLogs(30);r(Ce.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>B(!1)}),$&&o.jsx(mr,{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:()=>{ie(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>ie(!1)}),H&&o.jsx(mr,{title:`Turn All Plugs ${H==="on"?"On":"Off"}`,message:`This will turn ${H==="on"?"ON":"OFF"} all ${We?.filter(Ce=>Ce.enabled).length||0} enabled smart plugs. ${H==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${H==="on"?"On":"Off"}`,variant:H==="off"?"danger":"warning",onConfirm:()=>{const Ce=H;Y(null),Zt.mutate(Ce)},onCancel:()=>Y(null)}),se&&o.jsx(cWe,{onClose:()=>ve(!1),onExport:async Ce=>{ve(!1);const ce="backup-progress",Ue=Ce.archives;Ue&&i(ce,e("backup.preparing",{defaultValue:"Preparing backup..."}),"loading");try{const{blob:Xe,filename:rt}=await _e.exportBackup(Ce);Ue&&a(ce);const et=URL.createObjectURL(Xe),gt=document.createElement("a");gt.href=et,gt.download=rt,gt.click(),URL.revokeObjectURL(et),r(e("backup.downloaded",{defaultValue:"Backup downloaded"}),"success")}catch{Ue&&a(ce),r(e("backup.failed",{defaultValue:"Failed to create backup"}),"error")}}}),Ne&&o.jsx(uWe,{onClose:()=>Se(!1),onRestore:async(Ce,ce)=>await _e.importBackup(Ce,ce),onSuccess:()=>{A(null),Yt.current=!0,t.invalidateQueries()}}),U&&o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>L(!1),children:o.jsxs(At,{className:"w-full max-w-lg",onClick:Ce=>Ce.stopPropagation(),children:[o.jsxs(Ui,{className:"flex flex-row items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Gue,{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:()=>L(!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(Tt,{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(Ar,{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(Ar,{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(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoItem3")})]}),o.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[o.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),o.jsx("span",{children:e("settings.telemetryInfoItem4")})]})]})]}),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(Ra,{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(Ra,{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(Ra,{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(Ra,{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(Pe,{onClick:()=>L(!1),className:"w-full",children:e("common.close")})]})]})}),te&&wt?.release_notes&&o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>ye(!1),children:o.jsxs(At,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:Ce=>Ce.stopPropagation(),children:[o.jsxs(Ui,{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",wt.latest_version]}),wt.release_name&&wt.release_name!==wt.latest_version&&o.jsx("p",{className:"text-sm text-bambu-gray",children:wt.release_name})]}),o.jsx("button",{onClick:()=>ye(!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(Tt,{className:"overflow-y-auto flex-1",children:o.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:wt.release_notes})}),o.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[wt.release_url&&o.jsx("a",{href:wt.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:o.jsxs(Pe,{variant:"secondary",className:"w-full",children:[o.jsx(ui,{className:"w-4 h-4"}),"View on GitHub"]})}),o.jsx(Pe,{onClick:()=>ye(!1),className:"flex-1",children:"Close"})]})]})})]})}const Zte=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},wWe=t=>t.startsWith("HH")?"HF":"S",SWe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},Yj=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 Rk({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:s}){const l=wWe(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:Zte(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(K9,{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 Dk({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}=vr(),[f,g]=S.useState(t?.name||""),[p,b]=S.useState(t?.k_value?Zte(t.k_value):"0.020"),[v,x]=S.useState(t?.filament_id||""),[y,E]=S.useState(t?.nozzle_id?SWe(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}),[z,I]=S.useState(a),q=kr.useMemo(()=>{const Z=new Map;for(const F of r)if(F.filament_id&&!Z.has(F.filament_id)){const V=Yj(F.name||"");Z.set(F.filament_id,{id:F.filament_id,name:V||F.filament_id})}return Array.from(Z.values()).sort((F,V)=>F.name.localeCompare(V.name))},[r]),R=_t({mutationFn:Z=>(console.log("[KProfile] Calling API..."),_e.setKProfile(e,Z)),onSuccess:Z=>{if(console.log("[KProfile] Save success:",Z),d("K-profile saved"),u&&z!==a){let F;z===""&&s?F=s:t&&t.slot_id>0?F=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:F=`name_${f}_${v}`,u(F,z)}O(!0),setTimeout(()=>{O(!1),c()},2500)},onError:Z=>{console.error("[KProfile] Save error:",Z),d(Z.message,"error"),O(!1)}}),W=_t({mutationFn:Z=>(console.log("[KProfile] Deleting profile..."),_e.deleteKProfile(e,Z)),onSuccess:Z=>{console.log("[KProfile] Delete success:",Z),d("K-profile deleted"),O(!0),setTimeout(()=>{O(!1),l()},4e3)},onError:Z=>{console.error("[KProfile] Delete error:",Z),d(Z.message,"error"),O(!1)}}),[K,G]=S.useState(!1),J=()=>{t&&W.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 Z=>{if(Z.preventDefault(),i&&!t&&T.length===0){d("Please select at least one extruder","error");return}const F=parseFloat(p).toFixed(6),V=`${y}-${w}`;if(t||T.length===1){const le={name:f,k_value:F,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:",le),R.mutate(le);return}O(!0),j({current:1,total:T.length});const ne=T.map(le=>({name:f,k_value:F,filament_id:v,nozzle_id:V,nozzle_diameter:w,extruder_id:le,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${ne.length} profiles in batch:`,ne);try{if(await _e.setKProfilesBatch(e,ne),d(`K-profile saved to ${T.length} extruders`),u&&z){const le=`name_${f}_${v}`;u(le,z)}}catch(le){console.error("[KProfile] Failed to save batch:",le),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(At,{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(xt,{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(Tt,{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:Z=>g(Z.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:Z=>{const F=Z.target.value;(F===""||/^\d*\.?\d*$/.test(F))&&b(F)},onBlur:Z=>{const F=parseFloat(Z.target.value);isNaN(F)||b((Math.trunc(F*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:Z=>{const F=Z.target.value;if(x(F),!t&&F&&!f){const V=q.find(ne=>ne.id===F);V&&g(`${y==="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:q.find(Z=>Z.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(Z=>o.jsx("option",{value:Z.id,children:Z.name},Z.id))]}),!t&&q.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:y,onChange:Z=>{const F=Z.target.value;if(E(F),!t&&v&&!f){const V=q.find(ne=>ne.id===v);V&&g(`${F==="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:Z=>A(Z.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:Z=>{Z.target.checked?C([...T,1]):C(T.filter(F=>F!==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:Z=>{Z.target.checked?C([...T,0]):C(T.filter(F=>F!==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:z,onChange:Z=>I(Z.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(Pe,{type:"button",variant:"secondary",onClick:()=>G(!0),disabled:W.isPending||N,className:"text-red-500 hover:bg-red-500/10",children:W.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Rn,{className:"w-4 h-4"})}),o.jsx(Pe,{type:"button",variant:"secondary",onClick:l,disabled:N,className:"flex-1",children:"Cancel"}),o.jsxs(Pe,{type:"submit",disabled:R.isPending||N,className:"flex-1",children:[R.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(rM,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),K&&o.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:o.jsx(At,{className:"w-full max-w-sm",children:o.jsxs(Tt,{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(Rn,{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(Pe,{variant:"secondary",onClick:()=>G(!1),className:"flex-1",children:"Cancel"}),o.jsxs(Pe,{onClick:()=>{G(!1),J()},disabled:W.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[W.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const c1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function MWe(){const{showToast:t}=vr(),[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,b]=S.useState("all"),[v,x]=S.useState("all"),[y,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),z=H=>`${H.slot_id}_${H.extruder_id}`;S.useEffect(()=>{localStorage.setItem(c1.NOZZLE_DIAMETER,r)},[r]),S.useEffect(()=>{localStorage.setItem(c1.SORT_OPTION,y)},[y]);const{data:I,isLoading:q}=pt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:R,isLoading:W,isFetching:K,error:G,refetch:J}=pt({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const H=await _e.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",H?.profiles?.length||0,"profiles"),H},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:ee}=pt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>_e.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:Z,refetch:F}=pt({queryKey:["kprofile-notes",e],queryFn:()=>_e.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),V=G?.message?.includes("not connected");S.useEffect(()=>{if(!e&&I&&I.length>0){const H=I.find(Y=>Y.is_active);H&&n(H.id)}},[e,I]),S.useEffect(()=>{if(e){const H=setTimeout(()=>{J()},150);return()=>clearTimeout(H)}},[e,r]);const ne=I?.filter(H=>H.is_active)||[],le=kr.useMemo(()=>R?.profiles?R.profiles.filter(Y=>{const se=f.toLowerCase(),ve=!se||Y.name.toLowerCase().includes(se)||Y.filament_id.toLowerCase().includes(se),Ne=p==="all"||p==="left"&&Y.extruder_id===1||p==="right"&&Y.extruder_id===0,Se=v==="all"||v==="hf"&&Y.nozzle_id.startsWith("HH")||v==="s"&&Y.nozzle_id.startsWith("HS");return ve&&Ne&&Se}).sort((Y,se)=>{switch(y){case"k_value":return parseFloat(Y.k_value)-parseFloat(se.k_value);case"filament":return Yj(Y.name).localeCompare(Yj(se.name));case"name":default:return Y.name.localeCompare(se.name)}}):[],[R?.profiles,f,p,v,y]),oe=I?.find(H=>H.id===e),pe=oe?.nozzle_count===2;S.useEffect(()=>{const H=Y=>{Y.target instanceof HTMLInputElement||Y.target instanceof HTMLTextAreaElement||Y.target instanceof HTMLSelectElement||a||l||u||(Y.key==="r"||Y.key==="R"?(Y.preventDefault(),J()):Y.key==="n"||Y.key==="N"?(Y.preventDefault(),c(!0)):Y.key==="Escape"&&w&&(Y.preventDefault(),A(!1),C(new Set)))};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[a,l,u,w,J]);const Q=S.useCallback(()=>{if(!R?.profiles||R.profiles.length===0){t("No profiles to export","error");return}const H={version:1,exported_at:new Date().toISOString(),printer:oe?.name||"Unknown",nozzle_diameter:r,profiles:R.profiles.map(Ne=>({name:Ne.name,k_value:Ne.k_value,filament_id:Ne.filament_id,nozzle_id:Ne.nozzle_id,nozzle_diameter:Ne.nozzle_diameter,extruder_id:Ne.extruder_id}))},Y=new Blob([JSON.stringify(H,null,2)],{type:"application/json"}),se=URL.createObjectURL(Y),ve=document.createElement("a");ve.href=se,ve.download=`kprofiles_${oe?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(ve),ve.click(),document.body.removeChild(ve),URL.revokeObjectURL(se),t(`Exported ${R.profiles.length} profiles`)},[R?.profiles,oe,r,t]),Ee=S.useCallback(()=>{const H=document.createElement("input");H.type="file",H.accept=".json",H.onchange=async Y=>{const se=Y.target.files?.[0];if(se)try{const ve=await se.text(),Ne=JSON.parse(ve);if(!Ne.profiles||!Array.isArray(Ne.profiles)){t("Invalid file format","error");return}let Se=0;for(const U of Ne.profiles)if(!(!U.name||!U.k_value||!U.filament_id))try{await _e.setKProfile(e,{name:U.name,k_value:parseFloat(U.k_value).toFixed(6),filament_id:U.filament_id,nozzle_id:U.nozzle_id||`HH00-${r}`,nozzle_diameter:U.nozzle_diameter||r,extruder_id:U.extruder_id??0,slot_id:0}),Se++,await new Promise(L=>setTimeout(L,500))}catch(L){console.error("Failed to import profile:",U.name,L)}t(`Imported ${Se} of ${Ne.profiles.length} profiles`),J()}catch(ve){console.error("Import error:",ve),t("Failed to parse import file","error")}},H.click()},[e,r,t,J]),he=S.useCallback(H=>{C(Y=>{const se=new Set(Y);return se.has(H)?se.delete(H):se.add(H),se})},[]),ue=S.useCallback(()=>{C(new Set(le.map(H=>z(H))))},[le,z]),Ae=S.useCallback(()=>{T.size!==0&&O(!0)},[T.size]),fe=S.useCallback(async()=>{const H=le.filter(se=>T.has(z(se)));j(!0);let Y=0;for(const se of H)try{await _e.deleteKProfile(e,{slot_id:se.slot_id,extruder_id:se.extruder_id,nozzle_id:se.nozzle_id,nozzle_diameter:se.nozzle_diameter,filament_id:se.filament_id,setting_id:se.setting_id}),Y++,await new Promise(ve=>setTimeout(ve,300))}catch(ve){console.error("Failed to delete profile:",se.name,ve)}t(`Deleted ${Y} profiles`),j(!1),O(!1),A(!1),C(new Set),J()},[e,T,le,t,J,z]),at=S.useCallback(H=>{const Y=[];return H.setting_id&&Y.push(H.setting_id),Y.push(`slot_${H.slot_id}_${H.filament_id}_${H.extruder_id}`),Y.push(`name_${H.name}_${H.filament_id}`),Y},[]),B=S.useCallback(async(H,Y)=>{if(e)try{await _e.setKProfileNote(e,H,Y),F()}catch(se){console.error("Failed to save note:",se),t("Failed to save note","error")}},[e,F,t]),$=S.useCallback(H=>{if(!Z?.notes)return{note:"",key:null};const Y=at(H);for(const se of Y)if(Z.notes[se])return{note:Z.notes[se],key:se};return{note:"",key:null}},[Z,at]),ie=S.useCallback(H=>$(H).note,[$]);return q?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!I||I.length===0?o.jsx(At,{children:o.jsxs(Tt,{className:"py-12 text-center",children:[o.jsx(Sa,{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"})]})}):ne.length===0?o.jsx(At,{children:o.jsxs(Tt,{className:"py-12 text-center",children:[o.jsx(qi,{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:[K&&!W&&o.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[o.jsx(xt,{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:H=>n(parseInt(H.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:ne.map(H=>o.jsx("option",{value:H.id,children:H.name},H.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:H=>i(H.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(Pe,{variant:"secondary",onClick:()=>J(),disabled:K,children:[o.jsx(li,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),o.jsxs(Pe,{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:H=>g(H.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"})]}),pe&&o.jsx("div",{className:"w-36",children:o.jsxs("select",{value:p,onChange:H=>b(H.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:H=>x(H.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:y,onChange:H=>E(H.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(Pe,{variant:"secondary",onClick:Q,disabled:!R?.profiles?.length,title:"Export profiles to JSON",children:[o.jsx(Wi,{className:"w-4 h-4"}),"Export"]}),o.jsxs(Pe,{variant:"secondary",onClick:Ee,title:"Import profiles from JSON",children:[o.jsx(ua,{className:"w-4 h-4"}),"Import"]}),o.jsx("div",{className:"flex-1"}),w?o.jsxs(o.Fragment,{children:[o.jsxs(Pe,{variant:"secondary",onClick:ue,title:"Select all visible profiles",children:[o.jsx(rf,{className:"w-4 h-4"}),"Select All"]}),o.jsxs(Pe,{variant:"secondary",onClick:Ae,disabled:T.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${T.size} selected profiles`,children:[o.jsx(Rn,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),o.jsxs(Pe,{variant:"secondary",onClick:()=>{A(!1),C(new Set)},children:[o.jsx(Wt,{className:"w-4 h-4"}),"Cancel"]})]}):o.jsxs(Pe,{variant:"secondary",onClick:()=>A(!0),disabled:!le.length,title:"Enter selection mode for bulk delete",children:[o.jsx(rf,{className:"w-4 h-4"}),"Select"]})]}),W?o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):V?o.jsx(At,{children:o.jsxs(Tt,{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(Pe,{variant:"secondary",onClick:()=>J(),children:[o.jsx(li,{className:"w-4 h-4"}),"Retry"]})]})}):le.length>0?pe?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:le.filter(H=>H.extruder_id===1).map(H=>o.jsx(Rk,{profile:H,onEdit:()=>s(H),onCopy:()=>d(H),selectionMode:w,isSelected:T.has(z(H)),onToggleSelect:()=>he(z(H)),note:ie(H)},z(H)))})]}),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:le.filter(H=>H.extruder_id===0).map(H=>o.jsx(Rk,{profile:H,onEdit:()=>s(H),onCopy:()=>d(H),selectionMode:w,isSelected:T.has(z(H)),onToggleSelect:()=>he(z(H)),note:ie(H)},z(H)))})]})]}):o.jsx("div",{className:"space-y-1",children:le.map(H=>o.jsx(Rk,{profile:H,onEdit:()=>s(H),onCopy:()=>d(H),selectionMode:w,isSelected:T.has(z(H)),onToggleSelect:()=>he(z(H)),note:ie(H)},z(H)))}):f||p!=="all"||v!=="all"?o.jsx(At,{children:o.jsxs(Tt,{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(At,{children:o.jsxs(Tt,{className:"py-12 text-center",children:[o.jsx(rM,{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(Pe,{onClick:()=>c(!0),children:[o.jsx(fr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:H,key:Y}=$(a);return o.jsx(Dk,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:ee?.profiles||R?.profiles,isDualNozzle:pe,initialNote:H,initialNoteKey:Y,onSaveNote:B,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),s(null),J()},onSave:()=>{s(null),J()}})})(),l&&e&&o.jsx(Dk,{printerId:e,nozzleDiameter:r,existingProfiles:ee?.profiles||R?.profiles,isDualNozzle:pe,onSaveNote:B,onClose:()=>{c(!1),J()},onSave:()=>{c(!1),J()}}),u&&e&&o.jsx(Dk,{printerId:e,nozzleDiameter:r,existingProfiles:ee?.profiles||R?.profiles,isDualNozzle:pe,onSaveNote:B,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(At,{className:"w-full max-w-sm",children:o.jsxs(Tt,{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(Rn,{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(Pe,{variant:"secondary",onClick:()=>O(!1),disabled:k,className:"flex-1",children:"Cancel"}),o.jsxs(Pe,{onClick:fe,disabled:k,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[k?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function qL(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 EWe(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 AWe({onSuccess:t}){const{showToast:e}=vr(),[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"),b=_t({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=_t({mutationFn:()=>_e.cloudVerify(i,c),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>e(w.message,"error")}),x=_t({mutationFn:()=>_e.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>e(w.message,"error")}),y=w=>{w.preventDefault(),n==="email"?b.mutate():n==="code"?v.mutate():n==="token"&&x.mutate()},E=b.isPending||v.isPending||x.isPending;return o.jsx(At,{className:"max-w-md mx-auto",children:o.jsxs(Tt,{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(tM,{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:y,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(Pe,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),o.jsxs(Pe,{type:"submit",disabled:E,className:"flex-1",children:[E?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(AU,{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(AU,{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(Os,{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 TWe(){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 Ok({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:s}){const l=qL(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 Zj(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(`
  8279. `)){const i=t.replace(/\\n/g,`
  8280. `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
  8281. `);if(i.length>1)return`"""
  8282. `+i.map(a=>n+" "+a).join(`
  8283. `)+`
  8284. `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
  8285. `+t.map(i=>n+" "+Zj(i,e+1)).join(`,
  8286. `)+`
  8287. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
  8288. `+r.map(([a,s])=>n+" "+JSON.stringify(a)+": "+Zj(s,e+1)).join(`,
  8289. `)+`
  8290. `+n+"}"}return String(t)}function NWe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=vr(),s=dn(),[l,c]=S.useState(!1),{data:u,isLoading:d}=pt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>_e.getCloudSettingDetail(t.setting_id)}),f=_t({mutationFn:()=>_e.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),s.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>a(b.message,"error")}),g=wb(t.setting_id),p=qL(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(At,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:o.jsxs(Tt,{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(xt,{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:Zj(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(qn,{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(Pe,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),o.jsxs(Pe,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):o.jsx(Rn,{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(Pe,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),o.jsxs(Pe,{variant:"secondary",onClick:r,children:[o.jsx(vl,{className:"w-4 h-4"}),"Duplicate"]}),g&&o.jsxs(o.Fragment,{children:[o.jsxs(Pe,{variant:"secondary",onClick:i,disabled:d||!u,children:[o.jsx(Bc,{className:"w-4 h-4"}),"Edit"]}),o.jsx(Pe,{variant:"danger",onClick:()=>c(!0),children:o.jsx(Rn,{className:"w-4 h-4"})})]})]})})]})})})}function Qte(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Jte(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function CWe({onClose:t,onApply:e}){const{showToast:n}=vr(),[r,i]=S.useState(Qte),[a,s]=S.useState("all"),[l,c]=S.useState(null),[u,d]=S.useState(""),[f,g]=S.useState(""),[p,b]=S.useState("{}"),[v,x]=S.useState(null),[y,E]=S.useState(null),w=a==="all"?r:r.filter(I=>I.type===a),A=I=>{i(I),Jte(I)},T=I=>{const q=r.filter(R=>R.id!==I);A(q),E(null),n("Template deleted")},C=I=>{c(I.id),d(I.name),g(I.description),b(JSON.stringify(I.settings,null,2)),x(null)},N=()=>{if(!(!l||!u.trim()))try{const I=JSON.parse(p),q=r.map(R=>R.id===l?{...R,name:u.trim(),description:f.trim(),settings:I}:R);A(q),c(null),n("Template updated")}catch(I){x(I.message)}},O=()=>{c(null),d(""),g(""),b("{}"),x(null)},k=I=>{const q=r.map(R=>R.id===I?{...R,showInModal:!R.showInModal}:R);A(q)},j={filament:{label:"Filament",icon:uR,color:"text-amber-400"},print:{label:"Process",icon:aM,color:"text-blue-400"},printer:{label:"Printer",icon:qi,color:"text-purple-400"}},z=y?r.find(I=>I.id===y):null;return S.useEffect(()=>{const I=q=>{q.key==="Escape"&&(y?E(null):l?O():t())};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[y,l,t]),o.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[z&&o.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:o.jsx(At,{className:"w-full max-w-md",children:o.jsxs(Tt,{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(qn,{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:z.name}),'"?']}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Pe,{variant:"secondary",onClick:()=>E(null),className:"flex-1",children:"Cancel"}),o.jsxs(Pe,{onClick:()=>T(y),className:"flex-1 bg-red-500 hover:bg-red-600",children:[o.jsx(Rn,{className:"w-4 h-4"}),"Delete"]})]})]})})}),o.jsx(At,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:o.jsxs(Tt,{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(I=>o.jsx("button",{onClick:()=>s(I),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===I?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:I==="all"?"All":j[I].label},I))]}),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(I=>{const q=j[I.type],R=q.icon;return l===I.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:W=>d(W.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:W=>g(W.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:W=>{b(W.target.value),x(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(Pe,{size:"sm",onClick:N,disabled:!u.trim(),children:[o.jsx(Ts,{className:"w-4 h-4"}),"Save"]}),o.jsx(Pe,{size:"sm",variant:"secondary",onClick:O,children:"Cancel"})]})]},I.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 ${q.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:I.name}),o.jsx("p",{className:"text-xs text-bambu-gray truncate",children:I.description})]}),o.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(I.settings).length," fields"]}),o.jsx("button",{onClick:()=>k(I.id),className:`p-1 transition-colors ${I.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:I.showInModal?"Shown in modals":"Hidden in modals",children:I.showInModal?o.jsx(tf,{className:"w-4 h-4"}):o.jsx(nM,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>e(I),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(I),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(I.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:o.jsx(Rn,{className:"w-4 h-4"})})]},I.id)})})})]})})]})}function ene({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)]),b=[];for(const v of p){if(v==="inherits"||v==="version")continue;const x=e[v],y=n[v],E=v in e,w=v in n;let A;!E&&w?A="added":E&&!w?A="removed":JSON.stringify(x)!==JSON.stringify(y)?A="changed":A="same",b.push({key:v,left:x,right:y,status:A})}return b.sort((v,x)=>{const y={changed:0,added:1,removed:2,same:3};return y[v.status]!==y[x.status]?y[v.status]-y[x.status]:v.key.localeCompare(x.key)})},[e,n]),d=S.useMemo(()=>{let p=[...u];if(a==="changes"&&(p=p.filter(b=>b.status!=="same")),l){const b=l.toLowerCase();p=p.filter(v=>v.key.toLowerCase().includes(b)||String(v.left).toLowerCase().includes(b)||String(v.right).toLowerCase().includes(b))}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 b=String(p);if(b.includes("\\n")||b.length>100){const v=b.split("\\n").length;if(v>1)return`[${v} lines of G-code/script]`;if(b.length>100)return b.substring(0,100)+"…"}return b};return S.useEffect(()=>{const p=b=>{b.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(At,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:o.jsxs(Tt,{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(n3,{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(Zk,{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(YA,{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(YA,{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 b={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(n3,{className:"w-3.5 h-3.5 text-red-400"}),changed:o.jsx(Zk,{className:"w-3.5 h-3.5 text-amber-400"}),same:o.jsx(YA,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[p.status];return o.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${b}`,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 kWe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=vr(),i=dn(),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||""),[b,v]=S.useState(""),[x,y]=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,z]=S.useState(""),[I,q]=S.useState(!1),[R,W]=S.useState(Qte),[K,G]=S.useState(!1),[J,ee]=S.useState(""),[Z,F]=S.useState(""),[V,ne]=S.useState(!0),[le,oe]=S.useState(null),[pe,Q]=S.useState(!1),Ee=S.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),he=S.useMemo(()=>Ee.filter(ae=>wb(ae.setting_id)),[Ee]),{data:ue}=pt({queryKey:["cloudFields",c],queryFn:()=>_e.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:Ae}=pt({queryKey:["allPresetDetails",c,he.map(ae=>ae.setting_id).join(",")],queryFn:async()=>{const ae={};for(let Be=0;Be<he.length;Be+=5){const Ye=he.slice(Be,Be+5);(await Promise.all(Ye.map(async ge=>{try{const nt=await _e.getCloudSettingDetail(ge.setting_id);return{id:ge.setting_id,detail:nt}}catch{return null}}))).forEach(ge=>{ge&&(ae[ge.id]=ge.detail)})}return ae},enabled:he.length>0,staleTime:1e3*60*10}),{data:fe,isLoading:at}=pt({queryKey:["cloudSettingDetail",g],queryFn:()=>_e.getCloudSettingDetail(g),enabled:!!g});S.useEffect(()=>{s!=="json"&&w(JSON.stringify(x,null,2))},[x,s]);const B=S.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(He=>!wb(He.setting_id)).sort((He,Be)=>He.name.localeCompare(Be.name)),[n,c]);S.useEffect(()=>{if(!g)return;const ae=B.find(He=>He.setting_id===g);ae&&(v(ae.name),a||(y({inherits:ae.name}),w(JSON.stringify({inherits:ae.name},null,2))))},[g,B,a]);const $=S.useMemo(()=>{const ae=ue?.fields||[],He=new Set(ae.map(ge=>ge.key)),Be=new Set,Ye=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);Ae&&Object.values(Ae).forEach(ge=>{ge?.setting&&Object.keys(ge.setting).forEach(nt=>{!He.has(nt)&&!Ye.has(nt)&&Be.add(nt)})}),Object.keys(x).forEach(ge=>{!He.has(ge)&&!Ye.has(ge)&&Be.add(ge)});const ot=Array.from(Be).sort().map(ge=>({key:ge,label:ge.replace(/_/g," ").replace(/\b\w/g,nt=>nt.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...ae,...ot]},[ue,Ae,x]),ie=$.filter(ae=>ae.label.toLowerCase().includes(C.toLowerCase())||ae.key.toLowerCase().includes(C.toLowerCase())),H=()=>{if(j.trim()){const ae=j.trim().toLowerCase().replace(/\s+/g,"_");Y(ae,""),z(""),q(!1),r(`Field "${ae}" added`)}},Y=(ae,He)=>{y(Be=>{const Ye={...Be};return He===""||He===void 0?delete Ye[ae]:Ye[ae]=He,Ye})},se=ae=>{y(He=>({...He,...ae.settings})),oe(ae.name),r("Template applied")},ve=()=>{if(!J.trim())return;const ae={...x};if(delete ae.inherits,Object.keys(ae).length===0){r("No overrides to save","error");return}const He={id:Date.now().toString(),name:J.trim(),description:Z.trim()||"Custom template",type:c,settings:ae,showInModal:V},Be=[...R,He];W(Be),Jte(Be),G(!1),ee(""),F(""),ne(!0),r("Template saved")},Ne=S.useMemo(()=>R.filter(ae=>ae.type===c&&ae.showInModal),[c,R]),Se=ae=>{w(ae);try{const He=JSON.parse(ae);y(He),T(null)}catch(He){T(He.message)}},U=ae=>{ae.preventDefault(),k(!1);const He=ae.dataTransfer.files[0];if(He&&He.name.endsWith(".json")){const Be=new FileReader;Be.onload=Ye=>{try{const ot=Ye.target?.result,ge=JSON.parse(ot),nt=ge.setting||ge;y(xe=>({...xe,...nt})),w(JSON.stringify({...x,...nt},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},Be.readAsText(He)}},L=_t({mutationFn:()=>{const ae={...x},He=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";ae[He]=`"${d}"`;const Be={type:c,name:d,base_id:g,setting:ae};return _e.createCloudSetting(Be)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ae=>r(ae.message,"error")}),te=_t({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return _e.updateCloudSetting(e.setting_id,{name:d,setting:x})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ae=>r(ae.message,"error")}),ye=a?te:L,Me=fe?.setting?.inherits,be=Me?B.find(ae=>ae.name===Me):void 0,{data:qe}=pt({queryKey:["cloudSettingDetail",be?.setting_id],queryFn:()=>_e.getCloudSettingDetail(be.setting_id),enabled:!!be?.setting_id}),Ve=S.useMemo(()=>{const ae=qe?.setting||{},He=fe?.setting||{},Be=g&&Ae?.[g]?.setting?Ae[g].setting:{};return{...ae,...He,...Be}},[g,fe,qe,Ae]),We=ae=>{if(ae==null)return"";if(Array.isArray(ae)){const He=[...new Set(ae.map(Be=>String(Be)))];return He.length===1?He[0]:ae.join(", ")}return String(ae)},lt=ae=>{const He=x[ae.key],Be=Ve[ae.key],Ye=We(Be),ot=at?"Loading...":Ye||"",ge="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(ae.type==="boolean"){const nt=He==="1"||He===void 0&&Be==="1";return o.jsx("button",{type:"button",onClick:()=>Y(ae.key,He==="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 ae.type==="select"?o.jsxs("select",{value:He||"",onChange:nt=>Y(ae.key,nt.target.value),className:ge,children:[o.jsx("option",{value:"",children:ot}),ae.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:ae.type==="number"?"number":"text",value:He!==void 0?String(He):"",onChange:nt=>Y(ae.key,nt.target.value),step:ae.step,min:ae.min,max:ae.max,placeholder:ot,className:ge}),ae.unit&&o.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:ae.unit})]})},me=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:ae=>{ae.preventDefault(),k(!0)},onDragLeave:()=>k(!1),onDrop:U,children:[pe&&g&&o.jsx(ene,{onClose:()=>Q(!1),leftPreset:me,rightPreset:x,leftLabel:`Base: ${b||g}`,rightLabel:`Current: ${d||"New Preset"}`}),o.jsx(At,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:o.jsxs(Tt,{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:()=>Q(!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(ua,{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:ae=>{u(ae.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:ae=>p(ae.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..."}),B.map(ae=>o.jsx("option",{value:ae.setting_id,children:ae.name},ae.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:ae=>f(ae.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"})]})]}),b&&o.jsx("div",{className:"text-xs text-bambu-gray",children:o.jsxs("p",{className:"flex items-center gap-1",children:[o.jsx(go,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",o.jsx("span",{className:"text-white",children:b}),at&&o.jsx(xt,{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(TU,{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(xR,{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(H9,{className:"w-4 h-4"}),"JSON",A&&o.jsx(Sa,{className:"w-3 h-3 text-red-400"})]}),o.jsx("div",{className:"flex-1"}),o.jsxs("button",{onClick:()=>{const ae={name:d,type:c,base_id:g,setting:x},He=new Blob([JSON.stringify(ae,null,2)],{type:"application/json"}),Be=URL.createObjectURL(He),Ye=document.createElement("a");Ye.href=Be,Ye.download=`${d||"preset"}.json`,document.body.appendChild(Ye),Ye.click(),document.body.removeChild(Ye),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(Wi,{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(ua,{className:"w-4 h-4"}),"Import"]}),o.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:ae=>{const He=ae.target.files?.[0];if(He){const Be=new FileReader;Be.onload=Ye=>{try{const ot=JSON.parse(Ye.target?.result),ge=ot.setting||ot;y(nt=>({...nt,...ge})),r("File imported")}catch{r("Invalid JSON","error")}},Be.readAsText(He)}}})]}),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(x).filter(ae=>ae!=="inherits").length>0&&o.jsxs("button",{onClick:()=>G(!K),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"]})]}),K&&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:ae=>ee(ae.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:Z,onChange:ae=>F(ae.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(Pe,{size:"sm",onClick:ve,disabled:!J.trim(),children:[o.jsx(Ts,{className:"w-3 h-3"}),"Save"]}),o.jsx(Pe,{size:"sm",variant:"secondary",onClick:()=>G(!1),children:"Cancel"})]}),o.jsxs("button",{onClick:()=>ne(!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(tf,{className:"w-3.5 h-3.5"}):o.jsx(nM,{className:"w-3.5 h-3.5"}),V?"Show in modals":"Hidden in modals"]})]})]}),le&&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(go,{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:le})]}),o.jsx("button",{onClick:()=>oe(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:[Ne.map(ae=>o.jsxs("button",{onClick:()=>se(ae),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:ae.name}),o.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:ae.description})]},ae.id)),Ne.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:$.slice(0,10).map(ae=>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:ae.label}),o.jsx("div",{className:"w-48",children:lt(ae)})]},ae.key))})]}),Object.keys(x).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(x).filter(([ae])=>ae!=="inherits").map(([ae,He])=>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:[ae,": ",String(He).slice(0,20),o.jsx("button",{onClick:()=>Y(ae,void 0),className:"hover:text-white",children:o.jsx(Wt,{className:"w-3 h-3"})})]},ae))})]})]}),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:Ae?`${$.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:ae=>N(ae.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:[ie.filter(ae=>!(ae.key in x)).map(ae=>{const He=Ve[ae.key],Be=We(He);return o.jsxs("div",{onClick:()=>{y(Ye=>({...Ye,[ae.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:ae.label}),o.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:ae.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"})})]})]},ae.key)}),ie.filter(ae=>!(ae.key in x)).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:I?o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{type:"text",value:j,onChange:ae=>z(ae.target.value),onKeyDown:ae=>ae.key==="Enter"&&H(),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(Pe,{size:"sm",onClick:H,disabled:!j.trim(),children:o.jsx(fr,{className:"w-4 h-4"})}),o.jsx(Pe,{size:"sm",variant:"secondary",onClick:()=>{q(!1),z("")},children:o.jsx(Wt,{className:"w-4 h-4"})})]}):o.jsxs("button",{onClick:()=>q(!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(x).filter(ae=>ae!=="inherits").length," fields"]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(x).filter(([ae])=>ae!=="inherits").map(([ae,He])=>{const Be=$.find(Ye=>Ye.key===ae);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||ae}),o.jsx("p",{className:"text-xs text-bambu-gray-dark",children:ae})]}),o.jsx("button",{onClick:()=>Y(ae,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:o.jsx(Wt,{className:"w-4 h-4"})})]}),Be?lt(Be):o.jsx("input",{type:"text",value:String(He),onChange:Ye=>Y(ae,Ye.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"})]},ae)}),Object.keys(x).filter(ae=>ae!=="inherits").length===0&&o.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[o.jsx(TU,{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(x).filter(ae=>ae!=="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:()=>{G(!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(Sa,{className:"w-4 h-4"}),A]}),o.jsx("textarea",{value:E,onChange:ae=>Se(ae.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(Pe,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),o.jsxs(Pe,{onClick:()=>ye.mutate(),disabled:ye.isPending||!d.trim()||!a&&!g||!!A,className:"flex-1",children:[ye.isPending?o.jsx(xt,{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 PWe({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,b]=S.useState("all"),[v,x]=S.useState("all"),[y,E]=S.useState("all"),[w,A]=S.useState(null),[T,C]=S.useState(!1),[N,O]=S.useState(!1),[k,j]=S.useState(null),[z,I]=S.useState(null),[q,R]=S.useState(null),[W,K]=S.useState(!1),[G,J]=S.useState([null,null]),[ee,Z]=S.useState(!1),[F,V]=S.useState(null),ne=dn(),le=S.useMemo(()=>[...t.filament.map(ie=>({...ie,type:"filament"})),...t.printer.map(ie=>({...ie,type:"printer"})),...t.process.map(ie=>({...ie,type:"process"}))].map(ie=>({...ie,meta:qL(ie.name)})),[t]),oe=S.useMemo(()=>{const $=new Set,ie=new Set,H=new Set;return le.forEach(Y=>{Y.meta.nozzle&&$.add(Y.meta.nozzle),Y.meta.filamentType&&ie.add(Y.meta.filamentType),Y.meta.layerHeight&&H.add(Y.meta.layerHeight)}),{printers:i.map(Y=>({id:Y.id.toString(),name:Y.name})),nozzles:Array.from($).sort((Y,se)=>parseFloat(Y)-parseFloat(se)),filaments:Array.from(ie).sort(),layerHeights:Array.from(H).sort((Y,se)=>parseFloat(Y)-parseFloat(se))}},[le,i]),pe=S.useMemo(()=>f==="all"?null:i.find(ie=>ie.id.toString()===f)?.model||null,[f,i]),Q=S.useMemo(()=>le.filter($=>l==="all"||$.type===l).filter($=>{if(u==="all")return!0;const ie=wb($.setting_id);return u==="custom"?ie:!ie}).filter($=>{if(f==="all"||!pe)return!0;const ie=$.meta.printer?.toLowerCase()||"",H=pe.toLowerCase();return ie.includes(H)||H.includes(ie)}).filter($=>p==="all"||$.meta.nozzle===p).filter($=>v==="all"||$.meta.filamentType===v).filter($=>y==="all"||$.meta.layerHeight===y).filter($=>a===""||$.name.toLowerCase().includes(a.toLowerCase())).sort(($,ie)=>$.name.localeCompare(ie.name)),[le,l,u,f,pe,p,v,y,a]),Ee=$=>{if(W){const ie=G[0]?.setting_id===$.setting_id,H=G[1]?.setting_id===$.setting_id;if(ie)J([G[1],null]);else if(H)J([G[0],null]);else if(!G[0])J([$,null]);else if(G[1]){if(G[0].type!==$.type)return;J([G[0],$])}else{if(G[0].type!==$.type)return;J([G[0],$])}}else A($)},he=$=>{if(G[0]?.setting_id===$.setting_id)return 0;if(G[1]?.setting_id===$.setting_id)return 1},ue=async $=>{try{const ie=await _e.getCloudSettingDetail($.setting_id),H=$.type==="process"?"print":$.type;j({type:H,name:$.name,base_id:ie.base_id||"GFSA00",setting:ie.setting||{}}),A(null)}catch(ie){console.error("Failed to fetch preset details for duplication:",ie)}},Ae=async $=>{try{ne.removeQueries({queryKey:["cloudSettingDetail",$.setting_id]});const ie=await _e.getCloudSettingDetail($.setting_id),H=$.type==="process"?"print":$.type;I({type:H,name:$.name,base_id:ie.base_id||"GFSA00",setting:ie.setting||{},setting_id:$.setting_id}),A(null)}catch(ie){console.error("Failed to fetch preset details for editing:",ie)}},fe=()=>{c("all"),d("all"),g("all"),b("all"),x("all"),E("all"),s("")},at=l!=="all"||u!=="all"||f!=="all"||p!=="all"||v!=="all"||y!=="all"||a!=="",B=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:$=>s($.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(Pe,{variant:W?"primary":"secondary",onClick:()=>{W?(K(!1),J([null,null])):K(!0)},children:[o.jsx(dp,{className:"w-4 h-4"}),W?"Cancel":"Compare"]}),o.jsxs(Pe,{variant:"secondary",onClick:()=>O(!0),children:[o.jsx(O0,{className:"w-4 h-4"}),"Templates"]}),o.jsxs(Pe,{variant:"secondary",onClick:n,disabled:r,children:[o.jsx(li,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),o.jsxs(Pe,{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(fR,{className:"w-4 h-4 text-bambu-gray"}),o.jsx(Ym,{label:"Type",value:l,options:[{value:"all",label:"All",count:B},{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:$=>c($)}),o.jsx(Ym,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:$=>d($)}),oe.printers.length>0&&o.jsx(Ym,{label:"Printer",value:f,options:[{value:"all",label:"All"},...oe.printers.map($=>({value:$.id,label:$.name}))],onChange:g}),oe.nozzles.length>0&&o.jsx(Ym,{label:"Nozzle",value:p,options:[{value:"all",label:"All"},...oe.nozzles.map($=>({value:$,label:$}))],onChange:b}),oe.filaments.length>0&&(l==="all"||l==="filament")&&o.jsx(Ym,{label:"Filament",value:v,options:[{value:"all",label:"All"},...oe.filaments.map($=>({value:$,label:$}))],onChange:x}),oe.layerHeights.length>0&&(l==="all"||l==="process")&&o.jsx(Ym,{label:"Layer",value:y,options:[{value:"all",label:"All"},...oe.layerHeights.map($=>({value:$,label:$}))],onChange:E}),at&&o.jsx("button",{onClick:fe,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),W&&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:G[0]?`Select another ${G[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] ${G[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:G[0]?G[0].name:"1. Select first"}),o.jsx(Zk,{className:"w-4 h-4 text-bambu-gray"}),o.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${G[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:G[1]?G[1].name:"2. Select second"})]}),G[0]&&G[1]&&o.jsxs(Pe,{size:"sm",onClick:async()=>{try{const[$,ie]=await Promise.all([_e.getCloudSettingDetail(G[0].setting_id),_e.getCloudSettingDetail(G[1].setting_id)]);V([$.setting||{},ie.setting||{}]),Z(!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: ",EWe(e.toISOString())]}),o.jsxs("span",{children:["Showing ",Q.length," of ",B," 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)"})]})]}),Q.length===0?o.jsxs("div",{className:"text-center py-16",children:[o.jsx(vd,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),o.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),at&&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(uR,{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:["(",Q.filter($=>$.type==="filament").length,")"]})]}),o.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[Q.filter($=>$.type==="filament").map($=>o.jsx(Ok,{setting:$,onClick:()=>Ee($),onDuplicate:()=>ue($),compareMode:W,isCompareSelected:he($)!==void 0,compareIndex:he($),compareDisabled:W&&!!G[0]&&G[0].type!==$.type},$.setting_id)),Q.filter($=>$.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(aM,{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:["(",Q.filter($=>$.type==="process").length,")"]})]}),o.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[Q.filter($=>$.type==="process").map($=>o.jsx(Ok,{setting:$,onClick:()=>Ee($),onDuplicate:()=>ue($),compareMode:W,isCompareSelected:he($)!==void 0,compareIndex:he($),compareDisabled:W&&!!G[0]&&G[0].type!==$.type},$.setting_id)),Q.filter($=>$.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(qi,{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:["(",Q.filter($=>$.type==="printer").length,")"]})]}),o.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[Q.filter($=>$.type==="printer").map($=>o.jsx(Ok,{setting:$,onClick:()=>Ee($),onDuplicate:()=>ue($),compareMode:W,isCompareSelected:he($)!==void 0,compareIndex:he($),compareDisabled:W&&!!G[0]&&G[0].type!==$.type},$.setting_id)),Q.filter($=>$.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(NWe,{setting:w,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>ue(w),onEdit:()=>Ae(w)}),(T||k||z||q)&&o.jsx(kWe,{onClose:()=>{C(!1),j(null),I(null),R(null)},initialData:z||k||(q?{type:q.type,name:"",base_id:"",setting:q.setting}:void 0),allPresets:t}),N&&o.jsx(CWe,{onClose:()=>O(!1),onApply:$=>{R({type:$.type,setting:$.settings}),O(!1)}}),ee&&F&&G[0]&&G[1]&&o.jsx(ene,{onClose:()=>{Z(!1),V(null)},leftPreset:F[0],rightPreset:F[1],leftLabel:G[0].name,rightLabel:G[1].name})]})}function jWe(){const t=dn(),{showToast:e}=vr(),[n,r]=S.useState("cloud"),[i,a]=S.useState(),{data:s,isLoading:l}=pt({queryKey:["cloudStatus"],queryFn:_e.getCloudStatus}),{data:c=[]}=pt({queryKey:["printers"],queryFn:_e.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:g}=pt({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=_t({mutationFn:_e.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),b=()=>{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(xt,{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(tM,{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(rM,{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(Pe,{variant:"secondary",size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[o.jsx(Vce,{className:"w-4 h-4"}),"Logout"]})]}),s?.is_authenticated?d?o.jsx("div",{className:"flex items-center justify-center py-16",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?o.jsx(PWe,{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(Pe,{onClick:()=>f(),children:"Retry"})]}):o.jsx(AWe,{onSuccess:b})]}),n==="kprofiles"&&o.jsx(MWe,{}),o.jsx(TWe,{})]})}const i0={Droplet:uR,Flame:ece,Ruler:Rue,Sparkles:O0,Square:af,Cable:Zoe,Wrench:_d,Calendar:Jr,Timer:td,Cog:Tle,Fan:$9,Zap:sf,Wind:tW,Thermometer:sM,Layers:vd,Box:bd,Target:X9,RefreshCw:li,Settings:wR,Filter:fR,CircleDot:mle};function N0(t){return t&&i0[t]||_d}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 Lk(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 RWe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),a=n.includes("A1MINI"),s=n.includes("A1")&&!a,l=n.includes("H2D"),c=n.includes("H2C"),u=n.includes("H2S"),d=l||c||u,f=n.includes("P2S");switch(t){case"Lubricate Linear Rails":return r?"https://wiki.bambulab.com/en/x1/maintenance/basic-maintenance":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":a?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":s?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/general/lead-screws-lubrication";case"Clean Nozzle/Hotend":return r||i?"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog":a||s?"https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog":d?"https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning":f?"https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend":"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog";case"Check Belt Tension":return r?"https://wiki.bambulab.com/en/x1/maintenance/belt-tension":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":a?"https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension":s?"https://wiki.bambulab.com/en/a1/maintenance/belt_tension":l?"https://wiki.bambulab.com/en/h2/maintenance/belt-tension":c?"https://wiki.bambulab.com/en/h2c/maintenance/belt-tension":u?"https://wiki.bambulab.com/en/h2s/maintenance/belt-tension":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/x1/maintenance/belt-tension";case"Clean Carbon Rods":return r||i?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":a||s||d||f?null:"https://wiki.bambulab.com/en/general/carbon-rods-clearance";case"Clean Build Plate":return"https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide";case"Check PTFE Tube":return r||i?"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube":a||s?"https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube":l?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":u?"https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer":c?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube";case"Replace HEPA Filter":case"HEPA Filter":case"Replace Carbon Filter":case"Carbon Filter":return d?"https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte":"https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter";case"Lubricate Left Nozzle Rail":case"Left Nozzle Rail":return d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;default:return null}}function DWe({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"})}),(()=>{const f=t.maintenance_type_wiki_url||RWe(t.maintenance_type_name,t.printer_model);return f?o.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:"View documentation",onClick:g=>g.stopPropagation(),children:o.jsx(ui,{className:"w-3.5 h-3.5"})}):null})()]}),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(qn,{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(go,{className:"w-3 h-3"}),d()]})]}),o.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o.jsx(Vn,{checked:t.enabled,onChange:f=>n(t.id,f)}),o.jsxs(Pe,{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 OWe({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,b)=>p.is_due&&!b.is_due?-1:!p.is_due&&b.is_due?1:p.is_warning&&!b.is_warning?-1:!p.is_warning&&b.is_warning?1:p.maintenance_type_id-b.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(At,{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(qn,{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(go,{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(Os,{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(td,{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(Pe,{size:"sm",onClick:g,children:"Save"}),o.jsx(Pe,{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(Tt,{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(DWe,{item:p,onPerform:e,onToggle:n},p.id))})})]})}function LWe({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"),[b,v]=S.useState(!1),[x,y]=S.useState(""),[E,w]=S.useState("100"),[A,T]=S.useState("hours"),[C,N]=S.useState("Wrench"),[O,k]=S.useState(""),[j,z]=S.useState(new Set),[I,q]=S.useState(null),R=S.useMemo(()=>t?t.map(H=>({id:H.printer_id,name:H.printer_name})):[],[t]),W=H=>t?t.filter(Y=>Y.maintenance_items.some(se=>se.maintenance_type_id===H)).map(Y=>({printerId:Y.printer_id,printerName:Y.printer_name,itemId:Y.maintenance_items.find(se=>se.maintenance_type_id===H)?.id})):[],K=H=>{if(!t)return[];const Y=new Set(W(H).map(se=>se.printerId));return R.filter(se=>!Y.has(se.id))},[G,J]=S.useState(null),[ee,Z]=S.useState(""),[F,V]=S.useState(""),[ne,le]=S.useState("hours"),[oe,pe]=S.useState("Wrench"),[Q,Ee]=S.useState(""),he=H=>{J(H),Z(H.name),V(H.default_interval_hours.toString()),le(H.interval_type||"hours"),pe(H.icon||"Wrench"),Ee(H.wiki_url||"")},ue=()=>{G&&ee.trim()&&parseFloat(F)>0&&(i(G.id,{name:ee.trim(),default_interval_hours:parseFloat(F),interval_type:ne,icon:oe,wiki_url:Q.trim()||null}),J(null))},Ae=(H,Y,se)=>{const ve=parseFloat(d);if(!isNaN(ve)&&ve>0){const Ne=Math.abs(ve-Y)<.01?null:ve;n(H,{custom_interval_hours:Ne,custom_interval_type:g!==se?g:null})}u(null)},fe=H=>{H.preventDefault(),x.trim()&&parseFloat(E)>0&&j.size>0&&(r({name:x.trim(),default_interval_hours:parseFloat(E),interval_type:A,icon:C,wiki_url:O.trim()||null},Array.from(j)),y(""),w("100"),T("hours"),k(""),z(new Set),v(!1))},at=H=>{z(Y=>{const se=new Set(Y);return se.has(H)?se.delete(H):se.add(H),se})},B=t?.map(H=>({printerId:H.printer_id,printerName:H.printer_name,items:H.maintenance_items.sort((Y,se)=>Y.maintenance_type_id-se.maintenance_type_id)})).sort((H,Y)=>H.printerName.localeCompare(Y.printerName))||[],$=e.filter(H=>H.is_system),ie=e.filter(H=>!H.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(Pe,{onClick:()=>v(!b),children:[o.jsx(fr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),b&&o.jsx(At,{className:"mb-6",children:o.jsx(Tt,{className:"py-4",children:o.jsxs("form",{onSubmit:fe,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:x,onChange:H=>y(H.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:H=>{T(H.target.value),H.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:H=>w(H.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(H=>{const Y=i0[H];return o.jsx("button",{type:"button",onClick:()=>N(H),className:`p-2 rounded-lg transition-colors ${C===H?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:o.jsx(Y,{className:"w-4 h-4"})},H)})})]})}),o.jsxs("div",{className:"mt-4",children:[o.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Documentation Link (optional)"}),o.jsx("input",{type:"url",value:O,onChange:H=>k(H.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:"https://wiki.bambulab.com/..."})]}),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:R.map(H=>o.jsx("button",{type:"button",onClick:()=>at(H.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${j.has(H.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:H.name},H.id))}),j.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(Pe,{type:"button",variant:"secondary",onClick:()=>{v(!1),z(new Set)},children:"Cancel"}),o.jsx(Pe,{type:"submit",disabled:!x.trim()||j.size===0,children:"Add Type"})]})]})})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[$.map(H=>{const Y=N0(H.icon),se=H.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(Y,{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:H.name}),o.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[se==="days"?o.jsx(Jr,{className:"w-3 h-3"}):o.jsx(td,{className:"w-3 h-3"}),Lk(H.default_interval_hours,se)]})]})]})},H.id)}),ie.map(H=>{const Y=N0(H.icon),se=H.interval_type||"hours";if(G?.id===H.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:ee,onChange:L=>Z(L.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:ne,onChange:L=>le(L.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:F,onChange:L=>V(L.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(L=>{const te=i0[L];return o.jsx("button",{type:"button",onClick:()=>pe(L),className:`p-1.5 rounded transition-colors ${oe===L?"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"})},L)})}),o.jsx("input",{type:"url",value:Q,onChange:L=>Ee(L.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:"Documentation link (optional)"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Pe,{size:"sm",onClick:ue,disabled:!ee.trim(),children:"Save"}),o.jsx(Pe,{size:"sm",variant:"secondary",onClick:()=>J(null),children:"Cancel"})]})]})},H.id);const Ne=W(H.id),Se=K(H.id),U=I===H.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(Y,{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:H.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:[se==="days"?o.jsx(Jr,{className:"w-3 h-3"}):o.jsx(td,{className:"w-3 h-3"}),Lk(H.default_interval_hours,se)]})]}),o.jsxs("button",{onClick:()=>q(U?null:H.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${Ne.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:`${Ne.length} printer(s) assigned - click to manage`,children:[o.jsx(qi,{className:"w-3 h-3"}),o.jsx("span",{className:"text-xs font-medium",children:Ne.length}),o.jsx(Os,{className:`w-3 h-3 transition-transform ${U?"rotate-180":""}`})]}),o.jsx("button",{onClick:()=>he(H),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 "${H.name}"?`)&&a(H.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:o.jsx(Rn,{className:"w-4 h-4"})})]}),U&&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:"}),Ne.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:Ne.map(L=>o.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[L.printerName,o.jsx("button",{onClick:()=>L.itemId&&l(L.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},L.printerId))}),Se.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:"}),Se.map(L=>o.jsxs("button",{onClick:()=>s(L.id,H.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:["+ ",L.name]},L.id))]})]})]},H.id)})]})]}),B.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:B.map(H=>o.jsx(At,{children:o.jsxs(Tt,{className:"py-4",children:[o.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:H.printerName}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:H.items.map(Y=>{const se=N0(Y.maintenance_type_icon),ve=e.find(te=>te.id===Y.maintenance_type_id),Ne=ve?.default_interval_hours||Y.interval_hours,Se=ve?.interval_type||"hours",U=Y.interval_type||"hours",L=c===Y.id;return o.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[o.jsx(se,{className:"w-4 h-4 text-bambu-gray shrink-0"}),o.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:Y.maintenance_type_name}),L?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(td,{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"&&Ae(Y.id,Ne,Se),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(Pe,{size:"sm",onClick:()=>Ae(Y.id,Ne,Se),children:"OK"})]}):o.jsxs("button",{onClick:()=>{u(Y.id),f(Y.interval_hours.toString()),p(U)},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:[U==="days"?o.jsx(Jr,{className:"w-3 h-3"}):o.jsx(td,{className:"w-3 h-3"}),Lk(Y.interval_hours,U),o.jsx(nf,{className:"w-3 h-3 text-bambu-gray"})]})]},Y.id)})})]})},H.printerId))})]}),B.length===0&&o.jsx(At,{children:o.jsxs(Tt,{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 IWe(){const t=dn(),{showToast:e}=vr(),[n,r]=S.useState("status"),{data:i,isLoading:a}=pt({queryKey:["maintenanceOverview"],queryFn:_e.getMaintenanceOverview}),{data:s}=pt({queryKey:["maintenanceTypes"],queryFn:_e.getMaintenanceTypes}),l=_t({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=_t({mutationFn:({id:w,data:A})=>_e.updateMaintenanceItem(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:w=>{e(w.message,"error")}}),u=_t({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=_t({mutationFn:_e.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:w=>{e(w.message,"error")}}),f=_t({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=_t({mutationFn:({printerId:w,typeId:A})=>_e.assignMaintenanceType(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:w=>{e(w.message,"error")}}),p=_t({mutationFn:_e.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:w=>{e(w.message,"error")}}),b=w=>{l.mutate({id:w})},v=(w,A)=>{c.mutate({id:w,data:{enabled:A}})},x=(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(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const y=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:[y>0&&o.jsxs("span",{className:"text-red-400",children:[y," task",y!==1?"s":""," overdue"]}),y>0&&E>0&&" · ",E>0&&o.jsxs("span",{className:"text-amber-400",children:[E," due soon"]}),y===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(OWe,{overview:w,onPerform:b,onToggle:v,onSetHours:x},w.printer_id)):o.jsx(At,{children:o.jsxs(Tt,{className:"text-center py-16",children:[o.jsx(_d,{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(LWe,{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 e9=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function tne({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||e9[0]),[d,f]=S.useState(t?.target_count?.toString()||""),[g,p]=S.useState(t?.status||"active"),[b,v]=S.useState(t?.tags||""),[x,y]=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:b.trim()||void 0,due_date:x||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:e9.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:b,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:x,onChange:T=>y(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(Pe,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(Pe,{type:"submit",disabled:!i.trim()||r,children:r?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function FWe({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:cR,color:"text-bambu-green",bg:"bg-bambu-green/10"}:s?{icon:co,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(Rn,{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(co,{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(qn,{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(co,{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(t3,{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 UWe(){const t=Eb(),e=dn(),{showToast:n}=vr(),[r,i]=S.useState(!1),[a,s]=S.useState(),[l,c]=S.useState("active"),[u,d]=S.useState(null),{data:f,isLoading:g}=pt({queryKey:["projects",l==="all"?void 0:l],queryFn:()=>_e.getProjects(l==="all"?void 0:l)}),p=_t({mutationFn:C=>_e.createProject(C),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),n("Project created","success")},onError:C=>{n(C.message,"error")}}),b=_t({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=_t({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")}}),x=C=>{a?b.mutate({id:a.id,data:C}):p.mutate(C)},y=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(Pe,{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:cR},{key:"archived",label:"Archived",icon:co},{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(xt,{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(Pe,{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(FWe,{project:C,onClick:()=>E(C),onEdit:()=>y(C),onDelete:()=>w(C.id)},C.id))}),u!==null&&o.jsx(mr,{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(tne,{project:a,onClose:()=>{i(!1),s(void 0)},onSave:x,isLoading:p.isPending||b.isPending})]})}function zWe(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 BWe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function HWe({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(At,{children:o.jsx(Tt,{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 $We({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(Ra,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&o.jsx("div",{className:"absolute top-1 right-1",children:o.jsx(Ar,{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 VWe({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(qn,{className:"w-3 h-3"}),r]})}function GWe(t){return t?new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):""}function Ik(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 WWe(){const{id:t}=eR(),e=Eb(),n=dn(),{showToast:r}=vr(),[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:b,isLoading:v,error:x}=pt({queryKey:["project",p],queryFn:()=>_e.getProject(p),enabled:p>0}),{data:y,isLoading:E}=pt({queryKey:["project-archives",p],queryFn:()=>_e.getProjectArchives(p),enabled:p>0}),{data:w,isLoading:A}=pt({queryKey:["project-bom",p],queryFn:()=>_e.getProjectBOM(p),enabled:p>0}),{data:T,isLoading:C}=pt({queryKey:["project-timeline",p],queryFn:()=>_e.getProjectTimeline(p,20),enabled:p>0}),{data:N}=pt({queryKey:["settings"],queryFn:_e.getSettings}),O=N?.currency||"$",k=_t({mutationFn:U=>_e.updateProject(p,U),onSuccess:()=>{n.invalidateQueries({queryKey:["project",p]}),n.invalidateQueries({queryKey:["projects"]}),a(!1),l(!1),r("Project updated","success")},onError:U=>{r(U.message,"error")}}),j=()=>{u(b?.notes||""),l(!0)},z=()=>{k.mutate({notes:c})},I=()=>{l(!1),u("")},q=async U=>{const L=U.target.files?.[0];if(L){f(!0);try{const te=await _e.uploadProjectAttachment(p,L);n.invalidateQueries({queryKey:["project",p]}),r(`Uploaded: ${te.original_name}`,"success")}catch(te){r(te.message,"error")}finally{f(!1),g.current&&(g.current.value="")}}},R=(U,L)=>{Ae({isOpen:!0,title:"Delete Attachment",message:`Are you sure you want to delete "${L}"?`,onConfirm:async()=>{Ae(te=>({...te,isOpen:!1}));try{await _e.deleteProjectAttachment(p,U),n.invalidateQueries({queryKey:["project",p]}),r("Attachment deleted","success")}catch(te){r(te.message,"error")}}})},W=U=>U<1024?`${U} B`:U<1024*1024?`${(U/1024).toFixed(1)} KB`:`${(U/(1024*1024)).toFixed(1)} MB`,[K,G]=S.useState(""),[J,ee]=S.useState(1),[Z,F]=S.useState(""),[V,ne]=S.useState(""),[le,oe]=S.useState(""),[pe,Q]=S.useState(!1),[Ee,he]=S.useState(!1),[ue,Ae]=S.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),fe=_t({mutationFn:U=>_e.createBOMItem(p,U),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]}),G(""),ee(1),F(""),ne(""),oe(""),Q(!1),r("Part added","success")},onError:U=>r(U.message,"error")}),at=_t({mutationFn:({itemId:U,data:L})=>_e.updateBOMItem(p,U,L),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]})},onError:U=>r(U.message,"error")}),B=_t({mutationFn:U=>_e.deleteBOMItem(p,U),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]}),r("Part removed","success")},onError:U=>r(U.message,"error")}),$=U=>{U.preventDefault(),K.trim()&&fe.mutate({name:K.trim(),quantity_needed:J,unit_price:Z?parseFloat(Z):void 0,sourcing_url:V.trim()||void 0,remarks:le.trim()||void 0})},ie=U=>{const L=U.is_complete?0:U.quantity_needed;at.mutate({itemId:U.id,data:{quantity_acquired:L}})},H=(U,L)=>{Ae({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${L}"?`,onConfirm:()=>{Ae(te=>({...te,isOpen:!1})),B.mutate(U)}})},Y=_t({mutationFn:()=>_e.createTemplateFromProject(p),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:U=>r(U.message,"error")}),se=U=>new Date(U).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(xt,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(x||!b)return o.jsxs("div",{className:"text-center py-24",children:[o.jsx("p",{className:"text-bambu-gray",children:x?`Error: ${x.message}`:"Project not found"}),o.jsx(Pe,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const ve=b.stats,Ne=ve?.progress_percent??0,Se=ve&&ve.total_items>0?(ve.completed_prints/ve.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:b.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(Loe,{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:b.color||"#6b7280"}}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-bold text-white",children:b.name}),b.description&&o.jsx("p",{className:"text-bambu-gray mt-1",children:b.description})]})]}),o.jsx(HWe,{status:b.status})]}),o.jsxs(Pe,{onClick:()=>a(!0),children:[o.jsx(nf,{className:"w-4 h-4 mr-2"}),"Edit"]})]}),b.target_count&&o.jsx(At,{children:o.jsxs(Tt,{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:[ve?.completed_prints||0," / ",b.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(Ne,100)}%`,backgroundColor:Ne>=100?"#22c55e":b.color||"#6b7280"}})}),o.jsxs("div",{className:"flex justify-between mt-1",children:[o.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Ne.toFixed(0),"% complete"]}),b.target_count-(ve?.completed_prints||0)>0&&o.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[b.target_count-(ve?.completed_prints||0)," remaining"]})]})]})}),ve&&o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsx(u1,{icon:zc,label:"Total Items",value:ve.total_items,subValue:`${ve.total_archives} print job${ve.total_archives!==1?"s":""}`,color:"text-bambu-green"}),o.jsx(u1,{icon:Ar,label:"Completed",value:ve.completed_prints,subValue:ve.failed_prints>0?`${ve.failed_prints} failed`:Se?`${Se}% success`:void 0,color:"text-blue-400"}),o.jsx(u1,{icon:ur,label:"Print Time",value:zWe(ve.total_print_time_hours),color:"text-yellow-400"}),o.jsx(u1,{icon:qi,label:"Filament Used",value:BWe(ve.total_filament_grams),color:"text-purple-400"})]}),ve&&(ve.estimated_cost>0||b.budget)&&o.jsx(At,{children:o.jsxs(Tt,{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,ve.estimated_cost.toFixed(2)]})]}),ve.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:[ve.total_energy_kwh.toFixed(2)," kWh",ve.total_energy_cost>0&&o.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",O,ve.total_energy_cost.toFixed(2),")"]})]})]}),b.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,b.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 ${b.budget-ve.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[O,(b.budget-ve.estimated_cost).toFixed(2)]})]})]})]})]})}),b.children&&b.children.length>0&&o.jsx(At,{children:o.jsxs(Tt,{className:"p-4",children:[o.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[o.jsx(ace,{className:"w-5 h-5"}),"Sub-projects (",b.children.length,")"]}),o.jsx("div",{className:"space-y-2",children:b.children.map(U=>o.jsxs(Sc,{to:`/projects/${U.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:U.color||"#6b7280"}}),o.jsx("span",{className:"text-white",children:U.name}),o.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${U.status==="completed"?"bg-bambu-green/20 text-bambu-green":U.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:U.status})]}),U.progress_percent!==null&&o.jsxs("span",{className:"text-sm text-bambu-gray",children:[U.progress_percent.toFixed(0),"%"]})]},U.id))})]})}),b.parent_id&&b.parent_name&&o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx(vd,{className:"w-4 h-4 text-bambu-gray"}),o.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),o.jsx(Sc,{to:`/projects/${b.parent_id}`,className:"text-bambu-green hover:underline",children:b.parent_name})]}),(b.tags||b.due_date||b.priority!=="normal")&&o.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[b.priority&&b.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(VWe,{priority:b.priority})]}),b.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:GWe(b.due_date)}),Ik(b.due_date)&&o.jsxs("span",{className:`text-xs ${Ik(b.due_date).color}`,children:["(",Ik(b.due_date).label,")"]})]}),b.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:b.tags.split(",").map((U,L)=>o.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:U.trim()},L))})]})]}),o.jsx(At,{children:o.jsxs(Tt,{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(Pe,{variant:"secondary",size:"sm",onClick:I,disabled:k.isPending,children:[o.jsx(Wt,{className:"w-4 h-4 mr-1"}),"Cancel"]}),o.jsxs(Pe,{size:"sm",onClick:z,disabled:k.isPending,children:[k.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin mr-1"}):o.jsx(Ts,{className:"w-4 h-4 mr-1"}),"Save"]})]}):o.jsxs(Pe,{variant:"secondary",size:"sm",onClick:j,children:[o.jsx(nf,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),s?o.jsx($j,{content:c,onChange:u,placeholder:"Add notes about this project..."}):b.notes?o.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:b.notes}}):o.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No notes yet. Click Edit to add notes."})]})}),o.jsx(At,{children:o.jsxs(Tt,{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(pue,{className:"w-5 h-5"}),"Attachments (",b.attachments?.length||0,")"]}),o.jsxs("div",{children:[o.jsx("input",{ref:g,type:"file",onChange:q,className:"hidden"}),o.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>g.current?.click(),disabled:d,children:[d?o.jsx(xt,{className:"w-4 h-4 animate-spin mr-1"}):o.jsx(ua,{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."}),b.attachments&&b.attachments.length>0?o.jsx("div",{className:"space-y-2",children:b.attachments.map(U=>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(hR,{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:U.original_name}),o.jsx("p",{className:"text-xs text-bambu-gray",children:W(U.size)})]})]}),o.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[o.jsx("a",{href:_e.getProjectAttachmentUrl(p,U.filename),download:U.original_name,className:"p-2 rounded hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",title:"Download",children:o.jsx(Wi,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>R(U.filename,U.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(Rn,{className:"w-4 h-4"})})]})]},U.filename))}):o.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No attachments yet. Click Upload to add files."})]})}),o.jsx(At,{children:o.jsxs(Tt,{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(q9,{className:"w-5 h-5"}),"Bill of Materials",ve&&ve.bom_total_items>0&&o.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",ve.bom_completed_items,"/",ve.bom_total_items," acquired)"]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[w&&w.some(U=>U.is_complete)&&o.jsx("button",{onClick:()=>he(!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"}),!pe&&o.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>Q(!0),children:[o.jsx(fr,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),pe&&o.jsxs("form",{onSubmit:$,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:K,onChange:U=>G(U.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:U=>ee(parseInt(U.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:Z,onChange:U=>F(U.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:U=>ne(U.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:le,onChange:U=>oe(U.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(Pe,{type:"button",variant:"secondary",size:"sm",onClick:()=>Q(!1),children:"Cancel"}),o.jsx(Pe,{type:"submit",size:"sm",disabled:!K.trim()||fe.isPending,children:fe.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin"}):"Add Part"})]})]}),A?o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(xt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):w&&w.length>0?o.jsxs("div",{className:"space-y-2",children:[w.filter(U=>!Ee||!U.is_complete).map(U=>o.jsx("div",{className:`p-3 rounded-lg transition-colors ${U.is_complete?"bg-bambu-green/10":"bg-bambu-dark"}`,children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("button",{onClick:()=>ie(U),disabled:at.isPending,className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${U.is_complete?"bg-bambu-green border-bambu-green text-white":"border-bambu-gray hover:border-bambu-green"}`,children:U.is_complete&&o.jsx(Ar,{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 ${U.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[U.name,o.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",U.quantity_needed]})]}),U.unit_price!==null&&o.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[O,(U.unit_price*U.quantity_needed).toFixed(2)]})]}),o.jsx("button",{onClick:()=>H(U.id,U.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(Rn,{className:"w-4 h-4"})})]}),U.sourcing_url&&o.jsxs("a",{href:U.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:L=>L.stopPropagation(),children:[o.jsx(ui,{className:"w-3 h-3 flex-shrink-0"}),o.jsx("span",{className:"truncate",children:(()=>{try{return new URL(U.sourcing_url).hostname.replace("www.","")}catch{return U.sourcing_url}})()})]}),U.remarks&&o.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:U.remarks})]})]})},U.id)),w.some(U=>U.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((U,L)=>U+(L.unit_price||0)*L.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(At,{children:o.jsxs(Tt,{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(G1,{className:"w-5 h-5"}),"Activity Timeline"]})}),C?o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(xt,{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((U,L)=>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 ${U.event_type==="print_completed"?"bg-bambu-green/20 text-bambu-green":U.event_type==="print_failed"?"bg-red-500/20 text-red-400":U.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[U.event_type==="print_completed"&&o.jsx(Ar,{className:"w-4 h-4"}),U.event_type==="print_failed"&&o.jsx(Ra,{className:"w-4 h-4"}),U.event_type==="print_started"&&o.jsx(qi,{className:"w-4 h-4"}),U.event_type==="queued"&&o.jsx(t3,{className:"w-4 h-4"}),U.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:U.title}),U.description&&o.jsx("p",{className:"text-xs text-bambu-gray truncate",children:U.description}),o.jsx("p",{className:"text-xs text-bambu-gray/70",children:se(U.timestamp)})]})]},L))}):o.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No activity yet."})]})}),!b.is_template&&o.jsx("div",{className:"flex justify-end",children:o.jsxs(Pe,{variant:"secondary",size:"sm",onClick:()=>Y.mutate(),disabled:Y.isPending,children:[Y.isPending?o.jsx(xt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(vl,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),ve&&(ve.queued_prints>0||ve.in_progress_prints>0)&&o.jsx(At,{children:o.jsxs(Tt,{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(t3,{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:[ve.in_progress_prints>0&&o.jsxs("span",{className:"text-yellow-400",children:[ve.in_progress_prints," printing"]}),ve.queued_prints>0&&o.jsxs("span",{className:"text-bambu-gray",children:[ve.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 (",y?.length||0,")"]})}),E?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(xt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):o.jsx($We,{archives:y||[]})]}),i&&o.jsx(tne,{project:{...b,archive_count:ve?.total_archives||0,total_items:ve?.total_items||0,queue_count:ve?.queued_prints||0,progress_percent:ve?.progress_percent||null,archives:[]},onClose:()=>a(!1),onSave:U=>k.mutate(U),isLoading:k.isPending}),ue.isOpen&&o.jsx(mr,{title:ue.title,message:ue.message,confirmText:"Delete",variant:"danger",onConfirm:ue.onConfirm,onCancel:()=>Ae(U=>({...U,isOpen:!1}))})]})}const Fk=5,qWe=2e3,KWe=3e4,XWe=5e3;function YWe(){const{printerId:t}=eR(),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),[b,v]=S.useState(0),[x,y]=S.useState(!1),[E,w]=S.useState(0),A=S.useRef(null),T=S.useRef(null),C=S.useRef(null),N=S.useRef(null),O=S.useRef(null),{data:k}=pt({queryKey:["printer",e],queryFn:()=>_e.getPrinter(e),enabled:e>0});S.useEffect(()=>(k&&(document.title=`${k.name} - Camera`),()=>{document.title="Bambuddy"}),[k]);const j=S.useRef(!1);S.useEffect(()=>{const Z=`/api/v1/printers/${e}/camera/stop`;j.current=!1;const F=()=>{e>0&&!j.current&&(j.current=!0,navigator.sendBeacon(Z))},V=()=>{F()};return window.addEventListener("beforeunload",V),()=>{window.removeEventListener("beforeunload",V),A.current&&(A.current.src=""),F()}},[e]),S.useEffect(()=>{if(s&&!d){const F=setTimeout(()=>{l(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(F)}},[n,s,c,d]),S.useEffect(()=>{const Z=()=>{const F=!!document.fullscreenElement;p(F),n==="stream"&&!d&&(A.current&&(A.current.src=""),setTimeout(()=>{l(!0),u(Date.now())},200))};return document.addEventListener("fullscreenchange",Z),()=>document.removeEventListener("fullscreenchange",Z)},[n,d]),S.useEffect(()=>{let Z;const F=()=>{clearTimeout(Z),Z=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",F),()=>{clearTimeout(Z),window.removeEventListener("resize",F)}},[]),S.useEffect(()=>()=>{C.current&&clearTimeout(C.current),N.current&&clearInterval(N.current),O.current&&clearInterval(O.current)},[]);const z=S.useCallback(()=>{if(b>=Fk){y(!1),a(!0);return}const Z=Math.min(qWe*Math.pow(2,b),KWe);y(!0),w(Math.ceil(Z/1e3)),N.current=setInterval(()=>{w(F=>F<=1?(N.current&&clearInterval(N.current),0):F-1)},1e3),C.current=setTimeout(()=>{v(F=>F+1),y(!1),l(!0),a(!1),A.current&&(A.current.src=""),u(Date.now())},Z)},[b]);S.useEffect(()=>{if(n!=="stream"||s||i||x||d){O.current&&(clearInterval(O.current),O.current=null);return}return O.current=setInterval(async()=>{try{const Z=await fetch(`/api/v1/printers/${e}/camera/status`);Z.ok&&(await Z.json()).stalled&&(console.log("Stream stall detected, auto-reconnecting..."),O.current&&(clearInterval(O.current),O.current=null),l(!1),z())}catch{}},XWe),()=>{O.current&&(clearInterval(O.current),O.current=null)}},[n,s,i,x,d,e,z]);const I=()=>{l(!1),n==="stream"&&b<Fk?z():a(!0)},q=()=>{if(l(!1),a(!1),v(0),y(!1),C.current&&clearTimeout(C.current),N.current&&clearInterval(N.current),A.current&&!localStorage.getItem("cameraWindowState")){const Z=A.current,F=Z.naturalWidth,V=Z.naturalHeight;if(F>0&&V>0){const oe=window.outerWidth-window.innerWidth,pe=window.outerHeight-window.innerHeight,Q=F+16+oe,Ee=V+45+16+pe;try{window.resizeTo(Q,Ee)}catch{}}}},R=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},W=Z=>{n===Z||d||(f(!0),l(!0),a(!1),v(0),y(!1),C.current&&clearTimeout(C.current),N.current&&clearInterval(N.current),A.current&&(A.current.src=""),n==="stream"&&R(),setTimeout(()=>{r(Z),u(Date.now()),f(!1)},100))},K=()=>{d||(f(!0),l(!0),a(!1),v(0),y(!1),C.current&&clearTimeout(C.current),N.current&&clearInterval(N.current),A.current&&(A.current.src=""),n==="stream"&&R(),setTimeout(()=>{u(Date.now()),f(!1)},100))},G=()=>{T.current&&(document.fullscreenElement?document.exitFullscreen():T.current.requestFullscreen())},J=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,ee=s||d||x;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"}),k?.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:()=>W("stream"),disabled:ee,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:()=>W("snapshot"),disabled:ee,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:K,disabled:ee,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 ${ee?"animate-spin":""}`})}),o.jsx("button",{onClick:G,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:g?"Exit fullscreen":"Fullscreen",children:g?o.jsx(sue,{className:"w-4 h-4 text-bambu-gray"}):o.jsx(Qce,{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)&&!x&&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..."})]})}),x&&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 ",b+1,"/",Fk,")"]}),o.jsx("button",{onClick:K,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:"Reconnect now"})]})}),i&&!x&&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(qn,{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:K,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:J,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:J?I:void 0,onLoad:J?q: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 ZWe(){const{id:t}=eR(),{mode:e}=og(),{data:n,isLoading:r,error:i}=pt({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(xt,{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(qn,{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 t9({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 Bu({title:t,icon:e,children:n}){return o.jsxs(At,{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 QWe(){const{t}=ng(),e=dn(),[n,r]=S.useState(null),[i,a]=S.useState(!1),[s,l]=S.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:f}=pt({queryKey:["systemInfo"],queryFn:_e.getSystemInfo,refetchInterval:3e4}),{data:g}=pt({queryKey:["debugLogging"],queryFn:p1.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),p=async()=>{l(!0);try{const y=await p1.setDebugLogging(!g?.enabled);e.setQueryData(["debugLogging"],y)}catch(y){console.error("Failed to toggle debug logging:",y)}finally{l(!1)}},b=async()=>{r(null),a(!0);try{await p1.downloadSupportBundle()}catch(y){r(y instanceof Error?y.message:"Failed to download support bundle")}finally{a(!1)}};if(u)return o.jsx("div",{className:"flex items-center justify-center h-64",children:o.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return o.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const v=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",x=c.memory.percent_used>90?"bg-red-500":c.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:()=>d(),disabled:f,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 ${f?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),o.jsx(Bu,{title:t("system.application","Application"),icon:ph,children:o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[o.jsx(Yr,{icon:ph,label:t("system.version","Version"),value:`v${c.app.version}`}),o.jsx(Yr,{icon:ur,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),o.jsx(Yr,{icon:ph,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),o.jsx(Bu,{title:t("support.title","Support & Troubleshooting"),icon:vce,children:o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.description","Enable debug logging to capture detailed information, then download a support bundle to share when reporting issues.")}),o.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:`p-2 rounded-lg ${g?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:o.jsx(B9,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),o.jsxs("p",{className:"text-sm text-bambu-gray",children:[g?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),g?.enabled&&g.duration_seconds!==null&&o.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(g.duration_seconds/60),"m ",g.duration_seconds%60,"s)"]})]})]})]}),o.jsxs("button",{onClick:p,disabled:s,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${g?.enabled?"bg-amber-500/20 text-amber-400 hover:bg-amber-500/30":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30"} disabled:opacity-50`,children:[s&&o.jsx(xt,{className:"w-4 h-4 animate-spin"}),g?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),o.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:o.jsx(Wi,{className:"w-5 h-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),o.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),o.jsxs("button",{onClick:b,disabled:i||!g?.enabled,className:"px-4 py-2 rounded-lg font-medium bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",title:g?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[i&&o.jsx(xt,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&o.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-lg text-red-400 text-sm",children:n}),!g?.enabled&&o.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:o.jsxs("p",{className:"text-sm text-bambu-gray",children:[o.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),o.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),o.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),o.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),o.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),o.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[o.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),o.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[o.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),o.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),o.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),o.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),o.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),o.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]})]})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),o.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[o.jsxs("li",{children:["• ",t("support.notItem1","Printer names, IPs, serial numbers")]}),o.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),o.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),o.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),o.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),o.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]})]})]})]}),o.jsx("p",{className:"text-xs text-bambu-gray/70",children:t("support.privacyNote","IP addresses in logs are replaced with [IP] and email addresses with [EMAIL].")})]})]})}),o.jsxs(Bu,{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:co,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),o.jsx(Yr,{icon:cR,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),o.jsx(Yr,{icon:Ra,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),o.jsx(Yr,{icon:xt,label:t("system.printing","Printing"),value:c.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:qi,label:t("system.printers","Printers"),value:c.database.printers}),o.jsx(Yr,{icon:bR,label:t("system.filaments","Filaments"),value:c.database.filaments}),o.jsx(Yr,{icon:Bo,label:t("system.projects","Projects"),value:c.database.projects}),o.jsx(Yr,{icon:uo,label:t("system.smartPlugs","Smart Plugs"),value:c.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:c.database.total_print_time_formatted}),o.jsx(Yr,{icon:co,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),o.jsxs(Bu,{title:t("system.connectedPrinters","Connected Printers"),icon:qi,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:c.printers.connected}),o.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?o.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(y=>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:y.name})]}),o.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[o.jsx("span",{children:y.model}),o.jsx("span",{className:`px-2 py-0.5 rounded ${y.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":y.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:y.state})]})]},y.id))}):o.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),o.jsx(Bu,{title:t("system.storage","Storage"),icon:pR,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:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),o.jsx(t9,{percent:c.storage.disk_percent_used,color:v}),o.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.storage.disk_free_formatted," ",t("system.free","free")," (",(100-c.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:co,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),o.jsx(Yr,{icon:Ep,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted})]})]})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsx(Bu,{title:t("system.memory","Memory"),icon:eue,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:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),o.jsx(t9,{percent:c.memory.percent_used,color:x}),o.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),o.jsx(Bu,{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:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),o.jsx(Yr,{icon:Cv,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),o.jsx(Bu,{title:t("system.systemDetails","System Details"),icon:ph,children:o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[o.jsx(Yr,{icon:ph,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),o.jsx(Yr,{icon:Cv,label:t("system.architecture","Architecture"),value:c.system.architecture}),o.jsx(Yr,{icon:ph,label:t("system.python","Python"),value:c.system.python_version}),o.jsx(Yr,{icon:ur,label:t("system.bootTime","Boot Time"),value:new Date(c.system.boot_time).toLocaleString()})]})})]})}function JWe(){const t=S.useRef(null),e=S.useRef(null),n=dn(),[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},[]),b=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]),x=S.useCallback(E=>{switch(E.type){case"printer_status":E.printer_id!==void 0&&E.data&&b(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":v("archives"),v("archiveStats");break;case"archive_created":v("archives"),v("archiveStats");break;case"archive_updated":v("archives");break}},[n,v,b]);S.useEffect(()=>{f.current=x},[x]),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 y=S.useCallback(E=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(E))},[]);return{isConnected:r,sendMessage:y}}const eqe=new foe({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function tqe({children:t}){return JWe(),o.jsx(o.Fragment,{children:t})}function nqe(){return o.jsx(Hde,{children:o.jsx(Jde,{children:o.jsx(moe,{client:eqe,children:o.jsx(tqe,{children:o.jsx(Ose,{children:o.jsxs(hse,{children:[o.jsx(Za,{path:"/camera/:printerId",element:o.jsx(YWe,{})}),o.jsxs(Za,{path:"/",element:o.jsx(Yde,{}),children:[o.jsx(Za,{index:!0,element:o.jsx(vCe,{})}),o.jsx(Za,{path:"archives",element:o.jsx(J7e,{})}),o.jsx(Za,{path:"queue",element:o.jsx(F9e,{})}),o.jsx(Za,{path:"stats",element:o.jsx(Q9e,{})}),o.jsx(Za,{path:"profiles",element:o.jsx(jWe,{})}),o.jsx(Za,{path:"maintenance",element:o.jsx(IWe,{})}),o.jsx(Za,{path:"projects",element:o.jsx(UWe,{})}),o.jsx(Za,{path:"projects/:id",element:o.jsx(WWe,{})}),o.jsx(Za,{path:"settings",element:o.jsx(_We,{})}),o.jsx(Za,{path:"system",element:o.jsx(QWe,{})}),o.jsx(Za,{path:"external/:id",element:o.jsx(ZWe,{})})]})]})})})})})})}gie.createRoot(document.getElementById("root")).render(o.jsx(S.StrictMode,{children:o.jsx(nqe,{})}));