index-C_Su2_85.js 3.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663
  1. function Eie(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(t,i,a.get?a:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).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 Cv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function wo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var VA={exports:{}},_x={};var DF;function Aie(){if(DF)return _x;DF=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,a){var o=null;if(a!==void 0&&(o=""+a),i.key!==void 0&&(o=""+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:o,ref:i!==void 0?i:null,props:a}}return _x.Fragment=e,_x.jsx=n,_x.jsxs=n,_x}var OF;function Nie(){return OF||(OF=1,VA.exports=Aie()),VA.exports}var s=Nie(),GA={exports:{}},ln={};var LF;function Tie(){if(LF)return ln;LF=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"),o=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 x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,b={};function v(F,W,ee){this.props=F,this.context=W,this.refs=b,this.updater=ee||x}v.prototype.isReactComponent={},v.prototype.setState=function(F,W){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,W,"setState")},v.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function E(){}E.prototype=v.prototype;function w(F,W,ee){this.props=F,this.context=W,this.refs=b,this.updater=ee||x}var N=w.prototype=new E;N.constructor=w,y(N,v.prototype),N.isPureReactComponent=!0;var A=Array.isArray;function C(){}var T={H:null,A:null,T:null,S:null},L=Object.prototype.hasOwnProperty;function k(F,W,ee){var ie=ee.ref;return{$$typeof:t,type:F,key:W,ref:ie!==void 0?ie:null,props:ee}}function D(F,W){return k(F.type,W,F.props)}function U(F){return typeof F=="object"&&F!==null&&F.$$typeof===t}function O(F){var W={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(ee){return W[ee]})}var q=/\/+/g;function R(F,W){return typeof F=="object"&&F!==null&&F.key!=null?O(""+F.key):W.toString(36)}function G(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(W){F.status==="pending"&&(F.status="fulfilled",F.value=W)},function(W){F.status==="pending"&&(F.status="rejected",F.reason=W)})),F.status){case"fulfilled":return F.value;case"rejected":throw F.reason}}throw F}function Y(F,W,ee,ie,ae){var de=typeof F;(de==="undefined"||de==="boolean")&&(F=null);var ue=!1;if(F===null)ue=!0;else switch(de){case"bigint":case"string":case"number":ue=!0;break;case"object":switch(F.$$typeof){case t:case e:ue=!0;break;case d:return ue=F._init,Y(ue(F._payload),W,ee,ie,ae)}}if(ue)return ae=ae(F),ue=ie===""?"."+R(F,0):ie,A(ae)?(ee="",ue!=null&&(ee=ue.replace(q,"$&/")+"/"),Y(ae,W,ee,"",function(pe){return pe})):ae!=null&&(U(ae)&&(ae=D(ae,ee+(ae.key==null||F&&F.key===ae.key?"":(""+ae.key).replace(q,"$&/")+"/")+ue)),W.push(ae)),1;ue=0;var le=ie===""?".":ie+":";if(A(F))for(var he=0;he<F.length;he++)ie=F[he],de=le+R(ie,he),ue+=Y(ie,W,ee,de,ae);else if(he=p(F),typeof he=="function")for(F=he.call(F),he=0;!(ie=F.next()).done;)ie=ie.value,de=le+R(ie,he++),ue+=Y(ie,W,ee,de,ae);else if(de==="object"){if(typeof F.then=="function")return Y(G(F),W,ee,ie,ae);throw W=String(F),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return ue}function V(F,W,ee){if(F==null)return F;var ie=[],ae=0;return Y(F,ie,"","",function(de){return W.call(ee,de,ae++)}),ie}function K(F){if(F._status===-1){var W=F._result;W=W(),W.then(function(ee){(F._status===0||F._status===-1)&&(F._status=1,F._result=ee)},function(ee){(F._status===0||F._status===-1)&&(F._status=2,F._result=ee)}),F._status===-1&&(F._status=0,F._result=W)}if(F._status===1)return F._result.default;throw F._result}var J=typeof reportError=="function"?reportError:function(F){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=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(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",F);return}console.error(F)},X={map:V,forEach:function(F,W,ee){V(F,function(){W.apply(this,arguments)},ee)},count:function(F){var W=0;return V(F,function(){W++}),W},toArray:function(F){return V(F,function(W){return W})||[]},only:function(F){if(!U(F))throw Error("React.Children.only expected to receive a single React element child.");return F}};return ln.Activity=f,ln.Children=X,ln.Component=v,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=T,ln.__COMPILER_RUNTIME={__proto__:null,c:function(F){return T.H.useMemoCache(F)}},ln.cache=function(F){return function(){return F.apply(null,arguments)}},ln.cacheSignal=function(){return null},ln.cloneElement=function(F,W,ee){if(F==null)throw Error("The argument must be a React element, but you passed "+F+".");var ie=y({},F.props),ae=F.key;if(W!=null)for(de in W.key!==void 0&&(ae=""+W.key),W)!L.call(W,de)||de==="key"||de==="__self"||de==="__source"||de==="ref"&&W.ref===void 0||(ie[de]=W[de]);var de=arguments.length-2;if(de===1)ie.children=ee;else if(1<de){for(var ue=Array(de),le=0;le<de;le++)ue[le]=arguments[le+2];ie.children=ue}return k(F.type,ae,ie)},ln.createContext=function(F){return F={$$typeof:o,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null},F.Provider=F,F.Consumer={$$typeof:a,_context:F},F},ln.createElement=function(F,W,ee){var ie,ae={},de=null;if(W!=null)for(ie in W.key!==void 0&&(de=""+W.key),W)L.call(W,ie)&&ie!=="key"&&ie!=="__self"&&ie!=="__source"&&(ae[ie]=W[ie]);var ue=arguments.length-2;if(ue===1)ae.children=ee;else if(1<ue){for(var le=Array(ue),he=0;he<ue;he++)le[he]=arguments[he+2];ae.children=le}if(F&&F.defaultProps)for(ie in ue=F.defaultProps,ue)ae[ie]===void 0&&(ae[ie]=ue[ie]);return k(F,de,ae)},ln.createRef=function(){return{current:null}},ln.forwardRef=function(F){return{$$typeof:l,render:F}},ln.isValidElement=U,ln.lazy=function(F){return{$$typeof:d,_payload:{_status:-1,_result:F},_init:K}},ln.memo=function(F,W){return{$$typeof:u,type:F,compare:W===void 0?null:W}},ln.startTransition=function(F){var W=T.T,ee={};T.T=ee;try{var ie=F(),ae=T.S;ae!==null&&ae(ee,ie),typeof ie=="object"&&ie!==null&&typeof ie.then=="function"&&ie.then(C,J)}catch(de){J(de)}finally{W!==null&&ee.types!==null&&(W.types=ee.types),T.T=W}},ln.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},ln.use=function(F){return T.H.use(F)},ln.useActionState=function(F,W,ee){return T.H.useActionState(F,W,ee)},ln.useCallback=function(F,W){return T.H.useCallback(F,W)},ln.useContext=function(F){return T.H.useContext(F)},ln.useDebugValue=function(){},ln.useDeferredValue=function(F,W){return T.H.useDeferredValue(F,W)},ln.useEffect=function(F,W){return T.H.useEffect(F,W)},ln.useEffectEvent=function(F){return T.H.useEffectEvent(F)},ln.useId=function(){return T.H.useId()},ln.useImperativeHandle=function(F,W,ee){return T.H.useImperativeHandle(F,W,ee)},ln.useInsertionEffect=function(F,W){return T.H.useInsertionEffect(F,W)},ln.useLayoutEffect=function(F,W){return T.H.useLayoutEffect(F,W)},ln.useMemo=function(F,W){return T.H.useMemo(F,W)},ln.useOptimistic=function(F,W){return T.H.useOptimistic(F,W)},ln.useReducer=function(F,W,ee){return T.H.useReducer(F,W,ee)},ln.useRef=function(F){return T.H.useRef(F)},ln.useState=function(F){return T.H.useState(F)},ln.useSyncExternalStore=function(F,W,ee){return T.H.useSyncExternalStore(F,W,ee)},ln.useTransition=function(){return T.H.useTransition()},ln.version="19.2.0",ln}var IF;function og(){return IF||(IF=1,GA.exports=Tie()),GA.exports}var S=og();const kr=wo(S),Cie=Eie({__proto__:null,default:kr},[S]);var WA={exports:{}},wx={},qA={exports:{}},KA={};var FF;function kie(){return FF||(FF=1,(function(t){function e(Y,V){var K=Y.length;Y.push(V);e:for(;0<K;){var J=K-1>>>1,X=Y[J];if(0<i(X,V))Y[J]=V,Y[K]=X,K=J;else break e}}function n(Y){return Y.length===0?null:Y[0]}function r(Y){if(Y.length===0)return null;var V=Y[0],K=Y.pop();if(K!==V){Y[0]=K;e:for(var J=0,X=Y.length,F=X>>>1;J<F;){var W=2*(J+1)-1,ee=Y[W],ie=W+1,ae=Y[ie];if(0>i(ee,K))ie<X&&0>i(ae,ee)?(Y[J]=ae,Y[ie]=K,J=ie):(Y[J]=ee,Y[W]=K,J=W);else if(ie<X&&0>i(ae,K))Y[J]=ae,Y[ie]=K,J=ie;else break e}}return V}function i(Y,V){var K=Y.sortIndex-V.sortIndex;return K!==0?K:Y.id-V.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 o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,f=null,g=3,p=!1,x=!1,y=!1,b=!1,v=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function N(Y){for(var V=n(u);V!==null;){if(V.callback===null)r(u);else if(V.startTime<=Y)r(u),V.sortIndex=V.expirationTime,e(c,V);else break;V=n(u)}}function A(Y){if(y=!1,N(Y),!x)if(n(c)!==null)x=!0,C||(C=!0,O());else{var V=n(u);V!==null&&G(A,V.startTime-Y)}}var C=!1,T=-1,L=5,k=-1;function D(){return b?!0:!(t.unstable_now()-k<L)}function U(){if(b=!1,C){var Y=t.unstable_now();k=Y;var V=!0;try{e:{x=!1,y&&(y=!1,E(T),T=-1),p=!0;var K=g;try{t:{for(N(Y),f=n(c);f!==null&&!(f.expirationTime>Y&&D());){var J=f.callback;if(typeof J=="function"){f.callback=null,g=f.priorityLevel;var X=J(f.expirationTime<=Y);if(Y=t.unstable_now(),typeof X=="function"){f.callback=X,N(Y),V=!0;break t}f===n(c)&&r(c),N(Y)}else r(c);f=n(c)}if(f!==null)V=!0;else{var F=n(u);F!==null&&G(A,F.startTime-Y),V=!1}}break e}finally{f=null,g=K,p=!1}V=void 0}}finally{V?O():C=!1}}}var O;if(typeof w=="function")O=function(){w(U)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,R=q.port2;q.port1.onmessage=U,O=function(){R.postMessage(null)}}else O=function(){v(U,0)};function G(Y,V){T=v(function(){Y(t.unstable_now())},V)}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(Y){Y.callback=null},t.unstable_forceFrameRate=function(Y){0>Y||125<Y?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<Y?Math.floor(1e3/Y):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_next=function(Y){switch(g){case 1:case 2:case 3:var V=3;break;default:V=g}var K=g;g=V;try{return Y()}finally{g=K}},t.unstable_requestPaint=function(){b=!0},t.unstable_runWithPriority=function(Y,V){switch(Y){case 1:case 2:case 3:case 4:case 5:break;default:Y=3}var K=g;g=Y;try{return V()}finally{g=K}},t.unstable_scheduleCallback=function(Y,V,K){var J=t.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?J+K:J):K=J,Y){case 1:var X=-1;break;case 2:X=250;break;case 5:X=1073741823;break;case 4:X=1e4;break;default:X=5e3}return X=K+X,Y={id:d++,callback:V,priorityLevel:Y,startTime:K,expirationTime:X,sortIndex:-1},K>J?(Y.sortIndex=K,e(u,Y),n(c)===null&&Y===n(u)&&(y?(E(T),T=-1):y=!0,G(A,K-J))):(Y.sortIndex=X,e(c,Y),x||p||(x=!0,C||(C=!0,O()))),Y},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(Y){var V=g;return function(){var K=g;g=V;try{return Y.apply(this,arguments)}finally{g=K}}}})(KA)),KA}var UF;function Pie(){return UF||(UF=1,qA.exports=kie()),qA.exports}var XA={exports:{}},ma={};var zF;function jie(){if(zF)return ma;zF=1;var t=og();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 o=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 ma.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,ma.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)},ma.flushSync=function(c){var u=o.T,d=r.p;try{if(o.T=null,r.p=2,c)return c()}finally{o.T=u,r.p=d,r.d.f()}},ma.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))},ma.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},ma.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})}},ma.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)},ma.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})}},ma.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)},ma.requestFormReset=function(c){r.d.r(c)},ma.unstable_batchedUpdates=function(c,u){return c(u)},ma.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},ma.useFormStatus=function(){return o.H.useHostTransitionStatus()},ma.version="19.2.0",ma}var BF;function h9(){if(BF)return XA.exports;BF=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(),XA.exports=jie(),XA.exports}var HF;function Rie(){if(HF)return wx;HF=1;var t=Pie(),e=og(),n=h9();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 o(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 I=P.alternate;if(I===null){if(M=P.return,M!==null){_=M;continue}break}if(P.child===I.child){for(I=P.child;I;){if(I===_)return c(P),h;if(I===M)return c(P),m;I=I.sibling}throw Error(r(188))}if(_.return!==M.return)_=P,M=I;else{for(var Z=!1,fe=P.child;fe;){if(fe===_){Z=!0,_=P,M=I;break}if(fe===M){Z=!0,M=P,_=I;break}fe=fe.sibling}if(!Z){for(fe=I.child;fe;){if(fe===_){Z=!0,_=I,M=P;break}if(fe===M){Z=!0,M=I,_=P;break}fe=fe.sibling}if(!Z)throw Error(r(189))}}if(_.alternate!==M)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:m}function d(h){var m=h.tag;if(m===5||m===26||m===27||m===6)return h;for(h=h.child;h!==null;){if(m=d(h),m!==null)return m;h=h.sibling}return null}var f=Object.assign,g=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),w=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),U=Symbol.iterator;function O(h){return h===null||typeof h!="object"?null:(h=U&&h[U]||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 y:return"Fragment";case v:return"Profiler";case b:return"StrictMode";case A:return"Suspense";case C:return"SuspenseList";case k:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case w:return h.displayName||"Context";case E:return(h._context.displayName||"Context")+".Consumer";case N:var m=h.render;return h=h.displayName,h||(h=m.displayName||m.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case T:return m=h.displayName||null,m!==null?m:R(h.type)||"Memo";case L:m=h._payload,h=h._init;try{return R(h(m))}catch{}}return null}var G=Array.isArray,Y=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K={pending:!1,data:null,method:null,action:null},J=[],X=-1;function F(h){return{current:h}}function W(h){0>X||(h.current=J[X],J[X]=null,X--)}function ee(h,m){X++,J[X]=h.current,h.current=m}var ie=F(null),ae=F(null),de=F(null),ue=F(null);function le(h,m){switch(ee(de,m),ee(ae,h),ee(ie,null),m.nodeType){case 9:case 11:h=(h=m.documentElement)&&(h=h.namespaceURI)?rF(h):0;break;default:if(h=m.tagName,m=m.namespaceURI)m=rF(m),h=iF(m,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}W(ie),ee(ie,h)}function he(){W(ie),W(ae),W(de)}function pe(h){h.memoizedState!==null&&ee(ue,h);var m=ie.current,_=iF(m,h.type);m!==_&&(ee(ae,h),ee(ie,_))}function Me(h){ae.current===h&&(W(ie),W(ae)),ue.current===h&&(W(ue),xx._currentValue=K)}var re,We;function z(h){if(re===void 0)try{throw Error()}catch(_){var m=_.stack.trim().match(/\n( *(at )?)/);re=m&&m[1]||"",We=-1<_.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+re+h+We}var H=!1;function se(h,m){if(!h||H)return"";H=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var M={DetermineComponentFrameRoot:function(){try{if(m){var pt=function(){throw Error()};if(Object.defineProperty(pt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(pt,[])}catch(ot){var it=ot}Reflect.construct(h,[],pt)}else{try{pt.call()}catch(ot){it=ot}h.call(pt.prototype)}}else{try{throw Error()}catch(ot){it=ot}(pt=h())&&typeof pt.catch=="function"&&pt.catch(function(){})}}catch(ot){if(ot&&it&&typeof ot.stack=="string")return[ot.stack,it.stack]}return[null,null]}};M.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(M.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(M.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var I=M.DetermineComponentFrameRoot(),Z=I[0],fe=I[1];if(Z&&fe){var Te=Z.split(`
  4. `),nt=fe.split(`
  5. `);for(P=M=0;M<Te.length&&!Te[M].includes("DetermineComponentFrameRoot");)M++;for(;P<nt.length&&!nt[P].includes("DetermineComponentFrameRoot");)P++;if(M===Te.length||P===nt.length)for(M=Te.length-1,P=nt.length-1;1<=M&&0<=P&&Te[M]!==nt[P];)P--;for(;1<=M&&0<=P;M--,P--)if(Te[M]!==nt[P]){if(M!==1||P!==1)do if(M--,P--,0>P||Te[M]!==nt[P]){var lt=`
  6. `+Te[M].replace(" at new "," at ");return h.displayName&&lt.includes("<anonymous>")&&(lt=lt.replace("<anonymous>",h.displayName)),lt}while(1<=M&&0<=P);break}}}finally{H=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?z(_):""}function B(h,m){switch(h.tag){case 26:case 27:case 5:return z(h.type);case 16:return z("Lazy");case 13:return h.child!==m&&m!==null?z("Suspense Fallback"):z("Suspense");case 19:return z("SuspenseList");case 0:case 15:return se(h.type,!1);case 11:return se(h.type.render,!1);case 1:return se(h.type,!0);case 31:return z("Activity");default:return""}}function Q(h){try{var m="",_=null;do m+=B(h,_),_=h,h=h.return;while(h);return m}catch(M){return`
  7. Error generating stack: `+M.message+`
  8. `+M.stack}}var ce=Object.prototype.hasOwnProperty,Ce=t.unstable_scheduleCallback,_e=t.unstable_cancelCallback,Ee=t.unstable_shouldYield,$=t.unstable_requestPaint,j=t.unstable_now,ne=t.unstable_getCurrentPriorityLevel,be=t.unstable_ImmediatePriority,we=t.unstable_UserBlockingPriority,ve=t.unstable_NormalPriority,$e=t.unstable_LowPriority,Ge=t.unstable_IdlePriority,Xe=t.log,ut=t.unstable_setDisableYieldValue,He=null,me=null;function Je(h){if(typeof Xe=="function"&&ut(h),me&&typeof me.setStrictMode=="function")try{me.setStrictMode(He,h)}catch{}}var Ke=Math.clz32?Math.clz32:te,Ze=Math.log,ct=Math.LN2;function te(h){return h>>>=0,h===0?32:31-(Ze(h)/ct|0)|0}var Fe=256,xe=262144,ze=4194304;function Pe(h){var m=h&42;if(m!==0)return m;switch(h&-h){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return h&261888;case 262144:case 524288:case 1048576:case 2097152:return h&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return h&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return h}}function Se(h,m,_){var M=h.pendingLanes;if(M===0)return 0;var P=0,I=h.suspendedLanes,Z=h.pingedLanes;h=h.warmLanes;var fe=M&134217727;return fe!==0?(M=fe&~I,M!==0?P=Pe(M):(Z&=fe,Z!==0?P=Pe(Z):_||(_=fe&~h,_!==0&&(P=Pe(_))))):(fe=M&~I,fe!==0?P=Pe(fe):Z!==0?P=Pe(Z):_||(_=M&~h,_!==0&&(P=Pe(_)))),P===0?0:m!==0&&m!==P&&(m&I)===0&&(I=P&-P,_=m&-m,I>=_||I===32&&(_&4194048)!==0)?m:P}function Ye(h,m){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&m)===0}function dt(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 Tt(){var h=ze;return ze<<=1,(ze&62914560)===0&&(ze=4194304),h}function Et(h){for(var m=[],_=0;31>_;_++)m.push(h);return m}function Zt(h,m){h.pendingLanes|=m,m!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Rt(h,m,_,M,P,I){var Z=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var fe=h.entanglements,Te=h.expirationTimes,nt=h.hiddenUpdates;for(_=Z&~_;0<_;){var lt=31-Ke(_),pt=1<<lt;fe[lt]=0,Te[lt]=-1;var it=nt[lt];if(it!==null)for(nt[lt]=null,lt=0;lt<it.length;lt++){var ot=it[lt];ot!==null&&(ot.lane&=-536870913)}_&=~pt}M!==0&&en(h,M,0),I!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=I&~(Z&~m))}function en(h,m,_){h.pendingLanes|=m,h.suspendedLanes&=~m;var M=31-Ke(m);h.entangledLanes|=m,h.entanglements[M]=h.entanglements[M]|1073741824|_&261930}function Ln(h,m){var _=h.entangledLanes|=m;for(h=h.entanglements;_;){var M=31-Ke(_),P=1<<M;P&m|h[M]&m&&(h[M]|=m),_&=~P}}function Vn(h,m){var _=m&-m;return _=(_&42)!==0?1:tr(_),(_&(h.suspendedLanes|m))!==0?0:_}function tr(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 gt(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function Vt(){var h=V.p;return h!==0?h:(h=window.event,h===void 0?32:NF(h.type))}function Qt(h,m){var _=V.p;try{return V.p=h,m()}finally{V.p=_}}var mt=Math.random().toString(36).slice(2),Kt="__reactFiber$"+mt,dn="__reactProps$"+mt,Ht="__reactContainer$"+mt,Re="__reactEvents$"+mt,ge="__reactListeners$"+mt,je="__reactHandles$"+mt,Be="__reactResources$"+mt,rt="__reactMarker$"+mt;function tt(h){delete h[Kt],delete h[dn],delete h[Re],delete h[ge],delete h[je]}function yt(h){var m=h[Kt];if(m)return m;for(var _=h.parentNode;_;){if(m=_[Ht]||_[Kt]){if(_=m.alternate,m.child!==null||_!==null&&_.child!==null)for(h=dF(h);h!==null;){if(_=h[Kt])return _;h=dF(h)}return m}h=_,_=h.parentNode}return null}function oe(h){if(h=h[Kt]||h[Ht]){var m=h.tag;if(m===5||m===6||m===13||m===31||m===26||m===27||m===3)return h}return null}function Ae(h){var m=h.tag;if(m===5||m===26||m===27||m===6)return h.stateNode;throw Error(r(33))}function De(h){var m=h[Be];return m||(m=h[Be]={hoistableStyles:new Map,hoistableScripts:new Map}),m}function Oe(h){h[rt]=!0}var ke=new Set,st={};function vt(h,m){Ct(h,m),Ct(h+"Capture",m)}function Ct(h,m){for(st[h]=m,h=0;h<m.length;h++)ke.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 wt(h){return ce.call(jt,h)?!0:ce.call(Ut,h)?!1:Nt.test(h)?jt[h]=!0:(Ut[h]=!0,!1)}function rn(h,m,_){if(wt(m))if(_===null)h.removeAttribute(m);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(m);return;case"boolean":var M=m.toLowerCase().slice(0,5);if(M!=="data-"&&M!=="aria-"){h.removeAttribute(m);return}}h.setAttribute(m,""+_)}}function Gt(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 wn(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function Cn(h){var m=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(m==="checkbox"||m==="radio")}function $t(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,I=M.set;return Object.defineProperty(h,m,{configurable:!0,get:function(){return P.call(this)},set:function(Z){_=""+Z,I.call(this,Z)}}),Object.defineProperty(h,m,{enumerable:M.enumerable}),{getValue:function(){return _},setValue:function(Z){_=""+Z},stopTracking:function(){h._valueTracker=null,delete h[m]}}}}function on(h){if(!h._valueTracker){var m=Cn(h)?"checked":"value";h._valueTracker=$t(h,m,""+h[m])}}function un(h){if(!h)return!1;var m=h._valueTracker;if(!m)return!0;var _=m.getValue(),M="";return h&&(M=Cn(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 Yr=/[\n"\\]/g;function Gn(h){return h.replace(Yr,function(m){return"\\"+m.charCodeAt(0).toString(16)+" "})}function Mo(h,m,_,M,P,I,Z,fe){h.name="",Z!=null&&typeof Z!="function"&&typeof Z!="symbol"&&typeof Z!="boolean"?h.type=Z:h.removeAttribute("type"),m!=null?Z==="number"?(m===0&&h.value===""||h.value!=m)&&(h.value=""+wn(m)):h.value!==""+wn(m)&&(h.value=""+wn(m)):Z!=="submit"&&Z!=="reset"||h.removeAttribute("value"),m!=null?Li(h,Z,wn(m)):_!=null?Li(h,Z,wn(_)):M!=null&&h.removeAttribute("value"),P==null&&I!=null&&(h.defaultChecked=!!I),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),fe!=null&&typeof fe!="function"&&typeof fe!="symbol"&&typeof fe!="boolean"?h.name=""+wn(fe):h.removeAttribute("name")}function qn(h,m,_,M,P,I,Z,fe){if(I!=null&&typeof I!="function"&&typeof I!="symbol"&&typeof I!="boolean"&&(h.type=I),m!=null||_!=null){if(!(I!=="submit"&&I!=="reset"||m!=null)){on(h);return}_=_!=null?""+wn(_):"",m=m!=null?""+wn(m):_,fe||m===h.value||(h.value=m),h.defaultValue=m}M=M??P,M=typeof M!="function"&&typeof M!="symbol"&&!!M,h.checked=fe?h.checked:!!M,h.defaultChecked=!!M,Z!=null&&typeof Z!="function"&&typeof Z!="symbol"&&typeof Z!="boolean"&&(h.name=Z),on(h)}function Li(h,m,_){m==="number"&&Ur(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function xi(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(_=""+wn(_),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 Ii(h,m,_){if(m!=null&&(m=""+wn(m),m!==h.value&&(h.value=m),_==null)){h.defaultValue!==m&&(h.defaultValue=m);return}h.defaultValue=_!=null?""+wn(_):""}function Zi(h,m,_,M){if(m==null){if(M!=null){if(_!=null)throw Error(r(92));if(G(M)){if(1<M.length)throw Error(r(93));M=M[0]}_=M}_==null&&(_=""),m=_}_=wn(m),h.defaultValue=_,M=h.textContent,M===_&&M!==""&&M!==null&&(h.value=M),on(h)}function el(h,m){if(m){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=m;return}}h.textContent=m}var zl=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 eL(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||zl.has(m)?m==="float"?h.cssFloat=_:h[m]=(""+_).trim():h[m]=_+"px"}function tL(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&&eL(h,P,M)}else for(var I in m)m.hasOwnProperty(I)&&eL(h,I,m[I])}function z2(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 _ne=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"]]),wne=/^[\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 vy(h){return wne.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function Bl(){}var B2=null;function H2(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var Of=null,Lf=null;function nL(h){var m=oe(h);if(m&&(h=m.stateNode)){var _=h[dn]||null;e:switch(h=m.stateNode,m.type){case"input":if(Mo(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[dn]||null;if(!P)throw Error(r(90));Mo(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&&un(M)}break e;case"textarea":Ii(h,_.value,_.defaultValue);break e;case"select":m=_.value,m!=null&&xi(h,!!_.multiple,m,!1)}}}var $2=!1;function rL(h,m,_){if($2)return h(m,_);$2=!0;try{var M=h(m);return M}finally{if($2=!1,(Of!==null||Lf!==null)&&(ov(),Of&&(m=Of,h=Lf,Lf=Of=null,nL(m),h)))for(m=0;m<h.length;m++)nL(h[m])}}function Dg(h,m){var _=h.stateNode;if(_===null)return null;var M=_[dn]||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 Hl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),V2=!1;if(Hl)try{var Og={};Object.defineProperty(Og,"passive",{get:function(){V2=!0}}),window.addEventListener("test",Og,Og),window.removeEventListener("test",Og,Og)}catch{V2=!1}var su=null,G2=null,_y=null;function iL(){if(_y)return _y;var h,m=G2,_=m.length,M,P="value"in su?su.value:su.textContent,I=P.length;for(h=0;h<_&&m[h]===P[h];h++);var Z=_-h;for(M=1;M<=Z&&m[_-M]===P[I-M];M++);return _y=P.slice(h,1<M?1-M:void 0)}function wy(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 Sy(){return!0}function aL(){return!1}function Wa(h){function m(_,M,P,I,Z){this._reactName=_,this._targetInst=P,this.type=M,this.nativeEvent=I,this.target=Z,this.currentTarget=null;for(var fe in h)h.hasOwnProperty(fe)&&(_=h[fe],this[fe]=_?_(I):I[fe]);return this.isDefaultPrevented=(I.defaultPrevented!=null?I.defaultPrevented:I.returnValue===!1)?Sy:aL,this.isPropagationStopped=aL,this}return f(m.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=Sy)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=Sy)},persist:function(){},isPersistent:Sy}),m}var Wd={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},My=Wa(Wd),Lg=f({},Wd,{view:0,detail:0}),Sne=Wa(Lg),W2,q2,Ig,Ey=f({},Lg,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:X2,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!==Ig&&(Ig&&h.type==="mousemove"?(W2=h.screenX-Ig.screenX,q2=h.screenY-Ig.screenY):q2=W2=0,Ig=h),W2)},movementY:function(h){return"movementY"in h?h.movementY:q2}}),sL=Wa(Ey),Mne=f({},Ey,{dataTransfer:0}),Ene=Wa(Mne),Ane=f({},Lg,{relatedTarget:0}),K2=Wa(Ane),Nne=f({},Wd,{animationName:0,elapsedTime:0,pseudoElement:0}),Tne=Wa(Nne),Cne=f({},Wd,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),kne=Wa(Cne),Pne=f({},Wd,{data:0}),oL=Wa(Pne),jne={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Rne={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"},Dne={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function One(h){var m=this.nativeEvent;return m.getModifierState?m.getModifierState(h):(h=Dne[h])?!!m[h]:!1}function X2(){return One}var Lne=f({},Lg,{key:function(h){if(h.key){var m=jne[h.key]||h.key;if(m!=="Unidentified")return m}return h.type==="keypress"?(h=wy(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?Rne[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:X2,charCode:function(h){return h.type==="keypress"?wy(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?wy(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),Ine=Wa(Lne),Fne=f({},Ey,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),lL=Wa(Fne),Une=f({},Lg,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:X2}),zne=Wa(Une),Bne=f({},Wd,{propertyName:0,elapsedTime:0,pseudoElement:0}),Hne=Wa(Bne),$ne=f({},Ey,{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}),Vne=Wa($ne),Gne=f({},Wd,{newState:0,oldState:0}),Wne=Wa(Gne),qne=[9,13,27,32],Y2=Hl&&"CompositionEvent"in window,Fg=null;Hl&&"documentMode"in document&&(Fg=document.documentMode);var Kne=Hl&&"TextEvent"in window&&!Fg,cL=Hl&&(!Y2||Fg&&8<Fg&&11>=Fg),uL=" ",dL=!1;function hL(h,m){switch(h){case"keyup":return qne.indexOf(m.keyCode)!==-1;case"keydown":return m.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function fL(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var If=!1;function Xne(h,m){switch(h){case"compositionend":return fL(m);case"keypress":return m.which!==32?null:(dL=!0,uL);case"textInput":return h=m.data,h===uL&&dL?null:h;default:return null}}function Yne(h,m){if(If)return h==="compositionend"||!Y2&&hL(h,m)?(h=iL(),_y=G2=su=null,If=!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 cL&&m.locale!=="ko"?null:m.data;default:return null}}var Zne={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 mL(h){var m=h&&h.nodeName&&h.nodeName.toLowerCase();return m==="input"?!!Zne[h.type]:m==="textarea"}function pL(h,m,_,M){Of?Lf?Lf.push(M):Lf=[M]:Of=M,m=mv(m,"onChange"),0<m.length&&(_=new My("onChange","change",null,_,M),h.push({event:_,listeners:m}))}var Ug=null,zg=null;function Qne(h){Z5(h,0)}function Ay(h){var m=Ae(h);if(un(m))return h}function gL(h,m){if(h==="change")return m}var xL=!1;if(Hl){var Z2;if(Hl){var Q2="oninput"in document;if(!Q2){var bL=document.createElement("div");bL.setAttribute("oninput","return;"),Q2=typeof bL.oninput=="function"}Z2=Q2}else Z2=!1;xL=Z2&&(!document.documentMode||9<document.documentMode)}function yL(){Ug&&(Ug.detachEvent("onpropertychange",vL),zg=Ug=null)}function vL(h){if(h.propertyName==="value"&&Ay(zg)){var m=[];pL(m,zg,h,H2(h)),rL(Qne,m)}}function Jne(h,m,_){h==="focusin"?(yL(),Ug=m,zg=_,Ug.attachEvent("onpropertychange",vL)):h==="focusout"&&yL()}function ere(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return Ay(zg)}function tre(h,m){if(h==="click")return Ay(m)}function nre(h,m){if(h==="input"||h==="change")return Ay(m)}function rre(h,m){return h===m&&(h!==0||1/h===1/m)||h!==h&&m!==m}var ps=typeof Object.is=="function"?Object.is:rre;function Bg(h,m){if(ps(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(!ce.call(m,P)||!ps(h[P],m[P]))return!1}return!0}function _L(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function wL(h,m){var _=_L(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}_=_L(_)}}function SL(h,m){return h&&m?h===m?!0:h&&h.nodeType===3?!1:m&&m.nodeType===3?SL(h,m.parentNode):"contains"in h?h.contains(m):h.compareDocumentPosition?!!(h.compareDocumentPosition(m)&16):!1:!1}function ML(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 J2(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 ire=Hl&&"documentMode"in document&&11>=document.documentMode,Ff=null,eE=null,Hg=null,tE=!1;function EL(h,m,_){var M=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;tE||Ff==null||Ff!==Ur(M)||(M=Ff,"selectionStart"in M&&J2(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}),Hg&&Bg(Hg,M)||(Hg=M,M=mv(eE,"onSelect"),0<M.length&&(m=new My("onSelect","select",null,m,_),h.push({event:m,listeners:M}),m.target=Ff)))}function qd(h,m){var _={};return _[h.toLowerCase()]=m.toLowerCase(),_["Webkit"+h]="webkit"+m,_["Moz"+h]="moz"+m,_}var Uf={animationend:qd("Animation","AnimationEnd"),animationiteration:qd("Animation","AnimationIteration"),animationstart:qd("Animation","AnimationStart"),transitionrun:qd("Transition","TransitionRun"),transitionstart:qd("Transition","TransitionStart"),transitioncancel:qd("Transition","TransitionCancel"),transitionend:qd("Transition","TransitionEnd")},nE={},AL={};Hl&&(AL=document.createElement("div").style,"AnimationEvent"in window||(delete Uf.animationend.animation,delete Uf.animationiteration.animation,delete Uf.animationstart.animation),"TransitionEvent"in window||delete Uf.transitionend.transition);function Kd(h){if(nE[h])return nE[h];if(!Uf[h])return h;var m=Uf[h],_;for(_ in m)if(m.hasOwnProperty(_)&&_ in AL)return nE[h]=m[_];return h}var NL=Kd("animationend"),TL=Kd("animationiteration"),CL=Kd("animationstart"),are=Kd("transitionrun"),sre=Kd("transitionstart"),ore=Kd("transitioncancel"),kL=Kd("transitionend"),PL=new Map,rE="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(" ");rE.push("scrollEnd");function Eo(h,m){PL.set(h,m),vt(m,[h])}var Ny=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)},Us=[],zf=0,iE=0;function Ty(){for(var h=zf,m=iE=zf=0;m<h;){var _=Us[m];Us[m++]=null;var M=Us[m];Us[m++]=null;var P=Us[m];Us[m++]=null;var I=Us[m];if(Us[m++]=null,M!==null&&P!==null){var Z=M.pending;Z===null?P.next=P:(P.next=Z.next,Z.next=P),M.pending=P}I!==0&&jL(_,P,I)}}function Cy(h,m,_,M){Us[zf++]=h,Us[zf++]=m,Us[zf++]=_,Us[zf++]=M,iE|=M,h.lanes|=M,h=h.alternate,h!==null&&(h.lanes|=M)}function aE(h,m,_,M){return Cy(h,m,_,M),ky(h)}function Xd(h,m){return Cy(h,null,null,m),ky(h)}function jL(h,m,_){h.lanes|=_;var M=h.alternate;M!==null&&(M.lanes|=_);for(var P=!1,I=h.return;I!==null;)I.childLanes|=_,M=I.alternate,M!==null&&(M.childLanes|=_),I.tag===22&&(h=I.stateNode,h===null||h._visibility&1||(P=!0)),h=I,I=I.return;return h.tag===3?(I=h.stateNode,P&&m!==null&&(P=31-Ke(_),h=I.hiddenUpdates,M=h[P],M===null?h[P]=[m]:M.push(m),m.lane=_|536870912),I):null}function ky(h){if(50<ux)throw ux=0,mA=null,Error(r(185));for(var m=h.return;m!==null;)h=m,m=h.return;return h.tag===3?h.stateNode:null}var Bf={};function lre(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 gs(h,m,_,M){return new lre(h,m,_,M)}function sE(h){return h=h.prototype,!(!h||!h.isReactComponent)}function $l(h,m){var _=h.alternate;return _===null?(_=gs(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 RL(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 Py(h,m,_,M,P,I){var Z=0;if(M=h,typeof h=="function")sE(h)&&(Z=1);else if(typeof h=="string")Z=fie(h,_,ie.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case k:return h=gs(31,_,m,P),h.elementType=k,h.lanes=I,h;case y:return Yd(_.children,P,I,m);case b:Z=8,P|=24;break;case v:return h=gs(12,_,m,P|2),h.elementType=v,h.lanes=I,h;case A:return h=gs(13,_,m,P),h.elementType=A,h.lanes=I,h;case C:return h=gs(19,_,m,P),h.elementType=C,h.lanes=I,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case w:Z=10;break e;case E:Z=9;break e;case N:Z=11;break e;case T:Z=14;break e;case L:Z=16,M=null;break e}Z=29,_=Error(r(130,h===null?"null":typeof h,"")),M=null}return m=gs(Z,_,m,P),m.elementType=h,m.type=M,m.lanes=I,m}function Yd(h,m,_,M){return h=gs(7,h,M,m),h.lanes=_,h}function oE(h,m,_){return h=gs(6,h,null,m),h.lanes=_,h}function DL(h){var m=gs(18,null,null,0);return m.stateNode=h,m}function lE(h,m,_){return m=gs(4,h.children!==null?h.children:[],h.key,m),m.lanes=_,m.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},m}var OL=new WeakMap;function zs(h,m){if(typeof h=="object"&&h!==null){var _=OL.get(h);return _!==void 0?_:(m={value:h,source:m,stack:Q(m)},OL.set(h,m),m)}return{value:h,source:m,stack:Q(m)}}var Hf=[],$f=0,jy=null,$g=0,Bs=[],Hs=0,ou=null,tl=1,nl="";function Vl(h,m){Hf[$f++]=$g,Hf[$f++]=jy,jy=h,$g=m}function LL(h,m,_){Bs[Hs++]=tl,Bs[Hs++]=nl,Bs[Hs++]=ou,ou=h;var M=tl;h=nl;var P=32-Ke(M)-1;M&=~(1<<P),_+=1;var I=32-Ke(m)+P;if(30<I){var Z=P-P%5;I=(M&(1<<Z)-1).toString(32),M>>=Z,P-=Z,tl=1<<32-Ke(m)+P|_<<P|M,nl=I+h}else tl=1<<I|_<<P|M,nl=h}function cE(h){h.return!==null&&(Vl(h,1),LL(h,1,0))}function uE(h){for(;h===jy;)jy=Hf[--$f],Hf[$f]=null,$g=Hf[--$f],Hf[$f]=null;for(;h===ou;)ou=Bs[--Hs],Bs[Hs]=null,nl=Bs[--Hs],Bs[Hs]=null,tl=Bs[--Hs],Bs[Hs]=null}function IL(h,m){Bs[Hs++]=tl,Bs[Hs++]=nl,Bs[Hs++]=ou,tl=m.id,nl=m.overflow,ou=h}var Qi=null,_r=null,jn=!1,lu=null,$s=!1,dE=Error(r(519));function cu(h){var m=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Vg(zs(m,h)),dE}function FL(h){var m=h.stateNode,_=h.type,M=h.memoizedProps;switch(m[Kt]=h,m[dn]=M,_){case"dialog":En("cancel",m),En("close",m);break;case"iframe":case"object":case"embed":En("load",m);break;case"video":case"audio":for(_=0;_<hx.length;_++)En(hx[_],m);break;case"source":En("error",m);break;case"img":case"image":case"link":En("error",m),En("load",m);break;case"details":En("toggle",m);break;case"input":En("invalid",m),qn(m,M.value,M.defaultValue,M.checked,M.defaultChecked,M.type,M.name,!0);break;case"select":En("invalid",m);break;case"textarea":En("invalid",m),Zi(m,M.value,M.defaultValue,M.children)}_=M.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||m.textContent===""+_||M.suppressHydrationWarning===!0||tF(m.textContent,_)?(M.popover!=null&&(En("beforetoggle",m),En("toggle",m)),M.onScroll!=null&&En("scroll",m),M.onScrollEnd!=null&&En("scrollend",m),M.onClick!=null&&(m.onclick=Bl),m=!0):m=!1,m||cu(h,!0)}function UL(h){for(Qi=h.return;Qi;)switch(Qi.tag){case 5:case 31:case 13:$s=!1;return;case 27:case 3:$s=!0;return;default:Qi=Qi.return}}function Vf(h){if(h!==Qi)return!1;if(!jn)return UL(h),jn=!0,!1;var m=h.tag,_;if((_=m!==3&&m!==27)&&((_=m===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||CA(h.type,h.memoizedProps)),_=!_),_&&_r&&cu(h),UL(h),m===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));_r=uF(h)}else if(m===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));_r=uF(h)}else m===27?(m=_r,Su(h.type)?(h=DA,DA=null,_r=h):_r=m):_r=Qi?Gs(h.stateNode.nextSibling):null;return!0}function Zd(){_r=Qi=null,jn=!1}function hE(){var h=lu;return h!==null&&(Ya===null?Ya=h:Ya.push.apply(Ya,h),lu=null),h}function Vg(h){lu===null?lu=[h]:lu.push(h)}var fE=F(null),Qd=null,Gl=null;function uu(h,m,_){ee(fE,m._currentValue),m._currentValue=_}function Wl(h){h._currentValue=fE.current,W(fE)}function mE(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 pE(h,m,_,M){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var I=P.dependencies;if(I!==null){var Z=P.child;I=I.firstContext;e:for(;I!==null;){var fe=I;I=P;for(var Te=0;Te<m.length;Te++)if(fe.context===m[Te]){I.lanes|=_,fe=I.alternate,fe!==null&&(fe.lanes|=_),mE(I.return,_,h),M||(Z=null);break e}I=fe.next}}else if(P.tag===18){if(Z=P.return,Z===null)throw Error(r(341));Z.lanes|=_,I=Z.alternate,I!==null&&(I.lanes|=_),mE(Z,_,h),Z=null}else Z=P.child;if(Z!==null)Z.return=P;else for(Z=P;Z!==null;){if(Z===h){Z=null;break}if(P=Z.sibling,P!==null){P.return=Z.return,Z=P;break}Z=Z.return}P=Z}}function Gf(h,m,_,M){h=null;for(var P=m,I=!1;P!==null;){if(!I){if((P.flags&524288)!==0)I=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var Z=P.alternate;if(Z===null)throw Error(r(387));if(Z=Z.memoizedProps,Z!==null){var fe=P.type;ps(P.pendingProps.value,Z.value)||(h!==null?h.push(fe):h=[fe])}}else if(P===ue.current){if(Z=P.alternate,Z===null)throw Error(r(387));Z.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(xx):h=[xx])}P=P.return}h!==null&&pE(m,h,_,M),m.flags|=262144}function Ry(h){for(h=h.firstContext;h!==null;){if(!ps(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Jd(h){Qd=h,Gl=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function Ji(h){return zL(Qd,h)}function Dy(h,m){return Qd===null&&Jd(h),zL(h,m)}function zL(h,m){var _=m._currentValue;if(m={context:m,memoizedValue:_,next:null},Gl===null){if(h===null)throw Error(r(308));Gl=m,h.dependencies={lanes:0,firstContext:m},h.flags|=524288}else Gl=Gl.next=m;return _}var cre=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 _()})}},ure=t.unstable_scheduleCallback,dre=t.unstable_NormalPriority,ri={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function gE(){return{controller:new cre,data:new Map,refCount:0}}function Gg(h){h.refCount--,h.refCount===0&&ure(dre,function(){h.controller.abort()})}var Wg=null,xE=0,Wf=0,qf=null;function hre(h,m){if(Wg===null){var _=Wg=[];xE=0,Wf=vA(),qf={status:"pending",value:void 0,then:function(M){_.push(M)}}}return xE++,m.then(BL,BL),m}function BL(){if(--xE===0&&Wg!==null){qf!==null&&(qf.status="fulfilled");var h=Wg;Wg=null,Wf=0,qf=null;for(var m=0;m<h.length;m++)(0,h[m])()}}function fre(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 HL=Y.S;Y.S=function(h,m){E5=j(),typeof m=="object"&&m!==null&&typeof m.then=="function"&&hre(h,m),HL!==null&&HL(h,m)};var eh=F(null);function bE(){var h=eh.current;return h!==null?h:mr.pooledCache}function Oy(h,m){m===null?ee(eh,eh.current):ee(eh,m.pool)}function $L(){var h=bE();return h===null?null:{parent:ri._currentValue,pool:h}}var Kf=Error(r(460)),yE=Error(r(474)),Ly=Error(r(542)),Iy={then:function(){}};function VL(h){return h=h.status,h==="fulfilled"||h==="rejected"}function GL(h,m,_){switch(_=h[_],_===void 0?h.push(m):_!==m&&(m.then(Bl,Bl),m=_),m.status){case"fulfilled":return m.value;case"rejected":throw h=m.reason,qL(h),h;default:if(typeof m.status=="string")m.then(Bl,Bl);else{if(h=mr,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,qL(h),h}throw nh=m,Kf}}function th(h){try{var m=h._init;return m(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(nh=_,Kf):_}}var nh=null;function WL(){if(nh===null)throw Error(r(459));var h=nh;return nh=null,h}function qL(h){if(h===Kf||h===Ly)throw Error(r(483))}var Xf=null,qg=0;function Fy(h){var m=qg;return qg+=1,Xf===null&&(Xf=[]),GL(Xf,h,m)}function Kg(h,m){m=m.props.ref,h.ref=m!==void 0?m:null}function Uy(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 KL(h){function m(Ve,Le){if(h){var et=Ve.deletions;et===null?(Ve.deletions=[Le],Ve.flags|=16):et.push(Le)}}function _(Ve,Le){if(!h)return null;for(;Le!==null;)m(Ve,Le),Le=Le.sibling;return null}function M(Ve){for(var Le=new Map;Ve!==null;)Ve.key!==null?Le.set(Ve.key,Ve):Le.set(Ve.index,Ve),Ve=Ve.sibling;return Le}function P(Ve,Le){return Ve=$l(Ve,Le),Ve.index=0,Ve.sibling=null,Ve}function I(Ve,Le,et){return Ve.index=et,h?(et=Ve.alternate,et!==null?(et=et.index,et<Le?(Ve.flags|=67108866,Le):et):(Ve.flags|=67108866,Le)):(Ve.flags|=1048576,Le)}function Z(Ve){return h&&Ve.alternate===null&&(Ve.flags|=67108866),Ve}function fe(Ve,Le,et,ht){return Le===null||Le.tag!==6?(Le=oE(et,Ve.mode,ht),Le.return=Ve,Le):(Le=P(Le,et),Le.return=Ve,Le)}function Te(Ve,Le,et,ht){var Wt=et.type;return Wt===y?lt(Ve,Le,et.props.children,ht,et.key):Le!==null&&(Le.elementType===Wt||typeof Wt=="object"&&Wt!==null&&Wt.$$typeof===L&&th(Wt)===Le.type)?(Le=P(Le,et.props),Kg(Le,et),Le.return=Ve,Le):(Le=Py(et.type,et.key,et.props,null,Ve.mode,ht),Kg(Le,et),Le.return=Ve,Le)}function nt(Ve,Le,et,ht){return Le===null||Le.tag!==4||Le.stateNode.containerInfo!==et.containerInfo||Le.stateNode.implementation!==et.implementation?(Le=lE(et,Ve.mode,ht),Le.return=Ve,Le):(Le=P(Le,et.children||[]),Le.return=Ve,Le)}function lt(Ve,Le,et,ht,Wt){return Le===null||Le.tag!==7?(Le=Yd(et,Ve.mode,ht,Wt),Le.return=Ve,Le):(Le=P(Le,et),Le.return=Ve,Le)}function pt(Ve,Le,et){if(typeof Le=="string"&&Le!==""||typeof Le=="number"||typeof Le=="bigint")return Le=oE(""+Le,Ve.mode,et),Le.return=Ve,Le;if(typeof Le=="object"&&Le!==null){switch(Le.$$typeof){case p:return et=Py(Le.type,Le.key,Le.props,null,Ve.mode,et),Kg(et,Le),et.return=Ve,et;case x:return Le=lE(Le,Ve.mode,et),Le.return=Ve,Le;case L:return Le=th(Le),pt(Ve,Le,et)}if(G(Le)||O(Le))return Le=Yd(Le,Ve.mode,et,null),Le.return=Ve,Le;if(typeof Le.then=="function")return pt(Ve,Fy(Le),et);if(Le.$$typeof===w)return pt(Ve,Dy(Ve,Le),et);Uy(Ve,Le)}return null}function it(Ve,Le,et,ht){var Wt=Le!==null?Le.key:null;if(typeof et=="string"&&et!==""||typeof et=="number"||typeof et=="bigint")return Wt!==null?null:fe(Ve,Le,""+et,ht);if(typeof et=="object"&&et!==null){switch(et.$$typeof){case p:return et.key===Wt?Te(Ve,Le,et,ht):null;case x:return et.key===Wt?nt(Ve,Le,et,ht):null;case L:return et=th(et),it(Ve,Le,et,ht)}if(G(et)||O(et))return Wt!==null?null:lt(Ve,Le,et,ht,null);if(typeof et.then=="function")return it(Ve,Le,Fy(et),ht);if(et.$$typeof===w)return it(Ve,Le,Dy(Ve,et),ht);Uy(Ve,et)}return null}function ot(Ve,Le,et,ht,Wt){if(typeof ht=="string"&&ht!==""||typeof ht=="number"||typeof ht=="bigint")return Ve=Ve.get(et)||null,fe(Le,Ve,""+ht,Wt);if(typeof ht=="object"&&ht!==null){switch(ht.$$typeof){case p:return Ve=Ve.get(ht.key===null?et:ht.key)||null,Te(Le,Ve,ht,Wt);case x:return Ve=Ve.get(ht.key===null?et:ht.key)||null,nt(Le,Ve,ht,Wt);case L:return ht=th(ht),ot(Ve,Le,et,ht,Wt)}if(G(ht)||O(ht))return Ve=Ve.get(et)||null,lt(Le,Ve,ht,Wt,null);if(typeof ht.then=="function")return ot(Ve,Le,et,Fy(ht),Wt);if(ht.$$typeof===w)return ot(Ve,Le,et,Dy(Le,ht),Wt);Uy(Le,ht)}return null}function Ft(Ve,Le,et,ht){for(var Wt=null,In=null,zt=Le,fn=Le=0,Pn=null;zt!==null&&fn<et.length;fn++){zt.index>fn?(Pn=zt,zt=null):Pn=zt.sibling;var Fn=it(Ve,zt,et[fn],ht);if(Fn===null){zt===null&&(zt=Pn);break}h&&zt&&Fn.alternate===null&&m(Ve,zt),Le=I(Fn,Le,fn),In===null?Wt=Fn:In.sibling=Fn,In=Fn,zt=Pn}if(fn===et.length)return _(Ve,zt),jn&&Vl(Ve,fn),Wt;if(zt===null){for(;fn<et.length;fn++)zt=pt(Ve,et[fn],ht),zt!==null&&(Le=I(zt,Le,fn),In===null?Wt=zt:In.sibling=zt,In=zt);return jn&&Vl(Ve,fn),Wt}for(zt=M(zt);fn<et.length;fn++)Pn=ot(zt,Ve,fn,et[fn],ht),Pn!==null&&(h&&Pn.alternate!==null&&zt.delete(Pn.key===null?fn:Pn.key),Le=I(Pn,Le,fn),In===null?Wt=Pn:In.sibling=Pn,In=Pn);return h&&zt.forEach(function(Tu){return m(Ve,Tu)}),jn&&Vl(Ve,fn),Wt}function Jt(Ve,Le,et,ht){if(et==null)throw Error(r(151));for(var Wt=null,In=null,zt=Le,fn=Le=0,Pn=null,Fn=et.next();zt!==null&&!Fn.done;fn++,Fn=et.next()){zt.index>fn?(Pn=zt,zt=null):Pn=zt.sibling;var Tu=it(Ve,zt,Fn.value,ht);if(Tu===null){zt===null&&(zt=Pn);break}h&&zt&&Tu.alternate===null&&m(Ve,zt),Le=I(Tu,Le,fn),In===null?Wt=Tu:In.sibling=Tu,In=Tu,zt=Pn}if(Fn.done)return _(Ve,zt),jn&&Vl(Ve,fn),Wt;if(zt===null){for(;!Fn.done;fn++,Fn=et.next())Fn=pt(Ve,Fn.value,ht),Fn!==null&&(Le=I(Fn,Le,fn),In===null?Wt=Fn:In.sibling=Fn,In=Fn);return jn&&Vl(Ve,fn),Wt}for(zt=M(zt);!Fn.done;fn++,Fn=et.next())Fn=ot(zt,Ve,fn,Fn.value,ht),Fn!==null&&(h&&Fn.alternate!==null&&zt.delete(Fn.key===null?fn:Fn.key),Le=I(Fn,Le,fn),In===null?Wt=Fn:In.sibling=Fn,In=Fn);return h&&zt.forEach(function(Mie){return m(Ve,Mie)}),jn&&Vl(Ve,fn),Wt}function ir(Ve,Le,et,ht){if(typeof et=="object"&&et!==null&&et.type===y&&et.key===null&&(et=et.props.children),typeof et=="object"&&et!==null){switch(et.$$typeof){case p:e:{for(var Wt=et.key;Le!==null;){if(Le.key===Wt){if(Wt=et.type,Wt===y){if(Le.tag===7){_(Ve,Le.sibling),ht=P(Le,et.props.children),ht.return=Ve,Ve=ht;break e}}else if(Le.elementType===Wt||typeof Wt=="object"&&Wt!==null&&Wt.$$typeof===L&&th(Wt)===Le.type){_(Ve,Le.sibling),ht=P(Le,et.props),Kg(ht,et),ht.return=Ve,Ve=ht;break e}_(Ve,Le);break}else m(Ve,Le);Le=Le.sibling}et.type===y?(ht=Yd(et.props.children,Ve.mode,ht,et.key),ht.return=Ve,Ve=ht):(ht=Py(et.type,et.key,et.props,null,Ve.mode,ht),Kg(ht,et),ht.return=Ve,Ve=ht)}return Z(Ve);case x:e:{for(Wt=et.key;Le!==null;){if(Le.key===Wt)if(Le.tag===4&&Le.stateNode.containerInfo===et.containerInfo&&Le.stateNode.implementation===et.implementation){_(Ve,Le.sibling),ht=P(Le,et.children||[]),ht.return=Ve,Ve=ht;break e}else{_(Ve,Le);break}else m(Ve,Le);Le=Le.sibling}ht=lE(et,Ve.mode,ht),ht.return=Ve,Ve=ht}return Z(Ve);case L:return et=th(et),ir(Ve,Le,et,ht)}if(G(et))return Ft(Ve,Le,et,ht);if(O(et)){if(Wt=O(et),typeof Wt!="function")throw Error(r(150));return et=Wt.call(et),Jt(Ve,Le,et,ht)}if(typeof et.then=="function")return ir(Ve,Le,Fy(et),ht);if(et.$$typeof===w)return ir(Ve,Le,Dy(Ve,et),ht);Uy(Ve,et)}return typeof et=="string"&&et!==""||typeof et=="number"||typeof et=="bigint"?(et=""+et,Le!==null&&Le.tag===6?(_(Ve,Le.sibling),ht=P(Le,et),ht.return=Ve,Ve=ht):(_(Ve,Le),ht=oE(et,Ve.mode,ht),ht.return=Ve,Ve=ht),Z(Ve)):_(Ve,Le)}return function(Ve,Le,et,ht){try{qg=0;var Wt=ir(Ve,Le,et,ht);return Xf=null,Wt}catch(zt){if(zt===Kf||zt===Ly)throw zt;var In=gs(29,zt,null,Ve.mode);return In.lanes=ht,In.return=Ve,In}finally{}}}var rh=KL(!0),XL=KL(!1),du=!1;function vE(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function _E(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 hu(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function fu(h,m,_){var M=h.updateQueue;if(M===null)return null;if(M=M.shared,(Hn&2)!==0){var P=M.pending;return P===null?m.next=m:(m.next=P.next,P.next=m),M.pending=m,m=ky(h),jL(h,null,_),m}return Cy(h,M,m,_),ky(h)}function Xg(h,m,_){if(m=m.updateQueue,m!==null&&(m=m.shared,(_&4194048)!==0)){var M=m.lanes;M&=h.pendingLanes,_|=M,m.lanes=_,Ln(h,_)}}function wE(h,m){var _=h.updateQueue,M=h.alternate;if(M!==null&&(M=M.updateQueue,_===M)){var P=null,I=null;if(_=_.firstBaseUpdate,_!==null){do{var Z={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};I===null?P=I=Z:I=I.next=Z,_=_.next}while(_!==null);I===null?P=I=m:I=I.next=m}else P=I=m;_={baseState:M.baseState,firstBaseUpdate:P,lastBaseUpdate:I,shared:M.shared,callbacks:M.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=m:h.next=m,_.lastBaseUpdate=m}var SE=!1;function Yg(){if(SE){var h=qf;if(h!==null)throw h}}function Zg(h,m,_,M){SE=!1;var P=h.updateQueue;du=!1;var I=P.firstBaseUpdate,Z=P.lastBaseUpdate,fe=P.shared.pending;if(fe!==null){P.shared.pending=null;var Te=fe,nt=Te.next;Te.next=null,Z===null?I=nt:Z.next=nt,Z=Te;var lt=h.alternate;lt!==null&&(lt=lt.updateQueue,fe=lt.lastBaseUpdate,fe!==Z&&(fe===null?lt.firstBaseUpdate=nt:fe.next=nt,lt.lastBaseUpdate=Te))}if(I!==null){var pt=P.baseState;Z=0,lt=nt=Te=null,fe=I;do{var it=fe.lane&-536870913,ot=it!==fe.lane;if(ot?(kn&it)===it:(M&it)===it){it!==0&&it===Wf&&(SE=!0),lt!==null&&(lt=lt.next={lane:0,tag:fe.tag,payload:fe.payload,callback:null,next:null});e:{var Ft=h,Jt=fe;it=m;var ir=_;switch(Jt.tag){case 1:if(Ft=Jt.payload,typeof Ft=="function"){pt=Ft.call(ir,pt,it);break e}pt=Ft;break e;case 3:Ft.flags=Ft.flags&-65537|128;case 0:if(Ft=Jt.payload,it=typeof Ft=="function"?Ft.call(ir,pt,it):Ft,it==null)break e;pt=f({},pt,it);break e;case 2:du=!0}}it=fe.callback,it!==null&&(h.flags|=64,ot&&(h.flags|=8192),ot=P.callbacks,ot===null?P.callbacks=[it]:ot.push(it))}else ot={lane:it,tag:fe.tag,payload:fe.payload,callback:fe.callback,next:null},lt===null?(nt=lt=ot,Te=pt):lt=lt.next=ot,Z|=it;if(fe=fe.next,fe===null){if(fe=P.shared.pending,fe===null)break;ot=fe,fe=ot.next,ot.next=null,P.lastBaseUpdate=ot,P.shared.pending=null}}while(!0);lt===null&&(Te=pt),P.baseState=Te,P.firstBaseUpdate=nt,P.lastBaseUpdate=lt,I===null&&(P.shared.lanes=0),bu|=Z,h.lanes=Z,h.memoizedState=pt}}function YL(h,m){if(typeof h!="function")throw Error(r(191,h));h.call(m)}function ZL(h,m){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)YL(_[h],m)}var Yf=F(null),zy=F(0);function QL(h,m){h=tc,ee(zy,h),ee(Yf,m),tc=h|m.baseLanes}function ME(){ee(zy,tc),ee(Yf,Yf.current)}function EE(){tc=zy.current,W(Yf),W(zy)}var xs=F(null),Vs=null;function mu(h){var m=h.alternate;ee(Zr,Zr.current&1),ee(xs,h),Vs===null&&(m===null||Yf.current!==null||m.memoizedState!==null)&&(Vs=h)}function AE(h){ee(Zr,Zr.current),ee(xs,h),Vs===null&&(Vs=h)}function JL(h){h.tag===22?(ee(Zr,Zr.current),ee(xs,h),Vs===null&&(Vs=h)):pu()}function pu(){ee(Zr,Zr.current),ee(xs,xs.current)}function bs(h){W(xs),Vs===h&&(Vs=null),W(Zr)}var Zr=F(0);function By(h){for(var m=h;m!==null;){if(m.tag===13){var _=m.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||jA(_)||RA(_)))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 ql=0,hn=null,nr=null,ii=null,Hy=!1,Zf=!1,ih=!1,$y=0,Qg=0,Qf=null,mre=0;function zr(){throw Error(r(321))}function NE(h,m){if(m===null)return!1;for(var _=0;_<m.length&&_<h.length;_++)if(!ps(h[_],m[_]))return!1;return!0}function TE(h,m,_,M,P,I){return ql=I,hn=m,m.memoizedState=null,m.updateQueue=null,m.lanes=0,Y.H=h===null||h.memoizedState===null?LI:$E,ih=!1,I=_(M,P),ih=!1,Zf&&(I=tI(m,_,M,P)),eI(h),I}function eI(h){Y.H=tx;var m=nr!==null&&nr.next!==null;if(ql=0,ii=nr=hn=null,Hy=!1,Qg=0,Qf=null,m)throw Error(r(300));h===null||ai||(h=h.dependencies,h!==null&&Ry(h)&&(ai=!0))}function tI(h,m,_,M){hn=h;var P=0;do{if(Zf&&(Qf=null),Qg=0,Zf=!1,25<=P)throw Error(r(301));if(P+=1,ii=nr=null,h.updateQueue!=null){var I=h.updateQueue;I.lastEffect=null,I.events=null,I.stores=null,I.memoCache!=null&&(I.memoCache.index=0)}Y.H=II,I=m(_,M)}while(Zf);return I}function pre(){var h=Y.H,m=h.useState()[0];return m=typeof m.then=="function"?Jg(m):m,h=h.useState()[0],(nr!==null?nr.memoizedState:null)!==h&&(hn.flags|=1024),m}function CE(){var h=$y!==0;return $y=0,h}function kE(h,m,_){m.updateQueue=h.updateQueue,m.flags&=-2053,h.lanes&=~_}function PE(h){if(Hy){for(h=h.memoizedState;h!==null;){var m=h.queue;m!==null&&(m.pending=null),h=h.next}Hy=!1}ql=0,ii=nr=hn=null,Zf=!1,Qg=$y=0,Qf=null}function ka(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ii===null?hn.memoizedState=ii=h:ii=ii.next=h,ii}function Qr(){if(nr===null){var h=hn.alternate;h=h!==null?h.memoizedState:null}else h=nr.next;var m=ii===null?hn.memoizedState:ii.next;if(m!==null)ii=m,nr=h;else{if(h===null)throw hn.alternate===null?Error(r(467)):Error(r(310));nr=h,h={memoizedState:nr.memoizedState,baseState:nr.baseState,baseQueue:nr.baseQueue,queue:nr.queue,next:null},ii===null?hn.memoizedState=ii=h:ii=ii.next=h}return ii}function Vy(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Jg(h){var m=Qg;return Qg+=1,Qf===null&&(Qf=[]),h=GL(Qf,h,m),m=hn,(ii===null?m.memoizedState:ii.next)===null&&(m=m.alternate,Y.H=m===null||m.memoizedState===null?LI:$E),h}function Gy(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return Jg(h);if(h.$$typeof===w)return Ji(h)}throw Error(r(438,String(h)))}function jE(h){var m=null,_=hn.updateQueue;if(_!==null&&(m=_.memoCache),m==null){var M=hn.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&&(_=Vy(),hn.updateQueue=_),_.memoCache=m,_=m.data[m.index],_===void 0)for(_=m.data[m.index]=Array(h),M=0;M<h;M++)_[M]=D;return m.index++,_}function Kl(h,m){return typeof m=="function"?m(h):m}function Wy(h){var m=Qr();return RE(m,nr,h)}function RE(h,m,_){var M=h.queue;if(M===null)throw Error(r(311));M.lastRenderedReducer=_;var P=h.baseQueue,I=M.pending;if(I!==null){if(P!==null){var Z=P.next;P.next=I.next,I.next=Z}m.baseQueue=P=I,M.pending=null}if(I=h.baseState,P===null)h.memoizedState=I;else{m=P.next;var fe=Z=null,Te=null,nt=m,lt=!1;do{var pt=nt.lane&-536870913;if(pt!==nt.lane?(kn&pt)===pt:(ql&pt)===pt){var it=nt.revertLane;if(it===0)Te!==null&&(Te=Te.next={lane:0,revertLane:0,gesture:null,action:nt.action,hasEagerState:nt.hasEagerState,eagerState:nt.eagerState,next:null}),pt===Wf&&(lt=!0);else if((ql&it)===it){nt=nt.next,it===Wf&&(lt=!0);continue}else pt={lane:0,revertLane:nt.revertLane,gesture:null,action:nt.action,hasEagerState:nt.hasEagerState,eagerState:nt.eagerState,next:null},Te===null?(fe=Te=pt,Z=I):Te=Te.next=pt,hn.lanes|=it,bu|=it;pt=nt.action,ih&&_(I,pt),I=nt.hasEagerState?nt.eagerState:_(I,pt)}else it={lane:pt,revertLane:nt.revertLane,gesture:nt.gesture,action:nt.action,hasEagerState:nt.hasEagerState,eagerState:nt.eagerState,next:null},Te===null?(fe=Te=it,Z=I):Te=Te.next=it,hn.lanes|=pt,bu|=pt;nt=nt.next}while(nt!==null&&nt!==m);if(Te===null?Z=I:Te.next=fe,!ps(I,h.memoizedState)&&(ai=!0,lt&&(_=qf,_!==null)))throw _;h.memoizedState=I,h.baseState=Z,h.baseQueue=Te,M.lastRenderedState=I}return P===null&&(M.lanes=0),[h.memoizedState,M.dispatch]}function DE(h){var m=Qr(),_=m.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var M=_.dispatch,P=_.pending,I=m.memoizedState;if(P!==null){_.pending=null;var Z=P=P.next;do I=h(I,Z.action),Z=Z.next;while(Z!==P);ps(I,m.memoizedState)||(ai=!0),m.memoizedState=I,m.baseQueue===null&&(m.baseState=I),_.lastRenderedState=I}return[I,M]}function nI(h,m,_){var M=hn,P=Qr(),I=jn;if(I){if(_===void 0)throw Error(r(407));_=_()}else _=m();var Z=!ps((nr||P).memoizedState,_);if(Z&&(P.memoizedState=_,ai=!0),P=P.queue,IE(aI.bind(null,M,P,h),[h]),P.getSnapshot!==m||Z||ii!==null&&ii.memoizedState.tag&1){if(M.flags|=2048,Jf(9,{destroy:void 0},iI.bind(null,M,P,_,m),null),mr===null)throw Error(r(349));I||(ql&127)!==0||rI(M,m,_)}return _}function rI(h,m,_){h.flags|=16384,h={getSnapshot:m,value:_},m=hn.updateQueue,m===null?(m=Vy(),hn.updateQueue=m,m.stores=[h]):(_=m.stores,_===null?m.stores=[h]:_.push(h))}function iI(h,m,_,M){m.value=_,m.getSnapshot=M,sI(m)&&oI(h)}function aI(h,m,_){return _(function(){sI(m)&&oI(h)})}function sI(h){var m=h.getSnapshot;h=h.value;try{var _=m();return!ps(h,_)}catch{return!0}}function oI(h){var m=Xd(h,2);m!==null&&Za(m,h,2)}function OE(h){var m=ka();if(typeof h=="function"){var _=h;if(h=_(),ih){Je(!0);try{_()}finally{Je(!1)}}}return m.memoizedState=m.baseState=h,m.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Kl,lastRenderedState:h},m}function lI(h,m,_,M){return h.baseState=_,RE(h,nr,typeof M=="function"?M:Kl)}function gre(h,m,_,M,P){if(Xy(h))throw Error(r(485));if(h=m.action,h!==null){var I={payload:P,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(Z){I.listeners.push(Z)}};Y.T!==null?_(!0):I.isTransition=!1,M(I),_=m.pending,_===null?(I.next=m.pending=I,cI(m,I)):(I.next=_.next,m.pending=_.next=I)}}function cI(h,m){var _=m.action,M=m.payload,P=h.state;if(m.isTransition){var I=Y.T,Z={};Y.T=Z;try{var fe=_(P,M),Te=Y.S;Te!==null&&Te(Z,fe),uI(h,m,fe)}catch(nt){LE(h,m,nt)}finally{I!==null&&Z.types!==null&&(I.types=Z.types),Y.T=I}}else try{I=_(P,M),uI(h,m,I)}catch(nt){LE(h,m,nt)}}function uI(h,m,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(M){dI(h,m,M)},function(M){return LE(h,m,M)}):dI(h,m,_)}function dI(h,m,_){m.status="fulfilled",m.value=_,hI(m),h.state=_,m=h.pending,m!==null&&(_=m.next,_===m?h.pending=null:(_=_.next,m.next=_,cI(h,_)))}function LE(h,m,_){var M=h.pending;if(h.pending=null,M!==null){M=M.next;do m.status="rejected",m.reason=_,hI(m),m=m.next;while(m!==M)}h.action=null}function hI(h){h=h.listeners;for(var m=0;m<h.length;m++)(0,h[m])()}function fI(h,m){return m}function mI(h,m){if(jn){var _=mr.formState;if(_!==null){e:{var M=hn;if(jn){if(_r){t:{for(var P=_r,I=$s;P.nodeType!==8;){if(!I){P=null;break t}if(P=Gs(P.nextSibling),P===null){P=null;break t}}I=P.data,P=I==="F!"||I==="F"?P:null}if(P){_r=Gs(P.nextSibling),M=P.data==="F!";break e}}cu(M)}M=!1}M&&(m=_[0])}}return _=ka(),_.memoizedState=_.baseState=m,M={pending:null,lanes:0,dispatch:null,lastRenderedReducer:fI,lastRenderedState:m},_.queue=M,_=RI.bind(null,hn,M),M.dispatch=_,M=OE(!1),I=HE.bind(null,hn,!1,M.queue),M=ka(),P={state:m,dispatch:null,action:h,pending:null},M.queue=P,_=gre.bind(null,hn,P,I,_),P.dispatch=_,M.memoizedState=h,[m,_,!1]}function pI(h){var m=Qr();return gI(m,nr,h)}function gI(h,m,_){if(m=RE(h,m,fI)[0],h=Wy(Kl)[0],typeof m=="object"&&m!==null&&typeof m.then=="function")try{var M=Jg(m)}catch(Z){throw Z===Kf?Ly:Z}else M=m;m=Qr();var P=m.queue,I=P.dispatch;return _!==m.memoizedState&&(hn.flags|=2048,Jf(9,{destroy:void 0},xre.bind(null,P,_),null)),[M,I,h]}function xre(h,m){h.action=m}function xI(h){var m=Qr(),_=nr;if(_!==null)return gI(m,_,h);Qr(),m=m.memoizedState,_=Qr();var M=_.queue.dispatch;return _.memoizedState=h,[m,M,!1]}function Jf(h,m,_,M){return h={tag:h,create:_,deps:M,inst:m,next:null},m=hn.updateQueue,m===null&&(m=Vy(),hn.updateQueue=m),_=m.lastEffect,_===null?m.lastEffect=h.next=h:(M=_.next,_.next=h,h.next=M,m.lastEffect=h),h}function bI(){return Qr().memoizedState}function qy(h,m,_,M){var P=ka();hn.flags|=h,P.memoizedState=Jf(1|m,{destroy:void 0},_,M===void 0?null:M)}function Ky(h,m,_,M){var P=Qr();M=M===void 0?null:M;var I=P.memoizedState.inst;nr!==null&&M!==null&&NE(M,nr.memoizedState.deps)?P.memoizedState=Jf(m,I,_,M):(hn.flags|=h,P.memoizedState=Jf(1|m,I,_,M))}function yI(h,m){qy(8390656,8,h,m)}function IE(h,m){Ky(2048,8,h,m)}function bre(h){hn.flags|=4;var m=hn.updateQueue;if(m===null)m=Vy(),hn.updateQueue=m,m.events=[h];else{var _=m.events;_===null?m.events=[h]:_.push(h)}}function vI(h){var m=Qr().memoizedState;return bre({ref:m,nextImpl:h}),function(){if((Hn&2)!==0)throw Error(r(440));return m.impl.apply(void 0,arguments)}}function _I(h,m){return Ky(4,2,h,m)}function wI(h,m){return Ky(4,4,h,m)}function SI(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 MI(h,m,_){_=_!=null?_.concat([h]):null,Ky(4,4,SI.bind(null,m,h),_)}function FE(){}function EI(h,m){var _=Qr();m=m===void 0?null:m;var M=_.memoizedState;return m!==null&&NE(m,M[1])?M[0]:(_.memoizedState=[h,m],h)}function AI(h,m){var _=Qr();m=m===void 0?null:m;var M=_.memoizedState;if(m!==null&&NE(m,M[1]))return M[0];if(M=h(),ih){Je(!0);try{h()}finally{Je(!1)}}return _.memoizedState=[M,m],M}function UE(h,m,_){return _===void 0||(ql&1073741824)!==0&&(kn&261930)===0?h.memoizedState=m:(h.memoizedState=_,h=N5(),hn.lanes|=h,bu|=h,_)}function NI(h,m,_,M){return ps(_,m)?_:Yf.current!==null?(h=UE(h,_,M),ps(h,m)||(ai=!0),h):(ql&42)===0||(ql&1073741824)!==0&&(kn&261930)===0?(ai=!0,h.memoizedState=_):(h=N5(),hn.lanes|=h,bu|=h,m)}function TI(h,m,_,M,P){var I=V.p;V.p=I!==0&&8>I?I:8;var Z=Y.T,fe={};Y.T=fe,HE(h,!1,m,_);try{var Te=P(),nt=Y.S;if(nt!==null&&nt(fe,Te),Te!==null&&typeof Te=="object"&&typeof Te.then=="function"){var lt=fre(Te,M);ex(h,m,lt,_s(h))}else ex(h,m,M,_s(h))}catch(pt){ex(h,m,{then:function(){},status:"rejected",reason:pt},_s())}finally{V.p=I,Z!==null&&fe.types!==null&&(Z.types=fe.types),Y.T=Z}}function yre(){}function zE(h,m,_,M){if(h.tag!==5)throw Error(r(476));var P=CI(h).queue;TI(h,P,m,K,_===null?yre:function(){return kI(h),_(M)})}function CI(h){var m=h.memoizedState;if(m!==null)return m;m={memoizedState:K,baseState:K,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Kl,lastRenderedState:K},next:null};var _={};return m.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Kl,lastRenderedState:_},next:null},h.memoizedState=m,h=h.alternate,h!==null&&(h.memoizedState=m),m}function kI(h){var m=CI(h);m.next===null&&(m=h.alternate.memoizedState),ex(h,m.next.queue,{},_s())}function BE(){return Ji(xx)}function PI(){return Qr().memoizedState}function jI(){return Qr().memoizedState}function vre(h){for(var m=h.return;m!==null;){switch(m.tag){case 24:case 3:var _=_s();h=hu(_);var M=fu(m,h,_);M!==null&&(Za(M,m,_),Xg(M,m,_)),m={cache:gE()},h.payload=m;return}m=m.return}}function _re(h,m,_){var M=_s();_={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Xy(h)?DI(m,_):(_=aE(h,m,_,M),_!==null&&(Za(_,h,M),OI(_,m,M)))}function RI(h,m,_){var M=_s();ex(h,m,_,M)}function ex(h,m,_,M){var P={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Xy(h))DI(m,P);else{var I=h.alternate;if(h.lanes===0&&(I===null||I.lanes===0)&&(I=m.lastRenderedReducer,I!==null))try{var Z=m.lastRenderedState,fe=I(Z,_);if(P.hasEagerState=!0,P.eagerState=fe,ps(fe,Z))return Cy(h,m,P,0),mr===null&&Ty(),!1}catch{}finally{}if(_=aE(h,m,P,M),_!==null)return Za(_,h,M),OI(_,m,M),!0}return!1}function HE(h,m,_,M){if(M={lane:2,revertLane:vA(),gesture:null,action:M,hasEagerState:!1,eagerState:null,next:null},Xy(h)){if(m)throw Error(r(479))}else m=aE(h,_,M,2),m!==null&&Za(m,h,2)}function Xy(h){var m=h.alternate;return h===hn||m!==null&&m===hn}function DI(h,m){Zf=Hy=!0;var _=h.pending;_===null?m.next=m:(m.next=_.next,_.next=m),h.pending=m}function OI(h,m,_){if((_&4194048)!==0){var M=m.lanes;M&=h.pendingLanes,_|=M,m.lanes=_,Ln(h,_)}}var tx={readContext:Ji,use:Gy,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};tx.useEffectEvent=zr;var LI={readContext:Ji,use:Gy,useCallback:function(h,m){return ka().memoizedState=[h,m===void 0?null:m],h},useContext:Ji,useEffect:yI,useImperativeHandle:function(h,m,_){_=_!=null?_.concat([h]):null,qy(4194308,4,SI.bind(null,m,h),_)},useLayoutEffect:function(h,m){return qy(4194308,4,h,m)},useInsertionEffect:function(h,m){qy(4,2,h,m)},useMemo:function(h,m){var _=ka();m=m===void 0?null:m;var M=h();if(ih){Je(!0);try{h()}finally{Je(!1)}}return _.memoizedState=[M,m],M},useReducer:function(h,m,_){var M=ka();if(_!==void 0){var P=_(m);if(ih){Je(!0);try{_(m)}finally{Je(!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=_re.bind(null,hn,h),[M.memoizedState,h]},useRef:function(h){var m=ka();return h={current:h},m.memoizedState=h},useState:function(h){h=OE(h);var m=h.queue,_=RI.bind(null,hn,m);return m.dispatch=_,[h.memoizedState,_]},useDebugValue:FE,useDeferredValue:function(h,m){var _=ka();return UE(_,h,m)},useTransition:function(){var h=OE(!1);return h=TI.bind(null,hn,h.queue,!0,!1),ka().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,m,_){var M=hn,P=ka();if(jn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=m(),mr===null)throw Error(r(349));(kn&127)!==0||rI(M,m,_)}P.memoizedState=_;var I={value:_,getSnapshot:m};return P.queue=I,yI(aI.bind(null,M,I,h),[h]),M.flags|=2048,Jf(9,{destroy:void 0},iI.bind(null,M,I,_,m),null),_},useId:function(){var h=ka(),m=mr.identifierPrefix;if(jn){var _=nl,M=tl;_=(M&~(1<<32-Ke(M)-1)).toString(32)+_,m="_"+m+"R_"+_,_=$y++,0<_&&(m+="H"+_.toString(32)),m+="_"}else _=mre++,m="_"+m+"r_"+_.toString(32)+"_";return h.memoizedState=m},useHostTransitionStatus:BE,useFormState:mI,useActionState:mI,useOptimistic:function(h){var m=ka();m.memoizedState=m.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return m.queue=_,m=HE.bind(null,hn,!0,_),_.dispatch=m,[h,m]},useMemoCache:jE,useCacheRefresh:function(){return ka().memoizedState=vre.bind(null,hn)},useEffectEvent:function(h){var m=ka(),_={impl:h};return m.memoizedState=_,function(){if((Hn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},$E={readContext:Ji,use:Gy,useCallback:EI,useContext:Ji,useEffect:IE,useImperativeHandle:MI,useInsertionEffect:_I,useLayoutEffect:wI,useMemo:AI,useReducer:Wy,useRef:bI,useState:function(){return Wy(Kl)},useDebugValue:FE,useDeferredValue:function(h,m){var _=Qr();return NI(_,nr.memoizedState,h,m)},useTransition:function(){var h=Wy(Kl)[0],m=Qr().memoizedState;return[typeof h=="boolean"?h:Jg(h),m]},useSyncExternalStore:nI,useId:PI,useHostTransitionStatus:BE,useFormState:pI,useActionState:pI,useOptimistic:function(h,m){var _=Qr();return lI(_,nr,h,m)},useMemoCache:jE,useCacheRefresh:jI};$E.useEffectEvent=vI;var II={readContext:Ji,use:Gy,useCallback:EI,useContext:Ji,useEffect:IE,useImperativeHandle:MI,useInsertionEffect:_I,useLayoutEffect:wI,useMemo:AI,useReducer:DE,useRef:bI,useState:function(){return DE(Kl)},useDebugValue:FE,useDeferredValue:function(h,m){var _=Qr();return nr===null?UE(_,h,m):NI(_,nr.memoizedState,h,m)},useTransition:function(){var h=DE(Kl)[0],m=Qr().memoizedState;return[typeof h=="boolean"?h:Jg(h),m]},useSyncExternalStore:nI,useId:PI,useHostTransitionStatus:BE,useFormState:xI,useActionState:xI,useOptimistic:function(h,m){var _=Qr();return nr!==null?lI(_,nr,h,m):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:jE,useCacheRefresh:jI};II.useEffectEvent=vI;function VE(h,m,_,M){m=h.memoizedState,_=_(M,m),_=_==null?m:f({},m,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var GE={enqueueSetState:function(h,m,_){h=h._reactInternals;var M=_s(),P=hu(M);P.payload=m,_!=null&&(P.callback=_),m=fu(h,P,M),m!==null&&(Za(m,h,M),Xg(m,h,M))},enqueueReplaceState:function(h,m,_){h=h._reactInternals;var M=_s(),P=hu(M);P.tag=1,P.payload=m,_!=null&&(P.callback=_),m=fu(h,P,M),m!==null&&(Za(m,h,M),Xg(m,h,M))},enqueueForceUpdate:function(h,m){h=h._reactInternals;var _=_s(),M=hu(_);M.tag=2,m!=null&&(M.callback=m),m=fu(h,M,_),m!==null&&(Za(m,h,_),Xg(m,h,_))}};function FI(h,m,_,M,P,I,Z){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(M,I,Z):m.prototype&&m.prototype.isPureReactComponent?!Bg(_,M)||!Bg(P,I):!0}function UI(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&&GE.enqueueReplaceState(m,m.state,null)}function ah(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 zI(h){Ny(h)}function BI(h){console.error(h)}function HI(h){Ny(h)}function Yy(h,m){try{var _=h.onUncaughtError;_(m.value,{componentStack:m.stack})}catch(M){setTimeout(function(){throw M})}}function $I(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 WE(h,m,_){return _=hu(_),_.tag=3,_.payload={element:null},_.callback=function(){Yy(h,m)},_}function VI(h){return h=hu(h),h.tag=3,h}function GI(h,m,_,M){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var I=M.value;h.payload=function(){return P(I)},h.callback=function(){$I(m,_,M)}}var Z=_.stateNode;Z!==null&&typeof Z.componentDidCatch=="function"&&(h.callback=function(){$I(m,_,M),typeof P!="function"&&(yu===null?yu=new Set([this]):yu.add(this));var fe=M.stack;this.componentDidCatch(M.value,{componentStack:fe!==null?fe:""})})}function wre(h,m,_,M,P){if(_.flags|=32768,M!==null&&typeof M=="object"&&typeof M.then=="function"){if(m=_.alternate,m!==null&&Gf(m,_,P,!0),_=xs.current,_!==null){switch(_.tag){case 31:case 13:return Vs===null?lv():_.alternate===null&&Br===0&&(Br=3),_.flags&=-257,_.flags|=65536,_.lanes=P,M===Iy?_.flags|=16384:(m=_.updateQueue,m===null?_.updateQueue=new Set([M]):m.add(M),xA(h,M,P)),!1;case 22:return _.flags|=65536,M===Iy?_.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)),xA(h,M,P)),!1}throw Error(r(435,_.tag))}return xA(h,M,P),lv(),!1}if(jn)return m=xs.current,m!==null?((m.flags&65536)===0&&(m.flags|=256),m.flags|=65536,m.lanes=P,M!==dE&&(h=Error(r(422),{cause:M}),Vg(zs(h,_)))):(M!==dE&&(m=Error(r(423),{cause:M}),Vg(zs(m,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,M=zs(M,_),P=WE(h.stateNode,M,P),wE(h,P),Br!==4&&(Br=2)),!1;var I=Error(r(520),{cause:M});if(I=zs(I,_),cx===null?cx=[I]:cx.push(I),Br!==4&&(Br=2),m===null)return!0;M=zs(M,_),_=m;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=WE(_.stateNode,M,h),wE(_,h),!1;case 1:if(m=_.type,I=_.stateNode,(_.flags&128)===0&&(typeof m.getDerivedStateFromError=="function"||I!==null&&typeof I.componentDidCatch=="function"&&(yu===null||!yu.has(I))))return _.flags|=65536,P&=-P,_.lanes|=P,P=VI(P),GI(P,h,_,M),wE(_,P),!1}_=_.return}while(_!==null);return!1}var qE=Error(r(461)),ai=!1;function ea(h,m,_,M){m.child=h===null?XL(m,null,_,M):rh(m,h.child,_,M)}function WI(h,m,_,M,P){_=_.render;var I=m.ref;if("ref"in M){var Z={};for(var fe in M)fe!=="ref"&&(Z[fe]=M[fe])}else Z=M;return Jd(m),M=TE(h,m,_,Z,I,P),fe=CE(),h!==null&&!ai?(kE(h,m,P),Xl(h,m,P)):(jn&&fe&&cE(m),m.flags|=1,ea(h,m,M,P),m.child)}function qI(h,m,_,M,P){if(h===null){var I=_.type;return typeof I=="function"&&!sE(I)&&I.defaultProps===void 0&&_.compare===null?(m.tag=15,m.type=I,KI(h,m,I,M,P)):(h=Py(_.type,null,M,m,m.mode,P),h.ref=m.ref,h.return=m,m.child=h)}if(I=h.child,!tA(h,P)){var Z=I.memoizedProps;if(_=_.compare,_=_!==null?_:Bg,_(Z,M)&&h.ref===m.ref)return Xl(h,m,P)}return m.flags|=1,h=$l(I,M),h.ref=m.ref,h.return=m,m.child=h}function KI(h,m,_,M,P){if(h!==null){var I=h.memoizedProps;if(Bg(I,M)&&h.ref===m.ref)if(ai=!1,m.pendingProps=M=I,tA(h,P))(h.flags&131072)!==0&&(ai=!0);else return m.lanes=h.lanes,Xl(h,m,P)}return KE(h,m,_,M,P)}function XI(h,m,_,M){var P=M.children,I=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(I=I!==null?I.baseLanes|_:_,h!==null){for(M=m.child=h.child,P=0;M!==null;)P=P|M.lanes|M.childLanes,M=M.sibling;M=P&~I}else M=0,m.child=null;return YI(h,m,I,_,M)}if((_&536870912)!==0)m.memoizedState={baseLanes:0,cachePool:null},h!==null&&Oy(m,I!==null?I.cachePool:null),I!==null?QL(m,I):ME(),JL(m);else return M=m.lanes=536870912,YI(h,m,I!==null?I.baseLanes|_:_,_,M)}else I!==null?(Oy(m,I.cachePool),QL(m,I),pu(),m.memoizedState=null):(h!==null&&Oy(m,null),ME(),pu());return ea(h,m,P,_),m.child}function nx(h,m){return h!==null&&h.tag===22||m.stateNode!==null||(m.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),m.sibling}function YI(h,m,_,M,P){var I=bE();return I=I===null?null:{parent:ri._currentValue,pool:I},m.memoizedState={baseLanes:_,cachePool:I},h!==null&&Oy(m,null),ME(),JL(m),h!==null&&Gf(h,m,M,!0),m.childLanes=P,null}function Zy(h,m){return m=Jy({mode:m.mode,children:m.children},h.mode),m.ref=h.ref,h.child=m,m.return=h,m}function ZI(h,m,_){return rh(m,h.child,null,_),h=Zy(m,m.pendingProps),h.flags|=2,bs(m),m.memoizedState=null,h}function Sre(h,m,_){var M=m.pendingProps,P=(m.flags&128)!==0;if(m.flags&=-129,h===null){if(jn){if(M.mode==="hidden")return h=Zy(m,M),m.lanes=536870912,nx(null,h);if(AE(m),(h=_r)?(h=cF(h,$s),h=h!==null&&h.data==="&"?h:null,h!==null&&(m.memoizedState={dehydrated:h,treeContext:ou!==null?{id:tl,overflow:nl}:null,retryLane:536870912,hydrationErrors:null},_=DL(h),_.return=m,m.child=_,Qi=m,_r=null)):h=null,h===null)throw cu(m);return m.lanes=536870912,null}return Zy(m,M)}var I=h.memoizedState;if(I!==null){var Z=I.dehydrated;if(AE(m),P)if(m.flags&256)m.flags&=-257,m=ZI(h,m,_);else if(m.memoizedState!==null)m.child=h.child,m.flags|=128,m=null;else throw Error(r(558));else if(ai||Gf(h,m,_,!1),P=(_&h.childLanes)!==0,ai||P){if(M=mr,M!==null&&(Z=Vn(M,_),Z!==0&&Z!==I.retryLane))throw I.retryLane=Z,Xd(h,Z),Za(M,h,Z),qE;lv(),m=ZI(h,m,_)}else h=I.treeContext,_r=Gs(Z.nextSibling),Qi=m,jn=!0,lu=null,$s=!1,h!==null&&IL(m,h),m=Zy(m,M),m.flags|=4096;return m}return h=$l(h.child,{mode:M.mode,children:M.children}),h.ref=m.ref,m.child=h,h.return=m,h}function Qy(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 KE(h,m,_,M,P){return Jd(m),_=TE(h,m,_,M,void 0,P),M=CE(),h!==null&&!ai?(kE(h,m,P),Xl(h,m,P)):(jn&&M&&cE(m),m.flags|=1,ea(h,m,_,P),m.child)}function QI(h,m,_,M,P,I){return Jd(m),m.updateQueue=null,_=tI(m,M,_,P),eI(h),M=CE(),h!==null&&!ai?(kE(h,m,I),Xl(h,m,I)):(jn&&M&&cE(m),m.flags|=1,ea(h,m,_,I),m.child)}function JI(h,m,_,M,P){if(Jd(m),m.stateNode===null){var I=Bf,Z=_.contextType;typeof Z=="object"&&Z!==null&&(I=Ji(Z)),I=new _(M,I),m.memoizedState=I.state!==null&&I.state!==void 0?I.state:null,I.updater=GE,m.stateNode=I,I._reactInternals=m,I=m.stateNode,I.props=M,I.state=m.memoizedState,I.refs={},vE(m),Z=_.contextType,I.context=typeof Z=="object"&&Z!==null?Ji(Z):Bf,I.state=m.memoizedState,Z=_.getDerivedStateFromProps,typeof Z=="function"&&(VE(m,_,Z,M),I.state=m.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof I.getSnapshotBeforeUpdate=="function"||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(Z=I.state,typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount(),Z!==I.state&&GE.enqueueReplaceState(I,I.state,null),Zg(m,M,I,P),Yg(),I.state=m.memoizedState),typeof I.componentDidMount=="function"&&(m.flags|=4194308),M=!0}else if(h===null){I=m.stateNode;var fe=m.memoizedProps,Te=ah(_,fe);I.props=Te;var nt=I.context,lt=_.contextType;Z=Bf,typeof lt=="object"&&lt!==null&&(Z=Ji(lt));var pt=_.getDerivedStateFromProps;lt=typeof pt=="function"||typeof I.getSnapshotBeforeUpdate=="function",fe=m.pendingProps!==fe,lt||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(fe||nt!==Z)&&UI(m,I,M,Z),du=!1;var it=m.memoizedState;I.state=it,Zg(m,M,I,P),Yg(),nt=m.memoizedState,fe||it!==nt||du?(typeof pt=="function"&&(VE(m,_,pt,M),nt=m.memoizedState),(Te=du||FI(m,_,Te,M,it,nt,Z))?(lt||typeof I.UNSAFE_componentWillMount!="function"&&typeof I.componentWillMount!="function"||(typeof I.componentWillMount=="function"&&I.componentWillMount(),typeof I.UNSAFE_componentWillMount=="function"&&I.UNSAFE_componentWillMount()),typeof I.componentDidMount=="function"&&(m.flags|=4194308)):(typeof I.componentDidMount=="function"&&(m.flags|=4194308),m.memoizedProps=M,m.memoizedState=nt),I.props=M,I.state=nt,I.context=Z,M=Te):(typeof I.componentDidMount=="function"&&(m.flags|=4194308),M=!1)}else{I=m.stateNode,_E(h,m),Z=m.memoizedProps,lt=ah(_,Z),I.props=lt,pt=m.pendingProps,it=I.context,nt=_.contextType,Te=Bf,typeof nt=="object"&&nt!==null&&(Te=Ji(nt)),fe=_.getDerivedStateFromProps,(nt=typeof fe=="function"||typeof I.getSnapshotBeforeUpdate=="function")||typeof I.UNSAFE_componentWillReceiveProps!="function"&&typeof I.componentWillReceiveProps!="function"||(Z!==pt||it!==Te)&&UI(m,I,M,Te),du=!1,it=m.memoizedState,I.state=it,Zg(m,M,I,P),Yg();var ot=m.memoizedState;Z!==pt||it!==ot||du||h!==null&&h.dependencies!==null&&Ry(h.dependencies)?(typeof fe=="function"&&(VE(m,_,fe,M),ot=m.memoizedState),(lt=du||FI(m,_,lt,M,it,ot,Te)||h!==null&&h.dependencies!==null&&Ry(h.dependencies))?(nt||typeof I.UNSAFE_componentWillUpdate!="function"&&typeof I.componentWillUpdate!="function"||(typeof I.componentWillUpdate=="function"&&I.componentWillUpdate(M,ot,Te),typeof I.UNSAFE_componentWillUpdate=="function"&&I.UNSAFE_componentWillUpdate(M,ot,Te)),typeof I.componentDidUpdate=="function"&&(m.flags|=4),typeof I.getSnapshotBeforeUpdate=="function"&&(m.flags|=1024)):(typeof I.componentDidUpdate!="function"||Z===h.memoizedProps&&it===h.memoizedState||(m.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||Z===h.memoizedProps&&it===h.memoizedState||(m.flags|=1024),m.memoizedProps=M,m.memoizedState=ot),I.props=M,I.state=ot,I.context=Te,M=lt):(typeof I.componentDidUpdate!="function"||Z===h.memoizedProps&&it===h.memoizedState||(m.flags|=4),typeof I.getSnapshotBeforeUpdate!="function"||Z===h.memoizedProps&&it===h.memoizedState||(m.flags|=1024),M=!1)}return I=M,Qy(h,m),M=(m.flags&128)!==0,I||M?(I=m.stateNode,_=M&&typeof _.getDerivedStateFromError!="function"?null:I.render(),m.flags|=1,h!==null&&M?(m.child=rh(m,h.child,null,P),m.child=rh(m,null,_,P)):ea(h,m,_,P),m.memoizedState=I.state,h=m.child):h=Xl(h,m,P),h}function e5(h,m,_,M){return Zd(),m.flags|=256,ea(h,m,_,M),m.child}var XE={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function YE(h){return{baseLanes:h,cachePool:$L()}}function ZE(h,m,_){return h=h!==null?h.childLanes&~_:0,m&&(h|=vs),h}function t5(h,m,_){var M=m.pendingProps,P=!1,I=(m.flags&128)!==0,Z;if((Z=I)||(Z=h!==null&&h.memoizedState===null?!1:(Zr.current&2)!==0),Z&&(P=!0,m.flags&=-129),Z=(m.flags&32)!==0,m.flags&=-33,h===null){if(jn){if(P?mu(m):pu(),(h=_r)?(h=cF(h,$s),h=h!==null&&h.data!=="&"?h:null,h!==null&&(m.memoizedState={dehydrated:h,treeContext:ou!==null?{id:tl,overflow:nl}:null,retryLane:536870912,hydrationErrors:null},_=DL(h),_.return=m,m.child=_,Qi=m,_r=null)):h=null,h===null)throw cu(m);return RA(h)?m.lanes=32:m.lanes=536870912,null}var fe=M.children;return M=M.fallback,P?(pu(),P=m.mode,fe=Jy({mode:"hidden",children:fe},P),M=Yd(M,P,_,null),fe.return=m,M.return=m,fe.sibling=M,m.child=fe,M=m.child,M.memoizedState=YE(_),M.childLanes=ZE(h,Z,_),m.memoizedState=XE,nx(null,M)):(mu(m),QE(m,fe))}var Te=h.memoizedState;if(Te!==null&&(fe=Te.dehydrated,fe!==null)){if(I)m.flags&256?(mu(m),m.flags&=-257,m=JE(h,m,_)):m.memoizedState!==null?(pu(),m.child=h.child,m.flags|=128,m=null):(pu(),fe=M.fallback,P=m.mode,M=Jy({mode:"visible",children:M.children},P),fe=Yd(fe,P,_,null),fe.flags|=2,M.return=m,fe.return=m,M.sibling=fe,m.child=M,rh(m,h.child,null,_),M=m.child,M.memoizedState=YE(_),M.childLanes=ZE(h,Z,_),m.memoizedState=XE,m=nx(null,M));else if(mu(m),RA(fe)){if(Z=fe.nextSibling&&fe.nextSibling.dataset,Z)var nt=Z.dgst;Z=nt,M=Error(r(419)),M.stack="",M.digest=Z,Vg({value:M,source:null,stack:null}),m=JE(h,m,_)}else if(ai||Gf(h,m,_,!1),Z=(_&h.childLanes)!==0,ai||Z){if(Z=mr,Z!==null&&(M=Vn(Z,_),M!==0&&M!==Te.retryLane))throw Te.retryLane=M,Xd(h,M),Za(Z,h,M),qE;jA(fe)||lv(),m=JE(h,m,_)}else jA(fe)?(m.flags|=192,m.child=h.child,m=null):(h=Te.treeContext,_r=Gs(fe.nextSibling),Qi=m,jn=!0,lu=null,$s=!1,h!==null&&IL(m,h),m=QE(m,M.children),m.flags|=4096);return m}return P?(pu(),fe=M.fallback,P=m.mode,Te=h.child,nt=Te.sibling,M=$l(Te,{mode:"hidden",children:M.children}),M.subtreeFlags=Te.subtreeFlags&65011712,nt!==null?fe=$l(nt,fe):(fe=Yd(fe,P,_,null),fe.flags|=2),fe.return=m,M.return=m,M.sibling=fe,m.child=M,nx(null,M),M=m.child,fe=h.child.memoizedState,fe===null?fe=YE(_):(P=fe.cachePool,P!==null?(Te=ri._currentValue,P=P.parent!==Te?{parent:Te,pool:Te}:P):P=$L(),fe={baseLanes:fe.baseLanes|_,cachePool:P}),M.memoizedState=fe,M.childLanes=ZE(h,Z,_),m.memoizedState=XE,nx(h.child,M)):(mu(m),_=h.child,h=_.sibling,_=$l(_,{mode:"visible",children:M.children}),_.return=m,_.sibling=null,h!==null&&(Z=m.deletions,Z===null?(m.deletions=[h],m.flags|=16):Z.push(h)),m.child=_,m.memoizedState=null,_)}function QE(h,m){return m=Jy({mode:"visible",children:m},h.mode),m.return=h,h.child=m}function Jy(h,m){return h=gs(22,h,null,m),h.lanes=0,h}function JE(h,m,_){return rh(m,h.child,null,_),h=QE(m,m.pendingProps.children),h.flags|=2,m.memoizedState=null,h}function n5(h,m,_){h.lanes|=m;var M=h.alternate;M!==null&&(M.lanes|=m),mE(h.return,m,_)}function eA(h,m,_,M,P,I){var Z=h.memoizedState;Z===null?h.memoizedState={isBackwards:m,rendering:null,renderingStartTime:0,last:M,tail:_,tailMode:P,treeForkCount:I}:(Z.isBackwards=m,Z.rendering=null,Z.renderingStartTime=0,Z.last=M,Z.tail=_,Z.tailMode=P,Z.treeForkCount=I)}function r5(h,m,_){var M=m.pendingProps,P=M.revealOrder,I=M.tail;M=M.children;var Z=Zr.current,fe=(Z&2)!==0;if(fe?(Z=Z&1|2,m.flags|=128):Z&=1,ee(Zr,Z),ea(h,m,M,_),M=jn?$g:0,!fe&&h!==null&&(h.flags&128)!==0)e:for(h=m.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&n5(h,_,m);else if(h.tag===19)n5(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&&By(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=m.child,m.child=null):(P=_.sibling,_.sibling=null),eA(m,!1,P,_,I,M);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=m.child,m.child=null;P!==null;){if(h=P.alternate,h!==null&&By(h)===null){m.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}eA(m,!0,_,null,I,M);break;case"together":eA(m,!1,null,null,void 0,M);break;default:m.memoizedState=null}return m.child}function Xl(h,m,_){if(h!==null&&(m.dependencies=h.dependencies),bu|=m.lanes,(_&m.childLanes)===0)if(h!==null){if(Gf(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,_=$l(h,h.pendingProps),m.child=_,_.return=m;h.sibling!==null;)h=h.sibling,_=_.sibling=$l(h,h.pendingProps),_.return=m;_.sibling=null}return m.child}function tA(h,m){return(h.lanes&m)!==0?!0:(h=h.dependencies,!!(h!==null&&Ry(h)))}function Mre(h,m,_){switch(m.tag){case 3:le(m,m.stateNode.containerInfo),uu(m,ri,h.memoizedState.cache),Zd();break;case 27:case 5:pe(m);break;case 4:le(m,m.stateNode.containerInfo);break;case 10:uu(m,m.type,m.memoizedProps.value);break;case 31:if(m.memoizedState!==null)return m.flags|=128,AE(m),null;break;case 13:var M=m.memoizedState;if(M!==null)return M.dehydrated!==null?(mu(m),m.flags|=128,null):(_&m.child.childLanes)!==0?t5(h,m,_):(mu(m),h=Xl(h,m,_),h!==null?h.sibling:null);mu(m);break;case 19:var P=(h.flags&128)!==0;if(M=(_&m.childLanes)!==0,M||(Gf(h,m,_,!1),M=(_&m.childLanes)!==0),P){if(M)return r5(h,m,_);m.flags|=128}if(P=m.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),ee(Zr,Zr.current),M)break;return null;case 22:return m.lanes=0,XI(h,m,_,m.pendingProps);case 24:uu(m,ri,h.memoizedState.cache)}return Xl(h,m,_)}function i5(h,m,_){if(h!==null)if(h.memoizedProps!==m.pendingProps)ai=!0;else{if(!tA(h,_)&&(m.flags&128)===0)return ai=!1,Mre(h,m,_);ai=(h.flags&131072)!==0}else ai=!1,jn&&(m.flags&1048576)!==0&&LL(m,$g,m.index);switch(m.lanes=0,m.tag){case 16:e:{var M=m.pendingProps;if(h=th(m.elementType),m.type=h,typeof h=="function")sE(h)?(M=ah(h,M),m.tag=1,m=JI(null,m,h,M,_)):(m.tag=0,m=KE(null,m,h,M,_));else{if(h!=null){var P=h.$$typeof;if(P===N){m.tag=11,m=WI(null,m,h,M,_);break e}else if(P===T){m.tag=14,m=qI(null,m,h,M,_);break e}}throw m=R(h)||h,Error(r(306,m,""))}}return m;case 0:return KE(h,m,m.type,m.pendingProps,_);case 1:return M=m.type,P=ah(M,m.pendingProps),JI(h,m,M,P,_);case 3:e:{if(le(m,m.stateNode.containerInfo),h===null)throw Error(r(387));M=m.pendingProps;var I=m.memoizedState;P=I.element,_E(h,m),Zg(m,M,null,_);var Z=m.memoizedState;if(M=Z.cache,uu(m,ri,M),M!==I.cache&&pE(m,[ri],_,!0),Yg(),M=Z.element,I.isDehydrated)if(I={element:M,isDehydrated:!1,cache:Z.cache},m.updateQueue.baseState=I,m.memoizedState=I,m.flags&256){m=e5(h,m,M,_);break e}else if(M!==P){P=zs(Error(r(424)),m),Vg(P),m=e5(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=Gs(h.firstChild),Qi=m,jn=!0,lu=null,$s=!0,_=XL(m,null,M,_),m.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(Zd(),M===P){m=Xl(h,m,_);break e}ea(h,m,M,_)}m=m.child}return m;case 26:return Qy(h,m),h===null?(_=pF(m.type,null,m.pendingProps,null))?m.memoizedState=_:jn||(_=m.type,h=m.pendingProps,M=pv(de.current).createElement(_),M[Kt]=m,M[dn]=h,ta(M,_,h),Oe(M),m.stateNode=M):m.memoizedState=pF(m.type,h.memoizedProps,m.pendingProps,h.memoizedState),null;case 27:return pe(m),h===null&&jn&&(M=m.stateNode=hF(m.type,m.pendingProps,de.current),Qi=m,$s=!0,P=_r,Su(m.type)?(DA=P,_r=Gs(M.firstChild)):_r=P),ea(h,m,m.pendingProps.children,_),Qy(h,m),h===null&&(m.flags|=4194304),m.child;case 5:return h===null&&jn&&((P=M=_r)&&(M=eie(M,m.type,m.pendingProps,$s),M!==null?(m.stateNode=M,Qi=m,_r=Gs(M.firstChild),$s=!1,P=!0):P=!1),P||cu(m)),pe(m),P=m.type,I=m.pendingProps,Z=h!==null?h.memoizedProps:null,M=I.children,CA(P,I)?M=null:Z!==null&&CA(P,Z)&&(m.flags|=32),m.memoizedState!==null&&(P=TE(h,m,pre,null,null,_),xx._currentValue=P),Qy(h,m),ea(h,m,M,_),m.child;case 6:return h===null&&jn&&((h=_=_r)&&(_=tie(_,m.pendingProps,$s),_!==null?(m.stateNode=_,Qi=m,_r=null,h=!0):h=!1),h||cu(m)),null;case 13:return t5(h,m,_);case 4:return le(m,m.stateNode.containerInfo),M=m.pendingProps,h===null?m.child=rh(m,null,M,_):ea(h,m,M,_),m.child;case 11:return WI(h,m,m.type,m.pendingProps,_);case 7:return ea(h,m,m.pendingProps,_),m.child;case 8:return ea(h,m,m.pendingProps.children,_),m.child;case 12:return ea(h,m,m.pendingProps.children,_),m.child;case 10:return M=m.pendingProps,uu(m,m.type,M.value),ea(h,m,M.children,_),m.child;case 9:return P=m.type._context,M=m.pendingProps.children,Jd(m),P=Ji(P),M=M(P),m.flags|=1,ea(h,m,M,_),m.child;case 14:return qI(h,m,m.type,m.pendingProps,_);case 15:return KI(h,m,m.type,m.pendingProps,_);case 19:return r5(h,m,_);case 31:return Sre(h,m,_);case 22:return XI(h,m,_,m.pendingProps);case 24:return Jd(m),M=Ji(ri),h===null?(P=bE(),P===null&&(P=mr,I=gE(),P.pooledCache=I,I.refCount++,I!==null&&(P.pooledCacheLanes|=_),P=I),m.memoizedState={parent:M,cache:P},vE(m),uu(m,ri,P)):((h.lanes&_)!==0&&(_E(h,m),Zg(m,null,null,_),Yg()),P=h.memoizedState,I=m.memoizedState,P.parent!==M?(P={parent:M,cache:M},m.memoizedState=P,m.lanes===0&&(m.memoizedState=m.updateQueue.baseState=P),uu(m,ri,M)):(M=I.cache,uu(m,ri,M),M!==P.cache&&pE(m,[ri],_,!0))),ea(h,m,m.pendingProps.children,_),m.child;case 29:throw m.pendingProps}throw Error(r(156,m.tag))}function Yl(h){h.flags|=4}function nA(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(P5())h.flags|=8192;else throw nh=Iy,yE}else h.flags&=-16777217}function a5(h,m){if(m.type!=="stylesheet"||(m.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!vF(m))if(P5())h.flags|=8192;else throw nh=Iy,yE}function ev(h,m){m!==null&&(h.flags|=4),h.flags&16384&&(m=h.tag!==22?Tt():536870912,h.lanes|=m,rm|=m)}function rx(h,m){if(!jn)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 Ere(h,m,_){var M=m.pendingProps;switch(uE(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),Wl(ri),he(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(Vf(m)?Yl(m):h===null||h.memoizedState.isDehydrated&&(m.flags&256)===0||(m.flags|=1024,hE())),wr(m),null;case 26:var P=m.type,I=m.memoizedState;return h===null?(Yl(m),I!==null?(wr(m),a5(m,I)):(wr(m),nA(m,P,null,M,_))):I?I!==h.memoizedState?(Yl(m),wr(m),a5(m,I)):(wr(m),m.flags&=-16777217):(h=h.memoizedProps,h!==M&&Yl(m),wr(m),nA(m,P,h,M,_)),null;case 27:if(Me(m),_=de.current,P=m.type,h!==null&&m.stateNode!=null)h.memoizedProps!==M&&Yl(m);else{if(!M){if(m.stateNode===null)throw Error(r(166));return wr(m),null}h=ie.current,Vf(m)?FL(m):(h=hF(P,M,_),m.stateNode=h,Yl(m))}return wr(m),null;case 5:if(Me(m),P=m.type,h!==null&&m.stateNode!=null)h.memoizedProps!==M&&Yl(m);else{if(!M){if(m.stateNode===null)throw Error(r(166));return wr(m),null}if(I=ie.current,Vf(m))FL(m);else{var Z=pv(de.current);switch(I){case 1:I=Z.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:I=Z.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":I=Z.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":I=Z.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;case"script":I=Z.createElement("div"),I.innerHTML="<script><\/script>",I=I.removeChild(I.firstChild);break;case"select":I=typeof M.is=="string"?Z.createElement("select",{is:M.is}):Z.createElement("select"),M.multiple?I.multiple=!0:M.size&&(I.size=M.size);break;default:I=typeof M.is=="string"?Z.createElement(P,{is:M.is}):Z.createElement(P)}}I[Kt]=m,I[dn]=M;e:for(Z=m.child;Z!==null;){if(Z.tag===5||Z.tag===6)I.appendChild(Z.stateNode);else if(Z.tag!==4&&Z.tag!==27&&Z.child!==null){Z.child.return=Z,Z=Z.child;continue}if(Z===m)break e;for(;Z.sibling===null;){if(Z.return===null||Z.return===m)break e;Z=Z.return}Z.sibling.return=Z.return,Z=Z.sibling}m.stateNode=I;e:switch(ta(I,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&&Yl(m)}}return wr(m),nA(m,m.type,h===null?null:h.memoizedProps,m.pendingProps,_),null;case 6:if(h&&m.stateNode!=null)h.memoizedProps!==M&&Yl(m);else{if(typeof M!="string"&&m.stateNode===null)throw Error(r(166));if(h=de.current,Vf(m)){if(h=m.stateNode,_=m.memoizedProps,M=null,P=Qi,P!==null)switch(P.tag){case 27:case 5:M=P.memoizedProps}h[Kt]=m,h=!!(h.nodeValue===_||M!==null&&M.suppressHydrationWarning===!0||tF(h.nodeValue,_)),h||cu(m,!0)}else h=pv(h).createTextNode(M),h[Kt]=m,m.stateNode=h}return wr(m),null;case 31:if(_=m.memoizedState,h===null||h.memoizedState!==null){if(M=Vf(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[Kt]=m}else Zd(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;wr(m),h=!1}else _=hE(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return m.flags&256?(bs(m),m):(bs(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=Vf(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[Kt]=m}else Zd(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;wr(m),P=!1}else P=hE(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=P),P=!0;if(!P)return m.flags&256?(bs(m),m):(bs(m),null)}return bs(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),I=null,M.memoizedState!==null&&M.memoizedState.cachePool!==null&&(I=M.memoizedState.cachePool.pool),I!==P&&(M.flags|=2048)),_!==h&&_&&(m.child.flags|=8192),ev(m,m.updateQueue),wr(m),null);case 4:return he(),h===null&&MA(m.stateNode.containerInfo),wr(m),null;case 10:return Wl(m.type),wr(m),null;case 19:if(W(Zr),M=m.memoizedState,M===null)return wr(m),null;if(P=(m.flags&128)!==0,I=M.rendering,I===null)if(P)rx(M,!1);else{if(Br!==0||h!==null&&(h.flags&128)!==0)for(h=m.child;h!==null;){if(I=By(h),I!==null){for(m.flags|=128,rx(M,!1),h=I.updateQueue,m.updateQueue=h,ev(m,h),m.subtreeFlags=0,h=_,_=m.child;_!==null;)RL(_,h),_=_.sibling;return ee(Zr,Zr.current&1|2),jn&&Vl(m,M.treeForkCount),m.child}h=h.sibling}M.tail!==null&&j()>av&&(m.flags|=128,P=!0,rx(M,!1),m.lanes=4194304)}else{if(!P)if(h=By(I),h!==null){if(m.flags|=128,P=!0,h=h.updateQueue,m.updateQueue=h,ev(m,h),rx(M,!0),M.tail===null&&M.tailMode==="hidden"&&!I.alternate&&!jn)return wr(m),null}else 2*j()-M.renderingStartTime>av&&_!==536870912&&(m.flags|=128,P=!0,rx(M,!1),m.lanes=4194304);M.isBackwards?(I.sibling=m.child,m.child=I):(h=M.last,h!==null?h.sibling=I:m.child=I,M.last=I)}return M.tail!==null?(h=M.tail,M.rendering=h,M.tail=h.sibling,M.renderingStartTime=j(),h.sibling=null,_=Zr.current,ee(Zr,P?_&1|2:_&1),jn&&Vl(m,M.treeForkCount),h):(wr(m),null);case 22:case 23:return bs(m),EE(),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&&ev(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&&W(eh),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),m.memoizedState.cache!==_&&(m.flags|=2048),Wl(ri),wr(m),null;case 25:return null;case 30:return null}throw Error(r(156,m.tag))}function Are(h,m){switch(uE(m),m.tag){case 1:return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 3:return Wl(ri),he(),h=m.flags,(h&65536)!==0&&(h&128)===0?(m.flags=h&-65537|128,m):null;case 26:case 27:case 5:return Me(m),null;case 31:if(m.memoizedState!==null){if(bs(m),m.alternate===null)throw Error(r(340));Zd()}return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 13:if(bs(m),h=m.memoizedState,h!==null&&h.dehydrated!==null){if(m.alternate===null)throw Error(r(340));Zd()}return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 19:return W(Zr),null;case 4:return he(),null;case 10:return Wl(m.type),null;case 22:case 23:return bs(m),EE(),h!==null&&W(eh),h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 24:return Wl(ri),null;case 25:return null;default:return null}}function s5(h,m){switch(uE(m),m.tag){case 3:Wl(ri),he();break;case 26:case 27:case 5:Me(m);break;case 4:he();break;case 31:m.memoizedState!==null&&bs(m);break;case 13:bs(m);break;case 19:W(Zr);break;case 10:Wl(m.type);break;case 22:case 23:bs(m),EE(),h!==null&&W(eh);break;case 24:Wl(ri)}}function ix(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 I=_.create,Z=_.inst;M=I(),Z.destroy=M}_=_.next}while(_!==P)}}catch(fe){Xn(m,m.return,fe)}}function gu(h,m,_){try{var M=m.updateQueue,P=M!==null?M.lastEffect:null;if(P!==null){var I=P.next;M=I;do{if((M.tag&h)===h){var Z=M.inst,fe=Z.destroy;if(fe!==void 0){Z.destroy=void 0,P=m;var Te=_,nt=fe;try{nt()}catch(lt){Xn(P,Te,lt)}}}M=M.next}while(M!==I)}}catch(lt){Xn(m,m.return,lt)}}function o5(h){var m=h.updateQueue;if(m!==null){var _=h.stateNode;try{ZL(m,_)}catch(M){Xn(h,h.return,M)}}}function l5(h,m,_){_.props=ah(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(M){Xn(h,m,M)}}function ax(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){Xn(h,m,P)}}function rl(h,m){var _=h.ref,M=h.refCleanup;if(_!==null)if(typeof M=="function")try{M()}catch(P){Xn(h,m,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){Xn(h,m,P)}else _.current=null}function c5(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){Xn(h,h.return,P)}}function rA(h,m,_){try{var M=h.stateNode;Kre(M,h.type,_,m),M[dn]=m}catch(P){Xn(h,h.return,P)}}function u5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&Su(h.type)||h.tag===4}function iA(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||u5(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&&Su(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 aA(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=Bl));else if(M!==4&&(M===27&&Su(h.type)&&(_=h.stateNode,m=null),h=h.child,h!==null))for(aA(h,m,_),h=h.sibling;h!==null;)aA(h,m,_),h=h.sibling}function tv(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&&Su(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(tv(h,m,_),h=h.sibling;h!==null;)tv(h,m,_),h=h.sibling}function d5(h){var m=h.stateNode,_=h.memoizedProps;try{for(var M=h.type,P=m.attributes;P.length;)m.removeAttributeNode(P[0]);ta(m,M,_),m[Kt]=h,m[dn]=_}catch(I){Xn(h,h.return,I)}}var Zl=!1,si=!1,sA=!1,h5=typeof WeakSet=="function"?WeakSet:Set,Fi=null;function Nre(h,m){if(h=h.containerInfo,NA=wv,h=ML(h),J2(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,I=M.focusNode;M=M.focusOffset;try{_.nodeType,I.nodeType}catch{_=null;break e}var Z=0,fe=-1,Te=-1,nt=0,lt=0,pt=h,it=null;t:for(;;){for(var ot;pt!==_||P!==0&&pt.nodeType!==3||(fe=Z+P),pt!==I||M!==0&&pt.nodeType!==3||(Te=Z+M),pt.nodeType===3&&(Z+=pt.nodeValue.length),(ot=pt.firstChild)!==null;)it=pt,pt=ot;for(;;){if(pt===h)break t;if(it===_&&++nt===P&&(fe=Z),it===I&&++lt===M&&(Te=Z),(ot=pt.nextSibling)!==null)break;pt=it,it=pt.parentNode}pt=ot}_=fe===-1||Te===-1?null:{start:fe,end:Te}}else _=null}_=_||{start:0,end:0}}else _=null;for(TA={focusedElem:h,selectionRange:_},wv=!1,Fi=m;Fi!==null;)if(m=Fi,h=m.child,(m.subtreeFlags&1028)!==0&&h!==null)h.return=m,Fi=h;else for(;Fi!==null;){switch(m=Fi,I=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&&I!==null){h=void 0,_=m,P=I.memoizedProps,I=I.memoizedState,M=_.stateNode;try{var Ft=ah(_.type,P);h=M.getSnapshotBeforeUpdate(Ft,I),M.__reactInternalSnapshotBeforeUpdate=h}catch(Jt){Xn(_,_.return,Jt)}}break;case 3:if((h&1024)!==0){if(h=m.stateNode.containerInfo,_=h.nodeType,_===9)PA(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":PA(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,Fi=h;break}Fi=m.return}}function f5(h,m,_){var M=_.flags;switch(_.tag){case 0:case 11:case 15:Jl(h,_),M&4&&ix(5,_);break;case 1:if(Jl(h,_),M&4)if(h=_.stateNode,m===null)try{h.componentDidMount()}catch(Z){Xn(_,_.return,Z)}else{var P=ah(_.type,m.memoizedProps);m=m.memoizedState;try{h.componentDidUpdate(P,m,h.__reactInternalSnapshotBeforeUpdate)}catch(Z){Xn(_,_.return,Z)}}M&64&&o5(_),M&512&&ax(_,_.return);break;case 3:if(Jl(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{ZL(h,m)}catch(Z){Xn(_,_.return,Z)}}break;case 27:m===null&&M&4&&d5(_);case 26:case 5:Jl(h,_),m===null&&M&4&&c5(_),M&512&&ax(_,_.return);break;case 12:Jl(h,_);break;case 31:Jl(h,_),M&4&&g5(h,_);break;case 13:Jl(h,_),M&4&&x5(h,_),M&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=Lre.bind(null,_),nie(h,_))));break;case 22:if(M=_.memoizedState!==null||Zl,!M){m=m!==null&&m.memoizedState!==null||si,P=Zl;var I=si;Zl=M,(si=m)&&!I?ec(h,_,(_.subtreeFlags&8772)!==0):Jl(h,_),Zl=P,si=I}break;case 30:break;default:Jl(h,_)}}function m5(h){var m=h.alternate;m!==null&&(h.alternate=null,m5(m)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(m=h.stateNode,m!==null&&tt(m)),h.stateNode=null,h.return=null,h.dependencies=null,h.memoizedProps=null,h.memoizedState=null,h.pendingProps=null,h.stateNode=null,h.updateQueue=null}var Tr=null,qa=!1;function Ql(h,m,_){for(_=_.child;_!==null;)p5(h,m,_),_=_.sibling}function p5(h,m,_){if(me&&typeof me.onCommitFiberUnmount=="function")try{me.onCommitFiberUnmount(He,_)}catch{}switch(_.tag){case 26:si||rl(_,m),Ql(h,m,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:si||rl(_,m);var M=Tr,P=qa;Su(_.type)&&(Tr=_.stateNode,qa=!1),Ql(h,m,_),mx(_.stateNode),Tr=M,qa=P;break;case 5:si||rl(_,m);case 6:if(M=Tr,P=qa,Tr=null,Ql(h,m,_),Tr=M,qa=P,Tr!==null)if(qa)try{(Tr.nodeType===9?Tr.body:Tr.nodeName==="HTML"?Tr.ownerDocument.body:Tr).removeChild(_.stateNode)}catch(I){Xn(_,m,I)}else try{Tr.removeChild(_.stateNode)}catch(I){Xn(_,m,I)}break;case 18:Tr!==null&&(qa?(h=Tr,oF(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),dm(h)):oF(Tr,_.stateNode));break;case 4:M=Tr,P=qa,Tr=_.stateNode.containerInfo,qa=!0,Ql(h,m,_),Tr=M,qa=P;break;case 0:case 11:case 14:case 15:gu(2,_,m),si||gu(4,_,m),Ql(h,m,_);break;case 1:si||(rl(_,m),M=_.stateNode,typeof M.componentWillUnmount=="function"&&l5(_,m,M)),Ql(h,m,_);break;case 21:Ql(h,m,_);break;case 22:si=(M=si)||_.memoizedState!==null,Ql(h,m,_),si=M;break;default:Ql(h,m,_)}}function g5(h,m){if(m.memoizedState===null&&(h=m.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{dm(h)}catch(_){Xn(m,m.return,_)}}}function x5(h,m){if(m.memoizedState===null&&(h=m.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{dm(h)}catch(_){Xn(m,m.return,_)}}function Tre(h){switch(h.tag){case 31:case 13:case 19:var m=h.stateNode;return m===null&&(m=h.stateNode=new h5),m;case 22:return h=h.stateNode,m=h._retryCache,m===null&&(m=h._retryCache=new h5),m;default:throw Error(r(435,h.tag))}}function nv(h,m){var _=Tre(h);m.forEach(function(M){if(!_.has(M)){_.add(M);var P=Ire.bind(null,h,M);M.then(P,P)}})}function Ka(h,m){var _=m.deletions;if(_!==null)for(var M=0;M<_.length;M++){var P=_[M],I=h,Z=m,fe=Z;e:for(;fe!==null;){switch(fe.tag){case 27:if(Su(fe.type)){Tr=fe.stateNode,qa=!1;break e}break;case 5:Tr=fe.stateNode,qa=!1;break e;case 3:case 4:Tr=fe.stateNode.containerInfo,qa=!0;break e}fe=fe.return}if(Tr===null)throw Error(r(160));p5(I,Z,P),Tr=null,qa=!1,I=P.alternate,I!==null&&(I.return=null),P.return=null}if(m.subtreeFlags&13886)for(m=m.child;m!==null;)b5(m,h),m=m.sibling}var Ao=null;function b5(h,m){var _=h.alternate,M=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:Ka(m,h),Xa(h),M&4&&(gu(3,h,h.return),ix(3,h),gu(5,h,h.return));break;case 1:Ka(m,h),Xa(h),M&512&&(si||_===null||rl(_,_.return)),M&64&&Zl&&(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=Ao;if(Ka(m,h),Xa(h),M&512&&(si||_===null||rl(_,_.return)),M&4){var I=_!==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":I=P.getElementsByTagName("title")[0],(!I||I[rt]||I[Kt]||I.namespaceURI==="http://www.w3.org/2000/svg"||I.hasAttribute("itemprop"))&&(I=P.createElement(M),P.head.insertBefore(I,P.querySelector("head > title"))),ta(I,M,_),I[Kt]=h,Oe(I),M=I;break e;case"link":var Z=bF("link","href",P).get(M+(_.href||""));if(Z){for(var fe=0;fe<Z.length;fe++)if(I=Z[fe],I.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&I.getAttribute("rel")===(_.rel==null?null:_.rel)&&I.getAttribute("title")===(_.title==null?null:_.title)&&I.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){Z.splice(fe,1);break t}}I=P.createElement(M),ta(I,M,_),P.head.appendChild(I);break;case"meta":if(Z=bF("meta","content",P).get(M+(_.content||""))){for(fe=0;fe<Z.length;fe++)if(I=Z[fe],I.getAttribute("content")===(_.content==null?null:""+_.content)&&I.getAttribute("name")===(_.name==null?null:_.name)&&I.getAttribute("property")===(_.property==null?null:_.property)&&I.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&I.getAttribute("charset")===(_.charSet==null?null:_.charSet)){Z.splice(fe,1);break t}}I=P.createElement(M),ta(I,M,_),P.head.appendChild(I);break;default:throw Error(r(468,M))}I[Kt]=h,Oe(I),M=I}h.stateNode=M}else yF(P,h.type,h.stateNode);else h.stateNode=xF(P,M,h.memoizedProps);else I!==M?(I===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):I.count--,M===null?yF(P,h.type,h.stateNode):xF(P,M,h.memoizedProps)):M===null&&h.stateNode!==null&&rA(h,h.memoizedProps,_.memoizedProps)}break;case 27:Ka(m,h),Xa(h),M&512&&(si||_===null||rl(_,_.return)),_!==null&&M&4&&rA(h,h.memoizedProps,_.memoizedProps);break;case 5:if(Ka(m,h),Xa(h),M&512&&(si||_===null||rl(_,_.return)),h.flags&32){P=h.stateNode;try{el(P,"")}catch(Ft){Xn(h,h.return,Ft)}}M&4&&h.stateNode!=null&&(P=h.memoizedProps,rA(h,P,_!==null?_.memoizedProps:P)),M&1024&&(sA=!0);break;case 6:if(Ka(m,h),Xa(h),M&4){if(h.stateNode===null)throw Error(r(162));M=h.memoizedProps,_=h.stateNode;try{_.nodeValue=M}catch(Ft){Xn(h,h.return,Ft)}}break;case 3:if(bv=null,P=Ao,Ao=gv(m.containerInfo),Ka(m,h),Ao=P,Xa(h),M&4&&_!==null&&_.memoizedState.isDehydrated)try{dm(m.containerInfo)}catch(Ft){Xn(h,h.return,Ft)}sA&&(sA=!1,y5(h));break;case 4:M=Ao,Ao=gv(h.stateNode.containerInfo),Ka(m,h),Xa(h),Ao=M;break;case 12:Ka(m,h),Xa(h);break;case 31:Ka(m,h),Xa(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,nv(h,M)));break;case 13:Ka(m,h),Xa(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(iv=j()),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,nv(h,M)));break;case 22:P=h.memoizedState!==null;var Te=_!==null&&_.memoizedState!==null,nt=Zl,lt=si;if(Zl=nt||P,si=lt||Te,Ka(m,h),si=lt,Zl=nt,Xa(h),M&8192)e:for(m=h.stateNode,m._visibility=P?m._visibility&-2:m._visibility|1,P&&(_===null||Te||Zl||si||sh(h)),_=null,m=h;;){if(m.tag===5||m.tag===26){if(_===null){Te=_=m;try{if(I=Te.stateNode,P)Z=I.style,typeof Z.setProperty=="function"?Z.setProperty("display","none","important"):Z.display="none";else{fe=Te.stateNode;var pt=Te.memoizedProps.style,it=pt!=null&&pt.hasOwnProperty("display")?pt.display:null;fe.style.display=it==null||typeof it=="boolean"?"":(""+it).trim()}}catch(Ft){Xn(Te,Te.return,Ft)}}}else if(m.tag===6){if(_===null){Te=m;try{Te.stateNode.nodeValue=P?"":Te.memoizedProps}catch(Ft){Xn(Te,Te.return,Ft)}}}else if(m.tag===18){if(_===null){Te=m;try{var ot=Te.stateNode;P?lF(ot,!0):lF(Te.stateNode,!1)}catch(Ft){Xn(Te,Te.return,Ft)}}}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,nv(h,_))));break;case 19:Ka(m,h),Xa(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,nv(h,M)));break;case 30:break;case 21:break;default:Ka(m,h),Xa(h)}}function Xa(h){var m=h.flags;if(m&2){try{for(var _,M=h.return;M!==null;){if(u5(M)){_=M;break}M=M.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,I=iA(h);tv(h,I,P);break;case 5:var Z=_.stateNode;_.flags&32&&(el(Z,""),_.flags&=-33);var fe=iA(h);tv(h,fe,Z);break;case 3:case 4:var Te=_.stateNode.containerInfo,nt=iA(h);aA(h,nt,Te);break;default:throw Error(r(161))}}catch(lt){Xn(h,h.return,lt)}h.flags&=-3}m&4096&&(h.flags&=-4097)}function y5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var m=h;y5(m),m.tag===5&&m.flags&1024&&m.stateNode.reset(),h=h.sibling}}function Jl(h,m){if(m.subtreeFlags&8772)for(m=m.child;m!==null;)f5(h,m.alternate,m),m=m.sibling}function sh(h){for(h=h.child;h!==null;){var m=h;switch(m.tag){case 0:case 11:case 14:case 15:gu(4,m,m.return),sh(m);break;case 1:rl(m,m.return);var _=m.stateNode;typeof _.componentWillUnmount=="function"&&l5(m,m.return,_),sh(m);break;case 27:mx(m.stateNode);case 26:case 5:rl(m,m.return),sh(m);break;case 22:m.memoizedState===null&&sh(m);break;case 30:sh(m);break;default:sh(m)}h=h.sibling}}function ec(h,m,_){for(_=_&&(m.subtreeFlags&8772)!==0,m=m.child;m!==null;){var M=m.alternate,P=h,I=m,Z=I.flags;switch(I.tag){case 0:case 11:case 15:ec(P,I,_),ix(4,I);break;case 1:if(ec(P,I,_),M=I,P=M.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(nt){Xn(M,M.return,nt)}if(M=I,P=M.updateQueue,P!==null){var fe=M.stateNode;try{var Te=P.shared.hiddenCallbacks;if(Te!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Te.length;P++)YL(Te[P],fe)}catch(nt){Xn(M,M.return,nt)}}_&&Z&64&&o5(I),ax(I,I.return);break;case 27:d5(I);case 26:case 5:ec(P,I,_),_&&M===null&&Z&4&&c5(I),ax(I,I.return);break;case 12:ec(P,I,_);break;case 31:ec(P,I,_),_&&Z&4&&g5(P,I);break;case 13:ec(P,I,_),_&&Z&4&&x5(P,I);break;case 22:I.memoizedState===null&&ec(P,I,_),ax(I,I.return);break;case 30:break;default:ec(P,I,_)}m=m.sibling}}function oA(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&&Gg(_))}function lA(h,m){h=null,m.alternate!==null&&(h=m.alternate.memoizedState.cache),m=m.memoizedState.cache,m!==h&&(m.refCount++,h!=null&&Gg(h))}function No(h,m,_,M){if(m.subtreeFlags&10256)for(m=m.child;m!==null;)v5(h,m,_,M),m=m.sibling}function v5(h,m,_,M){var P=m.flags;switch(m.tag){case 0:case 11:case 15:No(h,m,_,M),P&2048&&ix(9,m);break;case 1:No(h,m,_,M);break;case 3:No(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&&Gg(h)));break;case 12:if(P&2048){No(h,m,_,M),h=m.stateNode;try{var I=m.memoizedProps,Z=I.id,fe=I.onPostCommit;typeof fe=="function"&&fe(Z,m.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Te){Xn(m,m.return,Te)}}else No(h,m,_,M);break;case 31:No(h,m,_,M);break;case 13:No(h,m,_,M);break;case 23:break;case 22:I=m.stateNode,Z=m.alternate,m.memoizedState!==null?I._visibility&2?No(h,m,_,M):sx(h,m):I._visibility&2?No(h,m,_,M):(I._visibility|=2,em(h,m,_,M,(m.subtreeFlags&10256)!==0||!1)),P&2048&&oA(Z,m);break;case 24:No(h,m,_,M),P&2048&&lA(m.alternate,m);break;default:No(h,m,_,M)}}function em(h,m,_,M,P){for(P=P&&((m.subtreeFlags&10256)!==0||!1),m=m.child;m!==null;){var I=h,Z=m,fe=_,Te=M,nt=Z.flags;switch(Z.tag){case 0:case 11:case 15:em(I,Z,fe,Te,P),ix(8,Z);break;case 23:break;case 22:var lt=Z.stateNode;Z.memoizedState!==null?lt._visibility&2?em(I,Z,fe,Te,P):sx(I,Z):(lt._visibility|=2,em(I,Z,fe,Te,P)),P&&nt&2048&&oA(Z.alternate,Z);break;case 24:em(I,Z,fe,Te,P),P&&nt&2048&&lA(Z.alternate,Z);break;default:em(I,Z,fe,Te,P)}m=m.sibling}}function sx(h,m){if(m.subtreeFlags&10256)for(m=m.child;m!==null;){var _=h,M=m,P=M.flags;switch(M.tag){case 22:sx(_,M),P&2048&&oA(M.alternate,M);break;case 24:sx(_,M),P&2048&&lA(M.alternate,M);break;default:sx(_,M)}m=m.sibling}}var ox=8192;function tm(h,m,_){if(h.subtreeFlags&ox)for(h=h.child;h!==null;)_5(h,m,_),h=h.sibling}function _5(h,m,_){switch(h.tag){case 26:tm(h,m,_),h.flags&ox&&h.memoizedState!==null&&mie(_,Ao,h.memoizedState,h.memoizedProps);break;case 5:tm(h,m,_);break;case 3:case 4:var M=Ao;Ao=gv(h.stateNode.containerInfo),tm(h,m,_),Ao=M;break;case 22:h.memoizedState===null&&(M=h.alternate,M!==null&&M.memoizedState!==null?(M=ox,ox=16777216,tm(h,m,_),ox=M):tm(h,m,_));break;default:tm(h,m,_)}}function w5(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 lx(h){var m=h.deletions;if((h.flags&16)!==0){if(m!==null)for(var _=0;_<m.length;_++){var M=m[_];Fi=M,M5(M,h)}w5(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)S5(h),h=h.sibling}function S5(h){switch(h.tag){case 0:case 11:case 15:lx(h),h.flags&2048&&gu(9,h,h.return);break;case 3:lx(h);break;case 12:lx(h);break;case 22:var m=h.stateNode;h.memoizedState!==null&&m._visibility&2&&(h.return===null||h.return.tag!==13)?(m._visibility&=-3,rv(h)):lx(h);break;default:lx(h)}}function rv(h){var m=h.deletions;if((h.flags&16)!==0){if(m!==null)for(var _=0;_<m.length;_++){var M=m[_];Fi=M,M5(M,h)}w5(h)}for(h=h.child;h!==null;){switch(m=h,m.tag){case 0:case 11:case 15:gu(8,m,m.return),rv(m);break;case 22:_=m.stateNode,_._visibility&2&&(_._visibility&=-3,rv(m));break;default:rv(m)}h=h.sibling}}function M5(h,m){for(;Fi!==null;){var _=Fi;switch(_.tag){case 0:case 11:case 15:gu(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:Gg(_.memoizedState.cache)}if(M=_.child,M!==null)M.return=_,Fi=M;else e:for(_=h;Fi!==null;){M=Fi;var P=M.sibling,I=M.return;if(m5(M),M===_){Fi=null;break e}if(P!==null){P.return=I,Fi=P;break e}Fi=I}}}var Cre={getCacheForType:function(h){var m=Ji(ri),_=m.data.get(h);return _===void 0&&(_=h(),m.data.set(h,_)),_},cacheSignal:function(){return Ji(ri).controller.signal}},kre=typeof WeakMap=="function"?WeakMap:Map,Hn=0,mr=null,Mn=null,kn=0,Kn=0,ys=null,xu=!1,nm=!1,cA=!1,tc=0,Br=0,bu=0,oh=0,uA=0,vs=0,rm=0,cx=null,Ya=null,dA=!1,iv=0,E5=0,av=1/0,sv=null,yu=null,bi=0,vu=null,im=null,nc=0,hA=0,fA=null,A5=null,ux=0,mA=null;function _s(){return(Hn&2)!==0&&kn!==0?kn&-kn:Y.T!==null?vA():Vt()}function N5(){if(vs===0)if((kn&536870912)===0||jn){var h=xe;xe<<=1,(xe&3932160)===0&&(xe=262144),vs=h}else vs=536870912;return h=xs.current,h!==null&&(h.flags|=32),vs}function Za(h,m,_){(h===mr&&(Kn===2||Kn===9)||h.cancelPendingCommit!==null)&&(am(h,0),_u(h,kn,vs,!1)),Zt(h,_),((Hn&2)===0||h!==mr)&&(h===mr&&((Hn&2)===0&&(oh|=_),Br===4&&_u(h,kn,vs,!1)),il(h))}function T5(h,m,_){if((Hn&6)!==0)throw Error(r(327));var M=!_&&(m&127)===0&&(m&h.expiredLanes)===0||Ye(h,m),P=M?Rre(h,m):gA(h,m,!0),I=M;do{if(P===0){nm&&!M&&_u(h,m,0,!1);break}else{if(_=h.current.alternate,I&&!Pre(_)){P=gA(h,m,!1),I=!1;continue}if(P===2){if(I=m,h.errorRecoveryDisabledLanes&I)var Z=0;else Z=h.pendingLanes&-536870913,Z=Z!==0?Z:Z&536870912?536870912:0;if(Z!==0){m=Z;e:{var fe=h;P=cx;var Te=fe.current.memoizedState.isDehydrated;if(Te&&(am(fe,Z).flags|=256),Z=gA(fe,Z,!1),Z!==2){if(cA&&!Te){fe.errorRecoveryDisabledLanes|=I,oh|=I,P=4;break e}I=Ya,Ya=P,I!==null&&(Ya===null?Ya=I:Ya.push.apply(Ya,I))}P=Z}if(I=!1,P!==2)continue}}if(P===1){am(h,0),_u(h,m,0,!0);break}e:{switch(M=h,I=P,I){case 0:case 1:throw Error(r(345));case 4:if((m&4194048)!==m)break;case 6:_u(M,m,vs,!xu);break e;case 2:Ya=null;break;case 3:case 5:break;default:throw Error(r(329))}if((m&62914560)===m&&(P=iv+300-j(),10<P)){if(_u(M,m,vs,!xu),Se(M,0,!0)!==0)break e;nc=m,M.timeoutHandle=aF(C5.bind(null,M,_,Ya,sv,dA,m,vs,oh,rm,xu,I,"Throttled",-0,0),P);break e}C5(M,_,Ya,sv,dA,m,vs,oh,rm,xu,I,null,-0,0)}}break}while(!0);il(h)}function C5(h,m,_,M,P,I,Z,fe,Te,nt,lt,pt,it,ot){if(h.timeoutHandle=-1,pt=m.subtreeFlags,pt&8192||(pt&16785408)===16785408){pt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Bl},_5(m,I,pt);var Ft=(I&62914560)===I?iv-j():(I&4194048)===I?E5-j():0;if(Ft=pie(pt,Ft),Ft!==null){nc=I,h.cancelPendingCommit=Ft(I5.bind(null,h,m,I,_,M,P,Z,fe,Te,lt,pt,null,it,ot)),_u(h,I,Z,!nt);return}}I5(h,m,I,_,M,P,Z,fe,Te)}function Pre(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],I=P.getSnapshot;P=P.value;try{if(!ps(I(),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 _u(h,m,_,M){m&=~uA,m&=~oh,h.suspendedLanes|=m,h.pingedLanes&=~m,M&&(h.warmLanes|=m),M=h.expirationTimes;for(var P=m;0<P;){var I=31-Ke(P),Z=1<<I;M[I]=-1,P&=~Z}_!==0&&en(h,_,m)}function ov(){return(Hn&6)===0?(dx(0),!1):!0}function pA(){if(Mn!==null){if(Kn===0)var h=Mn.return;else h=Mn,Gl=Qd=null,PE(h),Xf=null,qg=0,h=Mn;for(;h!==null;)s5(h.alternate,h),h=h.return;Mn=null}}function am(h,m){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,Zre(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),nc=0,pA(),mr=h,Mn=_=$l(h.current,null),kn=m,Kn=0,ys=null,xu=!1,nm=Ye(h,m),cA=!1,rm=vs=uA=oh=bu=Br=0,Ya=cx=null,dA=!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-Ke(M),I=1<<P;m|=h[P],M&=~I}return tc=m,Ty(),_}function k5(h,m){hn=null,Y.H=tx,m===Kf||m===Ly?(m=WL(),Kn=3):m===yE?(m=WL(),Kn=4):Kn=m===qE?8:m!==null&&typeof m=="object"&&typeof m.then=="function"?6:1,ys=m,Mn===null&&(Br=1,Yy(h,zs(m,h.current)))}function P5(){var h=xs.current;return h===null?!0:(kn&4194048)===kn?Vs===null:(kn&62914560)===kn||(kn&536870912)!==0?h===Vs:!1}function j5(){var h=Y.H;return Y.H=tx,h===null?tx:h}function R5(){var h=Y.A;return Y.A=Cre,h}function lv(){Br=4,xu||(kn&4194048)!==kn&&xs.current!==null||(nm=!0),(bu&134217727)===0&&(oh&134217727)===0||mr===null||_u(mr,kn,vs,!1)}function gA(h,m,_){var M=Hn;Hn|=2;var P=j5(),I=R5();(mr!==h||kn!==m)&&(sv=null,am(h,m)),m=!1;var Z=Br;e:do try{if(Kn!==0&&Mn!==null){var fe=Mn,Te=ys;switch(Kn){case 8:pA(),Z=6;break e;case 3:case 2:case 9:case 6:xs.current===null&&(m=!0);var nt=Kn;if(Kn=0,ys=null,sm(h,fe,Te,nt),_&&nm){Z=0;break e}break;default:nt=Kn,Kn=0,ys=null,sm(h,fe,Te,nt)}}jre(),Z=Br;break}catch(lt){k5(h,lt)}while(!0);return m&&h.shellSuspendCounter++,Gl=Qd=null,Hn=M,Y.H=P,Y.A=I,Mn===null&&(mr=null,kn=0,Ty()),Z}function jre(){for(;Mn!==null;)D5(Mn)}function Rre(h,m){var _=Hn;Hn|=2;var M=j5(),P=R5();mr!==h||kn!==m?(sv=null,av=j()+500,am(h,m)):nm=Ye(h,m);e:do try{if(Kn!==0&&Mn!==null){m=Mn;var I=ys;t:switch(Kn){case 1:Kn=0,ys=null,sm(h,m,I,1);break;case 2:case 9:if(VL(I)){Kn=0,ys=null,O5(m);break}m=function(){Kn!==2&&Kn!==9||mr!==h||(Kn=7),il(h)},I.then(m,m);break e;case 3:Kn=7;break e;case 4:Kn=5;break e;case 7:VL(I)?(Kn=0,ys=null,O5(m)):(Kn=0,ys=null,sm(h,m,I,7));break;case 5:var Z=null;switch(Mn.tag){case 26:Z=Mn.memoizedState;case 5:case 27:var fe=Mn;if(Z?vF(Z):fe.stateNode.complete){Kn=0,ys=null;var Te=fe.sibling;if(Te!==null)Mn=Te;else{var nt=fe.return;nt!==null?(Mn=nt,cv(nt)):Mn=null}break t}}Kn=0,ys=null,sm(h,m,I,5);break;case 6:Kn=0,ys=null,sm(h,m,I,6);break;case 8:pA(),Br=6;break e;default:throw Error(r(462))}}Dre();break}catch(lt){k5(h,lt)}while(!0);return Gl=Qd=null,Y.H=M,Y.A=P,Hn=_,Mn!==null?0:(mr=null,kn=0,Ty(),Br)}function Dre(){for(;Mn!==null&&!Ee();)D5(Mn)}function D5(h){var m=i5(h.alternate,h,tc);h.memoizedProps=h.pendingProps,m===null?cv(h):Mn=m}function O5(h){var m=h,_=m.alternate;switch(m.tag){case 15:case 0:m=QI(_,m,m.pendingProps,m.type,void 0,kn);break;case 11:m=QI(_,m,m.pendingProps,m.type.render,m.ref,kn);break;case 5:PE(m);default:s5(_,m),m=Mn=RL(m,tc),m=i5(_,m,tc)}h.memoizedProps=h.pendingProps,m===null?cv(h):Mn=m}function sm(h,m,_,M){Gl=Qd=null,PE(m),Xf=null,qg=0;var P=m.return;try{if(wre(h,P,m,_,kn)){Br=1,Yy(h,zs(_,h.current)),Mn=null;return}}catch(I){if(P!==null)throw Mn=P,I;Br=1,Yy(h,zs(_,h.current)),Mn=null;return}m.flags&32768?(jn||M===1?h=!0:nm||(kn&536870912)!==0?h=!1:(xu=h=!0,(M===2||M===9||M===3||M===6)&&(M=xs.current,M!==null&&M.tag===13&&(M.flags|=16384))),L5(m,h)):cv(m)}function cv(h){var m=h;do{if((m.flags&32768)!==0){L5(m,xu);return}h=m.return;var _=Ere(m.alternate,m,tc);if(_!==null){Mn=_;return}if(m=m.sibling,m!==null){Mn=m;return}Mn=m=h}while(m!==null);Br===0&&(Br=5)}function L5(h,m){do{var _=Are(h.alternate,h);if(_!==null){_.flags&=32767,Mn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!m&&(h=h.sibling,h!==null)){Mn=h;return}Mn=h=_}while(h!==null);Br=6,Mn=null}function I5(h,m,_,M,P,I,Z,fe,Te){h.cancelPendingCommit=null;do uv();while(bi!==0);if((Hn&6)!==0)throw Error(r(327));if(m!==null){if(m===h.current)throw Error(r(177));if(I=m.lanes|m.childLanes,I|=iE,Rt(h,_,I,Z,fe,Te),h===mr&&(Mn=mr=null,kn=0),im=m,vu=h,nc=_,hA=I,fA=P,A5=M,(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,Fre(ve,function(){return H5(),null})):(h.callbackNode=null,h.callbackPriority=0),M=(m.flags&13878)!==0,(m.subtreeFlags&13878)!==0||M){M=Y.T,Y.T=null,P=V.p,V.p=2,Z=Hn,Hn|=4;try{Nre(h,m,_)}finally{Hn=Z,V.p=P,Y.T=M}}bi=1,F5(),U5(),z5()}}function F5(){if(bi===1){bi=0;var h=vu,m=im,_=(m.flags&13878)!==0;if((m.subtreeFlags&13878)!==0||_){_=Y.T,Y.T=null;var M=V.p;V.p=2;var P=Hn;Hn|=4;try{b5(m,h);var I=TA,Z=ML(h.containerInfo),fe=I.focusedElem,Te=I.selectionRange;if(Z!==fe&&fe&&fe.ownerDocument&&SL(fe.ownerDocument.documentElement,fe)){if(Te!==null&&J2(fe)){var nt=Te.start,lt=Te.end;if(lt===void 0&&(lt=nt),"selectionStart"in fe)fe.selectionStart=nt,fe.selectionEnd=Math.min(lt,fe.value.length);else{var pt=fe.ownerDocument||document,it=pt&&pt.defaultView||window;if(it.getSelection){var ot=it.getSelection(),Ft=fe.textContent.length,Jt=Math.min(Te.start,Ft),ir=Te.end===void 0?Jt:Math.min(Te.end,Ft);!ot.extend&&Jt>ir&&(Z=ir,ir=Jt,Jt=Z);var Ve=wL(fe,Jt),Le=wL(fe,ir);if(Ve&&Le&&(ot.rangeCount!==1||ot.anchorNode!==Ve.node||ot.anchorOffset!==Ve.offset||ot.focusNode!==Le.node||ot.focusOffset!==Le.offset)){var et=pt.createRange();et.setStart(Ve.node,Ve.offset),ot.removeAllRanges(),Jt>ir?(ot.addRange(et),ot.extend(Le.node,Le.offset)):(et.setEnd(Le.node,Le.offset),ot.addRange(et))}}}}for(pt=[],ot=fe;ot=ot.parentNode;)ot.nodeType===1&&pt.push({element:ot,left:ot.scrollLeft,top:ot.scrollTop});for(typeof fe.focus=="function"&&fe.focus(),fe=0;fe<pt.length;fe++){var ht=pt[fe];ht.element.scrollLeft=ht.left,ht.element.scrollTop=ht.top}}wv=!!NA,TA=NA=null}finally{Hn=P,V.p=M,Y.T=_}}h.current=m,bi=2}}function U5(){if(bi===2){bi=0;var h=vu,m=im,_=(m.flags&8772)!==0;if((m.subtreeFlags&8772)!==0||_){_=Y.T,Y.T=null;var M=V.p;V.p=2;var P=Hn;Hn|=4;try{f5(h,m.alternate,m)}finally{Hn=P,V.p=M,Y.T=_}}bi=3}}function z5(){if(bi===4||bi===3){bi=0,$();var h=vu,m=im,_=nc,M=A5;(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?bi=5:(bi=0,im=vu=null,B5(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(yu=null),gt(_),m=m.stateNode,me&&typeof me.onCommitFiberRoot=="function")try{me.onCommitFiberRoot(He,m,void 0,(m.current.flags&128)===128)}catch{}if(M!==null){m=Y.T,P=V.p,V.p=2,Y.T=null;try{for(var I=h.onRecoverableError,Z=0;Z<M.length;Z++){var fe=M[Z];I(fe.value,{componentStack:fe.stack})}}finally{Y.T=m,V.p=P}}(nc&3)!==0&&uv(),il(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===mA?ux++:(ux=0,mA=h):ux=0,dx(0)}}function B5(h,m){(h.pooledCacheLanes&=m)===0&&(m=h.pooledCache,m!=null&&(h.pooledCache=null,Gg(m)))}function uv(){return F5(),U5(),z5(),H5()}function H5(){if(bi!==5)return!1;var h=vu,m=hA;hA=0;var _=gt(nc),M=Y.T,P=V.p;try{V.p=32>_?32:_,Y.T=null,_=fA,fA=null;var I=vu,Z=nc;if(bi=0,im=vu=null,nc=0,(Hn&6)!==0)throw Error(r(331));var fe=Hn;if(Hn|=4,S5(I.current),v5(I,I.current,Z,_),Hn=fe,dx(0,!1),me&&typeof me.onPostCommitFiberRoot=="function")try{me.onPostCommitFiberRoot(He,I)}catch{}return!0}finally{V.p=P,Y.T=M,B5(h,m)}}function $5(h,m,_){m=zs(_,m),m=WE(h.stateNode,m,2),h=fu(h,m,2),h!==null&&(Zt(h,2),il(h))}function Xn(h,m,_){if(h.tag===3)$5(h,h,_);else for(;m!==null;){if(m.tag===3){$5(m,h,_);break}else if(m.tag===1){var M=m.stateNode;if(typeof m.type.getDerivedStateFromError=="function"||typeof M.componentDidCatch=="function"&&(yu===null||!yu.has(M))){h=zs(_,h),_=VI(2),M=fu(m,_,2),M!==null&&(GI(_,M,m,h),Zt(M,2),il(M));break}}m=m.return}}function xA(h,m,_){var M=h.pingCache;if(M===null){M=h.pingCache=new kre;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(_)||(cA=!0,P.add(_),h=Ore.bind(null,h,m,_),m.then(h,h))}function Ore(h,m,_){var M=h.pingCache;M!==null&&M.delete(m),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,mr===h&&(kn&_)===_&&(Br===4||Br===3&&(kn&62914560)===kn&&300>j()-iv?(Hn&2)===0&&am(h,0):uA|=_,rm===kn&&(rm=0)),il(h)}function V5(h,m){m===0&&(m=Tt()),h=Xd(h,m),h!==null&&(Zt(h,m),il(h))}function Lre(h){var m=h.memoizedState,_=0;m!==null&&(_=m.retryLane),V5(h,_)}function Ire(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),V5(h,_)}function Fre(h,m){return Ce(h,m)}var dv=null,om=null,bA=!1,hv=!1,yA=!1,wu=0;function il(h){h!==om&&h.next===null&&(om===null?dv=om=h:om=om.next=h),hv=!0,bA||(bA=!0,zre())}function dx(h,m){if(!yA&&hv){yA=!0;do for(var _=!1,M=dv;M!==null;){if(h!==0){var P=M.pendingLanes;if(P===0)var I=0;else{var Z=M.suspendedLanes,fe=M.pingedLanes;I=(1<<31-Ke(42|h)+1)-1,I&=P&~(Z&~fe),I=I&201326741?I&201326741|1:I?I|2:0}I!==0&&(_=!0,K5(M,I))}else I=kn,I=Se(M,M===mr?I:0,M.cancelPendingCommit!==null||M.timeoutHandle!==-1),(I&3)===0||Ye(M,I)||(_=!0,K5(M,I));M=M.next}while(_);yA=!1}}function Ure(){G5()}function G5(){hv=bA=!1;var h=0;wu!==0&&Yre()&&(h=wu);for(var m=j(),_=null,M=dv;M!==null;){var P=M.next,I=W5(M,m);I===0?(M.next=null,_===null?dv=P:_.next=P,P===null&&(om=_)):(_=M,(h!==0||(I&3)!==0)&&(hv=!0)),M=P}bi!==0&&bi!==5||dx(h),wu!==0&&(wu=0)}function W5(h,m){for(var _=h.suspendedLanes,M=h.pingedLanes,P=h.expirationTimes,I=h.pendingLanes&-62914561;0<I;){var Z=31-Ke(I),fe=1<<Z,Te=P[Z];Te===-1?((fe&_)===0||(fe&M)!==0)&&(P[Z]=dt(fe,m)):Te<=m&&(h.expiredLanes|=fe),I&=~fe}if(m=mr,_=kn,_=Se(h,h===m?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M=h.callbackNode,_===0||h===m&&(Kn===2||Kn===9)||h.cancelPendingCommit!==null)return M!==null&&M!==null&&_e(M),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||Ye(h,_)){if(m=_&-_,m===h.callbackPriority)return m;switch(M!==null&&_e(M),gt(_)){case 2:case 8:_=we;break;case 32:_=ve;break;case 268435456:_=Ge;break;default:_=ve}return M=q5.bind(null,h),_=Ce(_,M),h.callbackPriority=m,h.callbackNode=_,m}return M!==null&&M!==null&&_e(M),h.callbackPriority=2,h.callbackNode=null,2}function q5(h,m){if(bi!==0&&bi!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(uv()&&h.callbackNode!==_)return null;var M=kn;return M=Se(h,h===mr?M:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M===0?null:(T5(h,M,m),W5(h,j()),h.callbackNode!=null&&h.callbackNode===_?q5.bind(null,h):null)}function K5(h,m){if(uv())return null;T5(h,m,!0)}function zre(){Qre(function(){(Hn&6)!==0?Ce(be,Ure):G5()})}function vA(){if(wu===0){var h=Wf;h===0&&(h=Fe,Fe<<=1,(Fe&261888)===0&&(Fe=256)),wu=h}return wu}function X5(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:vy(""+h)}function Y5(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 Bre(h,m,_,M,P){if(m==="submit"&&_&&_.stateNode===P){var I=X5((P[dn]||null).action),Z=M.submitter;Z&&(m=(m=Z[dn]||null)?X5(m.formAction):Z.getAttribute("formAction"),m!==null&&(I=m,Z=null));var fe=new My("action","action",null,M,P);h.push({event:fe,listeners:[{instance:null,listener:function(){if(M.defaultPrevented){if(wu!==0){var Te=Z?Y5(P,Z):new FormData(P);zE(_,{pending:!0,data:Te,method:P.method,action:I},null,Te)}}else typeof I=="function"&&(fe.preventDefault(),Te=Z?Y5(P,Z):new FormData(P),zE(_,{pending:!0,data:Te,method:P.method,action:I},I,Te))},currentTarget:P}]})}}for(var _A=0;_A<rE.length;_A++){var wA=rE[_A],Hre=wA.toLowerCase(),$re=wA[0].toUpperCase()+wA.slice(1);Eo(Hre,"on"+$re)}Eo(NL,"onAnimationEnd"),Eo(TL,"onAnimationIteration"),Eo(CL,"onAnimationStart"),Eo("dblclick","onDoubleClick"),Eo("focusin","onFocus"),Eo("focusout","onBlur"),Eo(are,"onTransitionRun"),Eo(sre,"onTransitionStart"),Eo(ore,"onTransitionCancel"),Eo(kL,"onTransitionEnd"),Ct("onMouseEnter",["mouseout","mouseover"]),Ct("onMouseLeave",["mouseout","mouseover"]),Ct("onPointerEnter",["pointerout","pointerover"]),Ct("onPointerLeave",["pointerout","pointerover"]),vt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),vt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),vt("onBeforeInput",["compositionend","keypress","textInput","paste"]),vt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),vt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),vt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var hx="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(" "),Vre=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(hx));function Z5(h,m){m=(m&4)!==0;for(var _=0;_<h.length;_++){var M=h[_],P=M.event;M=M.listeners;e:{var I=void 0;if(m)for(var Z=M.length-1;0<=Z;Z--){var fe=M[Z],Te=fe.instance,nt=fe.currentTarget;if(fe=fe.listener,Te!==I&&P.isPropagationStopped())break e;I=fe,P.currentTarget=nt;try{I(P)}catch(lt){Ny(lt)}P.currentTarget=null,I=Te}else for(Z=0;Z<M.length;Z++){if(fe=M[Z],Te=fe.instance,nt=fe.currentTarget,fe=fe.listener,Te!==I&&P.isPropagationStopped())break e;I=fe,P.currentTarget=nt;try{I(P)}catch(lt){Ny(lt)}P.currentTarget=null,I=Te}}}}function En(h,m){var _=m[Re];_===void 0&&(_=m[Re]=new Set);var M=h+"__bubble";_.has(M)||(Q5(m,h,2,!1),_.add(M))}function SA(h,m,_){var M=0;m&&(M|=4),Q5(_,h,M,m)}var fv="_reactListening"+Math.random().toString(36).slice(2);function MA(h){if(!h[fv]){h[fv]=!0,ke.forEach(function(_){_!=="selectionchange"&&(Vre.has(_)||SA(_,!1,h),SA(_,!0,h))});var m=h.nodeType===9?h:h.ownerDocument;m===null||m[fv]||(m[fv]=!0,SA("selectionchange",!1,m))}}function Q5(h,m,_,M){switch(NF(m)){case 2:var P=bie;break;case 8:P=yie;break;default:P=UA}_=P.bind(null,m,_,h),P=void 0,!V2||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 EA(h,m,_,M,P){var I=M;if((m&1)===0&&(m&2)===0&&M!==null)e:for(;;){if(M===null)return;var Z=M.tag;if(Z===3||Z===4){var fe=M.stateNode.containerInfo;if(fe===P)break;if(Z===4)for(Z=M.return;Z!==null;){var Te=Z.tag;if((Te===3||Te===4)&&Z.stateNode.containerInfo===P)return;Z=Z.return}for(;fe!==null;){if(Z=yt(fe),Z===null)return;if(Te=Z.tag,Te===5||Te===6||Te===26||Te===27){M=I=Z;continue e}fe=fe.parentNode}}M=M.return}rL(function(){var nt=I,lt=H2(_),pt=[];e:{var it=PL.get(h);if(it!==void 0){var ot=My,Ft=h;switch(h){case"keypress":if(wy(_)===0)break e;case"keydown":case"keyup":ot=Ine;break;case"focusin":Ft="focus",ot=K2;break;case"focusout":Ft="blur",ot=K2;break;case"beforeblur":case"afterblur":ot=K2;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ot=sL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ot=Ene;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ot=zne;break;case NL:case TL:case CL:ot=Tne;break;case kL:ot=Hne;break;case"scroll":case"scrollend":ot=Sne;break;case"wheel":ot=Vne;break;case"copy":case"cut":case"paste":ot=kne;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ot=lL;break;case"toggle":case"beforetoggle":ot=Wne}var Jt=(m&4)!==0,ir=!Jt&&(h==="scroll"||h==="scrollend"),Ve=Jt?it!==null?it+"Capture":null:it;Jt=[];for(var Le=nt,et;Le!==null;){var ht=Le;if(et=ht.stateNode,ht=ht.tag,ht!==5&&ht!==26&&ht!==27||et===null||Ve===null||(ht=Dg(Le,Ve),ht!=null&&Jt.push(fx(Le,ht,et))),ir)break;Le=Le.return}0<Jt.length&&(it=new ot(it,Ft,null,_,lt),pt.push({event:it,listeners:Jt}))}}if((m&7)===0){e:{if(it=h==="mouseover"||h==="pointerover",ot=h==="mouseout"||h==="pointerout",it&&_!==B2&&(Ft=_.relatedTarget||_.fromElement)&&(yt(Ft)||Ft[Ht]))break e;if((ot||it)&&(it=lt.window===lt?lt:(it=lt.ownerDocument)?it.defaultView||it.parentWindow:window,ot?(Ft=_.relatedTarget||_.toElement,ot=nt,Ft=Ft?yt(Ft):null,Ft!==null&&(ir=a(Ft),Jt=Ft.tag,Ft!==ir||Jt!==5&&Jt!==27&&Jt!==6)&&(Ft=null)):(ot=null,Ft=nt),ot!==Ft)){if(Jt=sL,ht="onMouseLeave",Ve="onMouseEnter",Le="mouse",(h==="pointerout"||h==="pointerover")&&(Jt=lL,ht="onPointerLeave",Ve="onPointerEnter",Le="pointer"),ir=ot==null?it:Ae(ot),et=Ft==null?it:Ae(Ft),it=new Jt(ht,Le+"leave",ot,_,lt),it.target=ir,it.relatedTarget=et,ht=null,yt(lt)===nt&&(Jt=new Jt(Ve,Le+"enter",Ft,_,lt),Jt.target=et,Jt.relatedTarget=ir,ht=Jt),ir=ht,ot&&Ft)t:{for(Jt=Gre,Ve=ot,Le=Ft,et=0,ht=Ve;ht;ht=Jt(ht))et++;ht=0;for(var Wt=Le;Wt;Wt=Jt(Wt))ht++;for(;0<et-ht;)Ve=Jt(Ve),et--;for(;0<ht-et;)Le=Jt(Le),ht--;for(;et--;){if(Ve===Le||Le!==null&&Ve===Le.alternate){Jt=Ve;break t}Ve=Jt(Ve),Le=Jt(Le)}Jt=null}else Jt=null;ot!==null&&J5(pt,it,ot,Jt,!1),Ft!==null&&ir!==null&&J5(pt,ir,Ft,Jt,!0)}}e:{if(it=nt?Ae(nt):window,ot=it.nodeName&&it.nodeName.toLowerCase(),ot==="select"||ot==="input"&&it.type==="file")var In=gL;else if(mL(it))if(xL)In=nre;else{In=ere;var zt=Jne}else ot=it.nodeName,!ot||ot.toLowerCase()!=="input"||it.type!=="checkbox"&&it.type!=="radio"?nt&&z2(nt.elementType)&&(In=gL):In=tre;if(In&&(In=In(h,nt))){pL(pt,In,_,lt);break e}zt&&zt(h,it,nt),h==="focusout"&&nt&&it.type==="number"&&nt.memoizedProps.value!=null&&Li(it,"number",it.value)}switch(zt=nt?Ae(nt):window,h){case"focusin":(mL(zt)||zt.contentEditable==="true")&&(Ff=zt,eE=nt,Hg=null);break;case"focusout":Hg=eE=Ff=null;break;case"mousedown":tE=!0;break;case"contextmenu":case"mouseup":case"dragend":tE=!1,EL(pt,_,lt);break;case"selectionchange":if(ire)break;case"keydown":case"keyup":EL(pt,_,lt)}var fn;if(Y2)e:{switch(h){case"compositionstart":var Pn="onCompositionStart";break e;case"compositionend":Pn="onCompositionEnd";break e;case"compositionupdate":Pn="onCompositionUpdate";break e}Pn=void 0}else If?hL(h,_)&&(Pn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(Pn="onCompositionStart");Pn&&(cL&&_.locale!=="ko"&&(If||Pn!=="onCompositionStart"?Pn==="onCompositionEnd"&&If&&(fn=iL()):(su=lt,G2="value"in su?su.value:su.textContent,If=!0)),zt=mv(nt,Pn),0<zt.length&&(Pn=new oL(Pn,h,null,_,lt),pt.push({event:Pn,listeners:zt}),fn?Pn.data=fn:(fn=fL(_),fn!==null&&(Pn.data=fn)))),(fn=Kne?Xne(h,_):Yne(h,_))&&(Pn=mv(nt,"onBeforeInput"),0<Pn.length&&(zt=new oL("onBeforeInput","beforeinput",null,_,lt),pt.push({event:zt,listeners:Pn}),zt.data=fn)),Bre(pt,h,nt,_,lt)}Z5(pt,m)})}function fx(h,m,_){return{instance:h,listener:m,currentTarget:_}}function mv(h,m){for(var _=m+"Capture",M=[];h!==null;){var P=h,I=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||I===null||(P=Dg(h,_),P!=null&&M.unshift(fx(h,P,I)),P=Dg(h,m),P!=null&&M.push(fx(h,P,I))),h.tag===3)return M;h=h.return}return[]}function Gre(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function J5(h,m,_,M,P){for(var I=m._reactName,Z=[];_!==null&&_!==M;){var fe=_,Te=fe.alternate,nt=fe.stateNode;if(fe=fe.tag,Te!==null&&Te===M)break;fe!==5&&fe!==26&&fe!==27||nt===null||(Te=nt,P?(nt=Dg(_,I),nt!=null&&Z.unshift(fx(_,nt,Te))):P||(nt=Dg(_,I),nt!=null&&Z.push(fx(_,nt,Te)))),_=_.return}Z.length!==0&&h.push({event:m,listeners:Z})}var Wre=/\r\n?/g,qre=/\u0000|\uFFFD/g;function eF(h){return(typeof h=="string"?h:""+h).replace(Wre,`
  9. `).replace(qre,"")}function tF(h,m){return m=eF(m),eF(h)===m}function rr(h,m,_,M,P,I){switch(_){case"children":typeof M=="string"?m==="body"||m==="textarea"&&M===""||el(h,M):(typeof M=="number"||typeof M=="bigint")&&m!=="body"&&el(h,""+M);break;case"className":Gt(h,"class",M);break;case"tabIndex":Gt(h,"tabindex",M);break;case"dir":case"role":case"viewBox":case"width":case"height":Gt(h,_,M);break;case"style":tL(h,M,I);break;case"data":if(m!=="object"){Gt(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=vy(""+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 I=="function"&&(_==="formAction"?(m!=="input"&&rr(h,m,"name",P.name,P,null),rr(h,m,"formEncType",P.formEncType,P,null),rr(h,m,"formMethod",P.formMethod,P,null),rr(h,m,"formTarget",P.formTarget,P,null)):(rr(h,m,"encType",P.encType,P,null),rr(h,m,"method",P.method,P,null),rr(h,m,"target",P.target,P,null)));if(M==null||typeof M=="symbol"||typeof M=="boolean"){h.removeAttribute(_);break}M=vy(""+M),h.setAttribute(_,M);break;case"onClick":M!=null&&(h.onclick=Bl);break;case"onScroll":M!=null&&En("scroll",h);break;case"onScrollEnd":M!=null&&En("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}_=vy(""+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":En("beforetoggle",h),En("toggle",h),rn(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":rn(h,"is",M);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=_ne.get(_)||_,rn(h,_,M))}}function AA(h,m,_,M,P,I){switch(_){case"style":tL(h,M,I);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"?el(h,M):(typeof M=="number"||typeof M=="bigint")&&el(h,""+M);break;case"onScroll":M!=null&&En("scroll",h);break;case"onScrollEnd":M!=null&&En("scrollend",h);break;case"onClick":M!=null&&(h.onclick=Bl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!st.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(P=_.endsWith("Capture"),m=_.slice(2,P?_.length-7:void 0),I=h[dn]||null,I=I!=null?I[_]:null,typeof I=="function"&&h.removeEventListener(m,I,P),typeof M=="function")){typeof I!="function"&&I!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(m,M,P);break e}_ in h?h[_]=M:M===!0?h.setAttribute(_,""):rn(h,_,M)}}}function ta(h,m,_){switch(m){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":En("error",h),En("load",h);var M=!1,P=!1,I;for(I in _)if(_.hasOwnProperty(I)){var Z=_[I];if(Z!=null)switch(I){case"src":M=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,m));default:rr(h,m,I,Z,_,null)}}P&&rr(h,m,"srcSet",_.srcSet,_,null),M&&rr(h,m,"src",_.src,_,null);return;case"input":En("invalid",h);var fe=I=Z=P=null,Te=null,nt=null;for(M in _)if(_.hasOwnProperty(M)){var lt=_[M];if(lt!=null)switch(M){case"name":P=lt;break;case"type":Z=lt;break;case"checked":Te=lt;break;case"defaultChecked":nt=lt;break;case"value":I=lt;break;case"defaultValue":fe=lt;break;case"children":case"dangerouslySetInnerHTML":if(lt!=null)throw Error(r(137,m));break;default:rr(h,m,M,lt,_,null)}}qn(h,I,fe,Te,nt,Z,P,!1);return;case"select":En("invalid",h),M=Z=I=null;for(P in _)if(_.hasOwnProperty(P)&&(fe=_[P],fe!=null))switch(P){case"value":I=fe;break;case"defaultValue":Z=fe;break;case"multiple":M=fe;default:rr(h,m,P,fe,_,null)}m=I,_=Z,h.multiple=!!M,m!=null?xi(h,!!M,m,!1):_!=null&&xi(h,!!M,_,!0);return;case"textarea":En("invalid",h),I=P=M=null;for(Z in _)if(_.hasOwnProperty(Z)&&(fe=_[Z],fe!=null))switch(Z){case"value":M=fe;break;case"defaultValue":P=fe;break;case"children":I=fe;break;case"dangerouslySetInnerHTML":if(fe!=null)throw Error(r(91));break;default:rr(h,m,Z,fe,_,null)}Zi(h,M,P,I);return;case"option":for(Te in _)if(_.hasOwnProperty(Te)&&(M=_[Te],M!=null))switch(Te){case"selected":h.selected=M&&typeof M!="function"&&typeof M!="symbol";break;default:rr(h,m,Te,M,_,null)}return;case"dialog":En("beforetoggle",h),En("toggle",h),En("cancel",h),En("close",h);break;case"iframe":case"object":En("load",h);break;case"video":case"audio":for(M=0;M<hx.length;M++)En(hx[M],h);break;case"image":En("error",h),En("load",h);break;case"details":En("toggle",h);break;case"embed":case"source":case"link":En("error",h),En("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(nt in _)if(_.hasOwnProperty(nt)&&(M=_[nt],M!=null))switch(nt){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,m));default:rr(h,m,nt,M,_,null)}return;default:if(z2(m)){for(lt in _)_.hasOwnProperty(lt)&&(M=_[lt],M!==void 0&&AA(h,m,lt,M,_,void 0));return}}for(fe in _)_.hasOwnProperty(fe)&&(M=_[fe],M!=null&&rr(h,m,fe,M,_,null))}function Kre(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,I=null,Z=null,fe=null,Te=null,nt=null,lt=null;for(ot in _){var pt=_[ot];if(_.hasOwnProperty(ot)&&pt!=null)switch(ot){case"checked":break;case"value":break;case"defaultValue":Te=pt;default:M.hasOwnProperty(ot)||rr(h,m,ot,null,M,pt)}}for(var it in M){var ot=M[it];if(pt=_[it],M.hasOwnProperty(it)&&(ot!=null||pt!=null))switch(it){case"type":I=ot;break;case"name":P=ot;break;case"checked":nt=ot;break;case"defaultChecked":lt=ot;break;case"value":Z=ot;break;case"defaultValue":fe=ot;break;case"children":case"dangerouslySetInnerHTML":if(ot!=null)throw Error(r(137,m));break;default:ot!==pt&&rr(h,m,it,ot,M,pt)}}Mo(h,Z,fe,Te,nt,lt,I,P);return;case"select":ot=Z=fe=it=null;for(I in _)if(Te=_[I],_.hasOwnProperty(I)&&Te!=null)switch(I){case"value":break;case"multiple":ot=Te;default:M.hasOwnProperty(I)||rr(h,m,I,null,M,Te)}for(P in M)if(I=M[P],Te=_[P],M.hasOwnProperty(P)&&(I!=null||Te!=null))switch(P){case"value":it=I;break;case"defaultValue":fe=I;break;case"multiple":Z=I;default:I!==Te&&rr(h,m,P,I,M,Te)}m=fe,_=Z,M=ot,it!=null?xi(h,!!_,it,!1):!!M!=!!_&&(m!=null?xi(h,!!_,m,!0):xi(h,!!_,_?[]:"",!1));return;case"textarea":ot=it=null;for(fe in _)if(P=_[fe],_.hasOwnProperty(fe)&&P!=null&&!M.hasOwnProperty(fe))switch(fe){case"value":break;case"children":break;default:rr(h,m,fe,null,M,P)}for(Z in M)if(P=M[Z],I=_[Z],M.hasOwnProperty(Z)&&(P!=null||I!=null))switch(Z){case"value":it=P;break;case"defaultValue":ot=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==I&&rr(h,m,Z,P,M,I)}Ii(h,it,ot);return;case"option":for(var Ft in _)if(it=_[Ft],_.hasOwnProperty(Ft)&&it!=null&&!M.hasOwnProperty(Ft))switch(Ft){case"selected":h.selected=!1;break;default:rr(h,m,Ft,null,M,it)}for(Te in M)if(it=M[Te],ot=_[Te],M.hasOwnProperty(Te)&&it!==ot&&(it!=null||ot!=null))switch(Te){case"selected":h.selected=it&&typeof it!="function"&&typeof it!="symbol";break;default:rr(h,m,Te,it,M,ot)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Jt in _)it=_[Jt],_.hasOwnProperty(Jt)&&it!=null&&!M.hasOwnProperty(Jt)&&rr(h,m,Jt,null,M,it);for(nt in M)if(it=M[nt],ot=_[nt],M.hasOwnProperty(nt)&&it!==ot&&(it!=null||ot!=null))switch(nt){case"children":case"dangerouslySetInnerHTML":if(it!=null)throw Error(r(137,m));break;default:rr(h,m,nt,it,M,ot)}return;default:if(z2(m)){for(var ir in _)it=_[ir],_.hasOwnProperty(ir)&&it!==void 0&&!M.hasOwnProperty(ir)&&AA(h,m,ir,void 0,M,it);for(lt in M)it=M[lt],ot=_[lt],!M.hasOwnProperty(lt)||it===ot||it===void 0&&ot===void 0||AA(h,m,lt,it,M,ot);return}}for(var Ve in _)it=_[Ve],_.hasOwnProperty(Ve)&&it!=null&&!M.hasOwnProperty(Ve)&&rr(h,m,Ve,null,M,it);for(pt in M)it=M[pt],ot=_[pt],!M.hasOwnProperty(pt)||it===ot||it==null&&ot==null||rr(h,m,pt,it,M,ot)}function nF(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Xre(){if(typeof performance.getEntriesByType=="function"){for(var h=0,m=0,_=performance.getEntriesByType("resource"),M=0;M<_.length;M++){var P=_[M],I=P.transferSize,Z=P.initiatorType,fe=P.duration;if(I&&fe&&nF(Z)){for(Z=0,fe=P.responseEnd,M+=1;M<_.length;M++){var Te=_[M],nt=Te.startTime;if(nt>fe)break;var lt=Te.transferSize,pt=Te.initiatorType;lt&&nF(pt)&&(Te=Te.responseEnd,Z+=lt*(Te<fe?1:(fe-nt)/(Te-nt)))}if(--M,m+=8*(I+Z)/(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 NA=null,TA=null;function pv(h){return h.nodeType===9?h:h.ownerDocument}function rF(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 iF(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 CA(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 kA=null;function Yre(){var h=window.event;return h&&h.type==="popstate"?h===kA?!1:(kA=h,!0):(kA=null,!1)}var aF=typeof setTimeout=="function"?setTimeout:void 0,Zre=typeof clearTimeout=="function"?clearTimeout:void 0,sF=typeof Promise=="function"?Promise:void 0,Qre=typeof queueMicrotask=="function"?queueMicrotask:typeof sF<"u"?function(h){return sF.resolve(null).then(h).catch(Jre)}:aF;function Jre(h){setTimeout(function(){throw h})}function Su(h){return h==="head"}function oF(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),dm(m);return}M--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")M++;else if(_==="html")mx(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,mx(_);for(var I=_.firstChild;I;){var Z=I.nextSibling,fe=I.nodeName;I[rt]||fe==="SCRIPT"||fe==="STYLE"||fe==="LINK"&&I.rel.toLowerCase()==="stylesheet"||_.removeChild(I),I=Z}}else _==="body"&&mx(h.ownerDocument.body);_=P}while(_);dm(m)}function lF(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 PA(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":PA(_),tt(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function eie(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(I=h.getAttribute("rel"),I==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(I!==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(I=h.getAttribute("src"),(I!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&I&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(m==="input"&&h.type==="hidden"){var I=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===I)return h}else return h;if(h=Gs(h.nextSibling),h===null)break}return null}function tie(h,m,_){if(m==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=Gs(h.nextSibling),h===null))return null;return h}function cF(h,m){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!m||(h=Gs(h.nextSibling),h===null))return null;return h}function jA(h){return h.data==="$?"||h.data==="$~"}function RA(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function nie(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 Gs(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 DA=null;function uF(h){h=h.nextSibling;for(var m=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(m===0)return Gs(h.nextSibling);m--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||m++}h=h.nextSibling}return null}function dF(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 hF(h,m,_){switch(m=pv(_),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 mx(h){for(var m=h.attributes;m.length;)h.removeAttributeNode(m[0]);tt(h)}var Ws=new Map,fF=new Set;function gv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var rc=V.d;V.d={f:rie,r:iie,D:aie,C:sie,L:oie,m:lie,X:uie,S:cie,M:die};function rie(){var h=rc.f(),m=ov();return h||m}function iie(h){var m=oe(h);m!==null&&m.tag===5&&m.type==="form"?kI(m):rc.r(h)}var lm=typeof document>"u"?null:document;function mF(h,m,_){var M=lm;if(M&&typeof m=="string"&&m){var P=Gn(m);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),fF.has(P)||(fF.add(P),h={rel:h,crossOrigin:_,href:m},M.querySelector(P)===null&&(m=M.createElement("link"),ta(m,"link",h),Oe(m),M.head.appendChild(m)))}}function aie(h){rc.D(h),mF("dns-prefetch",h,null)}function sie(h,m){rc.C(h,m),mF("preconnect",h,m)}function oie(h,m,_){rc.L(h,m,_);var M=lm;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 I=P;switch(m){case"style":I=cm(h);break;case"script":I=um(h)}Ws.has(I)||(h=f({rel:"preload",href:m==="image"&&_&&_.imageSrcSet?void 0:h,as:m},_),Ws.set(I,h),M.querySelector(P)!==null||m==="style"&&M.querySelector(px(I))||m==="script"&&M.querySelector(gx(I))||(m=M.createElement("link"),ta(m,"link",h),Oe(m),M.head.appendChild(m)))}}function lie(h,m){rc.m(h,m);var _=lm;if(_&&h){var M=m&&typeof m.as=="string"?m.as:"script",P='link[rel="modulepreload"][as="'+Gn(M)+'"][href="'+Gn(h)+'"]',I=P;switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":I=um(h)}if(!Ws.has(I)&&(h=f({rel:"modulepreload",href:h},m),Ws.set(I,h),_.querySelector(P)===null)){switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(gx(I)))return}M=_.createElement("link"),ta(M,"link",h),Oe(M),_.head.appendChild(M)}}}function cie(h,m,_){rc.S(h,m,_);var M=lm;if(M&&h){var P=De(M).hoistableStyles,I=cm(h);m=m||"default";var Z=P.get(I);if(!Z){var fe={loading:0,preload:null};if(Z=M.querySelector(px(I)))fe.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":m},_),(_=Ws.get(I))&&OA(h,_);var Te=Z=M.createElement("link");Oe(Te),ta(Te,"link",h),Te._p=new Promise(function(nt,lt){Te.onload=nt,Te.onerror=lt}),Te.addEventListener("load",function(){fe.loading|=1}),Te.addEventListener("error",function(){fe.loading|=2}),fe.loading|=4,xv(Z,m,M)}Z={type:"stylesheet",instance:Z,count:1,state:fe},P.set(I,Z)}}}function uie(h,m){rc.X(h,m);var _=lm;if(_&&h){var M=De(_).hoistableScripts,P=um(h),I=M.get(P);I||(I=_.querySelector(gx(P)),I||(h=f({src:h,async:!0},m),(m=Ws.get(P))&&LA(h,m),I=_.createElement("script"),Oe(I),ta(I,"link",h),_.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},M.set(P,I))}}function die(h,m){rc.M(h,m);var _=lm;if(_&&h){var M=De(_).hoistableScripts,P=um(h),I=M.get(P);I||(I=_.querySelector(gx(P)),I||(h=f({src:h,async:!0,type:"module"},m),(m=Ws.get(P))&&LA(h,m),I=_.createElement("script"),Oe(I),ta(I,"link",h),_.head.appendChild(I)),I={type:"script",instance:I,count:1,state:null},M.set(P,I))}}function pF(h,m,_,M){var P=(P=de.current)?gv(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=cm(_.href),_=De(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=cm(_.href);var I=De(P).hoistableStyles,Z=I.get(h);if(Z||(P=P.ownerDocument||P,Z={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},I.set(h,Z),(I=P.querySelector(px(h)))&&!I._p&&(Z.instance=I,Z.state.loading=5),Ws.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Ws.set(h,_),I||hie(P,h,_,Z.state))),m&&M===null)throw Error(r(528,""));return Z}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=um(_),_=De(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 cm(h){return'href="'+Gn(h)+'"'}function px(h){return'link[rel="stylesheet"]['+h+"]"}function gF(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function hie(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}),ta(m,"link",_),Oe(m),h.head.appendChild(m))}function um(h){return'[src="'+Gn(h)+'"]'}function gx(h){return"script[async]"+h}function xF(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,Oe(M),M;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return M=(h.ownerDocument||h).createElement("style"),Oe(M),ta(M,"style",P),xv(M,_.precedence,h),m.instance=M;case"stylesheet":P=cm(_.href);var I=h.querySelector(px(P));if(I)return m.state.loading|=4,m.instance=I,Oe(I),I;M=gF(_),(P=Ws.get(P))&&OA(M,P),I=(h.ownerDocument||h).createElement("link"),Oe(I);var Z=I;return Z._p=new Promise(function(fe,Te){Z.onload=fe,Z.onerror=Te}),ta(I,"link",M),m.state.loading|=4,xv(I,_.precedence,h),m.instance=I;case"script":return I=um(_.src),(P=h.querySelector(gx(I)))?(m.instance=P,Oe(P),P):(M=_,(P=Ws.get(I))&&(M=f({},_),LA(M,P)),h=h.ownerDocument||h,P=h.createElement("script"),Oe(P),ta(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,xv(M,_.precedence,h));return m.instance}function xv(h,m,_){for(var M=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=M.length?M[M.length-1]:null,I=P,Z=0;Z<M.length;Z++){var fe=M[Z];if(fe.dataset.precedence===m)I=fe;else if(I!==P)break}I?I.parentNode.insertBefore(h,I.nextSibling):(m=_.nodeType===9?_.head:_,m.insertBefore(h,m.firstChild))}function OA(h,m){h.crossOrigin==null&&(h.crossOrigin=m.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=m.referrerPolicy),h.title==null&&(h.title=m.title)}function LA(h,m){h.crossOrigin==null&&(h.crossOrigin=m.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=m.referrerPolicy),h.integrity==null&&(h.integrity=m.integrity)}var bv=null;function bF(h,m,_){if(bv===null){var M=new Map,P=bv=new Map;P.set(_,M)}else P=bv,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 I=_[P];if(!(I[rt]||I[Kt]||h==="link"&&I.getAttribute("rel")==="stylesheet")&&I.namespaceURI!=="http://www.w3.org/2000/svg"){var Z=I.getAttribute(m)||"";Z=h+Z;var fe=M.get(Z);fe?fe.push(I):M.set(Z,[I])}}return M}function yF(h,m,_){h=h.ownerDocument||h,h.head.insertBefore(_,m==="title"?h.querySelector("head > title"):null)}function fie(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 vF(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function mie(h,m,_,M){if(_.type==="stylesheet"&&(typeof M.media!="string"||matchMedia(M.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var P=cm(M.href),I=m.querySelector(px(P));if(I){m=I._p,m!==null&&typeof m=="object"&&typeof m.then=="function"&&(h.count++,h=yv.bind(h),m.then(h,h)),_.state.loading|=4,_.instance=I,Oe(I);return}I=m.ownerDocument||m,M=gF(M),(P=Ws.get(P))&&OA(M,P),I=I.createElement("link"),Oe(I);var Z=I;Z._p=new Promise(function(fe,Te){Z.onload=fe,Z.onerror=Te}),ta(I,"link",M),_.instance=I}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,m),(m=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=yv.bind(h),m.addEventListener("load",_),m.addEventListener("error",_))}}var IA=0;function pie(h,m){return h.stylesheets&&h.count===0&&_v(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var M=setTimeout(function(){if(h.stylesheets&&_v(h,h.stylesheets),h.unsuspend){var I=h.unsuspend;h.unsuspend=null,I()}},6e4+m);0<h.imgBytes&&IA===0&&(IA=62500*Xre());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&_v(h,h.stylesheets),h.unsuspend)){var I=h.unsuspend;h.unsuspend=null,I()}},(h.imgBytes>IA?50:800)+m);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(M),clearTimeout(P)}}:null}function yv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)_v(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var vv=null;function _v(h,m){h.stylesheets=null,h.unsuspend!==null&&(h.count++,vv=new Map,m.forEach(gie,h),vv=null,yv.call(h))}function gie(h,m){if(!(m.state.loading&4)){var _=vv.get(h);if(_)var M=_.get(null);else{_=new Map,vv.set(h,_);for(var P=h.querySelectorAll("link[data-precedence],style[data-precedence]"),I=0;I<P.length;I++){var Z=P[I];(Z.nodeName==="LINK"||Z.getAttribute("media")!=="not all")&&(_.set(Z.dataset.precedence,Z),M=Z)}M&&_.set(null,M)}P=m.instance,Z=P.getAttribute("data-precedence"),I=_.get(Z)||M,I===M&&_.set(null,P),_.set(Z,P),this.count++,M=yv.bind(this),P.addEventListener("load",M),P.addEventListener("error",M),I?I.parentNode.insertBefore(P,I.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),m.state.loading|=4}}var xx={$$typeof:w,Provider:null,Consumer:null,_currentValue:K,_currentValue2:K,_threadCount:0};function xie(h,m,_,M,P,I,Z,fe,Te){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=Et(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Et(0),this.hiddenUpdates=Et(null),this.identifierPrefix=M,this.onUncaughtError=P,this.onCaughtError=I,this.onRecoverableError=Z,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Te,this.incompleteTransitions=new Map}function _F(h,m,_,M,P,I,Z,fe,Te,nt,lt,pt){return h=new xie(h,m,_,Z,Te,nt,lt,pt,fe),m=1,I===!0&&(m|=24),I=gs(3,null,null,m),h.current=I,I.stateNode=h,m=gE(),m.refCount++,h.pooledCache=m,m.refCount++,I.memoizedState={element:M,isDehydrated:_,cache:m},vE(I),h}function wF(h){return h?(h=Bf,h):Bf}function SF(h,m,_,M,P,I){P=wF(P),M.context===null?M.context=P:M.pendingContext=P,M=hu(m),M.payload={element:_},I=I===void 0?null:I,I!==null&&(M.callback=I),_=fu(h,M,m),_!==null&&(Za(_,h,m),Xg(_,h,m))}function MF(h,m){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<m?_:m}}function FA(h,m){MF(h,m),(h=h.alternate)&&MF(h,m)}function EF(h){if(h.tag===13||h.tag===31){var m=Xd(h,67108864);m!==null&&Za(m,h,67108864),FA(h,67108864)}}function AF(h){if(h.tag===13||h.tag===31){var m=_s();m=tr(m);var _=Xd(h,m);_!==null&&Za(_,h,m),FA(h,m)}}var wv=!0;function bie(h,m,_,M){var P=Y.T;Y.T=null;var I=V.p;try{V.p=2,UA(h,m,_,M)}finally{V.p=I,Y.T=P}}function yie(h,m,_,M){var P=Y.T;Y.T=null;var I=V.p;try{V.p=8,UA(h,m,_,M)}finally{V.p=I,Y.T=P}}function UA(h,m,_,M){if(wv){var P=zA(M);if(P===null)EA(h,m,M,Sv,_),TF(h,M);else if(_ie(P,h,m,_,M))M.stopPropagation();else if(TF(h,M),m&4&&-1<vie.indexOf(h)){for(;P!==null;){var I=oe(P);if(I!==null)switch(I.tag){case 3:if(I=I.stateNode,I.current.memoizedState.isDehydrated){var Z=Pe(I.pendingLanes);if(Z!==0){var fe=I;for(fe.pendingLanes|=2,fe.entangledLanes|=2;Z;){var Te=1<<31-Ke(Z);fe.entanglements[1]|=Te,Z&=~Te}il(I),(Hn&6)===0&&(av=j()+500,dx(0))}}break;case 31:case 13:fe=Xd(I,2),fe!==null&&Za(fe,I,2),ov(),FA(I,2)}if(I=zA(M),I===null&&EA(h,m,M,Sv,_),I===P)break;P=I}P!==null&&M.stopPropagation()}else EA(h,m,M,null,_)}}function zA(h){return h=H2(h),BA(h)}var Sv=null;function BA(h){if(Sv=null,h=yt(h),h!==null){var m=a(h);if(m===null)h=null;else{var _=m.tag;if(_===13){if(h=o(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 Sv=h,null}function NF(h){switch(h){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ne()){case be:return 2;case we:return 8;case ve:case $e:return 32;case Ge:return 268435456;default:return 32}default:return 32}}var HA=!1,Mu=null,Eu=null,Au=null,bx=new Map,yx=new Map,Nu=[],vie="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 TF(h,m){switch(h){case"focusin":case"focusout":Mu=null;break;case"dragenter":case"dragleave":Eu=null;break;case"mouseover":case"mouseout":Au=null;break;case"pointerover":case"pointerout":bx.delete(m.pointerId);break;case"gotpointercapture":case"lostpointercapture":yx.delete(m.pointerId)}}function vx(h,m,_,M,P,I){return h===null||h.nativeEvent!==I?(h={blockedOn:m,domEventName:_,eventSystemFlags:M,nativeEvent:I,targetContainers:[P]},m!==null&&(m=oe(m),m!==null&&EF(m)),h):(h.eventSystemFlags|=M,m=h.targetContainers,P!==null&&m.indexOf(P)===-1&&m.push(P),h)}function _ie(h,m,_,M,P){switch(m){case"focusin":return Mu=vx(Mu,h,m,_,M,P),!0;case"dragenter":return Eu=vx(Eu,h,m,_,M,P),!0;case"mouseover":return Au=vx(Au,h,m,_,M,P),!0;case"pointerover":var I=P.pointerId;return bx.set(I,vx(bx.get(I)||null,h,m,_,M,P)),!0;case"gotpointercapture":return I=P.pointerId,yx.set(I,vx(yx.get(I)||null,h,m,_,M,P)),!0}return!1}function CF(h){var m=yt(h.target);if(m!==null){var _=a(m);if(_!==null){if(m=_.tag,m===13){if(m=o(_),m!==null){h.blockedOn=m,Qt(h.priority,function(){AF(_)});return}}else if(m===31){if(m=l(_),m!==null){h.blockedOn=m,Qt(h.priority,function(){AF(_)});return}}else if(m===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function Mv(h){if(h.blockedOn!==null)return!1;for(var m=h.targetContainers;0<m.length;){var _=zA(h.nativeEvent);if(_===null){_=h.nativeEvent;var M=new _.constructor(_.type,_);B2=M,_.target.dispatchEvent(M),B2=null}else return m=oe(_),m!==null&&EF(m),h.blockedOn=_,!1;m.shift()}return!0}function kF(h,m,_){Mv(h)&&_.delete(m)}function wie(){HA=!1,Mu!==null&&Mv(Mu)&&(Mu=null),Eu!==null&&Mv(Eu)&&(Eu=null),Au!==null&&Mv(Au)&&(Au=null),bx.forEach(kF),yx.forEach(kF)}function Ev(h,m){h.blockedOn===m&&(h.blockedOn=null,HA||(HA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,wie)))}var Av=null;function PF(h){Av!==h&&(Av=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Av===h&&(Av=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(BA(M||_)===null)continue;break}var I=oe(_);I!==null&&(h.splice(m,3),m-=3,zE(I,{pending:!0,data:P,method:_.method,action:M},M,P))}}))}function dm(h){function m(Te){return Ev(Te,h)}Mu!==null&&Ev(Mu,h),Eu!==null&&Ev(Eu,h),Au!==null&&Ev(Au,h),bx.forEach(m),yx.forEach(m);for(var _=0;_<Nu.length;_++){var M=Nu[_];M.blockedOn===h&&(M.blockedOn=null)}for(;0<Nu.length&&(_=Nu[0],_.blockedOn===null);)CF(_),_.blockedOn===null&&Nu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(M=0;M<_.length;M+=3){var P=_[M],I=_[M+1],Z=P[dn]||null;if(typeof I=="function")Z||PF(_);else if(Z){var fe=null;if(I&&I.hasAttribute("formAction")){if(P=I,Z=I[dn]||null)fe=Z.formAction;else if(BA(P)!==null)continue}else fe=Z.action;typeof fe=="function"?_[M+1]=fe:(_.splice(M,3),M-=3),PF(_)}}}function jF(){function h(I){I.canIntercept&&I.info==="react-transition"&&I.intercept({handler:function(){return new Promise(function(Z){return P=Z})},focusReset:"manual",scroll:"manual"})}function m(){P!==null&&(P(),P=null),M||setTimeout(_,20)}function _(){if(!M&&!navigation.transition){var I=navigation.currentEntry;I&&I.url!=null&&navigation.navigate(I.url,{state:I.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 $A(h){this._internalRoot=h}Nv.prototype.render=$A.prototype.render=function(h){var m=this._internalRoot;if(m===null)throw Error(r(409));var _=m.current,M=_s();SF(_,M,h,m,null,null)},Nv.prototype.unmount=$A.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var m=h.containerInfo;SF(h.current,2,null,h,null,null),ov(),m[Ht]=null}};function Nv(h){this._internalRoot=h}Nv.prototype.unstable_scheduleHydration=function(h){if(h){var m=Vt();h={blockedOn:null,target:h,priority:m};for(var _=0;_<Nu.length&&m!==0&&m<Nu[_].priority;_++);Nu.splice(_,0,h),_===0&&CF(h)}};var RF=e.version;if(RF!=="19.2.0")throw Error(r(527,RF,"19.2.0"));V.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 Sie={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:Y,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Tv=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Tv.isDisabled&&Tv.supportsFiber)try{He=Tv.inject(Sie),me=Tv}catch{}}return wx.createRoot=function(h,m){if(!i(h))throw Error(r(299));var _=!1,M="",P=zI,I=BI,Z=HI;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&&(I=m.onCaughtError),m.onRecoverableError!==void 0&&(Z=m.onRecoverableError)),m=_F(h,1,!1,null,null,_,M,null,P,I,Z,jF),h[Ht]=m.current,MA(h),new $A(m)},wx.hydrateRoot=function(h,m,_){if(!i(h))throw Error(r(299));var M=!1,P="",I=zI,Z=BI,fe=HI,Te=null;return _!=null&&(_.unstable_strictMode===!0&&(M=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(I=_.onUncaughtError),_.onCaughtError!==void 0&&(Z=_.onCaughtError),_.onRecoverableError!==void 0&&(fe=_.onRecoverableError),_.formState!==void 0&&(Te=_.formState)),m=_F(h,1,!0,m,_??null,M,P,Te,I,Z,fe,jF),m.context=wF(null),_=m.current,M=_s(),M=tr(M),P=hu(M),P.callback=null,fu(_,P,M),_=M,m.current.lanes=_,Zt(m,_),il(m),h[Ht]=m.current,MA(h),new Nv(m)},wx.version="19.2.0",wx}var $F;function Die(){if($F)return WA.exports;$F=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(),WA.exports=Rie(),WA.exports}var Oie=Die();const tn=t=>typeof t=="string",Sx=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},VF=t=>t==null?"":""+t,Lie=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Iie=/###/g,GF=t=>t&&t.indexOf("###")>-1?t.replace(Iie,"."):t,WF=t=>!t||tn(t),d0=(t,e,n)=>{const r=tn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(WF(t))return{};const a=GF(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return WF(t)?{}:{obj:t,k:GF(r[i])}},qF=(t,e,n)=>{const{obj:r,k:i}=d0(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let a=e[e.length-1],o=e.slice(0,e.length-1),l=d0(t,o,Object);for(;l.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),l=d0(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},Fie=(t,e,n,r)=>{const{obj:i,k:a}=d0(t,e,Object);i[a]=i[a]||[],i[a].push(n)},H1=(t,e)=>{const{obj:n,k:r}=d0(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Uie=(t,e,n)=>{const r=H1(t,n);return r!==void 0?r:H1(e,n)},f9=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?tn(t[r])||t[r]instanceof String||tn(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):f9(t[r],e[r],n):t[r]=e[r]);return t},hm=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var zie={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Bie=t=>tn(t)?t.replace(/[&<>"'\/]/g,e=>zie[e]):t;class Hie{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 $ie=[" ",",","?","!",";"],Vie=new Hie(20),Gie=(t,e,n)=>{e=e||"",n=n||"";const r=$ie.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=Vie.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let a=!i.test(t);if(!a){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(a=!0)}return a},Wk=(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 o,l="";for(let c=a;c<r.length;++c)if(c!==a&&(l+=n),l+=r[c],o=i[l],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&c<r.length-1)continue;a+=c-a+1;break}i=o}return i},O0=t=>t?.replace("_","-"),Wie={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 $1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Wie,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:(tn(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new $1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new $1(this.logger,e)}}var gl=new $1;let iM=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 o=0;o<a;o++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,a])=>{for(let o=0;o<a;o++)i.apply(i,[e,...n])})}};class KF extends iM{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,o=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):tn(r)&&a?l.push(...r.split(a)):l.push(r)));const c=H1(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!tn(r)?c:Wk(this.data?.[e]?.[n],r,a)}addResource(e,n,r,i,a={silent:!1}){const o=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let l=[e,n];r&&(l=l.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(l=e.split("."),i=n,n=l[1]),this.addNamespaces(n),qF(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)(tn(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,o={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=H1(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?f9(c,r,a):c={...c,...r},qF(this.data,l,c),o.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 m9={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 p9=Symbol("i18next/PATH_KEY");function qie(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===p9?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function qk(t,e){const{[p9]:n}=t(qie());return n.join(e?.keySeparator??".")}const XF={},YA=t=>!tn(t)&&typeof t!="boolean"&&typeof t!="number";class V1 extends iM{constructor(e,n={}){super(),Lie(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=gl.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=YA(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 o=r&&e.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Gie(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:tn(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:tn(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=qk(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const a=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return g?a?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const p=this.resolve(e,i);let x=p?.res;const y=p?.usedKey||l,b=p?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],E=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,N=i.count!==void 0&&!tn(i.count),A=V1.hasDefaultValue(i),C=N?this.pluralResolver.getSuffix(f,i.count,i):"",T=i.ordinal&&N?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",L=N&&!i.ordinal&&i.count===0,k=L&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${C}`]||i[`defaultValue${T}`]||i.defaultValue;let D=x;w&&!x&&A&&(D=k);const U=YA(D),O=Object.prototype.toString.apply(D);if(w&&D&&U&&v.indexOf(O)<0&&!(tn(E)&&Array.isArray(D))){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(y,D,{...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(o){const q=Array.isArray(D),R=q?[]:{},G=q?b:y;for(const Y in D)if(Object.prototype.hasOwnProperty.call(D,Y)){const V=`${G}${o}${Y}`;A&&!x?R[Y]=this.translate(V,{...i,defaultValue:YA(k)?k[Y]:void 0,joinArrays:!1,ns:c}):R[Y]=this.translate(V,{...i,joinArrays:!1,ns:c}),R[Y]===V&&(R[Y]=D[Y])}x=R}}else if(w&&tn(E)&&Array.isArray(x))x=x.join(E),x&&(x=this.extendTranslation(x,e,i,r));else{let q=!1,R=!1;!this.isValidLookup(x)&&A&&(q=!0,x=k),this.isValidLookup(x)||(R=!0,x=l);const Y=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&R?void 0:x,V=A&&k!==x&&this.options.updateMissing;if(R||q||V){if(this.logger.log(V?"updateKey":"missingKey",f,u,l,V?k:x),o){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 K=[];const J=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&J&&J[0])for(let F=0;F<J.length;F++)K.push(J[F]);else this.options.saveMissingTo==="all"?K=this.languageUtils.toResolveHierarchy(i.lng||this.language):K.push(i.lng||this.language);const X=(F,W,ee)=>{const ie=A&&ee!==x?ee:Y;this.options.missingKeyHandler?this.options.missingKeyHandler(F,u,W,ie,V,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(F,u,W,ie,V,i),this.emit("missingKey",F,u,W,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?K.forEach(F=>{const W=this.pluralResolver.getSuffixes(F,i);L&&i[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(ee=>{X([F],l+ee,i[`defaultValue${ee}`]||k)})}):X(K,l,k))}x=this.extendTranslation(x,e,i,p,r),R&&x===l&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${l}`),(R||q)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,q?x:void 0,i))}return a?(p.res=x,p.usedParams=this.getUsedParamsDetails(i),p):x}extendTranslation(e,n,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=tn(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&&!tn(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 o=r.postProcess||this.options.postProcess,l=tn(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=m9.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,o,l;return tn(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&&!tn(n.count),p=g&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(tn(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(b=>{this.isValidLookup(r)||(l=b,!XF[`${y[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(XF[`${y[0]}-${b}`]=!0,this.logger.warn(`key "${i}" for languages "${y.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!!!")),y.forEach(v=>{if(this.isValidLookup(r))return;o=v;const E=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(E,d,v,b,n);else{let N;g&&(N=this.pluralResolver.getSuffix(v,n.count,n));const A=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(g&&(n.ordinal&&N.indexOf(C)===0&&E.push(d+N.replace(C,this.options.pluralSeparator)),E.push(d+N),p&&E.push(d+A)),x){const T=`${d}${this.options.contextSeparator||"_"}${n.context}`;E.push(T),g&&(n.ordinal&&N.indexOf(C)===0&&E.push(T+N.replace(C,this.options.pluralSeparator)),E.push(T+N),p&&E.push(T+A))}}let w;for(;w=E.pop();)this.isValidLookup(r)||(a=w,r=this.getResource(v,b,w,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,usedLng:o,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&&!tn(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 YF{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=gl.create("languageUtils")}getScriptPartFromCode(e){if(e=O0(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=O0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(tn(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(o=>{if(o===a)return o;if(!(o.indexOf("-")<0&&a.indexOf("-")<0)&&(o.indexOf("-")>0&&a.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===a||o.indexOf(a)===0&&a.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),tn(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=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return tn(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))):tn(e)&&a(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&a(this.formatLanguageCode(o))}),i}}const ZF={zero:0,one:1,two:2,few:3,many:4,other:5},QF={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Kie{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=gl.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=O0(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 o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),QF;if(!e.match(/-|_/))return QF;const c=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(c,n)}return this.pluralRulesCache[a]=o,o}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)=>ZF[i]-ZF[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 JF=(t,e,n,r=".",i=!0)=>{let a=Uie(t,e,n);return!a&&i&&tn(n)&&(a=Wk(t,n,r),a===void 0&&(a=Wk(e,n,r))),a},ZA=t=>t.replace(/\$/g,"$$$$");class Xie{constructor(e={}){this.logger=gl.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:o,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:g,nestingPrefixEscaped:p,nestingSuffix:x,nestingSuffixEscaped:y,nestingOptionsSeparator:b,maxReplaces:v,alwaysFormat:E}=e.interpolation;this.escape=n!==void 0?n:Bie,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?hm(a):o||"{{",this.suffix=l?hm(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=g?hm(g):p||hm("$t("),this.nestingSuffix=x?hm(x):y||hm(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=v||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,o,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=p=>{if(p.indexOf(this.formatSeparator)<0){const v=JF(n,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,r,{...i,...n,interpolationkey:p}):v}const x=p.split(this.formatSeparator),y=x.shift().trim(),b=x.join(this.formatSeparator).trim();return this.format(JF(n,c,y,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...i,...n,interpolationkey:y})};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=>ZA(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?ZA(this.escape(p)):ZA(p)}].forEach(p=>{for(l=0;a=p.regex.exec(e);){const x=a[1].trim();if(o=u(x),o===void 0)if(typeof d=="function"){const b=d(e,a,i);o=tn(b)?b:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))o="";else if(f){o=a[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),o="";else!tn(o)&&!this.useRawValueToEscape&&(o=VF(o));const y=p.safeValue(o);if(e=e.replace(a[0],y),f?(p.regex.lastIndex+=o.length,p.regex.lastIndex-=a[0].length):p.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,o;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,o);const p=g.match(/'/g),x=g.match(/"/g);((p?.length??0)%2===0&&!x||x.length%2!==0)&&(g=g.replace(/'/g,'"'));try{o=JSON.parse(g),u&&(o={...u,...o})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,y),`${c}${d}${g}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];o={...r},o=o.replace&&!tn(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.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(),o),o),a&&i[0]===e&&!tn(a))return a;tn(a)||(a=VF(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 Yie=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(o=>{if(o){const[l,...c]=o.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}},eU=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 o=r+JSON.stringify(a);let l=e[o];return l||(l=t(O0(r),i),e[o]=l),l(n)}},Zie=t=>(e,n,r)=>t(O0(n),r)(e);class Qie{constructor(e={}){this.logger=gl.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?eU:Zie;this.formats={number:r((i,a)=>{const o=new Intl.NumberFormat(i,{...a});return l=>o.format(l)}),currency:r((i,a)=>{const o=new Intl.NumberFormat(i,{...a,style:"currency"});return l=>o.format(l)}),datetime:r((i,a)=>{const o=new Intl.DateTimeFormat(i,{...a});return l=>o.format(l)}),relativetime:r((i,a)=>{const o=new Intl.RelativeTimeFormat(i,{...a});return l=>o.format(l,a.range||"day")}),list:r((i,a)=>{const o=new Intl.ListFormat(i,{...a});return l=>o.format(l)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=eU(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}=Yie(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 Jie=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class eae extends iM{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=gl.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={},o={},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?o[g]===void 0&&(o[g]=!0):(this.state[g]=1,d=!1,o[g]===void 0&&(o[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(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(o),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),a=i[0],o=i[1];n&&this.emit("failedLoading",a,o,n),!n&&r&&this.store.addResourceBundle(a,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const l={};this.queue.forEach(c=>{Fie(c.loaded,[a],o),Jie(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,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:a,callback:o});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,o)},a);return}o(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();tn(e)&&(e=this.languageUtils.toResolveHierarchy(e)),tn(n)&&(n=[n]);const a=this.queueLoad(e,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(o=>{this.loadOne(o)})}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,(o,l)=>{o&&this.logger.warn(`${n}loading namespace ${a} for language ${i} failed`,o),!o&&l&&this.logger.log(`${n}loaded namespace ${a} for language ${i}`,l),this.loaded(e,o,l)})}saveMissing(e,n,r,i,a,o={},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={...o,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 tU=()=>({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]),tn(t[1])&&(e.defaultValue=t[1]),tn(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}),nU=t=>(tn(t.ns)&&(t.ns=[t.ns]),tn(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),tn(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),kv=()=>{},tae=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class h0 extends iM{constructor(e={},n){if(super(),this.options=nU(e),this.services={},this.logger=gl,this.modules={external:[]},tae(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&&(tn(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=tU();this.options={...r,...this.options,...nU(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?gl.init(i(this.modules.logger),this.options):gl.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Qie;const d=new YF(this.options);this.store=new KF(this.options.resources,this.options);const f=this.services;f.logger=gl,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new Kie(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 Xie(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new eae(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(p,...x)=>{this.emit(p,...x)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new V1(this.services,this.options),this.translator.on("*",(p,...x)=>{this.emit(p,...x)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,n||(n=kv),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=Sx(),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=kv){let r=n;const i=tn(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=[],o=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&a.indexOf(u)<0&&a.push(u)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>o(c)),this.options.preload?.forEach?.(l=>o(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=Sx();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=kv),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"&&m9.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=Sx();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))},o=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);const c=tn(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(tn(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?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),r}getFixedT(e,n,r){const i=(a,o,...l)=>{let c;typeof o!="object"?c=this.options.overloadTranslationOptionHandler([a,o].concat(l)):c={...o},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=qk(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=qk(a,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return tn(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 o=(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,o);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(a,e)))}loadNamespaces(e,n){const r=Sx();return this.options.ns?(tn(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=Sx();tn(e)&&(e=[e]);const i=this.options.preload||[],a=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return a.length?(this.options.preload=i.concat(a),this.loadResources(o=>{r.resolve(),n&&n(o)}),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 YF(tU());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 h0(e,n);return r.createInstance=h0.createInstance,r}cloneInstance(e={},n=kv){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new h0(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 KF(l,i),a.services.resourceStore=a.store}return a.translator=new V1(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 Va=h0.createInstance();Va.createInstance;Va.dir;Va.init;Va.loadResources;Va.reloadResources;Va.use;Va.changeLanguage;Va.getFixedT;Va.t;Va.exists;Va.setDefaultNamespace;Va.hasLoadedNamespace;Va.loadNamespaces;Va.loadLanguages;const nae=(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);ef(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},rU={},g9=(t,e,n,r)=>{ef(n)&&rU[n]||(ef(n)&&(rU[n]=new Date),nae(t,e,n,r))},x9=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},Kk=(t,e,n)=>{t.loadNamespaces(e,x9(t,n))},iU=(t,e,n,r)=>{if(ef(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return Kk(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,x9(t,r))},rae=(t,e,n={})=>!e.languages||!e.languages.length?(g9(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}}),ef=t=>typeof t=="string",iae=t=>typeof t=="object"&&t!==null,aae=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,sae={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},oae=t=>sae[t],lae=t=>t.replace(aae,oae);let Xk={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:lae};const cae=(t={})=>{Xk={...Xk,...t}},uae=()=>Xk;let b9;const dae=t=>{b9=t},hae=()=>b9,fae={type:"3rdParty",init(t){cae(t.options.react),dae(t)}},mae=S.createContext();class pae{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var QA={exports:{}},JA={};var aU;function gae(){if(aU)return JA;aU=1;var t=og();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,o=t.useDebugValue;function l(f,g){var p=g(),x=r({inst:{value:p,getSnapshot:g}}),y=x[0].inst,b=x[1];return a(function(){y.value=p,y.getSnapshot=g,c(y)&&b({inst:y})},[f,p,g]),i(function(){return c(y)&&b({inst:y}),f(function(){c(y)&&b({inst:y})})},[f]),o(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 JA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,JA}var sU;function y9(){return sU||(sU=1,QA.exports=gae()),QA.exports}var iR=y9();const xae=(t,e)=>ef(e)?e:iae(e)&&ef(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,bae={t:xae,ready:!1},yae=()=>()=>{},lg=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=S.useContext(mae)||{},a=n||r||hae();a&&!a.reportNamespaces&&(a.reportNamespaces=new pae),a||g9(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=S.useMemo(()=>({...uae(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=o,u=i||a?.options?.defaultNS,d=ef(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 yae;const{bindI18n:D,bindI18nStore:U}=o,O=()=>{g.current+=1,k()};return D&&a.on(D,O),U&&a.store.on(U,O),()=>{D&&D.split(" ").forEach(q=>a.off(q,O)),U&&U.split(" ").forEach(q=>a.store.off(q,O))}},[a,o]),x=S.useRef(),y=S.useCallback(()=>{if(!a)return bae;const k=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(G=>rae(G,a,o)),D=e.lng||a.language,U=g.current,O=x.current;if(O&&O.ready===k&&O.lng===D&&O.keyPrefix===c&&O.revision===U)return O;const R={t:a.getFixedT(D,o.nsMode==="fallback"?f:f[0],c),ready:k,lng:D,keyPrefix:c,revision:U};return x.current=R,R},[a,f,c,o,e.lng]),[b,v]=S.useState(0),{t:E,ready:w}=iR.useSyncExternalStore(p,y,y);S.useEffect(()=>{if(a&&!w&&!l){const k=()=>v(D=>D+1);e.lng?iU(a,e.lng,f,k):Kk(a,f,k)}},[a,e.lng,f,w,l,b]);const N=a||{},A=S.useRef(null),C=S.useRef(),T=k=>{const D=Object.getOwnPropertyDescriptors(k);D.__original&&delete D.__original;const U=Object.create(Object.getPrototypeOf(k),D);if(!Object.prototype.hasOwnProperty.call(U,"__original"))try{Object.defineProperty(U,"__original",{value:k,writable:!1,enumerable:!1,configurable:!1})}catch{}return U},L=S.useMemo(()=>{const k=N,D=k?.language;let U=k;k&&(A.current&&A.current.__original===k?C.current!==D?(U=T(k),A.current=U,C.current=D):U=A.current:(U=T(k),A.current=U,C.current=D));const O=[E,U,w];return O.t=E,O.i18n=U,O.ready=w,O},[E,N,w,N.resolvedLanguage,N.language,N.languages]);if(a&&l&&!w)throw new Promise(k=>{const D=()=>k();e.lng?iU(a,e.lng,f,D):Kk(a,f,D)});return L},{slice:vae,forEach:_ae}=[];function wae(t){return _ae.call(vae.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Sae(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 oU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Mae=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 o=r.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");a+=`; Max-Age=${Math.floor(o)}`}if(r.domain){if(!oU.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!oU.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},lU={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=Mae(t,e,i)},read(t){const e=`${t}=`,n=document.cookie.split(";");for(let r=0;r<n.length;r++){let i=n[r];for(;i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return i.substring(e.length,i.length)}return null},remove(t,e){this.create(t,"",-1,e)}};var Eae={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return lU.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&lU.create(n,t,r,i,a)}},Aae={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 o=0;o<a.length;o++){const l=a[o].indexOf("=");l>0&&a[o].substring(0,l)===e&&(n=a[o].substring(l+1))}}return n}},Nae={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,r;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const a=i.substring(1);if(e){const o=a.split("&");for(let l=0;l<o.length;l++){const c=o[l].indexOf("=");c>0&&o[l].substring(0,c)===e&&(r=o[l].substring(c+1))}}if(r)return r;if(!r&&n>-1){const o=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(o)?o[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return r}};let fm=null;const cU=()=>{if(fm!==null)return fm;try{if(fm=typeof window<"u"&&window.localStorage!==null,!fm)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{fm=!1}return fm};var Tae={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&cU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&cU()&&window.localStorage.setItem(n,t)}};let mm=null;const uU=()=>{if(mm!==null)return mm;try{if(mm=typeof window<"u"&&window.sessionStorage!==null,!mm)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{mm=!1}return mm};var Cae={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&uU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&uU()&&window.sessionStorage.setItem(n,t)}},kae={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}},Pae={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}},jae={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}},Rae={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 v9=!1;try{document.cookie,v9=!0}catch{}const _9=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];v9||_9.splice(1,1);const Dae=()=>({order:_9,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class w9{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=wae(n,this.options||{},Dae()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=i=>i.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=r,this.addDetector(Eae),this.addDetector(Aae),this.addDetector(Tae),this.addDetector(Cae),this.addDetector(kae),this.addDetector(Pae),this.addDetector(jae),this.addDetector(Rae),this.addDetector(Nae)}addDetector(e){return this.detectors[e.name]=e,this}detect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,n=[];return e.forEach(r=>{if(this.detectors[r]){let i=this.detectors[r].lookup(this.options);i&&typeof i=="string"&&(i=[i]),i&&(n=n.concat(i))}}),n=n.filter(r=>r!=null&&!Sae(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)}))}}w9.type="languageDetector";const Oae={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?"}},Lae={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?"}},Iae={en:{translation:Oae},de:{translation:Lae}};Va.use(w9).use(fae).init({resources:Iae,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const dU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var hU="popstate";function Fae(t={}){function e(r,i){let{pathname:a,search:o,hash:l}=r.location;return Yk("",{pathname:a,search:o,hash:l},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:L0(i)}return zae(e,n,null,t)}function Dr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Go(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Uae(){return Math.random().toString(36).substring(2,10)}function fU(t,e){return{usr:t.state,key:t.key,idx:e}}function Yk(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?cg(e):e,state:n,key:e&&e.key||r||Uae()}}function L0({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 cg(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 zae(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,l="POP",c=null,u=d();u==null&&(u=0,o.replaceState({...o.state,idx:u},""));function d(){return(o.state||{idx:null}).idx}function f(){l="POP";let b=d(),v=b==null?null:b-u;u=b,c&&c({action:l,location:y.location,delta:v})}function g(b,v){l="PUSH";let E=Yk(y.location,b,v);u=d()+1;let w=fU(E,u),N=y.createHref(E);try{o.pushState(w,"",N)}catch(A){if(A instanceof DOMException&&A.name==="DataCloneError")throw A;i.location.assign(N)}a&&c&&c({action:l,location:y.location,delta:1})}function p(b,v){l="REPLACE";let E=Yk(y.location,b,v);u=d();let w=fU(E,u),N=y.createHref(E);o.replaceState(w,"",N),a&&c&&c({action:l,location:y.location,delta:0})}function x(b){return Bae(b)}let y={get action(){return l},get location(){return t(i,o)},listen(b){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(hU,f),c=b,()=>{i.removeEventListener(hU,f),c=null}},createHref(b){return e(i,b)},createURL:x,encodeLocation(b){let v=x(b);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:g,replace:p,go(b){return o.go(b)}};return y}function Bae(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:L0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function S9(t,e,n="/"){return Hae(t,e,n,!1)}function Hae(t,e,n,r){let i=typeof e=="string"?cg(e):e,a=$c(i.pathname||"/",n);if(a==null)return null;let o=M9(t);$ae(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=ese(a);l=Qae(o[c],u,r)}return l}function M9(t,e=[],n=[],r="",i=!1){let a=(o,l,c=i,u)=>{let d={relativePath:u===void 0?o.path||"":u,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};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=Oc([r,d.relativePath]),g=n.concat(d);o.children&&o.children.length>0&&(Dr(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),M9(o.children,e,g,f,c)),!(o.path==null&&!o.index)&&e.push({path:f,score:Yae(f,o.index),routesMeta:g})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))a(o,l);else for(let c of E9(o.path))a(o,l,!0,c)}),e}function E9(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 o=E9(r.join("/")),l=[];return l.push(...o.map(c=>c===""?a:[a,c].join("/"))),i&&l.push(...o),l.map(c=>t.startsWith("/")&&c===""?"/":c)}function $ae(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Zae(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Vae=/^:[\w-]+$/,Gae=3,Wae=2,qae=1,Kae=10,Xae=-2,mU=t=>t==="*";function Yae(t,e){let n=t.split("/"),r=n.length;return n.some(mU)&&(r+=Xae),e&&(r+=Wae),n.filter(i=>!mU(i)).reduce((i,a)=>i+(Vae.test(a)?Gae:a===""?qae:Kae),r)}function Zae(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 Qae(t,e,n=!1){let{routesMeta:r}=t,i={},a="/",o=[];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=G1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),g=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=G1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:Oc([a,f.pathname]),pathnameBase:ase(Oc([a,f.pathnameBase])),route:g}),f.pathnameBase!=="/"&&(a=Oc([a,f.pathnameBase]))}return o}function G1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Jae(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,"$1"),l=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},g)=>{if(d==="*"){let x=l[g]||"";o=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const p=l[g];return f&&!p?u[d]=void 0:u[d]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:o,pattern:t}}function Jae(t,e=!1,n=!0){Go(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,(o,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 ese(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Go(!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 $c(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 tse=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,nse=t=>tse.test(t);function rse(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?cg(t):t,a;if(n)if(nse(n))a=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Go(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${n}`)}n.startsWith("/")?a=pU(n.substring(1),"/"):a=pU(n,e)}else a=e;return{pathname:a,search:sse(r),hash:ose(i)}}function pU(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 eN(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 ise(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function A9(t){let e=ise(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function N9(t,e,n,r=!1){let i;typeof t=="string"?i=cg(t):(i={...t},Dr(!i.pathname||!i.pathname.includes("?"),eN("?","pathname","search",i)),Dr(!i.pathname||!i.pathname.includes("#"),eN("#","pathname","hash",i)),Dr(!i.search||!i.search.includes("#"),eN("#","search","hash",i)));let a=t===""||i.pathname==="",o=a?"/":i.pathname,l;if(o==null)l=n;else{let f=e.length-1;if(!r&&o.startsWith("..")){let g=o.split("/");for(;g[0]==="..";)g.shift(),f-=1;i.pathname=g.join("/")}l=f>=0?e[f]:"/"}let c=rse(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(a||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Oc=t=>t.join("/").replace(/\/\/+/g,"/"),ase=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),sse=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,ose=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function lse(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 T9=["POST","PUT","PATCH","DELETE"];new Set(T9);var cse=["GET",...T9];new Set(cse);var ug=S.createContext(null);ug.displayName="DataRouter";var aM=S.createContext(null);aM.displayName="DataRouterState";S.createContext(!1);var C9=S.createContext({isTransitioning:!1});C9.displayName="ViewTransition";var use=S.createContext(new Map);use.displayName="Fetchers";var dse=S.createContext(null);dse.displayName="Await";var Dl=S.createContext(null);Dl.displayName="Navigation";var Tb=S.createContext(null);Tb.displayName="Location";var Yo=S.createContext({outlet:null,matches:[],isDataRoute:!1});Yo.displayName="Route";var aR=S.createContext(null);aR.displayName="RouteError";function hse(t,{relative:e}={}){Dr(Cb(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=S.useContext(Dl),{hash:i,pathname:a,search:o}=Pb(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:Oc([n,a])),r.createHref({pathname:l,search:o,hash:i})}function Cb(){return S.useContext(Tb)!=null}function Fd(){return Dr(Cb(),"useLocation() may be used only in the context of a <Router> component."),S.useContext(Tb).location}var k9="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function P9(t){S.useContext(Dl).static||S.useLayoutEffect(t)}function kb(){let{isDataRoute:t}=S.useContext(Yo);return t?Nse():fse()}function fse(){Dr(Cb(),"useNavigate() may be used only in the context of a <Router> component.");let t=S.useContext(ug),{basename:e,navigator:n}=S.useContext(Dl),{matches:r}=S.useContext(Yo),{pathname:i}=Fd(),a=JSON.stringify(A9(r)),o=S.useRef(!1);return P9(()=>{o.current=!0}),S.useCallback((c,u={})=>{if(Go(o.current,k9),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=N9(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Oc([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var mse=S.createContext(null);function pse(t){let e=S.useContext(Yo).outlet;return S.useMemo(()=>e&&S.createElement(mse.Provider,{value:t},e),[e,t])}function sR(){let{matches:t}=S.useContext(Yo),e=t[t.length-1];return e?e.params:{}}function Pb(t,{relative:e}={}){let{matches:n}=S.useContext(Yo),{pathname:r}=Fd(),i=JSON.stringify(A9(n));return S.useMemo(()=>N9(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function gse(t,e){return j9(t,e)}function j9(t,e,n,r,i){Dr(Cb(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=S.useContext(Dl),{matches:o}=S.useContext(Yo),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",f=l&&l.route;{let E=f&&f.path||"";R9(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=Fd(),p;if(e){let E=typeof e=="string"?cg(e):e;Dr(d==="/"||E.pathname?.startsWith(d),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${E.pathname}" was given in the \`location\` prop.`),p=E}else p=g;let x=p.pathname||"/",y=x;if(d!=="/"){let E=d.replace(/^\//,"").split("/");y="/"+x.replace(/^\//,"").split("/").slice(E.length).join("/")}let b=S9(t,{pathname:y});Go(f||b!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Go(b==null||b[b.length-1].route.element!==void 0||b[b.length-1].route.Component!==void 0||b[b.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 v=_se(b&&b.map(E=>Object.assign({},E,{params:Object.assign({},c,E.params),pathname:Oc([d,a.encodeLocation?a.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?d:Oc([d,a.encodeLocation?a.encodeLocation(E.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),o,n,r,i);return e&&v?S.createElement(Tb.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},v):v}function xse(){let t=Ase(),e=lse(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},o=null;return console.error("Error handled by React Router default ErrorBoundary:",t),o=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,o)}var bse=S.createElement(xse,null),yse=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(Yo.Provider,{value:this.props.routeContext},S.createElement(aR.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function vse({routeContext:t,match:e,children:n}){let r=S.useContext(ug);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),S.createElement(Yo.Provider,{value:t},n)}function _se(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,o=n?.errors;if(o!=null){let d=a.findIndex(f=>f.route.id&&o?.[f.route.id]!==void 0);Dr(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let l=!1,c=-1;if(n)for(let d=0;d<a.length;d++){let f=a[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=d),f.route.id){let{loaderData:g,errors:p}=n,x=f.route.loader&&!g.hasOwnProperty(f.route.id)&&(!p||p[f.route.id]===void 0);if(f.route.lazy||x){l=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:f})}:void 0;return a.reduceRight((d,f,g)=>{let p,x=!1,y=null,b=null;n&&(p=o&&f.route.id?o[f.route.id]:void 0,y=f.route.errorElement||bse,l&&(c<0&&g===0?(R9("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,b=null):c===g&&(x=!0,b=f.route.hydrateFallbackElement||null)));let v=e.concat(a.slice(0,g+1)),E=()=>{let w;return p?w=y:x?w=b:f.route.Component?w=S.createElement(f.route.Component,null):f.route.element?w=f.route.element:w=d,S.createElement(vse,{match:f,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:w})};return n&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?S.createElement(yse,{location:n.location,revalidation:n.revalidation,component:y,error:p,children:E(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):E()},null)}function oR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function wse(t){let e=S.useContext(ug);return Dr(e,oR(t)),e}function Sse(t){let e=S.useContext(aM);return Dr(e,oR(t)),e}function Mse(t){let e=S.useContext(Yo);return Dr(e,oR(t)),e}function lR(t){let e=Mse(t),n=e.matches[e.matches.length-1];return Dr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function Ese(){return lR("useRouteId")}function Ase(){let t=S.useContext(aR),e=Sse("useRouteError"),n=lR("useRouteError");return t!==void 0?t:e.errors?.[n]}function Nse(){let{router:t}=wse("useNavigate"),e=lR("useNavigate"),n=S.useRef(!1);return P9(()=>{n.current=!0}),S.useCallback(async(i,a={})=>{Go(n.current,k9),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var gU={};function R9(t,e,n){!e&&!gU[t]&&(gU[t]=!0,Go(!1,n))}S.memo(Tse);function Tse({routes:t,future:e,state:n,unstable_onError:r}){return j9(t,void 0,n,r,e)}function Cse(t){return pse(t.context)}function es(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 kse({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1}){Dr(!Cb(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let o=t.replace(/^\/*/,"/"),l=S.useMemo(()=>({basename:o,navigator:i,static:a,future:{}}),[o,i,a]);typeof n=="string"&&(n=cg(n));let{pathname:c="/",search:u="",hash:d="",state:f=null,key:g="default"}=n,p=S.useMemo(()=>{let x=$c(c,o);return x==null?null:{location:{pathname:x,search:u,hash:d,state:f,key:g},navigationType:r}},[o,c,u,d,f,g,r]);return Go(p!=null,`<Router basename="${o}"> 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(Dl.Provider,{value:l},S.createElement(Tb.Provider,{children:e,value:p}))}function Pse({children:t,location:e}){return gse(Zk(t),e)}function Zk(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,Zk(r.props.children,a));return}Dr(r.type===es,`[${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 o={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&&(o.children=Zk(r.props.children,a)),n.push(o)}),n}var p1="get",g1="application/x-www-form-urlencoded";function sM(t){return t!=null&&typeof t.tagName=="string"}function jse(t){return sM(t)&&t.tagName.toLowerCase()==="button"}function Rse(t){return sM(t)&&t.tagName.toLowerCase()==="form"}function Dse(t){return sM(t)&&t.tagName.toLowerCase()==="input"}function Ose(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Lse(t,e){return t.button===0&&(!e||e==="_self")&&!Ose(t)}var Pv=null;function Ise(){if(Pv===null)try{new FormData(document.createElement("form"),0),Pv=!1}catch{Pv=!0}return Pv}var Fse=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function tN(t){return t!=null&&!Fse.has(t)?(Go(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${g1}"`),null):t}function Use(t,e){let n,r,i,a,o;if(Rse(t)){let l=t.getAttribute("action");r=l?$c(l,e):null,n=t.getAttribute("method")||p1,i=tN(t.getAttribute("enctype"))||g1,a=new FormData(t)}else if(jse(t)||Dse(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?$c(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||p1,i=tN(t.getAttribute("formenctype"))||tN(l.getAttribute("enctype"))||g1,a=new FormData(l,t),!Ise()){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(sM(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=p1,r=null,i=g1,o=t}return a&&i==="text/plain"&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function cR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function zse(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&&$c(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function Bse(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 Hse(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 $se(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let o=await Bse(a,n);return o.links?o.links():[]}return[]}));return qse(r.flat(1).filter(Hse).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function xU(t,e,n,r,i,a){let o=(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)=>o(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(o(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 Vse(t,e,{includeHydrateFallback:n}={}){return Gse(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 Gse(t){return[...new Set(t)]}function Wse(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function qse(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(Wse(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function D9(){let t=S.useContext(ug);return cR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Kse(){let t=S.useContext(aM);return cR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var uR=S.createContext(void 0);uR.displayName="FrameworkContext";function O9(){let t=S.useContext(uR);return cR(t,"You must render this element inside a <HydratedRouter> element"),t}function Xse(t,e){let n=S.useContext(uR),[r,i]=S.useState(!1),[a,o]=S.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,g=S.useRef(null);S.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let y=v=>{v.forEach(E=>{o(E.isIntersecting)})},b=new IntersectionObserver(y,{threshold:.5});return g.current&&b.observe(g.current),()=>{b.disconnect()}}},[t]),S.useEffect(()=>{if(r){let y=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(y)}}},[r]);let p=()=>{i(!0)},x=()=>{i(!1),o(!1)};return n?t!=="intent"?[a,g,{}]:[a,g,{onFocus:Mx(l,p),onBlur:Mx(c,x),onMouseEnter:Mx(u,p),onMouseLeave:Mx(d,x),onTouchStart:Mx(f,p)}]:[!1,g,{}]}function Mx(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Yse({page:t,...e}){let{router:n}=D9(),r=S.useMemo(()=>S9(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?S.createElement(Qse,{page:t,matches:r,...e}):null}function Zse(t){let{manifest:e,routeModules:n}=O9(),[r,i]=S.useState([]);return S.useEffect(()=>{let a=!1;return $se(t,e,n).then(o=>{a||i(o)}),()=>{a=!0}},[t,e,n]),r}function Qse({page:t,matches:e,...n}){let r=Fd(),{manifest:i,routeModules:a}=O9(),{basename:o}=D9(),{loaderData:l,matches:c}=Kse(),u=S.useMemo(()=>xU(t,e,c,i,r,"data"),[t,e,c,i,r]),d=S.useMemo(()=>xU(t,e,c,i,r,"assets"),[t,e,c,i,r]),f=S.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let x=new Set,y=!1;if(e.forEach(v=>{let E=i.routes[v.route.id];!E||!E.hasLoader||(!u.some(w=>w.route.id===v.route.id)&&v.route.id in l&&a[v.route.id]?.shouldRevalidate||E.hasClientLoader?y=!0:x.add(v.route.id))}),x.size===0)return[];let b=zse(t,o,"data");return y&&x.size>0&&b.searchParams.set("_routes",e.filter(v=>x.has(v.route.id)).map(v=>v.route.id).join(",")),[b.pathname+b.search]},[o,l,r,i,u,e,t,a]),g=S.useMemo(()=>Vse(d,i),[d,i]),p=Zse(d);return S.createElement(S.Fragment,null,f.map(x=>S.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),g.map(x=>S.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),p.map(({key:x,link:y})=>S.createElement("link",{key:x,nonce:n.nonce,...y})))}function Jse(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var L9=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{L9&&(window.__reactRouterVersion="7.9.6")}catch{}function eoe({basename:t,children:e,window:n}){let r=S.useRef();r.current==null&&(r.current=Fae({window:n,v5Compat:!0}));let i=r.current,[a,o]=S.useState({action:i.action,location:i.location}),l=S.useCallback(c=>{S.startTransition(()=>o(c))},[o]);return S.useLayoutEffect(()=>i.listen(l),[i,l]),S.createElement(kse,{basename:t,children:e,location:a.location,navigationType:a.action,navigator:i})}var I9=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Nc=S.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:a,replace:o,state:l,target:c,to:u,preventScrollReset:d,viewTransition:f,...g},p){let{basename:x}=S.useContext(Dl),y=typeof u=="string"&&I9.test(u),b,v=!1;if(typeof u=="string"&&y&&(b=u,L9))try{let k=new URL(window.location.href),D=u.startsWith("//")?new URL(k.protocol+u):new URL(u),U=$c(D.pathname,x);D.origin===k.origin&&U!=null?u=U+D.search+D.hash:v=!0}catch{Go(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let E=hse(u,{relative:i}),[w,N,A]=Xse(r,g),C=roe(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f});function T(k){e&&e(k),k.defaultPrevented||C(k)}let L=S.createElement("a",{...g,...A,href:b||E,onClick:v||a?e:T,ref:Jse(p,N),target:c,"data-discover":!y&&n==="render"?"true":void 0});return w&&!y?S.createElement(S.Fragment,null,L,S.createElement(Yse,{page:E})):L});Nc.displayName="Link";var Zx=S.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:a,to:o,viewTransition:l,children:c,...u},d){let f=Pb(o,{relative:u.relative}),g=Fd(),p=S.useContext(aM),{navigator:x,basename:y}=S.useContext(Dl),b=p!=null&&loe(f)&&l===!0,v=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,E=g.pathname,w=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(E=E.toLowerCase(),w=w?w.toLowerCase():null,v=v.toLowerCase()),w&&y&&(w=$c(w,y)||w);const N=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let A=E===v||!i&&E.startsWith(v)&&E.charAt(N)==="/",C=w!=null&&(w===v||!i&&w.startsWith(v)&&w.charAt(v.length)==="/"),T={isActive:A,isPending:C,isTransitioning:b},L=A?e:void 0,k;typeof r=="function"?k=r(T):k=[r,A?"active":null,C?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let D=typeof a=="function"?a(T):a;return S.createElement(Nc,{...u,"aria-current":L,className:k,ref:d,style:D,to:o,viewTransition:l},typeof c=="function"?c(T):c)});Zx.displayName="NavLink";var toe=S.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:o=p1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,...g},p)=>{let x=soe(),y=ooe(l,{relative:u}),b=o.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&I9.test(l),E=w=>{if(c&&c(w),w.defaultPrevented)return;w.preventDefault();let N=w.nativeEvent.submitter,A=N?.getAttribute("formmethod")||o;x(N||w.currentTarget,{fetcherKey:e,method:A,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f})};return S.createElement("form",{ref:p,method:b,action:y,onSubmit:r?c:E,...g,"data-discover":!v&&t==="render"?"true":void 0})});toe.displayName="Form";function noe(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function F9(t){let e=S.useContext(ug);return Dr(e,noe(t)),e}function roe(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o}={}){let l=kb(),c=Fd(),u=Pb(t,{relative:a});return S.useCallback(d=>{if(Lse(d,e)){d.preventDefault();let f=n!==void 0?n:L0(c)===L0(u);l(t,{replace:f,state:r,preventScrollReset:i,relative:a,viewTransition:o})}},[c,l,u,n,r,e,t,i,a,o])}var ioe=0,aoe=()=>`__${String(++ioe)}__`;function soe(){let{router:t}=F9("useSubmit"),{basename:e}=S.useContext(Dl),n=Ese();return S.useCallback(async(r,i={})=>{let{action:a,method:o,encType:l,formData:c,body:u}=Use(r,e);if(i.navigate===!1){let d=i.fetcherKey||aoe();await t.fetch(d,n,i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||o,formEncType:i.encType||l,flushSync:i.flushSync})}else await t.navigate(i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||o,formEncType:i.encType||l,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function ooe(t,{relative:e}={}){let{basename:n}=S.useContext(Dl),r=S.useContext(Yo);Dr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...Pb(t||".",{relative:e})},o=Fd();if(t==null){a.search=o.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:Oc([n,a.pathname])),L0(a)}function loe(t,{relative:e}={}){let n=S.useContext(C9);Dr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=F9("useViewTransitionState"),i=Pb(t,{relative:e});if(!n.isTransitioning)return!1;let a=$c(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=$c(n.nextLocation.pathname,r)||n.nextLocation.pathname;return G1(i.pathname,o)!=null||G1(i.pathname,a)!=null}var Tc=h9();const coe=wo(Tc);var dg=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(){}},uoe={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},doe=class{#e=uoe;#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)}},Ph=new doe;function hoe(t){setTimeout(t,0)}var tf=typeof window>"u"||"Deno"in globalThis;function Da(){}function foe(t,e){return typeof t=="function"?t(e):t}function Qk(t){return typeof t=="number"&&t>=0&&t!==1/0}function U9(t,e){return Math.max(t+(e||0)-Date.now(),0)}function dd(t,e){return typeof t=="function"?t(e):t}function to(t,e){return typeof t=="function"?t(e):t}function bU(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==dR(o,e.options))return!1}else if(!I0(e.queryKey,o))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 yU(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(nf(e.options.mutationKey)!==nf(a))return!1}else if(!I0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function dR(t,e){return(e?.queryKeyHashFn||nf)(t)}function nf(t){return JSON.stringify(t,(e,n)=>Jk(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function I0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>I0(t[n],e[n])):!1}var moe=Object.prototype.hasOwnProperty;function z9(t,e){if(t===e)return t;const n=vU(t)&&vU(e);if(!n&&!(Jk(t)&&Jk(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),o=a.length,l=n?new Array(o):{};let c=0;for(let u=0;u<o;u++){const d=n?u:a[u],f=t[d],g=e[d];if(f===g){l[d]=f,(n?u<i:moe.call(t,d))&&c++;continue}if(f===null||g===null||typeof f!="object"||typeof g!="object"){l[d]=g;continue}const p=z9(f,g);l[d]=p,p===f&&c++}return i===o&&c===i?t:l}function W1(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 vU(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Jk(t){if(!_U(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!_U(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function _U(t){return Object.prototype.toString.call(t)==="[object Object]"}function poe(t){return new Promise(e=>{Ph.setTimeout(e,t)})}function e3(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?z9(t,e):e}function goe(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function xoe(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var hR=Symbol();function B9(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===hR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function H9(t,e){return typeof t=="function"?t(...e):!!t}var boe=class extends dg{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!tf&&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"}},fR=new boe;function t3(){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 yoe=hoe;function voe(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=yoe;const a=l=>{e?t.push(l):i(()=>{n(l)})},o=()=>{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||o()}return c},batchCalls:l=>(...c)=>{a(()=>{l(...c)})},schedule:a,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var Si=voe(),_oe=class extends dg{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!tf&&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}},q1=new _oe;function woe(t){return Math.min(1e3*2**t,3e4)}function $9(t){return(t??"online")==="online"?q1.isOnline():!0}var n3=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function V9(t){let e=!1,n=0,r;const i=t3(),a=()=>i.status!=="pending",o=y=>{if(!a()){const b=new n3(y);g(b),t.onCancel?.(b)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>fR.isFocused()&&(t.networkMode==="always"||q1.isOnline())&&t.canRun(),d=()=>$9(t.networkMode)&&t.canRun(),f=y=>{a()||(r?.(),i.resolve(y))},g=y=>{a()||(r?.(),i.reject(y))},p=()=>new Promise(y=>{r=b=>{(a()||u())&&y(b)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),x=()=>{if(a())return;let y;const b=n===0?t.initialPromise:void 0;try{y=b??t.fn()}catch(v){y=Promise.reject(v)}Promise.resolve(y).then(f).catch(v=>{if(a())return;const E=t.retry??(tf?0:3),w=t.retryDelay??woe,N=typeof w=="function"?w(n,v):w,A=E===!0||typeof E=="number"&&n<E||typeof E=="function"&&E(n,v);if(e||!A){g(v);return}n++,t.onFail?.(n,v),poe(N).then(()=>u()?void 0:p()).then(()=>{e?g(v):x()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():p().then(x),i)}}var G9=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Qk(this.gcTime)&&(this.#e=Ph.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(tf?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Ph.clearTimeout(this.#e),this.#e=void 0)}},Soe=class extends G9{#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=SU(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=SU(this.options);e.data!==void 0&&(this.setState(wU(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=e3(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(Da).catch(Da):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>to(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===hR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>dd(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:!U9(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=B9(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)},o=(()=>{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(o,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#a({type:"fetch",meta:o.fetchOptions?.meta}),this.#r=V9({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof n3&&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:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.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 n3){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,...W9(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...wU(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),Si.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function W9(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:$9(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function wU(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function SU(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 Moe=class extends dg{constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=t3(),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),MU(this.#t,this.options)?this.#d():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return r3(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return r3(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 to(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&&!W1(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&EU(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||to(this.options.enabled,this.#t)!==to(e.enabled,this.#t)||dd(this.options.staleTime,this.#t)!==dd(e.staleTime,this.#t))&&this.#g();const i=this.#x();r&&(this.#t!==n||to(this.options.enabled,this.#t)!==to(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 Aoe(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(Da)),e}#g(){this.#v();const t=dd(this.options.staleTime,this.#t);if(tf||this.#i.isStale||!Qk(t))return;const n=U9(this.#i.dataUpdatedAt,t)+1;this.#c=Ph.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,!(tf||to(this.options.enabled,this.#t)===!1||!Qk(this.#l)||this.#l===0)&&(this.#u=Ph.setInterval(()=>{(this.options.refetchIntervalInBackground||fR.isFocused())&&this.#d()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(Ph.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(Ph.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#t,r=this.options,i=this.#i,a=this.#r,o=this.#s,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,g;if(e._optimisticResults){const L=this.hasListeners(),k=!L&&MU(t,e),D=L&&EU(t,n,e,r);(k||D)&&(d={...d,...W9(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:x,status:y}=d;g=d.data;let b=!1;if(e.placeholderData!==void 0&&g===void 0&&y==="pending"){let L;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(L=i.data,b=!0):L=typeof e.placeholderData=="function"?e.placeholderData(this.#f?.state.data,this.#f):e.placeholderData,L!==void 0&&(y="success",g=e3(i?.data,L,e),f=!0)}if(e.select&&g!==void 0&&!b)if(i&&g===a?.data&&e.select===this.#p)g=this.#h;else try{this.#p=e.select,g=e.select(g),g=e3(i?.data,g,e),this.#h=g,this.#a=null}catch(L){this.#a=L}this.#a&&(p=this.#a,g=this.#h,x=Date.now(),y="error");const v=d.fetchStatus==="fetching",E=y==="pending",w=y==="error",N=E&&v,A=g!==void 0,T={status:y,fetchStatus:d.fetchStatus,isPending:E,isSuccess:y==="success",isError:w,isInitialLoading:N,isLoading:N,data:g,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:v,isRefetching:v&&!E,isLoadingError:w&&!A,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&A,isStale:mR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:to(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const L=U=>{T.status==="error"?U.reject(T.error):T.data!==void 0&&U.resolve(T.data)},k=()=>{const U=this.#o=T.promise=t3();L(U)},D=this.#o;switch(D.status){case"pending":t.queryHash===n.queryHash&&L(D);break;case"fulfilled":(T.status==="error"||T.data!==D.value)&&k();break;case"rejected":(T.status!=="error"||T.error!==D.reason)&&k();break}}return T}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),W1(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(o=>{const l=o;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){Si.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Eoe(t,e){return to(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function MU(t,e){return Eoe(t,e)||t.state.data!==void 0&&r3(t,e,e.refetchOnMount)}function r3(t,e,n){if(to(e.enabled,t)!==!1&&dd(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&mR(t,e)}return!1}function EU(t,e,n,r){return(t!==e||to(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&mR(t,n)}function mR(t,e){return to(e.enabled,t)!==!1&&t.isStaleByTime(dd(e.staleTime,t))}function Aoe(t,e){return!W1(t.getCurrentResult(),e)}function AU(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,a=e.state.data?.pages||[],o=e.state.data?.pageParams||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const f=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},g=B9(e.options,e.fetchOptions),p=async(x,y,b)=>{if(d)return Promise.reject();if(y==null&&x.pages.length)return Promise.resolve(x);const E=(()=>{const C={client:e.client,queryKey:e.queryKey,pageParam:y,direction:b?"backward":"forward",meta:e.options.meta};return f(C),C})(),w=await g(E),{maxPages:N}=e.options,A=b?xoe:goe;return{pages:A(x.pages,w,N),pageParams:A(x.pageParams,y,N)}};if(i&&a.length){const x=i==="backward",y=x?Noe:NU,b={pages:a,pageParams:o},v=y(r,b);l=await p(b,v,x)}else{const x=t??a.length;do{const y=c===0?o[0]??r.initialPageParam:NU(r,l);if(c>0&&y==null)break;l=await p(l,y),c++}while(c<x)}return l};e.options.persister?e.fetchFn=()=>e.options.persister?.(u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=u}}}function NU(t,{pages:e,pageParams:n}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,n[r],n):void 0}function Noe(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var Toe=class extends G9{#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||q9(),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=V9({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(a,o)=>{this.#r({type:"failed",failureCount:a,error:o})},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 o=await this.options.onMutate?.(t,n);o!==this.state.context&&this.#r({type:"pending",context:o,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),Si.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function q9(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Coe=class extends dg{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 Toe({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=jv(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=jv(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=jv(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=jv(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Si.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=>yU(e,n))}findAll(t={}){return this.getAll().filter(e=>yU(t,e))}notify(t){Si.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return Si.batch(()=>Promise.all(t.map(e=>e.continue().catch(Da))))}};function jv(t){return t.options.scope?.id}var koe=class extends dg{#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),W1(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&nf(n.mutationKey)!==nf(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??q9();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){Si.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)})})}},Poe=class extends dg{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??dR(r,e);let a=this.get(i);return a||(a=new Soe({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(){Si.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=>bU(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>bU(t,n)):e}notify(t){Si.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){Si.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Si.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},joe=class{#e;#t;#n;#i;#r;#s;#o;#a;constructor(t={}){this.#e=t.queryCache||new Poe,this.#t=t.mutationCache||new Coe,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=fR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=q1.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(dd(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,o=foe(e,a);if(o!==void 0)return this.#e.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return Si.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;Si.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return Si.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=Si.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Da).catch(Da)}invalidateQueries(t,e={}){return Si.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=Si.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(Da)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Da)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(dd(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Da).catch(Da)}fetchInfiniteQuery(t){return t.behavior=AU(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Da).catch(Da)}ensureInfiniteQueryData(t){return t.behavior=AU(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return q1.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(nf(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{I0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(nf(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{I0(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=dR(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===hR&&(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()}},K9=S.createContext(void 0),cn=t=>{const e=S.useContext(K9);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Roe=({client:t,children:e})=>(S.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(K9.Provider,{value:t,children:e})),X9=S.createContext(!1),Doe=()=>S.useContext(X9);X9.Provider;function Ooe(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Loe=S.createContext(Ooe()),Ioe=()=>S.useContext(Loe),Foe=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Uoe=t=>{S.useEffect(()=>{t.clearReset()},[t])},zoe=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||H9(n,[t.error,r])),Boe=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))}},Hoe=(t,e)=>t.isLoading&&t.isFetching&&!e,$oe=(t,e)=>t?.suspense&&e.isPending,TU=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Voe(t,e,n){const r=Doe(),i=Ioe(),a=cn(),o=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",Boe(o),Foe(o,i),Uoe(i);const l=!a.getQueryCache().get(o.queryHash),[c]=S.useState(()=>new e(a,o)),u=c.getOptimisticResult(o),d=!r&&t.subscribed!==!1;if(S.useSyncExternalStore(S.useCallback(f=>{const g=d?c.subscribe(Si.batchCalls(f)):Da;return c.updateResult(),g},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),S.useEffect(()=>{c.setOptions(o)},[o,c]),$oe(o,u))throw TU(o,c,i);if(zoe({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!tf&&Hoe(u,r)&&(l?TU(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Da).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?u:c.trackResult(u)}function ft(t,e){return Voe(t,Moe)}function bt(t,e){const n=cn(),[r]=S.useState(()=>new koe(n,t));S.useEffect(()=>{r.setOptions(t)},[r,t]);const i=S.useSyncExternalStore(S.useCallback(o=>r.subscribe(Si.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=S.useCallback((o,l)=>{r.mutate(o,l).catch(Da)},[r]);if(i.error&&H9(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const Goe=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Woe=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),CU=t=>{const e=Woe(t);return e.charAt(0).toUpperCase()+e.slice(1)},Y9=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),qoe=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Koe={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 Xoe=S.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...l},c)=>S.createElement("svg",{ref:c,...Koe,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:Y9("lucide",i),...!a&&!qoe(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>S.createElement(u,d)),...Array.isArray(a)?a:[a]]));const qe=(t,e)=>{const n=S.forwardRef(({className:r,...i},a)=>S.createElement(Xoe,{ref:a,iconNode:e,className:Y9(`lucide-${Goe(CU(t))}`,`lucide-${t}`,r),...i}));return n.displayName=CU(t),n};const Yoe=[["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"}]],Zoe=qe("air-vent",Yoe);const Qoe=[["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"}]],fo=qe("archive",Qoe);const Joe=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],F0=qe("arrow-down",Joe);const ele=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],tle=qe("arrow-left",ele);const nle=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],i3=qe("arrow-right",nle);const rle=[["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"}]],ile=qe("arrow-up-down",rle);const ale=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Cp=qe("arrow-up",ale);const sle=[["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"}]],zh=qe("bell",sle);const ole=[["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"}]],lle=qe("bold",ole);const cle=[["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"}]],ule=qe("book",cle);const dle=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],hle=qe("bookmark",dle);const fle=[["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"}]],vl=qe("box",fle);const mle=[["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"}]],Z9=qe("bug",mle);const ple=[["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"}]],gle=qe("cable",ple);const xle=[["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"}]],ble=qe("calendar-days",xle);const yle=[["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"}]],Wr=qe("calendar",yle);const vle=[["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"}]],kp=qe("camera",vle);const _le=[["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"}]],wle=qe("chart-column",_le);const Sle=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ls=qe("check",Sle);const Mle=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ga=qe("chevron-down",Mle);const Ele=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Zo=qe("chevron-right",Ele);const Ale=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],rf=qe("chevron-left",Ale);const Nle=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Tf=qe("chevron-up",Nle);const Tle=[["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"}]],Aa=qe("circle-alert",Tle);const Cle=[["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"}]],nN=qe("circle-arrow-up",Cle);const kle=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ar=qe("circle-check-big",kle);const Ple=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],pR=qe("circle-check",Ple);const jle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Rle=qe("circle-dot",jle);const Dle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Ole=qe("circle-stop",Dle);const Lle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Sa=qe("circle-x",Lle);const Ile=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],a3=qe("circle",Ile);const Fle=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],dr=qe("clock",Fle);const Ule=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],oM=qe("cloud",Ule);const zle=[["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"}]],Ble=qe("code-xml",zle);const Hle=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Q9=qe("code",Hle);const $le=[["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"}]],Vle=qe("coffee",$le);const Gle=[["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"}]],Wle=qe("cog",Gle);const qle=[["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"}]],Kle=qe("compass",qle);const Xle=[["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"}]],Wo=qe("copy",Xle);const Yle=[["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"}]],Rv=qe("cpu",Yle);const Zle=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],Qle=qe("cylinder",Zle);const Jle=[["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"}]],Pp=qe("database",Jle);const ece=[["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"}]],s3=qe("dollar-sign",ece);const tce=[["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"}]],Mi=qe("download",tce);const nce=[["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"}]],gR=qe("droplet",nce);const rce=[["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"}]],xR=qe("droplets",rce);const ice=[["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"}]],pp=qe("ellipsis-vertical",ice);const ace=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],rN=qe("equal",ace);const sce=[["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"}]],qr=qe("external-link",sce);const oce=[["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"}]],lM=qe("eye-off",oce);const lce=[["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"}]],af=qe("eye",lce);const cce=[["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"}]],J9=qe("fan",cce);const uce=[["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"}]],eW=qe("file-box",uce);const dce=[["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"}]],K1=qe("file-code",dce);const hce=[["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"}]],fce=qe("file-exclamation-point",hce);const mce=[["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"}]],X1=qe("file-spreadsheet",mce);const pce=[["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"}]],is=qe("file-text",pce);const gce=[["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"}]],bR=qe("file",gce);const xce=[["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"}]],hd=qe("film",xce);const bce=[["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"}]],yce=qe("flame",bce);const vce=[["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"}]],ha=qe("folder-kanban",vce);const _ce=[["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"}]],wce=qe("folder-open",_ce);const Sce=[["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"}]],Mce=qe("folder-tree",Sce);const Ece=[["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"}]],tW=qe("folder",Ece);const Ace=[["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"}]],yR=qe("funnel",Ace);const Nce=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],cM=qe("gauge",Nce);const Tce=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],Cce=qe("gift",Tce);const kce=[["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"}]],gp=qe("git-compare",kce);const Pce=[["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"}]],kU=qe("github",Pce);const jce=[["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"}]],sf=qe("globe",jce);const Rce=[["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"}]],U0=qe("grip-vertical",Rce);const Dce=[["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"}]],vR=qe("hand",Dce);const Oce=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],_R=qe("hard-drive",Oce);const Lce=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Ice=qe("hash",Lce);const Fce=[["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"}]],Uce=qe("headphones",Fce);const zce=[["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"}]],Bce=qe("heart",zce);const Hce=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Y1=qe("history",Hce);const $ce=[["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"}]],Vce=qe("house",$ce);const Gce=[["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"}]],jb=qe("image",Gce);const Wce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],wd=qe("info",Wce);const qce=[["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"}]],Kce=qe("italic",qce);const Xce=[["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"}]],lp=qe("key",Xce);const Yce=[["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"}]],o3=qe("keyboard",Yce);const Zce=[["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"}]],Sd=qe("layers",Zce);const Qce=[["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"}]],wR=qe("layout-grid",Qce);const Jce=[["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"}]],eue=qe("link-2-off",Jce);const tue=[["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"}]],jp=qe("link-2",tue);const nue=[["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"}]],Rb=qe("link",nue);const rue=[["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"}]],nW=qe("list-ordered",rue);const iue=[["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"}]],l3=qe("list-todo",iue);const aue=[["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"}]],SR=qe("list",aue);const sue=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],xt=qe("loader-circle",sue);const oue=[["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"}]],PU=qe("log-in",oue);const lue=[["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"}]],cue=qe("log-out",lue);const uue=[["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"}]],due=qe("mail",uue);const hue=[["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"}]],fue=qe("map",hue);const mue=[["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"}]],pue=qe("maximize-2",mue);const gue=[["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"}]],xue=qe("maximize",gue);const bue=[["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"}]],yue=qe("memory-stick",bue);const vue=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],_ue=qe("menu",vue);const wue=[["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"}]],Sue=qe("minimize-2",wue);const Mue=[["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"}]],Eue=qe("minimize",Mue);const Aue=[["path",{d:"M5 12h14",key:"1ays0h"}]],c3=qe("minus",Aue);const Nue=[["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"}]],Tue=qe("monitor",Nue);const Cue=[["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"}]],Z1=qe("moon",Cue);const kue=[["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"}]],u3=qe("music",kue);const Pue=[["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"}]],Vc=qe("package",Pue);const jue=[["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"}]],MR=qe("palette",jue);const Rue=[["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"}]],Due=qe("paperclip",Rue);const Oue=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],ER=qe("pause",Oue);const Lue=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],of=qe("pen-line",Lue);const Iue=[["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"}]],AR=qe("pen",Iue);const Fue=[["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"}]],qo=qe("pencil",Fue);const Uue=[["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"}]],zue=qe("phone",Uue);const Bue=[["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"}]],Gc=qe("play",Bue);const Hue=[["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"}]],mo=qe("plug",Hue);const $ue=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],pr=qe("plus",$ue);const Vue=[["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"}]],uM=qe("power-off",Vue);const Gue=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Ol=qe("power",Gue);const Wue=[["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"}]],Ei=qe("printer",Wue);const que=[["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"}]],rW=qe("qr-code",que);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"}]],Gr=qe("refresh-cw",Kue);const Xue=[["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"}]],hg=qe("rotate-ccw",Xue);const Yue=[["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"}]],Zue=qe("ruler",Yue);const Que=[["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"}]],ks=qe("save",Que);const Jue=[["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"}]],iW=qe("scan-search",Jue);const ede=[["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"}]],tde=qe("scissors",ede);const nde=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ml=qe("search",nde);const rde=[["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"}]],NR=qe("send",rde);const ide=[["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"}]],vh=qe("server",ide);const ade=[["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"}]],dM=qe("settings-2",ade);const sde=[["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"}]],hM=qe("settings",sde);const ode=[["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"}]],lde=qe("shield",ode);const cde=[["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"}]],aW=qe("shopping-cart",cde);const ude=[["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"}]],dde=qe("signal",ude);const hde=[["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"}]],fde=qe("skip-back",hde);const mde=[["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=qe("skip-forward",mde);const pde=[["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"}]],jU=qe("sliders-vertical",pde);const gde=[["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"}]],z0=qe("sparkles",gde);const xde=[["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"}]],Md=qe("square-check-big",xde);const bde=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ed=qe("square",bde);const yde=[["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"}]],lf=qe("star",yde);const vde=[["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"}]],sW=qe("sticky-note",vde);const _de=[["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"}]],RU=qe("sun",_de);const wde=[["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"}]],Rp=qe("tag",wde);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"}]],oW=qe("target",Sde);const Mde=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],lW=qe("terminal",Mde);const Ede=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Ade=qe("text-align-center",Ede);const Nde=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Tde=qe("text-align-end",Nde);const Cde=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],kde=qe("text-align-start",Cde);const Pde=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],fM=qe("thermometer",Pde);const jde=[["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"}]],id=qe("timer",jde);const Rde=[["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"}]],_n=qe("trash-2",Rde);const Dde=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],cW=qe("trending-down",Dde);const Ode=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],uW=qe("trending-up",Ode);const Lde=[["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"}]],zn=qe("triangle-alert",Lde);const Ide=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Fde=qe("underline",Ide);const Ude=[["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"}]],dW=qe("unlink",Ude);const zde=[["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"}]],qi=qe("upload",zde);const Bde=[["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"}]],d3=qe("user",Bde);const Hde=[["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"}]],$de=qe("users",Hde);const Vde=[["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"}]],hW=qe("video",Vde);const Gde=[["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"}]],Wde=qe("volume-2",Gde);const qde=[["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"}]],Kde=qe("volume-x",qde);const Xde=[["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"}]],Db=qe("wifi-off",Xde);const Yde=[["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"}]],TR=qe("wifi",Yde);const Zde=[["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"}]],fW=qe("wind",Zde);const Qde=[["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"}]],Ad=qe("wrench",Qde);const Jde=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Bt=qe("x",Jde);const ehe=[["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"}]],the=qe("zoom-in",ehe);const nhe=[["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"}]],cf=qe("zap",nhe);const rhe=[["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"}]],ihe=qe("zoom-out",rhe),Dn="/api/v1";async function Ue(t,e={}){const n=await fetch(`${Dn}${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 ye={getPrinters:()=>Ue("/printers/"),getPrinter:t=>Ue(`/printers/${t}`),createPrinter:t=>Ue("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Ue(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Ue(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>Ue(`/printers/${t}/status`),refreshPrinterStatus:t=>Ue(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Ue(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Ue(`/printers/${t}/disconnect`,{method:"POST"}),stopPrint:t=>Ue(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Ue(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Ue(`/printers/${t}/print/resume`,{method:"POST"}),setChamberLight:(t,e)=>Ue(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>Ue(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Ue(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>Ue(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Ue(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Ue(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Ue(`/printers/${t}/logging`),clearMQTTLogs:t=>Ue(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Ue(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${Dn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>Ue(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Ue(`/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)),Ue(`/archives/?${i}`)},getArchive:t=>Ue(`/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)),Ue(`/archives/search?${n}`)},rebuildSearchIndex:()=>Ue("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Ue(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Ue(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Ue(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Ue("/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)),Ue(`/archives/analysis/failures?${e}`)},compareArchives:t=>Ue(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Ue(`/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(`${Dn}/archives/export?${e}`);if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.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 o=r.match(/filename="?([^"]+)"?/);o&&(i=o[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(`${Dn}/archives/stats/export?${e}`);if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.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 o=r.match(/filename="?([^"]+)"?/);o&&(i=o[1])}return{blob:await n.blob(),filename:i}},getArchiveDuplicates:t=>Ue(`/archives/${t}/duplicates`),backfillContentHashes:()=>Ue("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${Dn}/archives/${t}/thumbnail?v=${Date.now()}`,getArchiveDownload:t=>`${Dn}/archives/${t}/download`,getArchiveGcode:t=>`${Dn}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${Dn}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${Dn}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Ue(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Ue(`/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(`${Dn}/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=>Ue(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Ue(`/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(`${Dn}/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)=>`${Dn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${Dn}/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)=>Ue(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${Dn}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${Dn}/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(`${Dn}/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=>Ue(`/archives/${t}/source`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${Dn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Ue(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Ue(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Ue(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${Dn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${Dn}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchiveFilamentRequirements:t=>Ue(`/archives/${t}/filament-requirements`),reprintArchive:(t,e,n)=>Ue(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST",headers:n?{"Content-Type":"application/json"}:void 0,body:n?JSON.stringify(n):void 0}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${Dn}/archives/upload?printer_id=${e}`:`${Dn}/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?`${Dn}/archives/upload-bulk?printer_id=${e}`:`${Dn}/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:()=>Ue("/settings/"),updateSettings:t=>Ue("/settings/",{method:"PUT",body:JSON.stringify(t)}),resetSettings:()=>Ue("/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=`${Dn}/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=`${Dn}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>Ue("/settings/check-ffmpeg"),getCloudStatus:()=>Ue("/cloud/status"),cloudLogin:(t,e,n="global")=>Ue("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>Ue("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>Ue("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Ue("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Ue(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Ue(`/cloud/settings/${t}`),createCloudSetting:t=>Ue("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Ue(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Ue(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Ue("/cloud/devices"),getCloudFields:t=>Ue(`/cloud/fields/${t}`),getAllCloudFields:()=>Ue("/cloud/fields"),getFilamentInfo:t=>Ue("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Ue("/smart-plugs/"),getSmartPlug:t=>Ue(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Ue(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>Ue("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Ue(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Ue(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Ue(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Ue(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Ue("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${Dn}/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:()=>Ue("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${Dn}/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:()=>Ue("/smart-plugs/discover/devices"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Ue(`/queue/?${n}`)},getQueueItem:t=>Ue(`/queue/${t}`),addToQueue:t=>Ue("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Ue(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Ue(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Ue("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Ue(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Ue(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Ue(`/queue/${t}/start`,{method:"POST"}),getKProfiles:(t,e="0.4")=>Ue(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Ue(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Ue(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Ue(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Ue(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Ue(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Ue(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Ue(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Ue(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>Ue(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Ue(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),listFilaments:()=>Ue("/filaments/"),getFilament:t=>Ue(`/filaments/${t}`),getFilamentsByType:t=>Ue(`/filaments/by-type/${t}`),getNotificationProviders:()=>Ue("/notifications/"),getNotificationProvider:t=>Ue(`/notifications/${t}`),createNotificationProvider:t=>Ue("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Ue(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Ue(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Ue(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Ue("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Ue("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Ue("/notification-templates"),getNotificationTemplate:t=>Ue(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Ue(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Ue(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Ue("/notification-templates/variables"),previewTemplate:t=>Ue("/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)),Ue(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Ue(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Ue(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Ue("/spoolman/status"),connectSpoolman:()=>Ue("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Ue("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Ue(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Ue("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Ue("/spoolman/spools"),getSpoolmanFilaments:()=>Ue("/spoolman/filaments"),getUnlinkedSpools:()=>Ue("/spoolman/spools/unlinked"),linkSpool:(t,e)=>Ue(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>Ue("/updates/version"),checkForUpdates:()=>Ue("/updates/check"),applyUpdate:()=>Ue("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Ue("/updates/status"),getMaintenanceTypes:()=>Ue("/maintenance/types"),createMaintenanceType:t=>Ue("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Ue(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Ue(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Ue("/maintenance/overview"),getPrinterMaintenance:t=>Ue(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Ue(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Ue(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Ue(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Ue("/maintenance/summary"),setPrinterHours:(t,e)=>Ue(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Ue(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Ue(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${Dn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${Dn}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Ue(`/printers/${t}/camera/test`),getExternalLinks:()=>Ue("/external-links/"),getExternalLink:t=>Ue(`/external-links/${t}`),createExternalLink:t=>Ue("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Ue(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Ue(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Ue("/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(`${Dn}/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=>Ue(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${Dn}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Ue(`/projects/?${e}`)},getProject:t=>Ue(`/projects/${t}`),createProject:t=>Ue("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Ue(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Ue(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Ue(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Ue(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Ue(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Ue(`/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(`${Dn}/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)=>`${Dn}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Ue(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Ue(`/projects/${t}/bom`),createBOMItem:(t,e)=>Ue(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Ue(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Ue(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Ue("/projects/templates/"),createTemplateFromProject:t=>Ue(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Ue(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Ue(`/projects/${t}/timeline?limit=${e}`),getAPIKeys:()=>Ue("/api-keys/"),createAPIKey:t=>Ue("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Ue(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Ue(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Ue(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Ue("/system/info")},al={getInfo:()=>Ue("/discovery/info"),getStatus:()=>Ue("/discovery/status"),startDiscovery:(t=10)=>Ue(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Ue("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Ue("/discovery/printers"),startSubnetScan:(t,e=1)=>Ue("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Ue("/discovery/scan/status"),stopSubnetScan:()=>Ue("/discovery/scan/stop",{method:"POST"})},x1={getSettings:()=>Ue("/settings/virtual-printer"),getModels:()=>Ue("/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),Ue(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},Ex={list:()=>Ue("/pending-uploads/"),getCount:()=>Ue("/pending-uploads/count"),get:t=>Ue(`/pending-uploads/${t}`),archive:(t,e)=>Ue(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Ue(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Ue("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Ue("/pending-uploads/discard-all",{method:"DELETE"})},b1={checkUpdates:()=>Ue("/firmware/updates"),checkPrinterUpdate:t=>Ue(`/firmware/updates/${t}`),prepareUpload:t=>Ue(`/firmware/updates/${t}/prepare`),startUpload:t=>Ue(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Ue(`/firmware/updates/${t}/upload/status`)},y1={getDebugLoggingState:()=>Ue("/support/debug-logging"),setDebugLogging:t=>Ue("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t=await fetch(`${Dn}/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),o=document.createElement("a");o.href=a,o.download=r,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(a)}},mW=S.createContext(void 0);function ahe({children:t}){const[e,n]=S.useState(()=>{const T=localStorage.getItem("theme-mode"),L=localStorage.getItem("theme");return T||L||"dark"}),[r,i]=S.useState(()=>localStorage.getItem("dark-style")||"classic"),[a,o]=S.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=S.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=S.useState(()=>localStorage.getItem("light-style")||"classic"),[f,g]=S.useState(()=>localStorage.getItem("light-background")||"neutral"),[p,x]=S.useState(()=>localStorage.getItem("light-accent")||"green");S.useEffect(()=>{ye.getSettings().then(T=>{T.dark_style&&(i(T.dark_style),localStorage.setItem("dark-style",T.dark_style)),T.dark_background&&(o(T.dark_background),localStorage.setItem("dark-background",T.dark_background)),T.dark_accent&&(c(T.dark_accent),localStorage.setItem("dark-accent",T.dark_accent)),T.light_style&&(d(T.light_style),localStorage.setItem("light-style",T.light_style)),T.light_background&&(g(T.light_background),localStorage.setItem("light-background",T.light_background)),T.light_accent&&(x(T.light_accent),localStorage.setItem("light-accent",T.light_accent))}).catch(()=>{})},[]),S.useEffect(()=>{const T=document.documentElement;T.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"?(T.classList.add("dark"),T.classList.add(`style-${r}`),T.classList.add(`bg-${a}`),T.classList.add(`accent-${l}`)):(T.classList.add(`style-${u}`),T.classList.add(`bg-${f}`),T.classList.add(`accent-${p}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,a,l,u,f,p]);const y=()=>n(T=>T==="dark"?"light":"dark"),b=T=>n(T),v=T=>{i(T),localStorage.setItem("dark-style",T),ye.updateSettings({dark_style:T}).catch(()=>{})},E=T=>{o(T),localStorage.setItem("dark-background",T),ye.updateSettings({dark_background:T}).catch(()=>{})},w=T=>{c(T),localStorage.setItem("dark-accent",T),ye.updateSettings({dark_accent:T}).catch(()=>{})},N=T=>{d(T),localStorage.setItem("light-style",T),ye.updateSettings({light_style:T}).catch(()=>{})},A=T=>{g(T),localStorage.setItem("light-background",T),ye.updateSettings({light_background:T}).catch(()=>{})},C=T=>{x(T),localStorage.setItem("light-accent",T),ye.updateSettings({light_accent:T}).catch(()=>{})};return s.jsx(mW.Provider,{value:{mode:e,darkStyle:r,darkBackground:a,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:p,toggleMode:y,setMode:b,setDarkStyle:v,setDarkBackground:E,setDarkAccent:w,setLightStyle:N,setLightBackground:A,setLightAccent:C},children:t})}function fg(){const t=S.useContext(mW);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function Mt({children:t,className:e="",onClick:n,onContextMenu:r,...i}){return s.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary card-shadow ${e}`,onClick:n,onContextMenu:r,...i,children:t})}function vi({children:t,className:e=""}){return s.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function At({children:t,className:e=""}){return s.jsx("div",{className:`p-6 ${e}`,children:t})}function she(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 DU({children:t}){return s.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 ohe({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=lg(),i=she(n,e,r);return S.useEffect(()=>{const a=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:s.jsx(Mt,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:s.jsxs(At,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(o3,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(a=>s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:a.category}),s.jsx("div",{className:"space-y-2",children:a.items.map(o=>s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[o.description,o.isExternal&&s.jsx(qr,{className:"w-3 h-3 text-bambu-gray"})]}),s.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>s.jsx(DU,{children:l},l))})]},o.description))})]},a.category))}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",s.jsx(DU,{children:"Esc"})," or click outside to close"]})})]})})})}function Ne({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",o={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 s.jsx("button",{className:`${a} ${o[t]} ${l[e]} ${n}`,...i,children:r})}function Qn({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",onConfirm:a,onCancel:o}){S.useEffect(()=>{const u=d=>{d.key==="Escape"&&o()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[o]);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 s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:o,children:s.jsx(Mt,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:s.jsxs(At,{className:"p-6",children:[s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${c.icon}`,children:s.jsx(zn,{className:"w-6 h-6"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),s.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),s.jsxs("div",{className:"flex gap-3 mt-6",children:[s.jsx(Ne,{variant:"secondary",onClick:o,className:"flex-1",children:r}),s.jsx(Ne,{onClick:a,className:`flex-1 ${c.button}`,children:n})]})]})})})}function lhe({plug:t}){const e=cn(),[n,r]=S.useState(null),{data:i,isLoading:a}=ft({queryKey:["smart-plug-status",t.id],queryFn:()=>ye.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=bt({mutationFn:f=>ye.controlSmartPlug(t.id,f),onSuccess:()=>{e.invalidateQueries({queryKey:["smart-plug-status",t.id]})}}),l=i?.state==="ON",c=i?.reachable??!1,u=o.isPending,d=()=>{n&&(o.mutate(n),r(null))};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between py-2 px-3 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:`p-1.5 rounded ${c?l?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:s.jsx(mo,{className:`w-4 h-4 ${c?l?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white font-medium",children:t.name}),s.jsx("div",{className:"flex items-center gap-1 text-xs",children:a?s.jsx(xt,{className:"w-3 h-3 text-bambu-gray animate-spin"}):c?s.jsxs(s.Fragment,{children:[s.jsx(TR,{className:"w-3 h-3 text-bambu-green"}),s.jsx("span",{className:l?"text-bambu-green":"text-bambu-gray",children:i?.state||"Unknown"}),i?.energy?.power!==null&&i?.energy?.power!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),s.jsx(cf,{className:"w-3 h-3 text-yellow-400"}),s.jsxs("span",{className:"text-yellow-400",children:[Math.round(i.energy.power),"W"]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Db,{className:"w-3 h-3 text-red-400"}),s.jsx("span",{className:"text-red-400",children:"Offline"})]})})]})]}),s.jsxs("div",{className:"flex gap-1",children:[s.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?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(Ol,{className:"w-4 h-4"})}),s.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?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(uM,{className:"w-4 h-4"})})]})]}),n&&s.jsx(Qn,{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 OU({onClose:t}){const{data:e,isLoading:n}=ft({queryKey:["smart-plugs"],queryFn:ye.getSmartPlugs}),r=e?.filter(i=>i.show_in_switchbar)||[];return s.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:[s.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary",children:s.jsxs("h3",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[s.jsx(mo,{className:"w-4 h-4 text-bambu-green"}),"Smart Switches"]})}),s.jsx("div",{className:"p-2 max-h-80 overflow-y-auto",children:n?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(xt,{className:"w-6 h-6 text-bambu-gray animate-spin"})}):r.length===0?s.jsxs("div",{className:"text-center py-6 px-4",children:[s.jsx(mo,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"No switches in switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:'Enable "Show in Switchbar" in Settings > Smart Plugs'})]}):s.jsx("div",{className:"space-y-1",children:r.map(i=>s.jsx(lhe,{plug:i},i.id))})})]})}const pW=[{name:"globe",icon:sf},{name:"link",icon:Rb},{name:"external-link",icon:qr},{name:"book",icon:ule},{name:"file-text",icon:is},{name:"home",icon:Vce},{name:"star",icon:lf},{name:"heart",icon:Bce},{name:"bookmark",icon:hle},{name:"shopping-cart",icon:aW},{name:"music",icon:u3},{name:"video",icon:hW},{name:"image",icon:jb},{name:"camera",icon:kp},{name:"map",icon:fue},{name:"compass",icon:Kle},{name:"coffee",icon:Vle},{name:"gift",icon:Cce},{name:"wrench",icon:Ad},{name:"zap",icon:cf},{name:"cloud",icon:oM},{name:"database",icon:Pp},{name:"folder",icon:tW},{name:"mail",icon:due},{name:"phone",icon:zue},{name:"user",icon:d3},{name:"users",icon:$de},{name:"server",icon:vh},{name:"terminal",icon:lW},{name:"code",icon:Q9}];function mM(t){return pW.find(n=>n.name===t)?.icon||Rb}function che({value:t,onChange:e}){const[n,r]=S.useState(!1),i=mM(t);return s.jsxs("div",{className:"relative",children:[s.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:[s.jsx(i,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),s.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:s.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:pW.map(({name:a,icon:o})=>s.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:s.jsx(o,{className:"w-5 h-5"})},a))})})]})]})}const LU=768;function gW(){const[t,e]=S.useState(()=>typeof window<"u"?window.innerWidth<LU:!1);return S.useEffect(()=>{const n=window.matchMedia(`(max-width: ${LU-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const B0=[{id:"printers",to:"/",icon:Ei,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:fo,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:Wr,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:wle,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:oM,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Ad,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:ha,labelKey:"nav.projects"},{id:"settings",to:"/settings",icon:hM,labelKey:"nav.settings"}];function uhe(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return B0.map(e=>e.id)}return B0.map(e=>e.id)}function dhe(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function iN(t){return t.startsWith("ext-")}function xW(){return localStorage.getItem("defaultView")||"/"}function hhe(t){localStorage.setItem("defaultView",t)}function fhe(){const t=kb(),e=Fd(),{mode:n,toggleMode:r}=fg(),{t:i}=lg(),a=gW(),[o,l]=S.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[c,u]=S.useState(!1),[d,f]=S.useState(!1),[g,p]=S.useState(!1),[x,y]=S.useState(uhe),[b,v]=S.useState(null),[E,w]=S.useState(null),N=S.useRef(!1),[A,C]=S.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),{data:T}=ft({queryKey:["version"],queryFn:ye.getVersion,staleTime:1/0}),{data:L}=ft({queryKey:["settings"],queryFn:ye.getSettings,staleTime:300*1e3}),{data:k}=ft({queryKey:["updateCheck"],queryFn:ye.checkForUpdates,enabled:L?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:D}=ft({queryKey:["external-links"],queryFn:ye.getExternalLinks}),{data:U}=ft({queryKey:["smart-plugs"],queryFn:ye.getSmartPlugs,staleTime:30*1e3}),O=U?.some(ue=>ue.show_in_switchbar)??!1,{data:q}=ft({queryKey:["debugLogging"],queryFn:y1.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),[R,G]=S.useState(null);S.useEffect(()=>{if(!q?.enabled||!q.enabled_at){G(null);return}const ue=new Date(q.enabled_at).getTime(),le=()=>{G(Math.floor((Date.now()-ue)/1e3))};le();const he=setInterval(le,1e3);return()=>clearInterval(he)},[q?.enabled,q?.enabled_at]);const Y=new Map(B0.map(ue=>[ue.id,ue])),V=new Map((D||[]).map(ue=>[`ext-${ue.id}`,ue])),K=(()=>{const ue=[],le=new Set;for(const he of x)(Y.has(he)||V.has(he))&&(ue.push(he),le.add(he));for(const he of B0)le.has(he.id)||(ue.push(he.id),le.add(he.id));for(const he of D||[]){const pe=`ext-${he.id}`;le.has(pe)||(ue.push(pe),le.add(pe))}return ue})(),J=(ue,le)=>{v(le),ue.dataTransfer.effectAllowed="move",ue.dataTransfer.setData("text/plain",le)},X=(ue,le)=>{ue.preventDefault(),ue.dataTransfer.dropEffect="move",w(le)},F=()=>{w(null)},W=(ue,le)=>{if(ue.preventDefault(),b===null||b===le){v(null),w(null);return}const he=[...K],pe=he.indexOf(b),Me=he.indexOf(le);if(pe===-1||Me===-1){v(null),w(null);return}he.splice(pe,1),he.splice(Me,0,b),y(he),dhe(he),v(null),w(null)},ee=()=>{v(null),w(null)},ie=k?.update_available&&k.latest_version&&k.latest_version!==A,ae=()=>{k?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",k.latest_version),C(k.latest_version))};S.useEffect(()=>{if(!N.current&&e.pathname==="/"){const ue=xW();ue!=="/"&&(N.current=!0,t(ue,{replace:!0}))}},[e.pathname,t]),S.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(o))},[o]),S.useEffect(()=>{a&&u(!1)},[e.pathname,a]);const de=S.useCallback(ue=>{const le=ue.target;if(!(le.tagName==="INPUT"||le.tagName==="TEXTAREA"||le.isContentEditable)&&!ue.metaKey&&!ue.ctrlKey&&!ue.altKey){const he=parseInt(ue.key);if(he>=1&&he<=K.length&&he<=9){const pe=K[he-1];if(ue.preventDefault(),iN(pe)){const Me=pe.replace("ext-","");t(`/external/${Me}`)}else{const Me=Y.get(pe);Me&&t(Me.to)}return}switch(ue.key){case"?":ue.preventDefault(),f(!0);break;case"Escape":f(!1);break}}},[t,K,Y]);return S.useEffect(()=>(document.addEventListener("keydown",de),()=>document.removeEventListener("keydown",de)),[de]),s.jsxs("div",{className:"flex min-h-screen",children:[a&&s.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:[s.jsx("button",{onClick:()=>u(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:s.jsx(_ue,{className:"w-6 h-6 text-white"})}),s.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&&s.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>u(!1)}),s.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 ${o?"w-64":"w-16"}`}`,children:[s.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a||o?"p-4":"p-2"}`,children:s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:a||o?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),s.jsx("nav",{className:"flex-1 p-2",children:s.jsx("ul",{className:"space-y-2",children:K.map(ue=>{if(iN(ue)){const he=V.get(ue);if(!he)return null;const pe=he.custom_icon?null:mM(he.icon);return s.jsx("li",{draggable:!0,onDragStart:Me=>J(Me,ue),onDragOver:Me=>X(Me,ue),onDragLeave:F,onDrop:Me=>W(Me,ue),onDragEnd:ee,className:`relative ${b===ue?"opacity-50":""} ${E===ue&&b!==ue?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(Zx,{to:`/external/${he.id}`,className:({isActive:Me})=>`flex items-center ${a||o?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${Me?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!o?he.name:void 0,children:[o&&!a&&s.jsx(U0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),he.custom_icon?s.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"}`}):pe&&s.jsx(pe,{className:"w-5 h-5 flex-shrink-0"}),(a||o)&&s.jsx("span",{children:he.name})]})},ue)}else{const he=Y.get(ue);if(!he)return null;const{to:pe,icon:Me,labelKey:re}=he;return s.jsx("li",{draggable:!0,onDragStart:We=>J(We,ue),onDragOver:We=>X(We,ue),onDragLeave:F,onDrop:We=>W(We,ue),onDragEnd:ee,className:`relative ${b===ue?"opacity-50":""} ${E===ue&&b!==ue?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(Zx,{to:pe,className:({isActive:We})=>`flex items-center ${a||o?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${We?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!o?i(re):void 0,children:[o&&!a&&s.jsx(U0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),s.jsx(Me,{className:"w-5 h-5 flex-shrink-0"}),(a||o)&&s.jsx("span",{children:i(re)})]})},ue)}})})}),!a&&s.jsx("button",{onClick:()=>l(!o),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(o?"nav.collapseSidebar":"nav.expandSidebar"),children:o?s.jsx(rf,{className:"w-5 h-5"}):s.jsx(Zo,{className:"w-5 h-5"})}),s.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||o?s.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[O&&s.jsxs("div",{className:"relative",children:[s.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:s.jsx(mo,{className:"w-5 h-5"})}),g&&s.jsx(OU,{onClose:()=>p(!1)})]}),s.jsx(Zx,{to:"/system",className:({isActive:ue})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${ue?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(wd,{className:"w-5 h-5"})}),s.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:s.jsx(kU,{className:"w-5 h-5"})}),s.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:s.jsx(o3,{className:"w-5 h-5"})}),s.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"?s.jsx(RU,{className:"w-5 h-5"}):s.jsx(Z1,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex items-center justify-center gap-2",children:[s.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",T?.version||"..."]}),k?.update_available&&s.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:[s.jsx(nN,{className:"w-4 h-4"}),s.jsx("span",{children:i("nav.update")})]})]})]}):s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[k?.update_available&&s.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:s.jsx(nN,{className:"w-5 h-5"})}),O&&s.jsxs("div",{className:"relative",children:[s.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:s.jsx(mo,{className:"w-5 h-5"})}),g&&s.jsx(OU,{onClose:()=>p(!1)})]}),s.jsx(Zx,{to:"/system",className:({isActive:ue})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${ue?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(wd,{className:"w-5 h-5"})}),s.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:s.jsx(kU,{className:"w-5 h-5"})}),s.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:s.jsx(o3,{className:"w-5 h-5"})}),s.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"?s.jsx(RU,{className:"w-5 h-5"}):s.jsx(Z1,{className:"w-5 h-5"})})]})})]}),s.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${a?"mt-14":o?"ml-64":"ml-16"}`,children:[q?.enabled&&s.jsx("div",{className:"bg-amber-500/20 border-b border-amber-500/30 px-4 py-2 flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(Z9,{className:"w-4 h-4 text-amber-500 animate-pulse"}),s.jsxs("span",{className:"text-amber-200",children:[i("support.debugLoggingActive",{defaultValue:"Debug logging is active"}),R!==null&&s.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(R/60),"m ",R%60,"s)"]})]}),s.jsx("button",{onClick:()=>t("/system"),className:"text-amber-400 hover:text-amber-300 font-medium underline ml-2",children:i("support.manageLogs",{defaultValue:"Manage"})})]})}),ie&&s.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(nN,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{children:i("nav.updateAvailableBanner",{version:k?.latest_version,defaultValue:`Version ${k?.latest_version} is available!`})}),s.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),s.jsx("button",{onClick:ae,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:s.jsx(Bt,{className:"w-4 h-4"})})]}),s.jsx(Cse,{})]}),d&&s.jsx(ohe,{onClose:()=>f(!1),sidebarItems:K.map(ue=>{if(iN(ue)){const le=V.get(ue);return le?{type:"external",label:le.name}:null}else{const le=Y.get(ue);return le?{type:"nav",label:le.labelKey,labelKey:le.labelKey}:null}}).filter(Boolean)})]})}function f0(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function ui(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function Dp(t,e){const n=ui(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function Op(t,e="system",n){const r=ui(t);if(!r)return"";const a=f0(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,a)}function mhe(t,e="system",n){const i=f0({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const bW=S.createContext(void 0);function hr(){const t=S.useContext(bW);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const phe={success:s.jsx(Ar,{className:"w-5 h-5 text-green-400"}),error:s.jsx(Sa,{className:"w-5 h-5 text-red-400"}),warning:s.jsx(Aa,{className:"w-5 h-5 text-yellow-400"}),info:s.jsx(wd,{className:"w-5 h-5 text-blue-400"}),loading:s.jsx(xt,{className:"w-5 h-5 text-bambu-green animate-spin"})},ghe={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 xhe({children:t}){const[e,n]=S.useState([]),r=S.useCallback((o,l="success")=>{const c=Math.random().toString(36).substr(2,9);n(u=>[...u,{id:c,message:o,type:l}]),setTimeout(()=>{n(u=>u.filter(d=>d.id!==c))},3e3)},[]),i=S.useCallback((o,l,c="info")=>{n(u=>u.find(f=>f.id===o)?u.map(f=>f.id===o?{...f,message:l,type:c,persistent:!0}:f):[...u,{id:o,message:l,type:c,persistent:!0}])},[]),a=S.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]);return s.jsxs(bW.Provider,{value:{showToast:r,showPersistentToast:i,dismissToast:a},children:[t,s.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(o=>s.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${ghe[o.type]}`,children:[phe[o.type],s.jsx("span",{className:"text-white text-sm",children:o.message}),s.jsx("button",{onClick:()=>a(o.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(Bt,{className:"w-4 h-4"})})]},o.id))})]})}function bhe(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 IU(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 yhe(t,e){if(e)return tW;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return eW;case"gcode":return is;case"mp4":case"avi":return hd;case"png":case"jpg":case"jpeg":return jb;default:return bR}}function vhe({printerId:t,printerName:e,onClose:n}){const{showToast:r}=hr(),i=cn(),[a,o]=S.useState("/"),[l,c]=S.useState(null),[u,d]=S.useState(""),[f,g]=S.useState(null);S.useEffect(()=>{const T=L=>{L.key==="Escape"&&n()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[n]);const{data:p,isLoading:x,refetch:y}=ft({queryKey:["printerFiles",t,a],queryFn:()=>ye.getPrinterFiles(t,a)}),{data:b}=ft({queryKey:["printerStorage",t],queryFn:()=>ye.getPrinterStorage(t),staleTime:3e4}),v=bt({mutationFn:T=>ye.deletePrinterFile(t,T),onSuccess:(T,L)=>{r(`Deleted: ${L.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(null)},onError:T=>{r(`Delete failed: ${T.message}`,"error")}}),E=T=>{o(T),c(null)},w=()=>{if(a==="/")return;const T=a.split("/").filter(Boolean);T.pop(),o(T.length?"/"+T.join("/"):"/"),c(null)},N=T=>{window.open(ye.getPrinterFileDownloadUrl(t,T),"_blank")},A=T=>{g(T)},C=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[s.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:T=>T.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(_R,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[b&&(b.used_bytes!=null||b.free_bytes!=null)&&s.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[b.used_bytes!=null&&s.jsxs("span",{children:["Used: ",IU(b.used_bytes)]}),b.used_bytes!=null&&b.free_bytes!=null&&s.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),b.free_bytes!=null&&s.jsxs("span",{children:["Free: ",IU(b.free_bytes)]})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]})]}),s.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(T=>s.jsx("button",{onClick:()=>{E(T.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===T.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:T.label},T.path)),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(Ml,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Filter files...",value:u,onChange:T=>d(T.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"})]}),s.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>y(),disabled:x,children:s.jsx(Gr,{className:`w-4 h-4 ${x?"animate-spin":""}`})})]}),s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[s.jsx("button",{onClick:w,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:s.jsx(rf,{className:"w-4 h-4"})}),s.jsx("span",{className:"text-bambu-gray font-mono",children:a})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:x?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):p?.files?.length?s.jsx("div",{className:"space-y-1",children:[...p.files].filter(T=>!u||T.name.toLowerCase().includes(u.toLowerCase())).sort((T,L)=>T.is_directory&&!L.is_directory?-1:!T.is_directory&&L.is_directory?1:T.name.localeCompare(L.name)).map(T=>{const L=yhe(T.name,T.is_directory),k=l===T.path;return s.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:()=>{T.is_directory?E(T.path):c(k?null:T.path)},children:[s.jsx(L,{className:`w-5 h-5 flex-shrink-0 ${T.is_directory?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("span",{className:"flex-1 text-white truncate",children:T.name}),!T.is_directory&&s.jsx("span",{className:"text-sm text-bambu-gray",children:bhe(T.size)}),T.is_directory&&s.jsx(rf,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},T.path)})}):s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:u?`${p?.files?.filter(T=>T.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${p?.files?.length||0} items`:`${p?.files?.length||0} items`}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Ne,{variant:"secondary",disabled:!l,onClick:()=>l&&N(l),children:[s.jsx(Mi,{className:"w-4 h-4"}),"Download"]}),s.jsxs(Ne,{variant:"secondary",disabled:!l||v.isPending,onClick:()=>l&&A(l),className:"text-red-400 hover:text-red-300",children:[v.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(_n,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&s.jsx(Qn,{title:"Delete File",message:`Delete "${f.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{v.mutate(f),g(null)},onCancel:()=>g(null)})]})}function _he({printerId:t,printerName:e,onClose:n}){const r=cn(),[i,a]=S.useState(!0),[o,l]=S.useState(new Set),[c,u]=S.useState(""),[d,f]=S.useState("all"),g=S.useRef(null),{data:p,isLoading:x,refetch:y}=ft({queryKey:["mqtt-logs",t],queryFn:()=>ye.getMQTTLogs(t),refetchInterval:1e3}),b=bt({mutationFn:()=>ye.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),v=bt({mutationFn:()=>ye.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),E=bt({mutationFn:()=>ye.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});S.useEffect(()=>{const k=D=>{D.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(D=>{const U=new Set(D);return U.has(k)?U.delete(k):U.add(k),U})},N=k=>new Date(k).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),A=(k,D)=>{if(k==null)return"<empty>";const U=typeof k=="string"?JSON.parse(k):k,O=JSON.stringify(U,null,D?2:0);return!D&&O.length>100?O.substring(0,100)+"...":O},C=p?.logging_enabled??!1,T=p?.logs??[],L=S.useMemo(()=>T.filter(k=>{if(d!=="all"&&k.direction!==d)return!1;if(c.trim()){const D=c.toLowerCase(),U=k.topic.toLowerCase().includes(D),q=JSON.stringify(k.payload).toLowerCase().includes(D);return U||q}return!0}),[T,c,d]);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[C?s.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>v.mutate(),disabled:v.isPending,children:[s.jsx(Ed,{className:"w-4 h-4"}),"Stop"]}):s.jsxs(Ne,{size:"sm",onClick:()=>b.mutate(),disabled:b.isPending,children:[s.jsx(Gc,{className:"w-4 h-4"}),"Start Logging"]}),s.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>E.mutate(),disabled:E.isPending||T.length===0,children:[s.jsx(_n,{className:"w-4 h-4"}),"Clear"]}),s.jsx(Ne,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:x,children:s.jsx(Gr,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),s.jsx("div",{className:"flex-1"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:i,onChange:k=>a(k.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[L.length,"/",T.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Ml,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.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&&s.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:s.jsx(Bt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[s.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"}),s.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:[s.jsx(F0,{className:"w-3 h-3"}),"In"]}),s.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:[s.jsx(Cp,{className:"w-3 h-3"}),"Out"]})]})]})]}),s.jsx("div",{ref:g,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:T.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!C&&s.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):L.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No messages match your filter"}),s.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):s.jsx("div",{className:"space-y-1",children:L.map((k,D)=>{const U=o.has(D),O=k.direction==="in";return s.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${U?"bg-bambu-dark-secondary":""}`,onClick:()=>w(D),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray shrink-0",children:N(k.timestamp)}),s.jsx("span",{className:`shrink-0 ${O?"text-blue-400":"text-green-400"}`,title:O?"Incoming":"Outgoing",children:O?s.jsx(F0,{className:"w-3 h-3"}):s.jsx(Cp,{className:"w-3 h-3"})}),s.jsx("span",{className:"text-purple-400 shrink-0",children:k.topic})]}),U?s.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:A(k.payload,!0)}):s.jsx("pre",{className:"mt-1 text-white/80 truncate",children:A(k.payload,!1)})]},D)})})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:C?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):s.jsx("span",{children:"Logging stopped"})}),s.jsx(Ne,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const h3={"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 whe(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:zn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:zn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:Aa};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:wd}}}function f3(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 She(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=f3(e.attr,n);return h3[r]!==void 0})}function Mhe(){return"https://wiki.bambulab.com/en/hms/home"}function Ehe({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,o=f3(i.attr,a);return h3[o]!==void 0});return S.useEffect(()=>{const i=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(zn,{className:"w-5 h-5 text-orange-400"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Errors - ",t]})]}),s.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Bt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Aa,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{children:"No errors"})]}):s.jsx("div",{className:"space-y-3",children:r.map((i,a)=>{const{label:o,color:l,bgColor:c,Icon:u}=whe(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=f3(i.attr,d),g=h3[f],p=Mhe(),x=f.replace("_","-");return s.jsx("div",{className:`p-4 rounded-lg ${c} border border-white/10`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(u,{className:`w-5 h-5 ${l} flex-shrink-0 mt-0.5`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsxs("span",{className:`font-mono text-sm ${l}`,children:["[",x,"]"]}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${c} ${l}`,children:o})]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:g}),s.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[s.jsx(qr,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${i.code}-${a}`)})})}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx("p",{className:"text-xs text-bambu-gray",children:"Clear errors on the printer to dismiss them here."})})]})})}function Ahe(t){if(!t)return"ASAP";const e=ui(t);if(!e)return"ASAP";const 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 Nhe({printerId:t}){const{data:e}=ft({queryKey:["queue",t,"pending"],queryFn:()=>ye.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:s.jsx(Nc,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx(Wr,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),s.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[s.jsx(dr,{className:"w-3 h-3"}),Ahe(n?.scheduled_time||null)]}),r>1&&s.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),s.jsx(Zo,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function yW(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=yW(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function On(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=yW(t))&&(r&&(r+=" "),r+=e);return r}var The=["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 CR(t){if(typeof t!="string")return!1;var e=The;return e.includes(t)}var Che=["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"],khe=new Set(Che);function vW(t){return typeof t!="string"?!1:khe.has(t)}function _W(t){return typeof t=="string"&&t.startsWith("data-")}function Ua(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(vW(n)||_W(n))&&(e[n]=t[n]);return e}function uf(t){if(t==null)return null;if(S.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Ua(e)}return typeof t=="object"&&!Array.isArray(t)?Ua(t):null}function fa(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(vW(n)||_W(n)||CR(n))&&(e[n]=t[n]);return e}function Phe(t){return t==null?null:S.isValidElement(t)?fa(t.props):typeof t=="object"&&!Array.isArray(t)?fa(t):null}var jhe=["children","width","height","viewBox","className","style","title","desc"];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 Rhe(t,e){if(t==null)return{};var n,r,i=Dhe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Dhe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var kR=S.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:o,style:l,title:c,desc:u}=t,d=Rhe(t,jhe),f=a||{width:r,height:i,x:0,y:0},g=On("recharts-surface",o);return S.createElement("svg",m3({},fa(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)}),Ohe=["children","className"];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 Lhe(t,e){if(t==null)return{};var n,r,i=Ihe(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 Ihe(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=Lhe(t,Ohe),a=On("recharts-layer",r);return S.createElement("g",p3({className:a},fa(i),{ref:e}),n)}),wW=S.createContext(null),Fhe=()=>S.useContext(wW);function yr(t){return function(){return t}}const SW=Math.cos,J1=Math.sin,Qo=Math.sqrt,ew=Math.PI,pM=2*ew,g3=Math.PI,x3=2*g3,_h=1e-6,Uhe=x3-_h;function MW(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function zhe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return MW;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 Bhe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?MW:zhe(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,o){this._append`C${+e},${+n},${+r},${+i},${this._x1=+a},${this._y1=+o}`}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 o=this._x1,l=this._y1,c=r-e,u=i-n,d=o-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>_h)if(!(Math.abs(f*c-u*d)>_h)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let p=r-o,x=i-l,y=c*c+u*u,b=p*p+x*x,v=Math.sqrt(y),E=Math.sqrt(g),w=a*Math.tan((g3-Math.acos((y+g-b)/(2*v*E)))/2),N=w/E,A=w/v;Math.abs(N-1)>_h&&this._append`L${e+N*d},${n+N*f}`,this._append`A${a},${a},0,0,${+(f*p>d*x)},${this._x1=e+A*c},${this._y1=n+A*u}`}}arc(e,n,r,i,a,o){if(e=+e,n=+n,r=+r,o=!!o,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^o,g=o?i-a:a-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>_h||Math.abs(this._y1-d)>_h)&&this._append`L${u},${d}`,r&&(g<0&&(g=g%x3+x3),g>Uhe?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>_h&&this._append`A${r},${r},0,${+(g>=g3)},${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 PR(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 Bhe(e)}function jR(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function EW(t){this._context=t}EW.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 gM(t){return new EW(t)}function AW(t){return t[0]}function NW(t){return t[1]}function TW(t,e){var n=yr(!0),r=null,i=gM,a=null,o=PR(l);t=typeof t=="function"?t:t===void 0?AW:yr(t),e=typeof e=="function"?e:e===void 0?NW:yr(e);function l(c){var u,d=(c=jR(c)).length,f,g=!1,p;for(r==null&&(a=i(p=o())),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:yr(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:yr(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:yr(!!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 Dv(t,e,n){var r=null,i=yr(!0),a=null,o=gM,l=null,c=PR(u);t=typeof t=="function"?t:t===void 0?AW:yr(+t),e=typeof e=="function"?e:yr(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?NW:yr(+n);function u(f){var g,p,x,y=(f=jR(f)).length,b,v=!1,E,w=new Array(y),N=new Array(y);for(a==null&&(l=o(E=c())),g=0;g<=y;++g){if(!(g<y&&i(b=f[g],g,f))===v)if(v=!v)p=g,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=g-1;x>=p;--x)l.point(w[x],N[x]);l.lineEnd(),l.areaEnd()}v&&(w[g]=+t(b,g,f),N[g]=+e(b,g,f),l.point(r?+r(b,g,f):w[g],n?+n(b,g,f):N[g]))}if(E)return l=null,E+""||null}function d(){return TW().defined(i).curve(o).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:yr(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:yr(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:yr(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:yr(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:yr(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:yr(+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:yr(!!f),u):i},u.curve=function(f){return arguments.length?(o=f,a!=null&&(l=o(a)),u):o},u.context=function(f){return arguments.length?(f==null?a=l=null:l=o(a=f),u):a},u}class CW{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 Hhe(t){return new CW(t,!0)}function $he(t){return new CW(t,!1)}const RR={draw(t,e){const n=Qo(e/ew);t.moveTo(n,0),t.arc(0,0,n,0,pM)}},Vhe={draw(t,e){const n=Qo(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()}},kW=Qo(1/3),Ghe=kW*2,Whe={draw(t,e){const n=Qo(e/Ghe),r=n*kW;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},qhe={draw(t,e){const n=Qo(e),r=-n/2;t.rect(r,r,n,n)}},Khe=.8908130915292852,PW=J1(ew/10)/J1(7*ew/10),Xhe=J1(pM/10)*PW,Yhe=-SW(pM/10)*PW,Zhe={draw(t,e){const n=Qo(e*Khe),r=Xhe*n,i=Yhe*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const o=pM*a/5,l=SW(o),c=J1(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},aN=Qo(3),Qhe={draw(t,e){const n=-Qo(e/(aN*3));t.moveTo(0,n*2),t.lineTo(-aN*n,-n),t.lineTo(aN*n,-n),t.closePath()}},qs=-.5,Ks=Qo(3)/2,b3=1/Qo(12),Jhe=(b3/2+1)*3,efe={draw(t,e){const n=Qo(e/Jhe),r=n/2,i=n*b3,a=r,o=n*b3+n,l=-a,c=o;t.moveTo(r,i),t.lineTo(a,o),t.lineTo(l,c),t.lineTo(qs*r-Ks*i,Ks*r+qs*i),t.lineTo(qs*a-Ks*o,Ks*a+qs*o),t.lineTo(qs*l-Ks*c,Ks*l+qs*c),t.lineTo(qs*r+Ks*i,qs*i-Ks*r),t.lineTo(qs*a+Ks*o,qs*o-Ks*a),t.lineTo(qs*l+Ks*c,qs*c-Ks*l),t.closePath()}};function tfe(t,e){let n=null,r=PR(i);t=typeof t=="function"?t:yr(t||RR),e=typeof e=="function"?e:yr(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:yr(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:yr(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function tw(){}function nw(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 jW(t){this._context=t}jW.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:nw(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:nw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function nfe(t){return new jW(t)}function RW(t){this._context=t}RW.prototype={areaStart:tw,areaEnd:tw,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:nw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function rfe(t){return new RW(t)}function DW(t){this._context=t}DW.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:nw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function ife(t){return new DW(t)}function OW(t){this._context=t}OW.prototype={areaStart:tw,areaEnd:tw,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 afe(t){return new OW(t)}function FU(t){return t<0?-1:1}function UU(t,e,n){var r=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(r||i<0&&-0),o=(n-t._y1)/(i||r<0&&-0),l=(a*i+o*r)/(r+i);return(FU(a)+FU(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(l))||0}function zU(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function sN(t,e,n){var r=t._x0,i=t._y0,a=t._x1,o=t._y1,l=(a-r)/3;t._context.bezierCurveTo(r+l,i+l*e,a-l,o-l*n,a,o)}function rw(t){this._context=t}rw.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:sN(this,this._t0,zU(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,sN(this,zU(this,n=UU(this,t,e)),n);break;default:sN(this,this._t0,n=UU(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function LW(t){this._context=new IW(t)}(LW.prototype=Object.create(rw.prototype)).point=function(t,e){rw.prototype.point.call(this,e,t)};function IW(t){this._context=t}IW.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 sfe(t){return new rw(t)}function ofe(t){return new LW(t)}function FW(t){this._context=t}FW.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=BU(t),i=BU(e),a=0,o=1;o<n;++a,++o)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],t[o],e[o]);(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 BU(t){var e,n=t.length-1,r,i=new Array(n),a=new Array(n),o=new Array(n);for(i[0]=0,a[0]=2,o[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,a[e]=4,o[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,a[n-1]=7,o[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/a[e-1],a[e]-=r,o[e]-=r*o[e-1];for(i[n-1]=o[n-1]/a[n-1],e=n-2;e>=0;--e)i[e]=(o[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 lfe(t){return new FW(t)}function xM(t,e){this._context=t,this._t=e}xM.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 cfe(t){return new xM(t,.5)}function ufe(t){return new xM(t,0)}function dfe(t){return new xM(t,1)}function Lp(t,e){if((o=t.length)>1)for(var n=1,r,i,a=t[e[0]],o,l=a.length;n<o;++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 y3(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function hfe(t,e){return t[e]}function ffe(t){const e=[];return e.key=t,e}function mfe(){var t=yr([]),e=y3,n=Lp,r=hfe;function i(a){var o=Array.from(t.apply(this,arguments),ffe),l,c=o.length,u=-1,d;for(const f of a)for(l=0,++u;l<c;++l)(o[l][u]=[0,+r(f,o[l].key,u,a)]).data=f;for(l=0,d=jR(e(o));l<c;++l)o[d[l]].index=l;return n(o,d),o}return i.keys=function(a){return arguments.length?(t=typeof a=="function"?a:yr(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:yr(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?y3:typeof a=="function"?a:yr(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??Lp,i):n},i}function pfe(t,e){if((r=t.length)>0){for(var n,r,i=0,a=t[0].length,o;i<a;++i){for(o=n=0;n<r;++n)o+=t[n][i][1]||0;if(o)for(n=0;n<r;++n)t[n][i][1]/=o}Lp(t,e)}}function gfe(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,a=r.length;n<a;++n){for(var o=0,l=0;o<i;++o)l+=t[o][n][1]||0;r[n][1]+=r[n][0]=-l/2}Lp(t,e)}}function xfe(t,e){if(!(!((o=t.length)>0)||!((a=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,a,o;r<a;++r){for(var l=0,c=0,u=0;l<o;++l){for(var d=t[e[l]],f=d[r][1]||0,g=d[r-1][1]||0,p=(f-g)/2,x=0;x<l;++x){var y=t[e[x]],b=y[r][1]||0,v=y[r-1][1]||0;p+=b-v}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,Lp(t,e)}}var oN={},lN={},HU;function bfe(){return HU||(HU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(lN)),lN}var cN={},$U;function UW(){return $U||($U=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})(cN)),cN}var uN={},VU;function DR(){return VU||(VU=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})(uN)),uN}var dN={},hN={},GU;function yfe(){return GU||(GU=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})(hN)),hN}var WU;function OR(){return WU||(WU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=yfe(),n=DR();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const a=[],o=i.length;if(o===0)return a;let l=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(a.push(""),l++);l<o;){const f=i[l];u?f==="\\"&&l+1<o?(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})(dN)),dN}var qU;function LR(){return qU||(qU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bfe(),n=UW(),r=DR(),i=OR();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 o(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 o(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})(oN)),oN}var fN,KU;function vfe(){return KU||(KU=1,fN=LR().get),fN}var _fe=vfe();const df=wo(_fe);var Wi=t=>t===0?0:t>0?1:-1,ds=t=>typeof t=="number"&&t!=+t,Wc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Lt=t=>(typeof t=="number"||t instanceof Number)&&!ds(t),yo=t=>Lt(t)||typeof t=="string",wfe=0,H0=t=>{var e=++wfe;return"".concat(t||"").concat(e)},Ea=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(!Lt(e)&&typeof e!="string")return r;var a;if(Wc(e)){if(n==null)return r;var o=e.indexOf("%");a=n*parseFloat(e.slice(0,o))/100}else a=+e;return ds(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},zW=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 Lt(t)&&Lt(e)?t+n*(e-t):e}function BW(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):df(r,e))===n)}var Nr=t=>t===null||typeof t>"u",Ob=t=>Nr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function Sfe(t){return t!=null}function Lb(){}var Mfe=["type","size","sizeType"];function v3(){return v3=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},v3.apply(null,arguments)}function XU(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 YU(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?XU(Object(n),!0).forEach(function(r){Efe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):XU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Efe(t,e,n){return(e=Afe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Afe(t){var e=Nfe(t,"string");return typeof e=="symbol"?e:e+""}function Nfe(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 Tfe(t,e){if(t==null)return{};var n,r,i=Cfe(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 Cfe(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 HW={symbolCircle:RR,symbolCross:Vhe,symbolDiamond:Whe,symbolSquare:qhe,symbolStar:Zhe,symbolTriangle:Qhe,symbolWye:efe},kfe=Math.PI/180,Pfe=t=>{var e="symbol".concat(Ob(t));return HW[e]||RR},jfe=(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*kfe;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}},Rfe=(t,e)=>{HW["symbol".concat(Ob(t))]=e},IR=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=Tfe(t,Mfe),a=YU(YU({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var g=Pfe(o),p=tfe().type(g).size(jfe(n,r,o)),x=p();if(x!==null)return x},{className:c,cx:u,cy:d}=a,f=fa(a);return Lt(u)&&Lt(d)&&Lt(n)?S.createElement("path",v3({},f,{className:On("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};IR.registerSymbol=Rfe;var $W=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,FR=(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=>{CR(i)&&(r[i]=(a=>n[i](n,a)))}),r},Dfe=(t,e,n)=>r=>(t(e,n,r),null),Ib=(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];CR(i)&&typeof a=="function"&&(r||(r={}),r[i]=Dfe(a,e,n))}),r};function ZU(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 Ofe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ZU(Object(n),!0).forEach(function(r){Lfe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ZU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Lfe(t,e,n){return(e=Ife(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ife(t){var e=Ffe(t,"string");return typeof e=="symbol"?e:e+""}function Ffe(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=Ofe({},t),r=e,i=Object.keys(e),a=i.reduce((o,l)=>(o[l]===void 0&&r[l]!==void 0&&(o[l]=r[l]),o),n);return a}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)}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 Ufe(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){zfe(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 zfe(t,e,n){return(e=Bfe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Bfe(t){var e=Hfe(t,"string");return typeof e=="symbol"?e:e+""}function Hfe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Js=32,$fe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function Vfe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Js/2,a=Js/6,o=Js/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:Js,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(o,`
  11. A`).concat(a,",").concat(a,",0,1,1,").concat(2*o,",").concat(i,`
  12. H`).concat(Js,"M").concat(2*o,",").concat(i,`
  13. A`).concat(a,",").concat(a,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return S.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(Js/8,"h").concat(Js,"v").concat(Js*3/4,"h").concat(-Js,"z"),className:"recharts-legend-icon"});if(S.isValidElement(e.legendIcon)){var d=Ufe({},e);return delete d.legendIcon,S.cloneElement(e.legendIcon,d)}return S.createElement(IR,{fill:l,cx:i,cy:i,size:Js,sizeType:"diameter",type:c})}function Gfe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:o}=t,l={x:0,y:0,width:Js,height:Js},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=On({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?a:d.color,y=g?g(d.value,d,f):d.value;return S.createElement("li",iw({className:p,style:c,key:"legend-item-".concat(f)},Ib(t,d,f)),S.createElement(kR,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(y," legend icon")},S.createElement(Vfe,{data:d,iconType:o,inactiveColor:a})),S.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},y))})}var Wfe=t=>{var e=Lr(t,$fe),{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(Gfe,iw({},e,{payload:n})))},mN={},pN={},JU;function qfe(){return JU||(JU=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 o=n[a],l=r(o);i.has(l)||i.set(l,o)}return Array.from(i.values())}t.uniqBy=e})(pN)),pN}var gN={},ez;function VW(){return ez||(ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(gN)),gN}var xN={},bN={},yN={},tz;function Kfe(){return tz||(tz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(yN)),yN}var nz;function UR(){return nz||(nz=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})(bN)),bN}var vN={},rz;function Xfe(){return rz||(rz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(vN)),vN}var iz;function Yfe(){return iz||(iz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UR(),n=Xfe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(xN)),xN}var _N={},wN={},az;function Zfe(){return az||(az=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LR();function n(r){return function(i){return e.get(i,r)}}t.property=n})(wN)),wN}var SN={},MN={},EN={},AN={},sz;function GW(){return sz||(sz=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})(AN)),AN}var NN={},oz;function WW(){return oz||(oz=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})(NN)),NN}var TN={},lz;function qW(){return lz||(lz=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})(TN)),TN}var cz;function Qfe(){return cz||(cz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=GW(),n=WW(),r=qW();function i(d,f,g){return typeof g!="function"?i(d,f,()=>{}):a(d,f,function p(x,y,b,v,E,w){const N=g(x,y,b,v,E,w);return N!==void 0?!!N:a(x,y,p,w)},new Map)}function a(d,f,g,p){if(f===d)return!0;switch(typeof f){case"object":return o(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 o(d,f,g,p){if(f==null)return!0;if(Array.isArray(f))return c(d,f,g,p);if(f instanceof Map)return l(d,f,g,p);if(f instanceof Set)return u(d,f,g,p);const x=Object.keys(f);if(d==null)return x.length===0;if(x.length===0)return!0;if(p?.has(f))return p.get(f)===d;p?.set(f,d);try{for(let y=0;y<x.length;y++){const b=x[y];if(!n.isPrimitive(d)&&!(b in d)||f[b]===void 0&&d[b]!==void 0||f[b]===null&&d[b]!==null||!g(d[b],f[b],b,d,f,p))return!1}return!0}finally{p?.delete(f)}}function l(d,f,g,p){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,y]of f.entries()){const b=d.get(x);if(g(b,y,x,d,f,p)===!1)return!1}return!0}function c(d,f,g,p){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let y=0;y<f.length;y++){const b=f[y];let v=!1;for(let E=0;E<d.length;E++){if(x.has(E))continue;const w=d[E];let N=!1;if(g(w,b,y,d,f,p)&&(N=!0),N){x.add(E),v=!0;break}}if(!v)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})(EN)),EN}var uz;function KW(){return uz||(uz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Qfe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(MN)),MN}var CN={},kN={},PN={},dz;function Jfe(){return dz||(dz=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})(PN)),PN}var jN={},hz;function XW(){return hz||(hz=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})(jN)),jN}var RN={},fz;function YW(){return fz||(fz=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]",o="[object Symbol]",l="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",g="[object ArrayBuffer]",p="[object Object]",x="[object Error]",y="[object DataView]",b="[object Uint8Array]",v="[object Uint8ClampedArray]",E="[object Uint16Array]",w="[object Uint32Array]",N="[object BigUint64Array]",A="[object Int8Array]",C="[object Int16Array]",T="[object Int32Array]",L="[object BigInt64Array]",k="[object Float32Array]",D="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=g,t.arrayTag=d,t.bigInt64ArrayTag=L,t.bigUint64ArrayTag=N,t.booleanTag=i,t.dataViewTag=y,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=k,t.float64ArrayTag=D,t.functionTag=f,t.int16ArrayTag=C,t.int32ArrayTag=T,t.int8ArrayTag=A,t.mapTag=c,t.numberTag=r,t.objectTag=p,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=E,t.uint32ArrayTag=w,t.uint8ArrayTag=b,t.uint8ClampedArrayTag=v})(RN)),RN}var DN={},mz;function eme(){return mz||(mz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(DN)),DN}var pz;function ZW(){return pz||(pz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Jfe(),n=XW(),r=YW(),i=WW(),a=eme();function o(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,g,p=new Map,x=void 0){const y=x?.(d,f,g,p);if(y!==void 0)return y;if(i.isPrimitive(d))return d;if(p.has(d))return p.get(d);if(Array.isArray(d)){const b=new Array(d.length);p.set(d,b);for(let v=0;v<d.length;v++)b[v]=l(d[v],v,g,p,x);return Object.hasOwn(d,"index")&&(b.index=d.index),Object.hasOwn(d,"input")&&(b.input=d.input),b}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const b=new RegExp(d.source,d.flags);return b.lastIndex=d.lastIndex,b}if(d instanceof Map){const b=new Map;p.set(d,b);for(const[v,E]of d)b.set(v,l(E,v,g,p,x));return b}if(d instanceof Set){const b=new Set;p.set(d,b);for(const v of d)b.add(l(v,void 0,g,p,x));return b}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const b=new(Object.getPrototypeOf(d)).constructor(d.length);p.set(d,b);for(let v=0;v<d.length;v++)b[v]=l(d[v],v,g,p,x);return b}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const b=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return p.set(d,b),c(b,d,g,p,x),b}if(typeof File<"u"&&d instanceof File){const b=new File([d],d.name,{type:d.type});return p.set(d,b),c(b,d,g,p,x),b}if(typeof Blob<"u"&&d instanceof Blob){const b=new Blob([d],{type:d.type});return p.set(d,b),c(b,d,g,p,x),b}if(d instanceof Error){const b=new d.constructor;return p.set(d,b),b.message=d.message,b.name=d.name,b.stack=d.stack,b.cause=d.cause,c(b,d,g,p,x),b}if(d instanceof Boolean){const b=new Boolean(d.valueOf());return p.set(d,b),c(b,d,g,p,x),b}if(d instanceof Number){const b=new Number(d.valueOf());return p.set(d,b),c(b,d,g,p,x),b}if(d instanceof String){const b=new String(d.valueOf());return p.set(d,b),c(b,d,g,p,x),b}if(typeof d=="object"&&u(d)){const b=Object.create(Object.getPrototypeOf(d));return p.set(d,b),c(b,d,g,p,x),b}return d}function c(d,f,g=d,p,x){const y=[...Object.keys(f),...e.getSymbols(f)];for(let b=0;b<y.length;b++){const v=y[b],E=Object.getOwnPropertyDescriptor(d,v);(E==null||E.writable)&&(d[v]=l(f[v],v,g,p,x))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=o,t.cloneDeepWithImpl=l,t.copyProperties=c})(kN)),kN}var gz;function tme(){return gz||(gz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ZW();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(CN)),CN}var xz;function nme(){return xz||(xz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=KW(),n=tme();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(SN)),SN}var ON={},LN={},IN={},bz;function rme(){return bz||(bz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ZW(),n=YW();function r(i,a){return e.cloneDeepWith(i,(o,l,c,u)=>{const d=a?.(o,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})(IN)),IN}var yz;function ime(){return yz||(yz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rme();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(LN)),LN}var FN={},UN={},vz;function QW(){return vz||(vz=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})(UN)),UN}var zN={},_z;function ame(){return _z||(_z=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=XW();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(zN)),zN}var wz;function sme(){return wz||(wz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UW(),n=QW(),r=ame(),i=OR();function a(o,l){let c;if(Array.isArray(l)?c=l:typeof l=="string"&&e.isDeepKey(l)&&o?.[l]==null?c=i.toPath(l):c=[l],c.length===0)return!1;let u=o;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})(FN)),FN}var Sz;function ome(){return Sz||(Sz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=KW(),n=DR(),r=ime(),i=LR(),a=sme();function o(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=o})(ON)),ON}var Mz;function lme(){return Mz||(Mz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=VW(),n=Zfe(),r=nme(),i=ome();function a(o){if(o==null)return e.identity;switch(typeof o){case"function":return o;case"object":return Array.isArray(o)&&o.length===2?i.matchesProperty(o[0],o[1]):r.matches(o);case"string":case"symbol":case"number":return n.property(o)}}t.iteratee=a})(_N)),_N}var Ez;function cme(){return Ez||(Ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qfe(),n=VW(),r=Yfe(),i=lme();function a(o,l=n.identity){return r.isArrayLikeObject(o)?e.uniqBy(Array.from(o),i.iteratee(l)):[]}t.uniqBy=a})(mN)),mN}var BN,Az;function ume(){return Az||(Az=1,BN=cme().uniqBy),BN}var dme=ume();const Nz=wo(dme);function JW(t,e,n){return e===!0?Nz(t,n):typeof e=="function"?Nz(t,e):t}var HN={exports:{}},$N={};var Tz;function hme(){if(Tz)return $N;Tz=1;var t=og(),e=y9();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,o=t.useEffect,l=t.useMemo,c=t.useDebugValue;return $N.useSyncExternalStoreWithSelector=function(u,d,f,g,p){var x=a(null);if(x.current===null){var y={hasValue:!1,value:null};x.current=y}else y=x.current;x=l(function(){function v(C){if(!E){if(E=!0,w=C,C=g(C),p!==void 0&&y.hasValue){var T=y.value;if(p(T,C))return N=T}return N=C}if(T=N,r(w,C))return T;var L=g(C);return p!==void 0&&p(T,L)?(w=C,T):(w=C,N=L)}var E=!1,w,N,A=f===void 0?null:f;return[function(){return v(d())},A===null?void 0:function(){return v(A())}]},[d,f,g,p]);var b=i(u,x[0],x[1]);return o(function(){y.hasValue=!0,y.value=b},[b]),c(b),b},$N}var Cz;function fme(){return Cz||(Cz=1,HN.exports=hme()),HN.exports}var eq=fme(),zR=S.createContext(null),mme=t=>t,br=()=>{var t=S.useContext(zR);return t?t.store.dispatch:mme},v1=()=>{},pme=()=>v1,gme=(t,e)=>t===e;function Dt(t){var e=S.useContext(zR);return eq.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:pme,e?e.store.getState:v1,e?e.store.getState:v1,e?t:v1,gme)}function xme(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function bme(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function yme(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 kz=t=>Array.isArray(t)?t:[t];function vme(t){const e=Array.isArray(t[0])?t[0]:t;return yme(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function _me(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var wme=class{constructor(t){this.value=t}deref(){return this.value}},Sme=typeof WeakRef<"u"?WeakRef:wme,Mme=0,Pz=1;function Ov(){return{s:Mme,v:void 0,o:null,p:null}}function tq(t,e={}){let n=Ov();const{resultEqualityCheck:r}=e;let i,a=0;function o(){let l=n;const{length:c}=arguments;for(let f=0,g=c;f<g;f++){const p=arguments[f];if(typeof p=="function"||typeof p=="object"&&p!==null){let x=l.o;x===null&&(l.o=x=new WeakMap);const y=x.get(p);y===void 0?(l=Ov(),x.set(p,l)):l=y}else{let x=l.p;x===null&&(l.p=x=new Map);const y=x.get(p);y===void 0?(l=Ov(),x.set(p,l)):l=y}}const u=l;let d;if(l.s===Pz)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 Sme(d):d}return u.s=Pz,u.v=d,d}return o.clearCache=()=>{n=Ov(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function Eme(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let a=0,o=0,l,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),xme(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:g=[],argsMemoize:p=tq,argsMemoizeOptions:x=[]}=d,y=kz(g),b=kz(x),v=vme(i),E=f(function(){return a++,u.apply(null,arguments)},...y),w=p(function(){o++;const A=_me(v,arguments);return l=E.apply(null,A),l},...b);return Object.assign(w,{resultFunc:u,memoizedResultFunc:E,dependencies:v,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var Qe=Eme(tq),Ame=Object.assign((t,e=Qe)=>{bme(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((o,l,c)=>(o[n[c]]=l,o),{}))},{withTypes:()=>Ame}),VN={},GN={},WN={},jz;function Nme(){return jz||(jz=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 o=e(r),l=e(i);if(o===l&&o===0){if(r<i)return a==="desc"?1:-1;if(r>i)return a==="desc"?-1:1}return a==="desc"?l-o:o-l}return 0};t.compareValues=n})(WN)),WN}var qN={},KN={},Rz;function nq(){return Rz||(Rz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(KN)),KN}var Dz;function Tme(){return Dz||(Dz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=nq(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,o){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))||o!=null&&Object.hasOwn(o,a)}t.isKey=i})(qN)),qN}var Oz;function Cme(){return Oz||(Oz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Nme(),n=Tme(),r=OR();function i(a,o,l,c){if(a==null)return[];l=c?void 0:l,Array.isArray(a)||(a=Object.values(a)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(p=>String(p));const u=(p,x)=>{let y=p;for(let b=0;b<x.length&&y!=null;++b)y=y[x[b]];return y},d=(p,x)=>x==null||p==null?x:typeof p=="object"&&"key"in p?Object.hasOwn(x,p.key)?x[p.key]:u(x,p.path):typeof p=="function"?p(x):Array.isArray(p)?u(x,p):typeof x=="object"?x[p]:x,f=o.map(p=>(Array.isArray(p)&&p.length===1&&(p=p[0]),p==null||typeof p=="function"||Array.isArray(p)||n.isKey(p)?p:{key:p,path:r.toPath(p)}));return a.map(p=>({original:p,criteria:f.map(x=>d(x,p))})).slice().sort((p,x)=>{for(let y=0;y<f.length;y++){const b=e.compareValues(p.criteria[y],x.criteria[y],l[y]);if(b!==0)return b}return 0}).map(p=>p.original)}t.orderBy=i})(GN)),GN}var XN={},Lz;function kme(){return Lz||(Lz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],a=Math.floor(r),o=(l,c)=>{for(let u=0;u<l.length;u++){const d=l[u];Array.isArray(d)&&c<a?o(d,c+1):i.push(d)}};return o(n,0),i}t.flatten=e})(XN)),XN}var YN={},Iz;function rq(){return Iz||(Iz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=QW(),n=UR(),r=GW(),i=qW();function a(o,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],o):!1}t.isIterateeCall=a})(YN)),YN}var Fz;function Pme(){return Fz||(Fz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Cme(),n=kme(),r=rq();function i(a,...o){const l=o.length;return l>1&&r.isIterateeCall(a,o[0],o[1])?o=[]:l>2&&r.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),e.orderBy(a,n.flatten(o),["asc"])}t.sortBy=i})(VN)),VN}var ZN,Uz;function jme(){return Uz||(Uz=1,ZN=Pme().sortBy),ZN}var Rme=jme();const bM=wo(Rme);var iq=t=>t.legend.settings,Dme=t=>t.legend.size,Ome=t=>t.legend.payload,Lme=Qe([Ome,iq],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?bM(r,n):r});function Ime(){return Dt(Lme)}var Lv=1;function aq(){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(),o={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(o.height-e.height)>Lv||Math.abs(o.left-e.left)>Lv||Math.abs(o.top-e.top)>Lv||Math.abs(o.width-e.width)>Lv)&&n({height:o.height,left:o.left,top:o.top,width:o.width})}},[e.width,e.height,e.top,e.left,...t]);return[e,r]}function aa(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 Fme=typeof Symbol=="function"&&Symbol.observable||"@@observable",zz=Fme,QN=()=>Math.random().toString(36).substring(7).split("").join("."),Ume={INIT:`@@redux/INIT${QN()}`,REPLACE:`@@redux/REPLACE${QN()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${QN()}`},aw=Ume;function BR(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 sq(t,e,n){if(typeof t!="function")throw new Error(aa(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(aa(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(aa(1));return n(sq)(t,e)}let r=t,i=e,a=new Map,o=a,l=0,c=!1;function u(){o===a&&(o=new Map,a.forEach((b,v)=>{o.set(v,b)}))}function d(){if(c)throw new Error(aa(3));return i}function f(b){if(typeof b!="function")throw new Error(aa(4));if(c)throw new Error(aa(5));let v=!0;u();const E=l++;return o.set(E,b),function(){if(v){if(c)throw new Error(aa(6));v=!1,u(),o.delete(E),a=null}}}function g(b){if(!BR(b))throw new Error(aa(7));if(typeof b.type>"u")throw new Error(aa(8));if(typeof b.type!="string")throw new Error(aa(17));if(c)throw new Error(aa(9));try{c=!0,i=r(i,b)}finally{c=!1}return(a=o).forEach(E=>{E()}),b}function p(b){if(typeof b!="function")throw new Error(aa(10));r=b,g({type:aw.REPLACE})}function x(){const b=f;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(aa(11));function E(){const N=v;N.next&&N.next(d())}return E(),{unsubscribe:b(E)}},[zz](){return this}}}return g({type:aw.INIT}),{dispatch:g,subscribe:f,getState:d,replaceReducer:p,[zz]:x}}function zme(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:aw.INIT})>"u")throw new Error(aa(12));if(typeof n(void 0,{type:aw.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(aa(13))})}function oq(t){const e=Object.keys(t),n={};for(let a=0;a<e.length;a++){const o=e[a];typeof t[o]=="function"&&(n[o]=t[o])}const r=Object.keys(n);let i;try{zme(n)}catch(a){i=a}return function(o={},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=o[f],x=g(p,l);if(typeof x>"u")throw l&&l.type,new Error(aa(14));u[f]=x,c=c||x!==p}return c=c||r.length!==Object.keys(o).length,c?u:o}}function sw(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function Bme(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(aa(15))};const o={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(o));return a=sw(...l)(i.dispatch),{...i,dispatch:a}}}function lq(t){return BR(t)&&"type"in t&&typeof t.type=="string"}var cq=Symbol.for("immer-nothing"),Bz=Symbol.for("immer-draftable"),za=Symbol.for("immer-state");function Oo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Ps=Object,Ip=Ps.getPrototypeOf,ow="constructor",yM="prototype",_3="configurable",lw="enumerable",_1="writable",$0="value",qc=t=>!!t&&!!t[za];function Ko(t){return t?uq(t)||vM(t)||!!t[Bz]||!!t[ow]?.[Bz]||_M(t)||wM(t):!1}var Hme=Ps[yM][ow].toString(),Hz=new WeakMap;function uq(t){if(!t||!HR(t))return!1;const e=Ip(t);if(e===null||e===Ps[yM])return!0;const n=Ps.hasOwnProperty.call(e,ow)&&e[ow];if(n===Object)return!0;if(!np(n))return!1;let r=Hz.get(n);return r===void 0&&(r=Function.toString.call(n),Hz.set(n,r)),r===Hme}function Fb(t,e,n=!0){Ub(t)===0?(n?Reflect.ownKeys(t):Ps.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function Ub(t){const e=t[za];return e?e.type_:vM(t)?1:_M(t)?2:wM(t)?3:0}var $z=(t,e,n=Ub(t))=>n===2?t.has(e):Ps[yM].hasOwnProperty.call(t,e),w3=(t,e,n=Ub(t))=>n===2?t.get(e):t[e],cw=(t,e,n,r=Ub(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function $me(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var vM=Array.isArray,_M=t=>t instanceof Map,wM=t=>t instanceof Set,HR=t=>typeof t=="object",np=t=>typeof t=="function",JN=t=>typeof t=="boolean",wc=t=>t.copy_||t.base_,$R=t=>t.modified_?t.copy_:t.base_;function S3(t,e){if(_M(t))return new Map(t);if(wM(t))return new Set(t);if(vM(t))return Array[yM].slice.call(t);const n=uq(t);if(e===!0||e==="class_only"&&!n){const r=Ps.getOwnPropertyDescriptors(t);delete r[za];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l[_1]===!1&&(l[_1]=!0,l[_3]=!0),(l.get||l.set)&&(r[o]={[_3]:!0,[_1]:!0,[lw]:l[lw],[$0]:t[o]})}return Ps.create(Ip(t),r)}else{const r=Ip(t);if(r!==null&&n)return{...t};const i=Ps.create(r);return Ps.assign(i,t)}}function VR(t,e=!1){return SM(t)||qc(t)||!Ko(t)||(Ub(t)>1&&Ps.defineProperties(t,{set:Iv,add:Iv,clear:Iv,delete:Iv}),Ps.freeze(t),e&&Fb(t,(n,r)=>{VR(r,!0)},!1)),t}function Vme(){Oo(2)}var Iv={[$0]:Vme};function SM(t){return t===null||!HR(t)?!0:Ps.isFrozen(t)}var uw="MapSet",M3="Patches",dq={};function Fp(t){const e=dq[t];return e||Oo(0,t),e}var Gme=t=>!!dq[t],V0,hq=()=>V0,Wme=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Gme(uw)?Fp(uw):void 0});function Vz(t,e){e&&(t.patchPlugin_=Fp(M3),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function E3(t){A3(t),t.drafts_.forEach(qme),t.drafts_=null}function A3(t){t===V0&&(V0=t.parent_)}var Gz=t=>V0=Wme(V0,t);function qme(t){const e=t[za];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Wz(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[za].modified_&&(E3(e),Oo(4)),Ko(t)&&(t=qz(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[za].base_,t,e)}else t=qz(e,n);return Kme(e,t,!0),E3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==cq?t:void 0}function qz(t,e){if(SM(e))return e;const n=e[za];if(!n)return GR(e,t.handledSet_,t);if(!MM(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);pq(n,t)}return n.copy_}function Kme(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&VR(e,n)}function fq(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var MM=(t,e)=>t.scope_===e,Xme=[];function mq(t,e,n,r){const i=wc(t),a=t.type_;if(r!==void 0&&w3(i,r,a)===e){cw(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;Fb(i,(c,u)=>{if(qc(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??Xme;for(const l of o)cw(i,l,n,a)}function Yme(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!MM(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=$R(a);mq(t,a.draft_??a,o,n),pq(a,i)})}function pq(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)}fq(t)}}function Zme(t,e,n){const{scope_:r}=t;if(qc(n)){const i=n[za];MM(i,r)&&i.callbacks_.push(function(){w1(t);const o=$R(i);mq(t,n,o,e)})}else Ko(n)&&t.callbacks_.push(function(){const a=wc(t);w3(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&GR(w3(t.copy_,e,t.type_),r.handledSet_,r)})}function GR(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||qc(t)||e.has(t)||!Ko(t)||SM(t)||(e.add(t),Fb(t,(r,i)=>{if(qc(i)){const a=i[za];if(MM(a,n)){const o=$R(a);cw(t,r,o,t.type_),fq(a)}}else Ko(i)&&GR(i,e,n)})),t}function Qme(t,e){const n=vM(t),r={type_:n?1:0,scope_:e?e.scope_:hq(),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=WR;n&&(i=[r],a=G0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,[l,r]}var WR={get(t,e){if(e===za)return t;const n=wc(t);if(!$z(n,e,t.type_))return Jme(t,n,e);const r=n[e];if(t.finalized_||!Ko(r))return r;if(r===eT(t.base_,e)){w1(t);const i=t.type_===1?+e:e,a=T3(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in wc(t)},ownKeys(t){return Reflect.ownKeys(wc(t))},set(t,e,n){const r=gq(wc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=eT(wc(t),e),a=i?.[za];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if($me(n,i)&&(n!==void 0||$z(t.base_,e,t.type_)))return!0;w1(t),N3(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_.set(e,!0),Zme(t,e,n)),!0},deleteProperty(t,e){return w1(t),eT(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),N3(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=wc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[_1]:!0,[_3]:t.type_!==1||e!=="length",[lw]:r[lw],[$0]:n[e]}},defineProperty(){Oo(11)},getPrototypeOf(t){return Ip(t.base_)},setPrototypeOf(){Oo(12)}},G0={};Fb(WR,(t,e)=>{G0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});G0.deleteProperty=function(t,e){return G0.set.call(this,t,e,void 0)};G0.set=function(t,e,n){return WR.set.call(this,t[0],e,n,t[0])};function eT(t,e){const n=t[za];return(n?wc(n):t)[e]}function Jme(t,e,n){const r=gq(e,n);return r?$0 in r?r[$0]:r.get?.call(t.draft_):void 0}function gq(t,e){if(!(e in t))return;let n=Ip(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=Ip(n)}}function N3(t){t.modified_||(t.modified_=!0,t.parent_&&N3(t.parent_))}function w1(t){t.copy_||(t.assigned_=new Map,t.copy_=S3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var epe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(np(n)&&!np(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,f=>r.call(this,f,...d))}}np(r)||Oo(6),i!==void 0&&!np(i)&&Oo(7);let a;if(Ko(n)){const o=Gz(this),l=T3(o,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?E3(o):A3(o)}return Vz(o,i),Wz(a,o)}else if(!n||!HR(n)){if(a=r(n),a===void 0&&(a=n),a===cq&&(a=void 0),this.autoFreeze_&&VR(a,!0),i){const o=[],l=[];Fp(M3).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:l}),i(o,l)}return a}else Oo(1,n)},this.produceWithPatches=(n,r)=>{if(np(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]},JN(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),JN(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),JN(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ko(e)||Oo(8),qc(e)&&(e=$o(e));const n=Gz(this),r=T3(n,e,void 0);return r[za].isManual_=!0,A3(n),r}finishDraft(e,n){const r=e&&e[za];(!r||!r.isManual_)&&Oo(9);const{scope_:i}=r;return Vz(i,n),Wz(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=Fp(M3).applyPatches_;return qc(e)?i(e,n):this.produce(e,a=>i(a,n))}};function T3(t,e,n,r){const[i,a]=_M(e)?Fp(uw).proxyMap_(e,n):wM(e)?Fp(uw).proxySet_(e,n):Qme(e,n);return(n?.scope_??hq()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Yme(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 $o(t){return qc(t)||Oo(10,t),xq(t)}function xq(t){if(!Ko(t)||SM(t))return t;const e=t[za];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=S3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=S3(t,!0);return Fb(n,(i,a)=>{cw(n,i,xq(a))},r),e&&(e.finalized_=!1),n}var tpe=new epe,bq=tpe.produce;function yq(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var npe=yq(),rpe=yq,ipe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?sw:sw.apply(null,arguments)};function vo(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(js(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=>lq(r)&&r.type===t,n}var vq=class Qx extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Qx.prototype)}static get[Symbol.species](){return Qx}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Qx(...e[0].concat(this)):new Qx(...e.concat(this))}};function Kz(t){return Ko(t)?bq(t,()=>{}):t}function Fv(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function ape(t){return typeof t=="boolean"}var spe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let o=new vq;return n&&(ape(n)?o.push(npe):o.push(rpe(n.extraArgument))),o},_q="RTK_autoBatch",Cr=()=>t=>({payload:t,meta:{[_q]:!0}}),Xz=t=>e=>{setTimeout(e,t)},wq=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,a=!1,o=!1;const l=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:Xz(10):t.type==="callback"?t.queueNotification:Xz(t.timeout),u=()=>{o=!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?.[_q],a=!i,a&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},ope=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new vq(t);return r&&i.push(wq(typeof r=="object"?r:void 0)),i};function lpe(t){const e=spe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:o=void 0}=t||{};let l;if(typeof n=="function")l=n;else if(BR(n))l=oq(n);else throw new Error(js(1));let c;typeof r=="function"?c=r(e):c=e();let u=sw;i&&(u=ipe({trace:!1,...typeof i=="object"&&i}));const d=Bme(...c),f=ope(d);let g=typeof o=="function"?o(f):f();const p=u(...g);return sq(l,a,p)}function Sq(t){const e={},n=[];let r;const i={addCase(a,o){const l=typeof a=="string"?a:a.type;if(!l)throw new Error(js(28));if(l in e)throw new Error(js(29));return e[l]=o,i},addAsyncThunk(a,o){return o.pending&&(e[a.pending.type]=o.pending),o.rejected&&(e[a.rejected.type]=o.rejected),o.fulfilled&&(e[a.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:a.settled,reducer:o.settled}),i},addMatcher(a,o){return n.push({matcher:a,reducer:o}),i},addDefaultCase(a){return r=a,i}};return t(i),[e,n,r]}function cpe(t){return typeof t=="function"}function upe(t,e){let[n,r,i]=Sq(e),a;if(cpe(t))a=()=>Kz(t());else{const l=Kz(t);a=()=>l}function o(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(qc(d)){const p=f(d,c);return p===void 0?d:p}else{if(Ko(d))return bq(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 o.getInitialState=a,o}var dpe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",hpe=(t=21)=>{let e="",n=t;for(;n--;)e+=dpe[Math.random()*64|0];return e},fpe=Symbol.for("rtk-slice-createasyncthunk");function mpe(t,e){return`${t}/${e}`}function ppe({creators:t}={}){const e=t?.asyncThunk?.[fpe];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(js(11));const o=(typeof r.reducers=="function"?r.reducers(xpe()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(w,N){const A=typeof w=="string"?w:w.type;if(!A)throw new Error(js(12));if(A in c.sliceCaseReducersByType)throw new Error(js(13));return c.sliceCaseReducersByType[A]=N,u},addMatcher(w,N){return c.sliceMatchers.push({matcher:w,reducer:N}),u},exposeAction(w,N){return c.actionCreators[w]=N,u},exposeCaseReducer(w,N){return c.sliceCaseReducersByName[w]=N,u}};l.forEach(w=>{const N=o[w],A={reducerName:w,type:mpe(i,w),createNotation:typeof r.reducers=="function"};ype(N)?_pe(A,N,u,e):bpe(A,N,u)});function d(){const[w={},N=[],A=void 0]=typeof r.extraReducers=="function"?Sq(r.extraReducers):[r.extraReducers],C={...w,...c.sliceCaseReducersByType};return upe(r.initialState,T=>{for(let L in C)T.addCase(L,C[L]);for(let L of c.sliceMatchers)T.addMatcher(L.matcher,L.reducer);for(let L of N)T.addMatcher(L.matcher,L.reducer);A&&T.addDefaultCase(A)})}const f=w=>w,g=new Map,p=new WeakMap;let x;function y(w,N){return x||(x=d()),x(w,N)}function b(){return x||(x=d()),x.getInitialState()}function v(w,N=!1){function A(T){let L=T[w];return typeof L>"u"&&N&&(L=Fv(p,A,b)),L}function C(T=f){const L=Fv(g,N,()=>new WeakMap);return Fv(L,T,()=>{const k={};for(const[D,U]of Object.entries(r.selectors??{}))k[D]=gpe(U,T,()=>Fv(p,T,b),N);return k})}return{reducerPath:w,getSelectors:C,get selectors(){return C(A)},selectSlice:A}}const E={name:i,reducer:y,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:b,...v(a),injectInto(w,{reducerPath:N,...A}={}){const C=N??a;return w.inject({reducerPath:C,reducer:y},A),{...E,...v(C,!0)}}};return E}}function gpe(t,e,n,r){function i(a,...o){let l=e(a);return typeof l>"u"&&r&&(l=n()),t(l,...o)}return i.unwrapped=t,i}var hs=ppe();function xpe(){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 bpe({type:t,reducerName:e,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!vpe(r))throw new Error(js(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,o?vo(t,o):vo(t))}function ype(t){return t._reducerDefinitionType==="asyncThunk"}function vpe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function _pe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(js(18));const{payloadCreator:a,fulfilled:o,pending:l,rejected:c,settled:u,options:d}=n,f=i(t,a,d);r.exposeAction(e,f),o&&r.addCase(f.fulfilled,o),l&&r.addCase(f.pending,l),c&&r.addCase(f.rejected,c),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:o||Uv,pending:l||Uv,rejected:c||Uv,settled:u||Uv})}function Uv(){}var wpe="task",Mq="listener",Eq="completed",qR="cancelled",Spe=`task-${qR}`,Mpe=`task-${Eq}`,C3=`${Mq}-${qR}`,Epe=`${Mq}-${Eq}`,EM=class{constructor(t){this.code=t,this.message=`${wpe} ${qR} (reason: ${t})`}name="TaskAbortError";message},KR=(t,e)=>{if(typeof t!="function")throw new TypeError(js(32))},dw=()=>{},Aq=(t,e=dw)=>(t.catch(e),t),Nq=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Bh=(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))},Hh=t=>{if(t.aborted){const{reason:e}=t;throw new EM(e)}};function Tq(t,e){let n=dw;return new Promise((r,i)=>{const a=()=>i(new EM(t.reason));if(t.aborted){a();return}n=Nq(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=dw})}var Ape=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof EM?"cancelled":"rejected",error:n}}finally{e?.()}},hw=t=>e=>Aq(Tq(t,e).then(n=>(Hh(t),n))),Cq=t=>{const e=hw(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:xp}=Object,Yz={},AM="listenerMiddleware",Npe=(t,e)=>{const n=r=>Nq(t,()=>Bh(r,t.reason));return(r,i)=>{KR(r);const a=new AbortController;n(a);const o=Ape(async()=>{Hh(t),Hh(a.signal);const l=await r({pause:hw(a.signal),delay:Cq(a.signal),signal:a.signal});return Hh(a.signal),l},()=>Bh(a,Mpe));return i?.autoJoin&&e.push(o.catch(dw)),{result:hw(t)(o),cancel(){Bh(a,Spe)}}}},Tpe=(t,e)=>{const n=async(r,i)=>{Hh(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 Tq(e,Promise.race(l));return Hh(e),c}finally{a()}};return(r,i)=>Aq(n(r,i))},kq=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=vo(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(js(21));return KR(a),{predicate:i,type:e,effect:a}},Pq=xp(t=>{const{type:e,predicate:n,effect:r}=kq(t);return{id:hpe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(js(22))}}},{withTypes:()=>Pq}),Zz=(t,e)=>{const{type:n,effect:r,predicate:i}=kq(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},k3=t=>{t.pending.forEach(e=>{Bh(e,C3)})},Cpe=(t,e)=>()=>{for(const n of e.keys())k3(n);t.clear()},Qz=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},jq=xp(vo(`${AM}/add`),{withTypes:()=>jq}),kpe=vo(`${AM}/removeAll`),Rq=xp(vo(`${AM}/remove`),{withTypes:()=>Rq}),Ppe=(...t)=>{console.error(`${AM}/error`,...t)},zb=(t={})=>{const e=new Map,n=new Map,r=p=>{const x=n.get(p)??0;n.set(p,x+1)},i=p=>{const x=n.get(p)??1;x===1?n.delete(p):n.set(p,x-1)},{extra:a,onError:o=Ppe}=t;KR(o);const l=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),x=>{p.unsubscribe(),x?.cancelActive&&k3(p)}),c=p=>{const x=Zz(e,p)??Pq(p);return l(x)};xp(c,{withTypes:()=>c});const u=p=>{const x=Zz(e,p);return x&&(x.unsubscribe(),p.cancelActive&&k3(x)),!!x};xp(u,{withTypes:()=>u});const d=async(p,x,y,b)=>{const v=new AbortController,E=Tpe(c,v.signal),w=[];try{p.pending.add(v),r(p),await Promise.resolve(p.effect(x,xp({},y,{getOriginalState:b,condition:(N,A)=>E(N,A).then(Boolean),take:E,delay:Cq(v.signal),pause:hw(v.signal),extra:a,signal:v.signal,fork:Npe(v.signal,w),unsubscribe:p.unsubscribe,subscribe:()=>{e.set(p.id,p)},cancelActiveListeners:()=>{p.pending.forEach((N,A,C)=>{N!==v&&(Bh(N,C3),C.delete(N))})},cancel:()=>{Bh(v,C3),p.pending.delete(v)},throwIfCancelled:()=>{Hh(v.signal)}})))}catch(N){N instanceof EM||Qz(o,N,{raisedBy:"effect"})}finally{await Promise.all(w),Bh(v,Epe),i(p),p.pending.delete(v)}},f=Cpe(e,n);return{middleware:p=>x=>y=>{if(!lq(y))return x(y);if(jq.match(y))return c(y.payload);if(kpe.match(y)){f();return}if(Rq.match(y))return u(y.payload);let b=p.getState();const v=()=>{if(b===Yz)throw new Error(js(23));return b};let E;try{if(E=x(y),e.size>0){const w=p.getState(),N=Array.from(e.values());for(const A of N){let C=!1;try{C=A.predicate(y,w,b)}catch(T){C=!1,Qz(o,T,{raisedBy:"predicate"})}C&&d(A,y,p,v)}}}finally{b=Yz}return E},startListening:c,stopListening:u,clearListeners:f}};function js(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 jpe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},Dq=hs({name:"chartLayout",initialState:jpe,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:Rpe,setLayout:Dpe,setChartSize:Ope,setScale:Lpe}=Dq.actions,Ipe=Dq.reducer;function Oq(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function Jz(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 cp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Jz(Object(n),!0).forEach(function(r){Fpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Jz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Fpe(t,e,n){return(e=Upe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Upe(t){var e=zpe(t,"string");return typeof e=="symbol"?e:e+""}function zpe(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 Nr(t)||Nr(e)?n:yo(e)?df(t,e,n):typeof e=="function"?e(t):n}var Bpe=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:a,verticalAlign:o,layout:l}=e;if((l==="vertical"||l==="horizontal"&&o==="middle")&&a!=="center"&&Lt(t[a]))return cp(cp({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&o!=="middle"&&Lt(t[o]))return cp(cp({},t),{},{[o]:t[o]+(i||0)})}return t},Ll=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",Lq=(t,e,n,r)=>{if(r)return t.map(l=>l.coordinate);var i,a,o=t.map(l=>(l.coordinate===e&&(i=!0),l.coordinate===n&&(a=!0),l.coordinate));return i||o.push(e),a||o.push(n),o},Iq=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:a,scale:o,realScaleType:l,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:g,axisType:p}=t;if(!o)return null;var x=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,y=i==="category"&&o.bandwidth?o.bandwidth()/x:0;if(y=p==="angleAxis"&&a&&a.length>=2?Wi(a[0]-a[1])*2*y:y,f||g){var b=(f||g||[]).map((v,E)=>{var w=r?r.indexOf(v):v;return{coordinate:o(w)+y,value:v,offset:y,index:E}});return b.filter(v=>!ds(v.coordinate))}return c&&u?u.map((v,E)=>({coordinate:o(v)+y,value:v,index:E,offset:y})):o.ticks&&d!=null?o.ticks(d).map((v,E)=>({coordinate:o(v)+y,value:v,offset:y,index:E})):o.domain().map((v,E)=>({coordinate:o(v)+y,value:r?r[v]:v,index:E,offset:y}))},eB=1e-4,Hpe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-eB,a=Math.max(r[0],r[1])+eB,o=t(e[0]),l=t(e[n-1]);(o<i||o>a||l<i||l>a)&&t.domain([e[0],e[n-1]])}},$pe=(t,e)=>{if(!e||e.length!==2||!Lt(e[0])||!Lt(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(!Lt(t[0])||t[0]<n)&&(i[0]=n),(!Lt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},Vpe=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,o=0;o<e;++o){var l=ds(t[o][n][1])?t[o][n][0]:t[o][n][1];l>=0?(t[o][n][0]=i,t[o][n][1]=i+l,i=t[o][n][1]):(t[o][n][0]=a,t[o][n][1]=a+l,a=t[o][n][1])}},Gpe=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 o=ds(t[a][n][1])?t[a][n][0]:t[a][n][1];o>=0?(t[a][n][0]=i,t[a][n][1]=i+o,i=t[a][n][1]):(t[a][n][0]=0,t[a][n][1]=0)}},Wpe={sign:Vpe,expand:pfe,none:Lp,silhouette:gfe,wiggle:xfe,positive:Gpe},qpe=(t,e,n)=>{var r=Wpe[n],i=mfe().keys(e).value((a,o)=>Number(Jn(a,o,0))).order(y3).offset(r);return i(t)};function Fq(t){return t==null?void 0:String(t)}function fw(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Nr(i[e.dataKey])){var l=BW(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,Nr(o)?e.dataKey:o);return Nr(c)?null:e.scale(c)}var tB=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:a,index:o}=t;if(e.type==="category")return n[o]?n[o].coordinate+r:null;var l=Jn(a,e.dataKey,e.scale.domain()[o]);return Nr(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]},Xpe=t=>{var e=t.flat(2).filter(Lt);return[Math.min(...e),Math.max(...e)]},Ype=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],Zpe=(t,e,n)=>{if(t!=null)return Ype(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:o}=a,l=o.reduce((c,u)=>{var d=Oq(u,e,n),f=Xpe(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]))},nB=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,rB=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Nd=(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=bM(e,d=>d.coordinate),a=1/0,o=1,l=i.length;o<l;o++){var c=i[o],u=i[o-1];a=Math.min((c.coordinate||0)-(u.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function iB(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return cp(cp({},e),{},{dataKey:n,payload:r,value:i,name:a})}function Ud(t,e){if(t)return String(t);if(typeof e=="string")return e}var Qpe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Jpe=(t,e)=>e==="centric"?t.angle:t.radius,tu=t=>t.layout.width,nu=t=>t.layout.height,ege=t=>t.layout.scale,Uq=t=>t.layout.margin,NM=Qe(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),TM=Qe(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),zq="data-recharts-item-index",Bq="data-recharts-item-data-key",Bb=60;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 zv(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){tge(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 tge(t,e,n){return(e=nge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nge(t){var e=rge(t,"string");return typeof e=="symbol"?e:e+""}function rge(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 ige=t=>t.brush.height;function age(t){var e=TM(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Bb;return n+i}return n},0)}function sge(t){var e=TM(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Bb;return n+i}return n},0)}function oge(t){var e=NM(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function lge(t){var e=NM(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var ki=Qe([tu,nu,Uq,ige,age,sge,oge,lge,iq,Dme],(t,e,n,r,i,a,o,l,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+a},f={top:(n.top||0)+o,bottom:(n.bottom||0)+l},g=zv(zv({},f),d),p=g.bottom;g.bottom+=r,g=Bpe(g,c,u);var x=t-g.left-g.right,y=e-g.top-g.bottom;return zv(zv({brushBottom:p},g),{},{width:Math.max(x,0),height:Math.max(y,0)})}),cge=Qe(ki,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),XR=Qe(tu,nu,(t,e)=>({x:0,y:0,width:t,height:e})),uge=S.createContext(null),Pi=()=>S.useContext(uge)!=null,CM=t=>t.brush,kM=Qe([CM,ki,Uq],(t,e,n)=>({height:t.height,x:Lt(t.x)?t.x:e.left,y:Lt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Lt(t.width)?t.width:e.width})),tT={},nT={},rT={},sB;function dge(){return sB||(sB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let o,l=null;const c=a!=null&&a.includes("leading"),u=a==null||a.includes("trailing"),d=()=>{l!==null&&(n.apply(o,l),o=void 0,l=null)},f=()=>{u&&d(),y()};let g=null;const p=()=>{g!=null&&clearTimeout(g),g=setTimeout(()=>{g=null,f()},r)},x=()=>{g!==null&&(clearTimeout(g),g=null)},y=()=>{x(),o=void 0,l=null},b=()=>{d()},v=function(...E){if(i?.aborted)return;o=this,l=E;const w=g==null;p(),c&&w&&d()};return v.schedule=p,v.cancel=y,v.flush=b,i?.addEventListener("abort",y,{once:!0}),v}t.debounce=e})(rT)),rT}var oB;function hge(){return oB||(oB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dge();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:o=!1,trailing:l=!0,maxWait:c}=a,u=Array(2);o&&(u[0]="leading"),l&&(u[1]="trailing");let d,f=null;const g=e.debounce(function(...y){d=r.apply(this,y),f=null},i,{edges:u}),p=function(...y){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,y),f=Date.now(),g.cancel(),g.schedule(),d):(g.apply(this,y),d)},x=()=>(g.flush(),d);return p.cancel=g.cancel,p.flush=x,p}t.debounce=n})(nT)),nT}var lB;function fge(){return lB||(lB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=hge();function n(r,i=0,a={}){const{leading:o=!0,trailing:l=!0}=a;return e.debounce(r,i,{leading:o,maxWait:i,trailing:l})}t.throttle=n})(tT)),tT}var iT,cB;function mge(){return cB||(cB=1,iT=fge().throttle),iT}var pge=mge();const gge=wo(pge);var mw=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 o=0;console.warn(n.replace(/%s/g,()=>i[o++]))}},Hq=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:o}=n,l=Wc(r)?t:Number(r),c=Wc(i)?e:Number(i);return a&&a>0&&(l?c=l/a:c&&(l=c*a),o&&c!=null&&c>o&&(c=o)),{calculatedWidth:l,calculatedHeight:c}},xge={width:0,height:0,overflow:"visible"},bge={width:0,overflowX:"visible"},yge={height:0,overflowY:"visible"},vge={},_ge=t=>{var{width:e,height:n}=t,r=Wc(e),i=Wc(n);return r&&i?xge:r?bge:i?yge:vge};function wge(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 El(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}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 uB(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 dB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?uB(Object(n),!0).forEach(function(r){Sge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):uB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Sge(t,e,n){return(e=Mge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Mge(t){var e=Ege(t,"string");return typeof e=="symbol"?e:e+""}function Ege(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 $q=S.createContext({width:-1,height:-1});function Age(t){return El(t.width)&&El(t.height)}function Vq(t){var{children:e,width:n,height:r}=t,i=S.useMemo(()=>({width:n,height:r}),[n,r]);return Age(i)?S.createElement($q.Provider,{value:i},e):null}var YR=()=>S.useContext($q),Nge=S.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:a,minWidth:o=0,minHeight:l,maxHeight:c,children:u,debounce:d=0,id:f,className:g,onResize:p,style:x={}}=t,y=S.useRef(null),b=S.useRef();b.current=p,S.useImperativeHandle(e,()=>y.current);var[v,E]=S.useState({containerWidth:r.width,containerHeight:r.height}),w=S.useCallback((L,k)=>{E(D=>{var U=Math.round(L),O=Math.round(k);return D.containerWidth===U&&D.containerHeight===O?D:{containerWidth:U,containerHeight:O}})},[]);S.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return Lb;var L=O=>{var q,{width:R,height:G}=O[0].contentRect;w(R,G),(q=b.current)===null||q===void 0||q.call(b,R,G)};d>0&&(L=gge(L,d,{trailing:!0,leading:!1}));var k=new ResizeObserver(L),{width:D,height:U}=y.current.getBoundingClientRect();return w(D,U),k.observe(y.current),()=>{k.disconnect()}},[w,d]);var{containerWidth:N,containerHeight:A}=v;mw(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:C,calculatedHeight:T}=Hq(N,A,{width:i,height:a,aspect:n,maxHeight:c});return mw(C!=null&&C>0||T!=null&&T>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,T,i,a,o,l,n),S.createElement("div",{id:f?"".concat(f):void 0,className:On("recharts-responsive-container",g),style:dB(dB({},x),{},{width:i,height:a,minWidth:o,minHeight:l,maxHeight:c}),ref:y},S.createElement("div",{style:_ge({width:i,height:a})},S.createElement(Vq,{width:C,height:T},u)))}),S1=S.forwardRef((t,e)=>{var n=YR();if(El(n.width)&&El(n.height))return t.children;var{width:r,height:i}=wge({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:o}=Hq(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Lt(a)&&Lt(o)?S.createElement(Vq,{width:a,height:o},t.children):S.createElement(Nge,P3({},t,{width:r,height:i,ref:e}))});function Gq(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 Hb=()=>{var t,e=Pi(),n=Dt(cge),r=Dt(kM),i=(t=Dt(CM))===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}},Tge={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},Wq=()=>{var t;return(t=Dt(ki))!==null&&t!==void 0?t:Tge},ZR=()=>Dt(tu),QR=()=>Dt(nu),Cge=()=>Dt(t=>t.layout.margin),Tn=t=>t.layout.layoutType,Cf=()=>Dt(Tn),kge=()=>{var t=Cf();if(t==="horizontal"||t==="vertical")return t},Pge=()=>{var t=Cf();return t!==void 0},PM=t=>{var e=br(),n=Pi(),{width:r,height:i}=t,a=YR(),o=r,l=i;return a&&(o=a.width>0?a.width:r,l=a.height>0?a.height:i),S.useEffect(()=>{!n&&El(o)&&El(l)&&e(Ope({width:o,height:l}))},[e,n,o,l]),null},qq=Symbol.for("immer-nothing"),hB=Symbol.for("immer-draftable"),Is=Symbol.for("immer-state");function Lo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var W0=Object.getPrototypeOf;function Up(t){return!!t&&!!t[Is]}function hf(t){return t?Kq(t)||Array.isArray(t)||!!t[hB]||!!t.constructor?.[hB]||$b(t)||RM(t):!1}var jge=Object.prototype.constructor.toString(),fB=new WeakMap;function Kq(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);if(e===null||e===Object.prototype)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=fB.get(n);return r===void 0&&(r=Function.toString.call(n),fB.set(n,r)),r===jge}function pw(t,e,n=!0){jM(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 jM(t){const e=t[Is];return e?e.type_:Array.isArray(t)?1:$b(t)?2:RM(t)?3:0}function j3(t,e){return jM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Xq(t,e,n){const r=jM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function Rge(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function $b(t){return t instanceof Map}function RM(t){return t instanceof Set}function wh(t){return t.copy_||t.base_}function R3(t,e){if($b(t))return new Map(t);if(RM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=Kq(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Is];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(r[o]={configurable:!0,writable:!0,enumerable:l.enumerable,value:t[o]})}return Object.create(W0(t),r)}else{const r=W0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function JR(t,e=!1){return DM(t)||Up(t)||!hf(t)||(jM(t)>1&&Object.defineProperties(t,{set:Bv,add:Bv,clear:Bv,delete:Bv}),Object.freeze(t),e&&Object.values(t).forEach(n=>JR(n,!0))),t}function Dge(){Lo(2)}var Bv={value:Dge};function DM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var Oge={};function ff(t){const e=Oge[t];return e||Lo(0,t),e}var q0;function Yq(){return q0}function Lge(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function mB(t,e){e&&(ff("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function D3(t){O3(t),t.drafts_.forEach(Ige),t.drafts_=null}function O3(t){t===q0&&(q0=t.parent_)}function pB(t){return q0=Lge(q0,t)}function Ige(t){const e=t[Is];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function gB(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Is].modified_&&(D3(e),Lo(4)),hf(t)&&(t=gw(e,t),e.parent_||xw(e,t)),e.patches_&&ff("Patches").generateReplacementPatches_(n[Is].base_,t,e.patches_,e.inversePatches_)):t=gw(e,n,[]),D3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==qq?t:void 0}function gw(t,e,n){if(DM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Is];if(!i)return pw(e,(a,o)=>xB(t,i,e,a,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return xw(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const a=i.copy_;let o=a,l=!1;i.type_===3&&(o=new Set(a),a.clear(),l=!0),pw(o,(c,u)=>xB(t,i,a,c,u,n,l),r),xw(t,a,!1),n&&t.patches_&&ff("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function xB(t,e,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const l=DM(i);if(!(l&&!o)){if(Up(i)){const c=a&&e&&e.type_!==3&&!j3(e.assigned_,r)?a.concat(r):void 0,u=gw(t,i,c);if(Xq(n,r,u),Up(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(hf(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;gw(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&($b(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&xw(t,i)}}}function xw(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&JR(e,n)}function Fge(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:Yq(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=eD;n&&(i=[r],a=K0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,l}var eD={get(t,e){if(e===Is)return t;const n=wh(t);if(!j3(n,e))return Uge(t,n,e);const r=n[e];return t.finalized_||!hf(r)?r:r===aT(t.base_,e)?(sT(t),t.copy_[e]=I3(r,t)):r},has(t,e){return e in wh(t)},ownKeys(t){return Reflect.ownKeys(wh(t))},set(t,e,n){const r=Zq(wh(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=aT(wh(t),e),a=i?.[Is];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(Rge(n,i)&&(n!==void 0||j3(t.base_,e)))return!0;sT(t),L3(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 aT(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,sT(t),L3(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=wh(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Lo(11)},getPrototypeOf(t){return W0(t.base_)},setPrototypeOf(){Lo(12)}},K0={};pw(eD,(t,e)=>{K0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});K0.deleteProperty=function(t,e){return K0.set.call(this,t,e,void 0)};K0.set=function(t,e,n){return eD.set.call(this,t[0],e,n,t[0])};function aT(t,e){const n=t[Is];return(n?wh(n):t)[e]}function Uge(t,e,n){const r=Zq(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function Zq(t,e){if(!(e in t))return;let n=W0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=W0(n)}}function L3(t){t.modified_||(t.modified_=!0,t.parent_&&L3(t.parent_))}function sT(t){t.copy_||(t.copy_=R3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var zge=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 o=this;return function(c=a,...u){return o.produce(c,d=>n.call(this,d,...u))}}typeof n!="function"&&Lo(6),r!==void 0&&typeof r!="function"&&Lo(7);let i;if(hf(e)){const a=pB(this),o=I3(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?D3(a):O3(a)}return mB(a,r),gB(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===qq&&(i=void 0),this.autoFreeze_&&JR(i,!0),r){const a=[],o=[];ff("Patches").generateReplacementPatches_(e,i,a,o),r(a,o)}return i}else Lo(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(o,...l)=>this.produceWithPatches(o,c=>e(c,...l));let r,i;return[this.produce(e,n,(o,l)=>{r=o,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){hf(t)||Lo(8),Up(t)&&(t=Bge(t));const e=pB(this),n=I3(t,void 0);return n[Is].isManual_=!0,O3(e),n}finishDraft(t,e){const n=t&&t[Is];(!n||!n.isManual_)&&Lo(9);const{scope_:r}=n;return mB(r,e),gB(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=ff("Patches").applyPatches_;return Up(t)?r(t,e):this.produce(t,i=>r(i,e))}};function I3(t,e){const n=$b(t)?ff("MapSet").proxyMap_(t,e):RM(t)?ff("MapSet").proxySet_(t,e):Fge(t,e);return(e?e.scope_:Yq()).drafts_.push(n),n}function Bge(t){return Up(t)||Lo(10,t),Qq(t)}function Qq(t){if(!hf(t)||DM(t))return t;const e=t[Is];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=R3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=R3(t,!0);return pw(n,(i,a)=>{Xq(n,i,Qq(a))},r),e&&(e.finalized_=!1),n}var Hge=new zge;Hge.produce;var $ge={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},Jq=hs({name:"legend",initialState:$ge,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=$o(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Cr()},removeLegendPayload:{reducer(t,e){var n=$o(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Cr()}}}),{setLegendSize:bB,setLegendSettings:Vge,addLegendPayload:eK,replaceLegendPayload:tK,removeLegendPayload:nK}=Jq.actions,Gge=Jq.reducer,Wge=["contextPayload"];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 yB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function zp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yB(Object(n),!0).forEach(function(r){qge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qge(t,e,n){return(e=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=Xge(t,"string");return typeof e=="symbol"?e:e+""}function Xge(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 Yge(t,e){if(t==null)return{};var n,r,i=Zge(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 Zge(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 Qge(t){return t.value}function Jge(t){var{contextPayload:e}=t,n=Yge(t,Wge),r=JW(e,t.payloadUniqBy,Qge),i=zp(zp({},n),{},{payload:r});return S.isValidElement(t.content)?S.cloneElement(t.content,i):typeof t.content=="function"?S.createElement(t.content,i):S.createElement(Wfe,i)}function exe(t,e,n,r,i,a){var{layout:o,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"&&o==="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}),zp(zp({},u),d)}function txe(t){var e=br();return S.useEffect(()=>{e(Vge(t))},[e,t]),null}function nxe(t){var e=br();return S.useEffect(()=>(e(bB(t)),()=>{e(bB({width:0,height:0}))}),[e,t]),null}function rxe(t,e,n,r){return t==="vertical"&&Lt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var ixe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function tD(t){var e=Lr(t,ixe),n=Ime(),r=Fhe(),i=Cge(),{width:a,height:o,wrapperStyle:l,portal:c}=e,[u,d]=aq([n]),f=ZR(),g=QR();if(f==null||g==null)return null;var p=f-(i?.left||0)-(i?.right||0),x=rxe(e.layout,o,a,p),y=c?l:zp(zp({position:"absolute",width:x?.width||a||"auto",height:x?.height||o||"auto"},exe(l,e,i,f,g,u)),l),b=c??r;if(b==null||n==null)return null;var v=S.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:d},S.createElement(txe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&S.createElement(nxe,{width:u.width,height:u.height}),S.createElement(Jge,F3({},e,x,{margin:i,chartWidth:f,chartHeight:g,contextPayload:n})));return Tc.createPortal(v,b)}tD.displayName="Legend";function U3(){return U3=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},U3.apply(null,arguments)}function vB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function oT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vB(Object(n),!0).forEach(function(r){axe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function axe(t,e,n){return(e=sxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sxe(t){var e=oxe(t,"string");return typeof e=="symbol"?e:e+""}function oxe(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 lxe(t){return Array.isArray(t)&&yo(t[0])&&yo(t[1])?t.join(" ~ "):t}var cxe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:a,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:g=!1}=t,p=()=>{if(a&&a.length){var A={padding:0,margin:0},C=(l?bM(a,l):a).map((T,L)=>{if(T.type==="none")return null;var k=T.formatter||o||lxe,{value:D,name:U}=T,O=D,q=U;if(k){var R=k(D,U,T,L,a);if(Array.isArray(R))[O,q]=R;else if(R!=null)O=R;else return null}var G=oT({display:"block",paddingTop:4,paddingBottom:4,color:T.color||"#000"},r);return S.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(L),style:G},yo(q)?S.createElement("span",{className:"recharts-tooltip-item-name"},q):null,yo(q)?S.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,S.createElement("span",{className:"recharts-tooltip-item-value"},O),S.createElement("span",{className:"recharts-tooltip-item-unit"},T.unit||""))});return S.createElement("ul",{className:"recharts-tooltip-item-list",style:A},C)}return null},x=oT({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),y=oT({margin:0},i),b=!Nr(d),v=b?d:"",E=On("recharts-default-tooltip",c),w=On("recharts-tooltip-label",u);b&&f&&a!==void 0&&a!==null&&(v=f(d,a));var N=g?{role:"status","aria-live":"assertive"}:{};return S.createElement("div",U3({className:E,style:x},N),S.createElement("p",{className:w,style:y},S.isValidElement(v)?v:"".concat(v)),p())},Ax="recharts-tooltip-wrapper",uxe={visibility:"hidden"};function dxe(t){var{coordinate:e,translateX:n,translateY:r}=t;return On(Ax,{["".concat(Ax,"-right")]:Lt(n)&&e&&Lt(e.x)&&n>=e.x,["".concat(Ax,"-left")]:Lt(n)&&e&&Lt(e.x)&&n<e.x,["".concat(Ax,"-bottom")]:Lt(r)&&e&&Lt(e.y)&&r>=e.y,["".concat(Ax,"-top")]:Lt(r)&&e&&Lt(e.y)&&r<e.y})}function _B(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&Lt(a[r]))return a[r];var d=n[r]-l-(i>0?i:0),f=n[r]+i;if(e[r])return o[r]?d:f;var g=c[r];if(g==null)return 0;if(o[r]){var p=d,x=g;return p<x?Math.max(f,g):Math.max(d,g)}if(u==null)return 0;var y=f+l,b=g+u;return y>b?Math.max(d,g):Math.max(f,g)}function hxe(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 fxe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:a,tooltipBox:o,useTranslate3d:l,viewBox:c}=t,u,d,f;return o.height>0&&o.width>0&&n?(d=_B({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),f=_B({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=hxe({translateX:d,translateY:f,useTranslate3d:l})):u=uxe,{cssProperties:u,cssClasses:dxe({translateX:d,translateY:f,coordinate:n})}}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 Hv(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){z3(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 z3(t,e,n){return(e=mxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mxe(t){var e=pxe(t,"string");return typeof e=="symbol"?e:e+""}function pxe(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 gxe extends S.PureComponent{constructor(){super(...arguments),z3(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),z3(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:o,hasPayload:l,isAnimationActive:c,offset:u,position:d,reverseDirection:f,useTranslate3d:g,viewBox:p,wrapperStyle:x,lastBoundingBox:y,innerRef:b,hasPortalFromProps:v}=this.props,{cssClasses:E,cssProperties:w}=fxe({allowEscapeViewBox:n,coordinate:o,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:y.height,width:y.width},useTranslate3d:g,viewBox:p}),N=v?{}:Hv(Hv({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}),A=Hv(Hv({},N),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},x);return S.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:E,style:A,ref:b},a)}}var rK=()=>{var t;return(t=Dt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function B3(){return B3=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},B3.apply(null,arguments)}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){xxe(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 xxe(t,e,n){return(e=bxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bxe(t){var e=yxe(t,"string");return typeof e=="symbol"?e:e+""}function yxe(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 EB={curveBasisClosed:rfe,curveBasisOpen:ife,curveBasis:nfe,curveBumpX:Hhe,curveBumpY:$he,curveLinearClosed:afe,curveLinear:gM,curveMonotoneX:sfe,curveMonotoneY:ofe,curveNatural:lfe,curveStep:cfe,curveStepAfter:dfe,curveStepBefore:ufe},bw=t=>er(t.x)&&er(t.y),AB=t=>t.base!=null&&bw(t.base)&&bw(t),Nx=t=>t.x,Tx=t=>t.y,vxe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Ob(t));return(n==="curveMonotone"||n==="curveBump")&&e?EB["".concat(n).concat(e==="vertical"?"Y":"X")]:EB[n]||gM},_xe=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,o=vxe(e,i),l=a?n.filter(bw):n,c;if(Array.isArray(r)){var u=n.map((p,x)=>MB(MB({},p),{},{base:r[x]}));i==="vertical"?c=Dv().y(Tx).x1(Nx).x0(p=>p.base.x):c=Dv().x(Nx).y1(Tx).y0(p=>p.base.y);var d=c.defined(AB).curve(o),f=a?u.filter(AB):u;return d(f)}i==="vertical"&&Lt(r)?c=Dv().y(Tx).x1(Nx).x0(r):Lt(r)?c=Dv().x(Nx).y1(Tx).y0(r):c=TW().x(Nx).y(Tx);var g=c.defined(bw).curve(o);return g(l)},bp=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?_xe(t):r;return S.createElement("path",B3({},Ua(t),FR(t),{className:On("recharts-curve",e),d:a===null?void 0:a,ref:i}))},wxe=["x","y","top","left","width","height","className"];function H3(){return H3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},H3.apply(null,arguments)}function NB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Sxe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?NB(Object(n),!0).forEach(function(r){Mxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):NB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Mxe(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=Axe(t,"string");return typeof e=="symbol"?e:e+""}function Axe(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 Nxe(t,e){if(t==null)return{};var n,r,i=Txe(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 Txe(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 Cxe=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),kxe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:l}=t,c=Nxe(t,wxe),u=Sxe({x:e,y:n,top:r,left:i,width:a,height:o},c);return!Lt(e)||!Lt(n)||!Lt(a)||!Lt(o)||!Lt(r)||!Lt(i)?null:S.createElement("path",H3({},fa(u),{className:On("recharts-cross",l),d:Cxe(e,n,a,o,r,i)}))};function Pxe(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 TB(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 CB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?TB(Object(n),!0).forEach(function(r){jxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):TB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function jxe(t,e,n){return(e=Rxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Rxe(t){var e=Dxe(t,"string");return typeof e=="symbol"?e:e+""}function Dxe(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 Oxe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),iK=(t,e,n)=>t.map(r=>"".concat(Oxe(r)," ").concat(e,"ms ").concat(n)).join(","),Lxe=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),X0=(t,e)=>Object.keys(e).reduce((n,r)=>CB(CB({},n),{},{[r]:t(r,e[r])}),{});function kB(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 _i(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?kB(Object(n),!0).forEach(function(r){Ixe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ixe(t,e,n){return(e=Fxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Fxe(t){var e=Uxe(t,"string");return typeof e=="symbol"?e:e+""}function Uxe(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 yw=(t,e,n)=>t+(e-t)*n,$3=t=>{var{from:e,to:n}=t;return e!==n},aK=(t,e,n)=>{var r=X0((i,a)=>{if($3(a)){var[o,l]=t(a.from,a.to,a.velocity);return _i(_i({},a),{},{from:o,velocity:l})}return a},e);return n<1?X0((i,a)=>$3(a)?_i(_i({},a),{},{velocity:yw(a.velocity,r[i].velocity,n),from:yw(a.from,r[i].from,n)}):a,e):aK(t,r,n-1)};function zxe(t,e,n,r,i,a){var o,l=r.reduce((g,p)=>_i(_i({},g),{},{[p]:{from:t[p],velocity:0,to:e[p]}}),{}),c=()=>X0((g,p)=>p.from,l),u=()=>!Object.values(l).filter($3).length,d=null,f=g=>{o||(o=g);var p=g-o,x=p/n.dt;l=aK(n,l,x),i(_i(_i(_i({},t),e),c())),o=g,u()||(d=a.setTimeout(f))};return()=>(d=a.setTimeout(f),()=>{var g;(g=d)===null||g===void 0||g()})}function Bxe(t,e,n,r,i,a,o){var l=null,c=i.reduce((f,g)=>_i(_i({},f),{},{[g]:[t[g],e[g]]}),{}),u,d=f=>{u||(u=f);var g=(f-u)/r,p=X0((y,b)=>yw(...b,n(g)),c);if(a(_i(_i(_i({},t),e),p)),g<1)l=o.setTimeout(d);else{var x=X0((y,b)=>yw(...b,n(1)),c);a(_i(_i(_i({},t),e),x))}};return()=>(l=o.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const Hxe=(t,e,n,r,i,a)=>{var o=Lxe(t,e);return n==null?()=>(i(_i(_i({},t),e)),()=>{}):n.isStepper===!0?zxe(t,e,n,o,i,a):Bxe(t,e,n,r,o,i,a)};var vw=1e-4,sK=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],oK=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),PB=(t,e)=>n=>{var r=sK(t,e);return oK(r,n)},$xe=(t,e)=>n=>{var r=sK(t,e),i=[...r.map((a,o)=>a*o).slice(1),0];return oK(i,n)},Vxe=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 o=a[1].split(")")[0].split(",").map(l=>parseFloat(l));return[o[0],o[1],o[2],o[3]]}}}return n.length===4?n:[0,0,1,1]},Gxe=(t,e,n,r)=>{var i=PB(t,n),a=PB(e,r),o=$xe(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,g=0;g<8;++g){var p=i(f)-d,x=o(f);if(Math.abs(p-d)<vw||x<vw)return a(f);f=l(f-p/x)}return a(f)};return c.isStepper=!1,c},jB=function(){return Gxe(...Vxe(...arguments))},Wxe=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,a=(o,l,c)=>{var u=-(o-l)*n,d=c*r,f=c+(u-d)*i/1e3,g=c*i/1e3+o;return Math.abs(g-l)<vw&&Math.abs(f)<vw?[l,0]:[g,f]};return a.isStepper=!0,a.dt=i,a},qxe=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return jB(t);case"spring":return Wxe();default:if(t.split("(")[0]==="cubic-bezier")return jB(t)}return typeof t=="function"?t:null};function Kxe(t){var e,n=()=>null,r=!1,i=null,a=o=>{if(!r){if(Array.isArray(o)){if(!o.length)return;var l=o,[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 o=="string"&&(e=o,n(e)),typeof o=="object"&&(e=o,n(e)),typeof o=="function"&&o()}};return{stop:()=>{r=!0},start:o=>{r=!1,i&&(i(),i=null),a(o)},subscribe:o=>(n=o,()=>{n=()=>null}),getTimeoutController:()=>t}}class Xxe{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,a=o=>{o-r>=n?e(o):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(a))};return i=requestAnimationFrame(a),()=>{i!=null&&cancelAnimationFrame(i)}}}function Yxe(){return Kxe(new Xxe)}var Zxe=S.createContext(Yxe);function Qxe(t,e){var n=S.useContext(Zxe);return S.useMemo(()=>e??n(t),[t,e,n])}var Jxe=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),mg={devToolsEnabled:!1,isSsr:Jxe()},e0e={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},RB={t:0},lT={t:1};function pg(t){var e=Lr(t,e0e),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!mg.isSsr:n,f=Qxe(e.animationId,e.animationManager),[g,p]=S.useState(d?RB:lT),x=S.useRef(null);return S.useEffect(()=>{d||p(lT)},[d]),S.useEffect(()=>{if(!d||!r)return Lb;var y=Hxe(RB,lT,qxe(a),i,p,f.getTimeoutController()),b=()=>{x.current=y()};return f.start([c,o,b,i,l]),()=>{f.stop(),x.current&&x.current(),l()}},[d,r,i,a,o,c,l,f]),u(g.t)}function gg(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=S.useRef(H0(e)),r=S.useRef(t);return r.current!==t&&(n.current=H0(e),r.current=t),n.current}var t0e=["radius"],n0e=["radius"];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){r0e(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 r0e(t,e,n){return(e=i0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i0e(t){var e=a0e(t,"string");return typeof e=="symbol"?e:e+""}function a0e(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 _w(){return _w=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},_w.apply(null,arguments)}function LB(t,e){if(t==null)return{};var n,r,i=s0e(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 s0e(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 IB=(t,e,n,r,i)=>{var a=Math.min(Math.abs(n)/2,Math.abs(r)/2),o=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+o*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+o*d[1])),u+="L ".concat(t+n,",").concat(e+r-o*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-o*d[3])),u+="Z"}else if(a>0&&i===+i&&i>0){var p=Math.min(a,i);u="M ".concat(t,",").concat(e+o*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+o*p,`
  23. L `).concat(t+n,",").concat(e+r-o*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-o*p," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},FB={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},lK=t=>{var e=Lr(t,FB),n=S.useRef(null),[r,i]=S.useState(-1);S.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var V=n.current.getTotalLength();V&&i(V)}catch{}},[]);var{x:a,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:g,animationBegin:p,isAnimationActive:x,isUpdateAnimationActive:y}=e,b=S.useRef(l),v=S.useRef(c),E=S.useRef(a),w=S.useRef(o),N=S.useMemo(()=>({x:a,y:o,width:l,height:c,radius:u}),[a,o,l,c,u]),A=gg(N,"rectangle-");if(a!==+a||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var C=On("recharts-rectangle",d);if(!y){var T=fa(e),{radius:L}=T,k=LB(T,t0e);return S.createElement("path",_w({},k,{radius:typeof u=="number"?u:void 0,className:C,d:IB(a,o,l,c,u)}))}var D=b.current,U=v.current,O=E.current,q=w.current,R="0px ".concat(r===-1?1:r,"px"),G="".concat(r,"px 0px"),Y=iK(["strokeDasharray"],g,typeof f=="string"?f:FB.animationEasing);return S.createElement(pg,{animationId:A,key:A,canBegin:r>0,duration:g,easing:f,isActive:y,begin:p},V=>{var K=Wn(D,l,V),J=Wn(U,c,V),X=Wn(O,a,V),F=Wn(q,o,V);n.current&&(b.current=K,v.current=J,E.current=X,w.current=F);var W;x?V>0?W={transition:Y,strokeDasharray:G}:W={strokeDasharray:R}:W={strokeDasharray:G};var ee=fa(e),{radius:ie}=ee,ae=LB(ee,n0e);return S.createElement("path",_w({},ae,{radius:typeof u=="number"?u:void 0,className:C,d:IB(X,F,K,J,u),ref:n,style:OB(OB({},W),e.style)}))})};function UB(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 zB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?UB(Object(n),!0).forEach(function(r){o0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):UB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function o0e(t,e,n){return(e=l0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l0e(t){var e=c0e(t,"string");return typeof e=="symbol"?e:e+""}function c0e(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 ww=Math.PI/180,u0e=t=>t*180/Math.PI,hi=(t,e,n,r)=>({x:t+Math.cos(-ww*r)*n,y:e+Math.sin(-ww*r)*n}),cK=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},d0e=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},h0e=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,o=d0e({x:n,y:r},{x:i,y:a});if(o<=0)return{radius:o,angle:0};var l=(n-i)/o,c=Math.acos(l);return r>a&&(c=2*Math.PI-c),{radius:o,angle:u0e(c),angleInRadian:c}},f0e=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}},m0e=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),a=Math.floor(r/360),o=Math.min(i,a);return t+o*360},p0e=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=h0e({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=f0e(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?zB(zB({},e),{},{radius:i,angle:m0e(d,e)}):null};function uK(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,o=hi(e,n,r,i),l=hi(e,n,r,a);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}function V3(){return V3=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},V3.apply(null,arguments)}var g0e=(t,e)=>{var n=Wi(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},$v=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:a,isExternal:o,cornerRadius:l,cornerIsExternal:c}=t,u=l*(o?1:-1)+r,d=Math.asin(l/u)/ww,f=c?i:i+a*d,g=hi(e,n,u,f),p=hi(e,n,r,f),x=c?i-a*d:i,y=hi(e,n,u*Math.cos(d*ww),x);return{center:g,circleTangency:p,lineTangency:y,theta:d}},dK=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=t,l=g0e(a,o),c=a+l,u=hi(e,n,i,a),d=hi(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=hi(e,n,r,a),p=hi(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},x0e=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=Wi(u-c),{circleTangency:f,lineTangency:g,theta:p}=$v({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:x,lineTangency:y,theta:b}=$v({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:l}),v=l?Math.abs(c-u):Math.abs(c-u)-p-b;if(v<0)return o?"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. `):dK({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(+(v>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
  39. A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(y.x,",").concat(y.y,`
  40. `);if(r>0){var{circleTangency:w,lineTangency:N,theta:A}=$v({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:C,lineTangency:T,theta:L}=$v({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)-A-L;if(k<0&&a===0)return"".concat(E,"L").concat(e,",").concat(n,"Z");E+="L".concat(T.x,",").concat(T.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(N.x,",").concat(N.y,"Z")}else E+="L".concat(e,",").concat(n,"Z");return E},b0e={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},hK=t=>{var e=Lr(t,b0e),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:o,forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d,className:f}=e;if(a<i||u===d)return null;var g=On("recharts-sector",f),p=a-i,x=Ea(o,p,0,!0),y;return x>0&&Math.abs(u-d)<360?y=x0e({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(x,p/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):y=dK({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),S.createElement("path",V3({},fa(e),{className:g,d:y}))};function y0e(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($W(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:l}=e,c=hi(r,i,a,l),u=hi(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return uK(e)}}var cT={},uT={},dT={},BB;function v0e(){return BB||(BB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=nq();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(dT)),dT}var HB;function _0e(){return HB||(HB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=v0e();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})(uT)),uT}var $B;function w0e(){return $B||($B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rq(),n=_0e();function r(i,a,o){o&&typeof o!="number"&&e.isIterateeCall(i,a,o)&&(a=o=void 0),i=n.toFinite(i),a===void 0?(a=i,i=0):a=n.toFinite(a),o=o===void 0?i<a?1:-1:n.toFinite(o);const l=Math.max(Math.ceil((a-i)/(o||1)),0),c=new Array(l);for(let u=0;u<l;u++)c[u]=i,i+=o;return c}t.range=r})(cT)),cT}var hT,VB;function S0e(){return VB||(VB=1,hT=w0e().range),hT}var M0e=S0e();const fK=wo(M0e);function fd(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function E0e(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function nD(t){let e,n,r;t.length!==2?(e=fd,n=(l,c)=>fd(t(l),c),r=(l,c)=>t(l)-c):(e=t===fd||t===E0e?t:A0e,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 o(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:o,right:a}}function A0e(){return 0}function mK(t){return t===null?NaN:+t}function*N0e(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const T0e=nD(fd),Vb=T0e.right;nD(mK).center;class GB extends Map{constructor(e,n=P0e){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(WB(this,e))}has(e){return super.has(WB(this,e))}set(e,n){return super.set(C0e(this,e),n)}delete(e){return super.delete(k0e(this,e))}}function WB({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function C0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function k0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function P0e(t){return t!==null&&typeof t=="object"?t.valueOf():t}function j0e(t=fd){if(t===fd)return pK;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 pK(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const R0e=Math.sqrt(50),D0e=Math.sqrt(10),O0e=Math.sqrt(2);function Sw(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),o=a>=R0e?10:a>=D0e?5:a>=O0e?2:1;let l,c,u;return i<0?(u=Math.pow(10,-i)/o,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)*o,l=Math.round(t/u),c=Math.round(e/u),l*u<t&&++l,c*u>e&&--c),c<l&&.5<=n&&n<2?Sw(t,e,n*2):[l,c,u]}function G3(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,a,o]=r?Sw(e,t,n):Sw(t,e,n);if(!(a>=i))return[];const l=a-i+1,c=new Array(l);if(r)if(o<0)for(let u=0;u<l;++u)c[u]=(a-u)/-o;else for(let u=0;u<l;++u)c[u]=(a-u)*o;else if(o<0)for(let u=0;u<l;++u)c[u]=(i+u)/-o;else for(let u=0;u<l;++u)c[u]=(i+u)*o;return c}function W3(t,e,n){return e=+e,t=+t,n=+n,Sw(t,e,n)[2]}function q3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?W3(e,t,n):W3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function qB(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function KB(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function gK(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?pK:j0e(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),f=.5*Math.exp(2*d/3),g=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),p=Math.max(n,Math.floor(e-u*f/c+g)),x=Math.min(r,Math.floor(e+(c-u)*f/c+g));gK(t,e,p,x,i)}const a=t[e];let o=n,l=r;for(Cx(t,n,e),i(t[r],a)>0&&Cx(t,n,r);o<l;){for(Cx(t,o,l),++o,--l;i(t[o],a)<0;)++o;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?Cx(t,n,l):(++l,Cx(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function Cx(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function L0e(t,e,n){if(t=Float64Array.from(N0e(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return KB(t);if(e>=1)return qB(t);var r,i=(r-1)*e,a=Math.floor(i),o=qB(gK(t,a).subarray(0,a+1)),l=KB(t.subarray(a+1));return o+(l-o)*(i-a)}}function I0e(t,e,n=mK){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),o=+n(t[a],a,t),l=+n(t[a+1],a+1,t);return o+(l-o)*(i-a)}}function F0e(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 So(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function ru(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 K3=Symbol("implicit");function rD(){var t=new GB,e=[],n=[],r=K3;function i(a){let o=t.get(a);if(o===void 0){if(r!==K3)return r;t.set(a,o=e.push(a)-1)}return n[o%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new GB;for(const o of a)t.has(o)||t.set(o,e.push(o)-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 rD(e,n).unknown(r)},So.apply(i,arguments),i}function iD(){var t=rD().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,a,o,l=!1,c=0,u=0,d=.5;delete t.unknown;function f(){var g=e().length,p=i<r,x=p?i:r,y=p?r:i;a=(y-x)/Math.max(1,g-c+u*2),l&&(a=Math.floor(a)),x+=(y-x-a*(g-c))*d,o=a*(1-c),l&&(x=Math.round(x),o=Math.round(o));var b=F0e(g).map(function(v){return x+a*v});return n(p?b.reverse():b)}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 o},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 iD(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},So.apply(f(),arguments)}function xK(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return xK(e())},t}function U0e(){return xK(iD.apply(null,arguments).paddingInner(1))}function aD(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function bK(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Gb(){}var Y0=.7,Mw=1/Y0,yp="\\s*([+-]?\\d+)\\s*",Z0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",_l="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",z0e=/^#([0-9a-f]{3,8})$/,B0e=new RegExp(`^rgb\\(${yp},${yp},${yp}\\)$`),H0e=new RegExp(`^rgb\\(${_l},${_l},${_l}\\)$`),$0e=new RegExp(`^rgba\\(${yp},${yp},${yp},${Z0}\\)$`),V0e=new RegExp(`^rgba\\(${_l},${_l},${_l},${Z0}\\)$`),G0e=new RegExp(`^hsl\\(${Z0},${_l},${_l}\\)$`),W0e=new RegExp(`^hsla\\(${Z0},${_l},${_l},${Z0}\\)$`),XB={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};aD(Gb,Q0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:YB,formatHex:YB,formatHex8:q0e,formatHsl:K0e,formatRgb:ZB,toString:ZB});function YB(){return this.rgb().formatHex()}function q0e(){return this.rgb().formatHex8()}function K0e(){return yK(this).formatHsl()}function ZB(){return this.rgb().formatRgb()}function Q0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=z0e.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?QB(e):n===3?new as(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Vv(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Vv(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=B0e.exec(t))?new as(e[1],e[2],e[3],1):(e=H0e.exec(t))?new as(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=$0e.exec(t))?Vv(e[1],e[2],e[3],e[4]):(e=V0e.exec(t))?Vv(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=G0e.exec(t))?t8(e[1],e[2]/100,e[3]/100,1):(e=W0e.exec(t))?t8(e[1],e[2]/100,e[3]/100,e[4]):XB.hasOwnProperty(t)?QB(XB[t]):t==="transparent"?new as(NaN,NaN,NaN,0):null}function QB(t){return new as(t>>16&255,t>>8&255,t&255,1)}function Vv(t,e,n,r){return r<=0&&(t=e=n=NaN),new as(t,e,n,r)}function X0e(t){return t instanceof Gb||(t=Q0(t)),t?(t=t.rgb(),new as(t.r,t.g,t.b,t.opacity)):new as}function X3(t,e,n,r){return arguments.length===1?X0e(t):new as(t,e,n,r??1)}function as(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}aD(as,X3,bK(Gb,{brighter(t){return t=t==null?Mw:Math.pow(Mw,t),new as(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Y0:Math.pow(Y0,t),new as(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new as($h(this.r),$h(this.g),$h(this.b),Ew(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:JB,formatHex:JB,formatHex8:Y0e,formatRgb:e8,toString:e8}));function JB(){return`#${jh(this.r)}${jh(this.g)}${jh(this.b)}`}function Y0e(){return`#${jh(this.r)}${jh(this.g)}${jh(this.b)}${jh((isNaN(this.opacity)?1:this.opacity)*255)}`}function e8(){const t=Ew(this.opacity);return`${t===1?"rgb(":"rgba("}${$h(this.r)}, ${$h(this.g)}, ${$h(this.b)}${t===1?")":`, ${t})`}`}function Ew(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function $h(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function jh(t){return t=$h(t),(t<16?"0":"")+t.toString(16)}function t8(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Io(t,e,n,r)}function yK(t){if(t instanceof Io)return new Io(t.h,t.s,t.l,t.opacity);if(t instanceof Gb||(t=Q0(t)),!t)return new Io;if(t instanceof Io)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),o=NaN,l=a-i,c=(a+i)/2;return l?(e===a?o=(n-r)/l+(n<r)*6:n===a?o=(r-e)/l+2:o=(e-n)/l+4,l/=c<.5?a+i:2-a-i,o*=60):l=c>0&&c<1?0:o,new Io(o,l,c,t.opacity)}function Z0e(t,e,n,r){return arguments.length===1?yK(t):new Io(t,e,n,r??1)}function Io(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}aD(Io,Z0e,bK(Gb,{brighter(t){return t=t==null?Mw:Math.pow(Mw,t),new Io(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Y0:Math.pow(Y0,t),new Io(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 as(fT(t>=240?t-240:t+120,i,r),fT(t,i,r),fT(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Io(n8(this.h),Gv(this.s),Gv(this.l),Ew(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=Ew(this.opacity);return`${t===1?"hsl(":"hsla("}${n8(this.h)}, ${Gv(this.s)*100}%, ${Gv(this.l)*100}%${t===1?")":`, ${t})`}`}}));function n8(t){return t=(t||0)%360,t<0?t+360:t}function Gv(t){return Math.max(0,Math.min(1,t||0))}function fT(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 sD=t=>()=>t;function Q0e(t,e){return function(n){return t+n*e}}function J0e(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 ebe(t){return(t=+t)==1?vK:function(e,n){return n-e?J0e(e,n,t):sD(isNaN(e)?n:e)}}function vK(t,e){var n=e-t;return n?Q0e(t,n):sD(isNaN(t)?e:t)}const r8=(function t(e){var n=ebe(e);function r(i,a){var o=n((i=X3(i)).r,(a=X3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=vK(i.opacity,a.opacity);return function(d){return i.r=o(d),i.g=l(d),i.b=c(d),i.opacity=u(d),i+""}}return r.gamma=t,r})(1);function tbe(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 nbe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function rbe(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),a=new Array(n),o;for(o=0;o<r;++o)i[o]=xg(t[o],e[o]);for(;o<n;++o)a[o]=e[o];return function(l){for(o=0;o<r;++o)a[o]=i[o](l);return a}}function ibe(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Aw(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function abe(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]=xg(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var Y3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,mT=new RegExp(Y3.source,"g");function sbe(t){return function(){return t}}function obe(t){return function(e){return t(e)+""}}function lbe(t,e){var n=Y3.lastIndex=mT.lastIndex=0,r,i,a,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=Y3.exec(t))&&(i=mT.exec(e));)(a=i.index)>n&&(a=e.slice(n,a),l[o]?l[o]+=a:l[++o]=a),(r=r[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,c.push({i:o,x:Aw(r,i)})),n=mT.lastIndex;return n<e.length&&(a=e.slice(n),l[o]?l[o]+=a:l[++o]=a),l.length<2?c[0]?obe(c[0].x):sbe(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 xg(t,e){var n=typeof e,r;return e==null||n==="boolean"?sD(e):(n==="number"?Aw:n==="string"?(r=Q0(e))?(e=r,r8):lbe:e instanceof Q0?r8:e instanceof Date?ibe:nbe(e)?tbe:Array.isArray(e)?rbe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?abe:Aw)(t,e)}function oD(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function cbe(t,e){e===void 0&&(e=t,t=xg);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(o){var l=Math.max(0,Math.min(r-1,Math.floor(o*=r)));return a[l](o-l)}}function ube(t){return function(){return t}}function Nw(t){return+t}var i8=[0,1];function La(t){return t}function Z3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:ube(isNaN(e)?NaN:.5)}function dbe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function hbe(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=Z3(i,r),a=n(o,a)):(r=Z3(r,i),a=n(a,o)),function(l){return a(r(l))}}function fbe(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=Z3(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(l){var c=Vb(t,l,1,r)-1;return a[c](i[c](l))}}function Wb(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function OM(){var t=i8,e=i8,n=xg,r,i,a,o=La,l,c,u;function d(){var g=Math.min(t.length,e.length);return o!==La&&(o=dbe(t[0],t[g-1])),l=g>2?fbe:hbe,c=u=null,f}function f(g){return g==null||isNaN(g=+g)?a:(c||(c=l(t.map(r),e,n)))(r(o(g)))}return f.invert=function(g){return o(i((u||(u=l(e,t.map(r),Aw)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,Nw),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=oD,d()},f.clamp=function(g){return arguments.length?(o=g?!0:La,d()):o!==La},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 lD(){return OM()(La,La)}function mbe(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Tw(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 Bp(t){return t=Tw(Math.abs(t)),t?t[1]:NaN}function pbe(t,e){return function(n,r){for(var i=n.length,a=[],o=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[o=(o+1)%t.length];return a.reverse().join(e)}}function gbe(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var xbe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function J0(t){if(!(e=xbe.exec(t)))throw new Error("invalid format: "+t);var e;return new cD({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]})}J0.prototype=cD.prototype;function cD(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+""}cD.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 bbe(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 _K;function ybe(t,e){var n=Tw(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(_K=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+Tw(t,Math.max(0,e+a-1))[0]}function a8(t,e){var n=Tw(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 s8={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:mbe,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)=>a8(t*100,e),r:a8,s:ybe,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function o8(t){return t}var l8=Array.prototype.map,c8=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function vbe(t){var e=t.grouping===void 0||t.thousands===void 0?o8:pbe(l8.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?o8:gbe(l8.call(t.numerals,String)),o=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=J0(f);var g=f.fill,p=f.align,x=f.sign,y=f.symbol,b=f.zero,v=f.width,E=f.comma,w=f.precision,N=f.trim,A=f.type;A==="n"?(E=!0,A="g"):s8[A]||(w===void 0&&(w=12),N=!0,A="g"),(b||g==="0"&&p==="=")&&(b=!0,g="0",p="=");var C=y==="$"?n:y==="#"&&/[boxX]/.test(A)?"0"+A.toLowerCase():"",T=y==="$"?r:/[%p]/.test(A)?o:"",L=s8[A],k=/[defgprs%]/.test(A);w=w===void 0?6:/[gprs]/.test(A)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function D(U){var O=C,q=T,R,G,Y;if(A==="c")q=L(U)+q,U="";else{U=+U;var V=U<0||1/U<0;if(U=isNaN(U)?c:L(Math.abs(U),w),N&&(U=bbe(U)),V&&+U==0&&x!=="+"&&(V=!1),O=(V?x==="("?x:l:x==="-"||x==="("?"":x)+O,q=(A==="s"?c8[8+_K/3]:"")+q+(V&&x==="("?")":""),k){for(R=-1,G=U.length;++R<G;)if(Y=U.charCodeAt(R),48>Y||Y>57){q=(Y===46?i+U.slice(R+1):U.slice(R))+q,U=U.slice(0,R);break}}}E&&!b&&(U=e(U,1/0));var K=O.length+U.length+q.length,J=K<v?new Array(v-K+1).join(g):"";switch(E&&b&&(U=e(J+U,J.length?v-q.length:1/0),J=""),p){case"<":U=O+U+q+J;break;case"=":U=O+J+U+q;break;case"^":U=J.slice(0,K=J.length>>1)+O+U+q+J.slice(K);break;default:U=J+O+U+q;break}return a(U)}return D.toString=function(){return f+""},D}function d(f,g){var p=u((f=J0(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(Bp(g)/3)))*3,y=Math.pow(10,-x),b=c8[8+x/3];return function(v){return p(y*v)+b}}return{format:u,formatPrefix:d}}var Wv,uD,wK;_be({thousands:",",grouping:[3],currency:["$",""]});function _be(t){return Wv=vbe(t),uD=Wv.format,wK=Wv.formatPrefix,Wv}function wbe(t){return Math.max(0,-Bp(Math.abs(t)))}function Sbe(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Bp(e)/3)))*3-Bp(Math.abs(t)))}function Mbe(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Bp(e)-Bp(t))+1}function SK(t,e,n,r){var i=q3(t,e,n),a;switch(r=J0(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=Sbe(i,o))&&(r.precision=a),wK(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=Mbe(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=wbe(i))&&(r.precision=a-(r.type==="%")*2);break}}return uD(r)}function zd(t){var e=t.domain;return t.ticks=function(n){var r=e();return G3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return SK(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,o=r[i],l=r[a],c,u,d=10;for(l<o&&(u=o,o=l,l=u,u=i,i=a,a=u);d-- >0;){if(u=W3(o,l,n),u===c)return r[i]=o,r[a]=l,e(r);if(u>0)o=Math.floor(o/u)*u,l=Math.ceil(l/u)*u;else if(u<0)o=Math.ceil(o*u)/u,l=Math.floor(l*u)/u;else break;c=u}return t},t}function MK(){var t=lD();return t.copy=function(){return Wb(t,MK())},So.apply(t,arguments),zd(t)}function EK(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,Nw),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return EK(t).unknown(e)},t=arguments.length?Array.from(t,Nw):[0,1],zd(n)}function AK(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],a=t[r],o;return a<i&&(o=n,n=r,r=o,o=i,i=a,a=o),t[n]=e.floor(i),t[r]=e.ceil(a),t}function u8(t){return Math.log(t)}function d8(t){return Math.exp(t)}function Ebe(t){return-Math.log(-t)}function Abe(t){return-Math.exp(-t)}function Nbe(t){return isFinite(t)?+("1e"+t):t<0?0:t}function Tbe(t){return t===10?Nbe:t===Math.E?Math.exp:e=>Math.pow(t,e)}function Cbe(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 h8(t){return(e,n)=>-t(-e,n)}function dD(t){const e=t(u8,d8),n=e.domain;let r=10,i,a;function o(){return i=Cbe(r),a=Tbe(r),n()[0]<0?(i=h8(i),a=h8(a),t(Ebe,Abe)):t(u8,d8),e}return e.base=function(l){return arguments.length?(r=+l,o()):r},e.domain=function(l){return arguments.length?(n(l),o()):n()},e.ticks=l=>{const c=n();let u=c[0],d=c[c.length-1];const f=d<u;f&&([u,d]=[d,u]);let g=i(u),p=i(d),x,y;const b=l==null?10:+l;let v=[];if(!(r%1)&&p-g<b){if(g=Math.floor(g),p=Math.ceil(p),u>0){for(;g<=p;++g)for(x=1;x<r;++x)if(y=g<0?x/a(-g):x*a(g),!(y<u)){if(y>d)break;v.push(y)}}else for(;g<=p;++g)for(x=r-1;x>=1;--x)if(y=g>0?x/a(-g):x*a(g),!(y<u)){if(y>d)break;v.push(y)}v.length*2<b&&(v=G3(u,d,b))}else v=G3(g,p,Math.min(p-g,b)).map(a);return f?v.reverse():v},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=J0(c)).precision==null&&(c.trim=!0),c=uD(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(AK(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function NK(){const t=dD(OM()).domain([1,10]);return t.copy=()=>Wb(t,NK()).base(t.base()),So.apply(t,arguments),t}function f8(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function m8(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function hD(t){var e=1,n=t(f8(e),m8(e));return n.constant=function(r){return arguments.length?t(f8(e=+r),m8(e)):e},zd(n)}function TK(){var t=hD(OM());return t.copy=function(){return Wb(t,TK()).constant(t.constant())},So.apply(t,arguments)}function p8(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function kbe(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Pbe(t){return t<0?-t*t:t*t}function fD(t){var e=t(La,La),n=1;function r(){return n===1?t(La,La):n===.5?t(kbe,Pbe):t(p8(n),p8(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},zd(e)}function mD(){var t=fD(OM());return t.copy=function(){return Wb(t,mD()).exponent(t.exponent())},So.apply(t,arguments),t}function jbe(){return mD.apply(null,arguments).exponent(.5)}function g8(t){return Math.sign(t)*t*t}function Rbe(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function CK(){var t=lD(),e=[0,1],n=!1,r;function i(a){var o=Rbe(t(a));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(a){return t.invert(g8(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,Nw)).map(g8)),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 CK(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},So.apply(i,arguments),zd(i)}function kK(){var t=[],e=[],n=[],r;function i(){var o=0,l=Math.max(1,e.length);for(n=new Array(l-1);++o<l;)n[o-1]=I0e(t,o/l);return a}function a(o){return o==null||isNaN(o=+o)?r:e[Vb(n,o)]}return a.invertExtent=function(o){var l=e.indexOf(o);return l<0?[NaN,NaN]:[l>0?n[l-1]:t[0],l<n.length?n[l]:t[t.length-1]]},a.domain=function(o){if(!arguments.length)return t.slice();t=[];for(let l of o)l!=null&&!isNaN(l=+l)&&t.push(l);return t.sort(fd),i()},a.range=function(o){return arguments.length?(e=Array.from(o),i()):e.slice()},a.unknown=function(o){return arguments.length?(r=o,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return kK().domain(t).range(e).unknown(r)},So.apply(a,arguments)}function PK(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function o(c){return c!=null&&c<=c?i[Vb(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 o}return o.domain=function(c){return arguments.length?([t,e]=c,t=+t,e=+e,l()):[t,e]},o.range=function(c){return arguments.length?(n=(i=Array.from(c)).length-1,l()):i.slice()},o.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]]},o.unknown=function(c){return arguments.length&&(a=c),o},o.thresholds=function(){return r.slice()},o.copy=function(){return PK().domain([t,e]).range(i).unknown(a)},So.apply(zd(o),arguments)}function jK(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[Vb(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 o=e.indexOf(a);return[t[o-1],t[o]]},i.unknown=function(a){return arguments.length?(n=a,i):n},i.copy=function(){return jK().domain(t).range(e).unknown(n)},So.apply(i,arguments)}const pT=new Date,gT=new Date;function ji(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 o=i(a),l=i.ceil(a);return a-o<l-a?o:l},i.offset=(a,o)=>(e(a=new Date(+a),o==null?1:Math.floor(o)),a),i.range=(a,o,l)=>{const c=[];if(a=i.ceil(a),l=l==null?1:Math.floor(l),!(a<o)||!(l>0))return c;let u;do c.push(u=new Date(+a)),e(a,l),t(a);while(u<a&&a<o);return c},i.filter=a=>ji(o=>{if(o>=o)for(;t(o),!a(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;e(o,-1),!a(o););else for(;--l>=0;)for(;e(o,1),!a(o););}),n&&(i.count=(a,o)=>(pT.setTime(+a),gT.setTime(+o),t(pT),t(gT),Math.floor(n(pT,gT))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?o=>r(o)%a===0:o=>i.count(0,o)%a===0):i)),i}const Cw=ji(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);Cw.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?ji(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):Cw);Cw.range;const Cc=1e3,uo=Cc*60,kc=uo*60,Kc=kc*24,pD=Kc*7,x8=Kc*30,xT=Kc*365,Rh=ji(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Cc)},(t,e)=>(e-t)/Cc,t=>t.getUTCSeconds());Rh.range;const gD=ji(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Cc)},(t,e)=>{t.setTime(+t+e*uo)},(t,e)=>(e-t)/uo,t=>t.getMinutes());gD.range;const xD=ji(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*uo)},(t,e)=>(e-t)/uo,t=>t.getUTCMinutes());xD.range;const bD=ji(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Cc-t.getMinutes()*uo)},(t,e)=>{t.setTime(+t+e*kc)},(t,e)=>(e-t)/kc,t=>t.getHours());bD.range;const yD=ji(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*kc)},(t,e)=>(e-t)/kc,t=>t.getUTCHours());yD.range;const qb=ji(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*uo)/Kc,t=>t.getDate()-1);qb.range;const LM=ji(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Kc,t=>t.getUTCDate()-1);LM.range;const RK=ji(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Kc,t=>Math.floor(t/Kc));RK.range;function kf(t){return ji(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())*uo)/pD)}const IM=kf(0),kw=kf(1),Dbe=kf(2),Obe=kf(3),Hp=kf(4),Lbe=kf(5),Ibe=kf(6);IM.range;kw.range;Dbe.range;Obe.range;Hp.range;Lbe.range;Ibe.range;function Pf(t){return ji(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)/pD)}const FM=Pf(0),Pw=Pf(1),Fbe=Pf(2),Ube=Pf(3),$p=Pf(4),zbe=Pf(5),Bbe=Pf(6);FM.range;Pw.range;Fbe.range;Ube.range;$p.range;zbe.range;Bbe.range;const vD=ji(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());vD.range;const _D=ji(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());_D.range;const Xc=ji(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());Xc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ji(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)});Xc.range;const Yc=ji(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());Yc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:ji(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)});Yc.range;function DK(t,e,n,r,i,a){const o=[[Rh,1,Cc],[Rh,5,5*Cc],[Rh,15,15*Cc],[Rh,30,30*Cc],[a,1,uo],[a,5,5*uo],[a,15,15*uo],[a,30,30*uo],[i,1,kc],[i,3,3*kc],[i,6,6*kc],[i,12,12*kc],[r,1,Kc],[r,2,2*Kc],[n,1,pD],[e,1,x8],[e,3,3*x8],[t,1,xT]];function l(u,d,f){const g=d<u;g&&([u,d]=[d,u]);const p=f&&typeof f.range=="function"?f:c(u,d,f),x=p?p.range(u,+d+1):[];return g?x.reverse():x}function c(u,d,f){const g=Math.abs(d-u)/f,p=nD(([,,b])=>b).right(o,g);if(p===o.length)return t.every(q3(u/xT,d/xT,f));if(p===0)return Cw.every(Math.max(q3(u,d,f),1));const[x,y]=o[g/o[p-1][2]<o[p][2]/g?p-1:p];return x.every(y)}return[l,c]}const[Hbe,$be]=DK(Yc,_D,FM,RK,yD,xD),[Vbe,Gbe]=DK(Xc,vD,IM,qb,bD,gD);function bT(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 yT(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 kx(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function Wbe(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,l=t.months,c=t.shortMonths,u=Px(i),d=jx(i),f=Px(a),g=jx(a),p=Px(o),x=jx(o),y=Px(l),b=jx(l),v=Px(c),E=jx(c),w={a:V,A:K,b:J,B:X,c:null,d:S8,e:S8,f:pye,g:Eye,G:Nye,H:hye,I:fye,j:mye,L:OK,m:gye,M:xye,p:F,q:W,Q:A8,s:N8,S:bye,u:yye,U:vye,V:_ye,w:wye,W:Sye,x:null,X:null,y:Mye,Y:Aye,Z:Tye,"%":E8},N={a:ee,A:ie,b:ae,B:de,c:null,d:M8,e:M8,f:jye,g:Hye,G:Vye,H:Cye,I:kye,j:Pye,L:IK,m:Rye,M:Dye,p:ue,q:le,Q:A8,s:N8,S:Oye,u:Lye,U:Iye,V:Fye,w:Uye,W:zye,x:null,X:null,y:Bye,Y:$ye,Z:Gye,"%":E8},A={a:D,A:U,b:O,B:q,c:R,d:_8,e:_8,f:lye,g:v8,G:y8,H:w8,I:w8,j:iye,L:oye,m:rye,M:aye,p:k,q:nye,Q:uye,s:dye,S:sye,u:Zbe,U:Qbe,V:Jbe,w:Ybe,W:eye,x:G,X:Y,y:v8,Y:y8,Z:tye,"%":cye};w.x=C(n,w),w.X=C(r,w),w.c=C(e,w),N.x=C(n,N),N.X=C(r,N),N.c=C(e,N);function C(he,pe){return function(Me){var re=[],We=-1,z=0,H=he.length,se,B,Q;for(Me instanceof Date||(Me=new Date(+Me));++We<H;)he.charCodeAt(We)===37&&(re.push(he.slice(z,We)),(B=b8[se=he.charAt(++We)])!=null?se=he.charAt(++We):B=se==="e"?" ":"0",(Q=pe[se])&&(se=Q(Me,B)),re.push(se),z=We+1);return re.push(he.slice(z,We)),re.join("")}}function T(he,pe){return function(Me){var re=kx(1900,void 0,1),We=L(re,he,Me+="",0),z,H;if(We!=Me.length)return null;if("Q"in re)return new Date(re.Q);if("s"in re)return new Date(re.s*1e3+("L"in re?re.L:0));if(pe&&!("Z"in re)&&(re.Z=0),"p"in re&&(re.H=re.H%12+re.p*12),re.m===void 0&&(re.m="q"in re?re.q:0),"V"in re){if(re.V<1||re.V>53)return null;"w"in re||(re.w=1),"Z"in re?(z=yT(kx(re.y,0,1)),H=z.getUTCDay(),z=H>4||H===0?Pw.ceil(z):Pw(z),z=LM.offset(z,(re.V-1)*7),re.y=z.getUTCFullYear(),re.m=z.getUTCMonth(),re.d=z.getUTCDate()+(re.w+6)%7):(z=bT(kx(re.y,0,1)),H=z.getDay(),z=H>4||H===0?kw.ceil(z):kw(z),z=qb.offset(z,(re.V-1)*7),re.y=z.getFullYear(),re.m=z.getMonth(),re.d=z.getDate()+(re.w+6)%7)}else("W"in re||"U"in re)&&("w"in re||(re.w="u"in re?re.u%7:"W"in re?1:0),H="Z"in re?yT(kx(re.y,0,1)).getUTCDay():bT(kx(re.y,0,1)).getDay(),re.m=0,re.d="W"in re?(re.w+6)%7+re.W*7-(H+5)%7:re.w+re.U*7-(H+6)%7);return"Z"in re?(re.H+=re.Z/100|0,re.M+=re.Z%100,yT(re)):bT(re)}}function L(he,pe,Me,re){for(var We=0,z=pe.length,H=Me.length,se,B;We<z;){if(re>=H)return-1;if(se=pe.charCodeAt(We++),se===37){if(se=pe.charAt(We++),B=A[se in b8?pe.charAt(We++):se],!B||(re=B(he,Me,re))<0)return-1}else if(se!=Me.charCodeAt(re++))return-1}return re}function k(he,pe,Me){var re=u.exec(pe.slice(Me));return re?(he.p=d.get(re[0].toLowerCase()),Me+re[0].length):-1}function D(he,pe,Me){var re=p.exec(pe.slice(Me));return re?(he.w=x.get(re[0].toLowerCase()),Me+re[0].length):-1}function U(he,pe,Me){var re=f.exec(pe.slice(Me));return re?(he.w=g.get(re[0].toLowerCase()),Me+re[0].length):-1}function O(he,pe,Me){var re=v.exec(pe.slice(Me));return re?(he.m=E.get(re[0].toLowerCase()),Me+re[0].length):-1}function q(he,pe,Me){var re=y.exec(pe.slice(Me));return re?(he.m=b.get(re[0].toLowerCase()),Me+re[0].length):-1}function R(he,pe,Me){return L(he,e,pe,Me)}function G(he,pe,Me){return L(he,n,pe,Me)}function Y(he,pe,Me){return L(he,r,pe,Me)}function V(he){return o[he.getDay()]}function K(he){return a[he.getDay()]}function J(he){return c[he.getMonth()]}function X(he){return l[he.getMonth()]}function F(he){return i[+(he.getHours()>=12)]}function W(he){return 1+~~(he.getMonth()/3)}function ee(he){return o[he.getUTCDay()]}function ie(he){return a[he.getUTCDay()]}function ae(he){return c[he.getUTCMonth()]}function de(he){return l[he.getUTCMonth()]}function ue(he){return i[+(he.getUTCHours()>=12)]}function le(he){return 1+~~(he.getUTCMonth()/3)}return{format:function(he){var pe=C(he+="",w);return pe.toString=function(){return he},pe},parse:function(he){var pe=T(he+="",!1);return pe.toString=function(){return he},pe},utcFormat:function(he){var pe=C(he+="",N);return pe.toString=function(){return he},pe},utcParse:function(he){var pe=T(he+="",!0);return pe.toString=function(){return he},pe}}}var b8={"-":"",_:" ",0:"0"},Yi=/^\s*\d+/,qbe=/^%/,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 Xbe(t){return t.replace(Kbe,"\\$&")}function Px(t){return new RegExp("^(?:"+t.map(Xbe).join("|")+")","i")}function jx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function Ybe(t,e,n){var r=Yi.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Zbe(t,e,n){var r=Yi.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Qbe(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Jbe(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function eye(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function y8(t,e,n){var r=Yi.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function v8(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function tye(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 nye(t,e,n){var r=Yi.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function rye(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function _8(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function iye(t,e,n){var r=Yi.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function w8(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function aye(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function sye(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function oye(t,e,n){var r=Yi.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function lye(t,e,n){var r=Yi.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function cye(t,e,n){var r=qbe.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function uye(t,e,n){var r=Yi.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function dye(t,e,n){var r=Yi.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function S8(t,e){return Bn(t.getDate(),e,2)}function hye(t,e){return Bn(t.getHours(),e,2)}function fye(t,e){return Bn(t.getHours()%12||12,e,2)}function mye(t,e){return Bn(1+qb.count(Xc(t),t),e,3)}function OK(t,e){return Bn(t.getMilliseconds(),e,3)}function pye(t,e){return OK(t,e)+"000"}function gye(t,e){return Bn(t.getMonth()+1,e,2)}function xye(t,e){return Bn(t.getMinutes(),e,2)}function bye(t,e){return Bn(t.getSeconds(),e,2)}function yye(t){var e=t.getDay();return e===0?7:e}function vye(t,e){return Bn(IM.count(Xc(t)-1,t),e,2)}function LK(t){var e=t.getDay();return e>=4||e===0?Hp(t):Hp.ceil(t)}function _ye(t,e){return t=LK(t),Bn(Hp.count(Xc(t),t)+(Xc(t).getDay()===4),e,2)}function wye(t){return t.getDay()}function Sye(t,e){return Bn(kw.count(Xc(t)-1,t),e,2)}function Mye(t,e){return Bn(t.getFullYear()%100,e,2)}function Eye(t,e){return t=LK(t),Bn(t.getFullYear()%100,e,2)}function Aye(t,e){return Bn(t.getFullYear()%1e4,e,4)}function Nye(t,e){var n=t.getDay();return t=n>=4||n===0?Hp(t):Hp.ceil(t),Bn(t.getFullYear()%1e4,e,4)}function Tye(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Bn(e/60|0,"0",2)+Bn(e%60,"0",2)}function M8(t,e){return Bn(t.getUTCDate(),e,2)}function Cye(t,e){return Bn(t.getUTCHours(),e,2)}function kye(t,e){return Bn(t.getUTCHours()%12||12,e,2)}function Pye(t,e){return Bn(1+LM.count(Yc(t),t),e,3)}function IK(t,e){return Bn(t.getUTCMilliseconds(),e,3)}function jye(t,e){return IK(t,e)+"000"}function Rye(t,e){return Bn(t.getUTCMonth()+1,e,2)}function Dye(t,e){return Bn(t.getUTCMinutes(),e,2)}function Oye(t,e){return Bn(t.getUTCSeconds(),e,2)}function Lye(t){var e=t.getUTCDay();return e===0?7:e}function Iye(t,e){return Bn(FM.count(Yc(t)-1,t),e,2)}function FK(t){var e=t.getUTCDay();return e>=4||e===0?$p(t):$p.ceil(t)}function Fye(t,e){return t=FK(t),Bn($p.count(Yc(t),t)+(Yc(t).getUTCDay()===4),e,2)}function Uye(t){return t.getUTCDay()}function zye(t,e){return Bn(Pw.count(Yc(t)-1,t),e,2)}function Bye(t,e){return Bn(t.getUTCFullYear()%100,e,2)}function Hye(t,e){return t=FK(t),Bn(t.getUTCFullYear()%100,e,2)}function $ye(t,e){return Bn(t.getUTCFullYear()%1e4,e,4)}function Vye(t,e){var n=t.getUTCDay();return t=n>=4||n===0?$p(t):$p.ceil(t),Bn(t.getUTCFullYear()%1e4,e,4)}function Gye(){return"+0000"}function E8(){return"%"}function A8(t){return+t}function N8(t){return Math.floor(+t/1e3)}var pm,UK,zK;Wye({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 Wye(t){return pm=Wbe(t),UK=pm.format,pm.parse,zK=pm.utcFormat,pm.utcParse,pm}function qye(t){return new Date(t)}function Kye(t){return t instanceof Date?+t:+new Date(+t)}function wD(t,e,n,r,i,a,o,l,c,u){var d=lD(),f=d.invert,g=d.domain,p=u(".%L"),x=u(":%S"),y=u("%I:%M"),b=u("%I %p"),v=u("%a %d"),E=u("%b %d"),w=u("%B"),N=u("%Y");function A(C){return(c(C)<C?p:l(C)<C?x:o(C)<C?y:a(C)<C?b:r(C)<C?i(C)<C?v:E:n(C)<C?w:N)(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(qye)},d.ticks=function(C){var T=g();return t(T[0],T[T.length-1],C??10)},d.tickFormat=function(C,T){return T==null?A:u(T)},d.nice=function(C){var T=g();return(!C||typeof C.range!="function")&&(C=e(T[0],T[T.length-1],C??10)),C?g(AK(T,C)):d},d.copy=function(){return Wb(d,wD(t,e,n,r,i,a,o,l,c,u))},d}function Xye(){return So.apply(wD(Vbe,Gbe,Xc,vD,IM,qb,bD,gD,Rh,UK).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Yye(){return So.apply(wD(Hbe,$be,Yc,_D,FM,LM,yD,xD,Rh,zK).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function UM(){var t=0,e=1,n,r,i,a,o=La,l=!1,c;function u(f){return f==null||isNaN(f=+f)?c:o(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?(o=f,u):o};function d(f){return function(g){var p,x;return arguments.length?([p,x]=g,o=f(p,x),u):[o(0),o(1)]}}return u.range=d(xg),u.rangeRound=d(oD),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 Bd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function BK(){var t=zd(UM()(La));return t.copy=function(){return Bd(t,BK())},ru.apply(t,arguments)}function HK(){var t=dD(UM()).domain([1,10]);return t.copy=function(){return Bd(t,HK()).base(t.base())},ru.apply(t,arguments)}function $K(){var t=hD(UM());return t.copy=function(){return Bd(t,$K()).constant(t.constant())},ru.apply(t,arguments)}function SD(){var t=fD(UM());return t.copy=function(){return Bd(t,SD()).exponent(t.exponent())},ru.apply(t,arguments)}function Zye(){return SD.apply(null,arguments).exponent(.5)}function VK(){var t=[],e=La;function n(r){if(r!=null&&!isNaN(r=+r))return e((Vb(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(fd),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)=>L0e(t,a/r))},n.copy=function(){return VK(e).domain(t)},ru.apply(n,arguments)}function zM(){var t=0,e=.5,n=1,r=1,i,a,o,l,c,u=La,d,f=!1,g;function p(y){return isNaN(y=+y)?g:(y=.5+((y=+d(y))-a)*(r*y<r*a?l:c),u(f?Math.max(0,Math.min(1,y)):y))}p.domain=function(y){return arguments.length?([t,e,n]=y,i=d(t=+t),a=d(e=+e),o=d(n=+n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p):[t,e,n]},p.clamp=function(y){return arguments.length?(f=!!y,p):f},p.interpolator=function(y){return arguments.length?(u=y,p):u};function x(y){return function(b){var v,E,w;return arguments.length?([v,E,w]=b,u=cbe(y,[v,E,w]),p):[u(0),u(.5),u(1)]}}return p.range=x(xg),p.rangeRound=x(oD),p.unknown=function(y){return arguments.length?(g=y,p):g},function(y){return d=y,i=y(t),a=y(e),o=y(n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p}}function GK(){var t=zd(zM()(La));return t.copy=function(){return Bd(t,GK())},ru.apply(t,arguments)}function WK(){var t=dD(zM()).domain([.1,1,10]);return t.copy=function(){return Bd(t,WK()).base(t.base())},ru.apply(t,arguments)}function qK(){var t=hD(zM());return t.copy=function(){return Bd(t,qK()).constant(t.constant())},ru.apply(t,arguments)}function MD(){var t=fD(zM());return t.copy=function(){return Bd(t,MD()).exponent(t.exponent())},ru.apply(t,arguments)}function Qye(){return MD.apply(null,arguments).exponent(.5)}const Jx=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:iD,scaleDiverging:GK,scaleDivergingLog:WK,scaleDivergingPow:MD,scaleDivergingSqrt:Qye,scaleDivergingSymlog:qK,scaleIdentity:EK,scaleImplicit:K3,scaleLinear:MK,scaleLog:NK,scaleOrdinal:rD,scalePoint:U0e,scalePow:mD,scaleQuantile:kK,scaleQuantize:PK,scaleRadial:CK,scaleSequential:BK,scaleSequentialLog:HK,scaleSequentialPow:SD,scaleSequentialQuantile:VK,scaleSequentialSqrt:Zye,scaleSequentialSymlog:$K,scaleSqrt:jbe,scaleSymlog:TK,scaleThreshold:jK,scaleTime:Xye,scaleUtc:Yye,tickFormat:SK},Symbol.toStringTag,{value:"Module"}));var Hd=t=>t.chartData,ED=Qe([Hd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),Kb=(t,e,n,r)=>r?ED(t):Hd(t);function Td(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(er(e)&&er(n))return!0}return!1}function T8(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function KK(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(er(n))i=n;else if(typeof n=="function")return;if(er(r))a=r;else if(typeof r=="function")return;var o=[i,a];if(Td(o))return o}}function Jye(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(Td(r))return T8(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,a]=t,o,l;if(i==="auto")e!=null&&(o=Math.min(...e));else if(Lt(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&nB.test(i)){var c=nB.exec(i);if(c==null||e==null)o=void 0;else{var u=+c[1];o=e[0]-u}}else o=e?.[0];if(a==="auto")e!=null&&(l=Math.max(...e));else if(Lt(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&rB.test(a)){var d=rB.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=[o,l];if(Td(g))return e==null?g:T8(g,e,n)}}}var bg=1e9,eve={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},ND,Pr=!0,_o="[DecimalError] ",Vh=_o+"Invalid argument: ",AD=_o+"Exponent out of range: ",yg=Math.floor,Sh=Math.pow,tve=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ts,$i=1e7,Er=7,XK=9007199254740991,jw=yg(XK/Er),It={};It.absoluteValue=It.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};It.comparedTo=It.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};It.decimalPlaces=It.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};It.dividedBy=It.div=function(t){return Lc(this,new this.constructor(t))};It.dividedToIntegerBy=It.idiv=function(t){var e=this,n=e.constructor;return xr(Lc(e,new n(t),0,1),n.precision)};It.equals=It.eq=function(t){return!this.cmp(t)};It.exponent=function(){return mi(this)};It.greaterThan=It.gt=function(t){return this.cmp(t)>0};It.greaterThanOrEqualTo=It.gte=function(t){return this.cmp(t)>=0};It.isInteger=It.isint=function(){return this.e>this.d.length-2};It.isNegative=It.isneg=function(){return this.s<0};It.isPositive=It.ispos=function(){return this.s>0};It.isZero=function(){return this.s===0};It.lessThan=It.lt=function(t){return this.cmp(t)<0};It.lessThanOrEqualTo=It.lte=function(t){return this.cmp(t)<1};It.logarithm=It.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(Ts))throw Error(_o+"NaN");if(n.s<1)throw Error(_o+(n.s?"NaN":"-Infinity"));return n.eq(Ts)?new r(0):(Pr=!1,e=Lc(eb(n,a),eb(t,a),a),Pr=!0,xr(e,i))};It.minus=It.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?QK(e,t):YK(e,(t.s=-t.s,t))};It.modulo=It.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(_o+"NaN");return n.s?(Pr=!1,e=Lc(n,t,0,1).times(t),Pr=!0,n.minus(e)):xr(new r(n),i)};It.naturalExponential=It.exp=function(){return ZK(this)};It.naturalLogarithm=It.ln=function(){return eb(this)};It.negated=It.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};It.plus=It.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?YK(e,t):QK(e,(t.s=-t.s,t))};It.precision=It.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Vh+t);if(e=mi(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};It.squareRoot=It.sqrt=function(){var t,e,n,r,i,a,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(_o+"NaN")}for(t=mi(l),Pr=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=xl(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=yg((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=o=n+3;;)if(a=r,r=a.plus(Lc(l,a,o+2)).times(.5),xl(a.d).slice(0,o)===(e=xl(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(xr(a,n+1,0),a.times(a).eq(l)){r=a;break}}else if(e!="9999")break;o+=4}return Pr=!0,xr(r,n)};It.times=It.mul=function(t){var e,n,r,i,a,o,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,o=c,c=u,u=o),a=[],o=c+u,r=o;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%$i|0,e=l/$i|0;a[i]=(a[i]+e)%$i|0}for(;!a[--o];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,Pr?xr(t,f.precision):t};It.toDecimalPlaces=It.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(Al(t,0,bg),e===void 0?e=r.rounding:Al(e,0,8),xr(n,t+mi(n)+1,e))};It.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=mf(r,!0):(Al(t,0,bg),e===void 0?e=i.rounding:Al(e,0,8),r=xr(new i(r),t+1,e),n=mf(r,!0,t+1)),n};It.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?mf(i):(Al(t,0,bg),e===void 0?e=a.rounding:Al(e,0,8),r=xr(new a(i),t+mi(i)+1,e),n=mf(r.abs(),!1,t+mi(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};It.toInteger=It.toint=function(){var t=this,e=t.constructor;return xr(new e(t),mi(t)+1,e.rounding)};It.toNumber=function(){return+this};It.toPower=It.pow=function(t){var e,n,r,i,a,o,l=this,c=l.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(Ts);if(l=new c(l),!l.s){if(t.s<1)throw Error(_o+"Infinity");return l}if(l.eq(Ts))return l;if(r=c.precision,t.eq(Ts))return xr(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,a=l.s,o){if((n=d<0?-d:d)<=XK){for(i=new c(Ts),e=Math.ceil(r/Er+4),Pr=!1;n%2&&(i=i.times(l),k8(i.d,e)),n=yg(n/2),n!==0;)l=l.times(l),k8(l.d,e);return Pr=!0,t.s<0?new c(Ts).div(i):xr(i,r)}}else if(a<0)throw Error(_o+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,Pr=!1,i=t.times(eb(l,r+u)),Pr=!0,i=ZK(i),i.s=a,i};It.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=mi(i),r=mf(i,n<=a.toExpNeg||n>=a.toExpPos)):(Al(t,1,bg),e===void 0?e=a.rounding:Al(e,0,8),i=xr(new a(i),t,e),n=mi(i),r=mf(i,t<=n||n<=a.toExpNeg,t)),r};It.toSignificantDigits=It.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(Al(t,1,bg),e===void 0?e=r.rounding:Al(e,0,8)),xr(new r(n),t,e)};It.toString=It.valueOf=It.val=It.toJSON=It[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=mi(t),n=t.constructor;return mf(t,e<=n.toExpNeg||e>=n.toExpPos)};function YK(t,e){var n,r,i,a,o,l,c,u,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),Pr?xr(e,f):e;if(c=t.d,u=e.d,o=t.e,i=e.e,c=c.slice(),a=o-i,a){for(a<0?(r=c,a=-a,l=u.length):(r=u,i=o,l=c.length),o=Math.ceil(f/Er),l=o>l?o+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)/$i|0,c[a]%=$i;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,Pr?xr(e,f):e}function Al(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Vh+t)}function xl(t){var e,n,r,i=t.length-1,a="",o=t[0];if(i>0){for(a+=o,e=1;e<i;e++)r=t[e]+"",n=Er-r.length,n&&(a+=Wu(n)),a+=r;o=t[e],r=o+"",n=Er-r.length,n&&(a+=Wu(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return a+o}var Lc=(function(){function t(r,i){var a,o=0,l=r.length;for(r=r.slice();l--;)a=r[l]*i+o,r[l]=a%$i|0,o=a/$i|0;return o&&r.unshift(o),r}function e(r,i,a,o){var l,c;if(a!=o)c=a>o?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 o=0;a--;)r[a]-=o,o=r[a]<i[a]?1:0,r[a]=o*$i+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,o){var l,c,u,d,f,g,p,x,y,b,v,E,w,N,A,C,T,L,k=r.constructor,D=r.s==i.s?1:-1,U=r.d,O=i.d;if(!r.s)return new k(r);if(!i.s)throw Error(_o+"Division by zero");for(c=r.e-i.e,T=O.length,A=U.length,p=new k(D),x=p.d=[],u=0;O[u]==(U[u]||0);)++u;if(O[u]>(U[u]||0)&&--c,a==null?E=a=k.precision:o?E=a+(mi(r)-mi(i))+1:E=a,E<0)return new k(0);if(E=E/Er+2|0,u=0,T==1)for(d=0,O=O[0],E++;(u<A||d)&&E--;u++)w=d*$i+(U[u]||0),x[u]=w/O|0,d=w%O|0;else{for(d=$i/(O[0]+1)|0,d>1&&(O=t(O,d),U=t(U,d),T=O.length,A=U.length),N=T,y=U.slice(0,T),b=y.length;b<T;)y[b++]=0;L=O.slice(),L.unshift(0),C=O[0],O[1]>=$i/2&&++C;do d=0,l=e(O,y,T,b),l<0?(v=y[0],T!=b&&(v=v*$i+(y[1]||0)),d=v/C|0,d>1?(d>=$i&&(d=$i-1),f=t(O,d),g=f.length,b=y.length,l=e(f,y,g,b),l==1&&(d--,n(f,T<g?L:O,g))):(d==0&&(l=d=1),f=O.slice()),g=f.length,g<b&&f.unshift(0),n(y,f,b),l==-1&&(b=y.length,l=e(O,y,T,b),l<1&&(d++,n(y,T<b?L:O,b))),b=y.length):l===0&&(d++,y=[0]),x[u++]=d,l&&y[0]?y[b++]=U[N]||0:(y=[U[N]],b=1);while((N++<A||y[0]!==void 0)&&E--)}return x[0]||x.shift(),p.e=c,xr(p,o?a+mi(p)+1:a)}})();function ZK(t,e){var n,r,i,a,o,l,c=0,u=0,d=t.constructor,f=d.precision;if(mi(t)>16)throw Error(AD+mi(t));if(!t.s)return new d(Ts);for(Pr=!1,l=f,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(Sh(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d(Ts),d.precision=l;;){if(i=xr(i.times(t),l),n=n.times(++c),o=a.plus(Lc(i,n,l)),xl(o.d).slice(0,l)===xl(a.d).slice(0,l)){for(;u--;)a=xr(a.times(a),l);return d.precision=f,e==null?(Pr=!0,xr(a,f)):a}a=o}}function mi(t){for(var e=t.e*Er,n=t.d[0];n>=10;n/=10)e++;return e}function vT(t,e,n){if(e>t.LN10.sd())throw Pr=!0,n&&(t.precision=n),Error(_o+"LN10 precision limit exceeded");return xr(new t(t.LN10),e)}function Wu(t){for(var e="";t--;)e+="0";return e}function eb(t,e){var n,r,i,a,o,l,c,u,d,f=1,g=10,p=t,x=p.d,y=p.constructor,b=y.precision;if(p.s<1)throw Error(_o+(p.s?"NaN":"-Infinity"));if(p.eq(Ts))return new y(0);if(e==null?(Pr=!1,u=b):u=e,p.eq(10))return e==null&&(Pr=!0),vT(y,u);if(u+=g,y.precision=u,n=xl(x),r=n.charAt(0),a=mi(p),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(t),n=xl(p.d),r=n.charAt(0),f++;a=mi(p),r>1?(p=new y("0."+n),a++):p=new y(r+"."+n.slice(1))}else return c=vT(y,u+2,b).times(a+""),p=eb(new y(r+"."+n.slice(1)),u-g).plus(c),y.precision=b,e==null?(Pr=!0,xr(p,b)):p;for(l=o=p=Lc(p.minus(Ts),p.plus(Ts),u),d=xr(p.times(p),u),i=3;;){if(o=xr(o.times(d),u),c=l.plus(Lc(o,new y(i),u)),xl(c.d).slice(0,u)===xl(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(vT(y,u+2,b).times(a+""))),l=Lc(l,new y(f),u),y.precision=b,e==null?(Pr=!0,xr(l,b)):l;l=c,i+=2}}function C8(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=yg(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>jw||t.e<-jw))throw Error(AD+n)}else t.s=0,t.e=0,t.d=[0];return t}function xr(t,e,n){var r,i,a,o,l,c,u,d,f=t.d;for(o=1,a=f[0];a>=10;a/=10)o++;if(r=e-o,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],o=1;a>=10;a/=10)o++;r%=Er,i=r-Er+o}if(n!==void 0&&(a=Sh(10,o-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/Sh(10,o-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=mi(t),f.length=1,e=e-a-1,f[0]=Sh(10,(Er-e%Er)%Er),t.e=yg(-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=Sh(10,Er-r),f[d]=i>0?(u/Sh(10,o-i)%Sh(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==$i&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=$i)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(Pr&&(t.e>jw||t.e<-jw))throw Error(AD+mi(t));return t}function QK(t,e){var n,r,i,a,o,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?xr(e,p):e;if(c=t.d,f=e.d,r=e.e,u=t.e,c=c.slice(),o=u-r,o){for(d=o<0,d?(n=c,o=-o,l=f.length):(n=f,r=u,l=c.length),i=Math.max(Math.ceil(p/Er),l)+2,o>i&&(o=i,n.length=1),n.reverse(),i=o;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}o=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>o;){if(c[--i]<f[i]){for(a=i;a&&c[--a]===0;)c[a]=$i-1;--c[a],c[i]+=$i}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?xr(e,p):e):new g(0)}function mf(t,e,n){var r,i=mi(t),a=xl(t.d),o=a.length;return e?(n&&(r=n-o)>0?a=a.charAt(0)+"."+a.slice(1)+Wu(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+Wu(-i-1)+a,n&&(r=n-o)>0&&(a+=Wu(r))):i>=o?(a+=Wu(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+Wu(r))):((r=i+1)<o&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+="."),a+=Wu(r))),t.s<0?"-"+a:a}function k8(t,e){if(t.length>e)return t.length=e,!0}function JK(t){var e,n,r;function i(a){var o=this;if(!(o instanceof i))return new i(a);if(o.constructor=i,a instanceof i){o.s=a.s,o.e=a.e,o.d=(a=a.d)?a.slice():a;return}if(typeof a=="number"){if(a*0!==0)throw Error(Vh+a);if(a>0)o.s=1;else if(a<0)a=-a,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(a===~~a&&a<1e7){o.e=0,o.d=[a];return}return C8(o,a.toString())}else if(typeof a!="string")throw Error(Vh+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,tve.test(a))C8(o,a);else throw Error(Vh+a)}if(i.prototype=It,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=JK,i.config=i.set=nve,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 nve(t){if(!t||typeof t!="object")throw Error(_o+"Object expected");var e,n,r,i=["precision",1,bg,"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(yg(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Vh+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Vh+n+": "+r);return this}var ND=JK(eve);Ts=new ND(1);const Zn=ND;var rve=t=>t,eX={},tX=t=>t===eX,P8=t=>function e(){return arguments.length===0||arguments.length===1&&tX(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},nX=(t,e)=>t===1?e:P8(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var a=r.filter(o=>o!==eX).length;return a>=t?e(...r):nX(t-a,P8(function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];var u=r.map(d=>tX(d)?l.shift():d);return e(...u,...l)}))}),ive=t=>nX(t.length,t),Q3=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},ave=ive((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),sve=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return rve;var i=n.reverse(),a=i[0],o=i.slice(1);return function(){return o.reduce((l,c)=>c(l),a(...arguments))}},J3=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function rX(t){var e;return t===0?e=1:e=Math.floor(new Zn(t).abs().log(10).toNumber())+1,e}function iX(t,e,n){for(var r=new Zn(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var aX=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},sX=(t,e,n)=>{if(t.lte(0))return new Zn(0);var r=rX(t.toNumber()),i=new Zn(10).pow(r),a=t.div(i),o=r!==1?.05:.1,l=new Zn(Math.ceil(a.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new Zn(c.toNumber()):new Zn(Math.ceil(c.toNumber()))},ove=(t,e,n)=>{var r=new Zn(1),i=new Zn(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new Zn(10).pow(rX(t)-1),i=new Zn(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new Zn(Math.floor(t)))}else t===0?i=new Zn(Math.floor((e-1)/2)):n||(i=new Zn(Math.floor(t)));var o=Math.floor((e-1)/2),l=sve(ave(c=>i.add(new Zn(c-o).mul(r)).toNumber()),Q3);return l(0,e)},oX=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 Zn(0),tickMin:new Zn(0),tickMax:new Zn(0)};var o=sX(new Zn(n).sub(e).div(r-1),i,a),l;e<=0&&n>=0?l=new Zn(0):(l=new Zn(e).add(n).div(2),l=l.sub(new Zn(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new Zn(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?oX(e,n,r,i,a+1):(d<r&&(u=n>0?u+(r-d):u,c=n>0?c:c+(r-d)),{step:o,tickMin:l.sub(new Zn(c).mul(o)),tickMax:l.add(new Zn(u).mul(o))})},lve=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,o=Math.max(i,2),[l,c]=aX([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...Q3(0,i-1).map(()=>1/0)]:[...Q3(0,i-1).map(()=>-1/0),c];return n>r?J3(u):u}if(l===c)return ove(l,i,a);var{step:d,tickMin:f,tickMax:g}=oX(l,c,o,a,0),p=iX(f,g.add(new Zn(.1).mul(d)),d);return n>r?J3(p):p},cve=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=aX([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=sX(new Zn(l).sub(o).div(c-1),a,0),d=[...iX(new Zn(o),new Zn(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?J3(d):d},lX=t=>t.rootProps.maxBarSize,uve=t=>t.rootProps.barGap,cX=t=>t.rootProps.barCategoryGap,dve=t=>t.rootProps.barSize,Xb=t=>t.rootProps.stackOffset,uX=t=>t.rootProps.reverseStackOrder,TD=t=>t.options.chartName,CD=t=>t.rootProps.syncId,dX=t=>t.rootProps.syncMethod,kD=t=>t.options.eventEmitter,hve=t=>t.rootProps.baseValue,Kr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Sc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},As={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},BM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},fve={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Sc.angleAxisId,includeHidden:!1,name:void 0,reversed:Sc.reversed,scale:Sc.scale,tick:Sc.tick,tickCount:void 0,ticks:void 0,type:Sc.type,unit:void 0},mve={allowDataOverflow:As.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:As.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:As.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:As.scale,tick:As.tick,tickCount:As.tickCount,ticks:void 0,type:As.type,unit:void 0},pve={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:Sc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Sc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Sc.scale,tick:Sc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},gve={allowDataOverflow:As.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:As.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:As.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:As.scale,tick:As.tick,tickCount:As.tickCount,ticks:void 0,type:"category",unit:void 0},PD=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?pve:fve,jD=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?gve:mve,HM=t=>t.polarOptions,RD=Qe([tu,nu,ki],cK),hX=Qe([HM,RD],(t,e)=>{if(t!=null)return Ea(t.innerRadius,e,0)}),fX=Qe([HM,RD],(t,e)=>{if(t!=null)return Ea(t.outerRadius,e,e*.8)}),xve=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},mX=Qe([HM],xve);Qe([PD,mX],BM);var pX=Qe([RD,hX,fX],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});Qe([jD,pX],BM);var gX=Qe([Tn,HM,hX,fX,tu,nu],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:o,cy:l,startAngle:c,endAngle:u}=e;return{cx:Ea(o,i,i/2),cy:Ea(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),jr=(t,e)=>e,Yb=(t,e,n)=>n;function $M(t){return t?.id}function xX(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:a}=n,o=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=$M(l);u.forEach((f,g)=>{var p=a==null||i?g:String(Jn(f,a,null)),x=Jn(f,l.dataKey,0),y;o.has(p)?y=o.get(p):y={},Object.assign(y,{[d]:x}),o.set(p,y)})}}),Array.from(o.values())}function VM(t){return t.stackId!=null&&t.dataKey!=null}var GM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function WM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function bve(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 Ri=t=>{var e=Tn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},vg=t=>t.tooltip.settings.axisId;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 Rw(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){yve(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 yve(t,e,n){return(e=vve(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vve(t){var e=_ve(t,"string");return typeof e=="symbol"?e:e+""}function _ve(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 eP=[0,"auto"],Bi={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},bX=(t,e)=>t.cartesianAxis.xAxis[e],Il=(t,e)=>{var n=bX(t,e);return n??Bi},Hi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:eP,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:Bb},yX=(t,e)=>t.cartesianAxis.yAxis[e],Fl=(t,e)=>{var n=yX(t,e);return n??Hi},wve={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:""},DD=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??wve},Ir=(t,e,n)=>{switch(e){case"xAxis":return Il(t,n);case"yAxis":return Fl(t,n);case"zAxis":return DD(t,n);case"angleAxis":return PD(t,n);case"radiusAxis":return jD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Sve=(t,e,n)=>{switch(e){case"xAxis":return Il(t,n);case"yAxis":return Fl(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Zb=(t,e,n)=>{switch(e){case"xAxis":return Il(t,n);case"yAxis":return Fl(t,n);case"angleAxis":return PD(t,n);case"radiusAxis":return jD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},vX=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function OD(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 Qb=t=>t.graphicalItems.cartesianItems,Mve=Qe([jr,Yb],OD),LD=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Jb=Qe([Qb,Ir,Mve],LD,{memoizeOptions:{resultEqualityCheck:WM}}),_X=Qe([Jb],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(VM)),wX=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),Eve=Qe([Jb],wX),ID=t=>t.map(e=>e.data).filter(Boolean).flat(1),Ave=Qe([Jb],ID,{memoizeOptions:{resultEqualityCheck:WM}}),FD=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},UD=Qe([Ave,Kb],FD),zD=(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})),qM=Qe([UD,Ir,Jb],zD);function SX(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function M1(t){if(yo(t)||t instanceof Date){var e=Number(t);if(er(e))return e}}function R8(t){if(Array.isArray(t)){var e=[M1(t[0]),M1(t[1])];return Td(e)?e:void 0}var n=M1(t);if(n!=null)return[n,n]}function Zc(t){return t.map(M1).filter(Sfe)}function Nve(t,e,n){return!n||typeof e!="number"||ds(e)?[]:n.length?Zc(n.flatMap(r=>{var i=Jn(t,r.dataKey),a,o;if(Array.isArray(i)?[a,o]=i:a=o=i,!(!er(a)||!er(o)))return[e-a,e+o]})):[]}var Di=t=>{var e=Ri(t),n=vg(t);return Zb(t,e,n)},ey=Qe([Di],t=>t?.dataKey),Tve=Qe([_X,Kb,Di],xX),MX=(t,e,n,r)=>{var i={},a=e.reduce((o,l)=>(l.stackId==null||(o[l.stackId]==null&&(o[l.stackId]=[]),o[l.stackId].push(l)),o),i);return Object.fromEntries(Object.entries(a).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map($M);return[l,{stackedData:qpe(t,d,n),graphicalItems:u}]}))},tb=Qe([Tve,_X,Xb,uX],MX),EX=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var o=Zpe(t,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},Cve=Qe([Ir],t=>t.allowDataOverflow),BD=t=>{var e;if(t==null||!("domain"in t))return eP;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Zc(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:eP},HD=Qe([Ir],BD),$D=Qe([HD,Cve],KK),kve=Qe([tb,Hd,jr,$D],EX,{memoizeOptions:{resultEqualityCheck:GM}}),KM=t=>t.errorBars,Pve=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>SX(n,r)),Dw=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(),o=Math.min(...a),l=Math.max(...a);return[o,l]}},VD=(t,e,n,r,i)=>{var a,o;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(v=>SX(i,v)),g=Jn(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),p=Nve(l,g,f);if(p.length>=2){var x=Math.min(...p),y=Math.max(...p);(a==null||x<a)&&(a=x),(o==null||y>o)&&(o=y)}var b=R8(g);b!=null&&(a=a==null?b[0]:Math.min(a,b[0]),o=o==null?b[1]:Math.max(o,b[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=R8(Jn(l,e.dataKey));c!=null&&(a=a==null?c[0]:Math.min(a,c[0]),o=o==null?c[1]:Math.max(o,c[1]))}),er(a)&&er(o))return[a,o]},jve=Qe([UD,Ir,Eve,KM,jr],VD,{memoizeOptions:{resultEqualityCheck:GM}});function Rve(t){var{value:e}=t;if(yo(e)||e instanceof Date)return e}var Dve=(t,e,n)=>{var r=t.map(Rve).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&zW(r))?fK(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},AX=t=>t.referenceElements.dots,_g=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),Ove=Qe([AX,jr,Yb],_g),NX=t=>t.referenceElements.areas,Lve=Qe([NX,jr,Yb],_g),TX=t=>t.referenceElements.lines,Ive=Qe([TX,jr,Yb],_g),CX=(t,e)=>{var n=Zc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},Fve=Qe(Ove,jr,CX),kX=(t,e)=>{var n=Zc(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)]},Uve=Qe([Lve,jr],kX);function zve(t){var e;if(t.x!=null)return Zc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Zc(n)}function Bve(t){var e;if(t.y!=null)return Zc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Zc(n)}var PX=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?zve(r):Bve(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},Hve=Qe([Ive,jr],PX),$ve=Qe(Fve,Hve,Uve,(t,e,n)=>Dw(t,n,e)),GD=(t,e,n,r,i,a,o,l)=>{if(n!=null)return n;var c=o==="vertical"&&l==="xAxis"||o==="horizontal"&&l==="yAxis",u=c?Dw(r,a,i):Dw(a,i);return Jye(e,u,t.allowDataOverflow)},Vve=Qe([Ir,HD,$D,kve,jve,$ve,Tn,jr],GD,{memoizeOptions:{resultEqualityCheck:GM}}),Gve=[0,1],WD=(t,e,n,r,i,a,o)=>{if(!((t==null||n==null||n.length===0)&&o===void 0)){var{dataKey:l,type:c}=t,u=Ll(e,a);if(u&&l==null){var d;return fK(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?Dve(r,t,u):i==="expand"?Gve:o}},qD=Qe([Ir,Tn,UD,qM,Xb,jr,Vve],WD),jX=(t,e,n,r,i)=>{if(t!=null){var{scale:a,type:o}=t;if(a==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":o==="category"?"band":"linear";if(typeof a=="string"){var l="scale".concat(Ob(a));return l in Jx?l:"point"}}},wg=Qe([Ir,Tn,vX,TD,jr],jX);function Wve(t){if(t!=null){if(t in Jx)return Jx[t]();var e="scale".concat(Ob(t));if(e in Jx)return Jx[e]()}}function KD(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=Wve(e);if(i!=null){var a=i.domain(n).range(r);return Hpe(a),a}}}var XD=(t,e,n)=>{var r=BD(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&Td(t))return lve(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&Td(t))return cve(t,e.tickCount,e.allowDecimals)}},YD=Qe([qD,Zb,wg],XD),ZD=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&Td(e)&&Array.isArray(n)&&n.length>0){var i=e[0],a=n[0],o=e[1],l=n[n.length-1];return[Math.min(i,a),Math.max(o,l)]}return e},qve=Qe([Ir,qD,YD,jr],ZD),Kve=Qe(qM,Ir,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Zc(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 o=r[a+1]-r[a];n=Math.min(n,o)}return n/i}}),RX=Qe(Kve,Tn,cX,ki,(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 o=Ea(n,t*a),l=t*a/2;return l-o-(l-o)/a*o}return 0}),Xve=(t,e)=>{var n=Il(t,e);return n==null||typeof n.padding!="string"?0:RX(t,"xAxis",e,n.padding)},Yve=(t,e)=>{var n=Fl(t,e);return n==null||typeof n.padding!="string"?0:RX(t,"yAxis",e,n.padding)},Zve=Qe(Il,Xve,(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}}),Qve=Qe(Fl,Yve,(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}}),Jve=Qe([ki,Zve,kM,CM,(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]}),e_e=Qe([ki,Tn,Qve,kM,CM,(t,e,n)=>n],(t,e,n,r,i,a)=>{var{padding:o}=i;return a?[r.height-o.bottom,o.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),ty=(t,e,n,r)=>{var i;switch(e){case"xAxis":return Jve(t,n,r);case"yAxis":return e_e(t,n,r);case"zAxis":return(i=DD(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return mX(t);case"radiusAxis":return pX(t,n);default:return}},DX=Qe([Ir,ty],BM),Cd=Qe([Ir,wg,qve,DX],KD);Qe([Jb,KM,jr],Pve);function OX(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var XM=(t,e)=>e,YM=(t,e,n)=>n,t_e=Qe(NM,XM,YM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(OX)),n_e=Qe(TM,XM,YM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(OX)),LX=(t,e)=>({width:t.width,height:e.height}),r_e=(t,e)=>{var n=typeof e.width=="number"?e.width:Bb;return{width:n,height:t.height}},IX=Qe(ki,Il,LX),i_e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},a_e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},s_e=Qe(nu,ki,t_e,XM,YM,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=LX(e,l);o==null&&(o=i_e(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;a[l.id]=o-Number(u)*c.height,o+=(u?-1:1)*c.height}),a}),o_e=Qe(tu,ki,n_e,XM,YM,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=r_e(e,l);o==null&&(o=a_e(e,r,t));var u=r==="left"&&!i||r==="right"&&i;a[l.id]=o-Number(u)*c.width,o+=(u?-1:1)*c.width}),a}),l_e=(t,e)=>{var n=Il(t,e);if(n!=null)return s_e(t,n.orientation,n.mirror)},c_e=Qe([ki,Il,l_e,(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}}}),u_e=(t,e)=>{var n=Fl(t,e);if(n!=null)return o_e(t,n.orientation,n.mirror)},d_e=Qe([ki,Fl,u_e,(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}}}),FX=Qe(ki,Fl,(t,e)=>{var n=typeof e.width=="number"?e.width:Bb;return{width:n,height:t.height}}),D8=(t,e,n)=>{switch(e){case"xAxis":return IX(t,n).width;case"yAxis":return FX(t,n).height;default:return}},UX=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,l=Ll(t,r),c=e.map(u=>u.value);if(o&&l&&a==="category"&&i&&zW(c))return c}},QD=Qe([Tn,qM,Ir,jr],UX),zX=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,o=Ll(t,r);if(o&&(i==="number"||a!=="auto"))return e.map(l=>l.value)}},JD=Qe([Tn,qM,Zb,jr],zX),O8=Qe([Tn,Sve,wg,Cd,QD,JD,ty,YD,jr],(t,e,n,r,i,a,o,l,c)=>{if(e!=null){var u=Ll(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:o,realScaleType:n,scale:r}}}),h_e=(t,e,n,r,i,a,o,l,c)=>{if(!(e==null||r==null)){var u=Ll(t,c),{type:d,ticks:f,tickCount:g}=e,p=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/p:0;x=c==="angleAxis"&&a!=null&&a.length>=2?Wi(a[0]-a[1])*2*x:x;var y=f||i;if(y){var b=y.map((v,E)=>{var w=o?o.indexOf(v):v;return{index:E,coordinate:r(w)+x,value:v,offset:x}});return b.filter(v=>er(v.coordinate))}return u&&l?l.map((v,E)=>({coordinate:r(v)+x,value:v,index:E,offset:x})).filter(v=>er(v.coordinate)):r.ticks?r.ticks(g).map(v=>({coordinate:r(v)+x,value:v,offset:x})):r.domain().map((v,E)=>({coordinate:r(v)+x,value:o?o[v]:v,index:E,offset:x}))}},BX=Qe([Tn,Zb,wg,Cd,YD,ty,QD,JD,jr],h_e),f_e=(t,e,n,r,i,a,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=Ll(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?Wi(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}))}},Nl=Qe([Tn,Zb,Cd,ty,QD,JD,jr],f_e),Tl=Qe(Ir,Cd,(t,e)=>{if(!(t==null||e==null))return Rw(Rw({},t),{},{scale:e})}),m_e=Qe([Ir,wg,qD,DX],KD);Qe((t,e,n)=>DD(t,n),m_e,(t,e)=>{if(!(t==null||e==null))return Rw(Rw({},t),{},{scale:e})});var p_e=Qe([Tn,NM,TM],(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}}),HX=t=>t.options.defaultTooltipEventType,$X=t=>t.options.validateTooltipEventTypes;function VX(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function eO(t,e){var n=HX(t),r=$X(t);return VX(e,n,r)}function g_e(t){return Dt(e=>eO(e,t))}var GX=(t,e)=>{var n,r=Number(e);if(!(ds(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},x_e=t=>t.tooltip.settings,ed={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},b_e={itemInteraction:{click:ed,hover:ed},axisInteraction:{click:ed,hover:ed},keyboardInteraction:ed,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}},WX=hs({name:"tooltip",initialState:b_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=$o(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Cr()},removeTooltipEntrySettings:{reducer(t,e){var n=$o(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:y_e,replaceTooltipEntrySettings:v_e,removeTooltipEntrySettings:__e,setTooltipSettingsState:w_e,setActiveMouseOverItemIndex:qX,mouseLeaveItem:S_e,mouseLeaveChart:KX,setActiveClickItemIndex:M_e,setMouseOverAxisIndex:XX,setMouseClickAxisIndex:E_e,setSyncInteraction:tP,setKeyboardInteraction:nP}=WX.actions,A_e=WX.reducer;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 qv(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){N_e(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 N_e(t,e,n){return(e=T_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function T_e(t){var e=C_e(t,"string");return typeof e=="symbol"?e:e+""}function C_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 k_e(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function P_e(t){return t.index!=null}var YX=(t,e,n,r)=>{if(e==null)return ed;var i=k_e(t,e,n);if(i==null)return ed;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(P_e(i)){if(a)return qv(qv({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return qv(qv({},ed),{},{coordinate:i.coordinate})};function j_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 R_e(t,e){var n=j_e(t),r=e[0],i=e[1];if(n===void 0)return!1;var a=Math.min(r,i),o=Math.max(r,i);return n>=a&&n<=o}function D_e(t,e,n){if(n==null||e==null)return!0;var r=Jn(t,e);return r==null||!Td(n)?!0:R_e(r,n)}var tO=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!er(a))return i;var o=0,l=1/0;e.length>0&&(l=e.length-1);var c=Math.max(o,Math.min(a,l)),u=e[c];return u==null||D_e(u,n,r)?String(c):null},ZX=(t,e,n,r,i,a,o,l)=>{if(!(a==null||l==null)){var c=o[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}}}},QX=(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 o;return((o=a.settings)===null||o===void 0?void 0:o.dataKey)===i})},ny=t=>t.options.tooltipPayloadSearcher,Sg=t=>t.tooltip;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){O_e(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 O_e(t,e,n){return(e=L_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function L_e(t){var e=I_e(t,"string");return typeof e=="symbol"?e:e+""}function I_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 F_e(t,e){return t??e}var JX=(t,e,n,r,i,a,o)=>{if(!(e==null||a==null)){var{chartData:l,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((g,p)=>{var x,{dataDefinedOnItem:y,settings:b}=p,v=F_e(y,l),E=Array.isArray(v)?Oq(v,u,d):v,w=(x=b?.dataKey)!==null&&x!==void 0?x:r,N=b?.nameKey,A;if(r&&Array.isArray(E)&&!Array.isArray(E[0])&&o==="axis"?A=BW(E,r,i):A=a(E,e,c,N),Array.isArray(A))A.forEach(T=>{var L=F8(F8({},b),{},{name:T.name,unit:T.unit,color:void 0,fill:void 0});g.push(iB({tooltipEntrySettings:L,dataKey:T.dataKey,payload:T.payload,value:Jn(T.payload,T.dataKey),name:T.name}))});else{var C;g.push(iB({tooltipEntrySettings:b,dataKey:w,payload:A,value:Jn(A,w),name:(C=Jn(A,N))!==null&&C!==void 0?C:b?.name}))}return g},f)}},nO=Qe([Di,Tn,vX,TD,Ri],jX),U_e=Qe([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),z_e=Qe([Ri,vg],OD),ry=Qe([U_e,Di,z_e],LD,{memoizeOptions:{resultEqualityCheck:WM}}),B_e=Qe([ry],t=>t.filter(VM)),H_e=Qe([ry],ID,{memoizeOptions:{resultEqualityCheck:WM}}),Mg=Qe([H_e,Hd],FD),$_e=Qe([B_e,Hd,Di],xX),rO=Qe([Mg,Di,ry],zD),eY=Qe([Di],BD),V_e=Qe([Di],t=>t.allowDataOverflow),tY=Qe([eY,V_e],KK),G_e=Qe([ry],t=>t.filter(VM)),W_e=Qe([$_e,G_e,Xb,uX],MX),q_e=Qe([W_e,Hd,Ri,tY],EX),K_e=Qe([ry],wX),X_e=Qe([Mg,Di,K_e,KM,Ri],VD,{memoizeOptions:{resultEqualityCheck:GM}}),Y_e=Qe([AX,Ri,vg],_g),Z_e=Qe([Y_e,Ri],CX),Q_e=Qe([NX,Ri,vg],_g),J_e=Qe([Q_e,Ri],kX),e1e=Qe([TX,Ri,vg],_g),t1e=Qe([e1e,Ri],PX),n1e=Qe([Z_e,t1e,J_e],Dw),r1e=Qe([Di,eY,tY,q_e,X_e,n1e,Tn,Ri],GD),iy=Qe([Di,Tn,Mg,rO,Xb,Ri,r1e],WD),i1e=Qe([iy,Di,nO],XD),a1e=Qe([Di,iy,i1e,Ri],ZD),nY=t=>{var e=Ri(t),n=vg(t),r=!1;return ty(t,e,n,r)},rY=Qe([Di,nY],BM),iY=Qe([Di,nO,a1e,rY],KD),s1e=Qe([Tn,rO,Di,Ri],UX),o1e=Qe([Tn,rO,Di,Ri],zX),l1e=(t,e,n,r,i,a,o,l)=>{if(e){var{type:c}=e,u=Ll(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?Wi(i[0]-i[1])*2*f:f,u&&o?o.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}))}}},iu=Qe([Tn,Di,nO,iY,nY,s1e,o1e,Ri],l1e),iO=Qe([HX,$X,x_e],(t,e,n)=>VX(n.shared,t,e)),aY=t=>t.tooltip.settings.trigger,aO=t=>t.tooltip.settings.defaultIndex,ay=Qe([Sg,iO,aY,aO],YX),kd=Qe([ay,Mg,ey,iy],tO),sY=Qe([iu,kd],GX),sO=Qe([ay],t=>{if(t)return t.dataKey}),c1e=Qe([ay],t=>{if(t)return t.graphicalItemId}),oY=Qe([Sg,iO,aY,aO],QX),u1e=Qe([tu,nu,Tn,ki,iu,aO,oY,ny],ZX),d1e=Qe([ay,u1e],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),h1e=Qe([ay],t=>t.active),f1e=Qe([oY,kd,Hd,ey,sY,ny,iO],JX),m1e=Qe([f1e],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});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 z8(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){p1e(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 p1e(t,e,n){return(e=g1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function g1e(t){var e=x1e(t,"string");return typeof e=="symbol"?e:e+""}function x1e(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 b1e=()=>Dt(Di),y1e=()=>{var t=b1e(),e=Dt(iu),n=Dt(iY);return Nd(!t||!n?void 0:z8(z8({},t),{},{scale:n}),e)};function B8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function gm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?B8(Object(n),!0).forEach(function(r){v1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function v1e(t,e,n){return(e=_1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _1e(t){var e=w1e(t,"string");return typeof e=="symbol"?e:e+""}function w1e(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 S1e=(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}},M1e=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var a=i.coordinate,{radius:o}=r;return gm(gm(gm({},r),hi(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var l=i.coordinate,{angle:c}=r;return gm(gm(gm({},r),hi(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 E1e(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 lY=(t,e,n,r,i)=>{var a,o=-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(Wi(d-u)!==Wi(f-d)){var p=[];if(Wi(f-d)===Wi(i[1]-i[0])){g=f;var x=d+i[1]-i[0];p[0]=Math.min(x,(x+u)/2),p[1]=Math.max(x,(x+u)/2)}else{g=u;var y=f+i[1]-i[0];p[0]=Math.min(d,(y+d)/2),p[1]=Math.max(d,(y+d)/2)}var b=[Math.min(d,(g+d)/2),Math.max(d,(g+d)/2)];if(t>b[0]&&t<=b[1]||t>=p[0]&&t<=p[1]){({index:o}=n[c]);break}}else{var v=Math.min(u,f),E=Math.max(u,f);if(t>(v+d)/2&&t<=(E+d)/2){({index:o}=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:o}=e[w]);break}}return o},cY=()=>Dt(TD),oO=(t,e)=>e,uY=(t,e,n)=>n,lO=(t,e,n,r)=>r,A1e=Qe(iu,t=>bM(t,e=>e.coordinate)),cO=Qe([Sg,oO,uY,lO],YX),uO=Qe([cO,Mg,ey,iy],tO),N1e=(t,e,n)=>{if(e!=null){var r=Sg(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},dY=Qe([Sg,oO,uY,lO],QX),Ow=Qe([tu,nu,Tn,ki,iu,lO,dY,ny],ZX),T1e=Qe([cO,Ow],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),hY=Qe([iu,uO],GX),C1e=Qe([dY,uO,Hd,ey,hY,ny,oO],JX),k1e=Qe([cO,uO],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),P1e=(t,e,n,r,i,a,o)=>{if(!(!t||!n||!r||!i)&&E1e(t,o)){var l=Qpe(t,e),c=lY(l,a,i,n,r),u=S1e(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},j1e=(t,e,n,r,i,a,o)=>{if(!(!t||!r||!i||!a||!n)){var l=p0e(t,n);if(l){var c=Jpe(l,e),u=lY(c,o,a,r,i),d=M1e(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},R1e=(t,e,n,r,i,a,o,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?P1e(t,e,r,i,a,o,l):j1e(t,e,n,r,i,a,o)},D1e=Qe(t=>t.zIndex.zIndexMap,(t,e)=>e,(t,e,n)=>n,(t,e,n)=>{if(e!=null){var r=t[e];if(r!=null)return n?r.panoramaElementId:r.elementId}}),O1e=Qe(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Kr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:bve}});function H8(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 $8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?H8(Object(n),!0).forEach(function(r){L1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):H8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function L1e(t,e,n){return(e=I1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function I1e(t){var e=F1e(t,"string");return typeof e=="symbol"?e:e+""}function F1e(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 U1e={},z1e={zIndexMap:Object.values(Kr).reduce((t,e)=>$8($8({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),U1e)},B1e=new Set(Object.values(Kr));function H1e(t){return B1e.has(t)}var fY=hs({name:"zIndex",initialState:z1e,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&&!H1e(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:$1e,unregisterZIndexPortal:V1e,registerZIndexPortalId:G1e,unregisterZIndexPortalId:W1e}=fY.actions,q1e=fY.reducer;function Na(t){var{zIndex:e,children:n}=t,r=Pge(),i=r&&e!==void 0&&e!==0,a=Pi(),o=br();S.useLayoutEffect(()=>i?(o($1e({zIndex:e})),()=>{o(V1e({zIndex:e}))}):Lb,[o,e,i]);var l=Dt(u=>D1e(u,e,a));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?Tc.createPortal(n,c):null}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 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 Kv(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){K1e(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 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){var{cursor:e,cursorComp:n,cursorProps:r}=t;return S.isValidElement(e)?S.cloneElement(e,r):S.createElement(n,r)}function Q1e(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,g=r,p=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,y,b;if(d==="ScatterChart")x=f,y=kxe,b=Kr.cursorLine;else if(d==="BarChart")x=Pxe(l,f,a,o),y=lK,b=Kr.cursorRectangle;else if(l==="radial"&&$W(f)){var{cx:v,cy:E,radius:w,startAngle:N,endAngle:A}=uK(f);x={cx:v,cy:E,startAngle:N,endAngle:A,innerRadius:w,outerRadius:w},y=hK,b=Kr.cursorLine}else x={points:y0e(l,f,a)},y=bp,b=Kr.cursorLine;var C=typeof c=="object"&&"className"in c?c.className:void 0,T=Kv(Kv(Kv(Kv({stroke:"#ccc",pointerEvents:"none"},a),x),uf(c)),{},{payload:g,payloadIndex:p,className:On("recharts-tooltip-cursor",C)});return S.createElement(Na,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:b},S.createElement(Z1e,{cursor:c,cursorComp:y,cursorProps:T}))}function J1e(t){var e=y1e(),n=Wq(),r=Cf(),i=cY();return e==null||n==null||r==null||i==null?null:S.createElement(Q1e,rP({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var mY=S.createContext(null),ewe=()=>S.useContext(mY),_T={exports:{}},G8;function twe(){return G8||(G8=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function a(c,u,d,f,g){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new i(d,f||c,g),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],p]:c._events[x].push(p):(c._events[x]=p,c._eventsCount++),c}function o(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function l(){this._events=new r,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)e.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var g=0,p=f.length,x=new Array(p);g<p;g++)x[g]=f[g].fn;return x},l.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},l.prototype.emit=function(u,d,f,g,p,x){var y=n?n+u:u;if(!this._events[y])return!1;var b=this._events[y],v=arguments.length,E,w;if(b.fn){switch(b.once&&this.removeListener(u,b.fn,void 0,!0),v){case 1:return b.fn.call(b.context),!0;case 2:return b.fn.call(b.context,d),!0;case 3:return b.fn.call(b.context,d,f),!0;case 4:return b.fn.call(b.context,d,f,g),!0;case 5:return b.fn.call(b.context,d,f,g,p),!0;case 6:return b.fn.call(b.context,d,f,g,p,x),!0}for(w=1,E=new Array(v-1);w<v;w++)E[w-1]=arguments[w];b.fn.apply(b.context,E)}else{var N=b.length,A;for(w=0;w<N;w++)switch(b[w].once&&this.removeListener(u,b[w].fn,void 0,!0),v){case 1:b[w].fn.call(b[w].context);break;case 2:b[w].fn.call(b[w].context,d);break;case 3:b[w].fn.call(b[w].context,d,f);break;case 4:b[w].fn.call(b[w].context,d,f,g);break;default:if(!E)for(A=1,E=new Array(v-1);A<v;A++)E[A-1]=arguments[A];b[w].fn.apply(b[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 o(this,p),this;var x=this._events[p];if(x.fn)x.fn===d&&(!g||x.once)&&(!f||x.context===f)&&o(this,p);else{for(var y=0,b=[],v=x.length;y<v;y++)(x[y].fn!==d||g&&!x[y].once||f&&x[y].context!==f)&&b.push(x[y]);b.length?this._events[p]=b.length===1?b[0]:b:o(this,p)}return this},l.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&o(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})(_T)),_T.exports}var nwe=twe();const rwe=wo(nwe);var nb=new rwe,iP="recharts.syncEvent.tooltip",W8="recharts.syncEvent.brush";function ZM(t,e){if(e){var n=Number.parseInt(e,10);if(!ds(n))return t?.[n]}}var iwe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},pY=hs({name:"options",initialState:iwe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),awe=pY.reducer,{createEventEmitter:swe}=pY.actions;function owe(t){return t.tooltip.syncInteraction}var lwe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},gY=hs({name:"chartData",initialState:lwe,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:q8,setDataStartEndIndexes:cwe,setComputedData:wqe}=gY.actions,uwe=gY.reducer,dwe=["x","y"];function K8(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 xm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?K8(Object(n),!0).forEach(function(r){hwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hwe(t,e,n){return(e=fwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fwe(t){var e=mwe(t,"string");return typeof e=="symbol"?e:e+""}function mwe(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 pwe(t,e){if(t==null)return{};var n,r,i=gwe(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 gwe(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 xwe(){var t=Dt(CD),e=Dt(kD),n=br(),r=Dt(dX),i=Dt(iu),a=Cf(),o=Hb(),l=Dt(c=>c.rootProps.className);S.useEffect(()=>{if(t==null)return Lb;var c=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var g;if(o&&d!==null&&d!==void 0&&(g=d.payload)!==null&&g!==void 0&&g.coordinate&&d.payload.sourceViewBox){var p=d.payload.coordinate,{x,y}=p,b=pwe(p,dwe),{x:v,y:E,width:w,height:N}=d.payload.sourceViewBox,A=xm(xm({},b),{},{x:o.x+(w?(x-v)/w:0)*o.width,y:o.y+(N?(y-E)/N:0)*o.height});n(xm(xm({},d),{},{payload:xm(xm({},d.payload),{},{coordinate:A})}))}else n(d);return}if(i!=null){var C;if(typeof r=="function"){var T={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},L=r(i,T);C=i[L]}else r==="value"&&(C=i.find(Y=>String(Y.value)===d.payload.label));var{coordinate:k}=d.payload;if(C==null||d.payload.active===!1||k==null||o==null){n(tP({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:D,y:U}=k,O=Math.min(D,o.x+o.width),q=Math.min(U,o.y+o.height),R={x:a==="horizontal"?C.coordinate:O,y:a==="horizontal"?q:C.coordinate},G=tP({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(G)}}};return nb.on(iP,c),()=>{nb.off(iP,c)}},[l,n,e,t,r,i,a,o])}function bwe(){var t=Dt(CD),e=Dt(kD),n=br();S.useEffect(()=>{if(t==null)return Lb;var r=(i,a,o)=>{e!==o&&t===i&&n(cwe(a))};return nb.on(W8,r),()=>{nb.off(W8,r)}},[n,e,t])}function ywe(){var t=br();S.useEffect(()=>{t(swe())},[t]),xwe(),bwe()}function vwe(t,e,n,r,i,a){var o=Dt(p=>N1e(p,t,e)),l=Dt(kD),c=Dt(CD),u=Dt(dX),d=Dt(owe),f=d?.active,g=Hb();S.useEffect(()=>{if(!f&&c!=null&&l!=null){var p=tP({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});nb.emit(iP,c,p,l)}},[f,n,o,i,r,l,c,u,a,g])}function X8(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 Y8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?X8(Object(n),!0).forEach(function(r){_we(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):X8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _we(t,e,n){return(e=wwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wwe(t){var e=Swe(t,"string");return typeof e=="symbol"?e:e+""}function Swe(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 Mwe(t){return t.dataKey}function Ewe(t,e){return S.isValidElement(t)?S.cloneElement(t,e):typeof t=="function"?S.createElement(t,e):S.createElement(cxe,e)}var Z8=[],Awe={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 E1(t){var e,n,r=Lr(t,Awe),{active:i,allowEscapeViewBox:a,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:g,position:p,reverseDirection:x,useTranslate3d:y,wrapperStyle:b,cursor:v,shared:E,trigger:w,defaultIndex:N,portal:A,axisId:C}=r,T=br(),L=typeof N=="number"?String(N):N;S.useEffect(()=>{T(w_e({shared:E,trigger:w,axisId:C,active:i,defaultIndex:L}))},[T,E,w,C,i,L]);var k=Hb(),D=rK(),U=g_e(E),{activeIndex:O,isActive:q}=(e=Dt(ue=>k1e(ue,U,w,L)))!==null&&e!==void 0?e:{},R=Dt(ue=>C1e(ue,U,w,L)),G=Dt(ue=>hY(ue,U,w,L)),Y=Dt(ue=>T1e(ue,U,w,L)),V=R,K=ewe(),J=(n=i??q)!==null&&n!==void 0?n:!1,[X,F]=aq([V,J]),W=U==="axis"?G:void 0;vwe(U,w,Y,W,O,J);var ee=A??K;if(ee==null||k==null||U==null)return null;var ie=V??Z8;J||(ie=Z8),u&&ie.length&&(ie=JW(ie.filter(ue=>ue.value!=null&&(ue.hide!==!0||r.includeHidden)),g,Mwe));var ae=ie.length>0,de=S.createElement(gxe,{allowEscapeViewBox:a,animationDuration:o,animationEasing:l,isAnimationActive:d,active:J,coordinate:Y,hasPayload:ae,offset:f,position:p,reverseDirection:x,useTranslate3d:y,viewBox:k,wrapperStyle:b,lastBoundingBox:X,innerRef:F,hasPortalFromProps:!!A},Ewe(c,Y8(Y8({},r),{},{payload:ie,label:W,active:J,activeIndex:O,coordinate:Y,accessibilityLayer:D})));return S.createElement(S.Fragment,null,Tc.createPortal(de,ee),J&&S.createElement(J1e,{cursor:v,tooltipEventType:U,coordinate:Y,payload:ie,index:O}))}var sy=t=>null;sy.displayName="Cell";function Nwe(t,e,n){return(e=Twe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Twe(t){var e=Cwe(t,"string");return typeof e=="symbol"?e:e+""}function Cwe(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 kwe{constructor(e){Nwe(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 Pwe(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){jwe(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 jwe(t,e,n){return(e=Rwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Rwe(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)}var Owe={cacheSize:2e3,enableCache:!0},xY=Pwe({},Owe),J8=new kwe(xY.cacheSize),Lwe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},e6="recharts_measurement_span";function Iwe(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",a=e.fontStyle||"",o=e.letterSpacing||"",l=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(a,"|").concat(o,"|").concat(l)}var t6=(t,e)=>{try{var n=document.getElementById(e6);n||(n=document.createElement("span"),n.setAttribute("id",e6),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,Lwe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},m0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||mg.isSsr)return{width:0,height:0};if(!xY.enableCache)return t6(e,n);var r=Iwe(e,n),i=J8.get(r);if(i)return i;var a=t6(e,n);return J8.set(r,a),a},n6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,r6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Fwe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,Uwe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,bY={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},zwe=Object.keys(bY),up="NaN";function Bwe(t,e){return t*bY[e]}class ts{static parse(e){var n,[,r,i]=(n=Uwe.exec(e))!==null&&n!==void 0?n:[];return new ts(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,ds(e)&&(this.unit=""),n!==""&&!Fwe.test(n)&&(this.num=NaN,this.unit=""),zwe.includes(n)&&(this.num=Bwe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new ts(NaN,""):new ts(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new ts(NaN,""):new ts(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ts(NaN,""):new ts(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ts(NaN,""):new ts(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return ds(this.num)}}function yY(t){if(t.includes(up))return up;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=n6.exec(e))!==null&&n!==void 0?n:[],o=ts.parse(r??""),l=ts.parse(a??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return up;e=e.replace(n6,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,g]=(u=r6.exec(e))!==null&&u!==void 0?u:[],p=ts.parse(d??""),x=ts.parse(g??""),y=f==="+"?p.add(x):p.subtract(x);if(y.isNaN())return up;e=e.replace(r6,y.toString())}return e}var i6=/\(([^()]*)\)/;function Hwe(t){for(var e=t,n;(n=i6.exec(e))!=null;){var[,r]=n;e=e.replace(i6,yY(r))}return e}function $we(t){var e=t.replace(/\s+/g,"");return e=Hwe(e),e=yY(e),e}function Vwe(t){try{return $we(t)}catch{return up}}function wT(t){var e=Vwe(t.slice(5,-1));return e===up?"":e}var Gwe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],Wwe=["dx","dy","angle","className","breakAll"];function aP(){return aP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},aP.apply(null,arguments)}function a6(t,e){if(t==null)return{};var n,r,i=qwe(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 qwe(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 vY=/[ \f\n\r\t\v\u2028\u2029]+/,_Y=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Nr(e)||(n?i=e.toString().split(""):i=e.toString().split(vY));var a=i.map(l=>({word:l,width:m0(l,r).width})),o=n?0:m0(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function Kwe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var wY=(t,e,n,r)=>t.reduce((i,a)=>{var{word:o,width:l}=a,c=i[i.length-1];if(c&&l!=null&&(e==null||r||c.width+l+n<Number(e)))c.words.push(o),c.width+=l+n;else{var u={words:[o],width:l};i.push(u)}return i},[]),SY=t=>t.reduce((e,n)=>e.width>n.width?e:n),Xwe="…",s6=(t,e,n,r,i,a,o,l)=>{var c=t.slice(0,e),u=_Y({breakAll:n,style:r,children:c+Xwe});if(!u)return[!1,[]];var d=wY(u.wordsWithComputedWidth,a,o,l),f=d.length>i||SY(d).width>Number(a);return[f,d]},Ywe=(t,e,n,r,i)=>{var{maxLines:a,children:o,style:l,breakAll:c}=t,u=Lt(a),d=String(o),f=wY(e,r,n,i);if(!u||i)return f;var g=f.length>a||SY(f).width>Number(r);if(!g)return f;for(var p=0,x=d.length-1,y=0,b;p<=x&&y<=d.length-1;){var v=Math.floor((p+x)/2),E=v-1,[w,N]=s6(d,E,c,l,a,r,n,i),[A]=s6(d,v,c,l,a,r,n,i);if(!w&&!A&&(p=v+1),w&&A&&(x=v-1),!w&&A){b=N;break}y++}return b||f},o6=t=>{var e=Nr(t)?[]:t.toString().split(vY);return[{words:e,width:void 0}]},Zwe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=t;if((e||n)&&!mg.isSsr){var l,c,u=_Y({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return o6(r);return Ywe({breakAll:a,children:r,maxLines:o,style:i},l,c,e,!!n)}return o6(r)},MY="#808080",Qwe={angle:0,breakAll:!1,capHeight:"0.71em",fill:MY,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},QM=S.forwardRef((t,e)=>{var n=Lr(t,Qwe),{x:r,y:i,lineHeight:a,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=a6(n,Gwe),g=S.useMemo(()=>Zwe({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:p,dy:x,angle:y,className:b,breakAll:v}=f,E=a6(f,Wwe);if(!yo(r)||!yo(i)||g.length===0)return null;var w=Number(r)+(Lt(p)?p:0),N=Number(i)+(Lt(x)?x:0);if(!er(w)||!er(N))return null;var A;switch(d){case"start":A=wT("calc(".concat(o,")"));break;case"middle":A=wT("calc(".concat((g.length-1)/2," * -").concat(a," + (").concat(o," / 2))"));break;default:A=wT("calc(".concat(g.length-1," * -").concat(a,")"));break}var C=[];if(c){var T=g[0].width,{width:L}=f;C.push("scale(".concat(Lt(L)&&Lt(T)?L/T:1,")"))}return y&&C.push("rotate(".concat(y,", ").concat(w,", ").concat(N,")")),C.length&&(E.transform=C.join(" ")),S.createElement("text",aP({},fa(E),{ref:e,x:w,y:N,className:On("recharts-text",b),textAnchor:u,fill:l.includes("url")?MY:l}),g.map((k,D)=>{var U=k.words.join(v?"":" ");return S.createElement("tspan",{x:w,dy:D===0?A:a,key:"".concat(U,"-").concat(D)},U)}))});QM.displayName="Text";var Jwe=["labelRef"];function eSe(t,e){if(t==null)return{};var n,r,i=tSe(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 tSe(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 l6(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 ei(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?l6(Object(n),!0).forEach(function(r){nSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function nSe(t,e,n){return(e=rSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rSe(t){var e=iSe(t,"string");return typeof e=="symbol"?e:e+""}function iSe(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 Mc(){return Mc=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},Mc.apply(null,arguments)}var EY=S.createContext(null),AY=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o,children:l}=t,c=S.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[e,n,r,i,a,o]);return S.createElement(EY.Provider,{value:c},l)},NY=()=>{var t=S.useContext(EY),e=Hb();return t||Gq(e)},aSe=S.createContext(null),sSe=()=>{var t=S.useContext(aSe),e=Dt(gX);return t||e},oSe=t=>{var{value:e,formatter:n}=t,r=Nr(t.children)?e:t.children;return typeof n=="function"?n(r):r},dO=t=>t!=null&&typeof t=="function",lSe=(t,e)=>{var n=Wi(e-t),r=Math.min(Math.abs(e-t),360);return n*r},cSe=(t,e,n,r,i)=>{var{offset:a,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:g,clockWise:p}=i,x=(u+d)/2,y=lSe(f,g),b=y>=0?1:-1,v,E;switch(e){case"insideStart":v=f+b*a,E=p;break;case"insideEnd":v=g-b*a,E=!p;break;case"end":v=g+b*a,E=p;break;default:throw new Error("Unsupported position ".concat(e))}E=y<=0?E:!E;var w=hi(l,c,x,v),N=hi(l,c,x,v+(E?1:-1)*359),A="M".concat(w.x,",").concat(w.y,`
  44. A`).concat(x,",").concat(x,",0,1,").concat(E?0:1,`,
  45. `).concat(N.x,",").concat(N.y),C=Nr(t.id)?H0("recharts-radial-line-"):t.id;return S.createElement("text",Mc({},r,{dominantBaseline:"central",className:On("recharts-radial-bar-label",o)}),S.createElement("defs",null,S.createElement("path",{id:C,d:A})),S.createElement("textPath",{xlinkHref:"#".concat(C)},n))},uSe=(t,e,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:o,startAngle:l,endAngle:c}=t,u=(l+c)/2;if(n==="outside"){var{x:d,y:f}=hi(r,i,o+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+o)/2,{x:p,y:x}=hi(r,i,g,u);return{x:p,y:x,textAnchor:"middle",verticalAnchor:"middle"}},sP=t=>"cx"in t&&Lt(t.cx),dSe=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!sP(n)&&(a=n);var{x:o,y:l,upperWidth:c,lowerWidth:u,height:d}=e,f=o,g=o+(c-u)/2,p=(f+g)/2,x=(c+u)/2,y=f+c/2,b=d>=0?1:-1,v=b*r,E=b>0?"end":"start",w=b>0?"start":"end",N=c>=0?1:-1,A=N*r,C=N>0?"end":"start",T=N>0?"start":"end";if(i==="top"){var L={x:f+c/2,y:l-v,textAnchor:"middle",verticalAnchor:E};return ei(ei({},L),a?{height:Math.max(l-a.y,0),width:c}:{})}if(i==="bottom"){var k={x:g+u/2,y:l+d+v,textAnchor:"middle",verticalAnchor:w};return ei(ei({},k),a?{height:Math.max(a.y+a.height-(l+d),0),width:u}:{})}if(i==="left"){var D={x:p-A,y:l+d/2,textAnchor:C,verticalAnchor:"middle"};return ei(ei({},D),a?{width:Math.max(D.x-a.x,0),height:d}:{})}if(i==="right"){var U={x:p+x+A,y:l+d/2,textAnchor:T,verticalAnchor:"middle"};return ei(ei({},U),a?{width:Math.max(a.x+a.width-U.x,0),height:d}:{})}var O=a?{width:x,height:d}:{};return i==="insideLeft"?ei({x:p+A,y:l+d/2,textAnchor:T,verticalAnchor:"middle"},O):i==="insideRight"?ei({x:p+x-A,y:l+d/2,textAnchor:C,verticalAnchor:"middle"},O):i==="insideTop"?ei({x:f+c/2,y:l+v,textAnchor:"middle",verticalAnchor:w},O):i==="insideBottom"?ei({x:g+u/2,y:l+d-v,textAnchor:"middle",verticalAnchor:E},O):i==="insideTopLeft"?ei({x:f+A,y:l+v,textAnchor:T,verticalAnchor:w},O):i==="insideTopRight"?ei({x:f+c-A,y:l+v,textAnchor:C,verticalAnchor:w},O):i==="insideBottomLeft"?ei({x:g+A,y:l+d-v,textAnchor:T,verticalAnchor:E},O):i==="insideBottomRight"?ei({x:g+u-A,y:l+d-v,textAnchor:C,verticalAnchor:E},O):i&&typeof i=="object"&&(Lt(i.x)||Wc(i.x))&&(Lt(i.y)||Wc(i.y))?ei({x:o+Ea(i.x,x),y:l+Ea(i.y,d),textAnchor:"end",verticalAnchor:"end"},O):ei({x:y,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},O)},hSe={angle:0,offset:5,zIndex:Kr.label,position:"middle",textBreakAll:!1};function qu(t){var e=Lr(t,hSe),{viewBox:n,position:r,value:i,children:a,content:o,className:l="",textBreakAll:c,labelRef:u}=e,d=sSe(),f=NY(),g=r==="center"?f:d??f,p,x,y;if(n==null?p=g:sP(n)?p=n:p=Gq(n),!p||Nr(i)&&Nr(a)&&!S.isValidElement(o)&&typeof o!="function")return null;var b=ei(ei({},e),{},{viewBox:p});if(S.isValidElement(o)){var{labelRef:v}=b,E=eSe(b,Jwe);return S.cloneElement(o,E)}if(typeof o=="function"){if(x=S.createElement(o,b),S.isValidElement(x))return x}else x=oSe(e);var w=fa(e);if(sP(p)){if(r==="insideStart"||r==="insideEnd"||r==="end")return cSe(e,r,x,w,p);y=uSe(p,e.offset,e.position)}else y=dSe(e,p);return S.createElement(Na,{zIndex:e.zIndex},S.createElement(QM,Mc({ref:u,className:On("recharts-label",l)},w,y,{textAnchor:Kwe(w.textAnchor)?w.textAnchor:y.textAnchor,breakAll:c}),x))}qu.displayName="Label";var fSe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?S.createElement(qu,Mc({key:"label-implicit"},r)):yo(t)?S.createElement(qu,Mc({key:"label-implicit",value:t},r)):S.isValidElement(t)?t.type===qu?S.cloneElement(t,ei({key:"label-implicit"},r)):S.createElement(qu,Mc({key:"label-implicit",content:t},r)):dO(t)?S.createElement(qu,Mc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?S.createElement(qu,Mc({},t,{key:"label-implicit"},r)):null};function TY(t){var{label:e,labelRef:n}=t,r=NY();return fSe(e,r,n)||null}var ST={},MT={},c6;function mSe(){return c6||(c6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(MT)),MT}var ET={},u6;function pSe(){return u6||(u6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(ET)),ET}var d6;function gSe(){return d6||(d6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mSe(),n=pSe(),r=UR();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(ST)),ST}var AT,h6;function xSe(){return h6||(h6=1,AT=gSe().last),AT}var bSe=xSe();const ySe=wo(bSe);var vSe=["valueAccessor"],_Se=["dataKey","clockWise","id","textBreakAll","zIndex"];function Lw(){return Lw=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},Lw.apply(null,arguments)}function f6(t,e){if(t==null)return{};var n,r,i=wSe(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 wSe(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 SSe=t=>Array.isArray(t.value)?ySe(t.value):t.value,CY=S.createContext(void 0),hO=CY.Provider,kY=S.createContext(void 0),MSe=kY.Provider;function ESe(){return S.useContext(CY)}function ASe(){return S.useContext(kY)}function A1(t){var{valueAccessor:e=SSe}=t,n=f6(t,vSe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:l}=n,c=f6(n,_Se),u=ESe(),d=ASe(),f=u||d;return!f||!f.length?null:S.createElement(Na,{zIndex:l??Kr.label},S.createElement(Or,{className:"recharts-label-list"},f.map((g,p)=>{var x,y=Nr(r)?e(g,p):Jn(g&&g.payload,r),b=Nr(a)?{}:{id:"".concat(a,"-").concat(p)};return S.createElement(qu,Lw({key:"label-".concat(p)},fa(g),c,b,{fill:(x=n.fill)!==null&&x!==void 0?x:g.fill,parentViewBox:g.parentViewBox,value:y,textBreakAll:o,viewBox:g.viewBox,index:p,zIndex:0}))})))}A1.displayName="LabelList";function JM(t){var{label:e}=t;return e?e===!0?S.createElement(A1,{key:"labelList-implicit"}):S.isValidElement(e)||dO(e)?S.createElement(A1,{key:"labelList-implicit",content:e}):typeof e=="object"?S.createElement(A1,Lw({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}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)}var PY=t=>{var{cx:e,cy:n,r,className:i}=t,a=On("recharts-dot",i);return Lt(e)&&Lt(n)&&Lt(r)?S.createElement("circle",oP({},Ua(t),FR(t),{className:a,cx:e,cy:n,r})):null},jY=t=>t.graphicalItems.polarItems,NSe=Qe([jr,Yb],OD),e2=Qe([jY,Ir,NSe],LD),TSe=Qe([e2],ID),t2=Qe([TSe,ED],FD),CSe=Qe([t2,Ir,e2],zD);Qe([t2,Ir,e2],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,o=Jn(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Jn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var m6=()=>{},kSe=Qe([t2,Ir,e2,KM,jr],VD),PSe=Qe([Ir,HD,$D,m6,kSe,m6,Tn,jr],GD),RY=Qe([Ir,Tn,t2,CSe,Xb,jr,PSe],WD),jSe=Qe([RY,Ir,wg],XD);Qe([Ir,RY,jSe,jr],ZD);var RSe={radiusAxis:{},angleAxis:{}},DY=hs({name:"polarAxis",initialState:RSe,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:Sqe,removeRadiusAxis:Mqe,addAngleAxis:Eqe,removeAngleAxis:Aqe}=DY.actions,DSe=DY.reducer;function p6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function g6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?p6(Object(n),!0).forEach(function(r){OSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function OSe(t,e,n){return(e=LSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LSe(t){var e=ISe(t,"string");return typeof e=="symbol"?e:e+""}function ISe(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 FSe=(t,e)=>e,fO=Qe([jY,FSe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),USe=[],mO=(t,e,n)=>n?.length===0?USe:n,OY=Qe([ED,fO,mO],(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=>g6(g6({},e.presentationProps),a.props))),i!=null)return i}}),zSe=Qe([OY,fO,mO],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,o=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:Ud(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),BSe=Qe([OY,fO,mO,ki],(t,e,n,r)=>{if(!(e==null||t==null))return HMe({offset:r,pieSettings:e,displayedData:t,cells:n})}),NT={exports:{}},ar={};var x6;function HSe(){if(x6)return ar;x6=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"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),p=Symbol.for("react.client.reference");function x(y){if(typeof y=="object"&&y!==null){var b=y.$$typeof;switch(b){case t:switch(y=y.type,y){case n:case i:case r:case c:case u:case g:return y;default:switch(y=y&&y.$$typeof,y){case o:case l:case f:case d:return y;case a:return y;default:return b}}case e:return b}}}return ar.ContextConsumer=a,ar.ContextProvider=o,ar.Element=t,ar.ForwardRef=l,ar.Fragment=n,ar.Lazy=f,ar.Memo=d,ar.Portal=e,ar.Profiler=i,ar.StrictMode=r,ar.Suspense=c,ar.SuspenseList=u,ar.isContextConsumer=function(y){return x(y)===a},ar.isContextProvider=function(y){return x(y)===o},ar.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},ar.isForwardRef=function(y){return x(y)===l},ar.isFragment=function(y){return x(y)===n},ar.isLazy=function(y){return x(y)===f},ar.isMemo=function(y){return x(y)===d},ar.isPortal=function(y){return x(y)===e},ar.isProfiler=function(y){return x(y)===i},ar.isStrictMode=function(y){return x(y)===r},ar.isSuspense=function(y){return x(y)===c},ar.isSuspenseList=function(y){return x(y)===u},ar.isValidElementType=function(y){return typeof y=="string"||typeof y=="function"||y===n||y===i||y===r||y===c||y===u||typeof y=="object"&&y!==null&&(y.$$typeof===f||y.$$typeof===d||y.$$typeof===o||y.$$typeof===a||y.$$typeof===l||y.$$typeof===p||y.getModuleId!==void 0)},ar.typeOf=x,ar}var b6;function $Se(){return b6||(b6=1,NT.exports=HSe()),NT.exports}var VSe=$Se(),y6=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",v6=null,TT=null,LY=t=>{if(t===v6&&Array.isArray(TT))return TT;var e=[];return S.Children.forEach(t,n=>{Nr(n)||(VSe.isFragment(n)?e=e.concat(LY(n.props.children)):e.push(n))}),TT=e,v6=t,e};function pO(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>y6(i)):r=[y6(e)],LY(t).forEach(i=>{var a=df(i,"type.displayName")||df(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var gO=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,CT={},_6;function GSe(){return _6||(_6=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})(CT)),CT}var kT,w6;function WSe(){return w6||(w6=1,kT=GSe().isPlainObject),kT}var qSe=WSe();const KSe=wo(qSe);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 M6(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){XSe(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 XSe(t,e,n){return(e=YSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YSe(t){var e=ZSe(t,"string");return typeof e=="symbol"?e:e+""}function ZSe(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 E6=(t,e,n,r,i)=>{var a=n-r,o;return o="M ".concat(t,",").concat(e),o+="L ".concat(t+n,",").concat(e),o+="L ".concat(t+n-a/2,",").concat(e+i),o+="L ".concat(t+n-a/2-r,",").concat(e+i),o+="L ".concat(t,",").concat(e," Z"),o},QSe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},JSe=t=>{var e=Lr(t,QSe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,g=S.useRef(null),[p,x]=S.useState(-1),y=S.useRef(i),b=S.useRef(a),v=S.useRef(o),E=S.useRef(n),w=S.useRef(r),N=gg(t,"trapezoid-");if(S.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var R=g.current.getTotalLength();R&&x(R)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var A=On("recharts-trapezoid",l);if(!f)return S.createElement("g",null,S.createElement("path",Iw({},fa(e),{className:A,d:E6(n,r,i,a,o)})));var C=y.current,T=b.current,L=v.current,k=E.current,D=w.current,U="0px ".concat(p===-1?1:p,"px"),O="".concat(p,"px 0px"),q=iK(["strokeDasharray"],u,c);return S.createElement(pg,{animationId:N,key:N,canBegin:p>0,duration:u,easing:c,isActive:f,begin:d},R=>{var G=Wn(C,i,R),Y=Wn(T,a,R),V=Wn(L,o,R),K=Wn(k,n,R),J=Wn(D,r,R);g.current&&(y.current=G,b.current=Y,v.current=V,E.current=K,w.current=J);var X=R>0?{transition:q,strokeDasharray:O}:{strokeDasharray:U};return S.createElement("path",Iw({},fa(e),{className:A,d:E6(K,J,G,Y,V),ref:g,style:M6(M6({},X),e.style)}))})},eMe=["option","shapeType","propTransformer","activeClassName"];function tMe(t,e){if(t==null)return{};var n,r,i=nMe(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 nMe(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 A6(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 Fw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?A6(Object(n),!0).forEach(function(r){rMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):A6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rMe(t,e,n){return(e=iMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function iMe(t){var e=aMe(t,"string");return typeof e=="symbol"?e:e+""}function aMe(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 sMe(t,e){return Fw(Fw({},e),t)}function oMe(t,e){return t==="symbols"}function N6(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return S.createElement(lK,n);case"trapezoid":return S.createElement(JSe,n);case"sector":return S.createElement(hK,n);case"symbols":if(oMe(e))return S.createElement(IR,n);break;case"curve":return S.createElement(bp,n);default:return null}}function lMe(t){return S.isValidElement(t)?t.props:t}function xO(t){var{option:e,shapeType:n,propTransformer:r=sMe,activeClassName:i="recharts-active-shape"}=t,a=tMe(t,eMe),o;if(S.isValidElement(e))o=S.cloneElement(e,Fw(Fw({},a),lMe(e)));else if(typeof e=="function")o=e(a,a.index);else if(KSe(e)&&typeof e!="boolean"){var l=r(e,a);o=S.createElement(N6,{shapeType:n,elementProps:l})}else{var c=a;o=S.createElement(N6,{shapeType:n,elementProps:c})}return a.isActive?S.createElement(Or,{className:i},o):o}var bO=(t,e,n)=>{var r=br();return(i,a)=>o=>{t?.(i,a,o),r(qX({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},yO=t=>{var e=br();return(n,r)=>i=>{t?.(n,r,i),e(S_e())}},vO=(t,e,n)=>{var r=br();return(i,a)=>o=>{t?.(i,a,o),r(M_e({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function n2(t){var{tooltipEntrySettings:e}=t,n=br(),r=Pi(),i=S.useRef(null);return S.useLayoutEffect(()=>{r||(i.current===null?n(y_e(e)):i.current!==e&&n(v_e({prev:i.current,next:e})),i.current=e)},[e,n,r]),S.useLayoutEffect(()=>()=>{i.current&&(n(__e(i.current)),i.current=null)},[n]),null}function _O(t){var{legendPayload:e}=t,n=br(),r=Pi(),i=S.useRef(null);return S.useLayoutEffect(()=>{r||(i.current===null?n(eK(e)):i.current!==e&&n(tK({prev:i.current,next:e})),i.current=e)},[n,r,e]),S.useLayoutEffect(()=>()=>{i.current&&(n(nK(i.current)),i.current=null)},[n]),null}function cMe(t){var{legendPayload:e}=t,n=br(),r=Dt(Tn),i=S.useRef(null);return S.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(eK(e)):i.current!==e&&n(tK({prev:i.current,next:e})),i.current=e)},[n,r,e]),S.useLayoutEffect(()=>()=>{i.current&&(n(nK(i.current)),i.current=null)},[n]),null}var PT,uMe=()=>{var[t]=S.useState(()=>H0("uid-"));return t},dMe=(PT=Cie.useId)!==null&&PT!==void 0?PT:uMe;function IY(t,e){var n=dMe();return e||(t?"".concat(t,"-").concat(n):n)}var hMe=S.createContext(void 0),r2=t=>{var{id:e,type:n,children:r}=t,i=IY("recharts-".concat(n),e);return S.createElement(hMe.Provider,{value:i},r(i))},fMe={cartesianItems:[],polarItems:[]},FY=hs({name:"graphicalItems",initialState:fMe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Cr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=$o(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Cr()},removeCartesianGraphicalItem:{reducer(t,e){var n=$o(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=$o(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Cr()}}}),{addCartesianGraphicalItem:mMe,replaceCartesianGraphicalItem:pMe,removeCartesianGraphicalItem:gMe,addPolarGraphicalItem:xMe,removePolarGraphicalItem:bMe}=FY.actions,yMe=FY.reducer,vMe=t=>{var e=br(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?e(mMe(t)):n.current!==t&&e(pMe({prev:n.current,next:t})),n.current=t},[e,t]),S.useLayoutEffect(()=>()=>{n.current&&(e(gMe(n.current)),n.current=null)},[e]),null},wO=S.memo(vMe);function _Me(t){var e=br();return S.useLayoutEffect(()=>(e(xMe(t)),()=>{e(bMe(t))}),[e,t]),null}var wMe=["key"],SMe=["onMouseEnter","onClick","onMouseLeave"],MMe=["id"],EMe=["id"];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 $r(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){AMe(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 AMe(t,e,n){return(e=NMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function NMe(t){var e=TMe(t,"string");return typeof e=="symbol"?e:e+""}function TMe(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 Pd(){return Pd=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},Pd.apply(null,arguments)}function i2(t,e){if(t==null)return{};var n,r,i=CMe(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 CMe(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 kMe(t){var e=S.useMemo(()=>pO(t.children,sy),[t.children]),n=Dt(r=>zSe(r,t.id,e));return n==null?null:S.createElement(cMe,{legendPayload:n})}var PMe=S.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:o,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:o,dataKey:e,nameKey:n,name:Ud(l,e),hide:c,type:u,color:o,unit:""}};return S.createElement(n2,{tooltipEntrySettings:d})}),jMe=(t,e)=>t>e?"start":t<e?"end":"middle",RMe=(t,e,n)=>Ea(typeof e=="function"?e(t):e,n,n*.8),DMe=(t,e,n)=>{var{top:r,left:i,width:a,height:o}=e,l=cK(a,o),c=i+Ea(t.cx,a,a/2),u=r+Ea(t.cy,o,o/2),d=Ea(t.innerRadius,l,0),f=RMe(n,t.outerRadius,l),g=t.maxRadius||Math.sqrt(a*a+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:g}},OMe=(t,e)=>{var n=Wi(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function LMe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var IMe=(t,e)=>{if(S.isValidElement(t))return S.cloneElement(t,e);if(typeof t=="function")return t(e);var n=On("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=i2(e,wMe);return S.createElement(bp,Pd({},i,{type:"linear",className:n}))},FMe=(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=On("recharts-pie-label-text",LMe(t));return S.createElement(QM,Pd({},e,{alignmentBaseline:"middle",className:i}),r)};function UMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!e)return null;var l=Ua(n),c=uf(i),u=uf(a),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((g,p)=>{var x=(g.startAngle+g.endAngle)/2,y=hi(g.cx,g.cy,g.outerRadius+d,x),b=$r($r($r($r({},l),g),{},{stroke:"none"},c),{},{index:p,textAnchor:jMe(y.x,g.cx)},y),v=$r($r($r($r({},l),g),{},{fill:"none",stroke:g.fill},u),{},{index:p,points:[hi(g.cx,g.cy,g.outerRadius,x),y],key:"line"});return S.createElement(Na,{zIndex:Kr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(p)},S.createElement(Or,null,a&&IMe(a,v),FMe(i,b,Jn(g,o))))});return S.createElement(Or,{className:"recharts-pie-labels"},f)}function zMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?S.createElement(JM,{label:i}):S.createElement(UMe,{sectors:e,props:n,showLabels:r})}function BMe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=t,l=Dt(kd),c=Dt(sO),u=Dt(c1e),{onMouseEnter:d,onClick:f,onMouseLeave:g}=i,p=i2(i,SMe),x=bO(d,i.dataKey,o),y=yO(g),b=vO(f,i.dataKey,o);return e==null||e.length===0?null:S.createElement(S.Fragment,null,e.map((v,E)=>{if(v?.startAngle===0&&v?.endAngle===0&&e.length!==1)return null;var w=u==null||u===o,N=String(E)===l&&(c==null||i.dataKey===c)&&w,A=l?r:null,C=n&&N?n:A,T=$r($r({},v),{},{stroke:v.stroke,tabIndex:-1,[zq]:E,[Bq]:i.dataKey});return S.createElement(Or,Pd({key:"sector-".concat(v?.startAngle,"-").concat(v?.endAngle,"-").concat(v.midAngle,"-").concat(E),tabIndex:-1,className:"recharts-pie-sector"},Ib(p,v,E),{onMouseEnter:x(v,E),onMouseLeave:y(v,E),onClick:b(v,E)}),S.createElement(xO,Pd({option:a??C,index:E,shapeType:"sector",isActive:N},T)))}))}function HMe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:a}=t,{cornerRadius:o,startAngle:l,endAngle:c,dataKey:u,nameKey:d,tooltipType:f}=n,g=Math.abs(n.minAngle),p=OMe(l,c),x=Math.abs(p),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,b=r.filter(C=>Jn(C,u,0)!==0).length,v=(x>=360?b:b-1)*y,E=x-b*g-v,w=r.reduce((C,T)=>{var L=Jn(T,u,0);return C+(Lt(L)?L:0)},0),N;if(w>0){var A;N=r.map((C,T)=>{var L=Jn(C,u,0),k=Jn(C,d,T),D=DMe(n,a,C),U=(Lt(L)?L:0)/w,O,q=$r($r({},C),i&&i[T]&&i[T].props);T?O=A.endAngle+Wi(p)*y*(L!==0?1:0):O=l;var R=O+Wi(p)*((L!==0?g:0)+U*E),G=(O+R)/2,Y=(D.innerRadius+D.outerRadius)/2,V=[{name:k,value:L,payload:q,dataKey:u,type:f}],K=hi(D.cx,D.cy,Y,G);return A=$r($r($r($r({},n.presentationProps),{},{percent:U,cornerRadius:typeof o=="string"?parseFloat(o):o,name:k,tooltipPayload:V,midAngle:G,middleRadius:Y,tooltipPosition:K},q),D),{},{value:L,dataKey:u,startAngle:O,endAngle:R,payload:q,paddingAngle:Wi(p)*y}),A})}return N}function $Me(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(MSe,{value:e?i:void 0},r)}function VMe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:a,animationBegin:o,animationDuration:l,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:g}=e,p=gg(e,"recharts-pie-"),x=n.current,[y,b]=S.useState(!1),v=S.useCallback(()=>{typeof g=="function"&&g(),b(!1)},[g]),E=S.useCallback(()=>{typeof f=="function"&&f(),b(!0)},[f]);return S.createElement($Me,{showLabels:!y,sectors:i},S.createElement(pg,{animationId:p,begin:o,duration:l,isActive:a,easing:c,onAnimationStart:E,onAnimationEnd:v,key:p},w=>{var N=[],A=i&&i[0],C=A?.startAngle;return i?.forEach((T,L)=>{var k=x&&x[L],D=L>0?df(T,"paddingAngle",0):0;if(k){var U=Wn(k.endAngle-k.startAngle,T.endAngle-T.startAngle,w),O=$r($r({},T),{},{startAngle:C+D,endAngle:C+U+D});N.push(O),C=O.endAngle}else{var{endAngle:q,startAngle:R}=T,G=Wn(0,q-R,w),Y=$r($r({},T),{},{startAngle:C+D,endAngle:C+G+D});N.push(Y),C=Y.endAngle}}),n.current=N,S.createElement(Or,null,S.createElement(BMe,{sectors:N,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),S.createElement(zMe,{showLabels:!y,sectors:i,props:e}),e.children)}var GMe={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:Kr.area};function WMe(t){var{id:e}=t,n=i2(t,MMe),{hide:r,className:i,rootTabIndex:a}=t,o=S.useMemo(()=>pO(t.children,sy),[t.children]),l=Dt(d=>BSe(d,e,o)),c=S.useRef(null),u=On("recharts-pie",i);return r||l==null?(c.current=null,S.createElement(Or,{tabIndex:a,className:u})):S.createElement(Na,{zIndex:t.zIndex},S.createElement(PMe,{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(VMe,{props:$r($r({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function UY(t){var e=Lr(t,GMe),{id:n}=e,r=i2(e,EMe),i=Ua(r);return S.createElement(r2,{id:n,type:"pie"},a=>S.createElement(S.Fragment,null,S.createElement(_Me,{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(kMe,Pd({},r,{id:a})),S.createElement(WMe,Pd({},r,{id:a}))))}UY.displayName="Pie";var qMe=["points"];function C6(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 jT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?C6(Object(n),!0).forEach(function(r){KMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function KMe(t,e,n){return(e=XMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XMe(t){var e=YMe(t,"string");return typeof e=="symbol"?e:e+""}function YMe(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 Uw(){return Uw=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},Uw.apply(null,arguments)}function ZMe(t,e){if(t==null)return{};var n,r,i=QMe(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 QMe(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 JMe(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=On(r,typeof e!="boolean"?e.className:""),a=n??{},{points:o}=a,l=ZMe(a,qMe);return S.createElement(PY,Uw({},l,{className:i}))}function e2e(t,e){return t==null?!1:e?!0:t.length===1}function zY(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:l,clipPathId:c,zIndex:u=Kr.scatter}=t;if(!e2e(e,n))return null;var d=gO(n),f=Phe(n),g=e.map((x,y)=>{var b,v,E=jT(jT(jT({r:3},o),f),{},{index:y,cx:(b=x.x)!==null&&b!==void 0?b:void 0,cy:(v=x.y)!==null&&v!==void 0?v:void 0,dataKey:a,value:x.value,payload:x.payload,points:e});return S.createElement(JMe,{key:"dot-".concat(y),option:n,dotProps:E,className:i})}),p={};return l&&c!=null&&(p.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),S.createElement(Na,{zIndex:u},S.createElement(Or,Uw({className:r},p),g))}function k6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function P6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k6(Object(n),!0).forEach(function(r){t2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function t2e(t,e,n){return(e=n2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n2e(t){var e=r2e(t,"string");return typeof e=="symbol"?e:e+""}function r2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var i2e={xAxis:{},yAxis:{},zAxis:{}},BY=hs({name:"cartesianAxis",initialState:i2e,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 o=[...a,r].slice(-3);t.yAxis[n]=P6(P6({},t.yAxis[n]),{},{width:r,widthHistory:o})}}}}),{addXAxis:a2e,replaceXAxis:s2e,removeXAxis:o2e,addYAxis:l2e,replaceYAxis:c2e,removeYAxis:u2e,addZAxis:Nqe,replaceZAxis:Tqe,removeZAxis:Cqe,updateYAxisWidth:d2e}=BY.actions,h2e=BY.reducer,f2e=Qe([ki],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),m2e=Qe([f2e,tu,nu],(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)}}),a2=()=>Dt(m2e),p2e=()=>Dt(m1e);function j6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function RT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?j6(Object(n),!0).forEach(function(r){g2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):j6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function g2e(t,e,n){return(e=x2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function x2e(t){var e=b2e(t,"string");return typeof e=="symbol"?e:e+""}function b2e(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 y2e=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=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=RT(RT(RT({},l),uf(i)),FR(i)),u;return S.isValidElement(i)?u=S.cloneElement(i,c):typeof i=="function"?u=i(c):u=S.createElement(PY,c),S.createElement(Or,{className:"recharts-active-dot",clipPath:o},u)};function lP(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=Kr.activeDot}=t,l=Dt(kd),c=p2e();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Nr(u)?null:S.createElement(Na,{zIndex:o},S.createElement(y2e,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var v2e="Invariant failed";function _2e(t,e){throw new Error(v2e)}var w2e=["x","y"];function cP(){return cP=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},cP.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 Rx(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){S2e(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 S2e(t,e,n){return(e=M2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function M2e(t){var e=E2e(t,"string");return typeof e=="symbol"?e:e+""}function E2e(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 A2e(t,e){if(t==null)return{};var n,r,i=N2e(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 N2e(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 T2e(t,e){var{x:n,y:r}=t,i=A2e(t,w2e),a="".concat(n),o=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 Rx(Rx(Rx(Rx(Rx({},e),i),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:g,name:e.name,radius:e.radius})}function zw(t){return S.createElement(xO,cP({shapeType:"rectangle",propTransformer:T2e,activeClassName:"recharts-active-bar"},t))}var C2e=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Lt(e))return e;var a=Lt(r)||Nr(r);return a?e(r,i):(a||_2e(),n)}},k2e={},HY=hs({name:"errorBars",initialState:k2e,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:kqe,replaceErrorBar:Pqe,removeErrorBar:jqe}=HY.actions,P2e=HY.reducer,j2e=["children"];function R2e(t,e){if(t==null)return{};var n,r,i=D2e(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 D2e(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 O2e={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},L2e=S.createContext(O2e);function $Y(t){var{children:e}=t,n=R2e(t,j2e);return S.createElement(L2e.Provider,{value:n},e)}function s2(t,e){var n,r,i=Dt(u=>Il(u,t)),a=Dt(u=>Fl(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Bi.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Hi.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function SO(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=a2(),{needClipX:a,needClipY:o,needClip:l}=s2(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:o?u:u-f/2,width:a?d:d*2,height:o?f:f*2}))}function I2e(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&er(t.zIndex)?t.zIndex:e}var DT={exports:{}},OT={};var D6;function F2e(){if(D6)return OT;D6=1;var t=og();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,o=t.useMemo,l=t.useDebugValue;return OT.useSyncExternalStoreWithSelector=function(c,u,d,f,g){var p=i(null);if(p.current===null){var x={hasValue:!1,value:null};p.current=x}else x=p.current;p=o(function(){function b(A){if(!v){if(v=!0,E=A,A=f(A),g!==void 0&&x.hasValue){var C=x.value;if(g(C,A))return w=C}return w=A}if(C=w,n(E,A))return C;var T=f(A);return g!==void 0&&g(C,T)?(E=A,C):(E=A,w=T)}var v=!1,E,w,N=d===void 0?null:d;return[function(){return b(u())},N===null?void 0:function(){return b(N())}]},[u,d,f,g]);var y=r(c,p[0],p[1]);return a(function(){x.hasValue=!0,x.value=y},[y]),l(y),y},OT}var O6;function U2e(){return O6||(O6=1,DT.exports=F2e()),DT.exports}U2e();function z2e(t){t()}function B2e(){let t=null,e=null;return{clear(){t=null,e=null},notify(){z2e(()=>{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 L6={notify(){},get:()=>[]};function H2e(t,e){let n,r=L6,i=0,a=!1;function o(y){d();const b=r.subscribe(y);let v=!1;return()=>{v||(v=!0,b(),f())}}function l(){r.notify()}function c(){x.onStateChange&&x.onStateChange()}function u(){return a}function d(){i++,n||(n=t.subscribe(c),r=B2e())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=L6)}function g(){a||(a=!0,d())}function p(){a&&(a=!1,f())}const x={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:g,tryUnsubscribe:p,getListeners:()=>r};return x}var $2e=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",V2e=$2e(),G2e=()=>typeof navigator<"u"&&navigator.product==="ReactNative",W2e=G2e(),q2e=()=>V2e||W2e?S.useLayoutEffect:S.useEffect,K2e=q2e();function I6(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function X2e(t,e){if(I6(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])||!I6(t[n[i]],e[n[i]]))return!1;return!0}var Y2e=Symbol.for("react-redux-context"),Z2e=typeof globalThis<"u"?globalThis:{};function Q2e(){if(!S.createContext)return{};const t=Z2e[Y2e]??=new Map;let e=t.get(S.createContext);return e||(e=S.createContext(null),t.set(S.createContext,e)),e}var J2e=Q2e();function eEe(t){const{children:e,context:n,serverState:r,store:i}=t,a=S.useMemo(()=>{const c=H2e(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=S.useMemo(()=>i.getState(),[i]);K2e(()=>{const{subscription:c}=a;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),o!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[a,o]);const l=n||J2e;return S.createElement(l.Provider,{value:a},e)}var tEe=eEe,nEe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function rEe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function oy(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(nEe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!X2e(t[r],e[r]))return!1}else if(!rEe(t[r],e[r]))return!1;return!0}var iEe=["onMouseEnter","onMouseLeave","onClick"],aEe=["value","background","tooltipPosition"],sEe=["id"],oEe=["onMouseEnter","onClick","onMouseLeave"];function Qc(){return Qc=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},Qc.apply(null,arguments)}function F6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Oa(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){lEe(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 lEe(t,e,n){return(e=cEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cEe(t){var e=uEe(t,"string");return typeof e=="symbol"?e:e+""}function uEe(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){if(t==null)return{};var n,r,i=dEe(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 dEe(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 hEe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Ud(n,e),payload:t}]},fEe=S.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,hide:o,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:Ud(a,e),hide:o,type:c,color:i,unit:l}};return S.createElement(n2,{tooltipEntrySettings:u})});function mEe(t){var e=Dt(kd),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=a,u=Bw(a,iEe),d=bO(o,r),f=yO(l),g=vO(c,r);if(!i||n==null)return null;var p=uf(i);return S.createElement(Na,{zIndex:I2e(i,Kr.barBackground)},n.map((x,y)=>{var{value:b,background:v,tooltipPosition:E}=x,w=Bw(x,aEe);if(!v)return null;var N=d(x,y),A=f(x,y),C=g(x,y),T=Oa(Oa(Oa(Oa(Oa({option:i,isActive:String(y)===e},w),{},{fill:"#eee"},v),p),Ib(u,x,y)),{},{onMouseEnter:N,onMouseLeave:A,onClick:C,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return S.createElement(zw,Qc({key:"background-bar-".concat(y)},T))}))}function pEe(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(a=>{var o={x:a.x,y:a.y,width:a.width,lowerWidth:a.width,upperWidth:a.width,height:a.height};return Oa(Oa({},o),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:o,fill:a.fill})});return S.createElement(hO,{value:e?i:void 0},n)}function gEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=t,l=Dt(kd),c=Dt(sO),u=n&&String(a)===l&&(c==null||o===c),d=u?n:e;return u?S.createElement(Na,{zIndex:Kr.activeBar},S.createElement(zw,Qc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))):S.createElement(zw,Qc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))}function xEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return S.createElement(zw,Qc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function bEe(t){var e,{data:n,props:r}=t,i=(e=Ua(r))!==null&&e!==void 0?e:{},{id:a}=i,o=Bw(i,sEe),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:g}=r,p=Bw(r,oEe),x=bO(d,c),y=yO(g),b=vO(f,c);return n?S.createElement(S.Fragment,null,n.map((v,E)=>S.createElement(Or,Qc({key:"rectangle-".concat(v?.x,"-").concat(v?.y,"-").concat(v?.value,"-").concat(E),className:"recharts-bar-rectangle"},Ib(p,v,E),{onMouseEnter:x(v,E),onMouseLeave:y(v,E),onClick:b(v,E)}),u?S.createElement(gEe,{shape:l,activeBar:u,baseProps:o,entry:v,index:E,dataKey:c}):S.createElement(xEe,{shape:l,baseProps:o,entry:v,index:E,dataKey:c})))):null}function yEe(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:a,animationBegin:o,animationDuration:l,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,g=gg(e,"recharts-bar-"),[p,x]=S.useState(!1),y=!p,b=S.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),v=S.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return S.createElement(pEe,{showLabels:y,rects:r},S.createElement(pg,{animationId:g,begin:o,duration:l,isActive:a,easing:c,onAnimationEnd:b,onAnimationStart:v,key:g},E=>{var w=E===1?r:r?.map((N,A)=>{var C=f&&f[A];if(C)return Oa(Oa({},N),{},{x:Wn(C.x,N.x,E),y:Wn(C.y,N.y,E),width:Wn(C.width,N.width,E),height:Wn(C.height,N.height,E)});if(i==="horizontal"){var T=Wn(0,N.height,E),L=Wn(N.stackedBarStart,N.y,E);return Oa(Oa({},N),{},{y:L,height:T})}var k=Wn(0,N.width,E),D=Wn(N.stackedBarStart,N.x,E);return Oa(Oa({},N),{},{width:k,x:D})});return E>0&&(n.current=w??null),w==null?null:S.createElement(Or,null,S.createElement(bEe,{props:e,data:w}))}),S.createElement(JM,{label:e.label}),e.children)}function vEe(t){var e=S.useRef(null);return S.createElement(yEe,{previousRectanglesRef:e,props:t})}var VY=0,_Ee=(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 wEe extends S.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:o,needClip:l,background:c,id:u}=this.props;if(e||n==null)return null;var d=On("recharts-bar",i),f=u;return S.createElement(Or,{className:d,id:u},l&&S.createElement("defs",null,S.createElement(SO,{clipPathId:f,xAxisId:a,yAxisId:o})),S.createElement(Or,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},S.createElement(mEe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),S.createElement(vEe,this.props)))}}var SEe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:VY,xAxisId:0,yAxisId:0,zIndex:Kr.bar};function MEe(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=s2(e,n),g=Cf(),p=Pi(),x=pO(t.children,sy),y=Dt(E=>QEe(E,e,n,p,t.id,x));if(g!=="vertical"&&g!=="horizontal")return null;var b,v=y?.[0];return v==null||v.height==null||v.width==null?b=0:b=g==="vertical"?v.height/2:v.width/2,S.createElement($Y,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:_Ee,errorBarOffset:b},S.createElement(wEe,Qc({},t,{layout:g,needClip:f,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function EEe(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:o,yAxis:l,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:f,offset:g,cells:p,parentViewBox:x,dataStartIndex:y}=t,b=e==="horizontal"?l:o,v=d?b.scale.domain():null,E=Kpe({numericAxis:b}),w=b.scale(E);return f.map((N,A)=>{var C,T,L,k,D,U;d?C=$pe(d[A+y],v):(C=Jn(N,n),Array.isArray(C)||(C=[E,C]));var O=C2e(r,VY)(C[1],A);if(e==="horizontal"){var q,[R,G]=[l.scale(C[0]),l.scale(C[1])];T=tB({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:N,index:A}),L=(q=G??R)!==null&&q!==void 0?q:void 0,k=i.size;var Y=R-G;if(D=ds(Y)?0:Y,U={x:T,y:g.top,width:k,height:g.height},Math.abs(O)>0&&Math.abs(D)<Math.abs(O)){var V=Wi(D||O)*(Math.abs(O)-Math.abs(D));L-=V,D+=V}}else{var[K,J]=[o.scale(C[0]),o.scale(C[1])];if(T=K,L=tB({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:N,index:A}),k=J-K,D=i.size,U={x:g.left,y:L,width:g.width,height:D},Math.abs(O)>0&&Math.abs(k)<Math.abs(O)){var X=Wi(k||O)*(Math.abs(O)-Math.abs(k));k+=X}}if(T==null||L==null||k==null||D==null)return null;var F=Oa(Oa({},N),{},{stackedBarStart:w,x:T,y:L,width:k,height:D,value:d?C:C[1],payload:N,background:U,tooltipPosition:{x:T+k/2,y:L+D/2},parentViewBox:x},p&&p[A]&&p[A].props);return F}).filter(Boolean)}function AEe(t){var e=Lr(t,SEe),n=Pi();return S.createElement(r2,{id:e.id,type:"bar"},r=>S.createElement(S.Fragment,null,S.createElement(_O,{legendPayload:hEe(e)}),S.createElement(fEe,{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(wO,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:Fq(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),S.createElement(Na,{zIndex:e.zIndex},S.createElement(MEe,Qc({},e,{id:r})))))}var GY=S.memo(AEe,oy);GY.displayName="Bar";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 Xv(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){NEe(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 NEe(t,e,n){return(e=TEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function TEe(t){var e=CEe(t,"string");return typeof e=="symbol"?e:e+""}function CEe(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 kEe=(t,e)=>e,PEe=(t,e,n)=>n,jEe=(t,e,n,r)=>r,REe=(t,e,n,r,i)=>i,ly=Qe([Qb,REe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),DEe=Qe([ly],t=>t?.maxBarSize),OEe=(t,e,n,r,i,a)=>a,z6=(t,e,n)=>{var r=n??t;if(!Nr(r))return Ea(r,e,0)},LEe=Qe([Tn,Qb,kEe,PEe,jEe],(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")),IEe=(t,e,n,r)=>{var i=Tn(t);return i==="horizontal"?tb(t,"yAxis",n,r):tb(t,"xAxis",e,r)},FEe=(t,e,n)=>{var r=Tn(t);return r==="horizontal"?D8(t,"xAxis",e):D8(t,"yAxis",n)},UEe=(t,e,n)=>{var r={},i=t.filter(VM),a=t.filter(u=>u.stackId==null),o=i.reduce((u,d)=>(u[d.stackId]||(u[d.stackId]=[]),u[d.stackId].push(d),u),r),l=Object.entries(o).map(u=>{var[d,f]=u,g=f.map(x=>x.dataKey),p=z6(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=z6(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]},zEe=Qe([LEe,dve,FEe],UEe),BEe=(t,e,n,r,i)=>{var a,o,l=ly(t,e,n,r,i);if(l!=null){var c=Tn(t),u=lX(t),{maxBarSize:d}=l,f=Nr(d)?u:d,g,p;return c==="horizontal"?(g=Tl(t,"xAxis",e,r),p=Nl(t,"xAxis",e,r)):(g=Tl(t,"yAxis",n,r),p=Nl(t,"yAxis",n,r)),(a=(o=Nd(g,p,!0))!==null&&o!==void 0?o:f)!==null&&a!==void 0?a:0}},WY=(t,e,n,r)=>{var i=Tn(t),a,o;return i==="horizontal"?(a=Tl(t,"xAxis",e,r),o=Nl(t,"xAxis",e,r)):(a=Tl(t,"yAxis",n,r),o=Nl(t,"yAxis",n,r)),Nd(a,o)};function HEe(t,e,n,r,i){var a=r.length;if(!(a<1)){var o=Ea(t,n,0,!0),l,c=[];if(er(r[0].barSize)){var u=!1,d=n/a,f=r.reduce((v,E)=>v+(E.barSize||0),0);f+=(a-1)*o,f>=n&&(f-=(a-1)*o,o=0),f>=n&&d>0&&(u=!0,d*=.9,f=a*d);var g=(n-f)/2>>0,p={offset:g-o,size:0};l=r.reduce((v,E)=>{var w,N={stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:p.offset+p.size+o,size:u?d:(w=E.barSize)!==null&&w!==void 0?w:0}},A=[...v,N];return p=A[A.length-1].position,A},c)}else{var x=Ea(e,n,0,!0);n-2*x-(a-1)*o<=0&&(o=0);var y=(n-2*x-(a-1)*o)/a;y>1&&(y>>=0);var b=er(i)?Math.min(y,i):y;l=r.reduce((v,E,w)=>[...v,{stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:x+(y+o)*w+(y-b)/2,size:b}}],c)}return l}}var $Ee=(t,e,n,r,i,a,o)=>{var l=Nr(o)?e:o,c=HEe(n,r,i!==a?i:a,t,l);return i!==a&&c!=null&&(c=c.map(u=>Xv(Xv({},u),{},{position:Xv(Xv({},u.position),{},{offset:u.position.offset-i/2})}))),c},VEe=Qe([zEe,lX,uve,cX,BEe,WY,DEe],$Ee),GEe=(t,e,n,r)=>Tl(t,"xAxis",e,r),WEe=(t,e,n,r)=>Tl(t,"yAxis",n,r),qEe=(t,e,n,r)=>Nl(t,"xAxis",e,r),KEe=(t,e,n,r)=>Nl(t,"yAxis",n,r),XEe=Qe([VEe,ly],(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}}),YEe=(t,e)=>{var n=$M(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(o=>o.key===n)}}}},ZEe=Qe([IEe,ly],YEe),QEe=Qe([ki,XR,GEe,WEe,qEe,KEe,XEe,Tn,Kb,WY,ZEe,ly,OEe],(t,e,n,r,i,a,o,l,c,u,d,f,g)=>{var{chartData:p,dataStartIndex:x,dataEndIndex:y}=c;if(!(f==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||a==null||u==null)){var{data:b}=f,v;if(b!=null&&b.length>0?v=b:v=p?.slice(x,y+1),v!=null)return EEe({layout:l,barSettings:f,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:v,offset:t,cells:g,dataStartIndex:x})}}),qY=t=>{var{chartData:e}=t,n=br(),r=Pi();return S.useEffect(()=>r?()=>{}:(n(q8(e)),()=>{n(q8(void 0))}),[e,n,r]),null},B6={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},KY=hs({name:"brush",initialState:B6,reducers:{setBrushSettings(t,e){return e.payload==null?B6:e.payload}}}),{setBrushSettings:Rqe}=KY.actions,JEe=KY.reducer;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 Yv(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){XY(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 XY(t,e,n){return(e=eAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eAe(t){var e=tAe(t,"string");return typeof e=="symbol"?e:e+""}function tAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var nAe=(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)}},rAe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return nAe({x:e,y:n},{x:r,y:i})};class o2{static create(e){return new o2(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 o=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+o}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}}XY(o2,"EPS",1e-4);var iAe=t=>{var e=Object.keys(t).reduce((n,r)=>Yv(Yv({},n),{},{[r]:o2.create(t[r])}),{});return Yv(Yv({},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[o,l]=a;return[o,e[o].apply(l,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function aAe(t){return(t%180+180)%180}var sAe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=aAe(i),o=a*Math.PI/180,l=Math.atan(r/n),c=o>l&&o<Math.PI-l?r/Math.sin(o):n/Math.cos(o);return Math.abs(c)},oAe={dots:[],areas:[],lines:[]},YY=hs({name:"referenceElements",initialState:oAe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=$o(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=$o(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=$o(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:Dqe,removeDot:Oqe,addArea:Lqe,removeArea:Iqe,addLine:lAe,removeLine:cAe}=YY.actions,uAe=YY.reducer,ZY=S.createContext(void 0),dAe=t=>{var{children:e}=t,[n]=S.useState("".concat(H0("recharts"),"-clip")),r=a2();if(r==null)return null;var{x:i,y:a,width:o,height:l}=r;return S.createElement(ZY.Provider,{value:n},S.createElement("defs",null,S.createElement("clipPath",{id:n},S.createElement("rect",{x:i,y:a,height:l,width:o}))),e)},hAe=()=>S.useContext(ZY);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 V6(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){fAe(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 fAe(t,e,n){return(e=mAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mAe(t){var e=pAe(t,"string");return typeof e=="symbol"?e:e+""}function pAe(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 Hw(){return Hw=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},Hw.apply(null,arguments)}var gAe=(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",Hw({},e,{className:"recharts-reference-line-line"}))}return n},xAe=(t,e,n,r,i,a)=>{var{x:o,width:l}=a,c=i.y.apply(t,{position:n});if(ds(c)||e==="discard"&&!i.y.isInRange(c))return null;var u=[{x:o+l,y:c},{x:o,y:c}];return r==="left"?u.reverse():u},bAe=(t,e,n,r,i,a)=>{var{y:o,height:l}=a,c=i.x.apply(t,{position:n});if(ds(c)||e==="discard"&&!i.x.isInRange(c))return null;var u=[{x:c,y:o+l},{x:c,y:o}];return r==="top"?u.reverse():u},yAe=(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},vAe=(t,e,n,r,i,a)=>{var{x:o,y:l,segment:c,ifOverflow:u}=a,d=yo(o),f=yo(l);return f?xAe(l,u,n,i,t,e):d?bAe(o,u,n,r,t,e):c!=null&&c.length===2?yAe(c,u,n,t):null};function _Ae(t){var e=br();return S.useEffect(()=>(e(lAe(t)),()=>{e(cAe(t))})),null}function wAe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,o=Pi(),l=hAe(),c=Dt(C=>Il(C,e)),u=Dt(C=>Fl(C,n)),d=Dt(C=>Cd(C,"xAxis",e,o)),f=Dt(C=>Cd(C,"yAxis",n,o)),g=Hb();if(!l||!g||c==null||u==null||d==null||f==null)return null;var p=iAe({x:d,y:f}),x=vAe(p,g,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:y,y:b},{x:v,y:E}]=x,w=a==="hidden"?"url(#".concat(l,")"):void 0,N=V6(V6({clipPath:w},fa(t)),{},{x1:y,y1:b,x2:v,y2:E}),A=rAe({x1:y,y1:b,x2:v,y2:E});return S.createElement(Na,{zIndex:t.zIndex},S.createElement(Or,{className:On("recharts-reference-line",i)},gAe(r,N),S.createElement(AY,Hw({},A,{lowerWidth:A.width,upperWidth:A.width}),S.createElement(TY,{label:t.label}),t.children)))}var SAe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:Kr.line};function e0(t){var e=Lr(t,SAe);return S.createElement(S.Fragment,null,S.createElement(_Ae,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),S.createElement(wAe,e))}e0.displayName="ReferenceLine";function QY(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 MAe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return sAe(r,n)}function EAe(t,e,n){var r=n==="width",{x:i,y:a,width:o,height:l}=t;return e===1?{start:r?i:a,end:r?i+o:a+l}:{start:r?i+o:a+l,end:r?i:a}}function $w(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 AAe(t,e){return QY(t,e+1)}function NAe(t,e,n,r,i){for(var a=(r||[]).slice(),{start:o,end:l}=e,c=0,u=1,d=o,f=function(){var x=r?.[c];if(x===void 0)return{v:QY(r,u)};var y=c,b,v=()=>(b===void 0&&(b=n(x,y)),b),E=x.coordinate,w=c===0||$w(t,E,v,d,l);w||(c=0,d=o,u+=1),w&&(d=E+t*(v()/2+i),c+=u)},g;u<=a.length;)if(g=f(),g)return g.v;return[]}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 va(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){TAe(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 TAe(t,e,n){return(e=CAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function CAe(t){var e=kAe(t,"string");return typeof e=="symbol"?e:e+""}function kAe(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 PAe(t,e,n,r,i){for(var a=(r||[]).slice(),o=a.length,{start:l}=e,{end:c}=e,u=function(g){var p=a[g],x,y=()=>(x===void 0&&(x=n(p,g)),x);if(g===o-1){var b=t*(p.coordinate+t*y()/2-c);a[g]=p=va(va({},p),{},{tickCoord:b>0?p.coordinate-b*t:p.coordinate})}else a[g]=p=va(va({},p),{},{tickCoord:p.coordinate});if(p.tickCoord!=null){var v=$w(t,p.tickCoord,y,l,c);v&&(c=p.tickCoord-t*(y()/2+i),a[g]=va(va({},p),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return a}function jAe(t,e,n,r,i,a){var o=(r||[]).slice(),l=o.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(o[l-1]=d=va(va({},d),{},{tickCoord:g>0?d.coordinate-g*t:d.coordinate}),d.tickCoord!=null){var p=$w(t,d.tickCoord,()=>f,c,u);p&&(u=d.tickCoord-t*(f/2+i),o[l-1]=va(va({},d),{},{isShow:!0}))}}for(var x=a?l-1:l,y=function(E){var w=o[E],N,A=()=>(N===void 0&&(N=n(w,E)),N);if(E===0){var C=t*(w.coordinate-t*A()/2-c);o[E]=w=va(va({},w),{},{tickCoord:C<0?w.coordinate-C*t:w.coordinate})}else o[E]=w=va(va({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var T=$w(t,w.tickCoord,A,c,u);T&&(c=w.tickCoord+t*(A()/2+i),o[E]=va(va({},w),{},{isShow:!0}))}},b=0;b<x;b++)y(b);return o}function MO(t,e,n){var{tick:r,ticks:i,viewBox:a,minTickGap:o,orientation:l,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(Lt(c)||mg.isSsr){var g;return(g=AAe(i,Lt(c)?c:0))!==null&&g!==void 0?g:[]}var p=[],x=l==="top"||l==="bottom"?"width":"height",y=d&&x==="width"?m0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},b=(w,N)=>{var A=typeof u=="function"?u(w.value,N):w.value;return x==="width"?MAe(m0(A,{fontSize:e,letterSpacing:n}),y,f):m0(A,{fontSize:e,letterSpacing:n})[x]},v=i.length>=2?Wi(i[1].coordinate-i[0].coordinate):1,E=EAe(a,v,x);return c==="equidistantPreserveStart"?NAe(v,E,b,i,o):(c==="preserveStart"||c==="preserveStartEnd"?p=jAe(v,E,b,i,o,c==="preserveStartEnd"):p=PAe(v,E,b,i,o),p.filter(w=>w.isShow))}var RAe=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=t,o=0;if(e){Array.from(e).forEach(d=>{if(d){var f=d.getBoundingClientRect();f.width>o&&(o=f.width)}});var l=n?n.getBoundingClientRect().width:0,c=i+a,u=o+c+l+(n?r:0);return Math.round(u)}return 0},DAe=["axisLine","width","height","className","hide","ticks","axisType"];function OAe(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}function pf(){return pf=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},pf.apply(null,arguments)}function W6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ci(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?W6(Object(n),!0).forEach(function(r){IAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):W6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function IAe(t,e,n){return(e=FAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function FAe(t){var e=UAe(t,"string");return typeof e=="symbol"?e:e+""}function UAe(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 Ic={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:Kr.axis};function zAe(t){var{x:e,y:n,width:r,height:i,orientation:a,mirror:o,axisLine:l,otherSvgProps:c}=t;if(!l)return null;var u=ci(ci(ci({},c),Ua(l)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!o||a==="bottom"&&o);u=ci(ci({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!o||a==="right"&&o);u=ci(ci({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return S.createElement("line",pf({},u,{className:On("recharts-cartesian-axis-line",df(l,"className"))}))}function BAe(t,e,n,r,i,a,o,l,c){var u,d,f,g,p,x,y=l?-1:1,b=t.tickSize||o,v=Lt(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,g=n+ +!l*i,f=g-y*b,x=f-y*c,p=v;break;case"left":f=g=t.coordinate,d=e+ +!l*r,u=d-y*b,p=u-y*c,x=v;break;case"right":f=g=t.coordinate,d=e+ +l*r,u=d+y*b,p=u+y*c,x=v;break;default:u=d=t.coordinate,g=n+ +l*i,f=g+y*b,x=f+y*c,p=v;break}return{line:{x1:u,y1:f,x2:d,y2:g},tick:{x:p,y:x}}}function HAe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function $Ae(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function VAe(t){var{option:e,tickProps:n,value:r}=t,i,a=On(n.className,"recharts-cartesian-axis-tick-value");if(S.isValidElement(e))i=S.cloneElement(e,ci(ci({},n),{},{className:a}));else if(typeof e=="function")i=e(ci(ci({},n),{},{className:a}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=On(o,e?.className)),i=S.createElement(QM,pf({},n,{className:o}),r)}return i}var GAe=S.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:o,unit:l,padding:c,tickTextProps:u,orientation:d,mirror:f,x:g,y:p,width:x,height:y,tickSize:b,tickMargin:v,fontSize:E,letterSpacing:w,getTicksConfig:N,events:A,axisType:C}=t,T=MO(ci(ci({},N),{},{ticks:n}),E,w),L=HAe(d,f),k=$Ae(d,f),D=Ua(N),U=uf(r),O={};typeof i=="object"&&(O=i);var q=ci(ci({},D),{},{fill:"none"},O),R=T.map(V=>ci({entry:V},BAe(V,g,p,x,y,d,b,f,v))),G=R.map(V=>{var{entry:K,line:J}=V;return S.createElement(Or,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(K.value,"-").concat(K.coordinate,"-").concat(K.tickCoord)},i&&S.createElement("line",pf({},q,J,{className:On("recharts-cartesian-axis-tick-line",df(i,"className"))})))}),Y=R.map((V,K)=>{var{entry:J,tick:X}=V,F=ci(ci(ci(ci({textAnchor:L,verticalAnchor:k},D),{},{stroke:"none",fill:a},U),X),{},{index:K,payload:J,visibleTicksCount:T.length,tickFormatter:o,padding:c},u);return S.createElement(Or,pf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(J.value,"-").concat(J.coordinate,"-").concat(J.tickCoord)},Ib(A,J,K)),r&&S.createElement(VAe,{option:r,tickProps:F,value:"".concat(typeof o=="function"?o(J.value,K):J.value).concat(l||"")}))});return S.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(C,"-ticks")},Y.length>0&&S.createElement(Na,{zIndex:Kr.label},S.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(C,"-tick-labels"),ref:e},Y)),G.length>0&&S.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(C,"-tick-lines")},G))}),WAe=S.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:l,axisType:c}=t,u=OAe(t,DAe),[d,f]=S.useState(""),[g,p]=S.useState(""),x=S.useRef(null);S.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var b;return RAe({ticks:x.current,label:(b=t.labelRef)===null||b===void 0?void 0:b.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=S.useCallback(b=>{if(b){var v=b.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=v;var E=v[0];if(E){var w=window.getComputedStyle(E),N=w.fontSize,A=w.letterSpacing;(N!==d||A!==g)&&(f(N),p(A))}}},[d,g]);return o||r!=null&&r<=0||i!=null&&i<=0?null:S.createElement(Na,{zIndex:t.zIndex},S.createElement(Or,{className:On("recharts-cartesian-axis",a)},S.createElement(zAe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Ua(t)}),S.createElement(GAe,{ref:y,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(AY,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},S.createElement(TY,{label:t.label,labelRef:t.labelRef}),t.children)))}),EO=S.forwardRef((t,e)=>{var n=Lr(t,Ic);return S.createElement(WAe,pf({},n,{ref:e}))});EO.displayName="CartesianAxis";var qAe=["x1","y1","x2","y2","key"],KAe=["offset"],XAe=["xAxisId","yAxisId"],YAe=["xAxisId","yAxisId"];function q6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function wa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?q6(Object(n),!0).forEach(function(r){ZAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZAe(t,e,n){return(e=QAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QAe(t){var e=JAe(t,"string");return typeof e=="symbol"?e:e+""}function JAe(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 Dh(){return Dh=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},Dh.apply(null,arguments)}function Vw(t,e){if(t==null)return{};var n,r,i=eNe(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 eNe(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 tNe=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:l}=t;return S.createElement("rect",{x:r,y:i,ry:l,width:a,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function JY(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:o,x2:l,y2:c,key:u}=n,d=Vw(n,qAe),f=(i=Ua(d))!==null&&i!==void 0?i:{},{offset:g}=f,p=Vw(f,KAe);r=S.createElement("line",Dh({},p,{x1:a,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function nNe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=t,l=Vw(t,XAe),c=i.map((u,d)=>{var f=wa(wa({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return S.createElement(JY,{key:"line-".concat(d),option:r,lineItemProps:f})});return S.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function rNe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=t,l=Vw(t,YAe),c=i.map((u,d)=>{var f=wa(wa({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return S.createElement(JY,{option:r,lineItemProps:f,key:"line-".concat(d)})});return S.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function iNe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:a,height:o,horizontalPoints:l,horizontal:c=!0}=t;if(!c||!e||!e.length||l==null)return null;var u=l.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var p=!u[g+1],x=p?i+o-f:u[g+1]-f;if(x<=0)return null;var y=g%e.length;return S.createElement("rect",{key:"react-".concat(g),y:f,x:r,height:x,width:a,stroke:"none",fill:e[y],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return S.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function aNe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:o,height:l,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var p=!u[g+1],x=p?i+o-f:u[g+1]-f;if(x<=0)return null;var y=g%n.length;return S.createElement("rect",{key:"react-".concat(g),x:f,y:a,width:x,height:l,stroke:"none",fill:n[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return S.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var sNe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return Lq(MO(wa(wa(wa({},Ic),n),{},{ticks:Iq(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},oNe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return Lq(MO(wa(wa(wa({},Ic),n),{},{ticks:Iq(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},lNe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Kr.grid};function Gw(t){var e=ZR(),n=QR(),r=Wq(),i=wa(wa({},Lr(t,lNe)),{},{x:Lt(t.x)?t.x:r.left,y:Lt(t.y)?t.y:r.top,width:Lt(t.width)?t.width:r.width,height:Lt(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:g,verticalValues:p}=i,x=Pi(),y=Dt(k=>O8(k,"xAxis",a,x)),b=Dt(k=>O8(k,"yAxis",o,x));if(!El(u)||!El(d)||!Lt(l)||!Lt(c))return null;var v=i.verticalCoordinatesGenerator||sNe,E=i.horizontalCoordinatesGenerator||oNe,{horizontalPoints:w,verticalPoints:N}=i;if((!w||!w.length)&&typeof E=="function"){var A=g&&g.length,C=E({yAxis:b?wa(wa({},b),{},{ticks:A?g:b.ticks}):void 0,width:e??u,height:n??d,offset:r},A?!0:f);mw(Array.isArray(C),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof C,"]")),Array.isArray(C)&&(w=C)}if((!N||!N.length)&&typeof v=="function"){var T=p&&p.length,L=v({xAxis:y?wa(wa({},y),{},{ticks:T?p:y.ticks}):void 0,width:e??u,height:n??d,offset:r},T?!0:f);mw(Array.isArray(L),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof L,"]")),Array.isArray(L)&&(N=L)}return S.createElement(Na,{zIndex:i.zIndex},S.createElement("g",{className:"recharts-cartesian-grid"},S.createElement(tNe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),S.createElement(iNe,Dh({},i,{horizontalPoints:w})),S.createElement(aNe,Dh({},i,{verticalPoints:N})),S.createElement(nNe,Dh({},i,{offset:r,horizontalPoints:w,xAxis:y,yAxis:b})),S.createElement(rNe,Dh({},i,{offset:r,verticalPoints:N,xAxis:y,yAxis:b}))))}Gw.displayName="CartesianGrid";var eZ=(t,e,n,r)=>Tl(t,"xAxis",e,r),tZ=(t,e,n,r)=>Nl(t,"xAxis",e,r),nZ=(t,e,n,r)=>Tl(t,"yAxis",n,r),rZ=(t,e,n,r)=>Nl(t,"yAxis",n,r),cNe=Qe([Tn,eZ,nZ,tZ,rZ],(t,e,n,r,i)=>Ll(t,"xAxis")?Nd(e,r,!1):Nd(n,i,!1)),uNe=(t,e,n,r,i)=>i;function dNe(t){return t.type==="line"}var hNe=Qe([Qb,uNe],(t,e)=>t.filter(dNe).find(n=>n.id===e)),fNe=Qe([Tn,eZ,nZ,tZ,rZ,hNe,cNe,Kb],(t,e,n,r,i,a,o,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||o==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 RNe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:p})}});function iZ(t){var e=uf(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:a}=e,o=Number(i),l=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(l)||l<0)&&(l=r),{r:o,strokeWidth:l}}return{r:n,strokeWidth:r}}var mNe=["id"],pNe=["type","layout","connectNulls","needClip","shape"],gNe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function rb(){return rb=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},rb.apply(null,arguments)}function K6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function hl(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?K6(Object(n),!0).forEach(function(r){xNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function xNe(t,e,n){return(e=bNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bNe(t){var e=yNe(t,"string");return typeof e=="symbol"?e:e+""}function yNe(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 AO(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 _Ne=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Ud(n,e),payload:t}]},wNe=S.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,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:Ud(o,e),hide:l,type:u,color:r,unit:c}};return S.createElement(n2,{tooltipEntrySettings:d})}),aZ=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function SNe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var MNe=(t,e,n)=>{var r=n.reduce((f,g)=>f+g);if(!r)return aZ(e,t);for(var i=Math.floor(t/r),a=t%r,o=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,o]:[o];return[...SNe(n,i),...l,...d].map(f=>"".concat(f,"px")).join(", ")};function ENe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:o}=r,{id:l}=r,c=AO(r,mNe),u=Ua(c);return S.createElement(zY,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:o,clipPathId:e})}function ANe(t){var{showLabels:e,children:n,points:r}=t,i=S.useMemo(()=>r?.map(a=>{var o,l,c={x:(o=a.x)!==null&&o!==void 0?o:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return hl(hl({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return S.createElement(hO,{value:e?i:void 0},n)}function X6(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:a}=t,{type:o,layout:l,connectNulls:c,needClip:u,shape:d}=a,f=AO(a,pNe),g=hl(hl({},fa(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:o,layout:l,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return S.createElement(S.Fragment,null,r?.length>1&&S.createElement(xO,rb({shapeType:"curve",option:d},g,{pathRef:n})),S.createElement(ENe,{points:r,clipPathId:e,props:a}))}function NNe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function TNe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=t,{points:o,strokeDasharray:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:g,width:p,height:x,onAnimationEnd:y,onAnimationStart:b}=n,v=i.current,E=gg(o,"recharts-line-"),w=S.useRef(E),[N,A]=S.useState(!1),C=!N,T=S.useCallback(()=>{typeof y=="function"&&y(),A(!1)},[y]),L=S.useCallback(()=>{typeof b=="function"&&b(),A(!0)},[b]),k=NNe(r.current),D=S.useRef(0);w.current!==E&&(D.current=a.current,w.current=E);var U=D.current;return S.createElement(ANe,{points:o,showLabels:C},n.children,S.createElement(pg,{animationId:E,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:T,onAnimationStart:L,key:E},O=>{var q=Wn(U,k+U,O),R=Math.min(q,k),G;if(c)if(l){var Y="".concat(l).split(/[,\s]+/gim).map(J=>parseFloat(J));G=MNe(R,k,Y)}else G=aZ(k,R);else G=l==null?void 0:String(l);if(O>0&&k>0&&(i.current=o,a.current=Math.max(a.current,R)),v){var V=v.length/o.length,K=O===1?o:o.map((J,X)=>{var F=Math.floor(X*V);if(v[F]){var W=v[F];return hl(hl({},J),{},{x:Wn(W.x,J.x,O),y:Wn(W.y,J.y,O)})}return g?hl(hl({},J),{},{x:Wn(p*2,J.x,O),y:Wn(x/2,J.y,O)}):hl(hl({},J),{},{x:J.x,y:J.y})});return i.current=K,S.createElement(X6,{props:n,points:K,clipPathId:e,pathRef:r,strokeDasharray:G})}return S.createElement(X6,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:G})}),S.createElement(JM,{label:n.label}))}function CNe(t){var{clipPathId:e,props:n}=t,r=S.useRef(null),i=S.useRef(0),a=S.useRef(null);return S.createElement(TNe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var kNe=(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 PNe extends S.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:l,left:c,width:u,height:d,id:f,needClip:g,zIndex:p}=this.props;if(e)return null;var x=On("recharts-line",i),y=f,{r:b,strokeWidth:v}=iZ(n),E=gO(n),w=b*2+v,N=g?"url(#clipPath-".concat(E?"":"dots-").concat(y,")"):void 0;return S.createElement(Na,{zIndex:p},S.createElement(Or,{className:x},g&&S.createElement("defs",null,S.createElement(SO,{clipPathId:y,xAxisId:a,yAxisId:o}),!E&&S.createElement("clipPath",{id:"clipPath-dots-".concat(y)},S.createElement("rect",{x:c-w/2,y:l-w/2,width:u+w,height:d+w}))),S.createElement($Y,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:kNe,errorBarOffset:0},S.createElement(CNe,{props:this.props,clipPathId:y}))),S.createElement(lP,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:N}))}}var sZ={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:Kr.line,type:"linear"};function jNe(t){var e=Lr(t,sZ),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:f,legendType:g,xAxisId:p,yAxisId:x,id:y}=e,b=AO(e,gNe),{needClip:v}=s2(p,x),E=a2(),w=Cf(),N=Pi(),A=Dt(D=>fNe(D,p,x,N,y));if(w!=="horizontal"&&w!=="vertical"||A==null||E==null)return null;var{height:C,width:T,x:L,y:k}=E;return S.createElement(PNe,rb({},b,{id:y,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:d,hide:u,label:f,legendType:g,xAxisId:p,yAxisId:x,points:A,layout:w,height:C,width:T,left:L,top:k,needClip:v}))}function RNe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:l,displayedData:c}=t;return c.map((u,d)=>{var f=Jn(u,o);if(e==="horizontal"){var g=fw({axis:n,ticks:i,bandSize:l,entry:u,index:d}),p=Nr(f)?null:r.scale(f);return{x:g,y:p,value:f,payload:u}}var x=Nr(f)?null:n.scale(f),y=fw({axis:r,ticks:a,bandSize:l,entry:u,index:d});return x==null||y==null?null:{x,y,value:f,payload:u}}).filter(Boolean)}function DNe(t){var e=Lr(t,sZ),n=Pi();return S.createElement(r2,{id:e.id,type:"line"},r=>S.createElement(S.Fragment,null,S.createElement(_O,{legendPayload:_Ne(e)}),S.createElement(wNe,{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(wO,{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(jNe,rb({},e,{id:r}))))}var oZ=S.memo(DNe,oy);oZ.displayName="Line";var lZ=(t,e,n,r)=>Tl(t,"xAxis",e,r),cZ=(t,e,n,r)=>Nl(t,"xAxis",e,r),uZ=(t,e,n,r)=>Tl(t,"yAxis",n,r),dZ=(t,e,n,r)=>Nl(t,"yAxis",n,r),ONe=Qe([Tn,lZ,uZ,cZ,dZ],(t,e,n,r,i)=>Ll(t,"xAxis")?Nd(e,r,!1):Nd(n,i,!1)),LNe=(t,e,n,r,i)=>i,hZ=Qe([Qb,LNe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),INe=(t,e,n,r,i)=>{var a,o=hZ(t,e,n,r,i);if(o!=null){var l=Tn(t),c=Ll(l,"xAxis"),u;if(c?u=tb(t,"yAxis",n,r):u=tb(t,"xAxis",e,r),u!=null){var{stackId:d}=o,f=$M(o);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)}}}},FNe=Qe([Tn,lZ,uZ,cZ,dZ,INe,Kb,ONe,hZ,hve],(t,e,n,r,i,a,o,l,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:g}=o;if(!(c==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||l==null)){var{data:p}=c,x;if(p&&p.length>0?x=p:x=d?.slice(f,g+1),x!=null)return rTe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:x,chartBaseValue:u,bandSize:l})}}),UNe=["id"],zNe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Gh(){return Gh=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},Gh.apply(null,arguments)}function fZ(t,e){if(t==null)return{};var n,r,i=BNe(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 BNe(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 Y6(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?Y6(Object(n),!0).forEach(function(r){HNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function HNe(t,e,n){return(e=$Ne(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $Ne(t){var e=VNe(t,"string");return typeof e=="symbol"?e:e+""}function VNe(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 Ww(t,e){return t&&t!=="none"?t:e}var GNe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:o}=t;return[{inactive:o,dataKey:e,type:a,color:Ww(r,i),value:Ud(n,e),payload:t}]},WNe=S.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,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:Ud(o,e),hide:l,type:u,color:Ww(r,a),unit:c}};return S.createElement(n2,{tooltipEntrySettings:d})});function qNe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:o}=r,l=Ua(r);return S.createElement(zY,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function KNe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(a=>{var o,l,c={x:(o=a.x)!==null&&o!==void 0?o:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return dp(dp({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return S.createElement(hO,{value:e?i:void 0},n)}function Z6(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:a}=t,{layout:o,type:l,stroke:c,connectNulls:u,isRange:d}=a,{id:f}=a,g=fZ(a,UNe),p=Ua(g),x=fa(g);return S.createElement(S.Fragment,null,e?.length>1&&S.createElement(Or,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},S.createElement(bp,Gh({},x,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&S.createElement(bp,Gh({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&S.createElement(bp,Gh({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),S.createElement(qNe,{points:e,props:g,clipPathId:i}))}function XNe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,o=r[r.length-1].y;if(!er(a)||!er(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.x||0));return Lt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Lt(c)?S.createElement("rect",{x:0,y:a<o?a:a-l,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(l)}):null}function YNe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,o=r[r.length-1].x;if(!er(a)||!er(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.y||0));return Lt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Lt(c)?S.createElement("rect",{x:a<o?a:a-l,y:0,width:l,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function ZNe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?S.createElement(XNe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):S.createElement(YNe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function QNe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=t,{points:o,baseLine:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:g,onAnimationEnd:p}=r,x=S.useMemo(()=>({points:o,baseLine:l}),[o,l]),y=gg(x,"recharts-area-"),b=kge(),[v,E]=S.useState(!1),w=!v,N=S.useCallback(()=>{typeof p=="function"&&p(),E(!1)},[p]),A=S.useCallback(()=>{typeof g=="function"&&g(),E(!0)},[g]);if(b==null)return null;var C=i.current,T=a.current;return S.createElement(KNe,{showLabels:w,points:o},r.children,S.createElement(pg,{animationId:y,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:N,onAnimationStart:A,key:y},L=>{if(C){var k=C.length/o.length,D=L===1?o:o.map((O,q)=>{var R=Math.floor(q*k);if(C[R]){var G=C[R];return dp(dp({},O),{},{x:Wn(G.x,O.x,L),y:Wn(G.y,O.y,L)})}return O}),U;return Lt(l)?U=Wn(T,l,L):Nr(l)||ds(l)?U=Wn(T,0,L):U=l.map((O,q)=>{var R=Math.floor(q*k);if(Array.isArray(T)&&T[R]){var G=T[R];return dp(dp({},O),{},{x:Wn(G.x,O.x,L),y:Wn(G.y,O.y,L)})}return O}),L>0&&(i.current=D,a.current=U),S.createElement(Z6,{points:D,baseLine:U,needClip:e,clipPathId:n,props:r})}return L>0&&(i.current=o,a.current=l),S.createElement(Or,null,c&&S.createElement("defs",null,S.createElement("clipPath",{id:"animationClipPath-".concat(n)},S.createElement(ZNe,{alpha:L,points:o,baseLine:l,layout:b,strokeWidth:r.strokeWidth}))),S.createElement(Or,{clipPath:"url(#animationClipPath-".concat(n,")")},S.createElement(Z6,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),S.createElement(JM,{label:r.label}))}function JNe(t){var{needClip:e,clipPathId:n,props:r}=t,i=S.useRef(null),a=S.useRef();return S.createElement(QNe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class eTe extends S.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:o,needClip:l,xAxisId:c,yAxisId:u,width:d,height:f,id:g,baseLine:p,zIndex:x}=this.props;if(e)return null;var y=On("recharts-area",i),b=g,{r:v,strokeWidth:E}=iZ(n),w=gO(n),N=v*2+E,A=l?"url(#clipPath-".concat(w?"":"dots-").concat(b,")"):void 0;return S.createElement(Na,{zIndex:x},S.createElement(Or,{className:y},l&&S.createElement("defs",null,S.createElement(SO,{clipPathId:b,xAxisId:c,yAxisId:u}),!w&&S.createElement("clipPath",{id:"clipPath-dots-".concat(b)},S.createElement("rect",{x:o-N/2,y:a-N/2,width:d+N,height:f+N}))),S.createElement(JNe,{needClip:l,clipPathId:b,props:this.props})),S.createElement(lP,{points:r,mainColor:Ww(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:A}),this.props.isRange&&Array.isArray(p)&&S.createElement(lP,{points:p,mainColor:Ww(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:A}))}}var mZ={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:Kr.area};function tTe(t){var e,n=Lr(t,mZ),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:g,legendType:p,stroke:x,xAxisId:y,yAxisId:b}=n,v=fZ(n,zNe),E=Cf(),w=cY(),{needClip:N}=s2(y,b),A=Pi(),{points:C,isRange:T,baseLine:L}=(e=Dt(R=>FNe(R,y,b,A,t.id)))!==null&&e!==void 0?e:{},k=a2();if(E!=="horizontal"&&E!=="vertical"||k==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:D,width:U,x:O,y:q}=k;return!C||!C.length?null:S.createElement(eTe,Gh({},v,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,baseLine:L,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:D,hide:f,layout:E,isAnimationActive:g==="auto"?!mg.isSsr:g,isRange:T,legendType:p,needClip:N,points:C,stroke:x,width:U,left:O,top:q,xAxisId:y,yAxisId:b}))}var nTe=(t,e,n,r,i)=>{var a=n??e;if(Lt(a))return a;var o=t==="horizontal"?i:r,l=o.scale.domain();if(o.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 rTe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:o,xAxis:l,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:g,bandSize:p}=t,x=i&&i.length,y=nTe(a,o,n,l,c),b=a==="horizontal",v=!1,E=u.map((N,A)=>{var C;x?C=i[d+A]:(C=Jn(N,r),Array.isArray(C)?v=!0:C=[y,C]);var T=C[1]==null||x&&!e&&Jn(N,r)==null;return b?{x:fw({axis:l,ticks:f,bandSize:p,entry:N,index:A}),y:T?null:c.scale(C[1]),value:C,payload:N}:{x:T?null:l.scale(C[1]),y:fw({axis:c,ticks:g,bandSize:p,entry:N,index:A}),value:C,payload:N}}),w;return x||v?w=E.map(N=>{var A=Array.isArray(N.value)?N.value[0]:null;return b?{x:N.x,y:A!=null&&N.y!=null?c.scale(A):null,payload:N.payload}:{x:A!=null?l.scale(A):null,y:N.y,payload:N.payload}}):w=b?c.scale(y):l.scale(y),{points:E,baseLine:w,isRange:v}}function iTe(t){var e=Lr(t,mZ),n=Pi();return S.createElement(r2,{id:e.id,type:"area"},r=>S.createElement(S.Fragment,null,S.createElement(_O,{legendPayload:GNe(e)}),S.createElement(WNe,{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(wO,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:Fq(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),S.createElement(tTe,Gh({},e,{id:r}))))}var pZ=S.memo(iTe,oy);pZ.displayName="Area";var aTe=["domain","range"],sTe=["domain","range"];function Q6(t,e){if(t==null)return{};var n,r,i=oTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function oTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function J6(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 gZ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=Q6(t,aTe),{domain:a,range:o}=e,l=Q6(e,sTe);return!J6(n,a)||!J6(r,o)?!1:oy(i,l)}var lTe=["dangerouslySetInnerHTML","ticks"],cTe=["id"];function uP(){return uP=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},uP.apply(null,arguments)}function eH(t,e){if(t==null)return{};var n,r,i=uTe(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 uTe(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 dTe(t){var e=br(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?e(a2e(t)):n.current!==t&&e(s2e({prev:n.current,next:t})),n.current=t},[t,e]),S.useLayoutEffect(()=>()=>{n.current&&(e(o2e(n.current)),n.current=null)},[e]),null}var hTe=t=>{var{xAxisId:e,className:n}=t,r=Dt(XR),i=Pi(),a="xAxis",o=Dt(b=>Cd(b,a,e,i)),l=Dt(b=>BX(b,a,e,i)),c=Dt(b=>IX(b,e)),u=Dt(b=>c_e(b,e)),d=Dt(b=>bX(b,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:g}=t,p=eH(t,lTe),{id:x}=d,y=eH(d,cTe);return S.createElement(EO,uP({},p,y,{scale:o,x:u.x,y:u.y,width:c.width,height:c.height,className:On("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:l,axisType:a}))},fTe={allowDataOverflow:Bi.allowDataOverflow,allowDecimals:Bi.allowDecimals,allowDuplicatedCategory:Bi.allowDuplicatedCategory,angle:Bi.angle,axisLine:Ic.axisLine,height:Bi.height,hide:!1,includeHidden:Bi.includeHidden,interval:Bi.interval,minTickGap:Bi.minTickGap,mirror:Bi.mirror,orientation:Bi.orientation,padding:Bi.padding,reversed:Bi.reversed,scale:Bi.scale,tick:Bi.tick,tickCount:Bi.tickCount,tickLine:Ic.tickLine,tickSize:Ic.tickSize,type:Bi.type,xAxisId:0},mTe=t=>{var e=Lr(t,fTe);return S.createElement(S.Fragment,null,S.createElement(dTe,{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(hTe,e))},qw=S.memo(mTe,gZ);qw.displayName="XAxis";var pTe=["dangerouslySetInnerHTML","ticks"],gTe=["id"];function dP(){return dP=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},dP.apply(null,arguments)}function tH(t,e){if(t==null)return{};var n,r,i=xTe(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 xTe(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 bTe(t){var e=br(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?e(l2e(t)):n.current!==t&&e(c2e({prev:n.current,next:t})),n.current=t},[t,e]),S.useLayoutEffect(()=>()=>{n.current&&(e(u2e(n.current)),n.current=null)},[e]),null}var yTe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=S.useRef(null),o=S.useRef(null),l=Dt(XR),c=Pi(),u=br(),d="yAxis",f=Dt(A=>Cd(A,d,e,c)),g=Dt(A=>FX(A,e)),p=Dt(A=>d_e(A,e)),x=Dt(A=>BX(A,d,e,c)),y=Dt(A=>yX(A,e));if(S.useLayoutEffect(()=>{if(!(r!=="auto"||!g||dO(i)||S.isValidElement(i)||y==null)){var A=a.current;if(A){var C=A.getCalculatedWidth();Math.round(g.width)!==Math.round(C)&&u(d2e({id:e,width:C}))}}},[x,g,u,i,e,r,y]),g==null||p==null||y==null)return null;var{dangerouslySetInnerHTML:b,ticks:v}=t,E=tH(t,pTe),{id:w}=y,N=tH(y,gTe);return S.createElement(EO,dP({},E,N,{ref:a,labelRef:o,scale:f,x:p.x,y:p.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:On("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:x,axisType:d}))},vTe={allowDataOverflow:Hi.allowDataOverflow,allowDecimals:Hi.allowDecimals,allowDuplicatedCategory:Hi.allowDuplicatedCategory,angle:Hi.angle,axisLine:Ic.axisLine,hide:!1,includeHidden:Hi.includeHidden,interval:Hi.interval,minTickGap:Hi.minTickGap,mirror:Hi.mirror,orientation:Hi.orientation,padding:Hi.padding,reversed:Hi.reversed,scale:Hi.scale,tick:Hi.tick,tickCount:Hi.tickCount,tickLine:Ic.tickLine,tickSize:Ic.tickSize,type:Hi.type,width:Hi.width,yAxisId:0},_Te=t=>{var e=Lr(t,vTe);return S.createElement(S.Fragment,null,S.createElement(bTe,{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(yTe,e))},Kw=S.memo(_Te,gZ);Kw.displayName="YAxis";var wTe=(t,e)=>e,NO=Qe([wTe,Tn,gX,Ri,rY,iu,A1e,ki],R1e),TO=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)}},xZ=vo("mouseClick"),bZ=zb();bZ.startListening({actionCreator:xZ,effect:(t,e)=>{var n=t.payload,r=NO(e.getState(),TO(n));r?.activeIndex!=null&&e.dispatch(E_e({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var hP=vo("mouseMove"),yZ=zb(),Zv=null;yZ.startListening({actionCreator:hP,effect:(t,e)=>{var n=t.payload;Zv!==null&&cancelAnimationFrame(Zv);var r=TO(n);Zv=requestAnimationFrame(()=>{var i=e.getState(),a=eO(i,i.tooltip.settings.shared);if(a==="axis"){var o=NO(i,r);o?.activeIndex!=null?e.dispatch(XX({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(KX())}Zv=null})}});var nH={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},vZ=hs({name:"rootProps",initialState:nH,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:nH.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}}}),STe=vZ.reducer,{updateOptions:MTe}=vZ.actions,_Z=hs({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:ETe}=_Z.actions,ATe=_Z.reducer,wZ=vo("keyDown"),SZ=vo("focus"),CO=zb();CO.startListening({actionCreator:wZ,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 o=tO(i,Mg(n),ey(n),iy(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=iu(n);if(a==="Enter"){var u=Ow(n,"axis","hover",String(i.index));e.dispatch(nP({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=p_e(n),f=d==="left-to-right"?1:-1,g=a==="ArrowRight"?1:-1,p=l+g*f;if(!(c==null||p>=c.length||p<0)){var x=Ow(n,"axis","hover",String(p));e.dispatch(nP({active:!0,activeIndex:p.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});CO.startListening({actionCreator:SZ,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",o=Ow(n,"axis","hover",String(a));e.dispatch(nP({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:o}))}}}});var Qs=vo("externalEvent"),MZ=zb(),LT=new Map;MZ.startListening({actionCreator:Qs,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=LT.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:d1e(l),activeDataKey:sO(l),activeIndex:kd(l),activeLabel:sY(l),activeTooltipIndex:kd(l),isTooltipActive:h1e(l)};n(c,r)}finally{LT.delete(i)}});LT.set(i,o)}}});var NTe=Qe([Sg],t=>t.tooltipItemPayloads),TTe=Qe([NTe,ny,(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 o=e(a,n);return o}}}),EZ=vo("touchMove"),AZ=zb();AZ.startListening({actionCreator:EZ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=eO(r,r.tooltip.settings.shared);if(i==="axis"){var a=NO(r,TO({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(XX({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate}))}else if(i==="item"){var o,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(zq),d=(o=c.getAttribute(Bq))!==null&&o!==void 0?o:void 0,f=TTe(e.getState(),u,d);e.dispatch(qX({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var CTe=oq({brush:JEe,cartesianAxis:h2e,chartData:uwe,errorBars:P2e,graphicalItems:yMe,layout:Ipe,legend:Gge,options:awe,polarAxis:DSe,polarOptions:ATe,referenceElements:uAe,rootProps:STe,tooltip:A_e,zIndex:q1e}),kTe=function(e){return lpe({reducer:CTe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([bZ.middleware,yZ.middleware,CO.middleware,MZ.middleware,AZ.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(wq({type:"raf"}))},devTools:mg.devToolsEnabled})};function NZ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=Pi(),a=S.useRef(null);if(i)return n;a.current==null&&(a.current=kTe(e));var o=zR;return S.createElement(tEe,{context:o,store:a.current},n)}function PTe(t){var{layout:e,margin:n}=t,r=br(),i=Pi();return S.useEffect(()=>{i||(r(Dpe(e)),r(Rpe(n)))},[r,i,e,n]),null}var TZ=S.memo(PTe,oy);function CZ(t){var e=br();return S.useEffect(()=>{e(MTe(t))},[e,t]),null}function rH(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=IY("".concat(r).concat(e)),a=br();return S.useLayoutEffect(()=>(a(G1e({zIndex:e,elementId:i,isPanorama:n})),()=>{a(W1e({zIndex:e,isPanorama:n}))}),[a,e,i,n]),S.createElement("g",{tabIndex:-1,id:i})}function iH(t){var{children:e,isPanorama:n}=t,r=Dt(O1e);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),a=r.filter(o=>o>0);return S.createElement(S.Fragment,null,i.map(o=>S.createElement(rH,{key:o,zIndex:o,isPanorama:n})),e,a.map(o=>S.createElement(rH,{key:o,zIndex:o,isPanorama:n})))}var jTe=["children"];function RTe(t,e){if(t==null)return{};var n,r,i=DTe(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 DTe(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 Xw(){return Xw=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},Xw.apply(null,arguments)}var OTe={width:"100%",height:"100%",display:"block"},LTe=S.forwardRef((t,e)=>{var n=ZR(),r=QR(),i=rK();if(!El(n)||!El(r))return null;var{children:a,otherAttributes:o,title:l,desc:c}=t,u,d;return o!=null&&(typeof o.tabIndex=="number"?u=o.tabIndex:u=i?0:void 0,typeof o.role=="string"?d=o.role:d=i?"application":void 0),S.createElement(kR,Xw({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:OTe,ref:e}),a)}),ITe=t=>{var{children:e}=t,n=Dt(kM);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return S.createElement(kR,{width:r,height:i,x:o,y:a},e)},aH=S.forwardRef((t,e)=>{var{children:n}=t,r=RTe(t,jTe),i=Pi();return i?S.createElement(ITe,null,S.createElement(iH,{isPanorama:!0},n)):S.createElement(LTe,Xw({ref:e},r),S.createElement(iH,{isPanorama:!1},n))});function FTe(){var t=br(),[e,n]=S.useState(null),r=Dt(ege);return S.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;er(a)&&a!==r&&t(Lpe(a))}},[e,t,r]),n}function sH(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 UTe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?sH(Object(n),!0).forEach(function(r){zTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zTe(t,e,n){return(e=BTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function BTe(t){var e=HTe(t,"string");return typeof e=="symbol"?e:e+""}function HTe(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 gf(){return gf=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},gf.apply(null,arguments)}var $Te=()=>(ywe(),null);function Yw(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var VTe=S.forwardRef((t,e)=>{var n,r,i=S.useRef(null),[a,o]=S.useState({containerWidth:Yw((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:Yw((r=t.style)===null||r===void 0?void 0:r.height)}),l=S.useCallback((u,d)=>{o(f=>{var g=Math.round(u),p=Math.round(d);return f.containerWidth===g&&f.containerHeight===p?f:{containerWidth:g,containerHeight:p}})},[]),c=S.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();l(d,f);var g=x=>{var{width:y,height:b}=x[0].contentRect;l(y,b)},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(PM,{width:a.containerWidth,height:a.containerHeight}),S.createElement("div",gf({ref:c},t)))}),GTe=S.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=S.useState({containerWidth:Yw(n),containerHeight:Yw(r)}),o=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();o(u,d)}},[e,o]);return S.createElement(S.Fragment,null,S.createElement(PM,{width:i.containerWidth,height:i.containerHeight}),S.createElement("div",gf({ref:l},t)))}),WTe=S.forwardRef((t,e)=>{var{width:n,height:r}=t;return S.createElement(S.Fragment,null,S.createElement(PM,{width:n,height:r}),S.createElement("div",gf({ref:e},t)))}),qTe=S.forwardRef((t,e)=>{var{width:n,height:r}=t;return Wc(n)||Wc(r)?S.createElement(GTe,gf({},t,{ref:e})):S.createElement(WTe,gf({},t,{ref:e}))});function KTe(t){return t===!0?VTe:qTe}var XTe=S.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:g,onTouchEnd:p,onTouchMove:x,onTouchStart:y,style:b,width:v,responsive:E,dispatchTouchEvents:w=!0}=t,N=S.useRef(null),A=br(),[C,T]=S.useState(null),[L,k]=S.useState(null),D=FTe(),U=YR(),O=U?.width>0?U.width:v,q=U?.height>0?U.height:i,R=S.useCallback(he=>{D(he),typeof e=="function"&&e(he),T(he),k(he),he!=null&&(N.current=he)},[D,e,T,k]),G=S.useCallback(he=>{A(xZ(he)),A(Qs({handler:a,reactEvent:he}))},[A,a]),Y=S.useCallback(he=>{A(hP(he)),A(Qs({handler:u,reactEvent:he}))},[A,u]),V=S.useCallback(he=>{A(KX()),A(Qs({handler:d,reactEvent:he}))},[A,d]),K=S.useCallback(he=>{A(hP(he)),A(Qs({handler:f,reactEvent:he}))},[A,f]),J=S.useCallback(()=>{A(SZ())},[A]),X=S.useCallback(he=>{A(wZ(he.key))},[A]),F=S.useCallback(he=>{A(Qs({handler:o,reactEvent:he}))},[A,o]),W=S.useCallback(he=>{A(Qs({handler:l,reactEvent:he}))},[A,l]),ee=S.useCallback(he=>{A(Qs({handler:c,reactEvent:he}))},[A,c]),ie=S.useCallback(he=>{A(Qs({handler:g,reactEvent:he}))},[A,g]),ae=S.useCallback(he=>{A(Qs({handler:y,reactEvent:he}))},[A,y]),de=S.useCallback(he=>{w&&A(EZ(he)),A(Qs({handler:x,reactEvent:he}))},[A,w,x]),ue=S.useCallback(he=>{A(Qs({handler:p,reactEvent:he}))},[A,p]),le=KTe(E);return S.createElement(mY.Provider,{value:C},S.createElement(wW.Provider,{value:L},S.createElement(le,{width:O??b?.width,height:q??b?.height,className:On("recharts-wrapper",r),style:UTe({position:"relative",cursor:"default",width:O,height:q},b),onClick:G,onContextMenu:F,onDoubleClick:W,onFocus:J,onKeyDown:X,onMouseDown:ee,onMouseEnter:Y,onMouseLeave:V,onMouseMove:K,onMouseUp:ie,onTouchEnd:ue,onTouchMove:de,onTouchStart:ae,ref:R},S.createElement($Te,null),n)))}),YTe=["width","height","responsive","children","className","style","compact","title","desc"];function ZTe(t,e){if(t==null)return{};var n,r,i=QTe(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 QTe(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 kZ=S.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:o,style:l,compact:c,title:u,desc:d}=t,f=ZTe(t,YTe),g=Ua(f);return c?S.createElement(S.Fragment,null,S.createElement(PM,{width:n,height:r}),S.createElement(aH,{otherAttributes:g,title:u,desc:d},a)):S.createElement(XTe,{className:o,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(aH,{otherAttributes:g,title:u,desc:d,ref:e},S.createElement(dAe,null,a)))});function fP(){return fP=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},fP.apply(null,arguments)}var JTe={top:5,right:5,bottom:5,left:5},eCe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:JTe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},kO=S.forwardRef(function(e,n){var r,i=Lr(e.categoricalChartProps,eCe),{chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return S.createElement(NZ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},S.createElement(qY,{chartData:u.data}),S.createElement(TZ,{layout:i.layout,margin:i.margin}),S.createElement(CZ,{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(kZ,fP({},i,{ref:n})))}),tCe=["axis"],nCe=S.forwardRef((t,e)=>S.createElement(kO,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:tCe,tooltipPayloadSearcher:ZM,categoricalChartProps:t,ref:e})),rCe=["axis","item"],iCe=S.forwardRef((t,e)=>S.createElement(kO,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:rCe,tooltipPayloadSearcher:ZM,categoricalChartProps:t,ref:e}));function aCe(t){var e=br();return S.useEffect(()=>{e(ETe(t))},[e,t]),null}var sCe=["layout"];function mP(){return mP=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},mP.apply(null,arguments)}function oCe(t,e){if(t==null)return{};var n,r,i=lCe(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 lCe(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 cCe={top:5,right:5,bottom:5,left:5},PZ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:cCe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},uCe=S.forwardRef(function(e,n){var r,i=Lr(e.categoricalChartProps,PZ),{layout:a}=i,o=oCe(i,sCe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return S.createElement(NZ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},S.createElement(qY,{chartData:i.data}),S.createElement(TZ,{layout:a,margin:i.margin}),S.createElement(CZ,{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(aCe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),S.createElement(kZ,mP({},o,{ref:n})))});function oH(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 lH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?oH(Object(n),!0).forEach(function(r){dCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):oH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dCe(t,e,n){return(e=hCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hCe(t){var e=fCe(t,"string");return typeof e=="symbol"?e:e+""}function fCe(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 mCe=["item"],pCe=lH(lH({},PZ),{},{layout:"centric",startAngle:0,endAngle:360}),gCe=S.forwardRef((t,e)=>{var n=Lr(t,pCe);return S.createElement(uCe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:mCe,tooltipPayloadSearcher:ZM,categoricalChartProps:n,ref:e})}),xCe=["axis"],bCe=S.forwardRef((t,e)=>S.createElement(kO,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:xCe,tooltipPayloadSearcher:ZM,categoricalChartProps:t,ref:e}));const cH=[{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 yCe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o="humidity",thresholds:l}){const{t:c}=lg(),{mode:u}=fg(),[d,f]=S.useState("24h"),[g,p]=S.useState(o),x=u==="dark",{data:y}=ft({queryKey:["settings"],queryFn:ye.getSettings}),b=y?.time_format||"system";S.useEffect(()=>{if(!t)return;const ie=ae=>{ae.key==="Escape"&&e()};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[t,e]);const v=cH.find(ie=>ie.value===d)?.hours||24,{data:E,isLoading:w,error:N}=ft({queryKey:["ams-history",n,i,v],queryFn:()=>ye.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const A=E?.data.map(ie=>{const ae=ui(ie.recorded_at)||new Date,de={hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}};return{time:ae.getTime(),humidity:ie.humidity,temperature:ie.temperature,timeLabel:ae.toLocaleTimeString([],f0(de,b))}})||[],C=l?.humidityGood||40,T=l?.humidityFair||60,L=l?.tempGood||30,k=l?.tempFair||35,D=A[A.length-1],U=D?.humidity,O=D?.temperature,q=ie=>{const ae=ie.filter(Me=>Me!=null);if(ae.length<4)return"stable";const de=ae.slice(0,Math.floor(ae.length/4)),ue=ae.slice(-Math.floor(ae.length/4)),le=de.reduce((Me,re)=>Me+re,0)/de.length,pe=ue.reduce((Me,re)=>Me+re,0)/ue.length-le;return Math.abs(pe)<2?"stable":pe>0?"up":"down"},R=q(A.map(ie=>ie.humidity)),G=q(A.map(ie=>ie.temperature)),Y=({trend:ie})=>ie==="up"?s.jsx(uW,{className:"w-4 h-4 text-red-400"}):ie==="down"?s.jsx(cW,{className:"w-4 h-4 text-green-400"}):s.jsx(c3,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),V=ie=>ie==null?"#9ca3af":ie<=C?"#22a352":ie<=T?"#d4a017":"#c62828",K=ie=>ie==null?"#9ca3af":ie<=L?"#22a352":ie<=k?"#d4a017":"#c62828",J=x?"#2d2d2d":"#ffffff",X=x?"#1d1d1d":"#f3f4f6",F=x?"#3d3d3d":"#e5e7eb",W=x?"#ffffff":"#111827",ee=x?"#9ca3af":"#4b5563";return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:J},onClick:ie=>ie.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:F},children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold",style:{color:W},children:[a," ",c("common.history","History")]}),s.jsx("p",{className:"text-sm",style:{color:ee},children:r})]}),s.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:ee},children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:X},children:[s.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:ee}:void 0,children:[s.jsx(xR,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),s.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:ee}:void 0,children:[s.jsx(fM,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),s.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:X},children:cH.map(ie=>s.jsx("button",{onClick:()=>f(ie.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===ie.value?"bg-bambu-green text-white":""}`,style:d!==ie.value?{color:ee}:void 0,children:ie.label},ie.value))})]}),s.jsx("div",{className:"grid grid-cols-4 gap-4",children:g==="humidity"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:X},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.current","Current")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-2xl font-bold",style:{color:V(U)},children:U!=null?`${U}%`:"—"}),s.jsx(Y,{trend:R})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:X},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:W},children:E?.avg_humidity!=null?`${E.avg_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:X},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-green-500",children:E?.min_humidity!=null?`${E.min_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:X},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:E?.max_humidity!=null?`${E.max_humidity}%`:"—"})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:X},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.current","Current")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-2xl font-bold",style:{color:K(O)},children:O!=null?`${O}°C`:"—"}),s.jsx(Y,{trend:G})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:X},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:W},children:E?.avg_temperature!=null?`${E.avg_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:X},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-blue-500",children:E?.min_temperature!=null?`${E.min_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:X},children:[s.jsx("p",{className:"text-xs",style:{color:ee},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:E?.max_temperature!=null?`${E.max_temperature}°C`:"—"})]})]})}),s.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:X},children:w?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ee},children:c("common.loading","Loading...")}):N?s.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):A.length===0?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ee},children:c("common.noData","No data available for this time range")}):s.jsx(S1,{width:"100%",height:300,children:s.jsxs(nCe,{data:A,children:[s.jsx(Gw,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),s.jsx(qw,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:ie=>{const ae=new Date(ie);return v>24?ae.toLocaleDateString([],{day:"numeric",month:"short"}):ae.toLocaleTimeString([],f0({hour:"2-digit",minute:"2-digit"},b))},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),s.jsx(Kw,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:g==="humidity"?[0,100]:["auto","auto"],tickFormatter:ie=>g==="humidity"?`${ie}%`:`${ie}°C`}),s.jsx(E1,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:ie=>new Date(ie).toLocaleString(void 0,f0({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},b)),formatter:ie=>[g==="humidity"?`${ie}%`:`${ie}°C`,g==="humidity"?"Humidity":"Temperature"]}),s.jsx(tD,{}),g==="humidity"?s.jsxs(s.Fragment,{children:[s.jsx(e0,{y:C,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(e0,{y:T,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):s.jsxs(s.Fragment,{children:[s.jsx(e0,{y:L,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(e0,{y:k,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),s.jsx(oZ,{type:"monotone",dataKey:g,name:g==="humidity"?"Humidity":"Temperature",stroke:g==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),s.jsx("div",{className:"text-xs text-center",style:{color:ee},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function IT({data:t,children:e,disabled:n,className:r="",spoolman:i}){const[a,o]=S.useState(!1),[l,c]=S.useState("top"),[u,d]=S.useState(!1),f=S.useRef(null),g=S.useRef(null),p=S.useRef(null),x=()=>{const A=t.trayUuid;A&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(A).then(()=>{d(!0),setTimeout(()=>d(!1),2e3)}).catch(()=>{y(A)}):y(A))},y=A=>{const C=document.createElement("textarea");C.value=A,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 A=f.current.getBoundingClientRect(),C=g.current.offsetHeight,T=A.top,L=window.innerHeight-A.bottom;T<C+12&&L>T?c("bottom"):c("top")}},[a]);const b=()=>{n||(p.current&&clearTimeout(p.current),p.current=setTimeout(()=>o(!0),80))},v=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>o(!1),100)};S.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);const E=A=>A<=15?"#ef4444":A<=30?"#f97316":A<=50?"#eab308":"#22c55e",w=A=>{if(!A)return!1;const C=A.replace("#",""),T=parseInt(C.slice(0,2),16),L=parseInt(C.slice(2,4),16),k=parseInt(C.slice(4,6),16);return(.299*T+.587*L+.114*k)/255>.6},N=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return s.jsxs("div",{ref:f,className:`relative ${r}`,onMouseEnter:b,onMouseLeave:v,children:[e,a&&s.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:[s.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:[s.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:N||"#3d3d3d"},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),s.jsx("div",{className:`
  54. absolute inset-0 flex items-center justify-center
  55. font-semibold text-sm tracking-wide
  56. ${w(N)?"text-black/80":"text-white/90"}
  57. `,children:t.colorName}),s.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"})]}),s.jsxs("div",{className:"p-3 space-y-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Profile"}),s.jsx("span",{className:"text-xs text-white font-semibold truncate max-w-[120px]",children:t.profile})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"K Factor"}),s.jsx("span",{className:"text-xs text-bambu-green font-mono font-bold",children:t.kFactor})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium flex items-center gap-1",children:[s.jsx(xR,{className:"w-3 h-3"}),"Fill"]}),s.jsx("span",{className:"text-xs text-white font-semibold",children:t.fillLevel!==null?`${t.fillLevel}%`:"—"})]}),s.jsx("div",{className:"h-1.5 bg-black/40 rounded-full overflow-hidden",children:t.fillLevel!==null?s.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${t.fillLevel}%`,backgroundColor:E(t.fillLevel)}}):s.jsx("div",{className:"h-full w-full bg-bambu-gray/30 rounded-full"})})]}),i?.enabled&&t.trayUuid&&s.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Spool ID"}),s.jsxs("button",{onClick:A=>{A.stopPropagation(),x()},className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",title:"Copy spool UUID",children:[s.jsxs("span",{className:"font-mono text-[10px] truncate max-w-[80px]",children:[t.trayUuid.slice(0,8),"..."]}),u?s.jsx(Ls,{className:"w-3 h-3 text-bambu-green"}):s.jsx(Wo,{className:"w-3 h-3"})]})]}),i.onLinkSpool&&s.jsxs("button",{onClick:A=>{A.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:[s.jsx(jp,{className:"w-3.5 h-3.5"}),"Link to Spoolman"]})]})]})]}),s.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 uH({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)},o=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>r(!1),100)};return S.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),s.jsxs("div",{className:`relative ${e}`,onMouseEnter:a,onMouseLeave:o,children:[t,n&&s.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:[s.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"}),s.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 vCe({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const i=cn(),[a,o]=S.useState(null),{data:l,isLoading:c}=ft({queryKey:["unlinked-spools"],queryFn:ye.getUnlinkedSpools,enabled:t}),u=bt({mutationFn:f=>ye.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 s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),s.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:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(jp,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Link to Spoolman"})]}),s.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[r&&s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Linking AMS tray:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[r.color&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.color}`}}),s.jsx("span",{className:"text-white font-medium",children:r.type}),s.jsxs("span",{className:"text-bambu-gray",children:["(",r.location,")"]})]})]}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Spool UUID:"}),s.jsx("code",{className:"text-xs text-bambu-green font-mono break-all",children:n})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Select a Spoolman spool to link:"}),c?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):l&&l.length>0?s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2",children:l.map(f=>s.jsx("button",{onClick:()=>o(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:s.jsxs("div",{className:"flex items-center gap-2",children:[f.filament_color_hex&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${f.filament_color_hex}`}}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:f.filament_name||"Unknown filament"}),s.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&&s.jsx(Ls,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},f.id))}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx("p",{children:"No unlinked spools found in Spoolman."}),s.jsx("p",{className:"text-xs mt-1",children:"All spools are already linked to AMS trays."})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Ne,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Ne,{onClick:d,disabled:!a||u.isPending,children:u.isPending?s.jsxs(s.Fragment,{children:[s.jsx(xt,{className:"w-4 h-4 animate-spin"}),"Linking..."]}):s.jsxs(s.Fragment,{children:[s.jsx(jp,{className:"w-4 h-4"}),"Link Spool"]})})]}),u.isError&&s.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})]})]})}function _Ce({on:t,className:e="w-5 h-5"}){const n=t?"#facc15":"none",r=t?"#78350f":"currentColor",i=t?1:0;return s.jsxs("svg",{viewBox:"0 0 32 32",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[s.jsxs("g",{stroke:r,opacity:i,children:[s.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),s.jsx("line",{x1:"6.1",y1:"6.1",x2:"8.9",y2:"8.9"}),s.jsx("line",{x1:"25.9",y1:"6.1",x2:"23.1",y2:"8.9"}),s.jsx("line",{x1:"2",y1:"16",x2:"6",y2:"16"}),s.jsx("line",{x1:"30",y1:"16",x2:"26",y2:"16"})]}),s.jsx("path",{d:"M12 24v-2.3c0-.9-.4-1.7-1-2.3C9.2 17.6 8 15.4 8 13c0-4.4 3.6-8 8-8s8 3.6 8 8c0 2.4-1.2 4.6-3 6.4-.6.6-1 1.4-1 2.3V24",fill:n,stroke:r}),s.jsx("path",{d:"M12 24h8",stroke:r}),s.jsx("path",{d:"M12 27h8",stroke:r}),s.jsx("path",{d:"M13 30h6",stroke:r})]})}const dH=({className:t})=>s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("rect",{x:"9.5",y:"15",width:"5",height:"5",rx:"0.5",fill:"currentColor",opacity:"0.3"}),s.jsx("rect",{x:"17",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("path",{d:"M4 12 C4 6, 14 6, 14 12"}),s.jsx("polyline",{points:"12,10 14,12 12,14"})]}),hH={"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"},wCe={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 FT(t){if(!t)return null;if(hH[t])return hH[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return wCe[n]||null}function UT(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,o=(i+a)/2;let l=0,c=0;if(i!==a){const u=i-a;c=o>.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,o<.15?"Black":o>.85?"White":c<.15?o<.4?"Dark Gray":o>.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 zT(t){return(t??.02).toFixed(3)}function fH({side:t}){const{mode:e}=fg(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return s.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 mH({className:t}){return s.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.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 SCe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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"}),s.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 MCe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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"}),s.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 ECe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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"}),s.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function ACe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),s.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 NCe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),s.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 BT({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?s.jsxs("svg",{className:t,style:a,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),s.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"})]}):s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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"}),s.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function pH({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const a=typeof t=="string"?parseInt(t,10):t,o=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(a)?(c="#C3C2C1",u="Unknown"):a<=o?(c="#22a352",u="Good"):a<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(a)||a<=o?d=mH:a<=l?d=SCe:d=MCe,s.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:[s.jsx(d,{className:i?"w-2.5 h-3":"w-3 h-4"}),s.jsxs("span",{className:`font-medium tabular-nums ${i?"text-[10px]":"text-xs"}`,style:{color:c},children:[a,"%"]})]})}function gH({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const a=typeof e=="number"?e:28,o=typeof n=="number"?n:35;let l,c,u;return t<=a?(l="#22a352",c="Good",u=ECe):t<=o?(l="#d4a017",c="Fair",u=ACe):(l="#c62828",c="Bad",u=NCe),s.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:[s.jsx(u,{className:i?"w-2.5 h-3":"w-3 h-4"}),s.jsxs("span",{className:`tabular-nums text-right ${i?"text-[10px] w-8":"w-12"}`,style:{color:l},children:[t,"°C"]})]})}function Cu(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,o=String.fromCharCode(65+a);return i?`HT-${o}`:`AMS-${o}`}function xH(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function TCe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function CCe(t,e="system"){const n=new Date,r=new Date(n.getTime()+t*60*1e3),i=new Date;i.setHours(0,0,0,0);const a=new Date(r);a.setHours(0,0,0,0);const o={hour:"2-digit",minute:"2-digit"};e==="12h"?o.hour12=!0:e==="24h"&&(o.hour12=!1);const l=r.toLocaleTimeString([],o),c=Math.floor((a.getTime()-i.getTime())/(1e3*60*60*24));return c===0?l:c===1?`Tomorrow ${l}`:r.toLocaleDateString([],{weekday:"short"})+" "+l}function kCe(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 PCe(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 jCe({url:t,printName:e}){const[n,r]=S.useState(!1),[i,a]=S.useState(!1),[o,l]=S.useState(!1);return s.jsxs(s.Fragment,{children:[s.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?s.jsxs(s.Fragment,{children:[s.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>a(!0)}),!n&&s.jsx(vl,{className:"w-8 h-8 text-bambu-gray"})]}):s.jsx(vl,{className:"w-8 h-8 text-bambu-gray"})}),o&&t&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>l(!1),children:s.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[s.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&s.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function RCe({printers:t}){const e=cn(),n=S.useMemo(()=>{let i=0,a=0,o=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++:o++}),{printing:i,idle:a,offline:o,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(o=>o+1),i=!1}))});return()=>a()},[e]),t?.length?s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function bH(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 yH({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:a,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,timeFormat:c="system"}){const u=cn(),d=kb(),{showToast:f}=hr(),[g,p]=S.useState(!1),[x,y]=S.useState(!1),[b,v]=S.useState(!0),[E,w]=S.useState(!1),[N,A]=S.useState(!1),[C,T]=S.useState(!1),[L,k]=S.useState(!1),[D,U]=S.useState(!1),[O,q]=S.useState(!1),[R,G]=S.useState(!1),[Y,V]=S.useState(!1),[K,J]=S.useState(!1),[X,F]=S.useState(!1),[W,ee]=S.useState(null),[ie,ae]=S.useState(null),[de,ue]=S.useState(!1),{data:le}=ft({queryKey:["printerStatus",t.id],queryFn:()=>ye.getPrinterStatus(t.id),refetchInterval:3e4}),{data:he}=ft({queryKey:["firmwareUpdate",t.id],queryFn:()=>b1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3}),pe=S.useMemo(()=>{const gt=new Set;if(le?.ams)for(const Vt of le.ams)for(const Qt of Vt.tray||[])Qt.tray_info_idx&&gt.add(Qt.tray_info_idx);return le?.vt_tray?.tray_info_idx&&gt.add(le.vt_tray.tray_info_idx),Array.from(gt)},[le?.ams,le?.vt_tray]),{data:Me}=ft({queryKey:["filamentInfo",pe],queryFn:()=>ye.getFilamentInfo(pe),enabled:pe.length>0,staleTime:300*1e3}),[re,We]=S.useState(null);S.useEffect(()=>{le?.wifi_signal!=null&&We(le.wifi_signal)},[le?.wifi_signal]);const z=le?.wifi_signal??re,H=S.useRef(void 0);S.useEffect(()=>{le?.connected!==void 0&&(H.current=le.connected)},[le?.connected]);const se=le?.connected??H.current,B=S.useRef({});S.useEffect(()=>{le?.ams_extruder_map&&Object.keys(le.ams_extruder_map).length>0&&(B.current=le.ams_extruder_map)},[le?.ams_extruder_map]);const Q=le?.ams_extruder_map&&Object.keys(le.ams_extruder_map).length>0?le.ams_extruder_map:B.current,ce=S.useRef([]);S.useEffect(()=>{le?.ams&&le.ams.length>0&&(ce.current=le.ams)},[le?.ams]);const Ce=le?.ams&&le.ams.length>0?le.ams:ce.current,_e=S.useRef(255),Ee=le?.tray_now;Ee!==void 0&&Ee!==255&&(_e.current=Ee);const $=Ee===void 0||Ee===255?_e.current:Ee,{data:j}=ft({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>ye.getSmartPlugByPrinter(t.id)}),{data:ne}=ft({queryKey:["smartPlugStatus",j?.id],queryFn:()=>j?ye.getSmartPlugStatus(j.id):null,enabled:!!j,refetchInterval:1e4}),{data:be}=ft({queryKey:["queue",t.id,"pending"],queryFn:()=>ye.getQueue(t.id,"pending")}),we=be?.length||0,{data:ve}=ft({queryKey:["archives",t.id,"last"],queryFn:()=>ye.getArchives(t.id,1,0),enabled:le?.connected&&le?.state!=="RUNNING"}),$e=ve?.[0],Ge=e&&se===!1,Xe=bt({mutationFn:gt=>ye.deletePrinter(t.id,gt.deleteArchives),onSuccess:()=>{u.invalidateQueries({queryKey:["printers"]}),u.invalidateQueries({queryKey:["archives"]}),u.invalidateQueries({queryKey:["maintenanceOverview"]})}}),ut=bt({mutationFn:()=>ye.connectPrinter(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["printerStatus",t.id]})}}),He=bt({mutationFn:gt=>j?ye.controlSmartPlug(j.id,gt):Promise.reject("No plug"),onSuccess:()=>{u.invalidateQueries({queryKey:["smartPlugStatus",j?.id]})}}),me=bt({mutationFn:gt=>j?ye.updateSmartPlug(j.id,{auto_off:gt}):Promise.reject("No plug"),onSuccess:()=>{u.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),u.invalidateQueries({queryKey:["smart-plugs"]})}}),Je=bt({mutationFn:()=>ye.stopPrint(t.id),onSuccess:()=>{f("Print stopped"),u.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:gt=>f(gt.message||"Failed to stop print","error")}),Ke=bt({mutationFn:()=>ye.pausePrint(t.id),onSuccess:()=>{f("Print paused"),u.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:gt=>f(gt.message||"Failed to pause print","error")}),Ze=bt({mutationFn:()=>ye.resumePrint(t.id),onSuccess:()=>{f("Print resumed"),u.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:gt=>f(gt.message||"Failed to resume print","error")}),ct=bt({mutationFn:gt=>ye.setChamberLight(t.id,gt),onMutate:async gt=>{await u.cancelQueries({queryKey:["printerStatus",t.id]});const Vt=u.getQueryData(["printerStatus",t.id]);return u.setQueryData(["printerStatus",t.id],Qt=>({...Qt,chamber_light:gt})),{previousStatus:Vt}},onSuccess:(gt,Vt)=>{f(`Chamber light ${Vt?"on":"off"}`)},onError:(gt,Vt,Qt)=>{Qt?.previousStatus&&u.setQueryData(["printerStatus",t.id],Qt.previousStatus),f(gt.message||"Failed to control chamber light","error")}}),te=(le?.state==="RUNNING"||le?.state==="PAUSE"||le?.state==="PAUSED")&&(le?.printable_objects_count??0)>=2,{data:Fe,refetch:xe}=ft({queryKey:["printableObjects",t.id],queryFn:()=>ye.getPrintableObjects(t.id),enabled:X||te,refetchInterval:X?5e3:te?3e4:!1}),ze=bt({mutationFn:gt=>ye.skipObjects(t.id,gt),onSuccess:gt=>{f(gt.message||"Objects skipped"),xe()},onError:gt=>f(gt.message||"Failed to skip objects","error")}),[Pe,Se]=S.useState(null),Ye=S.useRef(!1),dt=S.useRef(null),Tt=S.useRef(!1),Et=bt({mutationFn:({amsId:gt,slotId:Vt})=>ye.refreshAmsSlot(t.id,gt,Vt),onMutate:({amsId:gt,slotId:Vt})=>{dt.current&&clearTimeout(dt.current),Ye.current=!1,Tt.current=!1,Se({amsId:gt,slotId:Vt}),setTimeout(()=>{Tt.current=!0},2e3),dt.current=setTimeout(()=>{Se(null)},3e4)},onSuccess:gt=>{f(gt.message||"RFID re-read initiated")},onError:gt=>{f(gt.message||"Failed to re-read RFID","error"),dt.current&&clearTimeout(dt.current),Se(null)}}),Zt=S.useRef(null);S.useEffect(()=>{if(!Pe)return;const gt=le?.ams_status_main??0;return gt!==0&&(Ye.current=!0,Zt.current&&(clearTimeout(Zt.current),Zt.current=null)),Ye.current&&gt===0&&(Tt.current?(dt.current&&clearTimeout(dt.current),Se(null)):Zt.current||(Zt.current=setTimeout(()=>{dt.current&&clearTimeout(dt.current),Se(null)},2e3))),()=>{Zt.current&&clearTimeout(Zt.current)}},[le?.ams_status_main,Pe]);const[Rt,en]=S.useState(null);if(Ge)return null;const Ln=()=>{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"}},Vn=()=>{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"}},tr=()=>{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 s.jsxs(Mt,{className:"relative",children:[s.jsxs(At,{className:i>=3?"p-5":"",children:[s.jsxs("div",{className:tr(),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("img",{src:kCe(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${Ln()}`}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:`font-semibold text-white ${Vn()}`,children:t.name}),r==="compact"&&s.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${le?.connected?"bg-bambu-green":"bg-red-500"}`,title:le?.connected?"Connected":"Offline"})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&le?.nozzles&&le.nozzles[0]?.nozzle_diameter&&s.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:le.nozzles[0].nozzle_type||"Nozzle",children:["• ",le.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&s.jsxs("span",{className:"ml-2 text-bambu-gray",children:[s.jsx(dr,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>p(!g),children:s.jsx(pp,{className:"w-4 h-4"})}),g&&s.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:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{w(!0),p(!1)},children:[s.jsx(qo,{className:"w-4 h-4"}),"Edit"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{ut.mutate(),p(!1)},children:[s.jsx(Gr,{className:"w-4 h-4"}),"Reconnect"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{T(!0),p(!1)},children:[s.jsx(lW,{className:"w-4 h-4"}),"MQTT Debug"]}),s.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:()=>{y(!0),p(!1)},children:[s.jsx(_n,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[s.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${le?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[le?.connected?s.jsx(Rb,{className:"w-3 h-3"}):s.jsx(dW,{className:"w-3 h-3"}),le?.connected?"Connected":"Offline"]}),le?.connected&&z!=null&&s.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${z>=-50||z>=-60?"bg-bambu-green/20 text-bambu-green":z>=-70?"bg-amber-500/20 text-amber-600":z>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${z} dBm - ${PCe(z).label}`,children:[s.jsx(dde,{className:"w-3 h-3"}),z,"dBm"]}),le?.connected&&(()=>{const gt=le.hms_errors?She(le.hms_errors):[];return s.jsxs("button",{onClick:()=>q(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${gt.length>0?gt.some(Vt=>Vt.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:[s.jsx(zn,{className:"w-3 h-3"}),gt.length>0?gt.length:"OK"]})})(),n&&s.jsxs("button",{onClick:()=>d("/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:[s.jsx(Ad,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),we>0&&s.jsxs("button",{onClick:()=>d("/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:`${we} print${we>1?"s":""} in queue`,children:[s.jsx(Sd,{className:"w-3 h-3"}),we]}),he?.update_available&&s.jsxs("button",{onClick:()=>ue(!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: ${he.current_version} → ${he.latest_version}`,children:[s.jsx(Mi,{className:"w-3 h-3"}),"Update"]})]})]}),x&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(Mt,{className:"w-full max-w-md mx-4",children:s.jsxs(At,{children:[s.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[s.jsx("div",{className:"p-2 rounded-full bg-red-500/20",children:s.jsx(zn,{className:"w-5 h-5 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Printer"}),s.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.']})]})]}),s.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:s.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:b,onChange:gt=>v(gt.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"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:"Delete print archives"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:b?"All print history for this printer will be permanently deleted.":"Print history will be kept but no longer associated with this printer."})]})]})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Ne,{variant:"secondary",onClick:()=>{y(!1),v(!0)},children:"Cancel"}),s.jsx(Ne,{variant:"danger",onClick:()=>{Xe.mutate({deleteArchives:b}),y(!1),v(!0)},children:"Delete"})]})]})})}),le?.connected&&s.jsxs(s.Fragment,{children:[r==="compact"?s.jsx("div",{className:"mt-2",children:le.state==="RUNNING"?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:s.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${le.progress||0}%`}})}),s.jsxs("span",{className:"text-xs text-white",children:[Math.round(le.progress||0),"%"]})]}):s.jsx("p",{className:"text-xs text-bambu-gray",children:bH(le.state,le.stg_cur_name)})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg relative",children:[s.jsxs("button",{onClick:()=>F(!0),disabled:!(le.state==="RUNNING"||le.state==="PAUSE"||le.state==="PAUSED")||(le.printable_objects_count??0)<2,className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(le.state==="RUNNING"||le.state==="PAUSE"||le.state==="PAUSED")&&(le.printable_objects_count??0)>=2?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:le.state==="RUNNING"||le.state==="PAUSE"||le.state==="PAUSED"?(le.printable_objects_count??0)>=2?"Skip objects":"Skip objects (requires 2+ objects)":"Skip objects (only while printing)",children:[s.jsx(dH,{className:"w-4 h-4"}),Fe&&Fe.skipped_count>0&&s.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:Fe.skipped_count})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(jCe,{url:le.state==="RUNNING"?le.cover_url:null,printName:le.state==="RUNNING"&&(le.subtask_name||le.current_print)||void 0}),s.jsx("div",{className:"flex-1 min-w-0",children:le.current_print&&le.state==="RUNNING"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:le.stg_cur_name||"Printing"}),s.jsx("p",{className:"text-white text-sm mb-2 truncate",children:le.subtask_name||le.current_print}),s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${le.progress||0}%`}})}),s.jsxs("span",{className:"text-white",children:[Math.round(le.progress||0),"%"]})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[le.remaining_time!=null&&le.remaining_time>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(dr,{className:"w-3 h-3"}),TCe(le.remaining_time*60)]}),s.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",CCe(le.remaining_time,c)]})]}),le.layer_num!=null&&le.total_layers!=null&&le.total_layers>0&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Sd,{className:"w-3 h-3"}),le.layer_num,"/",le.total_layers]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),s.jsx("p",{className:"text-white text-sm mb-2",children:bH(le.state,le.stg_cur_name)}),s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:s.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),s.jsx("span",{className:"text-bambu-gray",children:"—"})]}),$e?s.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:$e.print_name||$e.filename,children:["Last: ",$e.print_name||$e.filename,$e.completed_at&&s.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",Dp($e.completed_at,{month:"short",day:"numeric"})]})]}):s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})]}),le.state!=="RUNNING"&&s.jsx(Nhe,{printerId:t.id})]}),le.temperatures&&r==="expanded"&&(()=>{const gt=le.temperatures.nozzle_heating||le.temperatures.nozzle_2_heating||!1,Vt=le.temperatures.bed_heating||!1,Qt=le.temperatures.chamber_heating||!1;return s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[s.jsx(BT,{className:"w-4 h-4 mx-auto mb-1",color:"text-orange-400",isHeating:gt}),le.temperatures.nozzle_2!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[10px] text-bambu-gray",children:"L / R"}),s.jsxs("p",{className:"text-xs text-white",children:[Math.round(le.temperatures.nozzle||0),"° / ",Math.round(le.temperatures.nozzle_2||0),"°"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[10px] text-bambu-gray",children:"Nozzle"}),s.jsxs("p",{className:"text-xs text-white",children:[Math.round(le.temperatures.nozzle||0),"°C"]})]})]}),s.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[s.jsx(BT,{className:"w-4 h-4 mx-auto mb-1",color:"text-blue-400",isHeating:Vt}),s.jsx("p",{className:"text-[10px] text-bambu-gray",children:"Bed"}),s.jsxs("p",{className:"text-xs text-white",children:[Math.round(le.temperatures.bed||0),"°C"]})]}),le.temperatures.chamber!==void 0?s.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[s.jsx(BT,{className:"w-4 h-4 mx-auto mb-1",color:"text-green-400",isHeating:Qt}),s.jsx("p",{className:"text-[10px] text-bambu-gray",children:"Chamber"}),s.jsxs("p",{className:"text-xs text-white",children:[Math.round(le.temperatures.chamber||0),"°C"]})]}):s.jsx("div",{})]})})(),r==="expanded"&&(()=>{const gt=le.state==="RUNNING",Vt=le.state==="PAUSED"||le.state==="PAUSE",Qt=gt||Vt,mt=Je.isPending||Ke.isPending||Ze.isPending,Kt=le.cooling_fan_speed,dn=le.big_fan1_speed,Ht=le.big_fan2_speed;return s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Controls"}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Kt&&Kt>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:"Part Cooling Fan",children:[s.jsx(J9,{className:`w-3.5 h-3.5 ${Kt&&Kt>0?"text-cyan-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Kt&&Kt>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[Kt??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${dn&&dn>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:"Auxiliary Fan",children:[s.jsx(fW,{className:`w-3.5 h-3.5 ${dn&&dn>0?"text-blue-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${dn&&dn>0?"text-blue-400":"text-bambu-gray/50"}`,children:[dn??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Ht&&Ht>0?"bg-green-500/10":"bg-bambu-dark"}`,title:"Chamber Fan",children:[s.jsx(Zoe,{className:`w-3.5 h-3.5 ${Ht&&Ht>0?"text-green-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Ht&&Ht>0?"text-green-400":"text-bambu-gray/50"}`,children:[Ht??0,"%"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>G(!0),disabled:!Qt||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. ${Qt?"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:[s.jsx(Ed,{className:"w-3 h-3"}),"Stop"]}),s.jsxs("button",{onClick:()=>Vt?J(!0):V(!0),disabled:!Qt||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. ${Qt?Vt?"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:Vt?"Resume print":"Pause print",children:[Vt?s.jsx(Gc,{className:"w-3 h-3"}):s.jsx(ER,{className:"w-3 h-3"}),Vt?"Resume":"Pause"]})]})]})]})})(),Ce&&Ce.length>0&&r==="expanded"&&(()=>{const gt=Ce.filter(mt=>mt.tray.length>1),Vt=Ce.filter(mt=>mt.tray.length===1),Qt=t.nozzle_count===2||le?.temperatures?.nozzle_2!==void 0;return s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Filaments"}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),s.jsxs("div",{className:"space-y-3",children:[gt.length>0&&s.jsx("div",{className:"grid grid-cols-2 gap-3",children:gt.map(mt=>{const Kt=Q[String(mt.id)],dn=mt.id>=128?mt.id-128:mt.id,Ht=Kt!==void 0?Kt:dn,Re=Ht===1,ge=Ht===0;return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[10px] text-white font-medium",children:Cu(mt.id,mt.tray.length)}),Qt&&(Re||ge)&&s.jsx(fH,{side:Re?"L":"R"})]}),(mt.humidity!=null||mt.temp!=null)&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[mt.humidity!=null&&s.jsx(pH,{humidity:mt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>ee({amsId:mt.id,amsLabel:Cu(mt.id,mt.tray.length),mode:"humidity"}),compact:!0}),mt.temp!=null&&s.jsx(gH,{temp:mt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>ee({amsId:mt.id,amsLabel:Cu(mt.id,mt.tray.length),mode:"temperature"}),compact:!0})]})]}),s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(je=>{const Be=mt.tray[je]||mt.tray.find(st=>st.id===je),rt=Be?.tray_type&&Be.remain>=0,tt=!Be?.tray_type,yt=mt.id*4+je,oe=$===yt,Ae=Be?.tray_info_idx?Me?.[Be.tray_info_idx]:null,De=Be?.tray_type?{vendor:Be.tray_uuid?"Bambu Lab":"Generic",profile:Ae?.name||Be.tray_sub_brands||Be.tray_type,colorName:FT(Be.tray_id_name)||UT(Be.tray_color),colorHex:Be.tray_color||null,kFactor:zT(Be.k),fillLevel:rt?Be.remain:null,trayUuid:Be.tray_uuid||null}:null,Oe=Pe?.amsId===mt.id&&Pe?.slotId===je,ke=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${tt?"opacity-50":""} ${oe?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:Be?.tray_color?`#${Be.tray_color}`:Be?.tray_type?"#333":"transparent",borderColor:tt?"#666":"rgba(255,255,255,0.1)",borderStyle:tt?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Be?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:rt&&Be?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Be.remain}%`,backgroundColor:xH(Be.remain)}}):Be?.tray_type?s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return s.jsxs("div",{className:"relative group",children:[Oe&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Gr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),le?.state!=="RUNNING"&&s.jsx("button",{onClick:st=>{st.stopPropagation(),en(Rt?.amsId===mt.id&&Rt?.slotId===je?null:{amsId:mt.id,slotId:je})},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:s.jsx(pp,{className:"w-2.5 h-2.5 text-bambu-gray"})}),le?.state!=="RUNNING"&&Rt?.amsId===mt.id&&Rt?.slotId===je&&s.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:s.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:st=>{st.stopPropagation(),Et.mutate({amsId:mt.id,slotId:je}),en(null)},disabled:Oe,children:[s.jsx(Gr,{className:`w-3 h-3 ${Oe?"animate-spin":""}`}),"Re-read RFID"]})}),De?s.jsx(IT,{data:De,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&De.trayUuid?st=>{ae({trayUuid:st,trayInfo:{type:De.profile,color:De.colorHex||"",location:`${Cu(mt.id,mt.tray.length)} Slot ${je+1}`}})}:void 0},children:ke}):s.jsx(uH,{children:ke})]},je)})})]},mt.id)})}),(Vt.length>0||le.vt_tray&&le.vt_tray.tray_type)&&s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[Vt.map(mt=>{const Kt=Q[String(mt.id)],dn=mt.id>=128?mt.id-128:mt.id,Ht=Kt!==void 0?Kt:dn,Re=Ht===1,ge=Ht===0,je=mt.tray[0],Be=je?.tray_type&&je.remain>=0,rt=!je?.tray_type,tt=mt.id*4+(je?.id??0),yt=$===tt,oe=je?.tray_info_idx?Me?.[je.tray_info_idx]:null,Ae=je?.tray_type?{vendor:je.tray_uuid?"Bambu Lab":"Generic",profile:oe?.name||je.tray_sub_brands||je.tray_type,colorName:FT(je.tray_id_name)||UT(je.tray_color),colorHex:je.tray_color||null,kFactor:zT(je.k),fillLevel:Be?je.remain:null,trayUuid:je.tray_uuid||null}:null,De=je?.id??0,Oe=Pe?.amsId===mt.id&&Pe?.slotId===De,ke=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${rt?"opacity-50":""} ${yt?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:je?.tray_color?`#${je.tray_color}`:je?.tray_type?"#333":"transparent",borderColor:rt?"#666":"rgba(255,255,255,0.1)",borderStyle:rt?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:je?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Be?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${je.remain}%`,backgroundColor:xH(je.remain)}}):je?.tray_type?s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[s.jsx("span",{className:"text-[10px] text-white font-medium",children:Cu(mt.id,mt.tray.length)}),Qt&&(Re||ge)&&s.jsx(fH,{side:Re?"L":"R"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsxs("div",{className:"relative group flex-1",children:[Oe&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Gr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),le?.state!=="RUNNING"&&s.jsx("button",{onClick:st=>{st.stopPropagation(),en(Rt?.amsId===mt.id&&Rt?.slotId===De?null:{amsId:mt.id,slotId:De})},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:s.jsx(pp,{className:"w-2.5 h-2.5 text-bambu-gray"})}),le?.state!=="RUNNING"&&Rt?.amsId===mt.id&&Rt?.slotId===De&&s.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:s.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:st=>{st.stopPropagation(),Et.mutate({amsId:mt.id,slotId:De}),en(null)},disabled:Oe,children:[s.jsx(Gr,{className:`w-3 h-3 ${Oe?"animate-spin":""}`}),"Re-read RFID"]})}),Ae?s.jsx(IT,{data:Ae,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Ae.trayUuid?st=>{ae({trayUuid:st,trayInfo:{type:Ae.profile,color:Ae.colorHex||"",location:Cu(mt.id,mt.tray.length)}})}:void 0},children:ke}):s.jsx(uH,{children:ke})]}),(mt.humidity!=null||mt.temp!=null)&&s.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[mt.temp!=null&&s.jsx(gH,{temp:mt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>ee({amsId:mt.id,amsLabel:Cu(mt.id,mt.tray.length),mode:"temperature"}),compact:!0}),mt.humidity!=null&&s.jsx(pH,{humidity:mt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>ee({amsId:mt.id,amsLabel:Cu(mt.id,mt.tray.length),mode:"humidity"}),compact:!0})]})]})]},mt.id)}),le.vt_tray&&le.vt_tray.tray_type&&(()=>{const mt=le.vt_tray,Kt=$===254,dn=mt.tray_info_idx?Me?.[mt.tray_info_idx]:null,Ht={vendor:mt.tray_uuid?"Bambu Lab":"Generic",profile:dn?.name||mt.tray_sub_brands||mt.tray_type||"Unknown",colorName:FT(mt.tray_id_name)||UT(mt.tray_color),colorHex:mt.tray_color||null,kFactor:zT(mt.k),fillLevel:null,trayUuid:mt.tray_uuid||null},Re=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${Kt?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.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:Kt?"var(--accent)":"rgba(255,255,255,0.1)"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:mt.tray_type||"Spool"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"})})]});return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsx("div",{className:"flex items-center gap-1 mb-2",children:s.jsx("span",{className:"text-[10px] text-white font-medium",children:"External"})}),s.jsx(IT,{data:Ht,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Ht.trayUuid?ge=>{ae({trayUuid:ge,trayInfo:{type:Ht.profile,color:Ht.colorHex||"",location:"External Spool"}})}:void 0},children:Re})]})})()]})]})]})})()]}),j&&r==="expanded"&&s.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(cf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-sm text-white truncate",children:j.name}),ne&&s.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${ne.state==="ON"?"bg-bambu-green/20 text-bambu-green":ne.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[ne.state||"?",ne.state==="ON"&&ne.energy?.power!=null&&s.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",ne.energy.power,"W"]})]})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{onClick:()=>k(!0),disabled:He.isPending||ne?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${ne?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[s.jsx(Ol,{className:"w-3 h-3"}),"On"]}),s.jsxs("button",{onClick:()=>U(!0),disabled:He.isPending||ne?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${ne?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[s.jsx(uM,{className:"w-3 h-3"}),"Off"]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx("span",{className:`text-xs hidden sm:inline ${j.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:j.auto_off_executed?"Auto-off done":"Auto-off"}),s.jsx("button",{onClick:()=>me.mutate(!j.auto_off),disabled:me.isPending||j.auto_off_executed,title:j.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 ${j.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":j.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${j.auto_off||j.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),r==="expanded"&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("div",{className:"text-xs text-bambu-gray",children:[s.jsx("p",{children:t.ip_address}),s.jsx("p",{className:"truncate",children:t.serial_number})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>ct.mutate(!le?.chamber_light),disabled:!le?.connected||ct.isPending,title:le?.chamber_light?"Turn off chamber light":"Turn on chamber light",className:le?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:s.jsx(_Ce,{on:le?.chamber_light??!1,className:"w-4 h-4"})}),s.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>{const gt=localStorage.getItem("cameraWindowState"),Vt=gt?JSON.parse(gt):{width:640,height:400},Qt=[`width=${Vt.width}`,`height=${Vt.height}`,Vt.left!==void 0?`left=${Vt.left}`:"",Vt.top!==void 0?`top=${Vt.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,Qt)},disabled:!le?.connected,title:"Open camera in new window",children:s.jsx(hW,{className:"w-4 h-4"})}),s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>A(!0),title:"Browse printer files",children:[s.jsx(_R,{className:"w-4 h-4"}),"Files"]})]})]})]}),N&&s.jsx(vhe,{printerId:t.id,printerName:t.name,onClose:()=>A(!1)}),C&&s.jsx(_he,{printerId:t.id,printerName:t.name,onClose:()=>T(!1)}),L&&j&&s.jsx(Qn,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{He.mutate("on"),k(!1)},onCancel:()=>k(!1)}),D&&j&&s.jsx(Qn,{title:"Power Off Printer",message:le?.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:()=>{He.mutate("off"),U(!1)},onCancel:()=>U(!1)}),R&&s.jsx(Qn,{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:()=>{Je.mutate(),G(!1)},onCancel:()=>G(!1)}),Y&&s.jsx(Qn,{title:"Pause Print",message:`Are you sure you want to pause the current print on "${t.name}"?`,confirmText:"Pause Print",variant:"default",onConfirm:()=>{Ke.mutate(),V(!1)},onCancel:()=>V(!1)}),K&&s.jsx(Qn,{title:"Resume Print",message:`Are you sure you want to resume the print on "${t.name}"?`,confirmText:"Resume Print",variant:"default",onConfirm:()=>{Ze.mutate(),J(!1)},onCancel:()=>J(!1)}),X&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>F(!1),onKeyDown:gt=>gt.key==="Escape"&&F(!1),tabIndex:-1,ref:gt=>gt?.focus(),children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 z-0"}),s.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:gt=>gt.stopPropagation(),children:[s.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:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(dH,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Skip Objects"})]}),s.jsx("button",{onClick:()=>F(!1),className:"p-1 text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white rounded transition-colors",children:s.jsx(Bt,{className:"w-4 h-4"})})]}),Fe?Fe.objects.length===0?s.jsxs("div",{className:"text-center py-8 px-4 text-bambu-gray",children:[s.jsx("p",{className:"text-sm",children:"No objects found"}),s.jsx("p",{className:"text-xs mt-1 opacity-70",children:"Objects are loaded when a print starts"})]}):s.jsxs("div",{className:"flex flex-col",children:[s.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:[s.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:s.jsx(Tue,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-300",children:"Match IDs with your printer display"}),s.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"})]}),s.jsxs("div",{className:"flex-shrink-0 text-xs text-gray-500 dark:text-bambu-gray",children:[Fe.skipped_count,"/",Fe.total," skipped"]})]}),(le?.layer_num??0)<=1&&s.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:[s.jsx(Aa,{className:"w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0"}),s.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:["Wait for layer 2+ to skip objects (currently layer ",le?.layer_num??0,")"]})]}),s.jsxs("div",{className:"flex",children:[s.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:s.jsxs("div",{className:"relative",children:[le?.cover_url?s.jsx("img",{src:`${le.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"}):s.jsx("div",{className:"w-full aspect-square rounded-lg bg-gray-100 dark:bg-bambu-dark flex items-center justify-center",children:s.jsx(vl,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),Fe.objects.length>0&&s.jsx("div",{className:"absolute inset-0 pointer-events-none",children:Fe.objects.map((gt,Vt)=>{let Qt,mt;if(gt.x!=null&&gt.y!=null&&Fe.bbox_all){const[Kt,dn,Ht,Re]=Fe.bbox_all,ge=Ht-Kt,je=Re-dn,Be=8,rt=100-Be*2;Qt=Be+(gt.x-Kt)/ge*rt,mt=Be+(Re-gt.y)/je*rt,Qt=Math.max(5,Math.min(95,Qt)),mt=Math.max(5,Math.min(95,mt))}else if(gt.x!=null&&gt.y!=null)Qt=gt.x/256*100,mt=100-gt.y/256*100,Qt=Math.max(5,Math.min(95,Qt)),mt=Math.max(5,Math.min(95,mt));else{const Kt=Math.ceil(Math.sqrt(Fe.objects.length)),dn=Math.floor(Vt/Kt),Ht=Vt%Kt,Re=Math.ceil(Fe.objects.length/Kt);Qt=15+Ht*(70/Kt)+35/Kt,mt=15+dn*(70/Re)+35/Re}return s.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${gt.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${Qt}%`,top:`${mt}%`,transform:"translate(-50%, -50%)"},title:gt.name,children:gt.id},gt.id)})}),s.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:[Fe.objects.filter(gt=>!gt.skipped).length," active"]})]})}),s.jsx("div",{className:"flex-1 min-w-0",children:Fe.objects.map(gt=>s.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. ${gt.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
  87. `,children:[s.jsxs("div",{className:`
  88. w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
  89. ${gt.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:[s.jsx("span",{className:`text-lg font-mono font-bold ${gt.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:gt.id}),s.jsx("span",{className:`text-[8px] uppercase tracking-wider ${gt.skipped?"text-red-400/60":"text-green-500/60 dark:text-bambu-green/60"}`,children:"ID"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:`block text-sm truncate ${gt.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:gt.name}),gt.skipped&&s.jsx("span",{className:"text-[10px] text-red-400/60",children:"Will be skipped"})]}),gt.skipped?s.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"}):s.jsx("button",{onClick:()=>ze.mutate([gt.id]),disabled:ze.isPending||(le?.layer_num??0)<=1,className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(le?.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:(le?.layer_num??0)<=1?"Wait for layer 2+":"Skip this object",children:"Skip"})]},gt.id))})]})]}):s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(xt,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),O&&s.jsx(Ehe,{printerName:t.name,errors:le?.hms_errors||[],onClose:()=>q(!1)}),W&&s.jsx(yCe,{isOpen:!!W,onClose:()=>ee(null),printerId:t.id,printerName:t.name,amsId:W.amsId,amsLabel:W.amsLabel,initialMode:W.mode,thresholds:a}),ie&&s.jsx(vCe,{isOpen:!!ie,onClose:()=>ae(null),trayUuid:ie.trayUuid,trayInfo:ie.trayInfo}),E&&s.jsx(LCe,{printer:t,onClose:()=>w(!1)}),de&&he&&s.jsx(OCe,{printer:t,firmwareInfo:he,onClose:()=>ue(!1)}),Rt&&s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>en(null)})]})}function DCe({onClose:t,onAdd:e,existingSerials:n}){const[r,i]=S.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0}),[a,o]=S.useState(!1),[l,c]=S.useState([]),[u,d]=S.useState(""),[f,g]=S.useState(!1),[p,x]=S.useState(!1),[y,b]=S.useState("192.168.1.0/24"),[v,E]=S.useState({scanned:0,total:0});S.useEffect(()=>{al.getInfo().then(T=>{x(T.is_docker)}).catch(()=>{})},[]);const w=l.filter(T=>!n.includes(T.serial)),N=async()=>{d(""),c([]),o(!0),g(!1),E({scanned:0,total:0});try{if(p){await al.startSubnetScan(y);const T=setInterval(async()=>{try{const L=await al.getScanStatus();E({scanned:L.scanned,total:L.total});const k=await al.getDiscoveredPrinters();c(k),L.running||(clearInterval(T),o(!1),g(!0))}catch(L){console.error("Failed to get scan status:",L)}},500)}else{await al.startDiscovery(10);const T=setInterval(async()=>{try{const L=await al.getDiscoveredPrinters();c(L)}catch(L){console.error("Failed to get discovered printers:",L)}},1e3);setTimeout(async()=>{clearInterval(T);try{await al.stopDiscovery()}catch{}o(!1),g(!0);try{const L=await al.getDiscoveredPrinters();c(L)}catch(L){console.error("Failed to get final discovered printers:",L)}},1e4)}}catch(T){console.error("Failed to start discovery:",T),d(T instanceof Error?T.message:"Failed to start discovery"),o(!1),g(!0)}},A=T=>T?{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"}[T]||T:"",C=T=>{i({...r,name:T.name||"",serial_number:T.serial,ip_address:T.ip_address,model:A(T.model)}),c([])};return S.useEffect(()=>()=>{al.stopDiscovery().catch(()=>{}),al.stopSubnetScan().catch(()=>{})},[]),S.useEffect(()=>{const T=L=>{L.key==="Escape"&&t()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:s.jsx(Mt,{className:"w-full max-w-md",onClick:T=>T.stopPropagation(),children:s.jsxs(At,{children:[s.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),s.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[p&&s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Subnet to scan"}),s.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:y,onChange:T=>b(T.target.value),placeholder:"192.168.1.0/24",disabled:a}),s.jsxs("p",{className:"mt-1 text-xs text-bambu-gray",children:["Docker detected. Enter your printer's subnet in CIDR notation. Requires ",s.jsx("code",{className:"text-bambu-green",children:"network_mode: host"})," in docker-compose.yml."]})]}),s.jsx(Ne,{type:"button",variant:"secondary",onClick:N,disabled:a,className:"w-full",children:a?s.jsxs(s.Fragment,{children:[s.jsx(xt,{className:"w-4 h-4 animate-spin"}),p&&v.total>0?`Scanning... ${v.scanned}/${v.total}`:"Scanning..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ml,{className:"w-4 h-4"}),p?"Scan Subnet for Printers":"Discover Printers on Network"]})}),u&&s.jsx("div",{className:"mt-2 text-sm text-red-400",children:u}),w.length>0&&s.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:w.map(T=>s.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(T),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium text-white text-sm truncate",children:T.name||T.serial}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[A(T.model)||"Unknown"," • ",T.ip_address]})]}),s.jsx(Ga,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},T.serial))}),a&&s.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&&s.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&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:"All discovered printers are already configured."})]}),s.jsxs("form",{onSubmit:T=>{T.preventDefault(),e(r)},className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),s.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:T=>i({...r,name:T.target.value}),placeholder:"My Printer"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),s.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:T=>i({...r,ip_address:T.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),s.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:T=>i({...r,serial_number:T.target.value}),placeholder:"01P00A000000000"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),s.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:T=>i({...r,access_code:T.target.value}),placeholder:"From printer settings"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),s.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:T=>i({...r,model:T.target.value}),children:[s.jsx("option",{value:"",children:"Select model..."}),s.jsxs("optgroup",{label:"H2 Series",children:[s.jsx("option",{value:"H2C",children:"H2C"}),s.jsx("option",{value:"H2D",children:"H2D"}),s.jsx("option",{value:"H2S",children:"H2S"})]}),s.jsxs("optgroup",{label:"X1 Series",children:[s.jsx("option",{value:"X1E",children:"X1E"}),s.jsx("option",{value:"X1C",children:"X1 Carbon"}),s.jsx("option",{value:"X1",children:"X1"})]}),s.jsxs("optgroup",{label:"P Series",children:[s.jsx("option",{value:"P2S",children:"P2S"}),s.jsx("option",{value:"P1S",children:"P1S"}),s.jsx("option",{value:"P1P",children:"P1P"})]}),s.jsxs("optgroup",{label:"A1 Series",children:[s.jsx("option",{value:"A1",children:"A1"}),s.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"auto_archive",checked:r.auto_archive,onChange:T=>i({...r,auto_archive:T.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(Ne,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsx(Ne,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function OCe({printer:t,firmwareInfo:e,onClose:n}){const r=cn(),{showToast:i}=hr(),[a,o]=S.useState(null),[l,c]=S.useState(!1),[u,d]=S.useState(null),{data:f,isLoading:g}=ft({queryKey:["firmwarePrepare",t.id],queryFn:()=>b1.prepareUpload(t.id),staleTime:3e4}),p=bt({mutationFn:()=>b1.startUpload(t.id),onSuccess:()=>{c(!0);const y=setInterval(async()=>{try{const b=await b1.getUploadStatus(t.id);o(b),(b.status==="complete"||b.status==="error")&&(clearInterval(y),d(null),c(!1),b.status==="complete"&&(i("Firmware uploaded! Trigger update from printer screen.","success"),r.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);d(y)},onError:y=>{i(`Failed to start upload: ${y.message}`,"error"),c(!1)}});S.useEffect(()=>()=>{u&&clearInterval(u)},[u]);const x=()=>{o(null),p.mutate()};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(Mt,{className:"w-full max-w-md mx-4",children:s.jsxs(At,{children:[s.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[s.jsx("div",{className:"p-2 rounded-full bg-orange-500/20",children:s.jsx(Mi,{className:"w-5 h-5 text-orange-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Firmware Update"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t.name})]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:[s.jsxs("div",{className:"flex justify-between items-center text-sm",children:[s.jsx("span",{className:"text-bambu-gray",children:"Current:"}),s.jsx("span",{className:"text-white font-mono",children:e.current_version||"Unknown"})]}),s.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[s.jsx("span",{className:"text-bambu-gray",children:"Latest:"}),s.jsx("span",{className:"text-orange-400 font-mono",children:e.latest_version})]}),e.release_notes&&s.jsxs("details",{className:"mt-3 text-sm",children:[s.jsx("summary",{className:"text-orange-400 cursor-pointer hover:underline",children:"Release Notes"}),s.jsx("div",{className:"mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap",children:e.release_notes})]})]}),g?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm mb-4",children:[s.jsx(xt,{className:"w-4 h-4 animate-spin"}),"Checking prerequisites..."]}):f&&!l&&!a?s.jsx("div",{className:"mb-4",children:f.can_proceed?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-green text-sm",children:[s.jsx(vl,{className:"w-4 h-4"}),"SD card ready. Click below to upload firmware."]}):s.jsx("div",{className:"space-y-1",children:f.errors.map((y,b)=>s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(Aa,{className:"w-4 h-4 flex-shrink-0"}),y]},b))})}):null,(l||a)&&a&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray capitalize",children:a.status}),s.jsxs("span",{className:"text-white",children:[a.progress,"%"]})]}),s.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.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}%`}})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a.message}),a.error&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:a.error})]}),a?.status==="complete"&&s.jsxs("div",{className:"bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4",children:[s.jsx("p",{className:"text-sm text-bambu-green font-medium mb-2",children:"Firmware uploaded to SD card!"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"To apply the update on your printer:"}),s.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[s.jsxs("li",{children:["On the printer's touchscreen, go to ",s.jsx("strong",{className:"text-white",children:"Settings"})]}),s.jsxs("li",{children:["Navigate to ",s.jsx("strong",{className:"text-white",children:"Firmware"})]}),s.jsxs("li",{children:["Select ",s.jsx("strong",{className:"text-white",children:"Update from SD card"})]}),s.jsx("li",{children:"The update will take 10-20 minutes"})]})]}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx(Ne,{variant:"secondary",onClick:n,children:a?.status==="complete"?"Done":"Cancel"}),f?.can_proceed&&!l&&a?.status!=="complete"&&s.jsx(Ne,{onClick:x,disabled:p.isPending,children:p.isPending?s.jsxs(s.Fragment,{children:[s.jsx(xt,{className:"w-4 h-4 animate-spin mr-2"}),"Starting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Mi,{className:"w-4 h-4 mr-2"}),"Upload Firmware"]})})]})]})})})}function LCe({printer:t,onClose:e}){const n=cn(),[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=bt({mutationFn:l=>ye.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 o=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 s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsx(Mt,{className:"w-full max-w-md",onClick:l=>l.stopPropagation(),children:s.jsxs(At,{children:[s.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),s.jsxs("form",{onSubmit:o,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),s.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),s.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),s.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}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),s.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),s.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:[s.jsx("option",{value:"",children:"Select model..."}),s.jsxs("optgroup",{label:"H2 Series",children:[s.jsx("option",{value:"H2C",children:"H2C"}),s.jsx("option",{value:"H2D",children:"H2D"}),s.jsx("option",{value:"H2S",children:"H2S"})]}),s.jsxs("optgroup",{label:"X1 Series",children:[s.jsx("option",{value:"X1E",children:"X1E"}),s.jsx("option",{value:"X1C",children:"X1 Carbon"}),s.jsx("option",{value:"X1",children:"X1"})]}),s.jsxs("optgroup",{label:"P Series",children:[s.jsx("option",{value:"P2S",children:"P2S"}),s.jsx("option",{value:"P1S",children:"P1S"}),s.jsx("option",{value:"P1P",children:"P1P"})]}),s.jsxs("optgroup",{label:"A1 Series",children:[s.jsx("option",{value:"A1",children:"A1"}),s.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),s.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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"}),s.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(Ne,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsx(Ne,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function ICe(t){const{data:e}=ft({queryKey:["printerStatus",t],queryFn:()=>ye.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function FCe({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=ICe(t.id),{data:a}=ft({queryKey:["smartPlugStatus",e.id],queryFn:()=>ye.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),a&&s.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||"?"})]}),s.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:[s.jsx(Ol,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function UCe(){const[t,e]=S.useState(!1),[n,r]=S.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,a]=S.useState(!1),[o,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 X=localStorage.getItem("printerCardSize");return X?parseInt(X,10):2}),x=g===1?"compact":"expanded",y=cn(),{data:b,isLoading:v}=ft({queryKey:["printers"],queryFn:ye.getPrinters}),{data:E}=ft({queryKey:["settings"],queryFn:ye.getSettings}),{data:w}=ft({queryKey:["smart-plugs"],queryFn:ye.getSmartPlugs}),{data:N}=ft({queryKey:["maintenanceOverview"],queryFn:ye.getMaintenanceOverview,staleTime:60*1e3}),{data:A}=ft({queryKey:["spoolman-status"],queryFn:ye.getSpoolmanStatus,staleTime:60*1e3}),C=A?.enabled&&A?.connected,{data:T}=ft({queryKey:["unlinked-spools"],queryFn:ye.getUnlinkedSpools,enabled:!!C,staleTime:30*1e3}),L=T&&T.length>0,k=N?.reduce((X,F)=>(X[F.printer_id]={due_count:F.due_count,warning_count:F.warning_count,total_print_hours:F.total_print_hours},X),{})||{},D=w?.reduce((X,F)=>(F.printer_id&&(X[F.printer_id]=F),X),{})||{},U=bt({mutationFn:ye.createPrinter,onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),y.invalidateQueries({queryKey:["maintenanceOverview"]}),e(!1)}}),O=bt({mutationFn:X=>ye.controlSmartPlug(X,"on"),onSuccess:()=>{y.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),q=()=>{const X=!n;r(X),localStorage.setItem("hideDisconnectedPrinters",String(X))},R=X=>{u(X),localStorage.setItem("printerSortBy",X)},G=()=>{const X=!d;f(X),localStorage.setItem("printerSortAsc",String(X))},Y=()=>{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"}},V=["S","M","L","XL"],K=S.useMemo(()=>{if(!b)return[];const X=[...b];switch(c){case"name":X.sort((F,W)=>F.name.localeCompare(W.name));break;case"model":X.sort((F,W)=>(F.model||"").localeCompare(W.model||""));break;case"location":X.sort((F,W)=>{const ee=F.location||"",ie=W.location||"";return!ee&&ie?1:ee&&!ie?-1:ee.localeCompare(ie)||F.name.localeCompare(W.name)});break;case"status":X.sort((F,W)=>{const ee=y.getQueryData(["printerStatus",F.id]),ie=y.getQueryData(["printerStatus",W.id]),ae=de=>de?.connected?de.state==="RUNNING"?0:1:2;return ae(ee)-ae(ie)});break}return d||X.reverse(),X},[b,c,d,y]),J=S.useMemo(()=>{if(c!=="location")return null;const X={};return K.forEach(F=>{const W=F.location||"Ungrouped";X[W]||(X[W]=[]),X[W].push(F)}),X},[c,K]);return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),s.jsx(RCe,{printers:b})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("select",{value:c,onChange:X=>R(X.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:[s.jsx("option",{value:"name",children:"Name"}),s.jsx("option",{value:"status",children:"Status"}),s.jsx("option",{value:"model",children:"Model"}),s.jsx("option",{value:"location",children:"Location"})]}),s.jsx("button",{onClick:G,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?s.jsx(Cp,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(F0,{className:"w-4 h-4 text-bambu-gray"})})]}),s.jsx("div",{className:"flex items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:V.map((X,F)=>{const W=F+1,ee=g===W;return s.jsx("button",{onClick:()=>{p(W),localStorage.setItem("printerCardSize",String(W))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${F===0?"rounded-l-lg":""} ${F===V.length-1?"rounded-r-lg":""} ${ee?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:`${X==="S"?"Small":X==="M"?"Medium":X==="L"?"Large":"Extra large"} cards`,children:X},X)})}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.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(D).length>0&&s.jsxs("div",{className:"relative",children:[s.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:[s.jsx(Ol,{className:"w-4 h-4"}),"Power On",s.jsx(Ga,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),s.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:[s.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"}),b?.filter(X=>D[X.id]).map(X=>s.jsx(FCe,{printer:X,plug:D[X.id],onPowerOn:F=>{l(F),O.mutate(F)},isPowering:o===D[X.id]?.id},X.id)),b?.filter(X=>D[X.id]).length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),s.jsxs(Ne,{onClick:()=>e(!0),children:[s.jsx(pr,{className:"w-4 h-4"}),"Add Printer"]})]})]}),v?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):b?.length===0?s.jsx(Mt,{children:s.jsxs(At,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),s.jsxs(Ne,{onClick:()=>e(!0),children:[s.jsx(pr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):J?s.jsx("div",{className:"space-y-6",children:Object.entries(J).map(([X,F])=>s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),X,s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",F.length,")"]})]}),s.jsx("div",{className:`grid gap-4 ${g>=3?"gap-6":""} ${Y()}`,children:F.map(W=>s.jsx(yH,{printer:W,hideIfDisconnected:n,maintenanceInfo:k[W.id],viewMode:x,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:L,timeFormat:E?.time_format||"system"},W.id))})]},X))}):s.jsx("div",{className:`grid gap-4 ${g>=3?"gap-6":""} ${Y()}`,children:K.map(X=>s.jsx(yH,{printer:X,hideIfDisconnected:n,maintenanceInfo:k[X.id],viewMode:x,cardSize:g,spoolmanEnabled:C,hasUnlinkedSpools:L,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,timeFormat:E?.time_format||"system"},X.id))}),t&&s.jsx(DCe,{onClose:()=>e(!1),onAdd:X=>U.mutate(X),existingSerials:b?.map(X=>X.serial_number)||[]})]})}function zCe(){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 BCe(){switch(zCe()){case"windows":return"bambustudio://";case"macos":case"linux":default:return"bambustudioopen://"}}function Ec(t){const e=BCe();window.location.href=`${e}${encodeURIComponent(t)}`}const PO="181",vp={ROTATE:0,DOLLY:1,PAN:2},hp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},HCe=0,vH=1,$Ce=2,jZ=1,VCe=2,bc=3,jd=0,ss=1,ml=2,Fc=0,_p=1,_H=2,wH=3,SH=4,GCe=5,Eh=100,WCe=101,qCe=102,KCe=103,XCe=104,YCe=200,ZCe=201,QCe=202,JCe=203,pP=204,gP=205,eke=206,tke=207,nke=208,rke=209,ike=210,ake=211,ske=212,oke=213,lke=214,xP=0,bP=1,yP=2,Vp=3,vP=4,_P=5,wP=6,SP=7,jO=0,cke=1,uke=2,md=0,dke=1,hke=2,fke=3,mke=4,pke=5,gke=6,xke=7,RZ=300,Gp=301,Wp=302,MP=303,EP=304,l2=306,AP=1e3,Pc=1001,NP=1002,Rs=1003,bke=1004,Qv=1005,ho=1006,HT=1007,Oh=1008,Cl=1009,DZ=1010,OZ=1011,ib=1012,RO=1013,xf=1014,jc=1015,Eg=1016,DO=1017,OO=1018,ab=1020,LZ=35902,IZ=35899,FZ=1021,UZ=1022,zo=1023,sb=1026,ob=1027,zZ=1028,LO=1029,IO=1030,FO=1031,UO=1033,N1=33776,T1=33777,C1=33778,k1=33779,TP=35840,CP=35841,kP=35842,PP=35843,jP=36196,RP=37492,DP=37496,OP=37808,LP=37809,IP=37810,FP=37811,UP=37812,zP=37813,BP=37814,HP=37815,$P=37816,VP=37817,GP=37818,WP=37819,qP=37820,KP=37821,XP=36492,YP=36494,ZP=36495,QP=36283,JP=36284,ej=36285,tj=36286,yke=3200,vke=3201,BZ=0,_ke=1,td="",no="srgb",qp="srgb-linear",Zw="linear",sr="srgb",bm=7680,MH=519,wke=512,Ske=513,Mke=514,HZ=515,Eke=516,Ake=517,Nke=518,Tke=519,EH=35044,AH="300 es",bl=2e3,Qw=2001;function $Z(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function Jw(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Cke(){const t=Jw("canvas");return t.style.display="block",t}const NH={};function TH(...t){const e="THREE."+t.shift();console.log(e,...t)}function an(...t){const e="THREE."+t.shift();console.warn(e,...t)}function ti(...t){const e="THREE."+t.shift();console.error(e,...t)}function lb(...t){const e=t.join(" ");e in NH||(NH[e]=!0,an(...t))}function kke(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 jf=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,o=i.length;a<o;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"],P1=Math.PI/180,nj=180/Math.PI;function cy(){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 An(t,e,n){return Math.max(e,Math.min(n,t))}function Pke(t,e){return(t%e+e)%e}function $T(t,e,n){return(1-n)*t+n*e}function Dx(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 Qa(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 jke={DEG2RAD:P1};let bn=class VZ{constructor(e=0,n=0){VZ.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=An(this.x,e.x,n.x),this.y=An(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=An(this.x,e,n),this.y=An(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(An(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(An(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,o=this.y-e.y;return this.x=a*r-o*i+e.x,this.y=a*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},bf=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,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3],g=a[o+0],p=a[o+1],x=a[o+2],y=a[o+3];if(l<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l>=1){e[n+0]=g,e[n+1]=p,e[n+2]=x,e[n+3]=y;return}if(f!==y||c!==g||u!==p||d!==x){let b=c*g+u*p+d*x+f*y;b<0&&(g=-g,p=-p,x=-x,y=-y,b=-b);let v=1-l;if(b<.9995){const E=Math.acos(b),w=Math.sin(E);v=Math.sin(v*E)/w,l=Math.sin(l*E)/w,c=c*v+g*l,u=u*v+p*l,d=d*v+x*l,f=f*v+y*l}else{c=c*v+g*l,u=u*v+p*l,d=d*v+x*l,f=f*v+y*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,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[o],g=a[o+1],p=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*p-u*g,e[n+1]=c*x+d*g+u*f-l*p,e[n+2]=u*x+d*p+l*g-c*f,e[n+3]=d*x-l*f-c*g-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),g=c(r/2),p=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"YXZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"ZXY":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"ZYX":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"YZX":this._x=g*d*f+u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f-g*p*x;break;case"XZY":this._x=g*d*f-u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f+g*p*x;break;default:an("Quaternion: .setFromEuler() encountered an unknown order: "+o)}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],o=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=(o-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+o)/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+o)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(o-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(An(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,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*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,o=e._w,l=this.dot(e);l<0&&(r=-r,i=-i,a=-a,o=-o,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+o*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+o*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),a=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),a*Math.sin(n),a*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},at=class GZ{constructor(e=0,n=0,r=0){GZ.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(CH.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(CH.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,o=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])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*d-o*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=An(this.x,e.x,n.x),this.y=An(this.y,e.y,n.y),this.z=An(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=An(this.x,e,n),this.y=An(this.y,e,n),this.z=An(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(An(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,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*o-r*c,this.z=r*l-i*o,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 VT.copy(this).projectOnVector(e),this.sub(VT)}reflect(e){return this.sub(VT.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(An(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 VT=new at,CH=new bf;let vn=class WZ{constructor(e,n,r,i,a,o,l,c,u){WZ.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u)}set(e,n,r,i,a,o,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]=o,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,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],g=r[2],p=r[5],x=r[8],y=i[0],b=i[3],v=i[6],E=i[1],w=i[4],N=i[7],A=i[2],C=i[5],T=i[8];return a[0]=o*y+l*E+c*A,a[3]=o*b+l*w+c*C,a[6]=o*v+l*N+c*T,a[1]=u*y+d*E+f*A,a[4]=u*b+d*w+f*C,a[7]=u*v+d*N+f*T,a[2]=g*y+p*E+x*A,a[5]=g*b+p*w+x*C,a[8]=g*v+p*N+x*T,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],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,g=l*c-d*a,p=u*a-o*c,x=n*f+r*g+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=g*y,e[4]=(d*n-i*c)*y,e[5]=(i*a-l*n)*y,e[6]=p*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*a)*y,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,o,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(GT.makeScale(e,n)),this}rotate(e){return this.premultiply(GT.makeRotation(-e)),this}translate(e,n){return this.premultiply(GT.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 GT=new vn,kH=new vn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),PH=new vn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Rke(){const t={enabled:!0,workingColorSpace:qp,spaces:{},convert:function(i,a,o){return this.enabled===!1||a===o||!a||!o||(this.spaces[a].transfer===sr&&(i.r=Uc(i.r),i.g=Uc(i.g),i.b=Uc(i.b)),this.spaces[a].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===sr&&(i.r=wp(i.r),i.g=wp(i.g),i.b=wp(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===td?Zw: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,o){return i.copy(this.spaces[a].toXYZ).multiply(this.spaces[o].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 lb("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return lb("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({[qp]:{primaries:e,whitePoint:r,transfer:Zw,toXYZ:kH,fromXYZ:PH,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:no},outputColorSpaceConfig:{drawingBufferColorSpace:no}},[no]:{primaries:e,whitePoint:r,transfer:sr,toXYZ:kH,fromXYZ:PH,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:no}}}),t}const Un=Rke();function Uc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function wp(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let ym,Dke=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{ym===void 0&&(ym=Jw("canvas")),ym.width=e.width,ym.height=e.height;const i=ym.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=ym}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=Jw("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let o=0;o<a.length;o++)a[o]=Uc(a[o]/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(Uc(n[r]/255)*255):n[r]=Uc(n[r]);return{data:n,width:e.width,height:e.height}}else return an("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Oke=0,zO=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Oke++}),this.uuid=cy(),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 o=0,l=i.length;o<l;o++)i[o].isDataTexture?a.push(WT(i[o].image)):a.push(WT(i[o]))}else a=WT(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function WT(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Dke.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(an("Texture: Unable to serialize Texture."),{})}let Lke=0;const qT=new at;let Jo=class j1 extends jf{constructor(e=j1.DEFAULT_IMAGE,n=j1.DEFAULT_MAPPING,r=Pc,i=Pc,a=ho,o=Oh,l=zo,c=Cl,u=j1.DEFAULT_ANISOTROPY,d=td){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Lke++}),this.uuid=cy(),this.name="",this.source=new zO(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,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(qT).x}get height(){return this.source.getSize(qT).y}get depth(){return this.source.getSize(qT).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){an(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){an(`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!==RZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case AP:e.x=e.x-Math.floor(e.x);break;case Pc:e.x=e.x<0?0:1;break;case NP: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 AP:e.y=e.y-Math.floor(e.y);break;case Pc:e.y=e.y<0?0:1;break;case NP: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++}};Jo.DEFAULT_IMAGE=null;Jo.DEFAULT_MAPPING=RZ;Jo.DEFAULT_ANISOTROPY=1;let di=class qZ{constructor(e=0,n=0,r=0,i=1){qZ.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,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*a,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*a,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*a,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],g=c[1],p=c[5],x=c[9],y=c[2],b=c[6],v=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-y)<.01&&Math.abs(x-b)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+y)<.1&&Math.abs(x+b)<.1&&Math.abs(u+p+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(u+1)/2,N=(p+1)/2,A=(v+1)/2,C=(d+g)/4,T=(f+y)/4,L=(x+b)/4;return w>N&&w>A?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=C/r,a=T/r):N>A?N<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(N),r=C/i,a=L/i):A<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(A),r=T/a,i=L/a),this.set(r,i,a,n),this}let E=Math.sqrt((b-x)*(b-x)+(f-y)*(f-y)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(b-x)/E,this.y=(f-y)/E,this.z=(g-d)/E,this.w=Math.acos((u+p+v-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=An(this.x,e.x,n.x),this.y=An(this.y,e.y,n.y),this.z=An(this.z,e.z,n.z),this.w=An(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=An(this.x,e,n),this.y=An(this.y,e,n),this.z=An(this.z,e,n),this.w=An(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(An(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}},Ike=class extends jf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ho,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 di(0,0,e,n),this.scissorTest=!1,this.viewport=new di(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new Jo(i);this.textures=[];const o=r.count;for(let l=0;l<o;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:ho,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 zO(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"})}},yf=class extends Ike{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},KZ=class extends Jo{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=Rs,this.minFilter=Rs,this.wrapR=Pc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Fke=class extends Jo{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=Rs,this.minFilter=Rs,this.wrapR=Pc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},vf=class{constructor(e=new at(1/0,1/0,1/0),n=new at(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(To.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(To.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=To.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 o=0,l=a.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,To):To.fromBufferAttribute(a,o),To.applyMatrix4(e.matrixWorld),this.expandByPoint(To);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Jv.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Jv.copy(r.boundingBox)),Jv.applyMatrix4(e.matrixWorld),this.union(Jv)}const i=e.children;for(let a=0,o=i.length;a<o;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,To),To.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(Ox),e_.subVectors(this.max,Ox),vm.subVectors(e.a,Ox),_m.subVectors(e.b,Ox),wm.subVectors(e.c,Ox),ku.subVectors(_m,vm),Pu.subVectors(wm,_m),lh.subVectors(vm,wm);let n=[0,-ku.z,ku.y,0,-Pu.z,Pu.y,0,-lh.z,lh.y,ku.z,0,-ku.x,Pu.z,0,-Pu.x,lh.z,0,-lh.x,-ku.y,ku.x,0,-Pu.y,Pu.x,0,-lh.y,lh.x,0];return!KT(n,vm,_m,wm,e_)||(n=[1,0,0,0,1,0,0,0,1],!KT(n,vm,_m,wm,e_))?!1:(t_.crossVectors(ku,Pu),n=[t_.x,t_.y,t_.z],KT(n,vm,_m,wm,e_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,To).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(To).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:(ic[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ic[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ic[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ic[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ic[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ic[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ic[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ic[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ic),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 ic=[new at,new at,new at,new at,new at,new at,new at,new at],To=new at,Jv=new vf,vm=new at,_m=new at,wm=new at,ku=new at,Pu=new at,lh=new at,Ox=new at,e_=new at,t_=new at,ch=new at;function KT(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){ch.fromArray(t,a);const l=i.x*Math.abs(ch.x)+i.y*Math.abs(ch.y)+i.z*Math.abs(ch.z),c=e.dot(ch),u=n.dot(ch),d=r.dot(ch);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const Uke=new vf,Lx=new at,XT=new at;let c2=class{constructor(e=new at,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):Uke.setFromPoints(e).getCenter(r);let i=0;for(let a=0,o=e.length;a<o;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;Lx.subVectors(e,this.center);const n=Lx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Lx,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):(XT.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Lx.copy(e.center).add(XT)),this.expandByPoint(Lx.copy(e.center).sub(XT))),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 ac=new at,YT=new at,n_=new at,ju=new at,ZT=new at,r_=new at,QT=new at;let BO=class{constructor(e=new at,n=new at(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ac)),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=ac.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(ac.copy(this.origin).addScaledVector(this.direction,n),ac.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){YT.copy(e).add(n).multiplyScalar(.5),n_.copy(n).sub(e).normalize(),ju.copy(this.origin).sub(YT);const a=e.distanceTo(n)*.5,o=-this.direction.dot(n_),l=ju.dot(this.direction),c=-ju.dot(n_),u=ju.lengthSq(),d=Math.abs(1-o*o);let f,g,p,x;if(d>0)if(f=o*c-l,g=o*l-c,x=a*d,f>=0)if(g>=-x)if(g<=x){const y=1/d;f*=y,g*=y,p=f*(f+o*g+2*l)+g*(o*f+g+2*c)+u}else g=a,f=Math.max(0,-(o*g+l)),p=-f*f+g*(g+2*c)+u;else g=-a,f=Math.max(0,-(o*g+l)),p=-f*f+g*(g+2*c)+u;else g<=-x?(f=Math.max(0,-(-o*a+l)),g=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u):g<=x?(f=0,g=Math.min(Math.max(-a,-c),a),p=g*(g+2*c)+u):(f=Math.max(0,-(o*a+l)),g=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u);else g=o>0?-a:a,f=Math.max(0,-(o*g+l)),p=-f*f+g*(g+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(YT).addScaledVector(n_,g),p}intersectSphere(e,n){ac.subVectors(e.center,this.origin);const r=ac.dot(this.direction),i=ac.dot(ac)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-i),l=r-o,c=r+o;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,o,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,o=(e.max.y-g.y)*d):(a=(e.max.y-g.y)*d,o=(e.min.y-g.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),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,ac)!==null}intersectTriangle(e,n,r,i,a){ZT.subVectors(n,e),r_.subVectors(r,e),QT.crossVectors(ZT,r_);let o=this.direction.dot(QT),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;ju.subVectors(this.origin,e);const c=l*this.direction.dot(r_.crossVectors(ju,r_));if(c<0)return null;const u=l*this.direction.dot(ZT.cross(ju));if(u<0||c+u>o)return null;const d=-l*ju.dot(QT);return d<0?null:this.at(d/o,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)}},pi=class rj{constructor(e,n,r,i,a,o,l,c,u,d,f,g,p,x,y,b){rj.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,o,l,c,u,d,f,g,p,x,y,b)}set(e,n,r,i,a,o,l,c,u,d,f,g,p,x,y,b){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=a,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=g,v[3]=p,v[7]=x,v[11]=y,v[15]=b,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 rj().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/Sm.setFromMatrixColumn(e,0).length(),a=1/Sm.setFromMatrixColumn(e,1).length(),o=1/Sm.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]*o,n[9]=r[9]*o,n[10]=r[10]*o,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,o=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=o*d,p=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=g-y*u,n[9]=-l*c,n[2]=y-g*u,n[6]=x+p*u,n[10]=o*c}else if(e.order==="YXZ"){const g=c*d,p=c*f,x=u*d,y=u*f;n[0]=g+y*l,n[4]=x*l-p,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=p*l-x,n[6]=y+g*l,n[10]=o*c}else if(e.order==="ZXY"){const g=c*d,p=c*f,x=u*d,y=u*f;n[0]=g-y*l,n[4]=-o*f,n[8]=x+p*l,n[1]=p+x*l,n[5]=o*d,n[9]=y-g*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const g=o*d,p=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=x*u-p,n[8]=g*u+y,n[1]=c*f,n[5]=y*u+g,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const g=o*c,p=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=y-g*f,n[8]=x*f+p,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+x,n[10]=g-y*f}else if(e.order==="XZY"){const g=o*c,p=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=g*f+y,n[5]=o*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=l*d,n[10]=y*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(zke,e,Bke)}lookAt(e,n,r){const i=this.elements;return ws.subVectors(e,n),ws.lengthSq()===0&&(ws.z=1),ws.normalize(),Ru.crossVectors(r,ws),Ru.lengthSq()===0&&(Math.abs(r.z)===1?ws.x+=1e-4:ws.z+=1e-4,ws.normalize(),Ru.crossVectors(r,ws)),Ru.normalize(),i_.crossVectors(ws,Ru),i[0]=Ru.x,i[4]=i_.x,i[8]=ws.x,i[1]=Ru.y,i[5]=i_.y,i[9]=ws.y,i[2]=Ru.z,i[6]=i_.z,i[10]=ws.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,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],g=r[9],p=r[13],x=r[2],y=r[6],b=r[10],v=r[14],E=r[3],w=r[7],N=r[11],A=r[15],C=i[0],T=i[4],L=i[8],k=i[12],D=i[1],U=i[5],O=i[9],q=i[13],R=i[2],G=i[6],Y=i[10],V=i[14],K=i[3],J=i[7],X=i[11],F=i[15];return a[0]=o*C+l*D+c*R+u*K,a[4]=o*T+l*U+c*G+u*J,a[8]=o*L+l*O+c*Y+u*X,a[12]=o*k+l*q+c*V+u*F,a[1]=d*C+f*D+g*R+p*K,a[5]=d*T+f*U+g*G+p*J,a[9]=d*L+f*O+g*Y+p*X,a[13]=d*k+f*q+g*V+p*F,a[2]=x*C+y*D+b*R+v*K,a[6]=x*T+y*U+b*G+v*J,a[10]=x*L+y*O+b*Y+v*X,a[14]=x*k+y*q+b*V+v*F,a[3]=E*C+w*D+N*R+A*K,a[7]=E*T+w*U+N*G+A*J,a[11]=E*L+w*O+N*Y+A*X,a[15]=E*k+w*q+N*V+A*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],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],g=e[10],p=e[14],x=e[3],y=e[7],b=e[11],v=e[15];return x*(+a*c*f-i*u*f-a*l*g+r*u*g+i*l*p-r*c*p)+y*(+n*c*p-n*u*g+a*o*g-i*o*p+i*u*d-a*c*d)+b*(+n*u*f-n*l*p-a*o*f+r*o*p+a*l*d-r*u*d)+v*(-i*l*d-n*c*f+n*l*g+i*o*f-r*o*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],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],g=e[10],p=e[11],x=e[12],y=e[13],b=e[14],v=e[15],E=f*b*u-y*g*u+y*c*p-l*b*p-f*c*v+l*g*v,w=x*g*u-d*b*u-x*c*p+o*b*p+d*c*v-o*g*v,N=d*y*u-x*f*u+x*l*p-o*y*p-d*l*v+o*f*v,A=x*f*c-d*y*c-x*l*g+o*y*g+d*l*b-o*f*b,C=n*E+r*w+i*N+a*A;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/C;return e[0]=E*T,e[1]=(y*g*a-f*b*a-y*i*p+r*b*p+f*i*v-r*g*v)*T,e[2]=(l*b*a-y*c*a+y*i*u-r*b*u-l*i*v+r*c*v)*T,e[3]=(f*c*a-l*g*a-f*i*u+r*g*u+l*i*p-r*c*p)*T,e[4]=w*T,e[5]=(d*b*a-x*g*a+x*i*p-n*b*p-d*i*v+n*g*v)*T,e[6]=(x*c*a-o*b*a-x*i*u+n*b*u+o*i*v-n*c*v)*T,e[7]=(o*g*a-d*c*a+d*i*u-n*g*u-o*i*p+n*c*p)*T,e[8]=N*T,e[9]=(x*f*a-d*y*a-x*r*p+n*y*p+d*r*v-n*f*v)*T,e[10]=(o*y*a-x*l*a+x*r*u-n*y*u-o*r*v+n*l*v)*T,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*T,e[12]=A*T,e[13]=(d*y*i-x*f*i+x*r*g-n*y*g-d*r*b+n*f*b)*T,e[14]=(x*l*i-o*y*i-x*r*c+n*y*c+o*r*b-n*l*b)*T,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*g+n*l*g)*T,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,o=e.x,l=e.y,c=e.z,u=a*o,d=a*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,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,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,g=a*u,p=a*d,x=a*f,y=o*d,b=o*f,v=l*f,E=c*u,w=c*d,N=c*f,A=r.x,C=r.y,T=r.z;return i[0]=(1-(y+v))*A,i[1]=(p+N)*A,i[2]=(x-w)*A,i[3]=0,i[4]=(p-N)*C,i[5]=(1-(g+v))*C,i[6]=(b+E)*C,i[7]=0,i[8]=(x+w)*T,i[9]=(b-E)*T,i[10]=(1-(g+y))*T,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=Sm.set(i[0],i[1],i[2]).length();const o=Sm.set(i[4],i[5],i[6]).length(),l=Sm.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],Co.copy(this);const u=1/a,d=1/o,f=1/l;return Co.elements[0]*=u,Co.elements[1]*=u,Co.elements[2]*=u,Co.elements[4]*=d,Co.elements[5]*=d,Co.elements[6]*=d,Co.elements[8]*=f,Co.elements[9]*=f,Co.elements[10]*=f,n.setFromRotationMatrix(Co),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=bl,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),g=(n+e)/(n-e),p=(r+i)/(r-i);let x,y;if(c)x=a/(o-a),y=o*a/(o-a);else if(l===bl)x=-(o+a)/(o-a),y=-2*o*a/(o-a);else if(l===Qw)x=-o/(o-a),y=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=g,u[12]=0,u[1]=0,u[5]=f,u[9]=p,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=y,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=bl,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),g=-(n+e)/(n-e),p=-(r+i)/(r-i);let x,y;if(c)x=1/(o-a),y=o/(o-a);else if(l===bl)x=-2/(o-a),y=-(o+a)/(o-a);else if(l===Qw)x=-1/(o-a),y=-a/(o-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=0,u[12]=g,u[1]=0,u[5]=f,u[9]=0,u[13]=p,u[2]=0,u[6]=0,u[10]=x,u[14]=y,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 Sm=new at,Co=new pi,zke=new at(0,0,0),Bke=new at(1,1,1),Ru=new at,i_=new at,ws=new at,jH=new pi,RH=new bf;let Rd=class XZ{constructor(e=0,n=0,r=0,i=XZ.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],o=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(An(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-An(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(An(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-An(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(-o,u));break;case"YZX":this._z=Math.asin(An(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(-An(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:an("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return jH.makeRotationFromQuaternion(e),this.setFromRotationMatrix(jH,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return RH.setFromEuler(this),this.setFromQuaternion(RH,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}};Rd.DEFAULT_ORDER="XYZ";let YZ=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}},Hke=0;const DH=new at,Mm=new bf,sc=new pi,a_=new at,Ix=new at,$ke=new at,Vke=new bf,OH=new at(1,0,0),LH=new at(0,1,0),IH=new at(0,0,1),FH={type:"added"},Gke={type:"removed"},Em={type:"childadded",child:null},JT={type:"childremoved",child:null};let Fs=class R1 extends jf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Hke++}),this.uuid=cy(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=R1.DEFAULT_UP.clone();const e=new at,n=new Rd,r=new bf,i=new at(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),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 pi},normalMatrix:{value:new vn}}),this.matrix=new pi,this.matrixWorld=new pi,this.matrixAutoUpdate=R1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=R1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new YZ,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 Mm.setFromAxisAngle(e,n),this.quaternion.multiply(Mm),this}rotateOnWorldAxis(e,n){return Mm.setFromAxisAngle(e,n),this.quaternion.premultiply(Mm),this}rotateX(e){return this.rotateOnAxis(OH,e)}rotateY(e){return this.rotateOnAxis(LH,e)}rotateZ(e){return this.rotateOnAxis(IH,e)}translateOnAxis(e,n){return DH.copy(e).applyQuaternion(this.quaternion),this.position.add(DH.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(OH,e)}translateY(e){return this.translateOnAxis(LH,e)}translateZ(e){return this.translateOnAxis(IH,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(sc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?a_.copy(e):a_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Ix.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?sc.lookAt(Ix,a_,this.up):sc.lookAt(a_,Ix,this.up),this.quaternion.setFromRotationMatrix(sc),i&&(sc.extractRotation(i.matrixWorld),Mm.setFromRotationMatrix(sc),this.quaternion.premultiply(Mm.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(ti("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(FH),Em.child=e,this.dispatchEvent(Em),Em.child=null):ti("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(Gke),JT.child=e,this.dispatchEvent(JT),JT.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),sc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),sc.multiply(e.parent.matrixWorld)),e.applyMatrix4(sc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(FH),Em.child=e,this.dispatchEvent(Em),Em.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 o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,o=i.length;a<o;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(Ix,e,$ke),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ix,Vke,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,o=i.length;a<o;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=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=o(e.shapes),g=o(e.skeletons),p=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(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}};Fs.DEFAULT_UP=new at(0,1,0);Fs.DEFAULT_MATRIX_AUTO_UPDATE=!0;Fs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const ko=new at,oc=new at,eC=new at,lc=new at,Am=new at,Nm=new at,UH=new at,tC=new at,nC=new at,rC=new at,iC=new di,aC=new di,sC=new di;let Fx=class rp{constructor(e=new at,n=new at,r=new at){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),ko.subVectors(e,n),i.cross(ko);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){ko.subVectors(i,n),oc.subVectors(r,n),eC.subVectors(e,n);const o=ko.dot(ko),l=ko.dot(oc),c=ko.dot(eC),u=oc.dot(oc),d=oc.dot(eC),f=o*u-l*l;if(f===0)return a.set(0,0,0),null;const g=1/f,p=(u*c-l*d)*g,x=(o*d-l*c)*g;return a.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,lc)===null?!1:lc.x>=0&&lc.y>=0&&lc.x+lc.y<=1}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,lc)===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,lc.x),c.addScaledVector(o,lc.y),c.addScaledVector(l,lc.z),c)}static getInterpolatedAttribute(e,n,r,i,a,o){return iC.setScalar(0),aC.setScalar(0),sC.setScalar(0),iC.fromBufferAttribute(e,n),aC.fromBufferAttribute(e,r),sC.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(iC,a.x),o.addScaledVector(aC,a.y),o.addScaledVector(sC,a.z),o}static isFrontFacing(e,n,r,i){return ko.subVectors(r,n),oc.subVectors(e,n),ko.cross(oc).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 ko.subVectors(this.c,this.b),oc.subVectors(this.a,this.b),ko.cross(oc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return rp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return rp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return rp.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return rp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return rp.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 o,l;Am.subVectors(i,r),Nm.subVectors(a,r),tC.subVectors(e,r);const c=Am.dot(tC),u=Nm.dot(tC);if(c<=0&&u<=0)return n.copy(r);nC.subVectors(e,i);const d=Am.dot(nC),f=Nm.dot(nC);if(d>=0&&f<=d)return n.copy(i);const g=c*f-d*u;if(g<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Am,o);rC.subVectors(e,a);const p=Am.dot(rC),x=Nm.dot(rC);if(x>=0&&p<=x)return n.copy(a);const y=p*u-c*x;if(y<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Nm,l);const b=d*x-p*f;if(b<=0&&f-d>=0&&p-x>=0)return UH.subVectors(a,i),l=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(UH,l);const v=1/(b+y+g);return o=y*v,l=g*v,n.copy(r).addScaledVector(Am,o).addScaledVector(Nm,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const ZZ={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},Du={h:0,s:0,l:0},s_={h:0,s:0,l:0};function oC(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=no){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Un.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Un.workingColorSpace){return this.r=e,this.g=n,this.b=r,Un.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Un.workingColorSpace){if(e=Pke(e,1),n=An(n,0,1),r=An(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=oC(o,a,e+1/3),this.g=oC(o,a,e),this.b=oC(o,a,e-1/3)}return Un.colorSpaceToWorking(this,i),this}setStyle(e,n=no){function r(a){a!==void 0&&parseFloat(a)<1&&an("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const o=i[1],l=i[2];switch(o){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:an("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],o=a.length;if(o===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(a,16),n);an("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=no){const r=ZZ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):an("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=Uc(e.r),this.g=Uc(e.g),this.b=Uc(e.b),this}copyLinearToSRGB(e){return this.r=wp(e.r),this.g=wp(e.g),this.b=wp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=no){return Un.workingToColorSpace(ga.copy(this),e),Math.round(An(ga.r*255,0,255))*65536+Math.round(An(ga.g*255,0,255))*256+Math.round(An(ga.b*255,0,255))}getHexString(e=no){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Un.workingColorSpace){Un.workingToColorSpace(ga.copy(this),n);const r=ga.r,i=ga.g,a=ga.b,o=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){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=Un.workingColorSpace){return Un.workingToColorSpace(ga.copy(this),n),e.r=ga.r,e.g=ga.g,e.b=ga.b,e}getStyle(e=no){Un.workingToColorSpace(ga.copy(this),e);const n=ga.r,r=ga.g,i=ga.b;return e!==no?`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(Du),this.setHSL(Du.h+e,Du.s+n,Du.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(Du),e.getHSL(s_);const r=$T(Du.h,s_.h,n),i=$T(Du.s,s_.s,n),a=$T(Du.l,s_.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 Nn;Nn.NAMES=ZZ;let Wke=0,Ag=class extends jf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Wke++}),this.uuid=cy(),this.name="",this.type="Material",this.blending=_p,this.side=jd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=pP,this.blendDst=gP,this.blendEquation=Eh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Nn(0,0,0),this.blendAlpha=0,this.depthFunc=Vp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=MH,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=bm,this.stencilZFail=bm,this.stencilZPass=bm,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){an(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){an(`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!==_p&&(r.blending=this.blending),this.side!==jd&&(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!==pP&&(r.blendSrc=this.blendSrc),this.blendDst!==gP&&(r.blendDst=this.blendDst),this.blendEquation!==Eh&&(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!==Vp&&(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!==MH&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==bm&&(r.stencilFail=this.stencilFail),this.stencilZFail!==bm&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==bm&&(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 o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(n){const a=i(e.textures),o=i(e.images);a.length>0&&(r.textures=a),o.length>0&&(r.images=o)}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++}},HO=class extends Ag{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 Rd,this.combine=jO,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 oi=new at,o_=new bn;let qke=0,po=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:qke++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=EH,this.updateRanges=[],this.gpuType=jc,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++)o_.fromBufferAttribute(this,n),o_.applyMatrix3(e),this.setXY(n,o_.x,o_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)oi.fromBufferAttribute(this,n),oi.applyMatrix3(e),this.setXYZ(n,oi.x,oi.y,oi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)oi.fromBufferAttribute(this,n),oi.applyMatrix4(e),this.setXYZ(n,oi.x,oi.y,oi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)oi.fromBufferAttribute(this,n),oi.applyNormalMatrix(e),this.setXYZ(n,oi.x,oi.y,oi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)oi.fromBufferAttribute(this,n),oi.transformDirection(e),this.setXYZ(n,oi.x,oi.y,oi.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=Dx(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Qa(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Dx(n,this.array)),n}setX(e,n){return this.normalized&&(n=Qa(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Dx(n,this.array)),n}setY(e,n){return this.normalized&&(n=Qa(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=Dx(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Qa(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=Dx(n,this.array)),n}setW(e,n){return this.normalized&&(n=Qa(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Qa(n,this.array),r=Qa(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=Qa(n,this.array),r=Qa(r,this.array),i=Qa(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=Qa(n,this.array),r=Qa(r,this.array),i=Qa(i,this.array),a=Qa(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!==EH&&(e.usage=this.usage),e}},QZ=class extends po{constructor(e,n,r){super(new Uint16Array(e),n,r)}},JZ=class extends po{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Vo=class extends po{constructor(e,n,r){super(new Float32Array(e),n,r)}},Kke=0;const Xs=new pi,lC=new Fs,Tm=new at,Ss=new vf,Ux=new vf,Ui=new at;let Ul=class eQ extends jf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Kke++}),this.uuid=cy(),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($Z(e)?JZ:QZ)(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 Xs.makeRotationFromQuaternion(e),this.applyMatrix4(Xs),this}rotateX(e){return Xs.makeRotationX(e),this.applyMatrix4(Xs),this}rotateY(e){return Xs.makeRotationY(e),this.applyMatrix4(Xs),this}rotateZ(e){return Xs.makeRotationZ(e),this.applyMatrix4(Xs),this}translate(e,n,r){return Xs.makeTranslation(e,n,r),this.applyMatrix4(Xs),this}scale(e,n,r){return Xs.makeScale(e,n,r),this.applyMatrix4(Xs),this}lookAt(e){return lC.lookAt(e),lC.updateMatrix(),this.applyMatrix4(lC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Tm).negate(),this.translate(Tm.x,Tm.y,Tm.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 o=e[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Vo(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&&an("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 vf);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ti("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new at(-1/0,-1/0,-1/0),new at(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];Ss.setFromBufferAttribute(a),this.morphTargetsRelative?(Ui.addVectors(this.boundingBox.min,Ss.min),this.boundingBox.expandByPoint(Ui),Ui.addVectors(this.boundingBox.max,Ss.max),this.boundingBox.expandByPoint(Ui)):(this.boundingBox.expandByPoint(Ss.min),this.boundingBox.expandByPoint(Ss.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ti('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 c2);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ti("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new at,1/0);return}if(e){const r=this.boundingSphere.center;if(Ss.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];Ux.setFromBufferAttribute(l),this.morphTargetsRelative?(Ui.addVectors(Ss.min,Ux.min),Ss.expandByPoint(Ui),Ui.addVectors(Ss.max,Ux.max),Ss.expandByPoint(Ui)):(Ss.expandByPoint(Ux.min),Ss.expandByPoint(Ux.max))}Ss.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Ui.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Ui));if(n)for(let a=0,o=n.length;a<o;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)Ui.fromBufferAttribute(l,u),c&&(Tm.fromBufferAttribute(e,u),Ui.add(Tm)),i=Math.max(i,r.distanceToSquared(Ui))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&ti('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){ti("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 po(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let L=0;L<r.count;L++)l[L]=new at,c[L]=new at;const u=new at,d=new at,f=new at,g=new bn,p=new bn,x=new bn,y=new at,b=new at;function v(L,k,D){u.fromBufferAttribute(r,L),d.fromBufferAttribute(r,k),f.fromBufferAttribute(r,D),g.fromBufferAttribute(a,L),p.fromBufferAttribute(a,k),x.fromBufferAttribute(a,D),d.sub(u),f.sub(u),p.sub(g),x.sub(g);const U=1/(p.x*x.y-x.x*p.y);isFinite(U)&&(y.copy(d).multiplyScalar(x.y).addScaledVector(f,-p.y).multiplyScalar(U),b.copy(f).multiplyScalar(p.x).addScaledVector(d,-x.x).multiplyScalar(U),l[L].add(y),l[k].add(y),l[D].add(y),c[L].add(b),c[k].add(b),c[D].add(b))}let E=this.groups;E.length===0&&(E=[{start:0,count:e.count}]);for(let L=0,k=E.length;L<k;++L){const D=E[L],U=D.start,O=D.count;for(let q=U,R=U+O;q<R;q+=3)v(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const w=new at,N=new at,A=new at,C=new at;function T(L){A.fromBufferAttribute(i,L),C.copy(A);const k=l[L];w.copy(k),w.sub(A.multiplyScalar(A.dot(k))).normalize(),N.crossVectors(C,k);const U=N.dot(c[L])<0?-1:1;o.setXYZW(L,w.x,w.y,w.z,U)}for(let L=0,k=E.length;L<k;++L){const D=E[L],U=D.start,O=D.count;for(let q=U,R=U+O;q<R;q+=3)T(e.getX(q+0)),T(e.getX(q+1)),T(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 po(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,p=r.count;g<p;g++)r.setXYZ(g,0,0,0);const i=new at,a=new at,o=new at,l=new at,c=new at,u=new at,d=new at,f=new at;if(e)for(let g=0,p=e.count;g<p;g+=3){const x=e.getX(g+0),y=e.getX(g+1),b=e.getX(g+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,y),o.fromBufferAttribute(n,b),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,b),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(b,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),o.fromBufferAttribute(n,g+2),d.subVectors(o,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++)Ui.fromBufferAttribute(e,n),Ui.normalize(),e.setXYZ(n,Ui.x,Ui.y,Ui.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,g=new u.constructor(c.length*d);let p=0,x=0;for(let y=0,b=c.length;y<b;y++){l.isInterleavedBufferAttribute?p=c[y]*l.data.stride+l.offset:p=c[y]*d;for(let v=0;v<d;v++)g[x++]=u[p++]}return new po(g,d,f)}if(this.index===null)return an("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new eQ,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 o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[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 o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));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 o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[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 zH=new pi,uh=new BO,l_=new c2,BH=new at,c_=new at,u_=new at,d_=new at,cC=new at,h_=new at,HH=new at,f_=new at;let kl=class extends Fs{constructor(e=new Ul,n=new HO){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,o=i.length;a<o;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,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){h_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(cC.fromBufferAttribute(f,e),o?h_.addScaledVector(cC,d):h_.addScaledVector(cC.sub(n),d))}n.add(h_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),l_.copy(r.boundingSphere),l_.applyMatrix4(a),uh.copy(e.ray).recast(e.near),!(l_.containsPoint(uh.origin)===!1&&(uh.intersectSphere(l_,BH)===null||uh.origin.distanceToSquared(BH)>(e.far-e.near)**2))&&(zH.copy(a).invert(),uh.copy(e.ray).applyMatrix4(zH),!(r.boundingBox!==null&&uh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,uh)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=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(o))for(let x=0,y=g.length;x<y;x++){const b=g[x],v=o[b.materialIndex],E=Math.max(b.start,p.start),w=Math.min(l.count,Math.min(b.start+b.count,p.start+p.count));for(let N=E,A=w;N<A;N+=3){const C=l.getX(N),T=l.getX(N+1),L=l.getX(N+2);i=m_(this,v,e,r,u,d,f,C,T,L),i&&(i.faceIndex=Math.floor(N/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let b=x,v=y;b<v;b+=3){const E=l.getX(b),w=l.getX(b+1),N=l.getX(b+2);i=m_(this,o,e,r,u,d,f,E,w,N),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,y=g.length;x<y;x++){const b=g[x],v=o[b.materialIndex],E=Math.max(b.start,p.start),w=Math.min(c.count,Math.min(b.start+b.count,p.start+p.count));for(let N=E,A=w;N<A;N+=3){const C=N,T=N+1,L=N+2;i=m_(this,v,e,r,u,d,f,C,T,L),i&&(i.faceIndex=Math.floor(N/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),y=Math.min(c.count,p.start+p.count);for(let b=x,v=y;b<v;b+=3){const E=b,w=b+1,N=b+2;i=m_(this,o,e,r,u,d,f,E,w,N),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}};function Xke(t,e,n,r,i,a,o,l){let c;if(e.side===ss?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===jd,l),c===null)return null;f_.copy(l),f_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(f_);return u<n.near||u>n.far?null:{distance:u,point:f_.clone(),object:t}}function m_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,c_),t.getVertexPosition(c,u_),t.getVertexPosition(u,d_);const d=Xke(t,e,n,r,c_,u_,d_,HH);if(d){const f=new at;Fx.getBarycoord(HH,c_,u_,d_,f),i&&(d.uv=Fx.getInterpolatedAttribute(i,l,c,u,f,new bn)),a&&(d.uv1=Fx.getInterpolatedAttribute(a,l,c,u,f,new bn)),o&&(d.normal=Fx.getInterpolatedAttribute(o,l,c,u,f,new at),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const g={a:l,b:c,c:u,normal:new at,materialIndex:0};Fx.getNormal(c_,u_,d_,g.normal),d.face=g,d.barycoord=f}return d}let $O=class tQ extends Ul{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let g=0,p=0;x("z","y","x",-1,-1,r,n,e,o,a,0),x("z","y","x",1,-1,r,n,-e,o,a,1),x("x","z","y",1,1,e,r,n,i,o,2),x("x","z","y",1,-1,e,r,-n,i,o,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Vo(u,3)),this.setAttribute("normal",new Vo(d,3)),this.setAttribute("uv",new Vo(f,2));function x(y,b,v,E,w,N,A,C,T,L,k){const D=N/T,U=A/L,O=N/2,q=A/2,R=C/2,G=T+1,Y=L+1;let V=0,K=0;const J=new at;for(let X=0;X<Y;X++){const F=X*U-q;for(let W=0;W<G;W++){const ee=W*D-O;J[y]=ee*E,J[b]=F*w,J[v]=R,u.push(J.x,J.y,J.z),J[y]=0,J[b]=0,J[v]=C>0?1:-1,d.push(J.x,J.y,J.z),f.push(W/T),f.push(1-X/L),V+=1}}for(let X=0;X<L;X++)for(let F=0;F<T;F++){const W=g+F+G*X,ee=g+F+G*(X+1),ie=g+(F+1)+G*(X+1),ae=g+(F+1)+G*X;c.push(W,ee,ae),c.push(ee,ie,ae),K+=6}l.addGroup(p,K,k),p+=K,g+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new tQ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Kp(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?(an("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 ja(t){const e={};for(let n=0;n<t.length;n++){const r=Kp(t[n]);for(const i in r)e[i]=r[i]}return e}function Yke(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function nQ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Un.workingColorSpace}const Zke={clone:Kp,merge:ja};var Qke=`void main() {
  91. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  92. }`,Jke=`void main() {
  93. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  94. }`;let Jc=class extends Ag{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Qke,this.fragmentShader=Jke,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=Kp(e.uniforms),this.uniformsGroups=Yke(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 o=this.uniforms[i].value;o&&o.isTexture?n.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?n.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?n.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?n.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?n.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?n.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?n.uniforms[i]={type:"m4",value:o.toArray()}:n.uniforms[i]={value:o}}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}},rQ=class extends Fs{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new pi,this.projectionMatrix=new pi,this.projectionMatrixInverse=new pi,this.coordinateSystem=bl,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 Ou=new at,$H=new bn,VH=new bn;let ao=class extends rQ{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=nj*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(P1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return nj*2*Math.atan(Math.tan(P1*.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){Ou.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ou.x,Ou.y).multiplyScalar(-e/Ou.z),Ou.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Ou.x,Ou.y).multiplyScalar(-e/Ou.z)}getViewSize(e,n){return this.getViewBounds(e,$H,VH),n.subVectors(VH,$H)}setViewOffset(e,n,r,i,a,o){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=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(P1*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;a+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.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 Cm=-90,km=1;let e3e=class extends Fs{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ao(Cm,km,e,n);i.layers=this.layers,this.add(i);const a=new ao(Cm,km,e,n);a.layers=this.layers,this.add(a);const o=new ao(Cm,km,e,n);o.layers=this.layers,this.add(o);const l=new ao(Cm,km,e,n);l.layers=this.layers,this.add(l);const c=new ao(Cm,km,e,n);c.layers=this.layers,this.add(c);const u=new ao(Cm,km,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,o,l,c]=n;for(const u of n)this.remove(u);if(e===bl)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),o.up.set(0,0,1),o.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),o.up.set(0,0,-1),o.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,o,l,c,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,o),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=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},iQ=class extends Jo{constructor(e=[],n=Gp,r,i,a,o,l,c,u,d){super(e,n,r,i,a,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},t3e=class extends yf{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 iQ(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 $O(5,5,5),a=new Jc({name:"CubemapFromEquirect",uniforms:Kp(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ss,blending:Fc});a.uniforms.tEquirect.value=n;const o=new kl(i,a),l=n.minFilter;return n.minFilter===Oh&&(n.minFilter=ho),new e3e(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const a=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(a)}},t0=class extends Fs{constructor(){super(),this.isGroup=!0,this.type="Group"}};const n3e={type:"move"};let uC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new t0,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 t0,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new at,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new at),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new t0,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new at,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new at),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const y of e.hand.values()){const b=n.getJointPose(y,r),v=this._getHandJoint(u,y);b!==null&&(v.matrix.fromArray(b.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=b.radius),v.visible=b!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&g>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(n3e)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new t0;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},r3e=class extends Fs{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 Rd,this.environmentIntensity=1,this.environmentRotation=new Rd,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}},i3e=class extends Jo{constructor(e=null,n=1,r=1,i,a,o,l,c,u=Rs,d=Rs,f,g){super(null,o,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 dC=new at,a3e=new at,s3e=new vn;let Ku=class{constructor(e=new at(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=dC.subVectors(r,n).cross(a3e.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n){const r=e.delta(dC),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||s3e.getNormalMatrix(e),i=this.coplanarPoint(dC).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const dh=new c2,o3e=new bn(.5,.5),p_=new at;let VO=class{constructor(e=new Ku,n=new Ku,r=new Ku,i=new Ku,a=new Ku,o=new Ku){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,o){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(o),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=bl,r=!1){const i=this.planes,a=e.elements,o=a[0],l=a[1],c=a[2],u=a[3],d=a[4],f=a[5],g=a[6],p=a[7],x=a[8],y=a[9],b=a[10],v=a[11],E=a[12],w=a[13],N=a[14],A=a[15];if(i[0].setComponents(u-o,p-d,v-x,A-E).normalize(),i[1].setComponents(u+o,p+d,v+x,A+E).normalize(),i[2].setComponents(u+l,p+f,v+y,A+w).normalize(),i[3].setComponents(u-l,p-f,v-y,A-w).normalize(),r)i[4].setComponents(c,g,b,N).normalize(),i[5].setComponents(u-c,p-g,v-b,A-N).normalize();else if(i[4].setComponents(u-c,p-g,v-b,A-N).normalize(),n===bl)i[5].setComponents(u+c,p+g,v+b,A+N).normalize();else if(n===Qw)i[5].setComponents(c,g,b,N).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(),dh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),dh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(dh)}intersectsSprite(e){dh.center.set(0,0,0);const n=o3e.distanceTo(e.center);return dh.radius=.7071067811865476+n,dh.applyMatrix4(e.matrixWorld),this.intersectsSphere(dh)}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(p_.x=i.normal.x>0?e.max.x:e.min.x,p_.y=i.normal.y>0?e.max.y:e.min.y,p_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(p_)<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)}},aQ=class extends Ag{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 eS=new at,tS=new at,GH=new pi,zx=new BO,g_=new c2,hC=new at,WH=new at;let l3e=class extends Fs{constructor(e=new Ul,n=new aQ){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++)eS.fromBufferAttribute(n,i-1),tS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=eS.distanceTo(tS);e.setAttribute("lineDistance",new Vo(r,1))}else an("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,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),g_.copy(r.boundingSphere),g_.applyMatrix4(i),g_.radius+=a,e.ray.intersectsSphere(g_)===!1)return;GH.copy(i).invert(),zx.copy(e.ray).applyMatrix4(GH);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,o.start),x=Math.min(d.count,o.start+o.count);for(let y=p,b=x-1;y<b;y+=u){const v=d.getX(y),E=d.getX(y+1),w=x_(this,e,zx,c,v,E,y);w&&n.push(w)}if(this.isLineLoop){const y=d.getX(x-1),b=d.getX(p),v=x_(this,e,zx,c,y,b,x-1);v&&n.push(v)}}else{const p=Math.max(0,o.start),x=Math.min(g.count,o.start+o.count);for(let y=p,b=x-1;y<b;y+=u){const v=x_(this,e,zx,c,y,y+1,y);v&&n.push(v)}if(this.isLineLoop){const y=x_(this,e,zx,c,x-1,p,x-1);y&&n.push(y)}}}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,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}};function x_(t,e,n,r,i,a,o){const l=t.geometry.attributes.position;if(eS.fromBufferAttribute(l,i),tS.fromBufferAttribute(l,a),n.distanceSqToSegment(eS,tS,hC,WH)>r)return;hC.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(hC);if(!(u<e.near||u>e.far))return{distance:u,point:WH.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const qH=new at,KH=new at;let c3e=class extends l3e{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)qH.fromBufferAttribute(n,i),KH.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+qH.distanceTo(KH);e.setAttribute("lineDistance",new Vo(r,1))}else an("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},sQ=class extends Jo{constructor(e,n,r=xf,i,a,o,l=Rs,c=Rs,u,d=sb,f=1){if(d!==sb&&d!==ob)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,o,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 zO(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 oQ extends Jo{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let GO=class lQ extends Ul{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,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,g=n/c,p=[],x=[],y=[],b=[];for(let v=0;v<d;v++){const E=v*g-o;for(let w=0;w<u;w++){const N=w*f-a;x.push(N,-E,0),y.push(0,0,1),b.push(w/l),b.push(1-v/c)}}for(let v=0;v<c;v++)for(let E=0;E<l;E++){const w=E+u*v,N=E+u*(v+1),A=E+1+u*(v+1),C=E+1+u*v;p.push(w,N,C),p.push(N,A,C)}this.setIndex(p),this.setAttribute("position",new Vo(x,3)),this.setAttribute("normal",new Vo(y,3)),this.setAttribute("uv",new Vo(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new lQ(e.width,e.height,e.widthSegments,e.heightSegments)}};class u3e extends Ag{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=BZ,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 Rd,this.combine=jO,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 d3e=class extends Ag{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=yke,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}},h3e=class extends Ag{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}},cQ=class extends Fs{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 fC=new pi,XH=new at,YH=new at;let f3e=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=Cl,this.map=null,this.mapPass=null,this.matrix=new pi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new VO,this._frameExtents=new bn(1,1),this._viewportCount=1,this._viewports=[new di(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;XH.setFromMatrixPosition(e.matrixWorld),n.position.copy(XH),YH.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(YH),n.updateMatrixWorld(),fC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(fC,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(fC)}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}},uQ=class extends rQ{constructor(e=-1,n=1,r=1,i=-1,a=.1,o=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=o,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,o){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=o,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,o=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,o=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,o,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 m3e extends f3e{constructor(){super(new uQ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class ZH extends cQ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Fs.DEFAULT_UP),this.updateMatrix(),this.target=new Fs,this.shadow=new m3e}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let p3e=class extends cQ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},g3e=class extends ao{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=An(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(An(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class x3e extends c3e{constructor(e=10,n=10,r=4473924,i=8947848){r=new Nn(r),i=new Nn(i);const a=n/2,o=e/n,l=e/2,c=[],u=[];for(let g=0,p=0,x=-l;g<=n;g++,x+=o){c.push(-l,0,x,l,0,x),c.push(x,0,-l,x,0,l);const y=g===a?r:i;y.toArray(u,p),p+=3,y.toArray(u,p),p+=3,y.toArray(u,p),p+=3,y.toArray(u,p),p+=3}const d=new Ul;d.setAttribute("position",new Vo(c,3)),d.setAttribute("color",new Vo(u,3));const f=new aQ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class b3e extends jf{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){an("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function JH(t,e,n,r){const i=y3e(r);switch(n){case FZ:return t*e;case zZ:return t*e/i.components*i.byteLength;case LO:return t*e/i.components*i.byteLength;case IO:return t*e*2/i.components*i.byteLength;case FO:return t*e*2/i.components*i.byteLength;case UZ:return t*e*3/i.components*i.byteLength;case zo:return t*e*4/i.components*i.byteLength;case UO:return t*e*4/i.components*i.byteLength;case N1:case T1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case C1:case k1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case CP:case PP:return Math.max(t,16)*Math.max(e,8)/4;case TP:case kP:return Math.max(t,8)*Math.max(e,8)/2;case jP:case RP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case DP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case OP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case LP:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case IP:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case FP:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case UP:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case zP:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case BP:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case HP:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case $P:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case VP:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case GP:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case WP:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case qP:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case KP:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case XP:case YP:case ZP:return Math.ceil(t/4)*Math.ceil(e/4)*16;case QP:case JP:return Math.ceil(t/4)*Math.ceil(e/4)*8;case ej:case tj:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function y3e(t){switch(t){case Cl:case DZ:return{byteLength:1,components:1};case ib:case OZ:case Eg:return{byteLength:2,components:1};case DO:case OO:return{byteLength:2,components:4};case xf:case RO:case jc:return{byteLength:4,components:1};case LZ:case IZ:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:PO}}));typeof window<"u"&&(window.__THREE__?an("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=PO);function dQ(){let t=null,e=!1,n=null,r=null;function i(a,o){n(a,o),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 v3e(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,f=u.byteLength,g=t.createBuffer();t.bindBuffer(c,g),t.bufferData(c,u,d),l.onUploadCallback();let p;if(u instanceof Float32Array)p=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)p=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?p=t.HALF_FLOAT:p=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)p=t.SHORT;else if(u instanceof Uint32Array)p=t.UNSIGNED_INT;else if(u instanceof Int32Array)p=t.INT;else if(u instanceof Int8Array)p=t.BYTE;else if(u instanceof Uint8Array)p=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)p=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:g,type:p,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version,size:f}}function r(l,c,u){const d=c.array,f=c.updateRanges;if(t.bindBuffer(u,l),f.length===0)t.bufferSubData(u,0,d);else{f.sort((p,x)=>p.start-x.start);let g=0;for(let p=1;p<f.length;p++){const x=f[g],y=f[p];y.start<=x.start+x.count+1?x.count=Math.max(x.count,y.start+y.count-x.start):(++g,f[g]=y)}f.length=g+1;for(let p=0,x=f.length;p<x;p++){const y=f[p];t.bufferSubData(u,y.start*d.BYTES_PER_ELEMENT,d,y.start,y.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 o(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:o}}var _3e=`#ifdef USE_ALPHAHASH
  114. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  115. #endif`,w3e=`#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`,S3e=`#ifdef USE_ALPHAMAP
  151. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  152. #endif`,M3e=`#ifdef USE_ALPHAMAP
  153. uniform sampler2D alphaMap;
  154. #endif`,E3e=`#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`,A3e=`#ifdef USE_ALPHATEST
  162. uniform float alphaTest;
  163. #endif`,N3e=`#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`,T3e=`#ifdef USE_AOMAP
  177. uniform sampler2D aoMap;
  178. uniform float aoMapIntensity;
  179. #endif`,C3e=`#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`,k3e=`#ifdef USE_BATCHING
  214. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  215. #endif`,P3e=`vec3 transformed = vec3( position );
  216. #ifdef USE_ALPHAHASH
  217. vPosition = vec3( position );
  218. #endif`,j3e=`vec3 objectNormal = vec3( normal );
  219. #ifdef USE_TANGENT
  220. vec3 objectTangent = vec3( tangent.xyz );
  221. #endif`,R3e=`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`,D3e=`#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`,O3e=`#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`,L3e=`#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`,I3e=`#if NUM_CLIPPING_PLANES > 0
  366. varying vec3 vClipPosition;
  367. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  368. #endif`,F3e=`#if NUM_CLIPPING_PLANES > 0
  369. varying vec3 vClipPosition;
  370. #endif`,U3e=`#if NUM_CLIPPING_PLANES > 0
  371. vClipPosition = - mvPosition.xyz;
  372. #endif`,z3e=`#if defined( USE_COLOR_ALPHA )
  373. diffuseColor *= vColor;
  374. #elif defined( USE_COLOR )
  375. diffuseColor.rgb *= vColor;
  376. #endif`,B3e=`#if defined( USE_COLOR_ALPHA )
  377. varying vec4 vColor;
  378. #elif defined( USE_COLOR )
  379. varying vec3 vColor;
  380. #endif`,H3e=`#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`,$3e=`#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`,V3e=`#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`,G3e=`#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`,W3e=`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`,q3e=`#ifdef USE_DISPLACEMENTMAP
  588. uniform sampler2D displacementMap;
  589. uniform float displacementScale;
  590. uniform float displacementBias;
  591. #endif`,K3e=`#ifdef USE_DISPLACEMENTMAP
  592. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  593. #endif`,X3e=`#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`,Y3e=`#ifdef USE_EMISSIVEMAP
  600. uniform sampler2D emissiveMap;
  601. #endif`,Z3e="gl_FragColor = linearToOutputTexel( gl_FragColor );",Q3e=`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. }`,J3e=`#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`,ePe=`#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`,tPe=`#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`,nPe=`#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`,rPe=`#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`,iPe=`#ifdef USE_FOG
  686. vFogDepth = - mvPosition.z;
  687. #endif`,aPe=`#ifdef USE_FOG
  688. varying float vFogDepth;
  689. #endif`,sPe=`#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`,oPe=`#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`,lPe=`#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. }`,cPe=`#ifdef USE_LIGHTMAP
  718. uniform sampler2D lightMap;
  719. uniform float lightMapIntensity;
  720. #endif`,uPe=`LambertMaterial material;
  721. material.diffuseColor = diffuseColor.rgb;
  722. material.specularStrength = specularStrength;`,dPe=`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`,hPe=`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`,fPe=`#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`,mPe=`ToonMaterial material;
  886. material.diffuseColor = diffuseColor.rgb;`,pPe=`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`,gPe=`BlinnPhongMaterial material;
  899. material.diffuseColor = diffuseColor.rgb;
  900. material.specularColor = specular;
  901. material.specularShininess = shininess;
  902. material.specularStrength = specularStrength;`,xPe=`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`,bPe=`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`,yPe=`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. }`,vPe=`
  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`,_Pe=`#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`,wPe=`#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`,SPe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1461. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1462. #endif`,MPe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1463. uniform float logDepthBufFC;
  1464. varying float vFragDepth;
  1465. varying float vIsPerspective;
  1466. #endif`,EPe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1467. varying float vFragDepth;
  1468. varying float vIsPerspective;
  1469. #endif`,APe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1470. vFragDepth = 1.0 + gl_Position.w;
  1471. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1472. #endif`,NPe=`#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`,TPe=`#ifdef USE_MAP
  1479. uniform sampler2D map;
  1480. #endif`,CPe=`#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`,kPe=`#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`,PPe=`float metalnessFactor = metalness;
  1505. #ifdef USE_METALNESSMAP
  1506. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1507. metalnessFactor *= texelMetalness.b;
  1508. #endif`,jPe=`#ifdef USE_METALNESSMAP
  1509. uniform sampler2D metalnessMap;
  1510. #endif`,RPe=`#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`,DPe=`#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`,OPe=`#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`,LPe=`#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`,IPe=`#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`,FPe=`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;`,UPe=`#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`,zPe=`#ifndef FLAT_SHADED
  1606. varying vec3 vNormal;
  1607. #ifdef USE_TANGENT
  1608. varying vec3 vTangent;
  1609. varying vec3 vBitangent;
  1610. #endif
  1611. #endif`,BPe=`#ifndef FLAT_SHADED
  1612. varying vec3 vNormal;
  1613. #ifdef USE_TANGENT
  1614. varying vec3 vTangent;
  1615. varying vec3 vBitangent;
  1616. #endif
  1617. #endif`,HPe=`#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`,$Pe=`#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`,VPe=`#ifdef USE_CLEARCOAT
  1646. vec3 clearcoatNormal = nonPerturbedNormal;
  1647. #endif`,GPe=`#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`,WPe=`#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`,qPe=`#ifdef USE_IRIDESCENCEMAP
  1661. uniform sampler2D iridescenceMap;
  1662. #endif
  1663. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1664. uniform sampler2D iridescenceThicknessMap;
  1665. #endif`,KPe=`#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 );`,XPe=`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. }`,YPe=`#ifdef PREMULTIPLIED_ALPHA
  1741. gl_FragColor.rgb *= gl_FragColor.a;
  1742. #endif`,ZPe=`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;`,QPe=`#ifdef DITHERING
  1751. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1752. #endif`,JPe=`#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`,eje=`float roughnessFactor = roughness;
  1760. #ifdef USE_ROUGHNESSMAP
  1761. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1762. roughnessFactor *= texelRoughness.g;
  1763. #endif`,tje=`#ifdef USE_ROUGHNESSMAP
  1764. uniform sampler2D roughnessMap;
  1765. #endif`,nje=`#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`,rje=`#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`,ije=`#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`,aje=`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. }`,sje=`#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`,oje=`#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`,lje=`#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`,cje=`#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`,uje=`float specularStrength;
  2104. #ifdef USE_SPECULARMAP
  2105. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2106. specularStrength = texelSpecular.r;
  2107. #else
  2108. specularStrength = 1.0;
  2109. #endif`,dje=`#ifdef USE_SPECULARMAP
  2110. uniform sampler2D specularMap;
  2111. #endif`,hje=`#if defined( TONE_MAPPING )
  2112. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2113. #endif`,fje=`#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; }`,mje=`#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`,pje=`#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`,gje=`#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`,xje=`#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`,bje=`#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`,yje=`#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 vje=`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. }`,_je=`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. }`,wje=`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. }`,Sje=`#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. }`,Mje=`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. }`,Eje=`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. }`,Aje=`#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. }`,Nje=`#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. }`,Tje=`#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. }`,Cje=`#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. }`,kje=`varying vec3 vWorldDirection;
  2782. #include <common>
  2783. void main() {
  2784. vWorldDirection = transformDirection( position, modelMatrix );
  2785. #include <begin_vertex>
  2786. #include <project_vertex>
  2787. }`,Pje=`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. }`,jje=`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. }`,Rje=`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. }`,Dje=`#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. }`,Oje=`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. }`,Lje=`#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. }`,Ije=`#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. }`,Fje=`#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. }`,Uje=`#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. }`,zje=`#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. }`,Bje=`#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. }`,Hje=`#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. }`,$je=`#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. }`,Vje=`#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. }`,Gje=`#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. }`,Wje=`#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. }`,qje=`#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. }`,Kje=`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. }`,Xje=`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. }`,Yje=`#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. }`,Zje=`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. }`,Qje=`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. }`,Jje=`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:_3e,alphahash_pars_fragment:w3e,alphamap_fragment:S3e,alphamap_pars_fragment:M3e,alphatest_fragment:E3e,alphatest_pars_fragment:A3e,aomap_fragment:N3e,aomap_pars_fragment:T3e,batching_pars_vertex:C3e,batching_vertex:k3e,begin_vertex:P3e,beginnormal_vertex:j3e,bsdfs:R3e,iridescence_fragment:D3e,bumpmap_pars_fragment:O3e,clipping_planes_fragment:L3e,clipping_planes_pars_fragment:I3e,clipping_planes_pars_vertex:F3e,clipping_planes_vertex:U3e,color_fragment:z3e,color_pars_fragment:B3e,color_pars_vertex:H3e,color_vertex:$3e,common:V3e,cube_uv_reflection_fragment:G3e,defaultnormal_vertex:W3e,displacementmap_pars_vertex:q3e,displacementmap_vertex:K3e,emissivemap_fragment:X3e,emissivemap_pars_fragment:Y3e,colorspace_fragment:Z3e,colorspace_pars_fragment:Q3e,envmap_fragment:J3e,envmap_common_pars_fragment:ePe,envmap_pars_fragment:tPe,envmap_pars_vertex:nPe,envmap_physical_pars_fragment:fPe,envmap_vertex:rPe,fog_vertex:iPe,fog_pars_vertex:aPe,fog_fragment:sPe,fog_pars_fragment:oPe,gradientmap_pars_fragment:lPe,lightmap_pars_fragment:cPe,lights_lambert_fragment:uPe,lights_lambert_pars_fragment:dPe,lights_pars_begin:hPe,lights_toon_fragment:mPe,lights_toon_pars_fragment:pPe,lights_phong_fragment:gPe,lights_phong_pars_fragment:xPe,lights_physical_fragment:bPe,lights_physical_pars_fragment:yPe,lights_fragment_begin:vPe,lights_fragment_maps:_Pe,lights_fragment_end:wPe,logdepthbuf_fragment:SPe,logdepthbuf_pars_fragment:MPe,logdepthbuf_pars_vertex:EPe,logdepthbuf_vertex:APe,map_fragment:NPe,map_pars_fragment:TPe,map_particle_fragment:CPe,map_particle_pars_fragment:kPe,metalnessmap_fragment:PPe,metalnessmap_pars_fragment:jPe,morphinstance_vertex:RPe,morphcolor_vertex:DPe,morphnormal_vertex:OPe,morphtarget_pars_vertex:LPe,morphtarget_vertex:IPe,normal_fragment_begin:FPe,normal_fragment_maps:UPe,normal_pars_fragment:zPe,normal_pars_vertex:BPe,normal_vertex:HPe,normalmap_pars_fragment:$Pe,clearcoat_normal_fragment_begin:VPe,clearcoat_normal_fragment_maps:GPe,clearcoat_pars_fragment:WPe,iridescence_pars_fragment:qPe,opaque_fragment:KPe,packing:XPe,premultiplied_alpha_fragment:YPe,project_vertex:ZPe,dithering_fragment:QPe,dithering_pars_fragment:JPe,roughnessmap_fragment:eje,roughnessmap_pars_fragment:tje,shadowmap_pars_fragment:nje,shadowmap_pars_vertex:rje,shadowmap_vertex:ije,shadowmask_pars_fragment:aje,skinbase_vertex:sje,skinning_pars_vertex:oje,skinning_vertex:lje,skinnormal_vertex:cje,specularmap_fragment:uje,specularmap_pars_fragment:dje,tonemapping_fragment:hje,tonemapping_pars_fragment:fje,transmission_fragment:mje,transmission_pars_fragment:pje,uv_pars_fragment:gje,uv_pars_vertex:xje,uv_vertex:bje,worldpos_vertex:yje,background_vert:vje,background_frag:_je,backgroundCube_vert:wje,backgroundCube_frag:Sje,cube_vert:Mje,cube_frag:Eje,depth_vert:Aje,depth_frag:Nje,distanceRGBA_vert:Tje,distanceRGBA_frag:Cje,equirect_vert:kje,equirect_frag:Pje,linedashed_vert:jje,linedashed_frag:Rje,meshbasic_vert:Dje,meshbasic_frag:Oje,meshlambert_vert:Lje,meshlambert_frag:Ije,meshmatcap_vert:Fje,meshmatcap_frag:Uje,meshnormal_vert:zje,meshnormal_frag:Bje,meshphong_vert:Hje,meshphong_frag:$je,meshphysical_vert:Vje,meshphysical_frag:Gje,meshtoon_vert:Wje,meshtoon_frag:qje,points_vert:Kje,points_frag:Xje,shadow_vert:Yje,shadow_frag:Zje,sprite_vert:Qje,sprite_frag:Jje},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}}},fl={basic:{uniforms:ja([Pt.common,Pt.specularmap,Pt.envmap,Pt.aomap,Pt.lightmap,Pt.fog]),vertexShader:gn.meshbasic_vert,fragmentShader:gn.meshbasic_frag},lambert:{uniforms:ja([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:ja([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:ja([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:ja([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:ja([Pt.common,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,Pt.fog,{matcap:{value:null}}]),vertexShader:gn.meshmatcap_vert,fragmentShader:gn.meshmatcap_frag},points:{uniforms:ja([Pt.points,Pt.fog]),vertexShader:gn.points_vert,fragmentShader:gn.points_frag},dashed:{uniforms:ja([Pt.common,Pt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:gn.linedashed_vert,fragmentShader:gn.linedashed_frag},depth:{uniforms:ja([Pt.common,Pt.displacementmap]),vertexShader:gn.depth_vert,fragmentShader:gn.depth_frag},normal:{uniforms:ja([Pt.common,Pt.bumpmap,Pt.normalmap,Pt.displacementmap,{opacity:{value:1}}]),vertexShader:gn.meshnormal_vert,fragmentShader:gn.meshnormal_frag},sprite:{uniforms:ja([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:ja([Pt.common,Pt.displacementmap,{referencePosition:{value:new at},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:gn.distanceRGBA_vert,fragmentShader:gn.distanceRGBA_frag},shadow:{uniforms:ja([Pt.lights,Pt.fog,{color:{value:new Nn(0)},opacity:{value:1}}]),vertexShader:gn.shadow_vert,fragmentShader:gn.shadow_frag}};fl.physical={uniforms:ja([fl.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 b_={r:0,b:0,g:0},hh=new Rd,eRe=new pi;function tRe(t,e,n,r,i,a,o){const l=new Nn(0);let c=a===!0?0:1,u,d,f=null,g=0,p=null;function x(w){let N=w.isScene===!0?w.background:null;return N&&N.isTexture&&(N=(w.backgroundBlurriness>0?n:e).get(N)),N}function y(w){let N=!1;const A=x(w);A===null?v(l,c):A&&A.isColor&&(v(A,1),N=!0);const C=t.xr.getEnvironmentBlendMode();C==="additive"?r.buffers.color.setClear(0,0,0,1,o):C==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||N)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function b(w,N){const A=x(N);A&&(A.isCubeTexture||A.mapping===l2)?(d===void 0&&(d=new kl(new $O(1,1,1),new Jc({name:"BackgroundCubeMaterial",uniforms:Kp(fl.backgroundCube.uniforms),vertexShader:fl.backgroundCube.vertexShader,fragmentShader:fl.backgroundCube.fragmentShader,side:ss,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(C,T,L){this.matrixWorld.copyPosition(L.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),hh.copy(N.backgroundRotation),hh.x*=-1,hh.y*=-1,hh.z*=-1,A.isCubeTexture&&A.isRenderTargetTexture===!1&&(hh.y*=-1,hh.z*=-1),d.material.uniforms.envMap.value=A,d.material.uniforms.flipEnvMap.value=A.isCubeTexture&&A.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=N.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=N.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(eRe.makeRotationFromEuler(hh)),d.material.toneMapped=Un.getTransfer(A.colorSpace)!==sr,(f!==A||g!==A.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=A,g=A.version,p=t.toneMapping),d.layers.enableAll(),w.unshift(d,d.geometry,d.material,0,0,null)):A&&A.isTexture&&(u===void 0&&(u=new kl(new GO(2,2),new Jc({name:"BackgroundMaterial",uniforms:Kp(fl.background.uniforms),vertexShader:fl.background.vertexShader,fragmentShader:fl.background.fragmentShader,side:jd,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=A,u.material.uniforms.backgroundIntensity.value=N.backgroundIntensity,u.material.toneMapped=Un.getTransfer(A.colorSpace)!==sr,A.matrixAutoUpdate===!0&&A.updateMatrix(),u.material.uniforms.uvTransform.value.copy(A.matrix),(f!==A||g!==A.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=A,g=A.version,p=t.toneMapping),u.layers.enableAll(),w.unshift(u,u.geometry,u.material,0,0,null))}function v(w,N){w.getRGB(b_,nQ(t)),r.buffers.color.setClear(b_.r,b_.g,b_.b,N,o)}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,N=1){l.set(w),c=N,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(w){c=w,v(l,c)},render:y,addToRenderList:b,dispose:E}}function nRe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=g(null);let a=i,o=!1;function l(D,U,O,q,R){let G=!1;const Y=f(q,O,U);a!==Y&&(a=Y,u(a.object)),G=p(D,q,O,R),G&&x(D,q,O,R),R!==null&&e.update(R,t.ELEMENT_ARRAY_BUFFER),(G||o)&&(o=!1,N(D,U,O,q),R!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(R).buffer))}function c(){return t.createVertexArray()}function u(D){return t.bindVertexArray(D)}function d(D){return t.deleteVertexArray(D)}function f(D,U,O){const q=O.wireframe===!0;let R=r[D.id];R===void 0&&(R={},r[D.id]=R);let G=R[U.id];G===void 0&&(G={},R[U.id]=G);let Y=G[q];return Y===void 0&&(Y=g(c()),G[q]=Y),Y}function g(D){const U=[],O=[],q=[];for(let R=0;R<n;R++)U[R]=0,O[R]=0,q[R]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:O,attributeDivisors:q,object:D,attributes:{},index:null}}function p(D,U,O,q){const R=a.attributes,G=U.attributes;let Y=0;const V=O.getAttributes();for(const K in V)if(V[K].location>=0){const X=R[K];let F=G[K];if(F===void 0&&(K==="instanceMatrix"&&D.instanceMatrix&&(F=D.instanceMatrix),K==="instanceColor"&&D.instanceColor&&(F=D.instanceColor)),X===void 0||X.attribute!==F||F&&X.data!==F.data)return!0;Y++}return a.attributesNum!==Y||a.index!==q}function x(D,U,O,q){const R={},G=U.attributes;let Y=0;const V=O.getAttributes();for(const K in V)if(V[K].location>=0){let X=G[K];X===void 0&&(K==="instanceMatrix"&&D.instanceMatrix&&(X=D.instanceMatrix),K==="instanceColor"&&D.instanceColor&&(X=D.instanceColor));const F={};F.attribute=X,X&&X.data&&(F.data=X.data),R[K]=F,Y++}a.attributes=R,a.attributesNum=Y,a.index=q}function y(){const D=a.newAttributes;for(let U=0,O=D.length;U<O;U++)D[U]=0}function b(D){v(D,0)}function v(D,U){const O=a.newAttributes,q=a.enabledAttributes,R=a.attributeDivisors;O[D]=1,q[D]===0&&(t.enableVertexAttribArray(D),q[D]=1),R[D]!==U&&(t.vertexAttribDivisor(D,U),R[D]=U)}function E(){const D=a.newAttributes,U=a.enabledAttributes;for(let O=0,q=U.length;O<q;O++)U[O]!==D[O]&&(t.disableVertexAttribArray(O),U[O]=0)}function w(D,U,O,q,R,G,Y){Y===!0?t.vertexAttribIPointer(D,U,O,R,G):t.vertexAttribPointer(D,U,O,q,R,G)}function N(D,U,O,q){y();const R=q.attributes,G=O.getAttributes(),Y=U.defaultAttributeValues;for(const V in G){const K=G[V];if(K.location>=0){let J=R[V];if(J===void 0&&(V==="instanceMatrix"&&D.instanceMatrix&&(J=D.instanceMatrix),V==="instanceColor"&&D.instanceColor&&(J=D.instanceColor)),J!==void 0){const X=J.normalized,F=J.itemSize,W=e.get(J);if(W===void 0)continue;const ee=W.buffer,ie=W.type,ae=W.bytesPerElement,de=ie===t.INT||ie===t.UNSIGNED_INT||J.gpuType===RO;if(J.isInterleavedBufferAttribute){const ue=J.data,le=ue.stride,he=J.offset;if(ue.isInstancedInterleavedBuffer){for(let pe=0;pe<K.locationSize;pe++)v(K.location+pe,ue.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ue.meshPerAttribute*ue.count)}else for(let pe=0;pe<K.locationSize;pe++)b(K.location+pe);t.bindBuffer(t.ARRAY_BUFFER,ee);for(let pe=0;pe<K.locationSize;pe++)w(K.location+pe,F/K.locationSize,ie,X,le*ae,(he+F/K.locationSize*pe)*ae,de)}else{if(J.isInstancedBufferAttribute){for(let ue=0;ue<K.locationSize;ue++)v(K.location+ue,J.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let ue=0;ue<K.locationSize;ue++)b(K.location+ue);t.bindBuffer(t.ARRAY_BUFFER,ee);for(let ue=0;ue<K.locationSize;ue++)w(K.location+ue,F/K.locationSize,ie,X,F*ae,F/K.locationSize*ue*ae,de)}}else if(Y!==void 0){const X=Y[V];if(X!==void 0)switch(X.length){case 2:t.vertexAttrib2fv(K.location,X);break;case 3:t.vertexAttrib3fv(K.location,X);break;case 4:t.vertexAttrib4fv(K.location,X);break;default:t.vertexAttrib1fv(K.location,X)}}}}E()}function A(){L();for(const D in r){const U=r[D];for(const O in U){const q=U[O];for(const R in q)d(q[R].object),delete q[R];delete U[O]}delete r[D]}}function C(D){if(r[D.id]===void 0)return;const U=r[D.id];for(const O in U){const q=U[O];for(const R in q)d(q[R].object),delete q[R];delete U[O]}delete r[D.id]}function T(D){for(const U in r){const O=r[U];if(O[D.id]===void 0)continue;const q=O[D.id];for(const R in q)d(q[R].object),delete q[R];delete O[D.id]}}function L(){k(),o=!0,a!==i&&(a=i,u(a.object))}function k(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:L,resetDefaultState:k,dispose:A,releaseStatesOfGeometry:C,releaseStatesOfProgram:T,initAttributes:y,enableAttribute:b,disableUnusedAttributes:E}}function rRe(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 o(u,d,f){f!==0&&(t.drawArraysInstanced(r,u,d,f),n.update(d,r,f))}function l(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,f);let p=0;for(let x=0;x<f;x++)p+=d[x];n.update(p,r,1)}function c(u,d,f,g){if(f===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<u.length;x++)o(u[x],d[x],g[x]);else{p.multiDrawArraysInstancedWEBGL(r,u,0,d,0,g,0,f);let x=0;for(let y=0;y<f;y++)x+=d[y]*g[y];n.update(x,r,1)}}this.setMode=i,this.render=a,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function iRe(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(T){return!(T!==zo&&r.convert(T)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(T){const L=T===Eg&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(T!==Cl&&r.convert(T)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==jc&&!L)}function c(T){if(T==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="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&&(an("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,g=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=t.getParameter(t.MAX_TEXTURE_SIZE),b=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),E=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),w=t.getParameter(t.MAX_VARYING_VECTORS),N=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),A=x>0,C=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:g,maxTextures:p,maxVertexTextures:x,maxTextureSize:y,maxCubemapSize:b,maxAttributes:v,maxVertexUniforms:E,maxVaryings:w,maxFragmentUniforms:N,vertexTextures:A,maxSamples:C}}function aRe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new Ku,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 x=f.clippingPlanes,y=f.clipIntersection,b=f.clipShadows,v=t.get(f);if(!i||x===null||x.length===0||a&&!b)a?d(null):u();else{const E=a?0:r,w=E*4;let N=v.clippingState||null;c.value=N,N=d(x,g,w,p);for(let A=0;A!==w;++A)N[A]=n[A];v.clippingState=N,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=E}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,g,p,x){const y=f!==null?f.length:0;let b=null;if(y!==0){if(b=c.value,x!==!0||b===null){const v=p+y*4,E=g.matrixWorldInverse;l.getNormalMatrix(E),(b===null||b.length<v)&&(b=new Float32Array(v));for(let w=0,N=p;w!==y;++w,N+=4)o.copy(f[w]).applyMatrix4(E,l),o.normal.toArray(b,N),b[N+3]=o.constant}c.value=b,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,b}}function sRe(t){let e=new WeakMap;function n(o,l){return l===MP?o.mapping=Gp:l===EP&&(o.mapping=Wp),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===MP||l===EP)if(e.has(o)){const c=e.get(o).texture;return n(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const u=new t3e(c.height);return u.fromEquirectangularTexture(t,o),e.set(o,u),o.addEventListener("dispose",i),n(u.texture,o.mapping)}else return null}}return o}function i(o){const l=o.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 ad=4,e$=[.125,.215,.35,.446,.526,.582],Ah=20,oRe=256,Bx=new uQ,t$=new Nn;let mC=null,pC=0,gC=0,xC=!1;const lRe=new at;let n$=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:o=256,position:l=lRe}=a;mC=this._renderer.getRenderTarget(),pC=this._renderer.getActiveCubeFace(),gC=this._renderer.getActiveMipmapLevel(),xC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);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=a$(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=i$(),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(mC,pC,gC),this._renderer.xr.enabled=xC,e.scissorTest=!1,Pm(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Gp||e.mapping===Wp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),mC=this._renderer.getRenderTarget(),pC=this._renderer.getActiveCubeFace(),gC=this._renderer.getActiveMipmapLevel(),xC=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:ho,minFilter:ho,generateMipmaps:!1,type:Eg,format:zo,colorSpace:qp,depthBuffer:!1},i=r$(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=r$(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=cRe(a)),this._blurMaterial=dRe(a,e,n),this._ggxMaterial=uRe(a,e,n)}return i}_compileMaterial(e){const n=new kl(new Ul,e);this._renderer.compile(n,Bx)}_sceneToCubeUV(e,n,r,i,a){const c=new ao(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(t$),f.toneMapping=md,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new kl(new $O,new HO({name:"PMREM.Background",side:ss,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,b=y.material;let v=!1;const E=e.background;E?E.isColor&&(b.color.copy(E),e.background=null,v=!0):(b.color.copy(t$),v=!0);for(let w=0;w<6;w++){const N=w%3;N===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)):N===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 A=this._cubeSize;Pm(i,N*A,w>2?A:0,A,A),f.setRenderTarget(i),v&&f.render(y,c),f.render(e,c)}f.toneMapping=p,f.autoClear=g,e.background=E}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Gp||e.mapping===Wp;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=a$()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=i$());const a=i?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=a;const l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;Pm(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Bx)}_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,o=this._ggxMaterial,l=this._lodMeshes[r];l.material=o;const c=o.uniforms,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(u*u-d*d),g=.05+u*.95,p=f*g,{_lodMax:x}=this,y=this._sizeLods[r],b=3*y*(r>x-ad?r-x+ad:0),v=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=x-n,Pm(a,b,v,3*y,2*y),i.setRenderTarget(a),i.render(l,Bx),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=x-r,Pm(e,b,v,3*y,2*y),i.setRenderTarget(e),i.render(l,Bx)}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&ti("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const g=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*Ah-1),y=a/x,b=isFinite(a)?1+Math.floor(d*y):Ah;b>Ah&&an(`sigmaRadians, ${a}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Ah}`);const v=[];let E=0;for(let T=0;T<Ah;++T){const L=T/y,k=Math.exp(-L*L/2);v.push(k),T===0?E+=k:T<b&&(E+=2*k)}for(let T=0;T<v.length;T++)v[T]=v[T]/E;g.envMap.value=e.texture,g.samples.value=b,g.weights.value=v,g.latitudinal.value=o==="latitudinal",l&&(g.poleAxis.value=l);const{_lodMax:w}=this;g.dTheta.value=x,g.mipInt.value=w-r;const N=this._sizeLods[i],A=3*N*(i>w-ad?i-w+ad:0),C=4*(this._cubeSize-N);Pm(n,A,C,3*N,2*N),c.setRenderTarget(n),c.render(f,Bx)}};function cRe(t){const e=[],n=[],r=[];let i=t;const a=t-ad+1+e$.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-ad?c=e$[o-t+ad-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,y=3,b=2,v=1,E=new Float32Array(y*x*p),w=new Float32Array(b*x*p),N=new Float32Array(v*x*p);for(let C=0;C<p;C++){const T=C%3*2/3-1,L=C>2?0:-1,k=[T,L,0,T+2/3,L,0,T+2/3,L+1,0,T,L,0,T+2/3,L+1,0,T,L+1,0];E.set(k,y*x*C),w.set(g,b*x*C);const D=[C,C,C,C,C,C];N.set(D,v*x*C)}const A=new Ul;A.setAttribute("position",new po(E,y)),A.setAttribute("uv",new po(w,b)),A.setAttribute("faceIndex",new po(N,v)),r.push(new kl(A,null)),i>ad&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function r$(t,e,n){const r=new yf(t,e,n);return r.texture.mapping=l2,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Pm(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function uRe(t,e,n){return new Jc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:oRe,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:u2(),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:Fc,depthTest:!1,depthWrite:!1})}function dRe(t,e,n){const r=new Float32Array(Ah),i=new at(0,1,0);return new Jc({name:"SphericalGaussianBlur",defines:{n:Ah,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:u2(),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:Fc,depthTest:!1,depthWrite:!1})}function i$(){return new Jc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:u2(),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:Fc,depthTest:!1,depthWrite:!1})}function a$(){return new Jc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:u2(),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:Fc,depthTest:!1,depthWrite:!1})}function u2(){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 hRe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===MP||c===EP,d=c===Gp||c===Wp;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 n$(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 n$(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 o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function fRe(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&&lb("WebGLRenderer: "+r+" extension not supported."),i}}}function mRe(t,e,n,r){const i={},a=new WeakMap;function o(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const x in g.attributes)e.remove(g.attributes[x]);g.removeEventListener("dispose",o),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",o),i[g.id]=!0,n.memory.geometries++),g}function c(f){const g=f.attributes;for(const p in g)e.update(g[p],t.ARRAY_BUFFER)}function u(f){const g=[],p=f.index,x=f.attributes.position;let y=0;if(p!==null){const E=p.array;y=p.version;for(let w=0,N=E.length;w<N;w+=3){const A=E[w+0],C=E[w+1],T=E[w+2];g.push(A,C,C,T,T,A)}}else if(x!==void 0){const E=x.array;y=x.version;for(let w=0,N=E.length/3-1;w<N;w+=3){const A=w+0,C=w+1,T=w+2;g.push(A,C,C,T,T,A)}}else return;const b=new($Z(g)?JZ:QZ)(g,1);b.version=y;const v=a.get(f);v&&e.remove(v),a.set(f,b)}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 pRe(t,e,n){let r;function i(g){r=g}let a,o;function l(g){a=g.type,o=g.bytesPerElement}function c(g,p){t.drawElements(r,p,a,g*o),n.update(p,r,1)}function u(g,p,x){x!==0&&(t.drawElementsInstanced(r,p,a,g*o,x),n.update(p,r,x))}function d(g,p,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,p,0,a,g,0,x);let b=0;for(let v=0;v<x;v++)b+=p[v];n.update(b,r,1)}function f(g,p,x,y){if(x===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let v=0;v<g.length;v++)u(g[v]/o,p[v],y[v]);else{b.multiDrawElementsInstancedWEBGL(r,p,0,a,g,0,y,0,x);let v=0;for(let E=0;E<x;E++)v+=p[E]*y[E];n.update(v,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function gRe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,o,l){switch(n.calls++,o){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:ti("WebGLInfo: Unknown draw mode:",o);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 xRe(t,e,n){const r=new WeakMap,i=new di;function a(o,l,c){const u=o.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 D=function(){L.dispose(),r.delete(l),l.removeEventListener("dispose",D)};var p=D;g!==void 0&&g.texture.dispose();const x=l.morphAttributes.position!==void 0,y=l.morphAttributes.normal!==void 0,b=l.morphAttributes.color!==void 0,v=l.morphAttributes.position||[],E=l.morphAttributes.normal||[],w=l.morphAttributes.color||[];let N=0;x===!0&&(N=1),y===!0&&(N=2),b===!0&&(N=3);let A=l.attributes.position.count*N,C=1;A>e.maxTextureSize&&(C=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const T=new Float32Array(A*C*4*f),L=new KZ(T,A,C,f);L.type=jc,L.needsUpdate=!0;const k=N*4;for(let U=0;U<f;U++){const O=v[U],q=E[U],R=w[U],G=A*C*4*U;for(let Y=0;Y<O.count;Y++){const V=Y*k;x===!0&&(i.fromBufferAttribute(O,Y),T[G+V+0]=i.x,T[G+V+1]=i.y,T[G+V+2]=i.z,T[G+V+3]=0),y===!0&&(i.fromBufferAttribute(q,Y),T[G+V+4]=i.x,T[G+V+5]=i.y,T[G+V+6]=i.z,T[G+V+7]=0),b===!0&&(i.fromBufferAttribute(R,Y),T[G+V+8]=i.x,T[G+V+9]=i.y,T[G+V+10]=i.z,T[G+V+11]=R.itemSize===4?i.w:1)}}g={count:f,texture:L,size:new bn(A,C)},r.set(l,g),l.addEventListener("dispose",D)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",o.morphTexture,n);else{let x=0;for(let b=0;b<u.length;b++)x+=u[b];const y=l.morphTargetsRelative?1:1-x;c.getUniforms().setValue(t,"morphTargetBaseInfluence",y),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 bRe(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 o(){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:o}}const hQ=new Jo,s$=new sQ(1,1),fQ=new KZ,mQ=new Fke,pQ=new iQ,o$=[],l$=[],c$=new Float32Array(16),u$=new Float32Array(9),d$=new Float32Array(4);function Ng(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=o$[i];if(a===void 0&&(a=new Float32Array(i),o$[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}function Ai(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 Ni(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function d2(t,e){let n=l$[e];n===void 0&&(n=new Int32Array(e),l$[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function yRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function vRe(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(Ai(n,e))return;t.uniform2fv(this.addr,e),Ni(n,e)}}function _Re(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(Ai(n,e))return;t.uniform3fv(this.addr,e),Ni(n,e)}}function wRe(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(Ai(n,e))return;t.uniform4fv(this.addr,e),Ni(n,e)}}function SRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ai(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ni(n,e)}else{if(Ai(n,r))return;d$.set(r),t.uniformMatrix2fv(this.addr,!1,d$),Ni(n,r)}}function MRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ai(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ni(n,e)}else{if(Ai(n,r))return;u$.set(r),t.uniformMatrix3fv(this.addr,!1,u$),Ni(n,r)}}function ERe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ai(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ni(n,e)}else{if(Ai(n,r))return;c$.set(r),t.uniformMatrix4fv(this.addr,!1,c$),Ni(n,r)}}function ARe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function NRe(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(Ai(n,e))return;t.uniform2iv(this.addr,e),Ni(n,e)}}function TRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Ai(n,e))return;t.uniform3iv(this.addr,e),Ni(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||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(Ai(n,e))return;t.uniform4iv(this.addr,e),Ni(n,e)}}function kRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function PRe(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(Ai(n,e))return;t.uniform2uiv(this.addr,e),Ni(n,e)}}function jRe(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(Ai(n,e))return;t.uniform3uiv(this.addr,e),Ni(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.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(Ai(n,e))return;t.uniform4uiv(this.addr,e),Ni(n,e)}}function DRe(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?(s$.compareFunction=HZ,a=s$):a=hQ,n.setTexture2D(e||a,i)}function ORe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||mQ,i)}function LRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||pQ,i)}function IRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||fQ,i)}function FRe(t){switch(t){case 5126:return yRe;case 35664:return vRe;case 35665:return _Re;case 35666:return wRe;case 35674:return SRe;case 35675:return MRe;case 35676:return ERe;case 5124:case 35670:return ARe;case 35667:case 35671:return NRe;case 35668:case 35672:return TRe;case 35669:case 35673:return CRe;case 5125:return kRe;case 36294:return PRe;case 36295:return jRe;case 36296:return RRe;case 35678:case 36198:case 36298:case 36306:case 35682:return DRe;case 35679:case 36299:case 36307:return ORe;case 35680:case 36300:case 36308:case 36293:return LRe;case 36289:case 36303:case 36311:case 36292:return IRe}}function URe(t,e){t.uniform1fv(this.addr,e)}function zRe(t,e){const n=Ng(e,this.size,2);t.uniform2fv(this.addr,n)}function BRe(t,e){const n=Ng(e,this.size,3);t.uniform3fv(this.addr,n)}function HRe(t,e){const n=Ng(e,this.size,4);t.uniform4fv(this.addr,n)}function $Re(t,e){const n=Ng(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function VRe(t,e){const n=Ng(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function GRe(t,e){const n=Ng(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function WRe(t,e){t.uniform1iv(this.addr,e)}function qRe(t,e){t.uniform2iv(this.addr,e)}function KRe(t,e){t.uniform3iv(this.addr,e)}function XRe(t,e){t.uniform4iv(this.addr,e)}function YRe(t,e){t.uniform1uiv(this.addr,e)}function ZRe(t,e){t.uniform2uiv(this.addr,e)}function QRe(t,e){t.uniform3uiv(this.addr,e)}function JRe(t,e){t.uniform4uiv(this.addr,e)}function eDe(t,e,n){const r=this.cache,i=e.length,a=d2(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ni(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||hQ,a[o])}function tDe(t,e,n){const r=this.cache,i=e.length,a=d2(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ni(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||mQ,a[o])}function nDe(t,e,n){const r=this.cache,i=e.length,a=d2(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ni(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||pQ,a[o])}function rDe(t,e,n){const r=this.cache,i=e.length,a=d2(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ni(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||fQ,a[o])}function iDe(t){switch(t){case 5126:return URe;case 35664:return zRe;case 35665:return BRe;case 35666:return HRe;case 35674:return $Re;case 35675:return VRe;case 35676:return GRe;case 5124:case 35670:return WRe;case 35667:case 35671:return qRe;case 35668:case 35672:return KRe;case 35669:case 35673:return XRe;case 5125:return YRe;case 36294:return ZRe;case 36295:return QRe;case 36296:return JRe;case 35678:case 36198:case 36298:case 36306:case 35682:return eDe;case 35679:case 36299:case 36307:return tDe;case 35680:case 36300:case 36308:case 36293:return nDe;case 36289:case 36303:case 36311:case 36292:return rDe}}let aDe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=FRe(n.type)}},sDe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=iDe(n.type)}},oDe=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,o=i.length;a!==o;++a){const l=i[a];l.setValue(e,n[l.id],r)}}};const bC=/(\w+)(\])?(\[|\.)?/g;function h$(t,e){t.seq.push(e),t.map[e.id]=e}function lDe(t,e,n){const r=t.name,i=r.length;for(bC.lastIndex=0;;){const a=bC.exec(r),o=bC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){h$(n,u===void 0?new aDe(l,t,e):new sDe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new oDe(l),h$(n,f)),n=f}}}let D1=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),o=e.getUniformLocation(n,a.name);lDe(a,o,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,o=n.length;a!==o;++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 o=e[i];o.id in n&&r.push(o)}return r}};function f$(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const cDe=37297;let uDe=0;function dDe(t,e){const n=t.split(`
  3830. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
  3831. `)}const m$=new vn;function hDe(t){Un._getMatrix(m$,Un.workingColorSpace,t);const e=`mat3( ${m$.elements.map(n=>n.toFixed(4))} )`;switch(Un.getTransfer(t)){case Zw:return[e,"LinearTransferOETF"];case sr:return[e,"sRGBTransferOETF"];default:return an("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function p$(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const o=/ERROR: 0:(\d+)/.exec(a);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
  3832. `+a+`
  3833. `+dDe(t.getShaderSource(e),l)}else return a}function fDe(t,e){const n=hDe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3834. `)}function mDe(t,e){let n;switch(e){case dke:n="Linear";break;case hke:n="Reinhard";break;case fke:n="Cineon";break;case mke:n="ACESFilmic";break;case gke:n="AgX";break;case xke:n="Neutral";break;case pke:n="Custom";break;default:an("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const y_=new at;function pDe(){Un.getLuminanceCoefficients(y_);const t=y_.x.toFixed(4),e=y_.y.toFixed(4),n=y_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
  3835. `)}function gDe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(n0).join(`
  3836. `)}function xDe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3837. `)}function bDe(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),o=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[o]={type:a.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function n0(t){return t!==""}function g$(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 x$(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const yDe=/^[ \t]*#include +<([\w\d./]+)>/gm;function ij(t){return t.replace(yDe,_De)}const vDe=new Map;function _De(t,e){let n=gn[e];if(n===void 0){const r=vDe.get(e);if(r!==void 0)n=gn[r],an('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return ij(n)}const wDe=/#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 b$(t){return t.replace(wDe,SDe)}function SDe(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 y$(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 MDe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===jZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===VCe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===bc&&(e="SHADOWMAP_TYPE_VSM"),e}function EDe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Gp:case Wp:e="ENVMAP_TYPE_CUBE";break;case l2:e="ENVMAP_TYPE_CUBE_UV";break}return e}function ADe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Wp:e="ENVMAP_MODE_REFRACTION";break}return e}function NDe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case jO:e="ENVMAP_BLENDING_MULTIPLY";break;case cke:e="ENVMAP_BLENDING_MIX";break;case uke:e="ENVMAP_BLENDING_ADD";break}return e}function TDe(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 CDe(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=MDe(n),u=EDe(n),d=ADe(n),f=NDe(n),g=TDe(n),p=gDe(n),x=xDe(a),y=i.createProgram();let b,v,E=n.glslVersion?"#version "+n.glslVersion+`
  3858. `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(n0).join(`
  3859. `),b.length>0&&(b+=`
  3860. `),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(n0).join(`
  3861. `),v.length>0&&(v+=`
  3862. `)):(b=[y$(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  3863. `].filter(n0).join(`
  3864. `),v=[y$(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==md?"#define TONE_MAPPING":"",n.toneMapping!==md?gn.tonemapping_pars_fragment:"",n.toneMapping!==md?mDe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",gn.colorspace_pars_fragment,fDe("linearToOutputTexel",n.outputColorSpace),pDe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3865. `].filter(n0).join(`
  3866. `)),o=ij(o),o=g$(o,n),o=x$(o,n),l=ij(l),l=g$(l,n),l=x$(l,n),o=b$(o),l=b$(l),n.isRawShaderMaterial!==!0&&(E=`#version 300 es
  3867. `,b=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3868. `)+`
  3869. `+b,v=["#define varying in",n.glslVersion===AH?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===AH?"":"#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. `+v);const w=E+b+o,N=E+v+l,A=f$(i,i.VERTEX_SHADER,w),C=f$(i,i.FRAGMENT_SHADER,N);i.attachShader(y,A),i.attachShader(y,C),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function T(U){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(y)||"",q=i.getShaderInfoLog(A)||"",R=i.getShaderInfoLog(C)||"",G=O.trim(),Y=q.trim(),V=R.trim();let K=!0,J=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(K=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,A,C);else{const X=p$(i,A,"vertex"),F=p$(i,C,"fragment");ti("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  3872. Material Name: `+U.name+`
  3873. Material Type: `+U.type+`
  3874. Program Info Log: `+G+`
  3875. `+X+`
  3876. `+F)}else G!==""?an("WebGLProgram: Program Info Log:",G):(Y===""||V==="")&&(J=!1);J&&(U.diagnostics={runnable:K,programLog:G,vertexShader:{log:Y,prefix:b},fragmentShader:{log:V,prefix:v}})}i.deleteShader(A),i.deleteShader(C),L=new D1(i,y),k=bDe(i,y)}let L;this.getUniforms=function(){return L===void 0&&T(this),L};let k;this.getAttributes=function(){return k===void 0&&T(this),k};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(y,cDe)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=uDe++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=A,this.fragmentShader=C,this}let kDe=0,PDe=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),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(a)===!1&&(o.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 jDe(e),n.set(e,r)),r}},jDe=class{constructor(e){this.id=kDe++,this.code=e,this.usedTimes=0}};function RDe(t,e,n,r,i,a,o){const l=new YZ,c=new PDe,u=new Set,d=[],f=i.logarithmicDepthBuffer,g=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(k){return u.add(k),k===0?"uv":`uv${k}`}function b(k,D,U,O,q){const R=O.fog,G=q.geometry,Y=k.isMeshStandardMaterial?O.environment:null,V=(k.isMeshStandardMaterial?n:e).get(k.envMap||Y),K=V&&V.mapping===l2?V.image.height:null,J=x[k.type];k.precision!==null&&(p=i.getMaxPrecision(k.precision),p!==k.precision&&an("WebGLProgram.getParameters:",k.precision,"not supported, using",p,"instead."));const X=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,F=X!==void 0?X.length:0;let W=0;G.morphAttributes.position!==void 0&&(W=1),G.morphAttributes.normal!==void 0&&(W=2),G.morphAttributes.color!==void 0&&(W=3);let ee,ie,ae,de;if(J){const Et=fl[J];ee=Et.vertexShader,ie=Et.fragmentShader}else ee=k.vertexShader,ie=k.fragmentShader,c.update(k),ae=c.getVertexShaderID(k),de=c.getFragmentShaderID(k);const ue=t.getRenderTarget(),le=t.state.buffers.depth.getReversed(),he=q.isInstancedMesh===!0,pe=q.isBatchedMesh===!0,Me=!!k.map,re=!!k.matcap,We=!!V,z=!!k.aoMap,H=!!k.lightMap,se=!!k.bumpMap,B=!!k.normalMap,Q=!!k.displacementMap,ce=!!k.emissiveMap,Ce=!!k.metalnessMap,_e=!!k.roughnessMap,Ee=k.anisotropy>0,$=k.clearcoat>0,j=k.dispersion>0,ne=k.iridescence>0,be=k.sheen>0,we=k.transmission>0,ve=Ee&&!!k.anisotropyMap,$e=$&&!!k.clearcoatMap,Ge=$&&!!k.clearcoatNormalMap,Xe=$&&!!k.clearcoatRoughnessMap,ut=ne&&!!k.iridescenceMap,He=ne&&!!k.iridescenceThicknessMap,me=be&&!!k.sheenColorMap,Je=be&&!!k.sheenRoughnessMap,Ke=!!k.specularMap,Ze=!!k.specularColorMap,ct=!!k.specularIntensityMap,te=we&&!!k.transmissionMap,Fe=we&&!!k.thicknessMap,xe=!!k.gradientMap,ze=!!k.alphaMap,Pe=k.alphaTest>0,Se=!!k.alphaHash,Ye=!!k.extensions;let dt=md;k.toneMapped&&(ue===null||ue.isXRRenderTarget===!0)&&(dt=t.toneMapping);const Tt={shaderID:J,shaderType:k.type,shaderName:k.name,vertexShader:ee,fragmentShader:ie,defines:k.defines,customVertexShaderID:ae,customFragmentShaderID:de,isRawShaderMaterial:k.isRawShaderMaterial===!0,glslVersion:k.glslVersion,precision:p,batching:pe,batchingColor:pe&&q._colorsTexture!==null,instancing:he,instancingColor:he&&q.instanceColor!==null,instancingMorph:he&&q.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:ue===null?t.outputColorSpace:ue.isXRRenderTarget===!0?ue.texture.colorSpace:qp,alphaToCoverage:!!k.alphaToCoverage,map:Me,matcap:re,envMap:We,envMapMode:We&&V.mapping,envMapCubeUVHeight:K,aoMap:z,lightMap:H,bumpMap:se,normalMap:B,displacementMap:g&&Q,emissiveMap:ce,normalMapObjectSpace:B&&k.normalMapType===_ke,normalMapTangentSpace:B&&k.normalMapType===BZ,metalnessMap:Ce,roughnessMap:_e,anisotropy:Ee,anisotropyMap:ve,clearcoat:$,clearcoatMap:$e,clearcoatNormalMap:Ge,clearcoatRoughnessMap:Xe,dispersion:j,iridescence:ne,iridescenceMap:ut,iridescenceThicknessMap:He,sheen:be,sheenColorMap:me,sheenRoughnessMap:Je,specularMap:Ke,specularColorMap:Ze,specularIntensityMap:ct,transmission:we,transmissionMap:te,thicknessMap:Fe,gradientMap:xe,opaque:k.transparent===!1&&k.blending===_p&&k.alphaToCoverage===!1,alphaMap:ze,alphaTest:Pe,alphaHash:Se,combine:k.combine,mapUv:Me&&y(k.map.channel),aoMapUv:z&&y(k.aoMap.channel),lightMapUv:H&&y(k.lightMap.channel),bumpMapUv:se&&y(k.bumpMap.channel),normalMapUv:B&&y(k.normalMap.channel),displacementMapUv:Q&&y(k.displacementMap.channel),emissiveMapUv:ce&&y(k.emissiveMap.channel),metalnessMapUv:Ce&&y(k.metalnessMap.channel),roughnessMapUv:_e&&y(k.roughnessMap.channel),anisotropyMapUv:ve&&y(k.anisotropyMap.channel),clearcoatMapUv:$e&&y(k.clearcoatMap.channel),clearcoatNormalMapUv:Ge&&y(k.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Xe&&y(k.clearcoatRoughnessMap.channel),iridescenceMapUv:ut&&y(k.iridescenceMap.channel),iridescenceThicknessMapUv:He&&y(k.iridescenceThicknessMap.channel),sheenColorMapUv:me&&y(k.sheenColorMap.channel),sheenRoughnessMapUv:Je&&y(k.sheenRoughnessMap.channel),specularMapUv:Ke&&y(k.specularMap.channel),specularColorMapUv:Ze&&y(k.specularColorMap.channel),specularIntensityMapUv:ct&&y(k.specularIntensityMap.channel),transmissionMapUv:te&&y(k.transmissionMap.channel),thicknessMapUv:Fe&&y(k.thicknessMap.channel),alphaMapUv:ze&&y(k.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(B||Ee),vertexColors:k.vertexColors,vertexAlphas:k.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!G.attributes.uv&&(Me||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:le,skinning:q.isSkinnedMesh===!0,morphTargets:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:F,morphTextureStride:W,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:k.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:dt,decodeVideoTexture:Me&&k.map.isVideoTexture===!0&&Un.getTransfer(k.map.colorSpace)===sr,decodeVideoTextureEmissive:ce&&k.emissiveMap.isVideoTexture===!0&&Un.getTransfer(k.emissiveMap.colorSpace)===sr,premultipliedAlpha:k.premultipliedAlpha,doubleSided:k.side===ml,flipSided:k.side===ss,useDepthPacking:k.depthPacking>=0,depthPacking:k.depthPacking||0,index0AttributeName:k.index0AttributeName,extensionClipCullDistance:Ye&&k.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ye&&k.extensions.multiDraw===!0||pe)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:k.customProgramCacheKey()};return Tt.vertexUv1s=u.has(1),Tt.vertexUv2s=u.has(2),Tt.vertexUv3s=u.has(3),u.clear(),Tt}function v(k){const D=[];if(k.shaderID?D.push(k.shaderID):(D.push(k.customVertexShaderID),D.push(k.customFragmentShaderID)),k.defines!==void 0)for(const U in k.defines)D.push(U),D.push(k.defines[U]);return k.isRawShaderMaterial===!1&&(E(D,k),w(D,k),D.push(t.outputColorSpace)),D.push(k.customProgramCacheKey),D.join()}function E(k,D){k.push(D.precision),k.push(D.outputColorSpace),k.push(D.envMapMode),k.push(D.envMapCubeUVHeight),k.push(D.mapUv),k.push(D.alphaMapUv),k.push(D.lightMapUv),k.push(D.aoMapUv),k.push(D.bumpMapUv),k.push(D.normalMapUv),k.push(D.displacementMapUv),k.push(D.emissiveMapUv),k.push(D.metalnessMapUv),k.push(D.roughnessMapUv),k.push(D.anisotropyMapUv),k.push(D.clearcoatMapUv),k.push(D.clearcoatNormalMapUv),k.push(D.clearcoatRoughnessMapUv),k.push(D.iridescenceMapUv),k.push(D.iridescenceThicknessMapUv),k.push(D.sheenColorMapUv),k.push(D.sheenRoughnessMapUv),k.push(D.specularMapUv),k.push(D.specularColorMapUv),k.push(D.specularIntensityMapUv),k.push(D.transmissionMapUv),k.push(D.thicknessMapUv),k.push(D.combine),k.push(D.fogExp2),k.push(D.sizeAttenuation),k.push(D.morphTargetsCount),k.push(D.morphAttributeCount),k.push(D.numDirLights),k.push(D.numPointLights),k.push(D.numSpotLights),k.push(D.numSpotLightMaps),k.push(D.numHemiLights),k.push(D.numRectAreaLights),k.push(D.numDirLightShadows),k.push(D.numPointLightShadows),k.push(D.numSpotLightShadows),k.push(D.numSpotLightShadowsWithMaps),k.push(D.numLightProbes),k.push(D.shadowMapType),k.push(D.toneMapping),k.push(D.numClippingPlanes),k.push(D.numClipIntersection),k.push(D.depthPacking)}function w(k,D){l.disableAll(),D.supportsVertexTextures&&l.enable(0),D.instancing&&l.enable(1),D.instancingColor&&l.enable(2),D.instancingMorph&&l.enable(3),D.matcap&&l.enable(4),D.envMap&&l.enable(5),D.normalMapObjectSpace&&l.enable(6),D.normalMapTangentSpace&&l.enable(7),D.clearcoat&&l.enable(8),D.iridescence&&l.enable(9),D.alphaTest&&l.enable(10),D.vertexColors&&l.enable(11),D.vertexAlphas&&l.enable(12),D.vertexUv1s&&l.enable(13),D.vertexUv2s&&l.enable(14),D.vertexUv3s&&l.enable(15),D.vertexTangents&&l.enable(16),D.anisotropy&&l.enable(17),D.alphaHash&&l.enable(18),D.batching&&l.enable(19),D.dispersion&&l.enable(20),D.batchingColor&&l.enable(21),D.gradientMap&&l.enable(22),k.push(l.mask),l.disableAll(),D.fog&&l.enable(0),D.useFog&&l.enable(1),D.flatShading&&l.enable(2),D.logarithmicDepthBuffer&&l.enable(3),D.reversedDepthBuffer&&l.enable(4),D.skinning&&l.enable(5),D.morphTargets&&l.enable(6),D.morphNormals&&l.enable(7),D.morphColors&&l.enable(8),D.premultipliedAlpha&&l.enable(9),D.shadowMapEnabled&&l.enable(10),D.doubleSided&&l.enable(11),D.flipSided&&l.enable(12),D.useDepthPacking&&l.enable(13),D.dithering&&l.enable(14),D.transmission&&l.enable(15),D.sheen&&l.enable(16),D.opaque&&l.enable(17),D.pointsUvs&&l.enable(18),D.decodeVideoTexture&&l.enable(19),D.decodeVideoTextureEmissive&&l.enable(20),D.alphaToCoverage&&l.enable(21),k.push(l.mask)}function N(k){const D=x[k.type];let U;if(D){const O=fl[D];U=Zke.clone(O.uniforms)}else U=k.uniforms;return U}function A(k,D){let U;for(let O=0,q=d.length;O<q;O++){const R=d[O];if(R.cacheKey===D){U=R,++U.usedTimes;break}}return U===void 0&&(U=new CDe(t,D,k,a),d.push(U)),U}function C(k){if(--k.usedTimes===0){const D=d.indexOf(k);d[D]=d[d.length-1],d.pop(),k.destroy()}}function T(k){c.remove(k)}function L(){c.dispose()}return{getParameters:b,getProgramCacheKey:v,getUniforms:N,acquireProgram:A,releaseProgram:C,releaseShaderCache:T,programs:d,dispose:L}}function DDe(){let t=new WeakMap;function e(o){return t.has(o)}function n(o){let l=t.get(o);return l===void 0&&(l={},t.set(o,l)),l}function r(o){t.delete(o)}function i(o,l,c){t.get(o)[l]=c}function a(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:a}}function ODe(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function v$(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 _$(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,g,p,x,y,b){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:g,material:p,groupOrder:x,renderOrder:f.renderOrder,z:y,group:b},t[e]=v):(v.id=f.id,v.object=f,v.geometry=g,v.material=p,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=y,v.group=b),e++,v}function l(f,g,p,x,y,b){const v=o(f,g,p,x,y,b);p.transmission>0?r.push(v):p.transparent===!0?i.push(v):n.push(v)}function c(f,g,p,x,y,b){const v=o(f,g,p,x,y,b);p.transmission>0?r.unshift(v):p.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,g){n.length>1&&n.sort(f||ODe),r.length>1&&r.sort(g||v$),i.length>1&&i.sort(g||v$)}function d(){for(let f=e,g=t.length;f<g;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function LDe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new _$,t.set(r,[o])):i>=a.length?(o=new _$,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function IDe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new at,color:new Nn};break;case"SpotLight":n={position:new at,direction:new at,color:new Nn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new at,color:new Nn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new at,skyColor:new Nn,groundColor:new Nn};break;case"RectAreaLight":n={color:new Nn,position:new at,halfWidth:new at,halfHeight:new at};break}return t[e.id]=n,n}}}function FDe(){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 UDe=0;function zDe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function BDe(t){const e=new IDe,n=FDe(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let u=0;u<9;u++)r.probe.push(new at);const i=new at,a=new pi,o=new pi;function l(u){let d=0,f=0,g=0;for(let k=0;k<9;k++)r.probe[k].set(0,0,0);let p=0,x=0,y=0,b=0,v=0,E=0,w=0,N=0,A=0,C=0,T=0;u.sort(zDe);for(let k=0,D=u.length;k<D;k++){const U=u[k],O=U.color,q=U.intensity,R=U.distance,G=U.shadow&&U.shadow.map?U.shadow.map.texture:null;if(U.isAmbientLight)d+=O.r*q,f+=O.g*q,g+=O.b*q;else if(U.isLightProbe){for(let Y=0;Y<9;Y++)r.probe[Y].addScaledVector(U.sh.coefficients[Y],q);T++}else if(U.isDirectionalLight){const Y=e.get(U);if(Y.color.copy(U.color).multiplyScalar(U.intensity),U.castShadow){const V=U.shadow,K=n.get(U);K.shadowIntensity=V.intensity,K.shadowBias=V.bias,K.shadowNormalBias=V.normalBias,K.shadowRadius=V.radius,K.shadowMapSize=V.mapSize,r.directionalShadow[p]=K,r.directionalShadowMap[p]=G,r.directionalShadowMatrix[p]=U.shadow.matrix,E++}r.directional[p]=Y,p++}else if(U.isSpotLight){const Y=e.get(U);Y.position.setFromMatrixPosition(U.matrixWorld),Y.color.copy(O).multiplyScalar(q),Y.distance=R,Y.coneCos=Math.cos(U.angle),Y.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),Y.decay=U.decay,r.spot[y]=Y;const V=U.shadow;if(U.map&&(r.spotLightMap[A]=U.map,A++,V.updateMatrices(U),U.castShadow&&C++),r.spotLightMatrix[y]=V.matrix,U.castShadow){const K=n.get(U);K.shadowIntensity=V.intensity,K.shadowBias=V.bias,K.shadowNormalBias=V.normalBias,K.shadowRadius=V.radius,K.shadowMapSize=V.mapSize,r.spotShadow[y]=K,r.spotShadowMap[y]=G,N++}y++}else if(U.isRectAreaLight){const Y=e.get(U);Y.color.copy(O).multiplyScalar(q),Y.halfWidth.set(U.width*.5,0,0),Y.halfHeight.set(0,U.height*.5,0),r.rectArea[b]=Y,b++}else if(U.isPointLight){const Y=e.get(U);if(Y.color.copy(U.color).multiplyScalar(U.intensity),Y.distance=U.distance,Y.decay=U.decay,U.castShadow){const V=U.shadow,K=n.get(U);K.shadowIntensity=V.intensity,K.shadowBias=V.bias,K.shadowNormalBias=V.normalBias,K.shadowRadius=V.radius,K.shadowMapSize=V.mapSize,K.shadowCameraNear=V.camera.near,K.shadowCameraFar=V.camera.far,r.pointShadow[x]=K,r.pointShadowMap[x]=G,r.pointShadowMatrix[x]=U.shadow.matrix,w++}r.point[x]=Y,x++}else if(U.isHemisphereLight){const Y=e.get(U);Y.skyColor.copy(U.color).multiplyScalar(q),Y.groundColor.copy(U.groundColor).multiplyScalar(q),r.hemi[v]=Y,v++}}b>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 L=r.hash;(L.directionalLength!==p||L.pointLength!==x||L.spotLength!==y||L.rectAreaLength!==b||L.hemiLength!==v||L.numDirectionalShadows!==E||L.numPointShadows!==w||L.numSpotShadows!==N||L.numSpotMaps!==A||L.numLightProbes!==T)&&(r.directional.length=p,r.spot.length=y,r.rectArea.length=b,r.point.length=x,r.hemi.length=v,r.directionalShadow.length=E,r.directionalShadowMap.length=E,r.pointShadow.length=w,r.pointShadowMap.length=w,r.spotShadow.length=N,r.spotShadowMap.length=N,r.directionalShadowMatrix.length=E,r.pointShadowMatrix.length=w,r.spotLightMatrix.length=N+A-C,r.spotLightMap.length=A,r.numSpotLightShadowsWithMaps=C,r.numLightProbes=T,L.directionalLength=p,L.pointLength=x,L.spotLength=y,L.rectAreaLength=b,L.hemiLength=v,L.numDirectionalShadows=E,L.numPointShadows=w,L.numSpotShadows=N,L.numSpotMaps=A,L.numLightProbes=T,r.version=UDe++)}function c(u,d){let f=0,g=0,p=0,x=0,y=0;const b=d.matrixWorldInverse;for(let v=0,E=u.length;v<E;v++){const w=u[v];if(w.isDirectionalLight){const N=r.directional[f];N.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),N.direction.sub(i),N.direction.transformDirection(b),f++}else if(w.isSpotLight){const N=r.spot[p];N.position.setFromMatrixPosition(w.matrixWorld),N.position.applyMatrix4(b),N.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),N.direction.sub(i),N.direction.transformDirection(b),p++}else if(w.isRectAreaLight){const N=r.rectArea[x];N.position.setFromMatrixPosition(w.matrixWorld),N.position.applyMatrix4(b),o.identity(),a.copy(w.matrixWorld),a.premultiply(b),o.extractRotation(a),N.halfWidth.set(w.width*.5,0,0),N.halfHeight.set(0,w.height*.5,0),N.halfWidth.applyMatrix4(o),N.halfHeight.applyMatrix4(o),x++}else if(w.isPointLight){const N=r.point[g];N.position.setFromMatrixPosition(w.matrixWorld),N.position.applyMatrix4(b),g++}else if(w.isHemisphereLight){const N=r.hemi[y];N.direction.setFromMatrixPosition(w.matrixWorld),N.direction.transformDirection(b),y++}}}return{setup:l,setupView:c,state:r}}function w$(t){const e=new BDe(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function a(d){n.push(d)}function o(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:o}}function HDe(t){let e=new WeakMap;function n(i,a=0){const o=e.get(i);let l;return o===void 0?(l=new w$(t),e.set(i,[l])):a>=o.length?(l=new w$(t),o.push(l)):l=o[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const $De=`void main() {
  3877. gl_Position = vec4( position, 1.0 );
  3878. }`,VDe=`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 GDe(t,e,n){let r=new VO;const i=new bn,a=new bn,o=new di,l=new d3e({depthPacking:vke}),c=new h3e,u={},d=n.maxTextureSize,f={[jd]:ss,[ss]:jd,[ml]:ml},g=new Jc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new bn},radius:{value:4}},vertexShader:$De,fragmentShader:VDe}),p=g.clone();p.defines.HORIZONTAL_PASS=1;const x=new Ul;x.setAttribute("position",new po(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new kl(x,g),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=jZ;let v=this.type;this.render=function(C,T,L){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||C.length===0)return;const k=t.getRenderTarget(),D=t.getActiveCubeFace(),U=t.getActiveMipmapLevel(),O=t.state;O.setBlending(Fc),O.buffers.depth.getReversed()===!0?O.buffers.color.setClear(0,0,0,0):O.buffers.color.setClear(1,1,1,1),O.buffers.depth.setTest(!0),O.setScissorTest(!1);const q=v!==bc&&this.type===bc,R=v===bc&&this.type!==bc;for(let G=0,Y=C.length;G<Y;G++){const V=C[G],K=V.shadow;if(K===void 0){an("WebGLShadowMap:",V,"has no shadow.");continue}if(K.autoUpdate===!1&&K.needsUpdate===!1)continue;i.copy(K.mapSize);const J=K.getFrameExtents();if(i.multiply(J),a.copy(K.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/J.x),i.x=a.x*J.x,K.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/J.y),i.y=a.y*J.y,K.mapSize.y=a.y)),K.map===null||q===!0||R===!0){const F=this.type!==bc?{minFilter:Rs,magFilter:Rs}:{};K.map!==null&&K.map.dispose(),K.map=new yf(i.x,i.y,F),K.map.texture.name=V.name+".shadowMap",K.camera.updateProjectionMatrix()}t.setRenderTarget(K.map),t.clear();const X=K.getViewportCount();for(let F=0;F<X;F++){const W=K.getViewport(F);o.set(a.x*W.x,a.y*W.y,a.x*W.z,a.y*W.w),O.viewport(o),K.updateMatrices(V,F),r=K.getFrustum(),N(T,L,K.camera,V,this.type)}K.isPointLightShadow!==!0&&this.type===bc&&E(K,L),K.needsUpdate=!1}v=this.type,b.needsUpdate=!1,t.setRenderTarget(k,D,U)};function E(C,T){const L=e.update(y);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 yf(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(T,null,L,g,y,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(T,null,L,p,y,null)}function w(C,T,L,k){let D=null;const U=L.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(U!==void 0)D=U;else if(D=L.isPointLight===!0?c:l,t.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0||T.alphaToCoverage===!0){const O=D.uuid,q=T.uuid;let R=u[O];R===void 0&&(R={},u[O]=R);let G=R[q];G===void 0&&(G=D.clone(),R[q]=G,T.addEventListener("dispose",A)),D=G}if(D.visible=T.visible,D.wireframe=T.wireframe,k===bc?D.side=T.shadowSide!==null?T.shadowSide:T.side:D.side=T.shadowSide!==null?T.shadowSide:f[T.side],D.alphaMap=T.alphaMap,D.alphaTest=T.alphaToCoverage===!0?.5:T.alphaTest,D.map=T.map,D.clipShadows=T.clipShadows,D.clippingPlanes=T.clippingPlanes,D.clipIntersection=T.clipIntersection,D.displacementMap=T.displacementMap,D.displacementScale=T.displacementScale,D.displacementBias=T.displacementBias,D.wireframeLinewidth=T.wireframeLinewidth,D.linewidth=T.linewidth,L.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const O=t.properties.get(D);O.light=L}return D}function N(C,T,L,k,D){if(C.visible===!1)return;if(C.layers.test(T.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&D===bc)&&(!C.frustumCulled||r.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(L.matrixWorldInverse,C.matrixWorld);const q=e.update(C),R=C.material;if(Array.isArray(R)){const G=q.groups;for(let Y=0,V=G.length;Y<V;Y++){const K=G[Y],J=R[K.materialIndex];if(J&&J.visible){const X=w(C,J,k,D);C.onBeforeShadow(t,C,T,L,q,X,K),t.renderBufferDirect(L,null,q,X,C,K),C.onAfterShadow(t,C,T,L,q,X,K)}}}else if(R.visible){const G=w(C,R,k,D);C.onBeforeShadow(t,C,T,L,q,G,null),t.renderBufferDirect(L,null,q,G,C,null),C.onAfterShadow(t,C,T,L,q,G,null)}}const O=C.children;for(let q=0,R=O.length;q<R;q++)N(O[q],T,L,k,D)}function A(C){C.target.removeEventListener("dispose",A);for(const L in u){const k=u[L],D=C.target.uuid;D in k&&(k[D].dispose(),delete k[D])}}}const WDe={[xP]:bP,[yP]:wP,[vP]:SP,[Vp]:_P,[bP]:xP,[wP]:yP,[SP]:vP,[_P]:Vp};function qDe(t,e){function n(){let te=!1;const Fe=new di;let xe=null;const ze=new di(0,0,0,0);return{setMask:function(Pe){xe!==Pe&&!te&&(t.colorMask(Pe,Pe,Pe,Pe),xe=Pe)},setLocked:function(Pe){te=Pe},setClear:function(Pe,Se,Ye,dt,Tt){Tt===!0&&(Pe*=dt,Se*=dt,Ye*=dt),Fe.set(Pe,Se,Ye,dt),ze.equals(Fe)===!1&&(t.clearColor(Pe,Se,Ye,dt),ze.copy(Fe))},reset:function(){te=!1,xe=null,ze.set(-1,0,0,0)}}}function r(){let te=!1,Fe=!1,xe=null,ze=null,Pe=null;return{setReversed:function(Se){if(Fe!==Se){const Ye=e.get("EXT_clip_control");Se?Ye.clipControlEXT(Ye.LOWER_LEFT_EXT,Ye.ZERO_TO_ONE_EXT):Ye.clipControlEXT(Ye.LOWER_LEFT_EXT,Ye.NEGATIVE_ONE_TO_ONE_EXT),Fe=Se;const dt=Pe;Pe=null,this.setClear(dt)}},getReversed:function(){return Fe},setTest:function(Se){Se?ue(t.DEPTH_TEST):le(t.DEPTH_TEST)},setMask:function(Se){xe!==Se&&!te&&(t.depthMask(Se),xe=Se)},setFunc:function(Se){if(Fe&&(Se=WDe[Se]),ze!==Se){switch(Se){case xP:t.depthFunc(t.NEVER);break;case bP:t.depthFunc(t.ALWAYS);break;case yP:t.depthFunc(t.LESS);break;case Vp:t.depthFunc(t.LEQUAL);break;case vP:t.depthFunc(t.EQUAL);break;case _P:t.depthFunc(t.GEQUAL);break;case wP:t.depthFunc(t.GREATER);break;case SP:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}ze=Se}},setLocked:function(Se){te=Se},setClear:function(Se){Pe!==Se&&(Fe&&(Se=1-Se),t.clearDepth(Se),Pe=Se)},reset:function(){te=!1,xe=null,ze=null,Pe=null,Fe=!1}}}function i(){let te=!1,Fe=null,xe=null,ze=null,Pe=null,Se=null,Ye=null,dt=null,Tt=null;return{setTest:function(Et){te||(Et?ue(t.STENCIL_TEST):le(t.STENCIL_TEST))},setMask:function(Et){Fe!==Et&&!te&&(t.stencilMask(Et),Fe=Et)},setFunc:function(Et,Zt,Rt){(xe!==Et||ze!==Zt||Pe!==Rt)&&(t.stencilFunc(Et,Zt,Rt),xe=Et,ze=Zt,Pe=Rt)},setOp:function(Et,Zt,Rt){(Se!==Et||Ye!==Zt||dt!==Rt)&&(t.stencilOp(Et,Zt,Rt),Se=Et,Ye=Zt,dt=Rt)},setLocked:function(Et){te=Et},setClear:function(Et){Tt!==Et&&(t.clearStencil(Et),Tt=Et)},reset:function(){te=!1,Fe=null,xe=null,ze=null,Pe=null,Se=null,Ye=null,dt=null,Tt=null}}}const a=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},g=new WeakMap,p=[],x=null,y=!1,b=null,v=null,E=null,w=null,N=null,A=null,C=null,T=new Nn(0,0,0),L=0,k=!1,D=null,U=null,O=null,q=null,R=null;const G=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,V=0;const K=t.getParameter(t.VERSION);K.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(K)[1]),Y=V>=1):K.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),Y=V>=2);let J=null,X={};const F=t.getParameter(t.SCISSOR_BOX),W=t.getParameter(t.VIEWPORT),ee=new di().fromArray(F),ie=new di().fromArray(W);function ae(te,Fe,xe,ze){const Pe=new Uint8Array(4),Se=t.createTexture();t.bindTexture(te,Se),t.texParameteri(te,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(te,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Ye=0;Ye<xe;Ye++)te===t.TEXTURE_3D||te===t.TEXTURE_2D_ARRAY?t.texImage3D(Fe,0,t.RGBA,1,1,ze,0,t.RGBA,t.UNSIGNED_BYTE,Pe):t.texImage2D(Fe+Ye,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Pe);return Se}const de={};de[t.TEXTURE_2D]=ae(t.TEXTURE_2D,t.TEXTURE_2D,1),de[t.TEXTURE_CUBE_MAP]=ae(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),de[t.TEXTURE_2D_ARRAY]=ae(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),de[t.TEXTURE_3D]=ae(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),l.setClear(0),ue(t.DEPTH_TEST),o.setFunc(Vp),se(!1),B(vH),ue(t.CULL_FACE),z(Fc);function ue(te){d[te]!==!0&&(t.enable(te),d[te]=!0)}function le(te){d[te]!==!1&&(t.disable(te),d[te]=!1)}function he(te,Fe){return f[te]!==Fe?(t.bindFramebuffer(te,Fe),f[te]=Fe,te===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=Fe),te===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=Fe),!0):!1}function pe(te,Fe){let xe=p,ze=!1;if(te){xe=g.get(Fe),xe===void 0&&(xe=[],g.set(Fe,xe));const Pe=te.textures;if(xe.length!==Pe.length||xe[0]!==t.COLOR_ATTACHMENT0){for(let Se=0,Ye=Pe.length;Se<Ye;Se++)xe[Se]=t.COLOR_ATTACHMENT0+Se;xe.length=Pe.length,ze=!0}}else xe[0]!==t.BACK&&(xe[0]=t.BACK,ze=!0);ze&&t.drawBuffers(xe)}function Me(te){return x!==te?(t.useProgram(te),x=te,!0):!1}const re={[Eh]:t.FUNC_ADD,[WCe]:t.FUNC_SUBTRACT,[qCe]:t.FUNC_REVERSE_SUBTRACT};re[KCe]=t.MIN,re[XCe]=t.MAX;const We={[YCe]:t.ZERO,[ZCe]:t.ONE,[QCe]:t.SRC_COLOR,[pP]:t.SRC_ALPHA,[ike]:t.SRC_ALPHA_SATURATE,[nke]:t.DST_COLOR,[eke]:t.DST_ALPHA,[JCe]:t.ONE_MINUS_SRC_COLOR,[gP]:t.ONE_MINUS_SRC_ALPHA,[rke]:t.ONE_MINUS_DST_COLOR,[tke]:t.ONE_MINUS_DST_ALPHA,[ake]:t.CONSTANT_COLOR,[ske]:t.ONE_MINUS_CONSTANT_COLOR,[oke]:t.CONSTANT_ALPHA,[lke]:t.ONE_MINUS_CONSTANT_ALPHA};function z(te,Fe,xe,ze,Pe,Se,Ye,dt,Tt,Et){if(te===Fc){y===!0&&(le(t.BLEND),y=!1);return}if(y===!1&&(ue(t.BLEND),y=!0),te!==GCe){if(te!==b||Et!==k){if((v!==Eh||N!==Eh)&&(t.blendEquation(t.FUNC_ADD),v=Eh,N=Eh),Et)switch(te){case _p:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case _H:t.blendFunc(t.ONE,t.ONE);break;case wH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case SH:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:ti("WebGLState: Invalid blending: ",te);break}else switch(te){case _p:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case _H:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case wH:ti("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case SH:ti("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ti("WebGLState: Invalid blending: ",te);break}E=null,w=null,A=null,C=null,T.set(0,0,0),L=0,b=te,k=Et}return}Pe=Pe||Fe,Se=Se||xe,Ye=Ye||ze,(Fe!==v||Pe!==N)&&(t.blendEquationSeparate(re[Fe],re[Pe]),v=Fe,N=Pe),(xe!==E||ze!==w||Se!==A||Ye!==C)&&(t.blendFuncSeparate(We[xe],We[ze],We[Se],We[Ye]),E=xe,w=ze,A=Se,C=Ye),(dt.equals(T)===!1||Tt!==L)&&(t.blendColor(dt.r,dt.g,dt.b,Tt),T.copy(dt),L=Tt),b=te,k=!1}function H(te,Fe){te.side===ml?le(t.CULL_FACE):ue(t.CULL_FACE);let xe=te.side===ss;Fe&&(xe=!xe),se(xe),te.blending===_p&&te.transparent===!1?z(Fc):z(te.blending,te.blendEquation,te.blendSrc,te.blendDst,te.blendEquationAlpha,te.blendSrcAlpha,te.blendDstAlpha,te.blendColor,te.blendAlpha,te.premultipliedAlpha),o.setFunc(te.depthFunc),o.setTest(te.depthTest),o.setMask(te.depthWrite),a.setMask(te.colorWrite);const ze=te.stencilWrite;l.setTest(ze),ze&&(l.setMask(te.stencilWriteMask),l.setFunc(te.stencilFunc,te.stencilRef,te.stencilFuncMask),l.setOp(te.stencilFail,te.stencilZFail,te.stencilZPass)),ce(te.polygonOffset,te.polygonOffsetFactor,te.polygonOffsetUnits),te.alphaToCoverage===!0?ue(t.SAMPLE_ALPHA_TO_COVERAGE):le(t.SAMPLE_ALPHA_TO_COVERAGE)}function se(te){D!==te&&(te?t.frontFace(t.CW):t.frontFace(t.CCW),D=te)}function B(te){te!==HCe?(ue(t.CULL_FACE),te!==U&&(te===vH?t.cullFace(t.BACK):te===$Ce?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):le(t.CULL_FACE),U=te}function Q(te){te!==O&&(Y&&t.lineWidth(te),O=te)}function ce(te,Fe,xe){te?(ue(t.POLYGON_OFFSET_FILL),(q!==Fe||R!==xe)&&(t.polygonOffset(Fe,xe),q=Fe,R=xe)):le(t.POLYGON_OFFSET_FILL)}function Ce(te){te?ue(t.SCISSOR_TEST):le(t.SCISSOR_TEST)}function _e(te){te===void 0&&(te=t.TEXTURE0+G-1),J!==te&&(t.activeTexture(te),J=te)}function Ee(te,Fe,xe){xe===void 0&&(J===null?xe=t.TEXTURE0+G-1:xe=J);let ze=X[xe];ze===void 0&&(ze={type:void 0,texture:void 0},X[xe]=ze),(ze.type!==te||ze.texture!==Fe)&&(J!==xe&&(t.activeTexture(xe),J=xe),t.bindTexture(te,Fe||de[te]),ze.type=te,ze.texture=Fe)}function $(){const te=X[J];te!==void 0&&te.type!==void 0&&(t.bindTexture(te.type,null),te.type=void 0,te.texture=void 0)}function j(){try{t.compressedTexImage2D(...arguments)}catch(te){te("WebGLState:",te)}}function ne(){try{t.compressedTexImage3D(...arguments)}catch(te){te("WebGLState:",te)}}function be(){try{t.texSubImage2D(...arguments)}catch(te){te("WebGLState:",te)}}function we(){try{t.texSubImage3D(...arguments)}catch(te){te("WebGLState:",te)}}function ve(){try{t.compressedTexSubImage2D(...arguments)}catch(te){te("WebGLState:",te)}}function $e(){try{t.compressedTexSubImage3D(...arguments)}catch(te){te("WebGLState:",te)}}function Ge(){try{t.texStorage2D(...arguments)}catch(te){te("WebGLState:",te)}}function Xe(){try{t.texStorage3D(...arguments)}catch(te){te("WebGLState:",te)}}function ut(){try{t.texImage2D(...arguments)}catch(te){te("WebGLState:",te)}}function He(){try{t.texImage3D(...arguments)}catch(te){te("WebGLState:",te)}}function me(te){ee.equals(te)===!1&&(t.scissor(te.x,te.y,te.z,te.w),ee.copy(te))}function Je(te){ie.equals(te)===!1&&(t.viewport(te.x,te.y,te.z,te.w),ie.copy(te))}function Ke(te,Fe){let xe=u.get(Fe);xe===void 0&&(xe=new WeakMap,u.set(Fe,xe));let ze=xe.get(te);ze===void 0&&(ze=t.getUniformBlockIndex(Fe,te.name),xe.set(te,ze))}function Ze(te,Fe){const ze=u.get(Fe).get(te);c.get(Fe)!==ze&&(t.uniformBlockBinding(Fe,ze,te.__bindingPointIndex),c.set(Fe,ze))}function ct(){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),o.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={},J=null,X={},f={},g=new WeakMap,p=[],x=null,y=!1,b=null,v=null,E=null,w=null,N=null,A=null,C=null,T=new Nn(0,0,0),L=0,k=!1,D=null,U=null,O=null,q=null,R=null,ee.set(0,0,t.canvas.width,t.canvas.height),ie.set(0,0,t.canvas.width,t.canvas.height),a.reset(),o.reset(),l.reset()}return{buffers:{color:a,depth:o,stencil:l},enable:ue,disable:le,bindFramebuffer:he,drawBuffers:pe,useProgram:Me,setBlending:z,setMaterial:H,setFlipSided:se,setCullFace:B,setLineWidth:Q,setPolygonOffset:ce,setScissorTest:Ce,activeTexture:_e,bindTexture:Ee,unbindTexture:$,compressedTexImage2D:j,compressedTexImage3D:ne,texImage2D:ut,texImage3D:He,updateUBOMapping:Ke,uniformBlockBinding:Ze,texStorage2D:Ge,texStorage3D:Xe,texSubImage2D:be,texSubImage3D:we,compressedTexSubImage2D:ve,compressedTexSubImage3D:$e,scissor:me,viewport:Je,reset:ct}}function KDe(t,e,n,r,i,a,o){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 x($,j){return p?new OffscreenCanvas($,j):Jw("canvas")}function y($,j,ne){let be=1;const we=Ee($);if((we.width>ne||we.height>ne)&&(be=ne/Math.max(we.width,we.height)),be<1)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap||typeof VideoFrame<"u"&&$ instanceof VideoFrame){const ve=Math.floor(be*we.width),$e=Math.floor(be*we.height);f===void 0&&(f=x(ve,$e));const Ge=j?x(ve,$e):f;return Ge.width=ve,Ge.height=$e,Ge.getContext("2d").drawImage($,0,0,ve,$e),an("WebGLRenderer: Texture has been resized from ("+we.width+"x"+we.height+") to ("+ve+"x"+$e+")."),Ge}else return"data"in $&&an("WebGLRenderer: Image in DataTexture is too big ("+we.width+"x"+we.height+")."),$;return $}function b($){return $.generateMipmaps}function v($){t.generateMipmap($)}function E($){return $.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:$.isWebGL3DRenderTarget?t.TEXTURE_3D:$.isWebGLArrayRenderTarget||$.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function w($,j,ne,be,we=!1){if($!==null){if(t[$]!==void 0)return t[$];an("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let ve=j;if(j===t.RED&&(ne===t.FLOAT&&(ve=t.R32F),ne===t.HALF_FLOAT&&(ve=t.R16F),ne===t.UNSIGNED_BYTE&&(ve=t.R8)),j===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ve=t.R8UI),ne===t.UNSIGNED_SHORT&&(ve=t.R16UI),ne===t.UNSIGNED_INT&&(ve=t.R32UI),ne===t.BYTE&&(ve=t.R8I),ne===t.SHORT&&(ve=t.R16I),ne===t.INT&&(ve=t.R32I)),j===t.RG&&(ne===t.FLOAT&&(ve=t.RG32F),ne===t.HALF_FLOAT&&(ve=t.RG16F),ne===t.UNSIGNED_BYTE&&(ve=t.RG8)),j===t.RG_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ve=t.RG8UI),ne===t.UNSIGNED_SHORT&&(ve=t.RG16UI),ne===t.UNSIGNED_INT&&(ve=t.RG32UI),ne===t.BYTE&&(ve=t.RG8I),ne===t.SHORT&&(ve=t.RG16I),ne===t.INT&&(ve=t.RG32I)),j===t.RGB_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ve=t.RGB8UI),ne===t.UNSIGNED_SHORT&&(ve=t.RGB16UI),ne===t.UNSIGNED_INT&&(ve=t.RGB32UI),ne===t.BYTE&&(ve=t.RGB8I),ne===t.SHORT&&(ve=t.RGB16I),ne===t.INT&&(ve=t.RGB32I)),j===t.RGBA_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ve=t.RGBA8UI),ne===t.UNSIGNED_SHORT&&(ve=t.RGBA16UI),ne===t.UNSIGNED_INT&&(ve=t.RGBA32UI),ne===t.BYTE&&(ve=t.RGBA8I),ne===t.SHORT&&(ve=t.RGBA16I),ne===t.INT&&(ve=t.RGBA32I)),j===t.RGB&&(ne===t.UNSIGNED_INT_5_9_9_9_REV&&(ve=t.RGB9_E5),ne===t.UNSIGNED_INT_10F_11F_11F_REV&&(ve=t.R11F_G11F_B10F)),j===t.RGBA){const $e=we?Zw:Un.getTransfer(be);ne===t.FLOAT&&(ve=t.RGBA32F),ne===t.HALF_FLOAT&&(ve=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(ve=$e===sr?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(ve=t.RGBA4),ne===t.UNSIGNED_SHORT_5_5_5_1&&(ve=t.RGB5_A1)}return(ve===t.R16F||ve===t.R32F||ve===t.RG16F||ve===t.RG32F||ve===t.RGBA16F||ve===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ve}function N($,j){let ne;return $?j===null||j===xf||j===ab?ne=t.DEPTH24_STENCIL8:j===jc?ne=t.DEPTH32F_STENCIL8:j===ib&&(ne=t.DEPTH24_STENCIL8,an("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):j===null||j===xf||j===ab?ne=t.DEPTH_COMPONENT24:j===jc?ne=t.DEPTH_COMPONENT32F:j===ib&&(ne=t.DEPTH_COMPONENT16),ne}function A($,j){return b($)===!0||$.isFramebufferTexture&&$.minFilter!==Rs&&$.minFilter!==ho?Math.log2(Math.max(j.width,j.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?j.mipmaps.length:1}function C($){const j=$.target;j.removeEventListener("dispose",C),L(j),j.isVideoTexture&&d.delete(j)}function T($){const j=$.target;j.removeEventListener("dispose",T),D(j)}function L($){const j=r.get($);if(j.__webglInit===void 0)return;const ne=$.source,be=g.get(ne);if(be){const we=be[j.__cacheKey];we.usedTimes--,we.usedTimes===0&&k($),Object.keys(be).length===0&&g.delete(ne)}r.remove($)}function k($){const j=r.get($);t.deleteTexture(j.__webglTexture);const ne=$.source,be=g.get(ne);delete be[j.__cacheKey],o.memory.textures--}function D($){const j=r.get($);if($.depthTexture&&($.depthTexture.dispose(),r.remove($.depthTexture)),$.isWebGLCubeRenderTarget)for(let be=0;be<6;be++){if(Array.isArray(j.__webglFramebuffer[be]))for(let we=0;we<j.__webglFramebuffer[be].length;we++)t.deleteFramebuffer(j.__webglFramebuffer[be][we]);else t.deleteFramebuffer(j.__webglFramebuffer[be]);j.__webglDepthbuffer&&t.deleteRenderbuffer(j.__webglDepthbuffer[be])}else{if(Array.isArray(j.__webglFramebuffer))for(let be=0;be<j.__webglFramebuffer.length;be++)t.deleteFramebuffer(j.__webglFramebuffer[be]);else t.deleteFramebuffer(j.__webglFramebuffer);if(j.__webglDepthbuffer&&t.deleteRenderbuffer(j.__webglDepthbuffer),j.__webglMultisampledFramebuffer&&t.deleteFramebuffer(j.__webglMultisampledFramebuffer),j.__webglColorRenderbuffer)for(let be=0;be<j.__webglColorRenderbuffer.length;be++)j.__webglColorRenderbuffer[be]&&t.deleteRenderbuffer(j.__webglColorRenderbuffer[be]);j.__webglDepthRenderbuffer&&t.deleteRenderbuffer(j.__webglDepthRenderbuffer)}const ne=$.textures;for(let be=0,we=ne.length;be<we;be++){const ve=r.get(ne[be]);ve.__webglTexture&&(t.deleteTexture(ve.__webglTexture),o.memory.textures--),r.remove(ne[be])}r.remove($)}let U=0;function O(){U=0}function q(){const $=U;return $>=i.maxTextures&&an("WebGLTextures: Trying to use "+$+" texture units while this GPU supports only "+i.maxTextures),U+=1,$}function R($){const j=[];return j.push($.wrapS),j.push($.wrapT),j.push($.wrapR||0),j.push($.magFilter),j.push($.minFilter),j.push($.anisotropy),j.push($.internalFormat),j.push($.format),j.push($.type),j.push($.generateMipmaps),j.push($.premultiplyAlpha),j.push($.flipY),j.push($.unpackAlignment),j.push($.colorSpace),j.join()}function G($,j){const ne=r.get($);if($.isVideoTexture&&Ce($),$.isRenderTargetTexture===!1&&$.isExternalTexture!==!0&&$.version>0&&ne.__version!==$.version){const be=$.image;if(be===null)an("WebGLRenderer: Texture marked for update but no image data found.");else if(be.complete===!1)an("WebGLRenderer: Texture marked for update but image is incomplete");else{de(ne,$,j);return}}else $.isExternalTexture&&(ne.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+j)}function Y($,j){const ne=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&ne.__version!==$.version){de(ne,$,j);return}else $.isExternalTexture&&(ne.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+j)}function V($,j){const ne=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&ne.__version!==$.version){de(ne,$,j);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+j)}function K($,j){const ne=r.get($);if($.version>0&&ne.__version!==$.version){ue(ne,$,j);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+j)}const J={[AP]:t.REPEAT,[Pc]:t.CLAMP_TO_EDGE,[NP]:t.MIRRORED_REPEAT},X={[Rs]:t.NEAREST,[bke]:t.NEAREST_MIPMAP_NEAREST,[Qv]:t.NEAREST_MIPMAP_LINEAR,[ho]:t.LINEAR,[HT]:t.LINEAR_MIPMAP_NEAREST,[Oh]:t.LINEAR_MIPMAP_LINEAR},F={[wke]:t.NEVER,[Tke]:t.ALWAYS,[Ske]:t.LESS,[HZ]:t.LEQUAL,[Mke]:t.EQUAL,[Nke]:t.GEQUAL,[Eke]:t.GREATER,[Ake]:t.NOTEQUAL};function W($,j){if(j.type===jc&&e.has("OES_texture_float_linear")===!1&&(j.magFilter===ho||j.magFilter===HT||j.magFilter===Qv||j.magFilter===Oh||j.minFilter===ho||j.minFilter===HT||j.minFilter===Qv||j.minFilter===Oh)&&an("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri($,t.TEXTURE_WRAP_S,J[j.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,J[j.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,J[j.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,X[j.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,X[j.minFilter]),j.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,F[j.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(j.magFilter===Rs||j.minFilter!==Qv&&j.minFilter!==Oh||j.type===jc&&e.has("OES_texture_float_linear")===!1)return;if(j.anisotropy>1||r.get(j).__currentAnisotropy){const ne=e.get("EXT_texture_filter_anisotropic");t.texParameterf($,ne.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(j.anisotropy,i.getMaxAnisotropy())),r.get(j).__currentAnisotropy=j.anisotropy}}}function ee($,j){let ne=!1;$.__webglInit===void 0&&($.__webglInit=!0,j.addEventListener("dispose",C));const be=j.source;let we=g.get(be);we===void 0&&(we={},g.set(be,we));const ve=R(j);if(ve!==$.__cacheKey){we[ve]===void 0&&(we[ve]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,ne=!0),we[ve].usedTimes++;const $e=we[$.__cacheKey];$e!==void 0&&(we[$.__cacheKey].usedTimes--,$e.usedTimes===0&&k(j)),$.__cacheKey=ve,$.__webglTexture=we[ve].texture}return ne}function ie($,j,ne){return Math.floor(Math.floor($/ne)/j)}function ae($,j,ne,be){const ve=$.updateRanges;if(ve.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,j.width,j.height,ne,be,j.data);else{ve.sort((He,me)=>He.start-me.start);let $e=0;for(let He=1;He<ve.length;He++){const me=ve[$e],Je=ve[He],Ke=me.start+me.count,Ze=ie(Je.start,j.width,4),ct=ie(me.start,j.width,4);Je.start<=Ke+1&&Ze===ct&&ie(Je.start+Je.count-1,j.width,4)===Ze?me.count=Math.max(me.count,Je.start+Je.count-me.start):(++$e,ve[$e]=Je)}ve.length=$e+1;const Ge=t.getParameter(t.UNPACK_ROW_LENGTH),Xe=t.getParameter(t.UNPACK_SKIP_PIXELS),ut=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,j.width);for(let He=0,me=ve.length;He<me;He++){const Je=ve[He],Ke=Math.floor(Je.start/4),Ze=Math.ceil(Je.count/4),ct=Ke%j.width,te=Math.floor(Ke/j.width),Fe=Ze,xe=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ct),t.pixelStorei(t.UNPACK_SKIP_ROWS,te),n.texSubImage2D(t.TEXTURE_2D,0,ct,te,Fe,xe,ne,be,j.data)}$.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ge),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(t.UNPACK_SKIP_ROWS,ut)}}function de($,j,ne){let be=t.TEXTURE_2D;(j.isDataArrayTexture||j.isCompressedArrayTexture)&&(be=t.TEXTURE_2D_ARRAY),j.isData3DTexture&&(be=t.TEXTURE_3D);const we=ee($,j),ve=j.source;n.bindTexture(be,$.__webglTexture,t.TEXTURE0+ne);const $e=r.get(ve);if(ve.version!==$e.__version||we===!0){n.activeTexture(t.TEXTURE0+ne);const Ge=Un.getPrimaries(Un.workingColorSpace),Xe=j.colorSpace===td?null:Un.getPrimaries(j.colorSpace),ut=j.colorSpace===td||Ge===Xe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,j.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,j.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ut);let He=y(j.image,!1,i.maxTextureSize);He=_e(j,He);const me=a.convert(j.format,j.colorSpace),Je=a.convert(j.type);let Ke=w(j.internalFormat,me,Je,j.colorSpace,j.isVideoTexture);W(be,j);let Ze;const ct=j.mipmaps,te=j.isVideoTexture!==!0,Fe=$e.__version===void 0||we===!0,xe=ve.dataReady,ze=A(j,He);if(j.isDepthTexture)Ke=N(j.format===ob,j.type),Fe&&(te?n.texStorage2D(t.TEXTURE_2D,1,Ke,He.width,He.height):n.texImage2D(t.TEXTURE_2D,0,Ke,He.width,He.height,0,me,Je,null));else if(j.isDataTexture)if(ct.length>0){te&&Fe&&n.texStorage2D(t.TEXTURE_2D,ze,Ke,ct[0].width,ct[0].height);for(let Pe=0,Se=ct.length;Pe<Se;Pe++)Ze=ct[Pe],te?xe&&n.texSubImage2D(t.TEXTURE_2D,Pe,0,0,Ze.width,Ze.height,me,Je,Ze.data):n.texImage2D(t.TEXTURE_2D,Pe,Ke,Ze.width,Ze.height,0,me,Je,Ze.data);j.generateMipmaps=!1}else te?(Fe&&n.texStorage2D(t.TEXTURE_2D,ze,Ke,He.width,He.height),xe&&ae(j,He,me,Je)):n.texImage2D(t.TEXTURE_2D,0,Ke,He.width,He.height,0,me,Je,He.data);else if(j.isCompressedTexture)if(j.isCompressedArrayTexture){te&&Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ze,Ke,ct[0].width,ct[0].height,He.depth);for(let Pe=0,Se=ct.length;Pe<Se;Pe++)if(Ze=ct[Pe],j.format!==zo)if(me!==null)if(te){if(xe)if(j.layerUpdates.size>0){const Ye=JH(Ze.width,Ze.height,j.format,j.type);for(const dt of j.layerUpdates){const Tt=Ze.data.subarray(dt*Ye/Ze.data.BYTES_PER_ELEMENT,(dt+1)*Ye/Ze.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Pe,0,0,dt,Ze.width,Ze.height,1,me,Tt)}j.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Pe,0,0,0,Ze.width,Ze.height,He.depth,me,Ze.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Pe,Ke,Ze.width,Ze.height,He.depth,0,Ze.data,0,0);else an("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else te?xe&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Pe,0,0,0,Ze.width,Ze.height,He.depth,me,Je,Ze.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Pe,Ke,Ze.width,Ze.height,He.depth,0,me,Je,Ze.data)}else{te&&Fe&&n.texStorage2D(t.TEXTURE_2D,ze,Ke,ct[0].width,ct[0].height);for(let Pe=0,Se=ct.length;Pe<Se;Pe++)Ze=ct[Pe],j.format!==zo?me!==null?te?xe&&n.compressedTexSubImage2D(t.TEXTURE_2D,Pe,0,0,Ze.width,Ze.height,me,Ze.data):n.compressedTexImage2D(t.TEXTURE_2D,Pe,Ke,Ze.width,Ze.height,0,Ze.data):an("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):te?xe&&n.texSubImage2D(t.TEXTURE_2D,Pe,0,0,Ze.width,Ze.height,me,Je,Ze.data):n.texImage2D(t.TEXTURE_2D,Pe,Ke,Ze.width,Ze.height,0,me,Je,Ze.data)}else if(j.isDataArrayTexture)if(te){if(Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ze,Ke,He.width,He.height,He.depth),xe)if(j.layerUpdates.size>0){const Pe=JH(He.width,He.height,j.format,j.type);for(const Se of j.layerUpdates){const Ye=He.data.subarray(Se*Pe/He.data.BYTES_PER_ELEMENT,(Se+1)*Pe/He.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,Se,He.width,He.height,1,me,Je,Ye)}j.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,He.width,He.height,He.depth,me,Je,He.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Ke,He.width,He.height,He.depth,0,me,Je,He.data);else if(j.isData3DTexture)te?(Fe&&n.texStorage3D(t.TEXTURE_3D,ze,Ke,He.width,He.height,He.depth),xe&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,He.width,He.height,He.depth,me,Je,He.data)):n.texImage3D(t.TEXTURE_3D,0,Ke,He.width,He.height,He.depth,0,me,Je,He.data);else if(j.isFramebufferTexture){if(Fe)if(te)n.texStorage2D(t.TEXTURE_2D,ze,Ke,He.width,He.height);else{let Pe=He.width,Se=He.height;for(let Ye=0;Ye<ze;Ye++)n.texImage2D(t.TEXTURE_2D,Ye,Ke,Pe,Se,0,me,Je,null),Pe>>=1,Se>>=1}}else if(ct.length>0){if(te&&Fe){const Pe=Ee(ct[0]);n.texStorage2D(t.TEXTURE_2D,ze,Ke,Pe.width,Pe.height)}for(let Pe=0,Se=ct.length;Pe<Se;Pe++)Ze=ct[Pe],te?xe&&n.texSubImage2D(t.TEXTURE_2D,Pe,0,0,me,Je,Ze):n.texImage2D(t.TEXTURE_2D,Pe,Ke,me,Je,Ze);j.generateMipmaps=!1}else if(te){if(Fe){const Pe=Ee(He);n.texStorage2D(t.TEXTURE_2D,ze,Ke,Pe.width,Pe.height)}xe&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,me,Je,He)}else n.texImage2D(t.TEXTURE_2D,0,Ke,me,Je,He);b(j)&&v(be),$e.__version=ve.version,j.onUpdate&&j.onUpdate(j)}$.__version=j.version}function ue($,j,ne){if(j.image.length!==6)return;const be=ee($,j),we=j.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+ne);const ve=r.get(we);if(we.version!==ve.__version||be===!0){n.activeTexture(t.TEXTURE0+ne);const $e=Un.getPrimaries(Un.workingColorSpace),Ge=j.colorSpace===td?null:Un.getPrimaries(j.colorSpace),Xe=j.colorSpace===td||$e===Ge?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,j.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,j.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Xe);const ut=j.isCompressedTexture||j.image[0].isCompressedTexture,He=j.image[0]&&j.image[0].isDataTexture,me=[];for(let Se=0;Se<6;Se++)!ut&&!He?me[Se]=y(j.image[Se],!0,i.maxCubemapSize):me[Se]=He?j.image[Se].image:j.image[Se],me[Se]=_e(j,me[Se]);const Je=me[0],Ke=a.convert(j.format,j.colorSpace),Ze=a.convert(j.type),ct=w(j.internalFormat,Ke,Ze,j.colorSpace),te=j.isVideoTexture!==!0,Fe=ve.__version===void 0||be===!0,xe=we.dataReady;let ze=A(j,Je);W(t.TEXTURE_CUBE_MAP,j);let Pe;if(ut){te&&Fe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,ze,ct,Je.width,Je.height);for(let Se=0;Se<6;Se++){Pe=me[Se].mipmaps;for(let Ye=0;Ye<Pe.length;Ye++){const dt=Pe[Ye];j.format!==zo?Ke!==null?te?xe&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye,0,0,dt.width,dt.height,Ke,dt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye,ct,dt.width,dt.height,0,dt.data):an("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):te?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye,0,0,dt.width,dt.height,Ke,Ze,dt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye,ct,dt.width,dt.height,0,Ke,Ze,dt.data)}}}else{if(Pe=j.mipmaps,te&&Fe){Pe.length>0&&ze++;const Se=Ee(me[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,ze,ct,Se.width,Se.height)}for(let Se=0;Se<6;Se++)if(He){te?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,0,0,0,me[Se].width,me[Se].height,Ke,Ze,me[Se].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,0,ct,me[Se].width,me[Se].height,0,Ke,Ze,me[Se].data);for(let Ye=0;Ye<Pe.length;Ye++){const Tt=Pe[Ye].image[Se].image;te?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye+1,0,0,Tt.width,Tt.height,Ke,Ze,Tt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye+1,ct,Tt.width,Tt.height,0,Ke,Ze,Tt.data)}}else{te?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,0,0,0,Ke,Ze,me[Se]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,0,ct,Ke,Ze,me[Se]);for(let Ye=0;Ye<Pe.length;Ye++){const dt=Pe[Ye];te?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye+1,0,0,Ke,Ze,dt.image[Se]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye+1,ct,Ke,Ze,dt.image[Se])}}}b(j)&&v(t.TEXTURE_CUBE_MAP),ve.__version=we.version,j.onUpdate&&j.onUpdate(j)}$.__version=j.version}function le($,j,ne,be,we,ve){const $e=a.convert(ne.format,ne.colorSpace),Ge=a.convert(ne.type),Xe=w(ne.internalFormat,$e,Ge,ne.colorSpace),ut=r.get(j),He=r.get(ne);if(He.__renderTarget=j,!ut.__hasExternalTextures){const me=Math.max(1,j.width>>ve),Je=Math.max(1,j.height>>ve);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,ve,Xe,me,Je,j.depth,0,$e,Ge,null):n.texImage2D(we,ve,Xe,me,Je,0,$e,Ge,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),ce(j)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,be,we,He.__webglTexture,0,Q(j)):(we===t.TEXTURE_2D||we>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,be,we,He.__webglTexture,ve),n.bindFramebuffer(t.FRAMEBUFFER,null)}function he($,j,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,$),j.depthBuffer){const be=j.depthTexture,we=be&&be.isDepthTexture?be.type:null,ve=N(j.stencilBuffer,we),$e=j.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ge=Q(j);ce(j)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ge,ve,j.width,j.height):ne?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ge,ve,j.width,j.height):t.renderbufferStorage(t.RENDERBUFFER,ve,j.width,j.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,$e,t.RENDERBUFFER,$)}else{const be=j.textures;for(let we=0;we<be.length;we++){const ve=be[we],$e=a.convert(ve.format,ve.colorSpace),Ge=a.convert(ve.type),Xe=w(ve.internalFormat,$e,Ge,ve.colorSpace),ut=Q(j);ne&&ce(j)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ut,Xe,j.width,j.height):ce(j)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ut,Xe,j.width,j.height):t.renderbufferStorage(t.RENDERBUFFER,Xe,j.width,j.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function pe($,j){if(j&&j.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(j.depthTexture&&j.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const be=r.get(j.depthTexture);be.__renderTarget=j,(!be.__webglTexture||j.depthTexture.image.width!==j.width||j.depthTexture.image.height!==j.height)&&(j.depthTexture.image.width=j.width,j.depthTexture.image.height=j.height,j.depthTexture.needsUpdate=!0),G(j.depthTexture,0);const we=be.__webglTexture,ve=Q(j);if(j.depthTexture.format===sb)ce(j)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,we,0,ve):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,we,0);else if(j.depthTexture.format===ob)ce(j)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,we,0,ve):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,we,0);else throw new Error("Unknown depthTexture format")}function Me($){const j=r.get($),ne=$.isWebGLCubeRenderTarget===!0;if(j.__boundDepthTexture!==$.depthTexture){const be=$.depthTexture;if(j.__depthDisposeCallback&&j.__depthDisposeCallback(),be){const we=()=>{delete j.__boundDepthTexture,delete j.__depthDisposeCallback,be.removeEventListener("dispose",we)};be.addEventListener("dispose",we),j.__depthDisposeCallback=we}j.__boundDepthTexture=be}if($.depthTexture&&!j.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");const be=$.texture.mipmaps;be&&be.length>0?pe(j.__webglFramebuffer[0],$):pe(j.__webglFramebuffer,$)}else if(ne){j.__webglDepthbuffer=[];for(let be=0;be<6;be++)if(n.bindFramebuffer(t.FRAMEBUFFER,j.__webglFramebuffer[be]),j.__webglDepthbuffer[be]===void 0)j.__webglDepthbuffer[be]=t.createRenderbuffer(),he(j.__webglDepthbuffer[be],$,!1);else{const we=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ve=j.__webglDepthbuffer[be];t.bindRenderbuffer(t.RENDERBUFFER,ve),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,ve)}}else{const be=$.texture.mipmaps;if(be&&be.length>0?n.bindFramebuffer(t.FRAMEBUFFER,j.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,j.__webglFramebuffer),j.__webglDepthbuffer===void 0)j.__webglDepthbuffer=t.createRenderbuffer(),he(j.__webglDepthbuffer,$,!1);else{const we=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ve=j.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ve),t.framebufferRenderbuffer(t.FRAMEBUFFER,we,t.RENDERBUFFER,ve)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function re($,j,ne){const be=r.get($);j!==void 0&&le(be.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&Me($)}function We($){const j=$.texture,ne=r.get($),be=r.get(j);$.addEventListener("dispose",T);const we=$.textures,ve=$.isWebGLCubeRenderTarget===!0,$e=we.length>1;if($e||(be.__webglTexture===void 0&&(be.__webglTexture=t.createTexture()),be.__version=j.version,o.memory.textures++),ve){ne.__webglFramebuffer=[];for(let Ge=0;Ge<6;Ge++)if(j.mipmaps&&j.mipmaps.length>0){ne.__webglFramebuffer[Ge]=[];for(let Xe=0;Xe<j.mipmaps.length;Xe++)ne.__webglFramebuffer[Ge][Xe]=t.createFramebuffer()}else ne.__webglFramebuffer[Ge]=t.createFramebuffer()}else{if(j.mipmaps&&j.mipmaps.length>0){ne.__webglFramebuffer=[];for(let Ge=0;Ge<j.mipmaps.length;Ge++)ne.__webglFramebuffer[Ge]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if($e)for(let Ge=0,Xe=we.length;Ge<Xe;Ge++){const ut=r.get(we[Ge]);ut.__webglTexture===void 0&&(ut.__webglTexture=t.createTexture(),o.memory.textures++)}if($.samples>0&&ce($)===!1){ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let Ge=0;Ge<we.length;Ge++){const Xe=we[Ge];ne.__webglColorRenderbuffer[Ge]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[Ge]);const ut=a.convert(Xe.format,Xe.colorSpace),He=a.convert(Xe.type),me=w(Xe.internalFormat,ut,He,Xe.colorSpace,$.isXRRenderTarget===!0),Je=Q($);t.renderbufferStorageMultisample(t.RENDERBUFFER,Je,me,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ge,t.RENDERBUFFER,ne.__webglColorRenderbuffer[Ge])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),he(ne.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ve){n.bindTexture(t.TEXTURE_CUBE_MAP,be.__webglTexture),W(t.TEXTURE_CUBE_MAP,j);for(let Ge=0;Ge<6;Ge++)if(j.mipmaps&&j.mipmaps.length>0)for(let Xe=0;Xe<j.mipmaps.length;Xe++)le(ne.__webglFramebuffer[Ge][Xe],$,j,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,Xe);else le(ne.__webglFramebuffer[Ge],$,j,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,0);b(j)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if($e){for(let Ge=0,Xe=we.length;Ge<Xe;Ge++){const ut=we[Ge],He=r.get(ut);let me=t.TEXTURE_2D;($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(me=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(me,He.__webglTexture),W(me,ut),le(ne.__webglFramebuffer,$,ut,t.COLOR_ATTACHMENT0+Ge,me,0),b(ut)&&v(me)}n.unbindTexture()}else{let Ge=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(Ge=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ge,be.__webglTexture),W(Ge,j),j.mipmaps&&j.mipmaps.length>0)for(let Xe=0;Xe<j.mipmaps.length;Xe++)le(ne.__webglFramebuffer[Xe],$,j,t.COLOR_ATTACHMENT0,Ge,Xe);else le(ne.__webglFramebuffer,$,j,t.COLOR_ATTACHMENT0,Ge,0);b(j)&&v(Ge),n.unbindTexture()}$.depthBuffer&&Me($)}function z($){const j=$.textures;for(let ne=0,be=j.length;ne<be;ne++){const we=j[ne];if(b(we)){const ve=E($),$e=r.get(we).__webglTexture;n.bindTexture(ve,$e),v(ve),n.unbindTexture()}}}const H=[],se=[];function B($){if($.samples>0){if(ce($)===!1){const j=$.textures,ne=$.width,be=$.height;let we=t.COLOR_BUFFER_BIT;const ve=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,$e=r.get($),Ge=j.length>1;if(Ge)for(let ut=0;ut<j.length;ut++)n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,$e.__webglMultisampledFramebuffer);const Xe=$.texture.mipmaps;Xe&&Xe.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,$e.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,$e.__webglFramebuffer);for(let ut=0;ut<j.length;ut++){if($.resolveDepthBuffer&&($.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&$.resolveStencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),Ge){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,$e.__webglColorRenderbuffer[ut]);const He=r.get(j[ut]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,He,0)}t.blitFramebuffer(0,0,ne,be,0,0,ne,be,we,t.NEAREST),c===!0&&(H.length=0,se.length=0,H.push(t.COLOR_ATTACHMENT0+ut),$.depthBuffer&&$.resolveDepthBuffer===!1&&(H.push(ve),se.push(ve),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,se)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,H))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ge)for(let ut=0;ut<j.length;ut++){n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.RENDERBUFFER,$e.__webglColorRenderbuffer[ut]);const He=r.get(j[ut]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,$e.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.TEXTURE_2D,He,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,$e.__webglMultisampledFramebuffer)}else if($.depthBuffer&&$.resolveDepthBuffer===!1&&c){const j=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[j])}}}function Q($){return Math.min(i.maxSamples,$.samples)}function ce($){const j=r.get($);return $.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&j.__useRenderToTexture!==!1}function Ce($){const j=o.render.frame;d.get($)!==j&&(d.set($,j),$.update())}function _e($,j){const ne=$.colorSpace,be=$.format,we=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||ne!==qp&&ne!==td&&(Un.getTransfer(ne)===sr?(be!==zo||we!==Cl)&&an("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ti("WebGLTextures: Unsupported texture color space:",ne)),j}function Ee($){return typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement?(u.width=$.naturalWidth||$.width,u.height=$.naturalHeight||$.height):typeof VideoFrame<"u"&&$ instanceof VideoFrame?(u.width=$.displayWidth,u.height=$.displayHeight):(u.width=$.width,u.height=$.height),u}this.allocateTextureUnit=q,this.resetTextureUnits=O,this.setTexture2D=G,this.setTexture2DArray=Y,this.setTexture3D=V,this.setTextureCube=K,this.rebindTextures=re,this.setupRenderTarget=We,this.updateRenderTargetMipmap=z,this.updateMultisampleRenderTarget=B,this.setupDepthRenderbuffer=Me,this.setupFrameBufferTexture=le,this.useMultisampledRTT=ce}function XDe(t,e){function n(r,i=td){let a;const o=Un.getTransfer(i);if(r===Cl)return t.UNSIGNED_BYTE;if(r===DO)return t.UNSIGNED_SHORT_4_4_4_4;if(r===OO)return t.UNSIGNED_SHORT_5_5_5_1;if(r===LZ)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===IZ)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===DZ)return t.BYTE;if(r===OZ)return t.SHORT;if(r===ib)return t.UNSIGNED_SHORT;if(r===RO)return t.INT;if(r===xf)return t.UNSIGNED_INT;if(r===jc)return t.FLOAT;if(r===Eg)return t.HALF_FLOAT;if(r===FZ)return t.ALPHA;if(r===UZ)return t.RGB;if(r===zo)return t.RGBA;if(r===sb)return t.DEPTH_COMPONENT;if(r===ob)return t.DEPTH_STENCIL;if(r===zZ)return t.RED;if(r===LO)return t.RED_INTEGER;if(r===IO)return t.RG;if(r===FO)return t.RG_INTEGER;if(r===UO)return t.RGBA_INTEGER;if(r===N1||r===T1||r===C1||r===k1)if(o===sr)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===N1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===T1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===C1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===k1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===N1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===T1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===C1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===k1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===TP||r===CP||r===kP||r===PP)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===TP)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===CP)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===kP)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===PP)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===jP||r===RP||r===DP)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===jP||r===RP)return o===sr?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===DP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===OP||r===LP||r===IP||r===FP||r===UP||r===zP||r===BP||r===HP||r===$P||r===VP||r===GP||r===WP||r===qP||r===KP)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===OP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===LP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===IP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===FP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===UP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===zP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===BP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===HP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===$P)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===VP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===GP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===WP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===qP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===KP)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===XP||r===YP||r===ZP)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===XP)return o===sr?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===YP)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===ZP)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===QP||r===JP||r===ej||r===tj)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===QP)return a.COMPRESSED_RED_RGTC1_EXT;if(r===JP)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===ej)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===tj)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===ab?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const YDe=`
  3905. void main() {
  3906. gl_Position = vec4( position, 1.0 );
  3907. }`,ZDe=`
  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 QDe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new oQ(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 Jc({vertexShader:YDe,fragmentShader:ZDe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new kl(new GO(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let JDe=class extends jf{constructor(e,n){super();const r=this;let i=null,a=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,g=null,p=null,x=null;const y=typeof XRWebGLBinding<"u",b=new QDe,v={},E=n.getContextAttributes();let w=null,N=null;const A=[],C=[],T=new bn;let L=null;const k=new ao;k.viewport=new di;const D=new ao;D.viewport=new di;const U=[k,D],O=new g3e;let q=null,R=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(de){let ue=A[de];return ue===void 0&&(ue=new uC,A[de]=ue),ue.getTargetRaySpace()},this.getControllerGrip=function(de){let ue=A[de];return ue===void 0&&(ue=new uC,A[de]=ue),ue.getGripSpace()},this.getHand=function(de){let ue=A[de];return ue===void 0&&(ue=new uC,A[de]=ue),ue.getHandSpace()};function G(de){const ue=C.indexOf(de.inputSource);if(ue===-1)return;const le=A[ue];le!==void 0&&(le.update(de.inputSource,de.frame,u||o),le.dispatchEvent({type:de.type,data:de.inputSource}))}function Y(){i.removeEventListener("select",G),i.removeEventListener("selectstart",G),i.removeEventListener("selectend",G),i.removeEventListener("squeeze",G),i.removeEventListener("squeezestart",G),i.removeEventListener("squeezeend",G),i.removeEventListener("end",Y),i.removeEventListener("inputsourceschange",V);for(let de=0;de<A.length;de++){const ue=C[de];ue!==null&&(C[de]=null,A[de].disconnect(ue))}q=null,R=null,b.reset();for(const de in v)delete v[de];e.setRenderTarget(w),p=null,g=null,f=null,i=null,N=null,ae.stop(),r.isPresenting=!1,e.setPixelRatio(L),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(de){a=de,r.isPresenting===!0&&an("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(de){l=de,r.isPresenting===!0&&an("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(de){u=de},this.getBaseLayer=function(){return g!==null?g:p},this.getBinding=function(){return f===null&&y&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(de){if(i=de,i!==null){if(w=e.getRenderTarget(),i.addEventListener("select",G),i.addEventListener("selectstart",G),i.addEventListener("selectend",G),i.addEventListener("squeeze",G),i.addEventListener("squeezestart",G),i.addEventListener("squeezeend",G),i.addEventListener("end",Y),i.addEventListener("inputsourceschange",V),E.xrCompatible!==!0&&await n.makeXRCompatible(),L=e.getPixelRatio(),e.getSize(T),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let le=null,he=null,pe=null;E.depth&&(pe=E.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,le=E.stencil?ob:sb,he=E.stencil?ab:xf);const Me={colorFormat:n.RGBA8,depthFormat:pe,scaleFactor:a};f=this.getBinding(),g=f.createProjectionLayer(Me),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),N=new yf(g.textureWidth,g.textureHeight,{format:zo,type:Cl,depthTexture:new sQ(g.textureWidth,g.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,le),stencilBuffer:E.stencil,colorSpace:e.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const le={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,le),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),N=new yf(p.framebufferWidth,p.framebufferHeight,{format:zo,type:Cl,colorSpace:e.outputColorSpace,stencilBuffer:E.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}N.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),ae.setContext(i),ae.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return b.getDepthTexture()};function V(de){for(let ue=0;ue<de.removed.length;ue++){const le=de.removed[ue],he=C.indexOf(le);he>=0&&(C[he]=null,A[he].disconnect(le))}for(let ue=0;ue<de.added.length;ue++){const le=de.added[ue];let he=C.indexOf(le);if(he===-1){for(let Me=0;Me<A.length;Me++)if(Me>=C.length){C.push(le),he=Me;break}else if(C[Me]===null){C[Me]=le,he=Me;break}if(he===-1)break}const pe=A[he];pe&&pe.connect(le)}}const K=new at,J=new at;function X(de,ue,le){K.setFromMatrixPosition(ue.matrixWorld),J.setFromMatrixPosition(le.matrixWorld);const he=K.distanceTo(J),pe=ue.projectionMatrix.elements,Me=le.projectionMatrix.elements,re=pe[14]/(pe[10]-1),We=pe[14]/(pe[10]+1),z=(pe[9]+1)/pe[5],H=(pe[9]-1)/pe[5],se=(pe[8]-1)/pe[0],B=(Me[8]+1)/Me[0],Q=re*se,ce=re*B,Ce=he/(-se+B),_e=Ce*-se;if(ue.matrixWorld.decompose(de.position,de.quaternion,de.scale),de.translateX(_e),de.translateZ(Ce),de.matrixWorld.compose(de.position,de.quaternion,de.scale),de.matrixWorldInverse.copy(de.matrixWorld).invert(),pe[10]===-1)de.projectionMatrix.copy(ue.projectionMatrix),de.projectionMatrixInverse.copy(ue.projectionMatrixInverse);else{const Ee=re+Ce,$=We+Ce,j=Q-_e,ne=ce+(he-_e),be=z*We/$*Ee,we=H*We/$*Ee;de.projectionMatrix.makePerspective(j,ne,be,we,Ee,$),de.projectionMatrixInverse.copy(de.projectionMatrix).invert()}}function F(de,ue){ue===null?de.matrixWorld.copy(de.matrix):de.matrixWorld.multiplyMatrices(ue.matrixWorld,de.matrix),de.matrixWorldInverse.copy(de.matrixWorld).invert()}this.updateCamera=function(de){if(i===null)return;let ue=de.near,le=de.far;b.texture!==null&&(b.depthNear>0&&(ue=b.depthNear),b.depthFar>0&&(le=b.depthFar)),O.near=D.near=k.near=ue,O.far=D.far=k.far=le,(q!==O.near||R!==O.far)&&(i.updateRenderState({depthNear:O.near,depthFar:O.far}),q=O.near,R=O.far),O.layers.mask=de.layers.mask|6,k.layers.mask=O.layers.mask&3,D.layers.mask=O.layers.mask&5;const he=de.parent,pe=O.cameras;F(O,he);for(let Me=0;Me<pe.length;Me++)F(pe[Me],he);pe.length===2?X(O,k,D):O.projectionMatrix.copy(k.projectionMatrix),W(de,O,he)};function W(de,ue,le){le===null?de.matrix.copy(ue.matrixWorld):(de.matrix.copy(le.matrixWorld),de.matrix.invert(),de.matrix.multiply(ue.matrixWorld)),de.matrix.decompose(de.position,de.quaternion,de.scale),de.updateMatrixWorld(!0),de.projectionMatrix.copy(ue.projectionMatrix),de.projectionMatrixInverse.copy(ue.projectionMatrixInverse),de.isPerspectiveCamera&&(de.fov=nj*2*Math.atan(1/de.projectionMatrix.elements[5]),de.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(!(g===null&&p===null))return c},this.setFoveation=function(de){c=de,g!==null&&(g.fixedFoveation=de),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=de)},this.hasDepthSensing=function(){return b.texture!==null},this.getDepthSensingMesh=function(){return b.getMesh(O)},this.getCameraTexture=function(de){return v[de]};let ee=null;function ie(de,ue){if(d=ue.getViewerPose(u||o),x=ue,d!==null){const le=d.views;p!==null&&(e.setRenderTargetFramebuffer(N,p.framebuffer),e.setRenderTarget(N));let he=!1;le.length!==O.cameras.length&&(O.cameras.length=0,he=!0);for(let We=0;We<le.length;We++){const z=le[We];let H=null;if(p!==null)H=p.getViewport(z);else{const B=f.getViewSubImage(g,z);H=B.viewport,We===0&&(e.setRenderTargetTextures(N,B.colorTexture,B.depthStencilTexture),e.setRenderTarget(N))}let se=U[We];se===void 0&&(se=new ao,se.layers.enable(We),se.viewport=new di,U[We]=se),se.matrix.fromArray(z.transform.matrix),se.matrix.decompose(se.position,se.quaternion,se.scale),se.projectionMatrix.fromArray(z.projectionMatrix),se.projectionMatrixInverse.copy(se.projectionMatrix).invert(),se.viewport.set(H.x,H.y,H.width,H.height),We===0&&(O.matrix.copy(se.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),he===!0&&O.cameras.push(se)}const pe=i.enabledFeatures;if(pe&&pe.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){f=r.getBinding();const We=f.getDepthInformation(le[0]);We&&We.isValid&&We.texture&&b.init(We,i.renderState)}if(pe&&pe.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let We=0;We<le.length;We++){const z=le[We].camera;if(z){let H=v[z];H||(H=new oQ,v[z]=H);const se=f.getCameraImage(z);H.sourceTexture=se}}}}for(let le=0;le<A.length;le++){const he=C[le],pe=A[le];he!==null&&pe!==void 0&&pe.update(he,ue,u||o)}ee&&ee(de,ue),ue.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ue}),x=null}const ae=new dQ;ae.setAnimationLoop(ie),this.setAnimationLoop=function(de){ee=de},this.dispose=function(){}}};const fh=new Rd,eOe=new pi;function tOe(t,e){function n(b,v){b.matrixAutoUpdate===!0&&b.updateMatrix(),v.value.copy(b.matrix)}function r(b,v){v.color.getRGB(b.fogColor.value,nQ(t)),v.isFog?(b.fogNear.value=v.near,b.fogFar.value=v.far):v.isFogExp2&&(b.fogDensity.value=v.density)}function i(b,v,E,w,N){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(b,v):v.isMeshToonMaterial?(a(b,v),f(b,v)):v.isMeshPhongMaterial?(a(b,v),d(b,v)):v.isMeshStandardMaterial?(a(b,v),g(b,v),v.isMeshPhysicalMaterial&&p(b,v,N)):v.isMeshMatcapMaterial?(a(b,v),x(b,v)):v.isMeshDepthMaterial?a(b,v):v.isMeshDistanceMaterial?(a(b,v),y(b,v)):v.isMeshNormalMaterial?a(b,v):v.isLineBasicMaterial?(o(b,v),v.isLineDashedMaterial&&l(b,v)):v.isPointsMaterial?c(b,v,E,w):v.isSpriteMaterial?u(b,v):v.isShadowMaterial?(b.color.value.copy(v.color),b.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(b,v){b.opacity.value=v.opacity,v.color&&b.diffuse.value.copy(v.color),v.emissive&&b.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.bumpMap&&(b.bumpMap.value=v.bumpMap,n(v.bumpMap,b.bumpMapTransform),b.bumpScale.value=v.bumpScale,v.side===ss&&(b.bumpScale.value*=-1)),v.normalMap&&(b.normalMap.value=v.normalMap,n(v.normalMap,b.normalMapTransform),b.normalScale.value.copy(v.normalScale),v.side===ss&&b.normalScale.value.negate()),v.displacementMap&&(b.displacementMap.value=v.displacementMap,n(v.displacementMap,b.displacementMapTransform),b.displacementScale.value=v.displacementScale,b.displacementBias.value=v.displacementBias),v.emissiveMap&&(b.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,b.emissiveMapTransform)),v.specularMap&&(b.specularMap.value=v.specularMap,n(v.specularMap,b.specularMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest);const E=e.get(v),w=E.envMap,N=E.envMapRotation;w&&(b.envMap.value=w,fh.copy(N),fh.x*=-1,fh.y*=-1,fh.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(fh.y*=-1,fh.z*=-1),b.envMapRotation.value.setFromMatrix4(eOe.makeRotationFromEuler(fh)),b.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=v.reflectivity,b.ior.value=v.ior,b.refractionRatio.value=v.refractionRatio),v.lightMap&&(b.lightMap.value=v.lightMap,b.lightMapIntensity.value=v.lightMapIntensity,n(v.lightMap,b.lightMapTransform)),v.aoMap&&(b.aoMap.value=v.aoMap,b.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,b.aoMapTransform))}function o(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform))}function l(b,v){b.dashSize.value=v.dashSize,b.totalSize.value=v.dashSize+v.gapSize,b.scale.value=v.scale}function c(b,v,E,w){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.size.value=v.size*E,b.scale.value=w*.5,v.map&&(b.map.value=v.map,n(v.map,b.uvTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function u(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.rotation.value=v.rotation,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function d(b,v){b.specular.value.copy(v.specular),b.shininess.value=Math.max(v.shininess,1e-4)}function f(b,v){v.gradientMap&&(b.gradientMap.value=v.gradientMap)}function g(b,v){b.metalness.value=v.metalness,v.metalnessMap&&(b.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,b.metalnessMapTransform)),b.roughness.value=v.roughness,v.roughnessMap&&(b.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,b.roughnessMapTransform)),v.envMap&&(b.envMapIntensity.value=v.envMapIntensity)}function p(b,v,E){b.ior.value=v.ior,v.sheen>0&&(b.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),b.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(b.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,b.sheenColorMapTransform)),v.sheenRoughnessMap&&(b.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,b.sheenRoughnessMapTransform))),v.clearcoat>0&&(b.clearcoat.value=v.clearcoat,b.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(b.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,b.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(b.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===ss&&b.clearcoatNormalScale.value.negate())),v.dispersion>0&&(b.dispersion.value=v.dispersion),v.iridescence>0&&(b.iridescence.value=v.iridescence,b.iridescenceIOR.value=v.iridescenceIOR,b.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(b.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,b.iridescenceMapTransform)),v.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),v.transmission>0&&(b.transmission.value=v.transmission,b.transmissionSamplerMap.value=E.texture,b.transmissionSamplerSize.value.set(E.width,E.height),v.transmissionMap&&(b.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,b.transmissionMapTransform)),b.thickness.value=v.thickness,v.thicknessMap&&(b.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=v.attenuationDistance,b.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(b.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(b.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=v.specularIntensity,b.specularColor.value.copy(v.specularColor),v.specularColorMap&&(b.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,b.specularColorMapTransform)),v.specularIntensityMap&&(b.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,b.specularIntensityMapTransform))}function x(b,v){v.matcap&&(b.matcap.value=v.matcap)}function y(b,v){const E=e.get(v).light;b.referencePosition.value.setFromMatrixPosition(E.matrixWorld),b.nearDistance.value=E.shadow.camera.near,b.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function nOe(t,e,n,r){let i={},a={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(E,w){const N=w.program;r.uniformBlockBinding(E,N)}function u(E,w){let N=i[E.id];N===void 0&&(x(E),N=d(E),i[E.id]=N,E.addEventListener("dispose",b));const A=w.program;r.updateUBOMapping(E,A);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 N=t.createBuffer(),A=E.__size,C=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,N),t.bufferData(t.UNIFORM_BUFFER,A,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,N),N}function f(){for(let E=0;E<l;E++)if(o.indexOf(E)===-1)return o.push(E),E;return ti("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(E){const w=i[E.id],N=E.uniforms,A=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let C=0,T=N.length;C<T;C++){const L=Array.isArray(N[C])?N[C]:[N[C]];for(let k=0,D=L.length;k<D;k++){const U=L[k];if(p(U,C,k,A)===!0){const O=U.__offset,q=Array.isArray(U.value)?U.value:[U.value];let R=0;for(let G=0;G<q.length;G++){const Y=q[G],V=y(Y);typeof Y=="number"||typeof Y=="boolean"?(U.__data[0]=Y,t.bufferSubData(t.UNIFORM_BUFFER,O+R,U.__data)):Y.isMatrix3?(U.__data[0]=Y.elements[0],U.__data[1]=Y.elements[1],U.__data[2]=Y.elements[2],U.__data[3]=0,U.__data[4]=Y.elements[3],U.__data[5]=Y.elements[4],U.__data[6]=Y.elements[5],U.__data[7]=0,U.__data[8]=Y.elements[6],U.__data[9]=Y.elements[7],U.__data[10]=Y.elements[8],U.__data[11]=0):(Y.toArray(U.__data,R),R+=V.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,O,U.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(E,w,N,A){const C=E.value,T=w+"_"+N;if(A[T]===void 0)return typeof C=="number"||typeof C=="boolean"?A[T]=C:A[T]=C.clone(),!0;{const L=A[T];if(typeof C=="number"||typeof C=="boolean"){if(L!==C)return A[T]=C,!0}else if(L.equals(C)===!1)return L.copy(C),!0}return!1}function x(E){const w=E.uniforms;let N=0;const A=16;for(let T=0,L=w.length;T<L;T++){const k=Array.isArray(w[T])?w[T]:[w[T]];for(let D=0,U=k.length;D<U;D++){const O=k[D],q=Array.isArray(O.value)?O.value:[O.value];for(let R=0,G=q.length;R<G;R++){const Y=q[R],V=y(Y),K=N%A,J=K%V.boundary,X=K+J;N+=J,X!==0&&A-X<V.storage&&(N+=A-X),O.__data=new Float32Array(V.storage/Float32Array.BYTES_PER_ELEMENT),O.__offset=N,N+=V.storage}}}const C=N%A;return C>0&&(N+=A-C),E.__size=N,E.__cache={},this}function y(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?an("WebGLRenderer: Texture samplers can not be part of an uniforms group."):an("WebGLRenderer: Unsupported uniform value type.",E),w}function b(E){const w=E.target;w.removeEventListener("dispose",b);const N=o.indexOf(w.__bindingPointIndex);o.splice(N,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function v(){for(const E in i)t.deleteBuffer(i[E]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}const rOe=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 cc=null;function iOe(){return cc===null&&(cc=new i3e(rOe,32,32,IO,Eg),cc.minFilter=ho,cc.magFilter=ho,cc.wrapS=Pc,cc.wrapT=Pc,cc.generateMipmaps=!1,cc.needsUpdate=!0),cc}let aOe=class{constructor(e={}){const{canvas:n=Cke(),context:r=null,depth:i=!0,stencil:a=!1,alpha:o=!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=o;const x=new Set([UO,FO,LO]),y=new Set([Cl,xf,ib,ab,DO,OO]),b=new Uint32Array(4),v=new Int32Array(4);let E=null,w=null;const N=[],A=[];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=md,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let T=!1;this._outputColorSpace=no;let L=0,k=0,D=null,U=-1,O=null;const q=new di,R=new di;let G=null;const Y=new Nn(0);let V=0,K=n.width,J=n.height,X=1,F=null,W=null;const ee=new di(0,0,K,J),ie=new di(0,0,K,J);let ae=!1;const de=new VO;let ue=!1,le=!1;const he=new pi,pe=new at,Me=new di,re={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let We=!1;function z(){return D===null?X:1}let H=r;function se(oe,Ae){return n.getContext(oe,Ae)}try{const oe={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${PO}`),n.addEventListener("webglcontextlost",Pe,!1),n.addEventListener("webglcontextrestored",Se,!1),n.addEventListener("webglcontextcreationerror",Ye,!1),H===null){const Ae="webgl2";if(H=se(Ae,oe),H===null)throw se(Ae)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(oe){throw oe("WebGLRenderer: "+oe.message),oe}let B,Q,ce,Ce,_e,Ee,$,j,ne,be,we,ve,$e,Ge,Xe,ut,He,me,Je,Ke,Ze,ct,te,Fe;function xe(){B=new fRe(H),B.init(),ct=new XDe(H,B),Q=new iRe(H,B,e,ct),ce=new qDe(H,B),Q.reversedDepthBuffer&&g&&ce.buffers.depth.setReversed(!0),Ce=new gRe(H),_e=new DDe,Ee=new KDe(H,B,ce,_e,Q,ct,Ce),$=new sRe(C),j=new hRe(C),ne=new v3e(H),te=new nRe(H,ne),be=new mRe(H,ne,Ce,te),we=new bRe(H,be,ne,Ce),Je=new xRe(H,Q,Ee),ut=new aRe(_e),ve=new RDe(C,$,j,B,Q,te,ut),$e=new tOe(C,_e),Ge=new LDe,Xe=new HDe(B),me=new tRe(C,$,j,ce,we,p,c),He=new GDe(C,we,Q),Fe=new nOe(H,Ce,Q,ce),Ke=new rRe(H,B,Ce),Ze=new pRe(H,B,Ce),Ce.programs=ve.programs,C.capabilities=Q,C.extensions=B,C.properties=_e,C.renderLists=Ge,C.shadowMap=He,C.state=ce,C.info=Ce}xe();const ze=new JDe(C,H);this.xr=ze,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){const oe=B.get("WEBGL_lose_context");oe&&oe.loseContext()},this.forceContextRestore=function(){const oe=B.get("WEBGL_lose_context");oe&&oe.restoreContext()},this.getPixelRatio=function(){return X},this.setPixelRatio=function(oe){oe!==void 0&&(X=oe,this.setSize(K,J,!1))},this.getSize=function(oe){return oe.set(K,J)},this.setSize=function(oe,Ae,De=!0){if(ze.isPresenting){an("WebGLRenderer: Can't change size while VR device is presenting.");return}K=oe,J=Ae,n.width=Math.floor(oe*X),n.height=Math.floor(Ae*X),De===!0&&(n.style.width=oe+"px",n.style.height=Ae+"px"),this.setViewport(0,0,oe,Ae)},this.getDrawingBufferSize=function(oe){return oe.set(K*X,J*X).floor()},this.setDrawingBufferSize=function(oe,Ae,De){K=oe,J=Ae,X=De,n.width=Math.floor(oe*De),n.height=Math.floor(Ae*De),this.setViewport(0,0,oe,Ae)},this.getCurrentViewport=function(oe){return oe.copy(q)},this.getViewport=function(oe){return oe.copy(ee)},this.setViewport=function(oe,Ae,De,Oe){oe.isVector4?ee.set(oe.x,oe.y,oe.z,oe.w):ee.set(oe,Ae,De,Oe),ce.viewport(q.copy(ee).multiplyScalar(X).round())},this.getScissor=function(oe){return oe.copy(ie)},this.setScissor=function(oe,Ae,De,Oe){oe.isVector4?ie.set(oe.x,oe.y,oe.z,oe.w):ie.set(oe,Ae,De,Oe),ce.scissor(R.copy(ie).multiplyScalar(X).round())},this.getScissorTest=function(){return ae},this.setScissorTest=function(oe){ce.setScissorTest(ae=oe)},this.setOpaqueSort=function(oe){F=oe},this.setTransparentSort=function(oe){W=oe},this.getClearColor=function(oe){return oe.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor(...arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha(...arguments)},this.clear=function(oe=!0,Ae=!0,De=!0){let Oe=0;if(oe){let ke=!1;if(D!==null){const st=D.texture.format;ke=x.has(st)}if(ke){const st=D.texture.type,vt=y.has(st),Ct=me.getClearColor(),Nt=me.getClearAlpha(),Ut=Ct.r,jt=Ct.g,wt=Ct.b;vt?(b[0]=Ut,b[1]=jt,b[2]=wt,b[3]=Nt,H.clearBufferuiv(H.COLOR,0,b)):(v[0]=Ut,v[1]=jt,v[2]=wt,v[3]=Nt,H.clearBufferiv(H.COLOR,0,v))}else Oe|=H.COLOR_BUFFER_BIT}Ae&&(Oe|=H.DEPTH_BUFFER_BIT),De&&(Oe|=H.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H.clear(Oe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Pe,!1),n.removeEventListener("webglcontextrestored",Se,!1),n.removeEventListener("webglcontextcreationerror",Ye,!1),me.dispose(),Ge.dispose(),Xe.dispose(),_e.dispose(),$.dispose(),j.dispose(),we.dispose(),te.dispose(),Fe.dispose(),ve.dispose(),ze.dispose(),ze.removeEventListener("sessionstart",Ln),ze.removeEventListener("sessionend",Vn),tr.stop()};function Pe(oe){oe.preventDefault(),TH("WebGLRenderer: Context Lost."),T=!0}function Se(){TH("WebGLRenderer: Context Restored."),T=!1;const oe=Ce.autoReset,Ae=He.enabled,De=He.autoUpdate,Oe=He.needsUpdate,ke=He.type;xe(),Ce.autoReset=oe,He.enabled=Ae,He.autoUpdate=De,He.needsUpdate=Oe,He.type=ke}function Ye(oe){ti("WebGLRenderer: A WebGL context could not be created. Reason: ",oe.statusMessage)}function dt(oe){const Ae=oe.target;Ae.removeEventListener("dispose",dt),Tt(Ae)}function Tt(oe){Et(oe),_e.remove(oe)}function Et(oe){const Ae=_e.get(oe).programs;Ae!==void 0&&(Ae.forEach(function(De){ve.releaseProgram(De)}),oe.isShaderMaterial&&ve.releaseShaderCache(oe))}this.renderBufferDirect=function(oe,Ae,De,Oe,ke,st){Ae===null&&(Ae=re);const vt=ke.isMesh&&ke.matrixWorld.determinant()<0,Ct=ge(oe,Ae,De,Oe,ke);ce.setMaterial(Oe,vt);let Nt=De.index,Ut=1;if(Oe.wireframe===!0){if(Nt=be.getWireframeAttribute(De),Nt===void 0)return;Ut=2}const jt=De.drawRange,wt=De.attributes.position;let rn=jt.start*Ut,Gt=(jt.start+jt.count)*Ut;st!==null&&(rn=Math.max(rn,st.start*Ut),Gt=Math.min(Gt,(st.start+st.count)*Ut)),Nt!==null?(rn=Math.max(rn,0),Gt=Math.min(Gt,Nt.count)):wt!=null&&(rn=Math.max(rn,0),Gt=Math.min(Gt,wt.count));const mn=Gt-rn;if(mn<0||mn===1/0)return;te.setup(ke,Oe,Ct,De,Nt);let wn,Cn=Ke;if(Nt!==null&&(wn=ne.get(Nt),Cn=Ze,Cn.setIndex(wn)),ke.isMesh)Oe.wireframe===!0?(ce.setLineWidth(Oe.wireframeLinewidth*z()),Cn.setMode(H.LINES)):Cn.setMode(H.TRIANGLES);else if(ke.isLine){let $t=Oe.linewidth;$t===void 0&&($t=1),ce.setLineWidth($t*z()),ke.isLineSegments?Cn.setMode(H.LINES):ke.isLineLoop?Cn.setMode(H.LINE_LOOP):Cn.setMode(H.LINE_STRIP)}else ke.isPoints?Cn.setMode(H.POINTS):ke.isSprite&&Cn.setMode(H.TRIANGLES);if(ke.isBatchedMesh)if(ke._multiDrawInstances!==null)lb("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Cn.renderMultiDrawInstances(ke._multiDrawStarts,ke._multiDrawCounts,ke._multiDrawCount,ke._multiDrawInstances);else if(B.get("WEBGL_multi_draw"))Cn.renderMultiDraw(ke._multiDrawStarts,ke._multiDrawCounts,ke._multiDrawCount);else{const $t=ke._multiDrawStarts,on=ke._multiDrawCounts,un=ke._multiDrawCount,Ur=Nt?ne.get(Nt).bytesPerElement:1,Yr=_e.get(Oe).currentProgram.getUniforms();for(let Gn=0;Gn<un;Gn++)Yr.setValue(H,"_gl_DrawID",Gn),Cn.render($t[Gn]/Ur,on[Gn])}else if(ke.isInstancedMesh)Cn.renderInstances(rn,mn,ke.count);else if(De.isInstancedBufferGeometry){const $t=De._maxInstanceCount!==void 0?De._maxInstanceCount:1/0,on=Math.min(De.instanceCount,$t);Cn.renderInstances(rn,mn,on)}else Cn.render(rn,mn)};function Zt(oe,Ae,De){oe.transparent===!0&&oe.side===ml&&oe.forceSinglePass===!1?(oe.side=ss,oe.needsUpdate=!0,dn(oe,Ae,De),oe.side=jd,oe.needsUpdate=!0,dn(oe,Ae,De),oe.side=ml):dn(oe,Ae,De)}this.compile=function(oe,Ae,De=null){De===null&&(De=oe),w=Xe.get(De),w.init(Ae),A.push(w),De.traverseVisible(function(ke){ke.isLight&&ke.layers.test(Ae.layers)&&(w.pushLight(ke),ke.castShadow&&w.pushShadow(ke))}),oe!==De&&oe.traverseVisible(function(ke){ke.isLight&&ke.layers.test(Ae.layers)&&(w.pushLight(ke),ke.castShadow&&w.pushShadow(ke))}),w.setupLights();const Oe=new Set;return oe.traverse(function(ke){if(!(ke.isMesh||ke.isPoints||ke.isLine||ke.isSprite))return;const st=ke.material;if(st)if(Array.isArray(st))for(let vt=0;vt<st.length;vt++){const Ct=st[vt];Zt(Ct,De,ke),Oe.add(Ct)}else Zt(st,De,ke),Oe.add(st)}),w=A.pop(),Oe},this.compileAsync=function(oe,Ae,De=null){const Oe=this.compile(oe,Ae,De);return new Promise(ke=>{function st(){if(Oe.forEach(function(vt){_e.get(vt).currentProgram.isReady()&&Oe.delete(vt)}),Oe.size===0){ke(oe);return}setTimeout(st,10)}B.get("KHR_parallel_shader_compile")!==null?st():setTimeout(st,10)})};let Rt=null;function en(oe){Rt&&Rt(oe)}function Ln(){tr.stop()}function Vn(){tr.start()}const tr=new dQ;tr.setAnimationLoop(en),typeof self<"u"&&tr.setContext(self),this.setAnimationLoop=function(oe){Rt=oe,ze.setAnimationLoop(oe),oe===null?tr.stop():tr.start()},ze.addEventListener("sessionstart",Ln),ze.addEventListener("sessionend",Vn),this.render=function(oe,Ae){if(Ae!==void 0&&Ae.isCamera!==!0){ti("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;if(oe.matrixWorldAutoUpdate===!0&&oe.updateMatrixWorld(),Ae.parent===null&&Ae.matrixWorldAutoUpdate===!0&&Ae.updateMatrixWorld(),ze.enabled===!0&&ze.isPresenting===!0&&(ze.cameraAutoUpdate===!0&&ze.updateCamera(Ae),Ae=ze.getCamera()),oe.isScene===!0&&oe.onBeforeRender(C,oe,Ae,D),w=Xe.get(oe,A.length),w.init(Ae),A.push(w),he.multiplyMatrices(Ae.projectionMatrix,Ae.matrixWorldInverse),de.setFromProjectionMatrix(he,bl,Ae.reversedDepth),le=this.localClippingEnabled,ue=ut.init(this.clippingPlanes,le),E=Ge.get(oe,N.length),E.init(),N.push(E),ze.enabled===!0&&ze.isPresenting===!0){const st=C.xr.getDepthSensingMesh();st!==null&&gt(st,Ae,-1/0,C.sortObjects)}gt(oe,Ae,0,C.sortObjects),E.finish(),C.sortObjects===!0&&E.sort(F,W),We=ze.enabled===!1||ze.isPresenting===!1||ze.hasDepthSensing()===!1,We&&me.addToRenderList(E,oe),this.info.render.frame++,ue===!0&&ut.beginShadows();const De=w.state.shadowsArray;He.render(De,oe,Ae),ue===!0&&ut.endShadows(),this.info.autoReset===!0&&this.info.reset();const Oe=E.opaque,ke=E.transmissive;if(w.setupLights(),Ae.isArrayCamera){const st=Ae.cameras;if(ke.length>0)for(let vt=0,Ct=st.length;vt<Ct;vt++){const Nt=st[vt];Qt(Oe,ke,oe,Nt)}We&&me.render(oe);for(let vt=0,Ct=st.length;vt<Ct;vt++){const Nt=st[vt];Vt(E,oe,Nt,Nt.viewport)}}else ke.length>0&&Qt(Oe,ke,oe,Ae),We&&me.render(oe),Vt(E,oe,Ae);D!==null&&k===0&&(Ee.updateMultisampleRenderTarget(D),Ee.updateRenderTargetMipmap(D)),oe.isScene===!0&&oe.onAfterRender(C,oe,Ae),te.resetDefaultState(),U=-1,O=null,A.pop(),A.length>0?(w=A[A.length-1],ue===!0&&ut.setGlobalState(C.clippingPlanes,w.state.camera)):w=null,N.pop(),N.length>0?E=N[N.length-1]:E=null};function gt(oe,Ae,De,Oe){if(oe.visible===!1)return;if(oe.layers.test(Ae.layers)){if(oe.isGroup)De=oe.renderOrder;else if(oe.isLOD)oe.autoUpdate===!0&&oe.update(Ae);else if(oe.isLight)w.pushLight(oe),oe.castShadow&&w.pushShadow(oe);else if(oe.isSprite){if(!oe.frustumCulled||de.intersectsSprite(oe)){Oe&&Me.setFromMatrixPosition(oe.matrixWorld).applyMatrix4(he);const vt=we.update(oe),Ct=oe.material;Ct.visible&&E.push(oe,vt,Ct,De,Me.z,null)}}else if((oe.isMesh||oe.isLine||oe.isPoints)&&(!oe.frustumCulled||de.intersectsObject(oe))){const vt=we.update(oe),Ct=oe.material;if(Oe&&(oe.boundingSphere!==void 0?(oe.boundingSphere===null&&oe.computeBoundingSphere(),Me.copy(oe.boundingSphere.center)):(vt.boundingSphere===null&&vt.computeBoundingSphere(),Me.copy(vt.boundingSphere.center)),Me.applyMatrix4(oe.matrixWorld).applyMatrix4(he)),Array.isArray(Ct)){const Nt=vt.groups;for(let Ut=0,jt=Nt.length;Ut<jt;Ut++){const wt=Nt[Ut],rn=Ct[wt.materialIndex];rn&&rn.visible&&E.push(oe,vt,rn,De,Me.z,wt)}}else Ct.visible&&E.push(oe,vt,Ct,De,Me.z,null)}}const st=oe.children;for(let vt=0,Ct=st.length;vt<Ct;vt++)gt(st[vt],Ae,De,Oe)}function Vt(oe,Ae,De,Oe){const{opaque:ke,transmissive:st,transparent:vt}=oe;w.setupLightsView(De),ue===!0&&ut.setGlobalState(C.clippingPlanes,De),Oe&&ce.viewport(q.copy(Oe)),ke.length>0&&mt(ke,Ae,De),st.length>0&&mt(st,Ae,De),vt.length>0&&mt(vt,Ae,De),ce.buffers.depth.setTest(!0),ce.buffers.depth.setMask(!0),ce.buffers.color.setMask(!0),ce.setPolygonOffset(!1)}function Qt(oe,Ae,De,Oe){if((De.isScene===!0?De.overrideMaterial:null)!==null)return;w.state.transmissionRenderTarget[Oe.id]===void 0&&(w.state.transmissionRenderTarget[Oe.id]=new yf(1,1,{generateMipmaps:!0,type:B.has("EXT_color_buffer_half_float")||B.has("EXT_color_buffer_float")?Eg:Cl,minFilter:Oh,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Un.workingColorSpace}));const st=w.state.transmissionRenderTarget[Oe.id],vt=Oe.viewport||q;st.setSize(vt.z*C.transmissionResolutionScale,vt.w*C.transmissionResolutionScale);const Ct=C.getRenderTarget(),Nt=C.getActiveCubeFace(),Ut=C.getActiveMipmapLevel();C.setRenderTarget(st),C.getClearColor(Y),V=C.getClearAlpha(),V<1&&C.setClearColor(16777215,.5),C.clear(),We&&me.render(De);const jt=C.toneMapping;C.toneMapping=md;const wt=Oe.viewport;if(Oe.viewport!==void 0&&(Oe.viewport=void 0),w.setupLightsView(Oe),ue===!0&&ut.setGlobalState(C.clippingPlanes,Oe),mt(oe,De,Oe),Ee.updateMultisampleRenderTarget(st),Ee.updateRenderTargetMipmap(st),B.has("WEBGL_multisampled_render_to_texture")===!1){let rn=!1;for(let Gt=0,mn=Ae.length;Gt<mn;Gt++){const wn=Ae[Gt],{object:Cn,geometry:$t,material:on,group:un}=wn;if(on.side===ml&&Cn.layers.test(Oe.layers)){const Ur=on.side;on.side=ss,on.needsUpdate=!0,Kt(Cn,De,Oe,$t,on,un),on.side=Ur,on.needsUpdate=!0,rn=!0}}rn===!0&&(Ee.updateMultisampleRenderTarget(st),Ee.updateRenderTargetMipmap(st))}C.setRenderTarget(Ct,Nt,Ut),C.setClearColor(Y,V),wt!==void 0&&(Oe.viewport=wt),C.toneMapping=jt}function mt(oe,Ae,De){const Oe=Ae.isScene===!0?Ae.overrideMaterial:null;for(let ke=0,st=oe.length;ke<st;ke++){const vt=oe[ke],{object:Ct,geometry:Nt,group:Ut}=vt;let jt=vt.material;jt.allowOverride===!0&&Oe!==null&&(jt=Oe),Ct.layers.test(De.layers)&&Kt(Ct,Ae,De,Nt,jt,Ut)}}function Kt(oe,Ae,De,Oe,ke,st){oe.onBeforeRender(C,Ae,De,Oe,ke,st),oe.modelViewMatrix.multiplyMatrices(De.matrixWorldInverse,oe.matrixWorld),oe.normalMatrix.getNormalMatrix(oe.modelViewMatrix),ke.onBeforeRender(C,Ae,De,Oe,oe,st),ke.transparent===!0&&ke.side===ml&&ke.forceSinglePass===!1?(ke.side=ss,ke.needsUpdate=!0,C.renderBufferDirect(De,Ae,Oe,ke,oe,st),ke.side=jd,ke.needsUpdate=!0,C.renderBufferDirect(De,Ae,Oe,ke,oe,st),ke.side=ml):C.renderBufferDirect(De,Ae,Oe,ke,oe,st),oe.onAfterRender(C,Ae,De,Oe,ke,st)}function dn(oe,Ae,De){Ae.isScene!==!0&&(Ae=re);const Oe=_e.get(oe),ke=w.state.lights,st=w.state.shadowsArray,vt=ke.state.version,Ct=ve.getParameters(oe,ke.state,st,Ae,De),Nt=ve.getProgramCacheKey(Ct);let Ut=Oe.programs;Oe.environment=oe.isMeshStandardMaterial?Ae.environment:null,Oe.fog=Ae.fog,Oe.envMap=(oe.isMeshStandardMaterial?j:$).get(oe.envMap||Oe.environment),Oe.envMapRotation=Oe.environment!==null&&oe.envMap===null?Ae.environmentRotation:oe.envMapRotation,Ut===void 0&&(oe.addEventListener("dispose",dt),Ut=new Map,Oe.programs=Ut);let jt=Ut.get(Nt);if(jt!==void 0){if(Oe.currentProgram===jt&&Oe.lightsStateVersion===vt)return Re(oe,Ct),jt}else Ct.uniforms=ve.getUniforms(oe),oe.onBeforeCompile(Ct,C),jt=ve.acquireProgram(Ct,Nt),Ut.set(Nt,jt),Oe.uniforms=Ct.uniforms;const wt=Oe.uniforms;return(!oe.isShaderMaterial&&!oe.isRawShaderMaterial||oe.clipping===!0)&&(wt.clippingPlanes=ut.uniform),Re(oe,Ct),Oe.needsLights=Be(oe),Oe.lightsStateVersion=vt,Oe.needsLights&&(wt.ambientLightColor.value=ke.state.ambient,wt.lightProbe.value=ke.state.probe,wt.directionalLights.value=ke.state.directional,wt.directionalLightShadows.value=ke.state.directionalShadow,wt.spotLights.value=ke.state.spot,wt.spotLightShadows.value=ke.state.spotShadow,wt.rectAreaLights.value=ke.state.rectArea,wt.ltc_1.value=ke.state.rectAreaLTC1,wt.ltc_2.value=ke.state.rectAreaLTC2,wt.pointLights.value=ke.state.point,wt.pointLightShadows.value=ke.state.pointShadow,wt.hemisphereLights.value=ke.state.hemi,wt.directionalShadowMap.value=ke.state.directionalShadowMap,wt.directionalShadowMatrix.value=ke.state.directionalShadowMatrix,wt.spotShadowMap.value=ke.state.spotShadowMap,wt.spotLightMatrix.value=ke.state.spotLightMatrix,wt.spotLightMap.value=ke.state.spotLightMap,wt.pointShadowMap.value=ke.state.pointShadowMap,wt.pointShadowMatrix.value=ke.state.pointShadowMatrix),Oe.currentProgram=jt,Oe.uniformsList=null,jt}function Ht(oe){if(oe.uniformsList===null){const Ae=oe.currentProgram.getUniforms();oe.uniformsList=D1.seqWithValue(Ae.seq,oe.uniforms)}return oe.uniformsList}function Re(oe,Ae){const De=_e.get(oe);De.outputColorSpace=Ae.outputColorSpace,De.batching=Ae.batching,De.batchingColor=Ae.batchingColor,De.instancing=Ae.instancing,De.instancingColor=Ae.instancingColor,De.instancingMorph=Ae.instancingMorph,De.skinning=Ae.skinning,De.morphTargets=Ae.morphTargets,De.morphNormals=Ae.morphNormals,De.morphColors=Ae.morphColors,De.morphTargetsCount=Ae.morphTargetsCount,De.numClippingPlanes=Ae.numClippingPlanes,De.numIntersection=Ae.numClipIntersection,De.vertexAlphas=Ae.vertexAlphas,De.vertexTangents=Ae.vertexTangents,De.toneMapping=Ae.toneMapping}function ge(oe,Ae,De,Oe,ke){Ae.isScene!==!0&&(Ae=re),Ee.resetTextureUnits();const st=Ae.fog,vt=Oe.isMeshStandardMaterial?Ae.environment:null,Ct=D===null?C.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:qp,Nt=(Oe.isMeshStandardMaterial?j:$).get(Oe.envMap||vt),Ut=Oe.vertexColors===!0&&!!De.attributes.color&&De.attributes.color.itemSize===4,jt=!!De.attributes.tangent&&(!!Oe.normalMap||Oe.anisotropy>0),wt=!!De.morphAttributes.position,rn=!!De.morphAttributes.normal,Gt=!!De.morphAttributes.color;let mn=md;Oe.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(mn=C.toneMapping);const wn=De.morphAttributes.position||De.morphAttributes.normal||De.morphAttributes.color,Cn=wn!==void 0?wn.length:0,$t=_e.get(Oe),on=w.state.lights;if(ue===!0&&(le===!0||oe!==O)){const Ii=oe===O&&Oe.id===U;ut.setState(Oe,oe,Ii)}let un=!1;Oe.version===$t.__version?($t.needsLights&&$t.lightsStateVersion!==on.state.version||$t.outputColorSpace!==Ct||ke.isBatchedMesh&&$t.batching===!1||!ke.isBatchedMesh&&$t.batching===!0||ke.isBatchedMesh&&$t.batchingColor===!0&&ke.colorTexture===null||ke.isBatchedMesh&&$t.batchingColor===!1&&ke.colorTexture!==null||ke.isInstancedMesh&&$t.instancing===!1||!ke.isInstancedMesh&&$t.instancing===!0||ke.isSkinnedMesh&&$t.skinning===!1||!ke.isSkinnedMesh&&$t.skinning===!0||ke.isInstancedMesh&&$t.instancingColor===!0&&ke.instanceColor===null||ke.isInstancedMesh&&$t.instancingColor===!1&&ke.instanceColor!==null||ke.isInstancedMesh&&$t.instancingMorph===!0&&ke.morphTexture===null||ke.isInstancedMesh&&$t.instancingMorph===!1&&ke.morphTexture!==null||$t.envMap!==Nt||Oe.fog===!0&&$t.fog!==st||$t.numClippingPlanes!==void 0&&($t.numClippingPlanes!==ut.numPlanes||$t.numIntersection!==ut.numIntersection)||$t.vertexAlphas!==Ut||$t.vertexTangents!==jt||$t.morphTargets!==wt||$t.morphNormals!==rn||$t.morphColors!==Gt||$t.toneMapping!==mn||$t.morphTargetsCount!==Cn)&&(un=!0):(un=!0,$t.__version=Oe.version);let Ur=$t.currentProgram;un===!0&&(Ur=dn(Oe,Ae,ke));let Yr=!1,Gn=!1,Mo=!1;const qn=Ur.getUniforms(),Li=$t.uniforms;if(ce.useProgram(Ur.program)&&(Yr=!0,Gn=!0,Mo=!0),Oe.id!==U&&(U=Oe.id,Gn=!0),Yr||O!==oe){ce.buffers.depth.getReversed()&&oe.reversedDepth!==!0&&(oe._reversedDepth=!0,oe.updateProjectionMatrix()),qn.setValue(H,"projectionMatrix",oe.projectionMatrix),qn.setValue(H,"viewMatrix",oe.matrixWorldInverse);const Zi=qn.map.cameraPosition;Zi!==void 0&&Zi.setValue(H,pe.setFromMatrixPosition(oe.matrixWorld)),Q.logarithmicDepthBuffer&&qn.setValue(H,"logDepthBufFC",2/(Math.log(oe.far+1)/Math.LN2)),(Oe.isMeshPhongMaterial||Oe.isMeshToonMaterial||Oe.isMeshLambertMaterial||Oe.isMeshBasicMaterial||Oe.isMeshStandardMaterial||Oe.isShaderMaterial)&&qn.setValue(H,"isOrthographic",oe.isOrthographicCamera===!0),O!==oe&&(O=oe,Gn=!0,Mo=!0)}if(ke.isSkinnedMesh){qn.setOptional(H,ke,"bindMatrix"),qn.setOptional(H,ke,"bindMatrixInverse");const Ii=ke.skeleton;Ii&&(Ii.boneTexture===null&&Ii.computeBoneTexture(),qn.setValue(H,"boneTexture",Ii.boneTexture,Ee))}ke.isBatchedMesh&&(qn.setOptional(H,ke,"batchingTexture"),qn.setValue(H,"batchingTexture",ke._matricesTexture,Ee),qn.setOptional(H,ke,"batchingIdTexture"),qn.setValue(H,"batchingIdTexture",ke._indirectTexture,Ee),qn.setOptional(H,ke,"batchingColorTexture"),ke._colorsTexture!==null&&qn.setValue(H,"batchingColorTexture",ke._colorsTexture,Ee));const xi=De.morphAttributes;if((xi.position!==void 0||xi.normal!==void 0||xi.color!==void 0)&&Je.update(ke,De,Ur),(Gn||$t.receiveShadow!==ke.receiveShadow)&&($t.receiveShadow=ke.receiveShadow,qn.setValue(H,"receiveShadow",ke.receiveShadow)),Oe.isMeshGouraudMaterial&&Oe.envMap!==null&&(Li.envMap.value=Nt,Li.flipEnvMap.value=Nt.isCubeTexture&&Nt.isRenderTargetTexture===!1?-1:1),Oe.isMeshStandardMaterial&&Oe.envMap===null&&Ae.environment!==null&&(Li.envMapIntensity.value=Ae.environmentIntensity),Li.dfgLUT!==void 0&&(Li.dfgLUT.value=iOe()),Gn&&(qn.setValue(H,"toneMappingExposure",C.toneMappingExposure),$t.needsLights&&je(Li,Mo),st&&Oe.fog===!0&&$e.refreshFogUniforms(Li,st),$e.refreshMaterialUniforms(Li,Oe,X,J,w.state.transmissionRenderTarget[oe.id]),D1.upload(H,Ht($t),Li,Ee)),Oe.isShaderMaterial&&Oe.uniformsNeedUpdate===!0&&(D1.upload(H,Ht($t),Li,Ee),Oe.uniformsNeedUpdate=!1),Oe.isSpriteMaterial&&qn.setValue(H,"center",ke.center),qn.setValue(H,"modelViewMatrix",ke.modelViewMatrix),qn.setValue(H,"normalMatrix",ke.normalMatrix),qn.setValue(H,"modelMatrix",ke.matrixWorld),Oe.isShaderMaterial||Oe.isRawShaderMaterial){const Ii=Oe.uniformsGroups;for(let Zi=0,el=Ii.length;Zi<el;Zi++){const zl=Ii[Zi];Fe.update(zl,Ur),Fe.bind(zl,Ur)}}return Ur}function je(oe,Ae){oe.ambientLightColor.needsUpdate=Ae,oe.lightProbe.needsUpdate=Ae,oe.directionalLights.needsUpdate=Ae,oe.directionalLightShadows.needsUpdate=Ae,oe.pointLights.needsUpdate=Ae,oe.pointLightShadows.needsUpdate=Ae,oe.spotLights.needsUpdate=Ae,oe.spotLightShadows.needsUpdate=Ae,oe.rectAreaLights.needsUpdate=Ae,oe.hemisphereLights.needsUpdate=Ae}function Be(oe){return oe.isMeshLambertMaterial||oe.isMeshToonMaterial||oe.isMeshPhongMaterial||oe.isMeshStandardMaterial||oe.isShadowMaterial||oe.isShaderMaterial&&oe.lights===!0}this.getActiveCubeFace=function(){return L},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(oe,Ae,De){const Oe=_e.get(oe);Oe.__autoAllocateDepthBuffer=oe.resolveDepthBuffer===!1,Oe.__autoAllocateDepthBuffer===!1&&(Oe.__useRenderToTexture=!1),_e.get(oe.texture).__webglTexture=Ae,_e.get(oe.depthTexture).__webglTexture=Oe.__autoAllocateDepthBuffer?void 0:De,Oe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(oe,Ae){const De=_e.get(oe);De.__webglFramebuffer=Ae,De.__useDefaultFramebuffer=Ae===void 0};const rt=H.createFramebuffer();this.setRenderTarget=function(oe,Ae=0,De=0){D=oe,L=Ae,k=De;let Oe=!0,ke=null,st=!1,vt=!1;if(oe){const Nt=_e.get(oe);if(Nt.__useDefaultFramebuffer!==void 0)ce.bindFramebuffer(H.FRAMEBUFFER,null),Oe=!1;else if(Nt.__webglFramebuffer===void 0)Ee.setupRenderTarget(oe);else if(Nt.__hasExternalTextures)Ee.rebindTextures(oe,_e.get(oe.texture).__webglTexture,_e.get(oe.depthTexture).__webglTexture);else if(oe.depthBuffer){const wt=oe.depthTexture;if(Nt.__boundDepthTexture!==wt){if(wt!==null&&_e.has(wt)&&(oe.width!==wt.image.width||oe.height!==wt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ee.setupDepthRenderbuffer(oe)}}const Ut=oe.texture;(Ut.isData3DTexture||Ut.isDataArrayTexture||Ut.isCompressedArrayTexture)&&(vt=!0);const jt=_e.get(oe).__webglFramebuffer;oe.isWebGLCubeRenderTarget?(Array.isArray(jt[Ae])?ke=jt[Ae][De]:ke=jt[Ae],st=!0):oe.samples>0&&Ee.useMultisampledRTT(oe)===!1?ke=_e.get(oe).__webglMultisampledFramebuffer:Array.isArray(jt)?ke=jt[De]:ke=jt,q.copy(oe.viewport),R.copy(oe.scissor),G=oe.scissorTest}else q.copy(ee).multiplyScalar(X).floor(),R.copy(ie).multiplyScalar(X).floor(),G=ae;if(De!==0&&(ke=rt),ce.bindFramebuffer(H.FRAMEBUFFER,ke)&&Oe&&ce.drawBuffers(oe,ke),ce.viewport(q),ce.scissor(R),ce.setScissorTest(G),st){const Nt=_e.get(oe.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Nt.__webglTexture,De)}else if(vt){const Nt=Ae;for(let Ut=0;Ut<oe.textures.length;Ut++){const jt=_e.get(oe.textures[Ut]);H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0+Ut,jt.__webglTexture,De,Nt)}}else if(oe!==null&&De!==0){const Nt=_e.get(oe.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,Nt.__webglTexture,De)}U=-1},this.readRenderTargetPixels=function(oe,Ae,De,Oe,ke,st,vt,Ct=0){if(!(oe&&oe.isWebGLRenderTarget)){ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Nt=_e.get(oe).__webglFramebuffer;if(oe.isWebGLCubeRenderTarget&&vt!==void 0&&(Nt=Nt[vt]),Nt){ce.bindFramebuffer(H.FRAMEBUFFER,Nt);try{const Ut=oe.textures[Ct],jt=Ut.format,wt=Ut.type;if(!Q.textureFormatReadable(jt)){ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Q.textureTypeReadable(wt)){ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ae>=0&&Ae<=oe.width-Oe&&De>=0&&De<=oe.height-ke&&(oe.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+Ct),H.readPixels(Ae,De,Oe,ke,ct.convert(jt),ct.convert(wt),st))}finally{const Ut=D!==null?_e.get(D).__webglFramebuffer:null;ce.bindFramebuffer(H.FRAMEBUFFER,Ut)}}},this.readRenderTargetPixelsAsync=async function(oe,Ae,De,Oe,ke,st,vt,Ct=0){if(!(oe&&oe.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Nt=_e.get(oe).__webglFramebuffer;if(oe.isWebGLCubeRenderTarget&&vt!==void 0&&(Nt=Nt[vt]),Nt)if(Ae>=0&&Ae<=oe.width-Oe&&De>=0&&De<=oe.height-ke){ce.bindFramebuffer(H.FRAMEBUFFER,Nt);const Ut=oe.textures[Ct],jt=Ut.format,wt=Ut.type;if(!Q.textureFormatReadable(jt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Q.textureTypeReadable(wt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const rn=H.createBuffer();H.bindBuffer(H.PIXEL_PACK_BUFFER,rn),H.bufferData(H.PIXEL_PACK_BUFFER,st.byteLength,H.STREAM_READ),oe.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+Ct),H.readPixels(Ae,De,Oe,ke,ct.convert(jt),ct.convert(wt),0);const Gt=D!==null?_e.get(D).__webglFramebuffer:null;ce.bindFramebuffer(H.FRAMEBUFFER,Gt);const mn=H.fenceSync(H.SYNC_GPU_COMMANDS_COMPLETE,0);return H.flush(),await kke(H,mn,4),H.bindBuffer(H.PIXEL_PACK_BUFFER,rn),H.getBufferSubData(H.PIXEL_PACK_BUFFER,0,st),H.deleteBuffer(rn),H.deleteSync(mn),st}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(oe,Ae=null,De=0){const Oe=Math.pow(2,-De),ke=Math.floor(oe.image.width*Oe),st=Math.floor(oe.image.height*Oe),vt=Ae!==null?Ae.x:0,Ct=Ae!==null?Ae.y:0;Ee.setTexture2D(oe,0),H.copyTexSubImage2D(H.TEXTURE_2D,De,0,0,vt,Ct,ke,st),ce.unbindTexture()};const tt=H.createFramebuffer(),yt=H.createFramebuffer();this.copyTextureToTexture=function(oe,Ae,De=null,Oe=null,ke=0,st=null){st===null&&(ke!==0?(lb("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),st=ke,ke=0):st=0);let vt,Ct,Nt,Ut,jt,wt,rn,Gt,mn;const wn=oe.isCompressedTexture?oe.mipmaps[st]:oe.image;if(De!==null)vt=De.max.x-De.min.x,Ct=De.max.y-De.min.y,Nt=De.isBox3?De.max.z-De.min.z:1,Ut=De.min.x,jt=De.min.y,wt=De.isBox3?De.min.z:0;else{const xi=Math.pow(2,-ke);vt=Math.floor(wn.width*xi),Ct=Math.floor(wn.height*xi),oe.isDataArrayTexture?Nt=wn.depth:oe.isData3DTexture?Nt=Math.floor(wn.depth*xi):Nt=1,Ut=0,jt=0,wt=0}Oe!==null?(rn=Oe.x,Gt=Oe.y,mn=Oe.z):(rn=0,Gt=0,mn=0);const Cn=ct.convert(Ae.format),$t=ct.convert(Ae.type);let on;Ae.isData3DTexture?(Ee.setTexture3D(Ae,0),on=H.TEXTURE_3D):Ae.isDataArrayTexture||Ae.isCompressedArrayTexture?(Ee.setTexture2DArray(Ae,0),on=H.TEXTURE_2D_ARRAY):(Ee.setTexture2D(Ae,0),on=H.TEXTURE_2D),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,Ae.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ae.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,Ae.unpackAlignment);const un=H.getParameter(H.UNPACK_ROW_LENGTH),Ur=H.getParameter(H.UNPACK_IMAGE_HEIGHT),Yr=H.getParameter(H.UNPACK_SKIP_PIXELS),Gn=H.getParameter(H.UNPACK_SKIP_ROWS),Mo=H.getParameter(H.UNPACK_SKIP_IMAGES);H.pixelStorei(H.UNPACK_ROW_LENGTH,wn.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,wn.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Ut),H.pixelStorei(H.UNPACK_SKIP_ROWS,jt),H.pixelStorei(H.UNPACK_SKIP_IMAGES,wt);const qn=oe.isDataArrayTexture||oe.isData3DTexture,Li=Ae.isDataArrayTexture||Ae.isData3DTexture;if(oe.isDepthTexture){const xi=_e.get(oe),Ii=_e.get(Ae),Zi=_e.get(xi.__renderTarget),el=_e.get(Ii.__renderTarget);ce.bindFramebuffer(H.READ_FRAMEBUFFER,Zi.__webglFramebuffer),ce.bindFramebuffer(H.DRAW_FRAMEBUFFER,el.__webglFramebuffer);for(let zl=0;zl<Nt;zl++)qn&&(H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,_e.get(oe).__webglTexture,ke,wt+zl),H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,_e.get(Ae).__webglTexture,st,mn+zl)),H.blitFramebuffer(Ut,jt,vt,Ct,rn,Gt,vt,Ct,H.DEPTH_BUFFER_BIT,H.NEAREST);ce.bindFramebuffer(H.READ_FRAMEBUFFER,null),ce.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else if(ke!==0||oe.isRenderTargetTexture||_e.has(oe)){const xi=_e.get(oe),Ii=_e.get(Ae);ce.bindFramebuffer(H.READ_FRAMEBUFFER,tt),ce.bindFramebuffer(H.DRAW_FRAMEBUFFER,yt);for(let Zi=0;Zi<Nt;Zi++)qn?H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,xi.__webglTexture,ke,wt+Zi):H.framebufferTexture2D(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,xi.__webglTexture,ke),Li?H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Ii.__webglTexture,st,mn+Zi):H.framebufferTexture2D(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,Ii.__webglTexture,st),ke!==0?H.blitFramebuffer(Ut,jt,vt,Ct,rn,Gt,vt,Ct,H.COLOR_BUFFER_BIT,H.NEAREST):Li?H.copyTexSubImage3D(on,st,rn,Gt,mn+Zi,Ut,jt,vt,Ct):H.copyTexSubImage2D(on,st,rn,Gt,Ut,jt,vt,Ct);ce.bindFramebuffer(H.READ_FRAMEBUFFER,null),ce.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else Li?oe.isDataTexture||oe.isData3DTexture?H.texSubImage3D(on,st,rn,Gt,mn,vt,Ct,Nt,Cn,$t,wn.data):Ae.isCompressedArrayTexture?H.compressedTexSubImage3D(on,st,rn,Gt,mn,vt,Ct,Nt,Cn,wn.data):H.texSubImage3D(on,st,rn,Gt,mn,vt,Ct,Nt,Cn,$t,wn):oe.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,st,rn,Gt,vt,Ct,Cn,$t,wn.data):oe.isCompressedTexture?H.compressedTexSubImage2D(H.TEXTURE_2D,st,rn,Gt,wn.width,wn.height,Cn,wn.data):H.texSubImage2D(H.TEXTURE_2D,st,rn,Gt,vt,Ct,Cn,$t,wn);H.pixelStorei(H.UNPACK_ROW_LENGTH,un),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,Ur),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Yr),H.pixelStorei(H.UNPACK_SKIP_ROWS,Gn),H.pixelStorei(H.UNPACK_SKIP_IMAGES,Mo),st===0&&Ae.generateMipmaps&&H.generateMipmap(on),ce.unbindTexture()},this.initRenderTarget=function(oe){_e.get(oe).__webglFramebuffer===void 0&&Ee.setupRenderTarget(oe)},this.initTexture=function(oe){oe.isCubeTexture?Ee.setTextureCube(oe,0):oe.isData3DTexture?Ee.setTexture3D(oe,0):oe.isDataArrayTexture||oe.isCompressedArrayTexture?Ee.setTexture2DArray(oe,0):Ee.setTexture2D(oe,0),ce.unbindTexture()},this.resetState=function(){L=0,k=0,D=null,ce.reset(),te.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return bl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Un._getDrawingBufferColorSpace(e),n.unpackColorSpace=Un._getUnpackColorSpace()}};const S$={type:"change"},WO={type:"start"},gQ={type:"end"},v_=new BO,M$=new Ku,sOe=Math.cos(70*jke.DEG2RAD),yi=new at,Ja=2*Math.PI,cr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},yC=1e-6;class oOe extends b3e{constructor(e,n=null){super(e,n),this.state=cr.NONE,this.target=new at,this.cursor=new at,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:vp.ROTATE,MIDDLE:vp.DOLLY,RIGHT:vp.PAN},this.touches={ONE:hp.ROTATE,TWO:hp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new at,this._lastQuaternion=new bf,this._lastTargetPosition=new at,this._quat=new bf().setFromUnitVectors(e.up,new at(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new QH,this._sphericalDelta=new QH,this._scale=1,this._panOffset=new at,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 at,this._mouse=new bn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=cOe.bind(this),this._onPointerDown=lOe.bind(this),this._onPointerUp=uOe.bind(this),this._onContextMenu=xOe.bind(this),this._onMouseWheel=fOe.bind(this),this._onKeyDown=mOe.bind(this),this._onTouchStart=pOe.bind(this),this._onTouchMove=gOe.bind(this),this._onMouseDown=dOe.bind(this),this._onMouseMove=hOe.bind(this),this._interceptControlDown=bOe.bind(this),this._interceptControlUp=yOe.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(S$),this.update(),this.state=cr.NONE}update(e=null){const n=this.object.position;yi.copy(n).sub(this.target),yi.applyQuaternion(this._quat),this._spherical.setFromVector3(yi),this.autoRotate&&this.state===cr.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+=Ja:r>Math.PI&&(r-=Ja),i<-Math.PI?i+=Ja:i>Math.PI&&(i-=Ja),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 o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=o!=this._spherical.radius}if(yi.setFromSpherical(this._spherical),yi.applyQuaternion(this._quatInverse),n.copy(this.target).add(yi),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 o=null;if(this.object.isPerspectiveCamera){const l=yi.length();o=this._clampDistance(l*this._scale);const c=l-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),a=!!c}else if(this.object.isOrthographicCamera){const l=new at(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=c!==this.object.zoom;const u=new at(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=yi.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(v_.origin.copy(this.object.position),v_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(v_.direction))<sOe?this.object.lookAt(this.target):(M$.setFromNormalAndCoplanarPoint(this.object.up,this.target),v_.intersectPlane(M$,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>yC||8*(1-this._lastQuaternion.dot(this.object.quaternion))>yC||this._lastTargetPosition.distanceToSquared(this.target)>yC?(this.dispatchEvent(S$),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ja/60*this.autoRotateSpeed*e:Ja/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){yi.setFromMatrixColumn(n,0),yi.multiplyScalar(-e),this._panOffset.add(yi)}_panUp(e,n){this.screenSpacePanning===!0?yi.setFromMatrixColumn(n,1):(yi.setFromMatrixColumn(n,0),yi.crossVectors(this.object.up,yi)),yi.multiplyScalar(e),this._panOffset.add(yi)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;yi.copy(i).sub(this.target);let a=yi.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,o=r.width,l=r.height;this._mouse.x=i/o*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(Ja*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ja*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(Ja*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(-Ja*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(Ja*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(-Ja*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(Ja*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ja*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 o=(e.pageX+n.x)*.5,l=(e.pageY+n.y)*.5;this._updateZoomParameters(o,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 lOe(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 cOe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function uOe(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(gQ),this.state=cr.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 dOe(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 vp.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=cr.DOLLY;break;case vp.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=cr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=cr.ROTATE}break;case vp.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=cr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=cr.PAN}break;default:this.state=cr.NONE}this.state!==cr.NONE&&this.dispatchEvent(WO)}function hOe(t){switch(this.state){case cr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case cr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case cr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function fOe(t){this.enabled===!1||this.enableZoom===!1||this.state!==cr.NONE||(t.preventDefault(),this.dispatchEvent(WO),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(gQ))}function mOe(t){this.enabled!==!1&&this._handleKeyDown(t)}function pOe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case hp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=cr.TOUCH_ROTATE;break;case hp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=cr.TOUCH_PAN;break;default:this.state=cr.NONE}break;case 2:switch(this.touches.TWO){case hp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=cr.TOUCH_DOLLY_PAN;break;case hp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=cr.TOUCH_DOLLY_ROTATE;break;default:this.state=cr.NONE}break;default:this.state=cr.NONE}this.state!==cr.NONE&&this.dispatchEvent(WO)}function gOe(t){switch(this._trackPointer(t),this.state){case cr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case cr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case cr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case cr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=cr.NONE}}function xOe(t){this.enabled!==!1&&t.preventDefault()}function bOe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function yOe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function vOe(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={},o={},l=t[0].morphTargetsRelative,c=new Ul;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;o[p]===void 0&&(o[p]=[]),o[p].push(f.morphAttributes[p])}if(e){let p;if(n)p=f.index.count;else if(f.attributes.position!==void 0)p=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(u,p,d),u+=p}}if(n){let d=0;const f=[];for(let g=0;g<t.length;++g){const p=t[g].index;for(let x=0;x<p.count;++x)f.push(p.getX(x)+d);d+=t[g].attributes.position.count}c.setIndex(f)}for(const d in a){const f=E$(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 o){const f=o[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 y=0;y<o[d].length;++y)p.push(o[d][y][g]);const x=E$(p);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(x)}}return c}function E$(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 o=new e(a),l=new po(o,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=c/n;for(let g=0,p=d.count;g<p;g++)for(let x=0;x<n;x++){const y=d.getComponent(g,x);l.setComponent(g+f,x,y)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}function __(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 vC={exports:{}};var A$;function _Oe(){return A$||(A$=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,a){function o(u,d){if(!i[u]){if(!r[u]){var f=typeof __=="function"&&__;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var g=new Error("Cannot find module '"+u+"'");throw g.code="MODULE_NOT_FOUND",g}var p=i[u]={exports:{}};r[u][0].call(p.exports,function(x){var y=r[u][1][x];return o(y||x)},p,p.exports,n,r,i,a)}return i[u].exports}for(var l=typeof __=="function"&&__,c=0;c<a.length;c++)o(a[c]);return o})({1:[function(n,r,i){var a=n("./utils"),o=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,f,g,p,x,y,b=[],v=0,E=c.length,w=E,N=a.getTypeOf(c)!=="string";v<c.length;)w=E-v,f=N?(u=c[v++],d=v<E?c[v++]:0,v<E?c[v++]:0):(u=c.charCodeAt(v++),d=v<E?c.charCodeAt(v++):0,v<E?c.charCodeAt(v++):0),g=u>>2,p=(3&u)<<4|d>>4,x=1<w?(15&d)<<2|f>>6:64,y=2<w?63&f:64,b.push(l.charAt(g)+l.charAt(p)+l.charAt(x)+l.charAt(y));return b.join("")},i.decode=function(c){var u,d,f,g,p,x,y=0,b=0,v="data:";if(c.substr(0,v.length)===v)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=o.uint8array?new Uint8Array(0|w):new Array(0|w);y<c.length;)u=l.indexOf(c.charAt(y++))<<2|(g=l.indexOf(c.charAt(y++)))>>4,d=(15&g)<<4|(p=l.indexOf(c.charAt(y++)))>>2,f=(3&p)<<6|(x=l.indexOf(c.charAt(y++))),E[b++]=u,p!==64&&(E[b++]=d),x!==64&&(E[b++]=f);return E}},{"./support":30,"./utils":32}],2:[function(n,r,i){var a=n("./external"),o=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,g,p,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=g,this.compression=p,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new o(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 o(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"),o=(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=o,x=g+f;u^=-1;for(var y=g;y<x;y++)u=u>>>8^p[255&(u^d[y])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,g){var p=o,x=g+f;u^=-1;for(var y=g;y<x;y++)u=u>>>8^p[255&(u^d.charCodeAt(y))];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",o=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 o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(g){f.push({data:g,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function a(p,x){var y,b="";for(y=0;y<x;y++)b+=String.fromCharCode(255&p),p>>>=8;return b}function o(p,x,y,b,v,E){var w,N,A=p.file,C=p.compression,T=E!==u.utf8encode,L=l.transformTo("string",E(A.name)),k=l.transformTo("string",u.utf8encode(A.name)),D=A.comment,U=l.transformTo("string",E(D)),O=l.transformTo("string",u.utf8encode(D)),q=k.length!==A.name.length,R=O.length!==D.length,G="",Y="",V="",K=A.dir,J=A.date,X={crc32:0,compressedSize:0,uncompressedSize:0};x&&!y||(X.crc32=p.crc32,X.compressedSize=p.compressedSize,X.uncompressedSize=p.uncompressedSize);var F=0;x&&(F|=8),T||!q&&!R||(F|=2048);var W=0,ee=0;K&&(W|=16),v==="UNIX"?(ee=798,W|=(function(ae,de){var ue=ae;return ae||(ue=de?16893:33204),(65535&ue)<<16})(A.unixPermissions,K)):(ee=20,W|=(function(ae){return 63&(ae||0)})(A.dosPermissions)),w=J.getUTCHours(),w<<=6,w|=J.getUTCMinutes(),w<<=5,w|=J.getUTCSeconds()/2,N=J.getUTCFullYear()-1980,N<<=4,N|=J.getUTCMonth()+1,N<<=5,N|=J.getUTCDate(),q&&(Y=a(1,1)+a(d(L),4)+k,G+="up"+a(Y.length,2)+Y),R&&(V=a(1,1)+a(d(U),4)+O,G+="uc"+a(V.length,2)+V);var ie="";return ie+=`
  3919. \0`,ie+=a(F,2),ie+=C.magic,ie+=a(w,2),ie+=a(N,2),ie+=a(X.crc32,4),ie+=a(X.compressedSize,4),ie+=a(X.uncompressedSize,4),ie+=a(L.length,2),ie+=a(G.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ie+L+G,dirRecord:f.CENTRAL_FILE_HEADER+a(ee,2)+ie+a(U.length,2)+"\0\0\0\0"+a(W,4)+a(b,4)+L+G+U}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function g(p,x,y,b){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=y,this.encodeFileName=b,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(g,c),g.prototype.push=function(p){var x=p.meta.percent||0,y=this.entriesCount,b=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:y?(x+100*(y-b-1))/y:100}}))},g.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var x=this.streamFiles&&!p.file.dir;if(x){var y=o(p,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(p){this.accumulate=!1;var x=this.streamFiles&&!p.file.dir,y=o(p,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),x)this.push({data:(function(b){return f.DATA_DESCRIPTOR+a(b.crc32,4)+a(b.compressedSize,4)+a(b.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var p=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var y=this.bytesWritten-p,b=(function(v,E,w,N,A){var C=l.transformTo("string",A(N));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(v,2)+a(v,2)+a(E,4)+a(w,4)+a(C.length,2)+C})(this.dirRecords.length,y,p,this.zipComment,this.encodeFileName);this.push({data:b,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(p){this._sources.push(p);var x=this;return p.on("data",function(y){x.processChunk(y)}),p.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),p.on("error",function(y){x.error(y)}),this},g.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(p){var x=this._sources;if(!c.prototype.error.call(this,p))return!1;for(var y=0;y<x.length;y++)try{x[y].error(p)}catch{}return!0},g.prototype.lock=function(){c.prototype.lock.call(this);for(var p=this._sources,x=0;x<p.length;x++)p[x].lock()},r.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var a=n("../compressions"),o=n("./ZipFileWorker");i.generateWorker=function(l,c,u){var d=new o(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{l.forEach(function(g,p){f++;var x=(function(E,w){var N=E||w,A=a[N];if(!A)throw new Error(N+" is not a valid compression method !");return A})(p.options.compression,c.compression),y=p.options.compressionOptions||c.compressionOptions||{},b=p.dir,v=p.date;p._compressWorker(x,y).withStreamInfo("file",{name:g,dir:b,date:v,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 o=new a;for(var l in this)typeof this[l]!="function"&&(o[l]=this[l]);return o}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(o,l){return new a().loadAsync(o,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"),o=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(g){return new o.Promise(function(p,x){var y=g.decompressed.getContentWorker().pipe(new u);y.on("error",function(b){x(b)}).on("end",function(){y.streamInfo.crc32!==g.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}r.exports=function(g,p){var x=this;return p=a.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(g)?o.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(y){var b=new c(p);return b.load(y),b}).then(function(y){var b=[o.Promise.resolve(y)],v=y.files;if(p.checkCRC32)for(var E=0;E<v.length;E++)b.push(f(v[E]));return o.Promise.all(b)}).then(function(y){for(var b=y.shift(),v=b.files,E=0;E<v.length;E++){var w=v[E],N=w.fileNameStr,A=a.resolve(w.fileNameStr);x.file(A,w.decompressed,{binary:!0,optimizedBinaryString:!0,date:w.date,dir:w.dir,comment:w.fileCommentStr.length?w.fileCommentStr:null,unixPermissions:w.unixPermissions,dosPermissions:w.dosPermissions,createFolders:p.createFolders}),w.dir||(x.file(A).unsafeOriginalName=N)}return b.zipComment.length&&(x.comment=b.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var a=n("../utils"),o=n("../stream/GenericWorker");function l(c,u){o.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}a.inherits(l,o),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!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!o.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 o(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(o,a),o.prototype._read=function(){this._helper.resume()},r.exports=o},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,o);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,o)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var o=new Buffer(a);return o.fill(0),o},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(A,C,T){var L,k=l.getTypeOf(C),D=l.extend(T||{},d);D.date=D.date||new Date,D.compression!==null&&(D.compression=D.compression.toUpperCase()),typeof D.unixPermissions=="string"&&(D.unixPermissions=parseInt(D.unixPermissions,8)),D.unixPermissions&&16384&D.unixPermissions&&(D.dir=!0),D.dosPermissions&&16&D.dosPermissions&&(D.dir=!0),D.dir&&(A=v(A)),D.createFolders&&(L=b(A))&&E.call(this,L,!0);var U=k==="string"&&D.binary===!1&&D.base64===!1;T&&T.binary!==void 0||(D.binary=!U),(C instanceof f&&C.uncompressedSize===0||D.dir||!C||C.length===0)&&(D.base64=!1,D.binary=!0,C="",D.compression="STORE",k="string");var O=null;O=C instanceof f||C instanceof c?C:x.isNode&&x.isStream(C)?new y(A,C):l.prepareContent(A,C,D.binary,D.optimizedBinaryString,D.base64);var q=new g(A,O,D);this.files[A]=q}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),g=n("./zipObject"),p=n("./generate"),x=n("./nodejsUtils"),y=n("./nodejs/NodejsStreamInputAdapter"),b=function(A){A.slice(-1)==="/"&&(A=A.substring(0,A.length-1));var C=A.lastIndexOf("/");return 0<C?A.substring(0,C):""},v=function(A){return A.slice(-1)!=="/"&&(A+="/"),A},E=function(A,C){return C=C!==void 0?C:d.createFolders,A=v(A),this.files[A]||a.call(this,A,null,{dir:!0,createFolders:C}),this.files[A]};function w(A){return Object.prototype.toString.call(A)==="[object RegExp]"}var N={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(A){var C,T,L;for(C in this.files)L=this.files[C],(T=C.slice(this.root.length,C.length))&&C.slice(0,this.root.length)===this.root&&A(T,L)},filter:function(A){var C=[];return this.forEach(function(T,L){A(T,L)&&C.push(L)}),C},file:function(A,C,T){if(arguments.length!==1)return A=this.root+A,a.call(this,A,C,T),this;if(w(A)){var L=A;return this.filter(function(D,U){return!U.dir&&L.test(D)})}var k=this.files[this.root+A];return k&&!k.dir?k:null},folder:function(A){if(!A)return this;if(w(A))return this.filter(function(k,D){return D.dir&&A.test(k)});var C=this.root+A,T=E.call(this,C),L=this.clone();return L.root=T.name,L},remove:function(A){A=this.root+A;var C=this.files[A];if(C||(A.slice(-1)!=="/"&&(A+="/"),C=this.files[A]),C&&!C.dir)delete this.files[A];else for(var T=this.filter(function(k,D){return D.name.slice(0,A.length)===A}),L=0;L<T.length;L++)delete this.files[T[L].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(A){var C,T={};try{if((T=l.extend(A||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=T.type.toLowerCase(),T.compression=T.compression.toUpperCase(),T.type==="binarystring"&&(T.type="string"),!T.type)throw new Error("No output type specified.");l.checkSupport(T.type),T.platform!=="darwin"&&T.platform!=="freebsd"&&T.platform!=="linux"&&T.platform!=="sunos"||(T.platform="UNIX"),T.platform==="win32"&&(T.platform="DOS");var L=T.comment||this.comment||"";C=p.generateWorker(this,T,L)}catch(k){(C=new c("error")).error(k)}return new u(C,T.type||"string",T.mimeType)},generateAsync:function(A,C){return this.generateInternalStream(A).accumulate(C)},generateNodeStream:function(A,C){return(A=A||{}).type||(A.type="nodebuffer"),this.generateInternalStream(A).toNodejsStream(C)}};r.exports=N},{"./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 o(l){a.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(o,a),o.prototype.byteAt=function(l){return this.data[this.zero+l]},o.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},o.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]},o.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=o},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var a=n("../utils");function o(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}o.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=o},{"../utils":32}],19:[function(n,r,i){var a=n("./Uint8ArrayReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),o.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=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var a=n("./DataReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),o.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},o.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},o.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},o.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=o},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var a=n("./ArrayReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),o.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=o},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var a=n("../utils"),o=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"||o.uint8array?g==="nodebuffer"?new u(f):o.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"),o=n("../utils");function l(c){a.call(this,"ConvertWorker to "+c),this.destType=c}o.inherits(l,a),l.prototype.processChunk=function(c){this.push({data:o.transformTo(this.destType,c.data),meta:c.meta})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var a=n("./GenericWorker"),o=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=o(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"),o=n("./GenericWorker");function l(c){o.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}a.inherits(l,o),l.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}o.prototype.processChunk.call(this,c)},r.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var a=n("../utils"),o=n("./GenericWorker");function l(c){o.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,o),l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!o.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(o){this.name=o||"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(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,l){return this._listeners[o].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,l){if(this._listeners[o])for(var c=0;c<this._listeners[o].length;c++)this._listeners[o][c].call(this,l)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var l=this;return o.on("data",function(c){l.processChunk(c)}),o.on("end",function(){l.end()}),o.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 o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,l){return this.extraStreamInfo[o]=l,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},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 o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},r.exports=a},{}],29:[function(n,r,i){var a=n("../utils"),o=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(x,y){return new d.Promise(function(b,v){var E=[],w=x._internalType,N=x._outputType,A=x._mimeType;x.on("data",function(C,T){E.push(C),y&&y(T)}).on("error",function(C){E=[],v(C)}).on("end",function(){try{var C=(function(T,L,k){switch(T){case"blob":return a.newBlob(a.transformTo("arraybuffer",L),k);case"base64":return c.encode(L);default:return a.transformTo(T,L)}})(N,(function(T,L){var k,D=0,U=null,O=0;for(k=0;k<L.length;k++)O+=L[k].length;switch(T){case"string":return L.join("");case"array":return Array.prototype.concat.apply([],L);case"uint8array":for(U=new Uint8Array(O),k=0;k<L.length;k++)U.set(L[k],D),D+=L[k].length;return U;case"nodebuffer":return Buffer.concat(L);default:throw new Error("concat : unsupported type '"+T+"'")}})(w,E),A);b(C)}catch(T){v(T)}E=[]}).resume()})}function p(x,y,b){var v=y;switch(y){case"blob":case"arraybuffer":v="uint8array";break;case"base64":v="string"}try{this._internalType=v,this._outputType=y,this._mimeType=b,a.checkSupport(v),this._worker=x.pipe(new o(v)),x.lock()}catch(E){this._worker=new l("error"),this._worker.error(E)}}p.prototype={accumulate:function(x){return g(this,x)},on:function(x,y){var b=this;return x==="data"?this._worker.on(x,function(v){y.call(b,v.data,v.meta)}):this._worker.on(x,function(){a.delay(y,arguments,b)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var a=new ArrayBuffer(0);try{i.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(a),i.blob=o.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"),o=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 o.nodebuffer?l.newBufferFrom(p,"utf-8"):(function(x){var y,b,v,E,w,N=x.length,A=0;for(E=0;E<N;E++)(64512&(b=x.charCodeAt(E)))==55296&&E+1<N&&(64512&(v=x.charCodeAt(E+1)))==56320&&(b=65536+(b-55296<<10)+(v-56320),E++),A+=b<128?1:b<2048?2:b<65536?3:4;for(y=o.uint8array?new Uint8Array(A):new Array(A),E=w=0;w<A;E++)(64512&(b=x.charCodeAt(E)))==55296&&E+1<N&&(64512&(v=x.charCodeAt(E+1)))==56320&&(b=65536+(b-55296<<10)+(v-56320),E++),b<128?y[w++]=b:(b<2048?y[w++]=192|b>>>6:(b<65536?y[w++]=224|b>>>12:(y[w++]=240|b>>>18,y[w++]=128|b>>>12&63),y[w++]=128|b>>>6&63),y[w++]=128|63&b);return y})(p)},i.utf8decode=function(p){return o.nodebuffer?a.transformTo("nodebuffer",p).toString("utf-8"):(function(x){var y,b,v,E,w=x.length,N=new Array(2*w);for(y=b=0;y<w;)if((v=x[y++])<128)N[b++]=v;else if(4<(E=u[v]))N[b++]=65533,y+=E-1;else{for(v&=E===2?31:E===3?15:7;1<E&&y<w;)v=v<<6|63&x[y++],E--;1<E?N[b++]=65533:v<65536?N[b++]=v:(v-=65536,N[b++]=55296|v>>10&1023,N[b++]=56320|1023&v)}return N.length!==b&&(N.subarray?N=N.subarray(0,b):N.length=b),a.applyFromCharCode(N)})(p=a.transformTo(o.uint8array?"uint8array":"array",p))},a.inherits(f,c),f.prototype.processChunk=function(p){var x=a.transformTo(o.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var y=x;(x=new Uint8Array(y.length+this.leftOver.length)).set(this.leftOver,0),x.set(y,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var b=(function(E,w){var N;for((w=w||E.length)>E.length&&(w=E.length),N=w-1;0<=N&&(192&E[N])==128;)N--;return N<0||N===0?w:N+u[E[N]]>w?N:w})(x),v=x;b!==x.length&&(o.uint8array?(v=x.subarray(0,b),this.leftOver=x.subarray(b,x.length)):(v=x.slice(0,b),this.leftOver=x.slice(b,x.length))),this.push({data:i.utf8decode(v),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"),o=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(y){return y}function d(y,b){for(var v=0;v<y.length;++v)b[v]=255&y.charCodeAt(v);return b}n("setimmediate"),i.newBlob=function(y,b){i.checkSupport("blob");try{return new Blob([y],{type:b})}catch{try{var v=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return v.append(y),v.getBlob(b)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(y,b,v){var E=[],w=0,N=y.length;if(N<=v)return String.fromCharCode.apply(null,y);for(;w<N;)b==="array"||b==="nodebuffer"?E.push(String.fromCharCode.apply(null,y.slice(w,Math.min(w+v,N)))):E.push(String.fromCharCode.apply(null,y.subarray(w,Math.min(w+v,N)))),w+=v;return E.join("")},stringifyByChar:function(y){for(var b="",v=0;v<y.length;v++)b+=String.fromCharCode(y[v]);return b},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(y){var b=65536,v=i.getTypeOf(y),E=!0;if(v==="uint8array"?E=f.applyCanBeUsed.uint8array:v==="nodebuffer"&&(E=f.applyCanBeUsed.nodebuffer),E)for(;1<b;)try{return f.stringifyByChunk(y,v,b)}catch{b=Math.floor(b/2)}return f.stringifyByChar(y)}function p(y,b){for(var v=0;v<y.length;v++)b[v]=y[v];return b}i.applyFromCharCode=g;var x={};x.string={string:u,array:function(y){return d(y,new Array(y.length))},arraybuffer:function(y){return x.string.uint8array(y).buffer},uint8array:function(y){return d(y,new Uint8Array(y.length))},nodebuffer:function(y){return d(y,l.allocBuffer(y.length))}},x.array={string:g,array:u,arraybuffer:function(y){return new Uint8Array(y).buffer},uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return l.newBufferFrom(y)}},x.arraybuffer={string:function(y){return g(new Uint8Array(y))},array:function(y){return p(new Uint8Array(y),new Array(y.byteLength))},arraybuffer:u,uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return l.newBufferFrom(new Uint8Array(y))}},x.uint8array={string:g,array:function(y){return p(y,new Array(y.length))},arraybuffer:function(y){return y.buffer},uint8array:u,nodebuffer:function(y){return l.newBufferFrom(y)}},x.nodebuffer={string:g,array:function(y){return p(y,new Array(y.length))},arraybuffer:function(y){return x.nodebuffer.uint8array(y).buffer},uint8array:function(y){return p(y,new Uint8Array(y.length))},nodebuffer:u},i.transformTo=function(y,b){if(b=b||"",!y)return b;i.checkSupport(y);var v=i.getTypeOf(b);return x[v][y](b)},i.resolve=function(y){for(var b=y.split("/"),v=[],E=0;E<b.length;E++){var w=b[E];w==="."||w===""&&E!==0&&E!==b.length-1||(w===".."?v.pop():v.push(w))}return v.join("/")},i.getTypeOf=function(y){return typeof y=="string"?"string":Object.prototype.toString.call(y)==="[object Array]"?"array":a.nodebuffer&&l.isBuffer(y)?"nodebuffer":a.uint8array&&y instanceof Uint8Array?"uint8array":a.arraybuffer&&y instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(y){if(!a[y.toLowerCase()])throw new Error(y+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(y){var b,v,E="";for(v=0;v<(y||"").length;v++)E+="\\x"+((b=y.charCodeAt(v))<16?"0":"")+b.toString(16).toUpperCase();return E},i.delay=function(y,b,v){setImmediate(function(){y.apply(v||null,b||[])})},i.inherits=function(y,b){function v(){}v.prototype=b.prototype,y.prototype=new v},i.extend=function(){var y,b,v={};for(y=0;y<arguments.length;y++)for(b in arguments[y])Object.prototype.hasOwnProperty.call(arguments[y],b)&&v[b]===void 0&&(v[b]=arguments[y][b]);return v},i.prepareContent=function(y,b,v,E,w){return c.Promise.resolve(b).then(function(N){return a.blob&&(N instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(N))!==-1)&&typeof FileReader<"u"?new c.Promise(function(A,C){var T=new FileReader;T.onload=function(L){A(L.target.result)},T.onerror=function(L){C(L.target.error)},T.readAsArrayBuffer(N)}):N}).then(function(N){var A=i.getTypeOf(N);return A?(A==="arraybuffer"?N=i.transformTo("uint8array",N):A==="string"&&(w?N=o.decode(N):v&&E!==!0&&(N=(function(C){return d(C,a.uint8array?new Uint8Array(C.length):new Array(C.length))})(N))),N):c.Promise.reject(new Error("Can't read the data of '"+y+"'. 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"),o=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 ("+o.pretty(g)+", expected "+o.pretty(f)+")")}},isSignature:function(f,g){var p=this.reader.index;this.reader.setIndex(f);var x=this.reader.readString(4)===g;return this.reader.setIndex(p),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),g=u.uint8array?"uint8array":"array",p=o.transformTo(g,f);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,g,p,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),g=this.reader.readInt(4),p=this.reader.readData(g),this.zip64ExtensibleData[f]={id:f,length:g,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,g;for(f=0;f<this.files.length;f++)g=this.files[f],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(f=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,l.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var g=f;if(this.checkSignature(l.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var x=g-p;if(0<x)this.isSignature(g,l.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(f){this.reader=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var a=n("./reader/readerFor"),o=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function g(p,x){this.options=p,this.loadOptions=x}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var x,y;if(p.skip(22),this.fileNameLength=p.readInt(2),y=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(y),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=(function(b){for(var v in d)if(Object.prototype.hasOwnProperty.call(d,v)&&d[v].magic===b)return d[v];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,x,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var x=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(x),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=a(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var x,y,b,v=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<v;)x=p.readInt(2),y=p.readInt(2),b=p.readData(y),this.extraFields[x]={id:x,length:y,value:b};p.setIndex(v)},handleUTF8:function(){var p=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var y=o.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var b=this.findExtraFieldUnicodeComment();if(b!==null)this.fileCommentStr=b;else{var v=o.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null}},r.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function a(x,y,b){this.name=x,this.dir=b.dir,this.date=b.date,this.comment=b.comment,this.unixPermissions=b.unixPermissions,this.dosPermissions=b.dosPermissions,this._data=y,this._dataBinary=b.binary,this.options={compression:b.compression,compressionOptions:b.compressionOptions}}var o=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");a.prototype={internalStream:function(x){var y=null,b="string";try{if(!x)throw new Error("No output type specified.");var v=(b=x.toLowerCase())==="string"||b==="text";b!=="binarystring"&&b!=="text"||(b="string"),y=this._decompressWorker();var E=!this._dataBinary;E&&!v&&(y=y.pipe(new c.Utf8EncodeWorker)),!E&&v&&(y=y.pipe(new c.Utf8DecodeWorker))}catch(w){(y=new d("error")).error(w)}return new o(y,b,"")},async:function(x,y){return this.internalStream(x).accumulate(y)},nodeStream:function(x,y){return this.internalStream(x||"nodebuffer").toNodejsStream(y)},_compressWorker:function(x,y){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var b=this._decompressWorker();return this._dataBinary||(b=b.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(b,x,y)},_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 o,l,c=a.MutationObserver||a.WebKitMutationObserver;if(c){var u=0,d=new c(x),f=a.document.createTextNode("");d.observe(f,{characterData:!0}),o=function(){f.data=u=++u%2}}else if(a.setImmediate||a.MessageChannel===void 0)o="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var y=a.document.createElement("script");y.onreadystatechange=function(){x(),y.onreadystatechange=null,y.parentNode.removeChild(y),y=null},a.document.documentElement.appendChild(y)}:function(){setTimeout(x,0)};else{var g=new a.MessageChannel;g.port1.onmessage=x,o=function(){g.port2.postMessage(0)}}var p=[];function x(){var y,b;l=!0;for(var v=p.length;v;){for(b=p,p=[],y=-1;++y<v;)b[y]();v=p.length}l=!1}r.exports=function(y){p.push(y)!==1||l||o()}}).call(this,typeof Cv<"u"?Cv:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var a=n("immediate");function o(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(v){if(typeof v!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,v!==o&&y(this,v)}function g(v,E,w){this.promise=v,typeof E=="function"&&(this.onFulfilled=E,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function p(v,E,w){a(function(){var N;try{N=E(w)}catch(A){return l.reject(v,A)}N===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,N)})}function x(v){var E=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof E=="function")return function(){E.apply(v,arguments)}}function y(v,E){var w=!1;function N(T){w||(w=!0,l.reject(v,T))}function A(T){w||(w=!0,l.resolve(v,T))}var C=b(function(){E(A,N)});C.status==="error"&&N(C.value)}function b(v,E){var w={};try{w.value=v(E),w.status="success"}catch(N){w.status="error",w.value=N}return w}(r.exports=f).prototype.finally=function(v){if(typeof v!="function")return this;var E=this.constructor;return this.then(function(w){return E.resolve(v()).then(function(){return w})},function(w){return E.resolve(v()).then(function(){throw w})})},f.prototype.catch=function(v){return this.then(null,v)},f.prototype.then=function(v,E){if(typeof v!="function"&&this.state===u||typeof E!="function"&&this.state===c)return this;var w=new this.constructor(o);return this.state!==d?p(w,this.state===u?v:E,this.outcome):this.queue.push(new g(w,v,E)),w},g.prototype.callFulfilled=function(v){l.resolve(this.promise,v)},g.prototype.otherCallFulfilled=function(v){p(this.promise,this.onFulfilled,v)},g.prototype.callRejected=function(v){l.reject(this.promise,v)},g.prototype.otherCallRejected=function(v){p(this.promise,this.onRejected,v)},l.resolve=function(v,E){var w=b(x,E);if(w.status==="error")return l.reject(v,w.value);var N=w.value;if(N)y(v,N);else{v.state=u,v.outcome=E;for(var A=-1,C=v.queue.length;++A<C;)v.queue[A].callFulfilled(E)}return v},l.reject=function(v,E){v.state=c,v.outcome=E;for(var w=-1,N=v.queue.length;++w<N;)v.queue[w].callRejected(E);return v},f.resolve=function(v){return v instanceof this?v:l.resolve(new this(o),v)},f.reject=function(v){var E=new this(o);return l.reject(E,v)},f.all=function(v){var E=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=v.length,N=!1;if(!w)return this.resolve([]);for(var A=new Array(w),C=0,T=-1,L=new this(o);++T<w;)k(v[T],T);return L;function k(D,U){E.resolve(D).then(function(O){A[U]=O,++C!==w||N||(N=!0,l.resolve(L,A))},function(O){N||(N=!0,l.reject(L,O))})}},f.race=function(v){var E=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=v.length,N=!1;if(!w)return this.resolve([]);for(var A=-1,C=new this(o);++A<w;)T=v[A],E.resolve(T).then(function(L){N||(N=!0,l.resolve(C,L))},function(L){N||(N=!0,l.reject(C,L))});var T;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"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,g=-1,p=0,x=8;function y(v){if(!(this instanceof y))return new y(v);this.options=o.assign({level:g,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},v||{});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 N;if(N=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,N))!==f)throw new Error(c[w]);this._dict_set=!0}}function b(v,E){var w=new y(E);if(w.push(v,!0),w.err)throw w.msg||c[w.err];return w.result}y.prototype.push=function(v,E){var w,N,A=this.strm,C=this.options.chunkSize;if(this.ended)return!1;N=E===~~E?E:E===!0?4:0,typeof v=="string"?A.input=l.string2buf(v):d.call(v)==="[object ArrayBuffer]"?A.input=new Uint8Array(v):A.input=v,A.next_in=0,A.avail_in=A.input.length;do{if(A.avail_out===0&&(A.output=new o.Buf8(C),A.next_out=0,A.avail_out=C),(w=a.deflate(A,N))!==1&&w!==f)return this.onEnd(w),!(this.ended=!0);A.avail_out!==0&&(A.avail_in!==0||N!==4&&N!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(A.output,A.next_out))):this.onData(o.shrinkBuf(A.output,A.next_out)))}while((0<A.avail_in||A.avail_out===0)&&w!==1);return N===4?(w=a.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===f):N!==2||(this.onEnd(f),!(A.avail_out=0))},y.prototype.onData=function(v){this.chunks.push(v)},y.prototype.onEnd=function(v){v===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},i.Deflate=y,i.deflate=b,i.deflateRaw=function(v,E){return(E=E||{}).raw=!0,b(v,E)},i.gzip=function(v,E){return(E=E||{}).gzip=!0,b(v,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"),o=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(y){if(!(this instanceof p))return new p(y);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},y||{});var b=this.options;b.raw&&0<=b.windowBits&&b.windowBits<16&&(b.windowBits=-b.windowBits,b.windowBits===0&&(b.windowBits=-15)),!(0<=b.windowBits&&b.windowBits<16)||y&&y.windowBits||(b.windowBits+=32),15<b.windowBits&&b.windowBits<48&&(15&b.windowBits)==0&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var v=a.inflateInit2(this.strm,b.windowBits);if(v!==c.Z_OK)throw new Error(u[v]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function x(y,b){var v=new p(b);if(v.push(y,!0),v.err)throw v.msg||u[v.err];return v.result}p.prototype.push=function(y,b){var v,E,w,N,A,C,T=this.strm,L=this.options.chunkSize,k=this.options.dictionary,D=!1;if(this.ended)return!1;E=b===~~b?b:b===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof y=="string"?T.input=l.binstring2buf(y):g.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 o.Buf8(L),T.next_out=0,T.avail_out=L),(v=a.inflate(T,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,v=a.inflateSetDictionary(this.strm,C)),v===c.Z_BUF_ERROR&&D===!0&&(v=c.Z_OK,D=!1),v!==c.Z_STREAM_END&&v!==c.Z_OK)return this.onEnd(v),!(this.ended=!0);T.next_out&&(T.avail_out!==0&&v!==c.Z_STREAM_END&&(T.avail_in!==0||E!==c.Z_FINISH&&E!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=l.utf8border(T.output,T.next_out),N=T.next_out-w,A=l.buf2string(T.output,w),T.next_out=N,T.avail_out=L-N,N&&o.arraySet(T.output,T.output,w,N,0),this.onData(A)):this.onData(o.shrinkBuf(T.output,T.next_out)))),T.avail_in===0&&T.avail_out===0&&(D=!0)}while((0<T.avail_in||T.avail_out===0)&&v!==c.Z_STREAM_END);return v===c.Z_STREAM_END&&(E=c.Z_FINISH),E===c.Z_FINISH?(v=a.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===c.Z_OK):E!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(T.avail_out=0))},p.prototype.onData=function(y){this.chunks.push(y)},p.prototype.onEnd=function(y){y===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Inflate=p,i.inflate=x,i.inflateRaw=function(y,b){return(b=b||{}).raw=!0,x(y,b)},i.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var o={arraySet:function(c,u,d,f,g){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),g);else for(var p=0;p<f;p++)c[g+p]=u[d+p]},flattenChunks:function(c){var u,d,f,g,p,x;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(x=new Uint8Array(f),u=g=0,d=c.length;u<d;u++)p=c[u],x.set(p,g),g+=p.length;return x}},l={arraySet:function(c,u,d,f,g){for(var p=0;p<f;p++)c[g+p]=u[d+p]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(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"),o=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!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&&o))return String.fromCharCode.apply(null,a.shrinkBuf(f,g));for(var p="",x=0;x<g;x++)p+=String.fromCharCode(f[x]);return p}c[254]=c[254]=1,i.string2buf=function(f){var g,p,x,y,b,v=f.length,E=0;for(y=0;y<v;y++)(64512&(p=f.charCodeAt(y)))==55296&&y+1<v&&(64512&(x=f.charCodeAt(y+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),y++),E+=p<128?1:p<2048?2:p<65536?3:4;for(g=new a.Buf8(E),y=b=0;b<E;y++)(64512&(p=f.charCodeAt(y)))==55296&&y+1<v&&(64512&(x=f.charCodeAt(y+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),y++),p<128?g[b++]=p:(p<2048?g[b++]=192|p>>>6:(p<65536?g[b++]=224|p>>>12:(g[b++]=240|p>>>18,g[b++]=128|p>>>12&63),g[b++]=128|p>>>6&63),g[b++]=128|63&p);return g},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var g=new a.Buf8(f.length),p=0,x=g.length;p<x;p++)g[p]=f.charCodeAt(p);return g},i.buf2string=function(f,g){var p,x,y,b,v=g||f.length,E=new Array(2*v);for(p=x=0;p<v;)if((y=f[p++])<128)E[x++]=y;else if(4<(b=c[y]))E[x++]=65533,p+=b-1;else{for(y&=b===2?31:b===3?15:7;1<b&&p<v;)y=y<<6|63&f[p++],b--;1<b?E[x++]=65533:y<65536?E[x++]=y:(y-=65536,E[x++]=55296|y>>10&1023,E[x++]=56320|1023&y)}return d(E,x)},i.utf8border=function(f,g){var p;for((g=g||f.length)>f.length&&(g=f.length),p=g-1;0<=p&&(192&f[p])==128;)p--;return p<0||p===0?g:p+c[f[p]]>g?p:g}},{"./common":41}],43:[function(n,r,i){r.exports=function(a,o,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+o[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 o,l=[],c=0;c<256;c++){o=c;for(var u=0;u<8;u++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();r.exports=function(o,l,c,u){var d=a,f=u+c;o^=-1;for(var g=u;g<f;g++)o=o>>>8^d[255&(o^l[g])];return-1^o}},{}],46:[function(n,r,i){var a,o=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,g=4,p=0,x=-2,y=-1,b=4,v=2,E=8,w=9,N=286,A=30,C=19,T=2*N+1,L=15,k=3,D=258,U=D+k+1,O=42,q=113,R=1,G=2,Y=3,V=4;function K(z,H){return z.msg=d[H],H}function J(z){return(z<<1)-(4<z?9:0)}function X(z){for(var H=z.length;0<=--H;)z[H]=0}function F(z){var H=z.state,se=H.pending;se>z.avail_out&&(se=z.avail_out),se!==0&&(o.arraySet(z.output,H.pending_buf,H.pending_out,se,z.next_out),z.next_out+=se,H.pending_out+=se,z.total_out+=se,z.avail_out-=se,H.pending-=se,H.pending===0&&(H.pending_out=0))}function W(z,H){l._tr_flush_block(z,0<=z.block_start?z.block_start:-1,z.strstart-z.block_start,H),z.block_start=z.strstart,F(z.strm)}function ee(z,H){z.pending_buf[z.pending++]=H}function ie(z,H){z.pending_buf[z.pending++]=H>>>8&255,z.pending_buf[z.pending++]=255&H}function ae(z,H){var se,B,Q=z.max_chain_length,ce=z.strstart,Ce=z.prev_length,_e=z.nice_match,Ee=z.strstart>z.w_size-U?z.strstart-(z.w_size-U):0,$=z.window,j=z.w_mask,ne=z.prev,be=z.strstart+D,we=$[ce+Ce-1],ve=$[ce+Ce];z.prev_length>=z.good_match&&(Q>>=2),_e>z.lookahead&&(_e=z.lookahead);do if($[(se=H)+Ce]===ve&&$[se+Ce-1]===we&&$[se]===$[ce]&&$[++se]===$[ce+1]){ce+=2,se++;do;while($[++ce]===$[++se]&&$[++ce]===$[++se]&&$[++ce]===$[++se]&&$[++ce]===$[++se]&&$[++ce]===$[++se]&&$[++ce]===$[++se]&&$[++ce]===$[++se]&&$[++ce]===$[++se]&&ce<be);if(B=D-(be-ce),ce=be-D,Ce<B){if(z.match_start=H,_e<=(Ce=B))break;we=$[ce+Ce-1],ve=$[ce+Ce]}}while((H=ne[H&j])>Ee&&--Q!=0);return Ce<=z.lookahead?Ce:z.lookahead}function de(z){var H,se,B,Q,ce,Ce,_e,Ee,$,j,ne=z.w_size;do{if(Q=z.window_size-z.lookahead-z.strstart,z.strstart>=ne+(ne-U)){for(o.arraySet(z.window,z.window,ne,ne,0),z.match_start-=ne,z.strstart-=ne,z.block_start-=ne,H=se=z.hash_size;B=z.head[--H],z.head[H]=ne<=B?B-ne:0,--se;);for(H=se=ne;B=z.prev[--H],z.prev[H]=ne<=B?B-ne:0,--se;);Q+=ne}if(z.strm.avail_in===0)break;if(Ce=z.strm,_e=z.window,Ee=z.strstart+z.lookahead,$=Q,j=void 0,j=Ce.avail_in,$<j&&(j=$),se=j===0?0:(Ce.avail_in-=j,o.arraySet(_e,Ce.input,Ce.next_in,j,Ee),Ce.state.wrap===1?Ce.adler=c(Ce.adler,_e,j,Ee):Ce.state.wrap===2&&(Ce.adler=u(Ce.adler,_e,j,Ee)),Ce.next_in+=j,Ce.total_in+=j,j),z.lookahead+=se,z.lookahead+z.insert>=k)for(ce=z.strstart-z.insert,z.ins_h=z.window[ce],z.ins_h=(z.ins_h<<z.hash_shift^z.window[ce+1])&z.hash_mask;z.insert&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[ce+k-1])&z.hash_mask,z.prev[ce&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=ce,ce++,z.insert--,!(z.lookahead+z.insert<k)););}while(z.lookahead<U&&z.strm.avail_in!==0)}function ue(z,H){for(var se,B;;){if(z.lookahead<U){if(de(z),z.lookahead<U&&H===f)return R;if(z.lookahead===0)break}if(se=0,z.lookahead>=k&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+k-1])&z.hash_mask,se=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart),se!==0&&z.strstart-se<=z.w_size-U&&(z.match_length=ae(z,se)),z.match_length>=k)if(B=l._tr_tally(z,z.strstart-z.match_start,z.match_length-k),z.lookahead-=z.match_length,z.match_length<=z.max_lazy_match&&z.lookahead>=k){for(z.match_length--;z.strstart++,z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+k-1])&z.hash_mask,se=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart,--z.match_length!=0;);z.strstart++}else z.strstart+=z.match_length,z.match_length=0,z.ins_h=z.window[z.strstart],z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+1])&z.hash_mask;else B=l._tr_tally(z,0,z.window[z.strstart]),z.lookahead--,z.strstart++;if(B&&(W(z,!1),z.strm.avail_out===0))return R}return z.insert=z.strstart<k-1?z.strstart:k-1,H===g?(W(z,!0),z.strm.avail_out===0?Y:V):z.last_lit&&(W(z,!1),z.strm.avail_out===0)?R:G}function le(z,H){for(var se,B,Q;;){if(z.lookahead<U){if(de(z),z.lookahead<U&&H===f)return R;if(z.lookahead===0)break}if(se=0,z.lookahead>=k&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+k-1])&z.hash_mask,se=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart),z.prev_length=z.match_length,z.prev_match=z.match_start,z.match_length=k-1,se!==0&&z.prev_length<z.max_lazy_match&&z.strstart-se<=z.w_size-U&&(z.match_length=ae(z,se),z.match_length<=5&&(z.strategy===1||z.match_length===k&&4096<z.strstart-z.match_start)&&(z.match_length=k-1)),z.prev_length>=k&&z.match_length<=z.prev_length){for(Q=z.strstart+z.lookahead-k,B=l._tr_tally(z,z.strstart-1-z.prev_match,z.prev_length-k),z.lookahead-=z.prev_length-1,z.prev_length-=2;++z.strstart<=Q&&(z.ins_h=(z.ins_h<<z.hash_shift^z.window[z.strstart+k-1])&z.hash_mask,se=z.prev[z.strstart&z.w_mask]=z.head[z.ins_h],z.head[z.ins_h]=z.strstart),--z.prev_length!=0;);if(z.match_available=0,z.match_length=k-1,z.strstart++,B&&(W(z,!1),z.strm.avail_out===0))return R}else if(z.match_available){if((B=l._tr_tally(z,0,z.window[z.strstart-1]))&&W(z,!1),z.strstart++,z.lookahead--,z.strm.avail_out===0)return R}else z.match_available=1,z.strstart++,z.lookahead--}return z.match_available&&(B=l._tr_tally(z,0,z.window[z.strstart-1]),z.match_available=0),z.insert=z.strstart<k-1?z.strstart:k-1,H===g?(W(z,!0),z.strm.avail_out===0?Y:V):z.last_lit&&(W(z,!1),z.strm.avail_out===0)?R:G}function he(z,H,se,B,Q){this.good_length=z,this.max_lazy=H,this.nice_length=se,this.max_chain=B,this.func=Q}function pe(){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 o.Buf16(2*T),this.dyn_dtree=new o.Buf16(2*(2*A+1)),this.bl_tree=new o.Buf16(2*(2*C+1)),X(this.dyn_ltree),X(this.dyn_dtree),X(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(L+1),this.heap=new o.Buf16(2*N+1),X(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*N+1),X(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 Me(z){var H;return z&&z.state?(z.total_in=z.total_out=0,z.data_type=v,(H=z.state).pending=0,H.pending_out=0,H.wrap<0&&(H.wrap=-H.wrap),H.status=H.wrap?O:q,z.adler=H.wrap===2?0:1,H.last_flush=f,l._tr_init(H),p):K(z,x)}function re(z){var H=Me(z);return H===p&&(function(se){se.window_size=2*se.w_size,X(se.head),se.max_lazy_match=a[se.level].max_lazy,se.good_match=a[se.level].good_length,se.nice_match=a[se.level].nice_length,se.max_chain_length=a[se.level].max_chain,se.strstart=0,se.block_start=0,se.lookahead=0,se.insert=0,se.match_length=se.prev_length=k-1,se.match_available=0,se.ins_h=0})(z.state),H}function We(z,H,se,B,Q,ce){if(!z)return x;var Ce=1;if(H===y&&(H=6),B<0?(Ce=0,B=-B):15<B&&(Ce=2,B-=16),Q<1||w<Q||se!==E||B<8||15<B||H<0||9<H||ce<0||b<ce)return K(z,x);B===8&&(B=9);var _e=new pe;return(z.state=_e).strm=z,_e.wrap=Ce,_e.gzhead=null,_e.w_bits=B,_e.w_size=1<<_e.w_bits,_e.w_mask=_e.w_size-1,_e.hash_bits=Q+7,_e.hash_size=1<<_e.hash_bits,_e.hash_mask=_e.hash_size-1,_e.hash_shift=~~((_e.hash_bits+k-1)/k),_e.window=new o.Buf8(2*_e.w_size),_e.head=new o.Buf16(_e.hash_size),_e.prev=new o.Buf16(_e.w_size),_e.lit_bufsize=1<<Q+6,_e.pending_buf_size=4*_e.lit_bufsize,_e.pending_buf=new o.Buf8(_e.pending_buf_size),_e.d_buf=1*_e.lit_bufsize,_e.l_buf=3*_e.lit_bufsize,_e.level=H,_e.strategy=ce,_e.method=se,re(z)}a=[new he(0,0,0,0,function(z,H){var se=65535;for(se>z.pending_buf_size-5&&(se=z.pending_buf_size-5);;){if(z.lookahead<=1){if(de(z),z.lookahead===0&&H===f)return R;if(z.lookahead===0)break}z.strstart+=z.lookahead,z.lookahead=0;var B=z.block_start+se;if((z.strstart===0||z.strstart>=B)&&(z.lookahead=z.strstart-B,z.strstart=B,W(z,!1),z.strm.avail_out===0)||z.strstart-z.block_start>=z.w_size-U&&(W(z,!1),z.strm.avail_out===0))return R}return z.insert=0,H===g?(W(z,!0),z.strm.avail_out===0?Y:V):(z.strstart>z.block_start&&(W(z,!1),z.strm.avail_out),R)}),new he(4,4,8,4,ue),new he(4,5,16,8,ue),new he(4,6,32,32,ue),new he(4,4,16,16,le),new he(8,16,32,32,le),new he(8,16,128,128,le),new he(8,32,128,256,le),new he(32,128,258,1024,le),new he(32,258,258,4096,le)],i.deflateInit=function(z,H){return We(z,H,E,15,8,0)},i.deflateInit2=We,i.deflateReset=re,i.deflateResetKeep=Me,i.deflateSetHeader=function(z,H){return z&&z.state?z.state.wrap!==2?x:(z.state.gzhead=H,p):x},i.deflate=function(z,H){var se,B,Q,ce;if(!z||!z.state||5<H||H<0)return z?K(z,x):x;if(B=z.state,!z.output||!z.input&&z.avail_in!==0||B.status===666&&H!==g)return K(z,z.avail_out===0?-5:x);if(B.strm=z,se=B.last_flush,B.last_flush=H,B.status===O)if(B.wrap===2)z.adler=0,ee(B,31),ee(B,139),ee(B,8),B.gzhead?(ee(B,(B.gzhead.text?1:0)+(B.gzhead.hcrc?2:0)+(B.gzhead.extra?4:0)+(B.gzhead.name?8:0)+(B.gzhead.comment?16:0)),ee(B,255&B.gzhead.time),ee(B,B.gzhead.time>>8&255),ee(B,B.gzhead.time>>16&255),ee(B,B.gzhead.time>>24&255),ee(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ee(B,255&B.gzhead.os),B.gzhead.extra&&B.gzhead.extra.length&&(ee(B,255&B.gzhead.extra.length),ee(B,B.gzhead.extra.length>>8&255)),B.gzhead.hcrc&&(z.adler=u(z.adler,B.pending_buf,B.pending,0)),B.gzindex=0,B.status=69):(ee(B,0),ee(B,0),ee(B,0),ee(B,0),ee(B,0),ee(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ee(B,3),B.status=q);else{var Ce=E+(B.w_bits-8<<4)<<8;Ce|=(2<=B.strategy||B.level<2?0:B.level<6?1:B.level===6?2:3)<<6,B.strstart!==0&&(Ce|=32),Ce+=31-Ce%31,B.status=q,ie(B,Ce),B.strstart!==0&&(ie(B,z.adler>>>16),ie(B,65535&z.adler)),z.adler=1}if(B.status===69)if(B.gzhead.extra){for(Q=B.pending;B.gzindex<(65535&B.gzhead.extra.length)&&(B.pending!==B.pending_buf_size||(B.gzhead.hcrc&&B.pending>Q&&(z.adler=u(z.adler,B.pending_buf,B.pending-Q,Q)),F(z),Q=B.pending,B.pending!==B.pending_buf_size));)ee(B,255&B.gzhead.extra[B.gzindex]),B.gzindex++;B.gzhead.hcrc&&B.pending>Q&&(z.adler=u(z.adler,B.pending_buf,B.pending-Q,Q)),B.gzindex===B.gzhead.extra.length&&(B.gzindex=0,B.status=73)}else B.status=73;if(B.status===73)if(B.gzhead.name){Q=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>Q&&(z.adler=u(z.adler,B.pending_buf,B.pending-Q,Q)),F(z),Q=B.pending,B.pending===B.pending_buf_size)){ce=1;break}ce=B.gzindex<B.gzhead.name.length?255&B.gzhead.name.charCodeAt(B.gzindex++):0,ee(B,ce)}while(ce!==0);B.gzhead.hcrc&&B.pending>Q&&(z.adler=u(z.adler,B.pending_buf,B.pending-Q,Q)),ce===0&&(B.gzindex=0,B.status=91)}else B.status=91;if(B.status===91)if(B.gzhead.comment){Q=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>Q&&(z.adler=u(z.adler,B.pending_buf,B.pending-Q,Q)),F(z),Q=B.pending,B.pending===B.pending_buf_size)){ce=1;break}ce=B.gzindex<B.gzhead.comment.length?255&B.gzhead.comment.charCodeAt(B.gzindex++):0,ee(B,ce)}while(ce!==0);B.gzhead.hcrc&&B.pending>Q&&(z.adler=u(z.adler,B.pending_buf,B.pending-Q,Q)),ce===0&&(B.status=103)}else B.status=103;if(B.status===103&&(B.gzhead.hcrc?(B.pending+2>B.pending_buf_size&&F(z),B.pending+2<=B.pending_buf_size&&(ee(B,255&z.adler),ee(B,z.adler>>8&255),z.adler=0,B.status=q)):B.status=q),B.pending!==0){if(F(z),z.avail_out===0)return B.last_flush=-1,p}else if(z.avail_in===0&&J(H)<=J(se)&&H!==g)return K(z,-5);if(B.status===666&&z.avail_in!==0)return K(z,-5);if(z.avail_in!==0||B.lookahead!==0||H!==f&&B.status!==666){var _e=B.strategy===2?(function(Ee,$){for(var j;;){if(Ee.lookahead===0&&(de(Ee),Ee.lookahead===0)){if($===f)return R;break}if(Ee.match_length=0,j=l._tr_tally(Ee,0,Ee.window[Ee.strstart]),Ee.lookahead--,Ee.strstart++,j&&(W(Ee,!1),Ee.strm.avail_out===0))return R}return Ee.insert=0,$===g?(W(Ee,!0),Ee.strm.avail_out===0?Y:V):Ee.last_lit&&(W(Ee,!1),Ee.strm.avail_out===0)?R:G})(B,H):B.strategy===3?(function(Ee,$){for(var j,ne,be,we,ve=Ee.window;;){if(Ee.lookahead<=D){if(de(Ee),Ee.lookahead<=D&&$===f)return R;if(Ee.lookahead===0)break}if(Ee.match_length=0,Ee.lookahead>=k&&0<Ee.strstart&&(ne=ve[be=Ee.strstart-1])===ve[++be]&&ne===ve[++be]&&ne===ve[++be]){we=Ee.strstart+D;do;while(ne===ve[++be]&&ne===ve[++be]&&ne===ve[++be]&&ne===ve[++be]&&ne===ve[++be]&&ne===ve[++be]&&ne===ve[++be]&&ne===ve[++be]&&be<we);Ee.match_length=D-(we-be),Ee.match_length>Ee.lookahead&&(Ee.match_length=Ee.lookahead)}if(Ee.match_length>=k?(j=l._tr_tally(Ee,1,Ee.match_length-k),Ee.lookahead-=Ee.match_length,Ee.strstart+=Ee.match_length,Ee.match_length=0):(j=l._tr_tally(Ee,0,Ee.window[Ee.strstart]),Ee.lookahead--,Ee.strstart++),j&&(W(Ee,!1),Ee.strm.avail_out===0))return R}return Ee.insert=0,$===g?(W(Ee,!0),Ee.strm.avail_out===0?Y:V):Ee.last_lit&&(W(Ee,!1),Ee.strm.avail_out===0)?R:G})(B,H):a[B.level].func(B,H);if(_e!==Y&&_e!==V||(B.status=666),_e===R||_e===Y)return z.avail_out===0&&(B.last_flush=-1),p;if(_e===G&&(H===1?l._tr_align(B):H!==5&&(l._tr_stored_block(B,0,0,!1),H===3&&(X(B.head),B.lookahead===0&&(B.strstart=0,B.block_start=0,B.insert=0))),F(z),z.avail_out===0))return B.last_flush=-1,p}return H!==g?p:B.wrap<=0?1:(B.wrap===2?(ee(B,255&z.adler),ee(B,z.adler>>8&255),ee(B,z.adler>>16&255),ee(B,z.adler>>24&255),ee(B,255&z.total_in),ee(B,z.total_in>>8&255),ee(B,z.total_in>>16&255),ee(B,z.total_in>>24&255)):(ie(B,z.adler>>>16),ie(B,65535&z.adler)),F(z),0<B.wrap&&(B.wrap=-B.wrap),B.pending!==0?p:1)},i.deflateEnd=function(z){var H;return z&&z.state?(H=z.state.status)!==O&&H!==69&&H!==73&&H!==91&&H!==103&&H!==q&&H!==666?K(z,x):(z.state=null,H===q?K(z,-3):p):x},i.deflateSetDictionary=function(z,H){var se,B,Q,ce,Ce,_e,Ee,$,j=H.length;if(!z||!z.state||(ce=(se=z.state).wrap)===2||ce===1&&se.status!==O||se.lookahead)return x;for(ce===1&&(z.adler=c(z.adler,H,j,0)),se.wrap=0,j>=se.w_size&&(ce===0&&(X(se.head),se.strstart=0,se.block_start=0,se.insert=0),$=new o.Buf8(se.w_size),o.arraySet($,H,j-se.w_size,se.w_size,0),H=$,j=se.w_size),Ce=z.avail_in,_e=z.next_in,Ee=z.input,z.avail_in=j,z.next_in=0,z.input=H,de(se);se.lookahead>=k;){for(B=se.strstart,Q=se.lookahead-(k-1);se.ins_h=(se.ins_h<<se.hash_shift^se.window[B+k-1])&se.hash_mask,se.prev[B&se.w_mask]=se.head[se.ins_h],se.head[se.ins_h]=B,B++,--Q;);se.strstart=B,se.lookahead=k-1,de(se)}return se.strstart+=se.lookahead,se.block_start=se.strstart,se.insert=se.lookahead,se.lookahead=0,se.match_length=se.prev_length=k-1,se.match_available=0,z.next_in=_e,z.input=Ee,z.avail_in=Ce,se.wrap=ce,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,o){var l,c,u,d,f,g,p,x,y,b,v,E,w,N,A,C,T,L,k,D,U,O,q,R,G;l=a.state,c=a.next_in,R=a.input,u=c+(a.avail_in-5),d=a.next_out,G=a.output,f=d-(o-a.avail_out),g=d+(a.avail_out-257),p=l.dmax,x=l.wsize,y=l.whave,b=l.wnext,v=l.window,E=l.hold,w=l.bits,N=l.lencode,A=l.distcode,C=(1<<l.lenbits)-1,T=(1<<l.distbits)-1;e:do{w<15&&(E+=R[c++]<<w,w+=8,E+=R[c++]<<w,w+=8),L=N[E&C];t:for(;;){if(E>>>=k=L>>>24,w-=k,(k=L>>>16&255)===0)G[d++]=65535&L;else{if(!(16&k)){if((64&k)==0){L=N[(65535&L)+(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}D=65535&L,(k&=15)&&(w<k&&(E+=R[c++]<<w,w+=8),D+=E&(1<<k)-1,E>>>=k,w-=k),w<15&&(E+=R[c++]<<w,w+=8,E+=R[c++]<<w,w+=8),L=A[E&T];n:for(;;){if(E>>>=k=L>>>24,w-=k,!(16&(k=L>>>16&255))){if((64&k)==0){L=A[(65535&L)+(E&(1<<k)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(U=65535&L,w<(k&=15)&&(E+=R[c++]<<w,(w+=8)<k&&(E+=R[c++]<<w,w+=8)),p<(U+=E&(1<<k)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(E>>>=k,w-=k,(k=d-f)<U){if(y<(k=U-k)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(q=v,(O=0)===b){if(O+=x-k,k<D){for(D-=k;G[d++]=v[O++],--k;);O=d-U,q=G}}else if(b<k){if(O+=x+b-k,(k-=b)<D){for(D-=k;G[d++]=v[O++],--k;);if(O=0,b<D){for(D-=k=b;G[d++]=v[O++],--k;);O=d-U,q=G}}}else if(O+=b-k,k<D){for(D-=k;G[d++]=v[O++],--k;);O=d-U,q=G}for(;2<D;)G[d++]=q[O++],G[d++]=q[O++],G[d++]=q[O++],D-=3;D&&(G[d++]=q[O++],1<D&&(G[d++]=q[O++]))}else{for(O=d-U;G[d++]=G[O++],G[d++]=G[O++],G[d++]=G[O++],2<(D-=3););D&&(G[d++]=G[O++],1<D&&(G[d++]=G[O++]))}break}}break}}while(c<u&&d<g);c-=D=w>>3,E&=(1<<(w-=D<<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"),o=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,g=0,p=-2,x=1,y=852,b=592;function v(O){return(O>>>24&255)+(O>>>8&65280)+((65280&O)<<8)+((255&O)<<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(O){var q;return O&&O.state?(q=O.state,O.total_in=O.total_out=q.total=0,O.msg="",q.wrap&&(O.adler=1&q.wrap),q.mode=x,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(y),q.distcode=q.distdyn=new a.Buf32(b),q.sane=1,q.back=-1,g):p}function N(O){var q;return O&&O.state?((q=O.state).wsize=0,q.whave=0,q.wnext=0,w(O)):p}function A(O,q){var R,G;return O&&O.state?(G=O.state,q<0?(R=0,q=-q):(R=1+(q>>4),q<48&&(q&=15)),q&&(q<8||15<q)?p:(G.window!==null&&G.wbits!==q&&(G.window=null),G.wrap=R,G.wbits=q,N(O))):p}function C(O,q){var R,G;return O?(G=new E,(O.state=G).window=null,(R=A(O,q))!==g&&(O.state=null),R):p}var T,L,k=!0;function D(O){if(k){var q;for(T=new a.Buf32(512),L=new a.Buf32(32),q=0;q<144;)O.lens[q++]=8;for(;q<256;)O.lens[q++]=9;for(;q<280;)O.lens[q++]=7;for(;q<288;)O.lens[q++]=8;for(u(d,O.lens,0,288,T,0,O.work,{bits:9}),q=0;q<32;)O.lens[q++]=5;u(f,O.lens,0,32,L,0,O.work,{bits:5}),k=!1}O.lencode=T,O.lenbits=9,O.distcode=L,O.distbits=5}function U(O,q,R,G){var Y,V=O.state;return V.window===null&&(V.wsize=1<<V.wbits,V.wnext=0,V.whave=0,V.window=new a.Buf8(V.wsize)),G>=V.wsize?(a.arraySet(V.window,q,R-V.wsize,V.wsize,0),V.wnext=0,V.whave=V.wsize):(G<(Y=V.wsize-V.wnext)&&(Y=G),a.arraySet(V.window,q,R-G,Y,V.wnext),(G-=Y)?(a.arraySet(V.window,q,R-G,G,0),V.wnext=G,V.whave=V.wsize):(V.wnext+=Y,V.wnext===V.wsize&&(V.wnext=0),V.whave<V.wsize&&(V.whave+=Y))),0}i.inflateReset=N,i.inflateReset2=A,i.inflateResetKeep=w,i.inflateInit=function(O){return C(O,15)},i.inflateInit2=C,i.inflate=function(O,q){var R,G,Y,V,K,J,X,F,W,ee,ie,ae,de,ue,le,he,pe,Me,re,We,z,H,se,B,Q=0,ce=new a.Buf8(4),Ce=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!O||!O.state||!O.output||!O.input&&O.avail_in!==0)return p;(R=O.state).mode===12&&(R.mode=13),K=O.next_out,Y=O.output,X=O.avail_out,V=O.next_in,G=O.input,J=O.avail_in,F=R.hold,W=R.bits,ee=J,ie=X,H=g;e:for(;;)switch(R.mode){case x:if(R.wrap===0){R.mode=13;break}for(;W<16;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}if(2&R.wrap&&F===35615){ce[R.check=0]=255&F,ce[1]=F>>>8&255,R.check=l(R.check,ce,2,0),W=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){O.msg="incorrect header check",R.mode=30;break}if((15&F)!=8){O.msg="unknown compression method",R.mode=30;break}if(W-=4,z=8+(15&(F>>>=4)),R.wbits===0)R.wbits=z;else if(z>R.wbits){O.msg="invalid window size",R.mode=30;break}R.dmax=1<<z,O.adler=R.check=1,R.mode=512&F?10:12,W=F=0;break;case 2:for(;W<16;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}if(R.flags=F,(255&R.flags)!=8){O.msg="unknown compression method",R.mode=30;break}if(57344&R.flags){O.msg="unknown header flags set",R.mode=30;break}R.head&&(R.head.text=F>>8&1),512&R.flags&&(ce[0]=255&F,ce[1]=F>>>8&255,R.check=l(R.check,ce,2,0)),W=F=0,R.mode=3;case 3:for(;W<32;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}R.head&&(R.head.time=F),512&R.flags&&(ce[0]=255&F,ce[1]=F>>>8&255,ce[2]=F>>>16&255,ce[3]=F>>>24&255,R.check=l(R.check,ce,4,0)),W=F=0,R.mode=4;case 4:for(;W<16;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}R.head&&(R.head.xflags=255&F,R.head.os=F>>8),512&R.flags&&(ce[0]=255&F,ce[1]=F>>>8&255,R.check=l(R.check,ce,2,0)),W=F=0,R.mode=5;case 5:if(1024&R.flags){for(;W<16;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}R.length=F,R.head&&(R.head.extra_len=F),512&R.flags&&(ce[0]=255&F,ce[1]=F>>>8&255,R.check=l(R.check,ce,2,0)),W=F=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(J<(ae=R.length)&&(ae=J),ae&&(R.head&&(z=R.head.extra_len-R.length,R.head.extra||(R.head.extra=new Array(R.head.extra_len)),a.arraySet(R.head.extra,G,V,ae,z)),512&R.flags&&(R.check=l(R.check,G,ae,V)),J-=ae,V+=ae,R.length-=ae),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(J===0)break e;for(ae=0;z=G[V+ae++],R.head&&z&&R.length<65536&&(R.head.name+=String.fromCharCode(z)),z&&ae<J;);if(512&R.flags&&(R.check=l(R.check,G,ae,V)),J-=ae,V+=ae,z)break e}else R.head&&(R.head.name=null);R.length=0,R.mode=8;case 8:if(4096&R.flags){if(J===0)break e;for(ae=0;z=G[V+ae++],R.head&&z&&R.length<65536&&(R.head.comment+=String.fromCharCode(z)),z&&ae<J;);if(512&R.flags&&(R.check=l(R.check,G,ae,V)),J-=ae,V+=ae,z)break e}else R.head&&(R.head.comment=null);R.mode=9;case 9:if(512&R.flags){for(;W<16;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}if(F!==(65535&R.check)){O.msg="header crc mismatch",R.mode=30;break}W=F=0}R.head&&(R.head.hcrc=R.flags>>9&1,R.head.done=!0),O.adler=R.check=0,R.mode=12;break;case 10:for(;W<32;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}O.adler=R.check=v(F),W=F=0,R.mode=11;case 11:if(R.havedict===0)return O.next_out=K,O.avail_out=X,O.next_in=V,O.avail_in=J,R.hold=F,R.bits=W,2;O.adler=R.check=1,R.mode=12;case 12:if(q===5||q===6)break e;case 13:if(R.last){F>>>=7&W,W-=7&W,R.mode=27;break}for(;W<3;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}switch(R.last=1&F,W-=1,3&(F>>>=1)){case 0:R.mode=14;break;case 1:if(D(R),R.mode=20,q!==6)break;F>>>=2,W-=2;break e;case 2:R.mode=17;break;case 3:O.msg="invalid block type",R.mode=30}F>>>=2,W-=2;break;case 14:for(F>>>=7&W,W-=7&W;W<32;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}if((65535&F)!=(F>>>16^65535)){O.msg="invalid stored block lengths",R.mode=30;break}if(R.length=65535&F,W=F=0,R.mode=15,q===6)break e;case 15:R.mode=16;case 16:if(ae=R.length){if(J<ae&&(ae=J),X<ae&&(ae=X),ae===0)break e;a.arraySet(Y,G,V,ae,K),J-=ae,V+=ae,X-=ae,K+=ae,R.length-=ae;break}R.mode=12;break;case 17:for(;W<14;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}if(R.nlen=257+(31&F),F>>>=5,W-=5,R.ndist=1+(31&F),F>>>=5,W-=5,R.ncode=4+(15&F),F>>>=4,W-=4,286<R.nlen||30<R.ndist){O.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(;W<3;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}R.lens[Ce[R.have++]]=7&F,F>>>=3,W-=3}for(;R.have<19;)R.lens[Ce[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,se={bits:R.lenbits},H=u(0,R.lens,0,19,R.lencode,0,R.work,se),R.lenbits=se.bits,H){O.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=(Q=R.lencode[F&(1<<R.lenbits)-1])>>>16&255,pe=65535&Q,!((le=Q>>>24)<=W);){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}if(pe<16)F>>>=le,W-=le,R.lens[R.have++]=pe;else{if(pe===16){for(B=le+2;W<B;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}if(F>>>=le,W-=le,R.have===0){O.msg="invalid bit length repeat",R.mode=30;break}z=R.lens[R.have-1],ae=3+(3&F),F>>>=2,W-=2}else if(pe===17){for(B=le+3;W<B;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}W-=le,z=0,ae=3+(7&(F>>>=le)),F>>>=3,W-=3}else{for(B=le+7;W<B;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}W-=le,z=0,ae=11+(127&(F>>>=le)),F>>>=7,W-=7}if(R.have+ae>R.nlen+R.ndist){O.msg="invalid bit length repeat",R.mode=30;break}for(;ae--;)R.lens[R.have++]=z}}if(R.mode===30)break;if(R.lens[256]===0){O.msg="invalid code -- missing end-of-block",R.mode=30;break}if(R.lenbits=9,se={bits:R.lenbits},H=u(d,R.lens,0,R.nlen,R.lencode,0,R.work,se),R.lenbits=se.bits,H){O.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,se={bits:R.distbits},H=u(f,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,se),R.distbits=se.bits,H){O.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<=J&&258<=X){O.next_out=K,O.avail_out=X,O.next_in=V,O.avail_in=J,R.hold=F,R.bits=W,c(O,ie),K=O.next_out,Y=O.output,X=O.avail_out,V=O.next_in,G=O.input,J=O.avail_in,F=R.hold,W=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;he=(Q=R.lencode[F&(1<<R.lenbits)-1])>>>16&255,pe=65535&Q,!((le=Q>>>24)<=W);){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}if(he&&(240&he)==0){for(Me=le,re=he,We=pe;he=(Q=R.lencode[We+((F&(1<<Me+re)-1)>>Me)])>>>16&255,pe=65535&Q,!(Me+(le=Q>>>24)<=W);){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}F>>>=Me,W-=Me,R.back+=Me}if(F>>>=le,W-=le,R.back+=le,R.length=pe,he===0){R.mode=26;break}if(32&he){R.back=-1,R.mode=12;break}if(64&he){O.msg="invalid literal/length code",R.mode=30;break}R.extra=15&he,R.mode=22;case 22:if(R.extra){for(B=R.extra;W<B;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}R.length+=F&(1<<R.extra)-1,F>>>=R.extra,W-=R.extra,R.back+=R.extra}R.was=R.length,R.mode=23;case 23:for(;he=(Q=R.distcode[F&(1<<R.distbits)-1])>>>16&255,pe=65535&Q,!((le=Q>>>24)<=W);){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}if((240&he)==0){for(Me=le,re=he,We=pe;he=(Q=R.distcode[We+((F&(1<<Me+re)-1)>>Me)])>>>16&255,pe=65535&Q,!(Me+(le=Q>>>24)<=W);){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}F>>>=Me,W-=Me,R.back+=Me}if(F>>>=le,W-=le,R.back+=le,64&he){O.msg="invalid distance code",R.mode=30;break}R.offset=pe,R.extra=15&he,R.mode=24;case 24:if(R.extra){for(B=R.extra;W<B;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}R.offset+=F&(1<<R.extra)-1,F>>>=R.extra,W-=R.extra,R.back+=R.extra}if(R.offset>R.dmax){O.msg="invalid distance too far back",R.mode=30;break}R.mode=25;case 25:if(X===0)break e;if(ae=ie-X,R.offset>ae){if((ae=R.offset-ae)>R.whave&&R.sane){O.msg="invalid distance too far back",R.mode=30;break}de=ae>R.wnext?(ae-=R.wnext,R.wsize-ae):R.wnext-ae,ae>R.length&&(ae=R.length),ue=R.window}else ue=Y,de=K-R.offset,ae=R.length;for(X<ae&&(ae=X),X-=ae,R.length-=ae;Y[K++]=ue[de++],--ae;);R.length===0&&(R.mode=21);break;case 26:if(X===0)break e;Y[K++]=R.length,X--,R.mode=21;break;case 27:if(R.wrap){for(;W<32;){if(J===0)break e;J--,F|=G[V++]<<W,W+=8}if(ie-=X,O.total_out+=ie,R.total+=ie,ie&&(O.adler=R.check=R.flags?l(R.check,Y,ie,K-ie):o(R.check,Y,ie,K-ie)),ie=X,(R.flags?F:v(F))!==R.check){O.msg="incorrect data check",R.mode=30;break}W=F=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;W<32;){if(J===0)break e;J--,F+=G[V++]<<W,W+=8}if(F!==(4294967295&R.total)){O.msg="incorrect length check",R.mode=30;break}W=F=0}R.mode=29;case 29:H=1;break e;case 30:H=-3;break e;case 31:return-4;case 32:default:return p}return O.next_out=K,O.avail_out=X,O.next_in=V,O.avail_in=J,R.hold=F,R.bits=W,(R.wsize||ie!==O.avail_out&&R.mode<30&&(R.mode<27||q!==4))&&U(O,O.output,O.next_out,ie-O.avail_out)?(R.mode=31,-4):(ee-=O.avail_in,ie-=O.avail_out,O.total_in+=ee,O.total_out+=ie,R.total+=ie,R.wrap&&ie&&(O.adler=R.check=R.flags?l(R.check,Y,ie,O.next_out-ie):o(R.check,Y,ie,O.next_out-ie)),O.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(ee==0&&ie===0||q===4)&&H===g&&(H=-5),H)},i.inflateEnd=function(O){if(!O||!O.state)return p;var q=O.state;return q.window&&(q.window=null),O.state=null,g},i.inflateGetHeader=function(O,q){var R;return O&&O.state?(2&(R=O.state).wrap)==0?p:((R.head=q).done=!1,g):p},i.inflateSetDictionary=function(O,q){var R,G=q.length;return O&&O.state?(R=O.state).wrap!==0&&R.mode!==11?p:R.mode===11&&o(1,q,G,0)!==R.check?-3:U(O,q,G,G)?(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"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,g,p,x,y,b,v){var E,w,N,A,C,T,L,k,D,U=v.bits,O=0,q=0,R=0,G=0,Y=0,V=0,K=0,J=0,X=0,F=0,W=null,ee=0,ie=new a.Buf16(16),ae=new a.Buf16(16),de=null,ue=0;for(O=0;O<=15;O++)ie[O]=0;for(q=0;q<p;q++)ie[f[g+q]]++;for(Y=U,G=15;1<=G&&ie[G]===0;G--);if(G<Y&&(Y=G),G===0)return x[y++]=20971520,x[y++]=20971520,v.bits=1,0;for(R=1;R<G&&ie[R]===0;R++);for(Y<R&&(Y=R),O=J=1;O<=15;O++)if(J<<=1,(J-=ie[O])<0)return-1;if(0<J&&(d===0||G!==1))return-1;for(ae[1]=0,O=1;O<15;O++)ae[O+1]=ae[O]+ie[O];for(q=0;q<p;q++)f[g+q]!==0&&(b[ae[f[g+q]]++]=q);if(T=d===0?(W=de=b,19):d===1?(W=o,ee-=257,de=l,ue-=257,256):(W=c,de=u,-1),O=R,C=y,K=q=F=0,N=-1,A=(X=1<<(V=Y))-1,d===1&&852<X||d===2&&592<X)return 1;for(;;){for(L=O-K,D=b[q]<T?(k=0,b[q]):b[q]>T?(k=de[ue+b[q]],W[ee+b[q]]):(k=96,0),E=1<<O-K,R=w=1<<V;x[C+(F>>K)+(w-=E)]=L<<24|k<<16|D|0,w!==0;);for(E=1<<O-1;F&E;)E>>=1;if(E!==0?(F&=E-1,F+=E):F=0,q++,--ie[O]==0){if(O===G)break;O=f[g+b[q]]}if(Y<O&&(F&A)!==N){for(K===0&&(K=Y),C+=R,J=1<<(V=O-K);V+K<G&&!((J-=ie[V+K])<=0);)V++,J<<=1;if(X+=1<<V,d===1&&852<X||d===2&&592<X)return 1;x[N=F&A]=Y<<24|V<<16|C-y|0}}return F!==0&&(x[C+F]=O-K<<24|64<<16|0),v.bits=Y,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"),o=0,l=1;function c(Q){for(var ce=Q.length;0<=--ce;)Q[ce]=0}var u=0,d=29,f=256,g=f+1+d,p=30,x=19,y=2*g+1,b=15,v=16,E=7,w=256,N=16,A=17,C=18,T=[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],L=[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],D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],U=new Array(2*(g+2));c(U);var O=new Array(2*p);c(O);var q=new Array(512);c(q);var R=new Array(256);c(R);var G=new Array(d);c(G);var Y,V,K,J=new Array(p);function X(Q,ce,Ce,_e,Ee){this.static_tree=Q,this.extra_bits=ce,this.extra_base=Ce,this.elems=_e,this.max_length=Ee,this.has_stree=Q&&Q.length}function F(Q,ce){this.dyn_tree=Q,this.max_code=0,this.stat_desc=ce}function W(Q){return Q<256?q[Q]:q[256+(Q>>>7)]}function ee(Q,ce){Q.pending_buf[Q.pending++]=255&ce,Q.pending_buf[Q.pending++]=ce>>>8&255}function ie(Q,ce,Ce){Q.bi_valid>v-Ce?(Q.bi_buf|=ce<<Q.bi_valid&65535,ee(Q,Q.bi_buf),Q.bi_buf=ce>>v-Q.bi_valid,Q.bi_valid+=Ce-v):(Q.bi_buf|=ce<<Q.bi_valid&65535,Q.bi_valid+=Ce)}function ae(Q,ce,Ce){ie(Q,Ce[2*ce],Ce[2*ce+1])}function de(Q,ce){for(var Ce=0;Ce|=1&Q,Q>>>=1,Ce<<=1,0<--ce;);return Ce>>>1}function ue(Q,ce,Ce){var _e,Ee,$=new Array(b+1),j=0;for(_e=1;_e<=b;_e++)$[_e]=j=j+Ce[_e-1]<<1;for(Ee=0;Ee<=ce;Ee++){var ne=Q[2*Ee+1];ne!==0&&(Q[2*Ee]=de($[ne]++,ne))}}function le(Q){var ce;for(ce=0;ce<g;ce++)Q.dyn_ltree[2*ce]=0;for(ce=0;ce<p;ce++)Q.dyn_dtree[2*ce]=0;for(ce=0;ce<x;ce++)Q.bl_tree[2*ce]=0;Q.dyn_ltree[2*w]=1,Q.opt_len=Q.static_len=0,Q.last_lit=Q.matches=0}function he(Q){8<Q.bi_valid?ee(Q,Q.bi_buf):0<Q.bi_valid&&(Q.pending_buf[Q.pending++]=Q.bi_buf),Q.bi_buf=0,Q.bi_valid=0}function pe(Q,ce,Ce,_e){var Ee=2*ce,$=2*Ce;return Q[Ee]<Q[$]||Q[Ee]===Q[$]&&_e[ce]<=_e[Ce]}function Me(Q,ce,Ce){for(var _e=Q.heap[Ce],Ee=Ce<<1;Ee<=Q.heap_len&&(Ee<Q.heap_len&&pe(ce,Q.heap[Ee+1],Q.heap[Ee],Q.depth)&&Ee++,!pe(ce,_e,Q.heap[Ee],Q.depth));)Q.heap[Ce]=Q.heap[Ee],Ce=Ee,Ee<<=1;Q.heap[Ce]=_e}function re(Q,ce,Ce){var _e,Ee,$,j,ne=0;if(Q.last_lit!==0)for(;_e=Q.pending_buf[Q.d_buf+2*ne]<<8|Q.pending_buf[Q.d_buf+2*ne+1],Ee=Q.pending_buf[Q.l_buf+ne],ne++,_e===0?ae(Q,Ee,ce):(ae(Q,($=R[Ee])+f+1,ce),(j=T[$])!==0&&ie(Q,Ee-=G[$],j),ae(Q,$=W(--_e),Ce),(j=L[$])!==0&&ie(Q,_e-=J[$],j)),ne<Q.last_lit;);ae(Q,w,ce)}function We(Q,ce){var Ce,_e,Ee,$=ce.dyn_tree,j=ce.stat_desc.static_tree,ne=ce.stat_desc.has_stree,be=ce.stat_desc.elems,we=-1;for(Q.heap_len=0,Q.heap_max=y,Ce=0;Ce<be;Ce++)$[2*Ce]!==0?(Q.heap[++Q.heap_len]=we=Ce,Q.depth[Ce]=0):$[2*Ce+1]=0;for(;Q.heap_len<2;)$[2*(Ee=Q.heap[++Q.heap_len]=we<2?++we:0)]=1,Q.depth[Ee]=0,Q.opt_len--,ne&&(Q.static_len-=j[2*Ee+1]);for(ce.max_code=we,Ce=Q.heap_len>>1;1<=Ce;Ce--)Me(Q,$,Ce);for(Ee=be;Ce=Q.heap[1],Q.heap[1]=Q.heap[Q.heap_len--],Me(Q,$,1),_e=Q.heap[1],Q.heap[--Q.heap_max]=Ce,Q.heap[--Q.heap_max]=_e,$[2*Ee]=$[2*Ce]+$[2*_e],Q.depth[Ee]=(Q.depth[Ce]>=Q.depth[_e]?Q.depth[Ce]:Q.depth[_e])+1,$[2*Ce+1]=$[2*_e+1]=Ee,Q.heap[1]=Ee++,Me(Q,$,1),2<=Q.heap_len;);Q.heap[--Q.heap_max]=Q.heap[1],(function(ve,$e){var Ge,Xe,ut,He,me,Je,Ke=$e.dyn_tree,Ze=$e.max_code,ct=$e.stat_desc.static_tree,te=$e.stat_desc.has_stree,Fe=$e.stat_desc.extra_bits,xe=$e.stat_desc.extra_base,ze=$e.stat_desc.max_length,Pe=0;for(He=0;He<=b;He++)ve.bl_count[He]=0;for(Ke[2*ve.heap[ve.heap_max]+1]=0,Ge=ve.heap_max+1;Ge<y;Ge++)ze<(He=Ke[2*Ke[2*(Xe=ve.heap[Ge])+1]+1]+1)&&(He=ze,Pe++),Ke[2*Xe+1]=He,Ze<Xe||(ve.bl_count[He]++,me=0,xe<=Xe&&(me=Fe[Xe-xe]),Je=Ke[2*Xe],ve.opt_len+=Je*(He+me),te&&(ve.static_len+=Je*(ct[2*Xe+1]+me)));if(Pe!==0){do{for(He=ze-1;ve.bl_count[He]===0;)He--;ve.bl_count[He]--,ve.bl_count[He+1]+=2,ve.bl_count[ze]--,Pe-=2}while(0<Pe);for(He=ze;He!==0;He--)for(Xe=ve.bl_count[He];Xe!==0;)Ze<(ut=ve.heap[--Ge])||(Ke[2*ut+1]!==He&&(ve.opt_len+=(He-Ke[2*ut+1])*Ke[2*ut],Ke[2*ut+1]=He),Xe--)}})(Q,ce),ue($,we,Q.bl_count)}function z(Q,ce,Ce){var _e,Ee,$=-1,j=ce[1],ne=0,be=7,we=4;for(j===0&&(be=138,we=3),ce[2*(Ce+1)+1]=65535,_e=0;_e<=Ce;_e++)Ee=j,j=ce[2*(_e+1)+1],++ne<be&&Ee===j||(ne<we?Q.bl_tree[2*Ee]+=ne:Ee!==0?(Ee!==$&&Q.bl_tree[2*Ee]++,Q.bl_tree[2*N]++):ne<=10?Q.bl_tree[2*A]++:Q.bl_tree[2*C]++,$=Ee,we=(ne=0)===j?(be=138,3):Ee===j?(be=6,3):(be=7,4))}function H(Q,ce,Ce){var _e,Ee,$=-1,j=ce[1],ne=0,be=7,we=4;for(j===0&&(be=138,we=3),_e=0;_e<=Ce;_e++)if(Ee=j,j=ce[2*(_e+1)+1],!(++ne<be&&Ee===j)){if(ne<we)for(;ae(Q,Ee,Q.bl_tree),--ne!=0;);else Ee!==0?(Ee!==$&&(ae(Q,Ee,Q.bl_tree),ne--),ae(Q,N,Q.bl_tree),ie(Q,ne-3,2)):ne<=10?(ae(Q,A,Q.bl_tree),ie(Q,ne-3,3)):(ae(Q,C,Q.bl_tree),ie(Q,ne-11,7));$=Ee,we=(ne=0)===j?(be=138,3):Ee===j?(be=6,3):(be=7,4)}}c(J);var se=!1;function B(Q,ce,Ce,_e){ie(Q,(u<<1)+(_e?1:0),3),(function(Ee,$,j,ne){he(Ee),ee(Ee,j),ee(Ee,~j),a.arraySet(Ee.pending_buf,Ee.window,$,j,Ee.pending),Ee.pending+=j})(Q,ce,Ce)}i._tr_init=function(Q){se||((function(){var ce,Ce,_e,Ee,$,j=new Array(b+1);for(Ee=_e=0;Ee<d-1;Ee++)for(G[Ee]=_e,ce=0;ce<1<<T[Ee];ce++)R[_e++]=Ee;for(R[_e-1]=Ee,Ee=$=0;Ee<16;Ee++)for(J[Ee]=$,ce=0;ce<1<<L[Ee];ce++)q[$++]=Ee;for($>>=7;Ee<p;Ee++)for(J[Ee]=$<<7,ce=0;ce<1<<L[Ee]-7;ce++)q[256+$++]=Ee;for(Ce=0;Ce<=b;Ce++)j[Ce]=0;for(ce=0;ce<=143;)U[2*ce+1]=8,ce++,j[8]++;for(;ce<=255;)U[2*ce+1]=9,ce++,j[9]++;for(;ce<=279;)U[2*ce+1]=7,ce++,j[7]++;for(;ce<=287;)U[2*ce+1]=8,ce++,j[8]++;for(ue(U,g+1,j),ce=0;ce<p;ce++)O[2*ce+1]=5,O[2*ce]=de(ce,5);Y=new X(U,T,f+1,g,b),V=new X(O,L,0,p,b),K=new X(new Array(0),k,0,x,E)})(),se=!0),Q.l_desc=new F(Q.dyn_ltree,Y),Q.d_desc=new F(Q.dyn_dtree,V),Q.bl_desc=new F(Q.bl_tree,K),Q.bi_buf=0,Q.bi_valid=0,le(Q)},i._tr_stored_block=B,i._tr_flush_block=function(Q,ce,Ce,_e){var Ee,$,j=0;0<Q.level?(Q.strm.data_type===2&&(Q.strm.data_type=(function(ne){var be,we=4093624447;for(be=0;be<=31;be++,we>>>=1)if(1&we&&ne.dyn_ltree[2*be]!==0)return o;if(ne.dyn_ltree[18]!==0||ne.dyn_ltree[20]!==0||ne.dyn_ltree[26]!==0)return l;for(be=32;be<f;be++)if(ne.dyn_ltree[2*be]!==0)return l;return o})(Q)),We(Q,Q.l_desc),We(Q,Q.d_desc),j=(function(ne){var be;for(z(ne,ne.dyn_ltree,ne.l_desc.max_code),z(ne,ne.dyn_dtree,ne.d_desc.max_code),We(ne,ne.bl_desc),be=x-1;3<=be&&ne.bl_tree[2*D[be]+1]===0;be--);return ne.opt_len+=3*(be+1)+5+5+4,be})(Q),Ee=Q.opt_len+3+7>>>3,($=Q.static_len+3+7>>>3)<=Ee&&(Ee=$)):Ee=$=Ce+5,Ce+4<=Ee&&ce!==-1?B(Q,ce,Ce,_e):Q.strategy===4||$===Ee?(ie(Q,2+(_e?1:0),3),re(Q,U,O)):(ie(Q,4+(_e?1:0),3),(function(ne,be,we,ve){var $e;for(ie(ne,be-257,5),ie(ne,we-1,5),ie(ne,ve-4,4),$e=0;$e<ve;$e++)ie(ne,ne.bl_tree[2*D[$e]+1],3);H(ne,ne.dyn_ltree,be-1),H(ne,ne.dyn_dtree,we-1)})(Q,Q.l_desc.max_code+1,Q.d_desc.max_code+1,j+1),re(Q,Q.dyn_ltree,Q.dyn_dtree)),le(Q),_e&&he(Q)},i._tr_tally=function(Q,ce,Ce){return Q.pending_buf[Q.d_buf+2*Q.last_lit]=ce>>>8&255,Q.pending_buf[Q.d_buf+2*Q.last_lit+1]=255&ce,Q.pending_buf[Q.l_buf+Q.last_lit]=255&Ce,Q.last_lit++,ce===0?Q.dyn_ltree[2*Ce]++:(Q.matches++,ce--,Q.dyn_ltree[2*(R[Ce]+f+1)]++,Q.dyn_dtree[2*W(ce)]++),Q.last_lit===Q.lit_bufsize-1},i._tr_align=function(Q){ie(Q,2,3),ae(Q,w,U),(function(ce){ce.bi_valid===16?(ee(ce,ce.bi_buf),ce.bi_buf=0,ce.bi_valid=0):8<=ce.bi_valid&&(ce.pending_buf[ce.pending++]=255&ce.bi_buf,ce.bi_buf>>=8,ce.bi_valid-=8)})(Q)}},{"../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(o,l){if(!o.setImmediate){var c,u,d,f,g=1,p={},x=!1,y=o.document,b=Object.getPrototypeOf&&Object.getPrototypeOf(o);b=b&&b.setTimeout?b:o,c={}.toString.call(o.process)==="[object process]"?function(N){process.nextTick(function(){E(N)})}:(function(){if(o.postMessage&&!o.importScripts){var N=!0,A=o.onmessage;return o.onmessage=function(){N=!1},o.postMessage("","*"),o.onmessage=A,N}})()?(f="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",w,!1):o.attachEvent("onmessage",w),function(N){o.postMessage(f+N,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(N){E(N.data)},function(N){d.port2.postMessage(N)}):y&&"onreadystatechange"in y.createElement("script")?(u=y.documentElement,function(N){var A=y.createElement("script");A.onreadystatechange=function(){E(N),A.onreadystatechange=null,u.removeChild(A),A=null},u.appendChild(A)}):function(N){setTimeout(E,0,N)},b.setImmediate=function(N){typeof N!="function"&&(N=new Function(""+N));for(var A=new Array(arguments.length-1),C=0;C<A.length;C++)A[C]=arguments[C+1];var T={callback:N,args:A};return p[g]=T,c(g),g++},b.clearImmediate=v}function v(N){delete p[N]}function E(N){if(x)setTimeout(E,0,N);else{var A=p[N];if(A){x=!0;try{(function(C){var T=C.callback,L=C.args;switch(L.length){case 0:T();break;case 1:T(L[0]);break;case 2:T(L[0],L[1]);break;case 3:T(L[0],L[1],L[2]);break;default:T.apply(l,L)}})(A)}finally{v(N),x=!1}}}}function w(N){N.source===o&&typeof N.data=="string"&&N.data.indexOf(f)===0&&E(+N.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Cv<"u"?Cv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(vC)),vC.exports}var wOe=_Oe();const SOe=wo(wOe);function MOe(t){const e=new pi;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 N$=MOe;async function T$(t,e=0){const n=[],r=t.getElementsByTagName("mesh");for(let i=0;i<r.length;i++){const a=r[i],o=[],l=[],c=a.getElementsByTagName("vertex");for(let d=0;d<c.length;d++){const f=c[d];o.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"))}o.length>0&&l.length>0&&n.push({vertices:o,triangles:l,extruder:e})}return n}async function EOe(t){const e=await SOe.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(p){const x=p.startsWith("/")?p.slice(1):p,y=e.files[x];if(!y)return null;const b=await y.async("string");return i.parseFromString(b,"application/xml")}const o=new Map,l=new Map,c=e.files["Metadata/model_settings.config"];if(c)try{const p=await c.async("string"),y=i.parseFromString(p,"application/xml").getElementsByTagName("object");for(let b=0;b<y.length;b++){const v=y[b],E=v.getAttribute("id");if(!E)continue;const w=Array.from(v.children).filter(A=>A.tagName==="metadata"&&A.getAttribute("key")==="extruder");if(w.length>0){const A=w[0].getAttribute("value");A&&o.set(E,Math.max(0,parseInt(A,10)-1))}const N=v.getElementsByTagName("part");for(let A=0;A<N.length;A++){const C=N[A],T=C.getAttribute("id");if(!T)continue;const L=Array.from(C.children).filter(k=>k.tagName==="metadata"&&k.getAttribute("key")==="extruder");if(L.length>0){const k=L[0].getAttribute("value");k&&l.set(`${E}:${T}`,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(x=>x.endsWith(".model"));if(p){const x=await a(p);if(x){const y=await T$(x,0);y.length>0&&n.set("1",{id:"1",meshes:y,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 x=f[p],y=x.getAttribute("id");if(!y)continue;let b=o.get(y)??-1;if(b<0){const N=x.getAttribute("p:extruder")||x.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";b=Math.max(0,parseInt(N,10)-1)}const v=[],E=x.getElementsByTagName("mesh");for(let N=0;N<E.length;N++){const A=E[N],C=[],T=[],L=A.getElementsByTagName("vertex");for(let D=0;D<L.length;D++){const U=L[D];C.push(parseFloat(U.getAttribute("x")||"0"),parseFloat(U.getAttribute("y")||"0"),parseFloat(U.getAttribute("z")||"0"))}const k=A.getElementsByTagName("triangle");for(let D=0;D<k.length;D++){const U=k[D];T.push(parseInt(U.getAttribute("v1")||"0"),parseInt(U.getAttribute("v2")||"0"),parseInt(U.getAttribute("v3")||"0"))}C.length>0&&T.length>0&&v.push({vertices:C,triangles:T,extruder:b})}const w=x.getElementsByTagName("component");for(let N=0;N<w.length;N++){const A=w[N],C=A.getAttribute("p:path")||A.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),T=A.getAttribute("objectid");if(C){const L=await a(C);if(L){const k=T?`${y}:${T}`:null,D=k?l.get(k)??b:b,U=await T$(L,D),O=A.getAttribute("transform"),q=N$(O);for(const R of U)if(O){const G=[];for(let Y=0;Y<R.vertices.length;Y+=3){const V=new at(R.vertices[Y],R.vertices[Y+1],R.vertices[Y+2]);V.applyMatrix4(q),G.push(V.x,V.y,V.z)}v.push({vertices:G,triangles:R.triangles,extruder:R.extruder})}else v.push(R)}}}v.length>0&&n.set(y,{id:y,meshes:v,defaultExtruder:b})}const g=d.getElementsByTagName("build");if(g.length>0){const p=g[0].getElementsByTagName("item");for(let x=0;x<p.length;x++){const y=p[x],b=y.getAttribute("objectid");if(!b)continue;const v=N$(y.getAttribute("transform"));r.push({objectId:b,transform:v})}}return{objects:n,buildItems:r}}function C$(t){const e=new Ul,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 po(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function AOe({url:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=S.useRef(null),a=S.useRef(null),o=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 y=i.current,b=y.clientWidth,v=y.clientHeight,E=new r3e;E.background=new Nn(1710618),o.current=E;const w=new ao(45,b/v,.1,1e4);w.position.set(150,150,150),l.current=w;const N=new aOe({antialias:!0});N.setSize(b,v),N.setPixelRatio(window.devicePixelRatio),y.appendChild(N.domElement),a.current=N;const A=new oOe(w,N.domElement);A.enableDamping=!0,A.dampingFactor=.05,c.current=A;const C=new p3e(16777215,.6);E.add(C);const T=new ZH(16777215,.8);T.position.set(100,100,100),E.add(T);const L=new ZH(16777215,.4);L.position.set(-100,50,-100),E.add(L);const k=Math.max(e.x,e.y),D=Math.ceil(k/16),U=new x3e(k,D,4473924,3355443);E.add(U);const O=new GO(e.x,e.y),q=new HO({color:44610,transparent:!0,opacity:.15,side:ml}),R=new kl(O,q);R.rotation.x=-Math.PI/2,R.position.y=-.5,E.add(R);let G;const Y=()=>{G=requestAnimationFrame(Y),A.update(),N.render(E,w)};Y(),fetch(t).then(K=>{if(!K.ok)throw new Error("Failed to load file");return K.arrayBuffer()}).then(EOe).then(({objects:K,buildItems:J})=>{if(K.size===0)throw new Error("No meshes found in 3MF file");const X=pe=>{const re=n?.[pe]||"#00ae42",We=new Nn(re);return new u3e({color:We,shininess:30,flatShading:!1})},F=new t0,W=new Map;if(J.length>0)for(const pe of J){const Me=K.get(pe.objectId);if(Me)for(const re of Me.meshes){const We=pe.extruder??re.extruder,z=[];for(let se=0;se<re.vertices.length;se+=3){const B=new at(re.vertices[se],re.vertices[se+1],re.vertices[se+2]);B.applyMatrix4(pe.transform),z.push(B.x,B.y,B.z)}const H=C$({vertices:z,triangles:re.triangles});W.has(We)||W.set(We,[]),W.get(We).push(H)}}else for(const pe of K.values())for(const Me of pe.meshes){const re=Me.extruder,We=C$(Me);W.has(re)||W.set(re,[]),W.get(re).push(We)}for(const[pe,Me]of W){if(Me.length===0)continue;const re=Me.length===1?Me[0]:vOe(Me,!1);if(re){const We=X(pe),z=new kl(re,We);F.add(z)}if(Me.length>1)for(const We of Me)We.dispose()}const ee=new vf().setFromObject(F),ie=ee.getCenter(new at);F.position.y=-ee.min.y,J.length===0&&(F.position.x=-ie.x,F.position.z=-ie.z),E.add(F);const ae=new vf().setFromObject(F),de=ae.getCenter(new at),ue=ae.getSize(new at),he=Math.max(ue.x,ue.y,ue.z)*1.8;w.position.set(de.x+he*.7,de.y+he*.5,de.z+he*.7),A.target.copy(de),A.update(),d(!1)}).catch(K=>{g(K.message),d(!1)});const V=()=>{if(!y)return;const K=y.clientWidth,J=y.clientHeight;w.aspect=K/J,w.updateProjectionMatrix(),N.setSize(K,J)};return window.addEventListener("resize",V),()=>{window.removeEventListener("resize",V),cancelAnimationFrame(G),A.dispose(),N.dispose(),y.removeChild(N.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())},x=y=>{l.current&&l.current.position.multiplyScalar(y)};return s.jsxs("div",{className:`relative ${r}`,children:[s.jsx("div",{ref:i,className:"w-full h-full min-h-[400px]"}),u&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}),f&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx("p",{className:"text-red-400",children:f})}),!u&&!f&&s.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[s.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>x(.8),children:s.jsx(the,{className:"w-4 h-4"})}),s.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>x(1.25),children:s.jsx(ihe,{className:"w-4 h-4"})}),s.jsx(Ne,{variant:"secondary",size:"sm",onClick:p,children:s.jsx(hg,{className:"w-4 h-4"})})]})]})}const h2="159",jm={ROTATE:0,DOLLY:1,PAN:2},Rm={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},NOe=0,k$=1,TOe=2,xQ=1,COe=2,yc=3,Dd=0,ls=1,Ac=2,pd=0,Sp=1,P$=2,j$=3,R$=4,kOe=5,Nh=100,POe=101,jOe=102,D$=103,O$=104,ROe=200,DOe=201,OOe=202,LOe=203,aj=204,sj=205,IOe=206,FOe=207,UOe=208,zOe=209,BOe=210,HOe=211,$Oe=212,VOe=213,GOe=214,WOe=0,qOe=1,KOe=2,nS=3,XOe=4,YOe=5,ZOe=6,QOe=7,qO=0,JOe=1,e4e=2,gd=0,t4e=1,n4e=2,r4e=3,i4e=4,a4e=5,bQ=300,Xp=301,Yp=302,oj=303,lj=304,f2=306,cj=1e3,Fo=1001,uj=1002,oa=1003,L$=1004,_C=1005,so=1006,s4e=1007,cb=1008,xd=1009,o4e=1010,l4e=1011,KO=1012,yQ=1013,sd=1014,Rc=1015,ub=1016,vQ=1017,_Q=1018,Wh=1020,c4e=1021,oo=1023,u4e=1024,d4e=1025,qh=1026,Zp=1027,h4e=1028,wQ=1029,f4e=1030,SQ=1031,MQ=1033,wC=33776,SC=33777,MC=33778,EC=33779,I$=35840,F$=35841,U$=35842,z$=35843,EQ=36196,B$=37492,H$=37496,$$=37808,V$=37809,G$=37810,W$=37811,q$=37812,K$=37813,X$=37814,Y$=37815,Z$=37816,Q$=37817,J$=37818,eV=37819,tV=37820,nV=37821,AC=36492,rV=36494,iV=36495,m4e=36283,aV=36284,sV=36285,oV=36286,AQ=3e3,Kh=3001,p4e=3200,g4e=3201,NQ=0,x4e=1,lo="",la="srgb",eu="srgb-linear",XO="display-p3",m2="display-p3-linear",rS="linear",Sr="srgb",iS="rec709",aS="p3",Dm=7680,lV=519,b4e=512,y4e=513,v4e=514,TQ=515,_4e=516,w4e=517,S4e=518,M4e=519,dj=35044,cV="300 es",hj=1035,yl=2e3,db=2001;class Rf{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,o=i.length;a<o;a++)i[a].call(this,e);e.target=null}}}const xa=["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 uV=1234567;const p0=Math.PI/180,hb=180/Math.PI;function zc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(xa[t&255]+xa[t>>8&255]+xa[t>>16&255]+xa[t>>24&255]+"-"+xa[e&255]+xa[e>>8&255]+"-"+xa[e>>16&15|64]+xa[e>>24&255]+"-"+xa[n&63|128]+xa[n>>8&255]+"-"+xa[n>>16&255]+xa[n>>24&255]+xa[r&255]+xa[r>>8&255]+xa[r>>16&255]+xa[r>>24&255]).toLowerCase()}function ca(t,e,n){return Math.max(e,Math.min(n,t))}function YO(t,e){return(t%e+e)%e}function E4e(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function A4e(t,e,n){return t!==e?(n-t)/(e-t):0}function g0(t,e,n){return(1-n)*t+n*e}function N4e(t,e,n,r){return g0(t,e,1-Math.exp(-n*r))}function T4e(t,e=1){return e-Math.abs(YO(t,e*2)-e)}function C4e(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function k4e(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function P4e(t,e){return t+Math.floor(Math.random()*(e-t+1))}function j4e(t,e){return t+Math.random()*(e-t)}function R4e(t){return t*(.5-Math.random())}function D4e(t){t!==void 0&&(uV=t);let e=uV+=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 O4e(t){return t*p0}function L4e(t){return t*hb}function fj(t){return(t&t-1)===0&&t!==0}function I4e(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function sS(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function F4e(t,e,n,r,i){const a=Math.cos,o=Math.sin,l=a(n/2),c=o(n/2),u=a((e+r)/2),d=o((e+r)/2),f=a((e-r)/2),g=o((e-r)/2),p=a((r-e)/2),x=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*f,c*g,l*u);break;case"YZY":t.set(c*g,l*d,c*f,l*u);break;case"ZXZ":t.set(c*f,c*g,l*d,l*u);break;case"XZX":t.set(l*d,c*x,c*p,l*u);break;case"YXY":t.set(c*p,l*d,c*x,l*u);break;case"ZYZ":t.set(c*x,c*p,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function pl(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 or(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 CQ={DEG2RAD:p0,RAD2DEG:hb,generateUUID:zc,clamp:ca,euclideanModulo:YO,mapLinear:E4e,inverseLerp:A4e,lerp:g0,damp:N4e,pingpong:T4e,smoothstep:C4e,smootherstep:k4e,randInt:P4e,randFloat:j4e,randFloatSpread:R4e,seededRandom:D4e,degToRad:O4e,radToDeg:L4e,isPowerOfTwo:fj,ceilPowerOfTwo:I4e,floorPowerOfTwo:sS,setQuaternionFromProperEuler:F4e,normalize:or,denormalize:pl};class sn{constructor(e=0,n=0){sn.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(ca(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,o=this.y-e.y;return this.x=a*r-o*i+e.x,this.y=a*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Sn{constructor(e,n,r,i,a,o,l,c,u){Sn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u)}set(e,n,r,i,a,o,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]=o,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,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],g=r[2],p=r[5],x=r[8],y=i[0],b=i[3],v=i[6],E=i[1],w=i[4],N=i[7],A=i[2],C=i[5],T=i[8];return a[0]=o*y+l*E+c*A,a[3]=o*b+l*w+c*C,a[6]=o*v+l*N+c*T,a[1]=u*y+d*E+f*A,a[4]=u*b+d*w+f*C,a[7]=u*v+d*N+f*T,a[2]=g*y+p*E+x*A,a[5]=g*b+p*w+x*C,a[8]=g*v+p*N+x*T,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],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,g=l*c-d*a,p=u*a-o*c,x=n*f+r*g+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=g*y,e[4]=(d*n-i*c)*y,e[5]=(i*a-l*n)*y,e[6]=p*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*a)*y,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,o,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(NC.makeScale(e,n)),this}rotate(e){return this.premultiply(NC.makeRotation(-e)),this}translate(e,n){return this.premultiply(NC.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 NC=new Sn;function kQ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function oS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function U4e(){const t=oS("canvas");return t.style.display="block",t}const dV={};function x0(t){t in dV||(dV[t]=!0,console.warn(t))}const hV=new Sn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),fV=new Sn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),w_={[eu]:{transfer:rS,primaries:iS,toReference:t=>t,fromReference:t=>t},[la]:{transfer:Sr,primaries:iS,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[m2]:{transfer:rS,primaries:aS,toReference:t=>t.applyMatrix3(fV),fromReference:t=>t.applyMatrix3(hV)},[XO]:{transfer:Sr,primaries:aS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(fV),fromReference:t=>t.applyMatrix3(hV).convertLinearToSRGB()}},z4e=new Set([eu,m2]),lr={enabled:!0,_workingColorSpace:eu,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(!z4e.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=w_[e].toReference,i=w_[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 w_[t].primaries},getTransfer:function(t){return t===lo?rS:w_[t].transfer}};function Mp(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function TC(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Om;class PQ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Om===void 0&&(Om=oS("canvas")),Om.width=e.width,Om.height=e.height;const r=Om.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Om}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=oS("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 o=0;o<a.length;o++)a[o]=Mp(a[o]/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(Mp(n[r]/255)*255):n[r]=Mp(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 B4e=0;class jQ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:B4e++}),this.uuid=zc(),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 o=0,l=i.length;o<l;o++)i[o].isDataTexture?a.push(CC(i[o].image)):a.push(CC(i[o]))}else a=CC(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function CC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?PQ.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 H4e=0;class cs extends Rf{constructor(e=cs.DEFAULT_IMAGE,n=cs.DEFAULT_MAPPING,r=Fo,i=Fo,a=so,o=cb,l=oo,c=xd,u=cs.DEFAULT_ANISOTROPY,d=lo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:H4e++}),this.uuid=zc(),this.name="",this.source=new jQ(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new sn(0,0),this.repeat=new sn(1,1),this.center=new sn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Sn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(x0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Kh?la:lo),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!==bQ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case cj:e.x=e.x-Math.floor(e.x);break;case Fo:e.x=e.x<0?0:1;break;case uj: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 cj:e.y=e.y-Math.floor(e.y);break;case Fo:e.y=e.y<0?0:1;break;case uj: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 x0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===la?Kh:AQ}set encoding(e){x0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Kh?la:lo}}cs.DEFAULT_IMAGE=null;cs.DEFAULT_MAPPING=bQ;cs.DEFAULT_ANISOTROPY=1;class ur{constructor(e=0,n=0,r=0,i=1){ur.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,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*a,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*a,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*a,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],g=c[1],p=c[5],x=c[9],y=c[2],b=c[6],v=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-y)<.01&&Math.abs(x-b)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+y)<.1&&Math.abs(x+b)<.1&&Math.abs(u+p+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(u+1)/2,N=(p+1)/2,A=(v+1)/2,C=(d+g)/4,T=(f+y)/4,L=(x+b)/4;return w>N&&w>A?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=C/r,a=T/r):N>A?N<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(N),r=C/i,a=L/i):A<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(A),r=T/a,i=L/a),this.set(r,i,a,n),this}let E=Math.sqrt((b-x)*(b-x)+(f-y)*(f-y)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(b-x)/E,this.y=(f-y)/E,this.z=(g-d)/E,this.w=Math.acos((u+p+v-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 $4e extends Rf{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new ur(0,0,e,n),this.scissorTest=!1,this.viewport=new ur(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(x0("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Kh?la:lo),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:so,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new cs(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 jQ(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 _f extends $4e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class RQ extends cs{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=oa,this.minFilter=oa,this.wrapR=Fo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class V4e extends cs{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=oa,this.minFilter=oa,this.wrapR=Fo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class wf{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,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3];const g=a[o+0],p=a[o+1],x=a[o+2],y=a[o+3];if(l===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l===1){e[n+0]=g,e[n+1]=p,e[n+2]=x,e[n+3]=y;return}if(f!==y||c!==g||u!==p||d!==x){let b=1-l;const v=c*g+u*p+d*x+f*y,E=v>=0?1:-1,w=1-v*v;if(w>Number.EPSILON){const A=Math.sqrt(w),C=Math.atan2(A,v*E);b=Math.sin(b*C)/A,l=Math.sin(l*C)/A}const N=l*E;if(c=c*b+g*N,u=u*b+p*N,d=d*b+x*N,f=f*b+y*N,b===1-l){const A=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=A,u*=A,d*=A,f*=A}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[o],g=a[o+1],p=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*p-u*g,e[n+1]=c*x+d*g+u*f-l*p,e[n+2]=u*x+d*p+l*g-c*f,e[n+3]=d*x-l*f-c*g-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),g=c(r/2),p=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"YXZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"ZXY":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"ZYX":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"YZX":this._x=g*d*f+u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f-g*p*x;break;case"XZY":this._x=g*d*f-u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f+g*p*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}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],o=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=(o-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+o)/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+o)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(o-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(ca(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,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*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,o=this._w;let l=o*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=o,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*o+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=o*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 Ie{constructor(e=0,n=0,r=0){Ie.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(mV.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(mV.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,o=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])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*d-o*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,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*o-r*c,this.z=r*l-i*o,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 kC.copy(this).projectOnVector(e),this.sub(kC)}reflect(e){return this.sub(kC.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(ca(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 kC=new Ie,mV=new wf;class go{constructor(e=new Ie(1/0,1/0,1/0),n=new Ie(-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(Po.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Po.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=Po.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 o=0,l=a.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,Po):Po.fromBufferAttribute(a,o),Po.applyMatrix4(e.matrixWorld),this.expandByPoint(Po);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),S_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),S_.copy(r.boundingBox)),S_.applyMatrix4(e.matrixWorld),this.union(S_)}const i=e.children;for(let a=0,o=i.length;a<o;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,Po),Po.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(Hx),M_.subVectors(this.max,Hx),Lm.subVectors(e.a,Hx),Im.subVectors(e.b,Hx),Fm.subVectors(e.c,Hx),Lu.subVectors(Im,Lm),Iu.subVectors(Fm,Im),mh.subVectors(Lm,Fm);let n=[0,-Lu.z,Lu.y,0,-Iu.z,Iu.y,0,-mh.z,mh.y,Lu.z,0,-Lu.x,Iu.z,0,-Iu.x,mh.z,0,-mh.x,-Lu.y,Lu.x,0,-Iu.y,Iu.x,0,-mh.y,mh.x,0];return!PC(n,Lm,Im,Fm,M_)||(n=[1,0,0,0,1,0,0,0,1],!PC(n,Lm,Im,Fm,M_))?!1:(E_.crossVectors(Lu,Iu),n=[E_.x,E_.y,E_.z],PC(n,Lm,Im,Fm,M_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Po).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Po).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:(uc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),uc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),uc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),uc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),uc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),uc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),uc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),uc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(uc),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 uc=[new Ie,new Ie,new Ie,new Ie,new Ie,new Ie,new Ie,new Ie],Po=new Ie,S_=new go,Lm=new Ie,Im=new Ie,Fm=new Ie,Lu=new Ie,Iu=new Ie,mh=new Ie,Hx=new Ie,M_=new Ie,E_=new Ie,ph=new Ie;function PC(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){ph.fromArray(t,a);const l=i.x*Math.abs(ph.x)+i.y*Math.abs(ph.y)+i.z*Math.abs(ph.z),c=e.dot(ph),u=n.dot(ph),d=r.dot(ph);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const G4e=new go,$x=new Ie,jC=new Ie;class wl{constructor(e=new Ie,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):G4e.setFromPoints(e).getCenter(r);let i=0;for(let a=0,o=e.length;a<o;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;$x.subVectors(e,this.center);const n=$x.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector($x,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):(jC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint($x.copy(e.center).add(jC)),this.expandByPoint($x.copy(e.center).sub(jC))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const dc=new Ie,RC=new Ie,A_=new Ie,Fu=new Ie,DC=new Ie,N_=new Ie,OC=new Ie;class ZO{constructor(e=new Ie,n=new Ie(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,dc)),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=dc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(dc.copy(this.origin).addScaledVector(this.direction,n),dc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){RC.copy(e).add(n).multiplyScalar(.5),A_.copy(n).sub(e).normalize(),Fu.copy(this.origin).sub(RC);const a=e.distanceTo(n)*.5,o=-this.direction.dot(A_),l=Fu.dot(this.direction),c=-Fu.dot(A_),u=Fu.lengthSq(),d=Math.abs(1-o*o);let f,g,p,x;if(d>0)if(f=o*c-l,g=o*l-c,x=a*d,f>=0)if(g>=-x)if(g<=x){const y=1/d;f*=y,g*=y,p=f*(f+o*g+2*l)+g*(o*f+g+2*c)+u}else g=a,f=Math.max(0,-(o*g+l)),p=-f*f+g*(g+2*c)+u;else g=-a,f=Math.max(0,-(o*g+l)),p=-f*f+g*(g+2*c)+u;else g<=-x?(f=Math.max(0,-(-o*a+l)),g=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u):g<=x?(f=0,g=Math.min(Math.max(-a,-c),a),p=g*(g+2*c)+u):(f=Math.max(0,-(o*a+l)),g=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u);else g=o>0?-a:a,f=Math.max(0,-(o*g+l)),p=-f*f+g*(g+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(RC).addScaledVector(A_,g),p}intersectSphere(e,n){dc.subVectors(e.center,this.origin);const r=dc.dot(this.direction),i=dc.dot(dc)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-i),l=r-o,c=r+o;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,o,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,o=(e.max.y-g.y)*d):(a=(e.max.y-g.y)*d,o=(e.min.y-g.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),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,dc)!==null}intersectTriangle(e,n,r,i,a){DC.subVectors(n,e),N_.subVectors(r,e),OC.crossVectors(DC,N_);let o=this.direction.dot(OC),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Fu.subVectors(this.origin,e);const c=l*this.direction.dot(N_.crossVectors(Fu,N_));if(c<0)return null;const u=l*this.direction.dot(DC.cross(Fu));if(u<0||c+u>o)return null;const d=-l*Fu.dot(OC);return d<0?null:this.at(d/o,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 vr{constructor(e,n,r,i,a,o,l,c,u,d,f,g,p,x,y,b){vr.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,o,l,c,u,d,f,g,p,x,y,b)}set(e,n,r,i,a,o,l,c,u,d,f,g,p,x,y,b){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=a,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=g,v[3]=p,v[7]=x,v[11]=y,v[15]=b,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 vr().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/Um.setFromMatrixColumn(e,0).length(),a=1/Um.setFromMatrixColumn(e,1).length(),o=1/Um.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]*o,n[9]=r[9]*o,n[10]=r[10]*o,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,o=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=o*d,p=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=g-y*u,n[9]=-l*c,n[2]=y-g*u,n[6]=x+p*u,n[10]=o*c}else if(e.order==="YXZ"){const g=c*d,p=c*f,x=u*d,y=u*f;n[0]=g+y*l,n[4]=x*l-p,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=p*l-x,n[6]=y+g*l,n[10]=o*c}else if(e.order==="ZXY"){const g=c*d,p=c*f,x=u*d,y=u*f;n[0]=g-y*l,n[4]=-o*f,n[8]=x+p*l,n[1]=p+x*l,n[5]=o*d,n[9]=y-g*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const g=o*d,p=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=x*u-p,n[8]=g*u+y,n[1]=c*f,n[5]=y*u+g,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const g=o*c,p=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=y-g*f,n[8]=x*f+p,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+x,n[10]=g-y*f}else if(e.order==="XZY"){const g=o*c,p=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=g*f+y,n[5]=o*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=l*d,n[10]=y*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(W4e,e,q4e)}lookAt(e,n,r){const i=this.elements;return Ms.subVectors(e,n),Ms.lengthSq()===0&&(Ms.z=1),Ms.normalize(),Uu.crossVectors(r,Ms),Uu.lengthSq()===0&&(Math.abs(r.z)===1?Ms.x+=1e-4:Ms.z+=1e-4,Ms.normalize(),Uu.crossVectors(r,Ms)),Uu.normalize(),T_.crossVectors(Ms,Uu),i[0]=Uu.x,i[4]=T_.x,i[8]=Ms.x,i[1]=Uu.y,i[5]=T_.y,i[9]=Ms.y,i[2]=Uu.z,i[6]=T_.z,i[10]=Ms.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,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],g=r[9],p=r[13],x=r[2],y=r[6],b=r[10],v=r[14],E=r[3],w=r[7],N=r[11],A=r[15],C=i[0],T=i[4],L=i[8],k=i[12],D=i[1],U=i[5],O=i[9],q=i[13],R=i[2],G=i[6],Y=i[10],V=i[14],K=i[3],J=i[7],X=i[11],F=i[15];return a[0]=o*C+l*D+c*R+u*K,a[4]=o*T+l*U+c*G+u*J,a[8]=o*L+l*O+c*Y+u*X,a[12]=o*k+l*q+c*V+u*F,a[1]=d*C+f*D+g*R+p*K,a[5]=d*T+f*U+g*G+p*J,a[9]=d*L+f*O+g*Y+p*X,a[13]=d*k+f*q+g*V+p*F,a[2]=x*C+y*D+b*R+v*K,a[6]=x*T+y*U+b*G+v*J,a[10]=x*L+y*O+b*Y+v*X,a[14]=x*k+y*q+b*V+v*F,a[3]=E*C+w*D+N*R+A*K,a[7]=E*T+w*U+N*G+A*J,a[11]=E*L+w*O+N*Y+A*X,a[15]=E*k+w*q+N*V+A*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],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],g=e[10],p=e[14],x=e[3],y=e[7],b=e[11],v=e[15];return x*(+a*c*f-i*u*f-a*l*g+r*u*g+i*l*p-r*c*p)+y*(+n*c*p-n*u*g+a*o*g-i*o*p+i*u*d-a*c*d)+b*(+n*u*f-n*l*p-a*o*f+r*o*p+a*l*d-r*u*d)+v*(-i*l*d-n*c*f+n*l*g+i*o*f-r*o*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],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],g=e[10],p=e[11],x=e[12],y=e[13],b=e[14],v=e[15],E=f*b*u-y*g*u+y*c*p-l*b*p-f*c*v+l*g*v,w=x*g*u-d*b*u-x*c*p+o*b*p+d*c*v-o*g*v,N=d*y*u-x*f*u+x*l*p-o*y*p-d*l*v+o*f*v,A=x*f*c-d*y*c-x*l*g+o*y*g+d*l*b-o*f*b,C=n*E+r*w+i*N+a*A;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/C;return e[0]=E*T,e[1]=(y*g*a-f*b*a-y*i*p+r*b*p+f*i*v-r*g*v)*T,e[2]=(l*b*a-y*c*a+y*i*u-r*b*u-l*i*v+r*c*v)*T,e[3]=(f*c*a-l*g*a-f*i*u+r*g*u+l*i*p-r*c*p)*T,e[4]=w*T,e[5]=(d*b*a-x*g*a+x*i*p-n*b*p-d*i*v+n*g*v)*T,e[6]=(x*c*a-o*b*a-x*i*u+n*b*u+o*i*v-n*c*v)*T,e[7]=(o*g*a-d*c*a+d*i*u-n*g*u-o*i*p+n*c*p)*T,e[8]=N*T,e[9]=(x*f*a-d*y*a-x*r*p+n*y*p+d*r*v-n*f*v)*T,e[10]=(o*y*a-x*l*a+x*r*u-n*y*u-o*r*v+n*l*v)*T,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*T,e[12]=A*T,e[13]=(d*y*i-x*f*i+x*r*g-n*y*g-d*r*b+n*f*b)*T,e[14]=(x*l*i-o*y*i-x*r*c+n*y*c+o*r*b-n*l*b)*T,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*g+n*l*g)*T,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,o=e.x,l=e.y,c=e.z,u=a*o,d=a*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,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,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,g=a*u,p=a*d,x=a*f,y=o*d,b=o*f,v=l*f,E=c*u,w=c*d,N=c*f,A=r.x,C=r.y,T=r.z;return i[0]=(1-(y+v))*A,i[1]=(p+N)*A,i[2]=(x-w)*A,i[3]=0,i[4]=(p-N)*C,i[5]=(1-(g+v))*C,i[6]=(b+E)*C,i[7]=0,i[8]=(x+w)*T,i[9]=(b-E)*T,i[10]=(1-(g+y))*T,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=Um.set(i[0],i[1],i[2]).length();const o=Um.set(i[4],i[5],i[6]).length(),l=Um.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],jo.copy(this);const u=1/a,d=1/o,f=1/l;return jo.elements[0]*=u,jo.elements[1]*=u,jo.elements[2]*=u,jo.elements[4]*=d,jo.elements[5]*=d,jo.elements[6]*=d,jo.elements[8]*=f,jo.elements[9]*=f,jo.elements[10]*=f,n.setFromRotationMatrix(jo),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=yl){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),g=(r+i)/(r-i);let p,x;if(l===yl)p=-(o+a)/(o-a),x=-2*o*a/(o-a);else if(l===db)p=-o/(o-a),x=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=u,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=g,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=yl){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(o-a),g=(n+e)*u,p=(r+i)*d;let x,y;if(l===yl)x=(o+a)*f,y=-2*f;else if(l===db)x=a*f,y=-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]=y,c[14]=-x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const Um=new Ie,jo=new vr,W4e=new Ie(0,0,0),q4e=new Ie(1,1,1),Uu=new Ie,T_=new Ie,Ms=new Ie,pV=new vr,gV=new wf;class uy{constructor(e=0,n=0,r=0,i=uy.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],o=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(ca(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-ca(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(ca(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-ca(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(-o,u));break;case"YZX":this._z=Math.asin(ca(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(-ca(o,-1,1)),Math.abs(o)<.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 pV.makeRotationFromQuaternion(e),this.setFromRotationMatrix(pV,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return gV.setFromEuler(this),this.setFromQuaternion(gV,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}}uy.DEFAULT_ORDER="XYZ";class DQ{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 K4e=0;const xV=new Ie,zm=new wf,hc=new vr,C_=new Ie,Vx=new Ie,X4e=new Ie,Y4e=new wf,bV=new Ie(1,0,0),yV=new Ie(0,1,0),vV=new Ie(0,0,1),Z4e={type:"added"},Q4e={type:"removed"};class Fa extends Rf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:K4e++}),this.uuid=zc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Fa.DEFAULT_UP.clone();const e=new Ie,n=new uy,r=new wf,i=new Ie(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),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 vr},normalMatrix:{value:new Sn}}),this.matrix=new vr,this.matrixWorld=new vr,this.matrixAutoUpdate=Fa.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Fa.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new DQ,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 zm.setFromAxisAngle(e,n),this.quaternion.multiply(zm),this}rotateOnWorldAxis(e,n){return zm.setFromAxisAngle(e,n),this.quaternion.premultiply(zm),this}rotateX(e){return this.rotateOnAxis(bV,e)}rotateY(e){return this.rotateOnAxis(yV,e)}rotateZ(e){return this.rotateOnAxis(vV,e)}translateOnAxis(e,n){return xV.copy(e).applyQuaternion(this.quaternion),this.position.add(xV.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(bV,e)}translateY(e){return this.translateOnAxis(yV,e)}translateZ(e){return this.translateOnAxis(vV,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(hc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?C_.copy(e):C_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Vx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?hc.lookAt(Vx,C_,this.up):hc.lookAt(C_,Vx,this.up),this.quaternion.setFromRotationMatrix(hc),i&&(hc.extractRotation(i.matrixWorld),zm.setFromRotationMatrix(hc),this.quaternion.premultiply(zm.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(Z4e)):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(Q4e)),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),hc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),hc.multiply(e.parent.matrixWorld)),e.applyMatrix4(hc),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 o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,o=i.length;a<o;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(Vx,e,X4e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Vx,Y4e,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,o=i.length;a<o;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=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=o(e.shapes),g=o(e.skeletons),p=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(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}}Fa.DEFAULT_UP=new Ie(0,1,0);Fa.DEFAULT_MATRIX_AUTO_UPDATE=!0;Fa.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ro=new Ie,fc=new Ie,LC=new Ie,mc=new Ie,Bm=new Ie,Hm=new Ie,_V=new Ie,IC=new Ie,FC=new Ie,UC=new Ie;let k_=!1;class Do{constructor(e=new Ie,n=new Ie,r=new Ie){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Ro.subVectors(e,n),i.cross(Ro);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){Ro.subVectors(i,n),fc.subVectors(r,n),LC.subVectors(e,n);const o=Ro.dot(Ro),l=Ro.dot(fc),c=Ro.dot(LC),u=fc.dot(fc),d=fc.dot(LC),f=o*u-l*l;if(f===0)return a.set(-2,-1,-1);const g=1/f,p=(u*c-l*d)*g,x=(o*d-l*c)*g;return a.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,mc),mc.x>=0&&mc.y>=0&&mc.x+mc.y<=1}static getUV(e,n,r,i,a,o,l,c){return k_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),k_=!0),this.getInterpolation(e,n,r,i,a,o,l,c)}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,mc),c.setScalar(0),c.addScaledVector(a,mc.x),c.addScaledVector(o,mc.y),c.addScaledVector(l,mc.z),c}static isFrontFacing(e,n,r,i){return Ro.subVectors(r,n),fc.subVectors(e,n),Ro.cross(fc).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 Ro.subVectors(this.c,this.b),fc.subVectors(this.a,this.b),Ro.cross(fc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Do.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Do.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return k_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),k_=!0),Do.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return Do.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Do.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Do.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 o,l;Bm.subVectors(i,r),Hm.subVectors(a,r),IC.subVectors(e,r);const c=Bm.dot(IC),u=Hm.dot(IC);if(c<=0&&u<=0)return n.copy(r);FC.subVectors(e,i);const d=Bm.dot(FC),f=Hm.dot(FC);if(d>=0&&f<=d)return n.copy(i);const g=c*f-d*u;if(g<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Bm,o);UC.subVectors(e,a);const p=Bm.dot(UC),x=Hm.dot(UC);if(x>=0&&p<=x)return n.copy(a);const y=p*u-c*x;if(y<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Hm,l);const b=d*x-p*f;if(b<=0&&f-d>=0&&p-x>=0)return _V.subVectors(a,i),l=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(_V,l);const v=1/(b+y+g);return o=y*v,l=g*v,n.copy(r).addScaledVector(Bm,o).addScaledVector(Hm,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const OQ={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},zu={h:0,s:0,l:0},P_={h:0,s:0,l:0};function zC(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 Yt=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=la){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,lr.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=lr.workingColorSpace){return this.r=e,this.g=n,this.b=r,lr.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=lr.workingColorSpace){if(e=YO(e,1),n=ca(n,0,1),r=ca(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=zC(o,a,e+1/3),this.g=zC(o,a,e),this.b=zC(o,a,e-1/3)}return lr.toWorkingColorSpace(this,i),this}setStyle(e,n=la){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 o=i[1],l=i[2];switch(o){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],o=a.length;if(o===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(o===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=la){const r=OQ[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=Mp(e.r),this.g=Mp(e.g),this.b=Mp(e.b),this}copyLinearToSRGB(e){return this.r=TC(e.r),this.g=TC(e.g),this.b=TC(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=la){return lr.fromWorkingColorSpace(ba.copy(this),e),Math.round(ca(ba.r*255,0,255))*65536+Math.round(ca(ba.g*255,0,255))*256+Math.round(ca(ba.b*255,0,255))}getHexString(e=la){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=lr.workingColorSpace){lr.fromWorkingColorSpace(ba.copy(this),n);const r=ba.r,i=ba.g,a=ba.b,o=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){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=lr.workingColorSpace){return lr.fromWorkingColorSpace(ba.copy(this),n),e.r=ba.r,e.g=ba.g,e.b=ba.b,e}getStyle(e=la){lr.fromWorkingColorSpace(ba.copy(this),e);const n=ba.r,r=ba.g,i=ba.b;return e!==la?`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(zu),this.setHSL(zu.h+e,zu.s+n,zu.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(zu),e.getHSL(P_);const r=g0(zu.h,P_.h,n),i=g0(zu.s,P_.s,n),a=g0(zu.l,P_.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 ba=new Yt;Yt.NAMES=OQ;let J4e=0;class Tg extends Rf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:J4e++}),this.uuid=zc(),this.name="",this.type="Material",this.blending=Sp,this.side=Dd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=aj,this.blendDst=sj,this.blendEquation=Nh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Yt(0,0,0),this.blendAlpha=0,this.depthFunc=nS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=lV,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Dm,this.stencilZFail=Dm,this.stencilZPass=Dm,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!==Sp&&(r.blending=this.blending),this.side!==Dd&&(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!==aj&&(r.blendSrc=this.blendSrc),this.blendDst!==sj&&(r.blendDst=this.blendDst),this.blendEquation!==Nh&&(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!==nS&&(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!==lV&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Dm&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Dm&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Dm&&(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 o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(n){const a=i(e.textures),o=i(e.images);a.length>0&&(r.textures=a),o.length>0&&(r.images=o)}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 LQ extends Tg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Yt(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=qO,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 li=new Ie,j_=new sn;class Ds{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=dj,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Rc,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++)j_.fromBufferAttribute(this,n),j_.applyMatrix3(e),this.setXY(n,j_.x,j_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)li.fromBufferAttribute(this,n),li.applyMatrix3(e),this.setXYZ(n,li.x,li.y,li.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)li.fromBufferAttribute(this,n),li.applyMatrix4(e),this.setXYZ(n,li.x,li.y,li.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)li.fromBufferAttribute(this,n),li.applyNormalMatrix(e),this.setXYZ(n,li.x,li.y,li.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)li.fromBufferAttribute(this,n),li.transformDirection(e),this.setXYZ(n,li.x,li.y,li.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=pl(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=or(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=pl(n,this.array)),n}setX(e,n){return this.normalized&&(n=or(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=pl(n,this.array)),n}setY(e,n){return this.normalized&&(n=or(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=pl(n,this.array)),n}setZ(e,n){return this.normalized&&(n=or(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=pl(n,this.array)),n}setW(e,n){return this.normalized&&(n=or(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=or(n,this.array),r=or(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=or(n,this.array),r=or(r,this.array),i=or(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=or(n,this.array),r=or(r,this.array),i=or(i,this.array),a=or(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!==dj&&(e.usage=this.usage),e}}class IQ extends Ds{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class FQ extends Ds{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class ni extends Ds{constructor(e,n,r){super(new Float32Array(e),n,r)}}let eLe=0;const Ys=new vr,BC=new Fa,$m=new Ie,Es=new go,Gx=new go,zi=new Ie;class Ta extends Rf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:eLe++}),this.uuid=zc(),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(kQ(e)?FQ:IQ)(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 Sn().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 Ys.makeRotationFromQuaternion(e),this.applyMatrix4(Ys),this}rotateX(e){return Ys.makeRotationX(e),this.applyMatrix4(Ys),this}rotateY(e){return Ys.makeRotationY(e),this.applyMatrix4(Ys),this}rotateZ(e){return Ys.makeRotationZ(e),this.applyMatrix4(Ys),this}translate(e,n,r){return Ys.makeTranslation(e,n,r),this.applyMatrix4(Ys),this}scale(e,n,r){return Ys.makeScale(e,n,r),this.applyMatrix4(Ys),this}lookAt(e){return BC.lookAt(e),BC.updateMatrix(),this.applyMatrix4(BC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter($m).negate(),this.translate($m.x,$m.y,$m.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 ni(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new go);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 Ie(-1/0,-1/0,-1/0),new Ie(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];Es.setFromBufferAttribute(a),this.morphTargetsRelative?(zi.addVectors(this.boundingBox.min,Es.min),this.boundingBox.expandByPoint(zi),zi.addVectors(this.boundingBox.max,Es.max),this.boundingBox.expandByPoint(zi)):(this.boundingBox.expandByPoint(Es.min),this.boundingBox.expandByPoint(Es.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 wl);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 Ie,1/0);return}if(e){const r=this.boundingSphere.center;if(Es.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];Gx.setFromBufferAttribute(l),this.morphTargetsRelative?(zi.addVectors(Es.min,Gx.min),Es.expandByPoint(zi),zi.addVectors(Es.max,Gx.max),Es.expandByPoint(zi)):(Es.expandByPoint(Gx.min),Es.expandByPoint(Gx.max))}Es.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)zi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(zi));if(n)for(let a=0,o=n.length;a<o;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)zi.fromBufferAttribute(l,u),c&&($m.fromBufferAttribute(e,u),zi.add($m)),i=Math.max(i,r.distanceToSquared(zi))}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,o=n.uv.array,l=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ds(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let D=0;D<l;D++)u[D]=new Ie,d[D]=new Ie;const f=new Ie,g=new Ie,p=new Ie,x=new sn,y=new sn,b=new sn,v=new Ie,E=new Ie;function w(D,U,O){f.fromArray(i,D*3),g.fromArray(i,U*3),p.fromArray(i,O*3),x.fromArray(o,D*2),y.fromArray(o,U*2),b.fromArray(o,O*2),g.sub(f),p.sub(f),y.sub(x),b.sub(x);const q=1/(y.x*b.y-b.x*y.y);isFinite(q)&&(v.copy(g).multiplyScalar(b.y).addScaledVector(p,-y.y).multiplyScalar(q),E.copy(p).multiplyScalar(y.x).addScaledVector(g,-b.x).multiplyScalar(q),u[D].add(v),u[U].add(v),u[O].add(v),d[D].add(E),d[U].add(E),d[O].add(E))}let N=this.groups;N.length===0&&(N=[{start:0,count:r.length}]);for(let D=0,U=N.length;D<U;++D){const O=N[D],q=O.start,R=O.count;for(let G=q,Y=q+R;G<Y;G+=3)w(r[G+0],r[G+1],r[G+2])}const A=new Ie,C=new Ie,T=new Ie,L=new Ie;function k(D){T.fromArray(a,D*3),L.copy(T);const U=u[D];A.copy(U),A.sub(T.multiplyScalar(T.dot(U))).normalize(),C.crossVectors(L,U);const q=C.dot(d[D])<0?-1:1;c[D*4]=A.x,c[D*4+1]=A.y,c[D*4+2]=A.z,c[D*4+3]=q}for(let D=0,U=N.length;D<U;++D){const O=N[D],q=O.start,R=O.count;for(let G=q,Y=q+R;G<Y;G+=3)k(r[G+0]),k(r[G+1]),k(r[G+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 Ds(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 Ie,a=new Ie,o=new Ie,l=new Ie,c=new Ie,u=new Ie,d=new Ie,f=new Ie;if(e)for(let g=0,p=e.count;g<p;g+=3){const x=e.getX(g+0),y=e.getX(g+1),b=e.getX(g+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,y),o.fromBufferAttribute(n,b),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,b),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(b,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),o.fromBufferAttribute(n,g+2),d.subVectors(o,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++)zi.fromBufferAttribute(e,n),zi.normalize(),e.setXYZ(n,zi.x,zi.y,zi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,g=new u.constructor(c.length*d);let p=0,x=0;for(let y=0,b=c.length;y<b;y++){l.isInterleavedBufferAttribute?p=c[y]*l.data.stride+l.offset:p=c[y]*d;for(let v=0;v<d;v++)g[x++]=u[p++]}return new Ds(g,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Ta,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 o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[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 o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));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 o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[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 wV=new vr,gh=new ZO,R_=new wl,SV=new Ie,Vm=new Ie,Gm=new Ie,Wm=new Ie,HC=new Ie,D_=new Ie,O_=new sn,L_=new sn,I_=new sn,MV=new Ie,EV=new Ie,AV=new Ie,F_=new Ie,U_=new Ie;class Bo extends Fa{constructor(e=new Ta,n=new LQ){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,o=i.length;a<o;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,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){D_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(HC.fromBufferAttribute(f,e),o?D_.addScaledVector(HC,d):D_.addScaledVector(HC.sub(n),d))}n.add(D_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),R_.copy(r.boundingSphere),R_.applyMatrix4(a),gh.copy(e.ray).recast(e.near),!(R_.containsPoint(gh.origin)===!1&&(gh.intersectSphere(R_,SV)===null||gh.origin.distanceToSquared(SV)>(e.far-e.near)**2))&&(wV.copy(a).invert(),gh.copy(e.ray).applyMatrix4(wV),!(r.boundingBox!==null&&gh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,gh)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=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(o))for(let x=0,y=g.length;x<y;x++){const b=g[x],v=o[b.materialIndex],E=Math.max(b.start,p.start),w=Math.min(l.count,Math.min(b.start+b.count,p.start+p.count));for(let N=E,A=w;N<A;N+=3){const C=l.getX(N),T=l.getX(N+1),L=l.getX(N+2);i=z_(this,v,e,r,u,d,f,C,T,L),i&&(i.faceIndex=Math.floor(N/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let b=x,v=y;b<v;b+=3){const E=l.getX(b),w=l.getX(b+1),N=l.getX(b+2);i=z_(this,o,e,r,u,d,f,E,w,N),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,y=g.length;x<y;x++){const b=g[x],v=o[b.materialIndex],E=Math.max(b.start,p.start),w=Math.min(c.count,Math.min(b.start+b.count,p.start+p.count));for(let N=E,A=w;N<A;N+=3){const C=N,T=N+1,L=N+2;i=z_(this,v,e,r,u,d,f,C,T,L),i&&(i.faceIndex=Math.floor(N/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),y=Math.min(c.count,p.start+p.count);for(let b=x,v=y;b<v;b+=3){const E=b,w=b+1,N=b+2;i=z_(this,o,e,r,u,d,f,E,w,N),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}}function tLe(t,e,n,r,i,a,o,l){let c;if(e.side===ls?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Dd,l),c===null)return null;U_.copy(l),U_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(U_);return u<n.near||u>n.far?null:{distance:u,point:U_.clone(),object:t}}function z_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,Vm),t.getVertexPosition(c,Gm),t.getVertexPosition(u,Wm);const d=tLe(t,e,n,r,Vm,Gm,Wm,F_);if(d){i&&(O_.fromBufferAttribute(i,l),L_.fromBufferAttribute(i,c),I_.fromBufferAttribute(i,u),d.uv=Do.getInterpolation(F_,Vm,Gm,Wm,O_,L_,I_,new sn)),a&&(O_.fromBufferAttribute(a,l),L_.fromBufferAttribute(a,c),I_.fromBufferAttribute(a,u),d.uv1=Do.getInterpolation(F_,Vm,Gm,Wm,O_,L_,I_,new sn),d.uv2=d.uv1),o&&(MV.fromBufferAttribute(o,l),EV.fromBufferAttribute(o,c),AV.fromBufferAttribute(o,u),d.normal=Do.getInterpolation(F_,Vm,Gm,Wm,MV,EV,AV,new Ie),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new Ie,materialIndex:0};Do.getNormal(Vm,Gm,Wm,f.normal),d.face=f}return d}class dy extends Ta{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let g=0,p=0;x("z","y","x",-1,-1,r,n,e,o,a,0),x("z","y","x",1,-1,r,n,-e,o,a,1),x("x","z","y",1,1,e,r,n,i,o,2),x("x","z","y",1,-1,e,r,-n,i,o,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new ni(u,3)),this.setAttribute("normal",new ni(d,3)),this.setAttribute("uv",new ni(f,2));function x(y,b,v,E,w,N,A,C,T,L,k){const D=N/T,U=A/L,O=N/2,q=A/2,R=C/2,G=T+1,Y=L+1;let V=0,K=0;const J=new Ie;for(let X=0;X<Y;X++){const F=X*U-q;for(let W=0;W<G;W++){const ee=W*D-O;J[y]=ee*E,J[b]=F*w,J[v]=R,u.push(J.x,J.y,J.z),J[y]=0,J[b]=0,J[v]=C>0?1:-1,d.push(J.x,J.y,J.z),f.push(W/T),f.push(1-X/L),V+=1}}for(let X=0;X<L;X++)for(let F=0;F<T;F++){const W=g+F+G*X,ee=g+F+G*(X+1),ie=g+(F+1)+G*(X+1),ae=g+(F+1)+G*X;c.push(W,ee,ae),c.push(ee,ie,ae),K+=6}l.addGroup(p,K,k),p+=K,g+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dy(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Qp(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 Ra(t){const e={};for(let n=0;n<t.length;n++){const r=Qp(t[n]);for(const i in r)e[i]=r[i]}return e}function nLe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function UQ(t){return t.getRenderTarget()===null?t.outputColorSpace:lr.workingColorSpace}const QO={clone:Qp,merge:Ra};var rLe=`void main() {
  3920. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3921. }`,iLe=`void main() {
  3922. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3923. }`;class Od extends Tg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=rLe,this.fragmentShader=iLe,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=Qp(e.uniforms),this.uniformsGroups=nLe(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?n.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?n.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?n.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?n.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?n.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?n.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?n.uniforms[i]={type:"m4",value:o.toArray()}:n.uniforms[i]={value:o}}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 zQ extends Fa{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new vr,this.projectionMatrix=new vr,this.projectionMatrixInverse=new vr,this.coordinateSystem=yl}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 Ns extends zQ{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=hb*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(p0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return hb*2*Math.atan(Math.tan(p0*.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,o){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=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(p0*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;a+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.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 qm=-90,Km=1;class aLe extends Fa{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ns(qm,Km,e,n);i.layers=this.layers,this.add(i);const a=new Ns(qm,Km,e,n);a.layers=this.layers,this.add(a);const o=new Ns(qm,Km,e,n);o.layers=this.layers,this.add(o);const l=new Ns(qm,Km,e,n);l.layers=this.layers,this.add(l);const c=new Ns(qm,Km,e,n);c.layers=this.layers,this.add(c);const u=new Ns(qm,Km,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,o,l,c]=n;for(const u of n)this.remove(u);if(e===yl)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),o.up.set(0,0,1),o.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===db)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),o.up.set(0,0,-1),o.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,o,l,c,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,o),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=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class BQ extends cs{constructor(e,n,r,i,a,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Xp,super(e,n,r,i,a,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class sLe extends _f{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&&(x0("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Kh?la:lo),this.texture=new BQ(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:so}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 dy(5,5,5),a=new Od({name:"CubemapFromEquirect",uniforms:Qp(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ls,blending:pd});a.uniforms.tEquirect.value=n;const o=new Bo(i,a),l=n.minFilter;return n.minFilter===cb&&(n.minFilter=so),new aLe(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n,r,i){const a=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(a)}}const $C=new Ie,oLe=new Ie,lLe=new Sn;class Xu{constructor(e=new Ie(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=$C.subVectors(r,n).cross(oLe.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($C),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||lLe.getNormalMatrix(e),i=this.coplanarPoint($C).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 xh=new wl,B_=new Ie;class p2{constructor(e=new Xu,n=new Xu,r=new Xu,i=new Xu,a=new Xu,o=new Xu){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,o){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(o),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=yl){const r=this.planes,i=e.elements,a=i[0],o=i[1],l=i[2],c=i[3],u=i[4],d=i[5],f=i[6],g=i[7],p=i[8],x=i[9],y=i[10],b=i[11],v=i[12],E=i[13],w=i[14],N=i[15];if(r[0].setComponents(c-a,g-u,b-p,N-v).normalize(),r[1].setComponents(c+a,g+u,b+p,N+v).normalize(),r[2].setComponents(c+o,g+d,b+x,N+E).normalize(),r[3].setComponents(c-o,g-d,b-x,N-E).normalize(),r[4].setComponents(c-l,g-f,b-y,N-w).normalize(),n===yl)r[5].setComponents(c+l,g+f,b+y,N+w).normalize();else if(n===db)r[5].setComponents(l,f,y,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(),xh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),xh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(xh)}intersectsSprite(e){return xh.center.set(0,0,0),xh.radius=.7071067811865476,xh.applyMatrix4(e.matrixWorld),this.intersectsSphere(xh)}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(B_.x=i.normal.x>0?e.max.x:e.min.x,B_.y=i.normal.y>0?e.max.y:e.min.y,B_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(B_)<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 HQ(){let t=null,e=!1,n=null,r=null;function i(a,o){n(a,o),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 cLe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,g=u.usage,p=f.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,f,g),u.onUploadCallback();let y;if(f instanceof Float32Array)y=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)y=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else y=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)y=t.SHORT;else if(f instanceof Uint32Array)y=t.UNSIGNED_INT;else if(f instanceof Int32Array)y=t.INT;else if(f instanceof Int8Array)y=t.BYTE;else if(f instanceof Uint8Array)y=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)y=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:x,type:y,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:p}}function a(u,d,f){const g=d.array,p=d._updateRange,x=d.updateRanges;if(t.bindBuffer(f,u),p.count===-1&&x.length===0&&t.bufferSubData(f,0,g),x.length!==0){for(let y=0,b=x.length;y<b;y++){const v=x[y];n?t.bufferSubData(f,v.start*g.BYTES_PER_ELEMENT,g,v.start,v.count):t.bufferSubData(f,v.start*g.BYTES_PER_ELEMENT,g.subarray(v.start,v.start+v.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 o(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:o,remove:l,update:c}}class JO extends Ta{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,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,g=n/c,p=[],x=[],y=[],b=[];for(let v=0;v<d;v++){const E=v*g-o;for(let w=0;w<u;w++){const N=w*f-a;x.push(N,-E,0),y.push(0,0,1),b.push(w/l),b.push(1-v/c)}}for(let v=0;v<c;v++)for(let E=0;E<l;E++){const w=E+u*v,N=E+u*(v+1),A=E+1+u*(v+1),C=E+1+u*v;p.push(w,N,C),p.push(N,A,C)}this.setIndex(p),this.setAttribute("position",new ni(x,3)),this.setAttribute("normal",new ni(y,3)),this.setAttribute("uv",new ni(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new JO(e.width,e.height,e.widthSegments,e.heightSegments)}}var uLe=`#ifdef USE_ALPHAHASH
  3943. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3944. #endif`,dLe=`#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`,hLe=`#ifdef USE_ALPHAMAP
  3980. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  3981. #endif`,fLe=`#ifdef USE_ALPHAMAP
  3982. uniform sampler2D alphaMap;
  3983. #endif`,mLe=`#ifdef USE_ALPHATEST
  3984. if ( diffuseColor.a < alphaTest ) discard;
  3985. #endif`,pLe=`#ifdef USE_ALPHATEST
  3986. uniform float alphaTest;
  3987. #endif`,gLe=`#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`,xLe=`#ifdef USE_AOMAP
  4001. uniform sampler2D aoMap;
  4002. uniform float aoMapIntensity;
  4003. #endif`,bLe=`#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`,yLe=`#ifdef USE_BATCHING
  4018. mat4 batchingMatrix = getBatchingMatrix( batchId );
  4019. #endif`,vLe=`vec3 transformed = vec3( position );
  4020. #ifdef USE_ALPHAHASH
  4021. vPosition = vec3( position );
  4022. #endif`,_Le=`vec3 objectNormal = vec3( normal );
  4023. #ifdef USE_TANGENT
  4024. vec3 objectTangent = vec3( tangent.xyz );
  4025. #endif`,wLe=`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`,SLe=`#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`,MLe=`#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`,ELe=`#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`,ALe=`#if NUM_CLIPPING_PLANES > 0
  4142. varying vec3 vClipPosition;
  4143. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4144. #endif`,NLe=`#if NUM_CLIPPING_PLANES > 0
  4145. varying vec3 vClipPosition;
  4146. #endif`,TLe=`#if NUM_CLIPPING_PLANES > 0
  4147. vClipPosition = - mvPosition.xyz;
  4148. #endif`,CLe=`#if defined( USE_COLOR_ALPHA )
  4149. diffuseColor *= vColor;
  4150. #elif defined( USE_COLOR )
  4151. diffuseColor.rgb *= vColor;
  4152. #endif`,kLe=`#if defined( USE_COLOR_ALPHA )
  4153. varying vec4 vColor;
  4154. #elif defined( USE_COLOR )
  4155. varying vec3 vColor;
  4156. #endif`,PLe=`#if defined( USE_COLOR_ALPHA )
  4157. varying vec4 vColor;
  4158. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4159. varying vec3 vColor;
  4160. #endif`,jLe=`#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`,RLe=`#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`,DLe=`#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`,OLe=`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`,LLe=`#ifdef USE_DISPLACEMENTMAP
  4376. uniform sampler2D displacementMap;
  4377. uniform float displacementScale;
  4378. uniform float displacementBias;
  4379. #endif`,ILe=`#ifdef USE_DISPLACEMENTMAP
  4380. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4381. #endif`,FLe=`#ifdef USE_EMISSIVEMAP
  4382. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4383. totalEmissiveRadiance *= emissiveColor.rgb;
  4384. #endif`,ULe=`#ifdef USE_EMISSIVEMAP
  4385. uniform sampler2D emissiveMap;
  4386. #endif`,zLe="gl_FragColor = linearToOutputTexel( gl_FragColor );",BLe=`
  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. }`,HLe=`#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`,$Le=`#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`,VLe=`#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`,GLe=`#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`,WLe=`#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`,qLe=`#ifdef USE_FOG
  4490. vFogDepth = - mvPosition.z;
  4491. #endif`,KLe=`#ifdef USE_FOG
  4492. varying float vFogDepth;
  4493. #endif`,XLe=`#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`,YLe=`#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`,ZLe=`#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. }`,QLe=`#ifdef USE_LIGHTMAP
  4522. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4523. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4524. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4525. #endif`,JLe=`#ifdef USE_LIGHTMAP
  4526. uniform sampler2D lightMap;
  4527. uniform float lightMapIntensity;
  4528. #endif`,eIe=`LambertMaterial material;
  4529. material.diffuseColor = diffuseColor.rgb;
  4530. material.specularStrength = specularStrength;`,tIe=`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`,nIe=`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`,rIe=`#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`,iIe=`ToonMaterial material;
  4701. material.diffuseColor = diffuseColor.rgb;`,aIe=`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`,sIe=`BlinnPhongMaterial material;
  4714. material.diffuseColor = diffuseColor.rgb;
  4715. material.specularColor = specular;
  4716. material.specularShininess = shininess;
  4717. material.specularStrength = specularStrength;`,oIe=`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`,lIe=`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`,cIe=`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. }`,uIe=`
  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`,dIe=`#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`,hIe=`#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`,fIe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5257. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5258. #endif`,mIe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5259. uniform float logDepthBufFC;
  5260. varying float vFragDepth;
  5261. varying float vIsPerspective;
  5262. #endif`,pIe=`#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`,gIe=`#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`,xIe=`#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`,bIe=`#ifdef USE_MAP
  5286. uniform sampler2D map;
  5287. #endif`,yIe=`#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`,vIe=`#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`,_Ie=`float metalnessFactor = metalness;
  5312. #ifdef USE_METALNESSMAP
  5313. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5314. metalnessFactor *= texelMetalness.b;
  5315. #endif`,wIe=`#ifdef USE_METALNESSMAP
  5316. uniform sampler2D metalnessMap;
  5317. #endif`,SIe=`#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`,MIe=`#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`,EIe=`#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`,AIe=`#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`,NIe=`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;`,TIe=`#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`,CIe=`#ifndef FLAT_SHADED
  5433. varying vec3 vNormal;
  5434. #ifdef USE_TANGENT
  5435. varying vec3 vTangent;
  5436. varying vec3 vBitangent;
  5437. #endif
  5438. #endif`,kIe=`#ifndef FLAT_SHADED
  5439. varying vec3 vNormal;
  5440. #ifdef USE_TANGENT
  5441. varying vec3 vTangent;
  5442. varying vec3 vBitangent;
  5443. #endif
  5444. #endif`,PIe=`#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`,jIe=`#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`,RIe=`#ifdef USE_CLEARCOAT
  5473. vec3 clearcoatNormal = nonPerturbedNormal;
  5474. #endif`,DIe=`#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`,OIe=`#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`,LIe=`#ifdef USE_IRIDESCENCEMAP
  5488. uniform sampler2D iridescenceMap;
  5489. #endif
  5490. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5491. uniform sampler2D iridescenceThicknessMap;
  5492. #endif`,IIe=`#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 );`,FIe=`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. }`,UIe=`#ifdef PREMULTIPLIED_ALPHA
  5540. gl_FragColor.rgb *= gl_FragColor.a;
  5541. #endif`,zIe=`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;`,BIe=`#ifdef DITHERING
  5550. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5551. #endif`,HIe=`#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`,$Ie=`float roughnessFactor = roughness;
  5559. #ifdef USE_ROUGHNESSMAP
  5560. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5561. roughnessFactor *= texelRoughness.g;
  5562. #endif`,VIe=`#ifdef USE_ROUGHNESSMAP
  5563. uniform sampler2D roughnessMap;
  5564. #endif`,GIe=`#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`,WIe=`#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`,qIe=`#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`,KIe=`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. }`,XIe=`#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`,YIe=`#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`,ZIe=`#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`,QIe=`#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`,JIe=`float specularStrength;
  5883. #ifdef USE_SPECULARMAP
  5884. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5885. specularStrength = texelSpecular.r;
  5886. #else
  5887. specularStrength = 1.0;
  5888. #endif`,e5e=`#ifdef USE_SPECULARMAP
  5889. uniform sampler2D specularMap;
  5890. #endif`,t5e=`#if defined( TONE_MAPPING )
  5891. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5892. #endif`,n5e=`#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; }`,r5e=`#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`,i5e=`#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`,a5e=`#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`,s5e=`#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`,o5e=`#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`,l5e=`#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 c5e=`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. }`,u5e=`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. }`,d5e=`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. }`,h5e=`#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. }`,f5e=`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. }`,m5e=`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. }`,p5e=`#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. }`,g5e=`#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. }`,x5e=`#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. }`,b5e=`#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. }`,y5e=`varying vec3 vWorldDirection;
  6469. #include <common>
  6470. void main() {
  6471. vWorldDirection = transformDirection( position, modelMatrix );
  6472. #include <begin_vertex>
  6473. #include <project_vertex>
  6474. }`,v5e=`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. }`,_5e=`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. }`,w5e=`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. }`,S5e=`#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. }`,M5e=`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. }`,E5e=`#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. }`,A5e=`#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. }`,N5e=`#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. }`,T5e=`#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. }`,C5e=`#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. }`,k5e=`#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. }`,P5e=`#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. }`,j5e=`#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. }`,R5e=`#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. }`,D5e=`#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. }`,O5e=`#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. }`,L5e=`#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. }`,I5e=`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. }`,F5e=`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. }`,U5e=`#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. }`,z5e=`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. }`,B5e=`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. }`,H5e=`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:uLe,alphahash_pars_fragment:dLe,alphamap_fragment:hLe,alphamap_pars_fragment:fLe,alphatest_fragment:mLe,alphatest_pars_fragment:pLe,aomap_fragment:gLe,aomap_pars_fragment:xLe,batching_pars_vertex:bLe,batching_vertex:yLe,begin_vertex:vLe,beginnormal_vertex:_Le,bsdfs:wLe,iridescence_fragment:SLe,bumpmap_pars_fragment:MLe,clipping_planes_fragment:ELe,clipping_planes_pars_fragment:ALe,clipping_planes_pars_vertex:NLe,clipping_planes_vertex:TLe,color_fragment:CLe,color_pars_fragment:kLe,color_pars_vertex:PLe,color_vertex:jLe,common:RLe,cube_uv_reflection_fragment:DLe,defaultnormal_vertex:OLe,displacementmap_pars_vertex:LLe,displacementmap_vertex:ILe,emissivemap_fragment:FLe,emissivemap_pars_fragment:ULe,colorspace_fragment:zLe,colorspace_pars_fragment:BLe,envmap_fragment:HLe,envmap_common_pars_fragment:$Le,envmap_pars_fragment:VLe,envmap_pars_vertex:GLe,envmap_physical_pars_fragment:rIe,envmap_vertex:WLe,fog_vertex:qLe,fog_pars_vertex:KLe,fog_fragment:XLe,fog_pars_fragment:YLe,gradientmap_pars_fragment:ZLe,lightmap_fragment:QLe,lightmap_pars_fragment:JLe,lights_lambert_fragment:eIe,lights_lambert_pars_fragment:tIe,lights_pars_begin:nIe,lights_toon_fragment:iIe,lights_toon_pars_fragment:aIe,lights_phong_fragment:sIe,lights_phong_pars_fragment:oIe,lights_physical_fragment:lIe,lights_physical_pars_fragment:cIe,lights_fragment_begin:uIe,lights_fragment_maps:dIe,lights_fragment_end:hIe,logdepthbuf_fragment:fIe,logdepthbuf_pars_fragment:mIe,logdepthbuf_pars_vertex:pIe,logdepthbuf_vertex:gIe,map_fragment:xIe,map_pars_fragment:bIe,map_particle_fragment:yIe,map_particle_pars_fragment:vIe,metalnessmap_fragment:_Ie,metalnessmap_pars_fragment:wIe,morphcolor_vertex:SIe,morphnormal_vertex:MIe,morphtarget_pars_vertex:EIe,morphtarget_vertex:AIe,normal_fragment_begin:NIe,normal_fragment_maps:TIe,normal_pars_fragment:CIe,normal_pars_vertex:kIe,normal_vertex:PIe,normalmap_pars_fragment:jIe,clearcoat_normal_fragment_begin:RIe,clearcoat_normal_fragment_maps:DIe,clearcoat_pars_fragment:OIe,iridescence_pars_fragment:LIe,opaque_fragment:IIe,packing:FIe,premultiplied_alpha_fragment:UIe,project_vertex:zIe,dithering_fragment:BIe,dithering_pars_fragment:HIe,roughnessmap_fragment:$Ie,roughnessmap_pars_fragment:VIe,shadowmap_pars_fragment:GIe,shadowmap_pars_vertex:WIe,shadowmap_vertex:qIe,shadowmask_pars_fragment:KIe,skinbase_vertex:XIe,skinning_pars_vertex:YIe,skinning_vertex:ZIe,skinnormal_vertex:QIe,specularmap_fragment:JIe,specularmap_pars_fragment:e5e,tonemapping_fragment:t5e,tonemapping_pars_fragment:n5e,transmission_fragment:r5e,transmission_pars_fragment:i5e,uv_pars_fragment:a5e,uv_pars_vertex:s5e,uv_vertex:o5e,worldpos_vertex:l5e,background_vert:c5e,background_frag:u5e,backgroundCube_vert:d5e,backgroundCube_frag:h5e,cube_vert:f5e,cube_frag:m5e,depth_vert:p5e,depth_frag:g5e,distanceRGBA_vert:x5e,distanceRGBA_frag:b5e,equirect_vert:y5e,equirect_frag:v5e,linedashed_vert:_5e,linedashed_frag:w5e,meshbasic_vert:S5e,meshbasic_frag:M5e,meshlambert_vert:E5e,meshlambert_frag:A5e,meshmatcap_vert:N5e,meshmatcap_frag:T5e,meshnormal_vert:C5e,meshnormal_frag:k5e,meshphong_vert:P5e,meshphong_frag:j5e,meshphysical_vert:R5e,meshphysical_frag:D5e,meshtoon_vert:O5e,meshtoon_frag:L5e,points_vert:I5e,points_frag:F5e,shadow_vert:U5e,shadow_frag:z5e,sprite_vert:B5e,sprite_frag:H5e},kt={common:{diffuse:{value:new Yt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Sn},alphaMap:{value:null},alphaMapTransform:{value:new Sn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Sn}},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 Sn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Sn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Sn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Sn},normalScale:{value:new sn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Sn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Sn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Sn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Sn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Yt(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 Yt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Sn},alphaTest:{value:0},uvTransform:{value:new Sn}},sprite:{diffuse:{value:new Yt(16777215)},opacity:{value:1},center:{value:new sn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Sn},alphaMap:{value:null},alphaMapTransform:{value:new Sn},alphaTest:{value:0}}},ns={basic:{uniforms:Ra([kt.common,kt.specularmap,kt.envmap,kt.aomap,kt.lightmap,kt.fog]),vertexShader:xn.meshbasic_vert,fragmentShader:xn.meshbasic_frag},lambert:{uniforms:Ra([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 Yt(0)}}]),vertexShader:xn.meshlambert_vert,fragmentShader:xn.meshlambert_frag},phong:{uniforms:Ra([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 Yt(0)},specular:{value:new Yt(1118481)},shininess:{value:30}}]),vertexShader:xn.meshphong_vert,fragmentShader:xn.meshphong_frag},standard:{uniforms:Ra([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 Yt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:xn.meshphysical_vert,fragmentShader:xn.meshphysical_frag},toon:{uniforms:Ra([kt.common,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.gradientmap,kt.fog,kt.lights,{emissive:{value:new Yt(0)}}]),vertexShader:xn.meshtoon_vert,fragmentShader:xn.meshtoon_frag},matcap:{uniforms:Ra([kt.common,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.fog,{matcap:{value:null}}]),vertexShader:xn.meshmatcap_vert,fragmentShader:xn.meshmatcap_frag},points:{uniforms:Ra([kt.points,kt.fog]),vertexShader:xn.points_vert,fragmentShader:xn.points_frag},dashed:{uniforms:Ra([kt.common,kt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:xn.linedashed_vert,fragmentShader:xn.linedashed_frag},depth:{uniforms:Ra([kt.common,kt.displacementmap]),vertexShader:xn.depth_vert,fragmentShader:xn.depth_frag},normal:{uniforms:Ra([kt.common,kt.bumpmap,kt.normalmap,kt.displacementmap,{opacity:{value:1}}]),vertexShader:xn.meshnormal_vert,fragmentShader:xn.meshnormal_frag},sprite:{uniforms:Ra([kt.sprite,kt.fog]),vertexShader:xn.sprite_vert,fragmentShader:xn.sprite_frag},background:{uniforms:{uvTransform:{value:new Sn},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:Ra([kt.common,kt.displacementmap,{referencePosition:{value:new Ie},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:xn.distanceRGBA_vert,fragmentShader:xn.distanceRGBA_frag},shadow:{uniforms:Ra([kt.lights,kt.fog,{color:{value:new Yt(0)},opacity:{value:1}}]),vertexShader:xn.shadow_vert,fragmentShader:xn.shadow_frag}};ns.physical={uniforms:Ra([ns.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Sn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Sn},clearcoatNormalScale:{value:new sn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Sn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Sn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Sn},sheen:{value:0},sheenColor:{value:new Yt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Sn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Sn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Sn},transmissionSamplerSize:{value:new sn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Sn},attenuationDistance:{value:0},attenuationColor:{value:new Yt(0)},specularColor:{value:new Yt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Sn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Sn},anisotropyVector:{value:new sn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Sn}}]),vertexShader:xn.meshphysical_vert,fragmentShader:xn.meshphysical_frag};const H_={r:0,b:0,g:0};function $5e(t,e,n,r,i,a,o){const l=new Yt(0);let c=a===!0?0:1,u,d,f=null,g=0,p=null;function x(b,v){let E=!1,w=v.isScene===!0?v.background:null;w&&w.isTexture&&(w=(v.backgroundBlurriness>0?n:e).get(w)),w===null?y(l,c):w&&w.isColor&&(y(w,1),E=!0);const N=t.xr.getEnvironmentBlendMode();N==="additive"?r.buffers.color.setClear(0,0,0,1,o):N==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||E)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),w&&(w.isCubeTexture||w.mapping===f2)?(d===void 0&&(d=new Bo(new dy(1,1,1),new Od({name:"BackgroundCubeMaterial",uniforms:Qp(ns.backgroundCube.uniforms),vertexShader:ns.backgroundCube.vertexShader,fragmentShader:ns.backgroundCube.fragmentShader,side:ls,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(A,C,T){this.matrixWorld.copyPosition(T.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=v.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,d.material.toneMapped=lr.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(),b.unshift(d,d.geometry,d.material,0,0,null)):w&&w.isTexture&&(u===void 0&&(u=new Bo(new JO(2,2),new Od({name:"BackgroundMaterial",uniforms:Qp(ns.background.uniforms),vertexShader:ns.background.vertexShader,fragmentShader:ns.background.fragmentShader,side:Dd,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=v.backgroundIntensity,u.material.toneMapped=lr.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(),b.unshift(u,u.geometry,u.material,0,0,null))}function y(b,v){b.getRGB(H_,UQ(t)),r.buffers.color.setClear(H_.r,H_.g,H_.b,v,o)}return{getClearColor:function(){return l},setClearColor:function(b,v=1){l.set(b),c=v,y(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(b){c=b,y(l,c)},render:x}}function V5e(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),o=r.isWebGL2||a!==null,l={},c=b(null);let u=c,d=!1;function f(R,G,Y,V,K){let J=!1;if(o){const X=y(V,Y,G);u!==X&&(u=X,p(u.object)),J=v(R,V,Y,K),J&&E(R,V,Y,K)}else{const X=G.wireframe===!0;(u.geometry!==V.id||u.program!==Y.id||u.wireframe!==X)&&(u.geometry=V.id,u.program=Y.id,u.wireframe=X,J=!0)}K!==null&&n.update(K,t.ELEMENT_ARRAY_BUFFER),(J||d)&&(d=!1,L(R,G,Y,V),K!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(K).buffer))}function g(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function p(R){return r.isWebGL2?t.bindVertexArray(R):a.bindVertexArrayOES(R)}function x(R){return r.isWebGL2?t.deleteVertexArray(R):a.deleteVertexArrayOES(R)}function y(R,G,Y){const V=Y.wireframe===!0;let K=l[R.id];K===void 0&&(K={},l[R.id]=K);let J=K[G.id];J===void 0&&(J={},K[G.id]=J);let X=J[V];return X===void 0&&(X=b(g()),J[V]=X),X}function b(R){const G=[],Y=[],V=[];for(let K=0;K<i;K++)G[K]=0,Y[K]=0,V[K]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:G,enabledAttributes:Y,attributeDivisors:V,object:R,attributes:{},index:null}}function v(R,G,Y,V){const K=u.attributes,J=G.attributes;let X=0;const F=Y.getAttributes();for(const W in F)if(F[W].location>=0){const ie=K[W];let ae=J[W];if(ae===void 0&&(W==="instanceMatrix"&&R.instanceMatrix&&(ae=R.instanceMatrix),W==="instanceColor"&&R.instanceColor&&(ae=R.instanceColor)),ie===void 0||ie.attribute!==ae||ae&&ie.data!==ae.data)return!0;X++}return u.attributesNum!==X||u.index!==V}function E(R,G,Y,V){const K={},J=G.attributes;let X=0;const F=Y.getAttributes();for(const W in F)if(F[W].location>=0){let ie=J[W];ie===void 0&&(W==="instanceMatrix"&&R.instanceMatrix&&(ie=R.instanceMatrix),W==="instanceColor"&&R.instanceColor&&(ie=R.instanceColor));const ae={};ae.attribute=ie,ie&&ie.data&&(ae.data=ie.data),K[W]=ae,X++}u.attributes=K,u.attributesNum=X,u.index=V}function w(){const R=u.newAttributes;for(let G=0,Y=R.length;G<Y;G++)R[G]=0}function N(R){A(R,0)}function A(R,G){const Y=u.newAttributes,V=u.enabledAttributes,K=u.attributeDivisors;Y[R]=1,V[R]===0&&(t.enableVertexAttribArray(R),V[R]=1),K[R]!==G&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](R,G),K[R]=G)}function C(){const R=u.newAttributes,G=u.enabledAttributes;for(let Y=0,V=G.length;Y<V;Y++)G[Y]!==R[Y]&&(t.disableVertexAttribArray(Y),G[Y]=0)}function T(R,G,Y,V,K,J,X){X===!0?t.vertexAttribIPointer(R,G,Y,K,J):t.vertexAttribPointer(R,G,Y,V,K,J)}function L(R,G,Y,V){if(r.isWebGL2===!1&&(R.isInstancedMesh||V.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();const K=V.attributes,J=Y.getAttributes(),X=G.defaultAttributeValues;for(const F in J){const W=J[F];if(W.location>=0){let ee=K[F];if(ee===void 0&&(F==="instanceMatrix"&&R.instanceMatrix&&(ee=R.instanceMatrix),F==="instanceColor"&&R.instanceColor&&(ee=R.instanceColor)),ee!==void 0){const ie=ee.normalized,ae=ee.itemSize,de=n.get(ee);if(de===void 0)continue;const ue=de.buffer,le=de.type,he=de.bytesPerElement,pe=r.isWebGL2===!0&&(le===t.INT||le===t.UNSIGNED_INT||ee.gpuType===yQ);if(ee.isInterleavedBufferAttribute){const Me=ee.data,re=Me.stride,We=ee.offset;if(Me.isInstancedInterleavedBuffer){for(let z=0;z<W.locationSize;z++)A(W.location+z,Me.meshPerAttribute);R.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=Me.meshPerAttribute*Me.count)}else for(let z=0;z<W.locationSize;z++)N(W.location+z);t.bindBuffer(t.ARRAY_BUFFER,ue);for(let z=0;z<W.locationSize;z++)T(W.location+z,ae/W.locationSize,le,ie,re*he,(We+ae/W.locationSize*z)*he,pe)}else{if(ee.isInstancedBufferAttribute){for(let Me=0;Me<W.locationSize;Me++)A(W.location+Me,ee.meshPerAttribute);R.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let Me=0;Me<W.locationSize;Me++)N(W.location+Me);t.bindBuffer(t.ARRAY_BUFFER,ue);for(let Me=0;Me<W.locationSize;Me++)T(W.location+Me,ae/W.locationSize,le,ie,ae*he,ae/W.locationSize*Me*he,pe)}}else if(X!==void 0){const ie=X[F];if(ie!==void 0)switch(ie.length){case 2:t.vertexAttrib2fv(W.location,ie);break;case 3:t.vertexAttrib3fv(W.location,ie);break;case 4:t.vertexAttrib4fv(W.location,ie);break;default:t.vertexAttrib1fv(W.location,ie)}}}}C()}function k(){O();for(const R in l){const G=l[R];for(const Y in G){const V=G[Y];for(const K in V)x(V[K].object),delete V[K];delete G[Y]}delete l[R]}}function D(R){if(l[R.id]===void 0)return;const G=l[R.id];for(const Y in G){const V=G[Y];for(const K in V)x(V[K].object),delete V[K];delete G[Y]}delete l[R.id]}function U(R){for(const G in l){const Y=l[G];if(Y[R.id]===void 0)continue;const V=Y[R.id];for(const K in V)x(V[K].object),delete V[K];delete Y[R.id]}}function O(){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:O,resetDefaultState:q,dispose:k,releaseStatesOfGeometry:D,releaseStatesOfProgram:U,initAttributes:w,enableAttribute:N,disableUnusedAttributes:C}}function G5e(t,e,n,r){const i=r.isWebGL2;let a;function o(d){a=d}function l(d,f){t.drawArrays(a,d,f),n.update(f,a,1)}function c(d,f,g){if(g===0)return;let p,x;if(i)p=t,x="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[x](a,d,f,g),n.update(f,a,g)}function u(d,f,g){if(g===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<g;x++)this.render(d[x],f[x]);else{p.multiDrawArraysWEBGL(a,d,0,f,0,g);let x=0;for(let y=0;y<g;y++)x+=f[y];n.update(x,a,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function W5e(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(T){if(T==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=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=o||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),g=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),b=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),v=t.getParameter(t.MAX_VARYING_VECTORS),E=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),w=g>0,N=o||e.has("OES_texture_float"),A=w&&N,C=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:a,precision:l,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:p,maxCubemapSize:x,maxAttributes:y,maxVertexUniforms:b,maxVaryings:v,maxFragmentUniforms:E,vertexTextures:w,floatFragmentTextures:N,floatVertexTextures:A,maxSamples:C}}function q5e(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new Xu,l=new Sn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const p=f.length!==0||g||r!==0||i;return i=g,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,p){const x=f.clippingPlanes,y=f.clipIntersection,b=f.clipShadows,v=t.get(f);if(!i||x===null||x.length===0||a&&!b)a?d(null):u();else{const E=a?0:r,w=E*4;let N=v.clippingState||null;c.value=N,N=d(x,g,w,p);for(let A=0;A!==w;++A)N[A]=n[A];v.clippingState=N,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=E}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,g,p,x){const y=f!==null?f.length:0;let b=null;if(y!==0){if(b=c.value,x!==!0||b===null){const v=p+y*4,E=g.matrixWorldInverse;l.getNormalMatrix(E),(b===null||b.length<v)&&(b=new Float32Array(v));for(let w=0,N=p;w!==y;++w,N+=4)o.copy(f[w]).applyMatrix4(E,l),o.normal.toArray(b,N),b[N+3]=o.constant}c.value=b,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,b}}function K5e(t){let e=new WeakMap;function n(o,l){return l===oj?o.mapping=Xp:l===lj&&(o.mapping=Yp),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===oj||l===lj)if(e.has(o)){const c=e.get(o).texture;return n(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const u=new sLe(c.height/2);return u.fromEquirectangularTexture(t,o),e.set(o,u),o.addEventListener("dispose",i),n(u.texture,o.mapping)}else return null}}return o}function i(o){const l=o.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 X5e extends zQ{constructor(e=-1,n=1,r=1,i=-1,a=.1,o=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=o,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,o){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=o,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,o=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,o=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,o,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 fp=4,NV=[.125,.215,.35,.446,.526,.582],Th=20,VC=new X5e,TV=new Yt;let GC=null,WC=0,qC=0;const Mh=(1+Math.sqrt(5))/2,Xm=1/Mh,CV=[new Ie(1,1,1),new Ie(-1,1,1),new Ie(1,1,-1),new Ie(-1,1,-1),new Ie(0,Mh,Xm),new Ie(0,Mh,-Xm),new Ie(Xm,0,Mh),new Ie(-Xm,0,Mh),new Ie(Mh,Xm,0),new Ie(-Mh,Xm,0)];class kV{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){GC=this._renderer.getRenderTarget(),WC=this._renderer.getActiveCubeFace(),qC=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=RV(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=jV(),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(GC,WC,qC),e.scissorTest=!1,$_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Xp||e.mapping===Yp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),GC=this._renderer.getRenderTarget(),WC=this._renderer.getActiveCubeFace(),qC=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:so,minFilter:so,generateMipmaps:!1,type:ub,format:oo,colorSpace:eu,depthBuffer:!1},i=PV(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=PV(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Y5e(a)),this._blurMaterial=Z5e(a,e,n)}return i}_compileMaterial(e){const n=new Bo(this._lodPlanes[0],e);this._renderer.compile(n,VC)}_sceneToCubeUV(e,n,r,i){const l=new Ns(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(TV),d.toneMapping=gd,d.autoClear=!1;const p=new LQ({name:"PMREM.Background",side:ls,depthWrite:!1,depthTest:!1}),x=new Bo(new dy,p);let y=!1;const b=e.background;b?b.isColor&&(p.color.copy(b),e.background=null,y=!0):(p.color.copy(TV),y=!0);for(let v=0;v<6;v++){const E=v%3;E===0?(l.up.set(0,c[v],0),l.lookAt(u[v],0,0)):E===1?(l.up.set(0,0,c[v]),l.lookAt(0,u[v],0)):(l.up.set(0,c[v],0),l.lookAt(0,0,u[v]));const w=this._cubeSize;$_(i,E*w,v>2?w:0,w,w),d.setRenderTarget(i),y&&d.render(x,l),d.render(e,l)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=g,d.autoClear=f,e.background=b}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Xp||e.mapping===Yp;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=RV()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=jV());const a=i?this._cubemapMaterial:this._equirectMaterial,o=new Bo(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;$_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,VC)}_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]),o=CV[(i-1)%CV.length];this._blur(e,i-1,i,a,o)}n.autoClear=r}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new Bo(this._lodPlanes[i],u),g=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*Th-1),y=a/x,b=isFinite(a)?1+Math.floor(d*y):Th;b>Th&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Th}`);const v=[];let E=0;for(let T=0;T<Th;++T){const L=T/y,k=Math.exp(-L*L/2);v.push(k),T===0?E+=k:T<b&&(E+=2*k)}for(let T=0;T<v.length;T++)v[T]=v[T]/E;g.envMap.value=e.texture,g.samples.value=b,g.weights.value=v,g.latitudinal.value=o==="latitudinal",l&&(g.poleAxis.value=l);const{_lodMax:w}=this;g.dTheta.value=x,g.mipInt.value=w-r;const N=this._sizeLods[i],A=3*N*(i>w-fp?i-w+fp:0),C=4*(this._cubeSize-N);$_(n,A,C,3*N,2*N),c.setRenderTarget(n),c.render(f,VC)}}function Y5e(t){const e=[],n=[],r=[];let i=t;const a=t-fp+1+NV.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-fp?c=NV[o-t+fp-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,y=3,b=2,v=1,E=new Float32Array(y*x*p),w=new Float32Array(b*x*p),N=new Float32Array(v*x*p);for(let C=0;C<p;C++){const T=C%3*2/3-1,L=C>2?0:-1,k=[T,L,0,T+2/3,L,0,T+2/3,L+1,0,T,L,0,T+2/3,L+1,0,T,L+1,0];E.set(k,y*x*C),w.set(g,b*x*C);const D=[C,C,C,C,C,C];N.set(D,v*x*C)}const A=new Ta;A.setAttribute("position",new Ds(E,y)),A.setAttribute("uv",new Ds(w,b)),A.setAttribute("faceIndex",new Ds(N,v)),e.push(A),i>fp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function PV(t,e,n){const r=new _f(t,e,n);return r.texture.mapping=f2,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function $_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function Z5e(t,e,n){const r=new Float32Array(Th),i=new Ie(0,1,0);return new Od({name:"SphericalGaussianBlur",defines:{n:Th,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:e4(),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:pd,depthTest:!1,depthWrite:!1})}function jV(){return new Od({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:e4(),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:pd,depthTest:!1,depthWrite:!1})}function RV(){return new Od({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:e4(),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:pd,depthTest:!1,depthWrite:!1})}function e4(){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 Q5e(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===oj||c===lj,d=c===Xp||c===Yp;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new kV(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 kV(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 o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function J5e(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 eFe(t,e,n,r){const i={},a=new WeakMap;function o(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const x in g.attributes)e.remove(g.attributes[x]);for(const x in g.morphAttributes){const y=g.morphAttributes[x];for(let b=0,v=y.length;b<v;b++)e.remove(y[b])}g.removeEventListener("dispose",o),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",o),i[g.id]=!0,n.memory.geometries++),g}function c(f){const g=f.attributes;for(const x in g)e.update(g[x],t.ARRAY_BUFFER);const p=f.morphAttributes;for(const x in p){const y=p[x];for(let b=0,v=y.length;b<v;b++)e.update(y[b],t.ARRAY_BUFFER)}}function u(f){const g=[],p=f.index,x=f.attributes.position;let y=0;if(p!==null){const E=p.array;y=p.version;for(let w=0,N=E.length;w<N;w+=3){const A=E[w+0],C=E[w+1],T=E[w+2];g.push(A,C,C,T,T,A)}}else if(x!==void 0){const E=x.array;y=x.version;for(let w=0,N=E.length/3-1;w<N;w+=3){const A=w+0,C=w+1,T=w+2;g.push(A,C,C,T,T,A)}}else return;const b=new(kQ(g)?FQ:IQ)(g,1);b.version=y;const v=a.get(f);v&&e.remove(v),a.set(f,b)}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 tFe(t,e,n,r){const i=r.isWebGL2;let a;function o(p){a=p}let l,c;function u(p){l=p.type,c=p.bytesPerElement}function d(p,x){t.drawElements(a,x,l,p*c),n.update(x,a,1)}function f(p,x,y){if(y===0)return;let b,v;if(i)b=t,v="drawElementsInstanced";else if(b=e.get("ANGLE_instanced_arrays"),v="drawElementsInstancedANGLE",b===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}b[v](a,x,l,p*c,y),n.update(x,a,y)}function g(p,x,y){if(y===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let v=0;v<y;v++)this.render(p[v]/c,x[v]);else{b.multiDrawElementsWEBGL(a,x,0,l,p,0,y);let v=0;for(let E=0;E<y;E++)v+=x[E];n.update(v,a,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=g}function nFe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,o,l){switch(n.calls++,o){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:",o);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 rFe(t,e){return t[0]-e[0]}function iFe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function aFe(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,o=new ur,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,f){const g=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,y=x!==void 0?x.length:0;let b=a.get(d);if(b===void 0||b.count!==y){let G=function(){q.dispose(),a.delete(d),d.removeEventListener("dispose",G)};var p=G;b!==void 0&&b.texture.dispose();const w=d.morphAttributes.position!==void 0,N=d.morphAttributes.normal!==void 0,A=d.morphAttributes.color!==void 0,C=d.morphAttributes.position||[],T=d.morphAttributes.normal||[],L=d.morphAttributes.color||[];let k=0;w===!0&&(k=1),N===!0&&(k=2),A===!0&&(k=3);let D=d.attributes.position.count*k,U=1;D>e.maxTextureSize&&(U=Math.ceil(D/e.maxTextureSize),D=e.maxTextureSize);const O=new Float32Array(D*U*4*y),q=new RQ(O,D,U,y);q.type=Rc,q.needsUpdate=!0;const R=k*4;for(let Y=0;Y<y;Y++){const V=C[Y],K=T[Y],J=L[Y],X=D*U*4*Y;for(let F=0;F<V.count;F++){const W=F*R;w===!0&&(o.fromBufferAttribute(V,F),O[X+W+0]=o.x,O[X+W+1]=o.y,O[X+W+2]=o.z,O[X+W+3]=0),N===!0&&(o.fromBufferAttribute(K,F),O[X+W+4]=o.x,O[X+W+5]=o.y,O[X+W+6]=o.z,O[X+W+7]=0),A===!0&&(o.fromBufferAttribute(J,F),O[X+W+8]=o.x,O[X+W+9]=o.y,O[X+W+10]=o.z,O[X+W+11]=J.itemSize===4?o.w:1)}}b={count:y,texture:q,size:new sn(D,U)},a.set(d,b),d.addEventListener("dispose",G)}let v=0;for(let w=0;w<g.length;w++)v+=g[w];const E=d.morphTargetsRelative?1:1-v;f.getUniforms().setValue(t,"morphTargetBaseInfluence",E),f.getUniforms().setValue(t,"morphTargetInfluences",g),f.getUniforms().setValue(t,"morphTargetsTexture",b.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",b.size)}else{const x=g===void 0?0:g.length;let y=r[d.id];if(y===void 0||y.length!==x){y=[];for(let N=0;N<x;N++)y[N]=[N,0];r[d.id]=y}for(let N=0;N<x;N++){const A=y[N];A[0]=N,A[1]=g[N]}y.sort(iFe);for(let N=0;N<8;N++)N<x&&y[N][1]?(l[N][0]=y[N][0],l[N][1]=y[N][1]):(l[N][0]=Number.MAX_SAFE_INTEGER,l[N][1]=0);l.sort(rFe);const b=d.morphAttributes.position,v=d.morphAttributes.normal;let E=0;for(let N=0;N<8;N++){const A=l[N],C=A[0],T=A[1];C!==Number.MAX_SAFE_INTEGER&&T?(b&&d.getAttribute("morphTarget"+N)!==b[C]&&d.setAttribute("morphTarget"+N,b[C]),v&&d.getAttribute("morphNormal"+N)!==v[C]&&d.setAttribute("morphNormal"+N,v[C]),i[N]=T,E+=T):(b&&d.hasAttribute("morphTarget"+N)===!0&&d.deleteAttribute("morphTarget"+N),v&&d.hasAttribute("morphNormal"+N)===!0&&d.deleteAttribute("morphNormal"+N),i[N]=0)}const w=d.morphTargetsRelative?1:1-E;f.getUniforms().setValue(t,"morphTargetBaseInfluence",w),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function sFe(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 o(){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:o}}class $Q extends cs{constructor(e,n,r,i,a,o,l,c,u,d){if(d=d!==void 0?d:qh,d!==qh&&d!==Zp)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===qh&&(r=sd),r===void 0&&d===Zp&&(r=Wh),super(null,i,a,o,l,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=l!==void 0?l:oa,this.minFilter=c!==void 0?c:oa,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 VQ=new cs,GQ=new $Q(1,1);GQ.compareFunction=TQ;const WQ=new RQ,qQ=new V4e,KQ=new BQ,DV=[],OV=[],LV=new Float32Array(16),IV=new Float32Array(9),FV=new Float32Array(4);function Cg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=DV[i];if(a===void 0&&(a=new Float32Array(i),DV[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}function Ti(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 Ci(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function g2(t,e){let n=OV[e];n===void 0&&(n=new Int32Array(e),OV[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function oFe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function lFe(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(Ti(n,e))return;t.uniform2fv(this.addr,e),Ci(n,e)}}function cFe(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(Ti(n,e))return;t.uniform3fv(this.addr,e),Ci(n,e)}}function uFe(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(Ti(n,e))return;t.uniform4fv(this.addr,e),Ci(n,e)}}function dFe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ti(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ci(n,e)}else{if(Ti(n,r))return;FV.set(r),t.uniformMatrix2fv(this.addr,!1,FV),Ci(n,r)}}function hFe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ti(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ci(n,e)}else{if(Ti(n,r))return;IV.set(r),t.uniformMatrix3fv(this.addr,!1,IV),Ci(n,r)}}function fFe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ti(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ci(n,e)}else{if(Ti(n,r))return;LV.set(r),t.uniformMatrix4fv(this.addr,!1,LV),Ci(n,r)}}function mFe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function pFe(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(Ti(n,e))return;t.uniform2iv(this.addr,e),Ci(n,e)}}function gFe(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(Ti(n,e))return;t.uniform3iv(this.addr,e),Ci(n,e)}}function xFe(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(Ti(n,e))return;t.uniform4iv(this.addr,e),Ci(n,e)}}function bFe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function yFe(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(Ti(n,e))return;t.uniform2uiv(this.addr,e),Ci(n,e)}}function vFe(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(Ti(n,e))return;t.uniform3uiv(this.addr,e),Ci(n,e)}}function _Fe(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(Ti(n,e))return;t.uniform4uiv(this.addr,e),Ci(n,e)}}function wFe(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?GQ:VQ;n.setTexture2D(e||a,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.setTexture3D(e||qQ,i)}function MFe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||KQ,i)}function EFe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||WQ,i)}function AFe(t){switch(t){case 5126:return oFe;case 35664:return lFe;case 35665:return cFe;case 35666:return uFe;case 35674:return dFe;case 35675:return hFe;case 35676:return fFe;case 5124:case 35670:return mFe;case 35667:case 35671:return pFe;case 35668:case 35672:return gFe;case 35669:case 35673:return xFe;case 5125:return bFe;case 36294:return yFe;case 36295:return vFe;case 36296:return _Fe;case 35678:case 36198:case 36298:case 36306:case 35682:return wFe;case 35679:case 36299:case 36307:return SFe;case 35680:case 36300:case 36308:case 36293:return MFe;case 36289:case 36303:case 36311:case 36292:return EFe}}function NFe(t,e){t.uniform1fv(this.addr,e)}function TFe(t,e){const n=Cg(e,this.size,2);t.uniform2fv(this.addr,n)}function CFe(t,e){const n=Cg(e,this.size,3);t.uniform3fv(this.addr,n)}function kFe(t,e){const n=Cg(e,this.size,4);t.uniform4fv(this.addr,n)}function PFe(t,e){const n=Cg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function jFe(t,e){const n=Cg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function RFe(t,e){const n=Cg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function DFe(t,e){t.uniform1iv(this.addr,e)}function OFe(t,e){t.uniform2iv(this.addr,e)}function LFe(t,e){t.uniform3iv(this.addr,e)}function IFe(t,e){t.uniform4iv(this.addr,e)}function FFe(t,e){t.uniform1uiv(this.addr,e)}function UFe(t,e){t.uniform2uiv(this.addr,e)}function zFe(t,e){t.uniform3uiv(this.addr,e)}function BFe(t,e){t.uniform4uiv(this.addr,e)}function HFe(t,e,n){const r=this.cache,i=e.length,a=g2(n,i);Ti(r,a)||(t.uniform1iv(this.addr,a),Ci(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||VQ,a[o])}function $Fe(t,e,n){const r=this.cache,i=e.length,a=g2(n,i);Ti(r,a)||(t.uniform1iv(this.addr,a),Ci(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||qQ,a[o])}function VFe(t,e,n){const r=this.cache,i=e.length,a=g2(n,i);Ti(r,a)||(t.uniform1iv(this.addr,a),Ci(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||KQ,a[o])}function GFe(t,e,n){const r=this.cache,i=e.length,a=g2(n,i);Ti(r,a)||(t.uniform1iv(this.addr,a),Ci(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||WQ,a[o])}function WFe(t){switch(t){case 5126:return NFe;case 35664:return TFe;case 35665:return CFe;case 35666:return kFe;case 35674:return PFe;case 35675:return jFe;case 35676:return RFe;case 5124:case 35670:return DFe;case 35667:case 35671:return OFe;case 35668:case 35672:return LFe;case 35669:case 35673:return IFe;case 5125:return FFe;case 36294:return UFe;case 36295:return zFe;case 36296:return BFe;case 35678:case 36198:case 36298:case 36306:case 35682:return HFe;case 35679:case 36299:case 36307:return $Fe;case 35680:case 36300:case 36308:case 36293:return VFe;case 36289:case 36303:case 36311:case 36292:return GFe}}class qFe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=AFe(n.type)}}class KFe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=WFe(n.type)}}class XFe{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,o=i.length;a!==o;++a){const l=i[a];l.setValue(e,n[l.id],r)}}}const KC=/(\w+)(\])?(\[|\.)?/g;function UV(t,e){t.seq.push(e),t.map[e.id]=e}function YFe(t,e,n){const r=t.name,i=r.length;for(KC.lastIndex=0;;){const a=KC.exec(r),o=KC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){UV(n,u===void 0?new qFe(l,t,e):new KFe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new XFe(l),UV(n,f)),n=f}}}class O1{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),o=e.getUniformLocation(n,a.name);YFe(a,o,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,o=n.length;a!==o;++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 o=e[i];o.id in n&&r.push(o)}return r}}function zV(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const ZFe=37297;let QFe=0;function JFe(t,e){const n=t.split(`
  7422. `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
  7423. `)}function eUe(t){const e=lr.getPrimaries(lr.workingColorSpace),n=lr.getPrimaries(t);let r;switch(e===n?r="":e===aS&&n===iS?r="LinearDisplayP3ToLinearSRGB":e===iS&&n===aS&&(r="LinearSRGBToLinearDisplayP3"),t){case eu:case m2:return[r,"LinearTransferOETF"];case la:case XO:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function BV(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 o=parseInt(a[1]);return n.toUpperCase()+`
  7424. `+i+`
  7425. `+JFe(t.getShaderSource(e),o)}else return i}function tUe(t,e){const n=eUe(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function nUe(t,e){let n;switch(e){case t4e:n="Linear";break;case n4e:n="Reinhard";break;case r4e:n="OptimizedCineon";break;case i4e:n="ACESFilmic";break;case a4e:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function rUe(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(r0).join(`
  7426. `)}function iUe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7427. `)}function aUe(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),o=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[o]={type:a.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function r0(t){return t!==""}function HV(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 $V(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const sUe=/^[ \t]*#include +<([\w\d./]+)>/gm;function mj(t){return t.replace(sUe,lUe)}const oUe=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function lUe(t,e){let n=xn[e];if(n===void 0){const r=oUe.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 mj(n)}const cUe=/#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 VV(t){return t.replace(cUe,uUe)}function uUe(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 GV(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 dUe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===xQ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===COe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===yc&&(e="SHADOWMAP_TYPE_VSM"),e}function hUe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Xp:case Yp:e="ENVMAP_TYPE_CUBE";break;case f2:e="ENVMAP_TYPE_CUBE_UV";break}return e}function fUe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Yp:e="ENVMAP_MODE_REFRACTION";break}return e}function mUe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case qO:e="ENVMAP_BLENDING_MULTIPLY";break;case JOe:e="ENVMAP_BLENDING_MIX";break;case e4e:e="ENVMAP_BLENDING_ADD";break}return e}function pUe(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 gUe(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=dUe(n),u=hUe(n),d=fUe(n),f=mUe(n),g=pUe(n),p=n.isWebGL2?"":rUe(n),x=iUe(a),y=i.createProgram();let b,v,E=n.glslVersion?"#version "+n.glslVersion+`
  7432. `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(r0).join(`
  7433. `),b.length>0&&(b+=`
  7434. `),v=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(r0).join(`
  7435. `),v.length>0&&(v+=`
  7436. `)):(b=[GV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
  7437. `].filter(r0).join(`
  7438. `),v=[p,GV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==gd?"#define TONE_MAPPING":"",n.toneMapping!==gd?xn.tonemapping_pars_fragment:"",n.toneMapping!==gd?nUe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",xn.colorspace_pars_fragment,tUe("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7439. `].filter(r0).join(`
  7440. `)),o=mj(o),o=HV(o,n),o=$V(o,n),l=mj(l),l=HV(l,n),l=$V(l,n),o=VV(o),l=VV(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(E=`#version 300 es
  7441. `,b=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  7442. `)+`
  7443. `+b,v=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===cV?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===cV?"":"#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. `+v);const w=E+b+o,N=E+v+l,A=zV(i,i.VERTEX_SHADER,w),C=zV(i,i.FRAGMENT_SHADER,N);i.attachShader(y,A),i.attachShader(y,C),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function T(U){if(t.debug.checkShaderErrors){const O=i.getProgramInfoLog(y).trim(),q=i.getShaderInfoLog(A).trim(),R=i.getShaderInfoLog(C).trim();let G=!0,Y=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(G=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,A,C);else{const V=BV(i,A,"vertex"),K=BV(i,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  7446. Program Info Log: `+O+`
  7447. `+V+`
  7448. `+K)}else O!==""?console.warn("THREE.WebGLProgram: Program Info Log:",O):(q===""||R==="")&&(Y=!1);Y&&(U.diagnostics={runnable:G,programLog:O,vertexShader:{log:q,prefix:b},fragmentShader:{log:R,prefix:v}})}i.deleteShader(A),i.deleteShader(C),L=new O1(i,y),k=aUe(i,y)}let L;this.getUniforms=function(){return L===void 0&&T(this),L};let k;this.getAttributes=function(){return k===void 0&&T(this),k};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(y,ZFe)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=QFe++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=A,this.fragmentShader=C,this}let xUe=0;class bUe{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),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(a)===!1&&(o.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 yUe(e),n.set(e,r)),r}}class yUe{constructor(e){this.id=xUe++,this.code=e,this.usedTimes=0}}function vUe(t,e,n,r,i,a,o){const l=new DQ,c=new bUe,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,g=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(k){return k===0?"uv":`uv${k}`}function b(k,D,U,O,q){const R=O.fog,G=q.geometry,Y=k.isMeshStandardMaterial?O.environment:null,V=(k.isMeshStandardMaterial?n:e).get(k.envMap||Y),K=V&&V.mapping===f2?V.image.height:null,J=x[k.type];k.precision!==null&&(p=i.getMaxPrecision(k.precision),p!==k.precision&&console.warn("THREE.WebGLProgram.getParameters:",k.precision,"not supported, using",p,"instead."));const X=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,F=X!==void 0?X.length:0;let W=0;G.morphAttributes.position!==void 0&&(W=1),G.morphAttributes.normal!==void 0&&(W=2),G.morphAttributes.color!==void 0&&(W=3);let ee,ie,ae,de;if(J){const Zt=ns[J];ee=Zt.vertexShader,ie=Zt.fragmentShader}else ee=k.vertexShader,ie=k.fragmentShader,c.update(k),ae=c.getVertexShaderID(k),de=c.getFragmentShaderID(k);const ue=t.getRenderTarget(),le=q.isInstancedMesh===!0,he=q.isBatchedMesh===!0,pe=!!k.map,Me=!!k.matcap,re=!!V,We=!!k.aoMap,z=!!k.lightMap,H=!!k.bumpMap,se=!!k.normalMap,B=!!k.displacementMap,Q=!!k.emissiveMap,ce=!!k.metalnessMap,Ce=!!k.roughnessMap,_e=k.anisotropy>0,Ee=k.clearcoat>0,$=k.iridescence>0,j=k.sheen>0,ne=k.transmission>0,be=_e&&!!k.anisotropyMap,we=Ee&&!!k.clearcoatMap,ve=Ee&&!!k.clearcoatNormalMap,$e=Ee&&!!k.clearcoatRoughnessMap,Ge=$&&!!k.iridescenceMap,Xe=$&&!!k.iridescenceThicknessMap,ut=j&&!!k.sheenColorMap,He=j&&!!k.sheenRoughnessMap,me=!!k.specularMap,Je=!!k.specularColorMap,Ke=!!k.specularIntensityMap,Ze=ne&&!!k.transmissionMap,ct=ne&&!!k.thicknessMap,te=!!k.gradientMap,Fe=!!k.alphaMap,xe=k.alphaTest>0,ze=!!k.alphaHash,Pe=!!k.extensions,Se=!!G.attributes.uv1,Ye=!!G.attributes.uv2,dt=!!G.attributes.uv3;let Tt=gd;return k.toneMapped&&(ue===null||ue.isXRRenderTarget===!0)&&(Tt=t.toneMapping),{isWebGL2:d,shaderID:J,shaderType:k.type,shaderName:k.name,vertexShader:ee,fragmentShader:ie,defines:k.defines,customVertexShaderID:ae,customFragmentShaderID:de,isRawShaderMaterial:k.isRawShaderMaterial===!0,glslVersion:k.glslVersion,precision:p,batching:he,instancing:le,instancingColor:le&&q.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:ue===null?t.outputColorSpace:ue.isXRRenderTarget===!0?ue.texture.colorSpace:eu,map:pe,matcap:Me,envMap:re,envMapMode:re&&V.mapping,envMapCubeUVHeight:K,aoMap:We,lightMap:z,bumpMap:H,normalMap:se,displacementMap:g&&B,emissiveMap:Q,normalMapObjectSpace:se&&k.normalMapType===x4e,normalMapTangentSpace:se&&k.normalMapType===NQ,metalnessMap:ce,roughnessMap:Ce,anisotropy:_e,anisotropyMap:be,clearcoat:Ee,clearcoatMap:we,clearcoatNormalMap:ve,clearcoatRoughnessMap:$e,iridescence:$,iridescenceMap:Ge,iridescenceThicknessMap:Xe,sheen:j,sheenColorMap:ut,sheenRoughnessMap:He,specularMap:me,specularColorMap:Je,specularIntensityMap:Ke,transmission:ne,transmissionMap:Ze,thicknessMap:ct,gradientMap:te,opaque:k.transparent===!1&&k.blending===Sp,alphaMap:Fe,alphaTest:xe,alphaHash:ze,combine:k.combine,mapUv:pe&&y(k.map.channel),aoMapUv:We&&y(k.aoMap.channel),lightMapUv:z&&y(k.lightMap.channel),bumpMapUv:H&&y(k.bumpMap.channel),normalMapUv:se&&y(k.normalMap.channel),displacementMapUv:B&&y(k.displacementMap.channel),emissiveMapUv:Q&&y(k.emissiveMap.channel),metalnessMapUv:ce&&y(k.metalnessMap.channel),roughnessMapUv:Ce&&y(k.roughnessMap.channel),anisotropyMapUv:be&&y(k.anisotropyMap.channel),clearcoatMapUv:we&&y(k.clearcoatMap.channel),clearcoatNormalMapUv:ve&&y(k.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:$e&&y(k.clearcoatRoughnessMap.channel),iridescenceMapUv:Ge&&y(k.iridescenceMap.channel),iridescenceThicknessMapUv:Xe&&y(k.iridescenceThicknessMap.channel),sheenColorMapUv:ut&&y(k.sheenColorMap.channel),sheenRoughnessMapUv:He&&y(k.sheenRoughnessMap.channel),specularMapUv:me&&y(k.specularMap.channel),specularColorMapUv:Je&&y(k.specularColorMap.channel),specularIntensityMapUv:Ke&&y(k.specularIntensityMap.channel),transmissionMapUv:Ze&&y(k.transmissionMap.channel),thicknessMapUv:ct&&y(k.thicknessMap.channel),alphaMapUv:Fe&&y(k.alphaMap.channel),vertexTangents:!!G.attributes.tangent&&(se||_e),vertexColors:k.vertexColors,vertexAlphas:k.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,vertexUv1s:Se,vertexUv2s:Ye,vertexUv3s:dt,pointsUvs:q.isPoints===!0&&!!G.attributes.uv&&(pe||Fe),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:G.morphAttributes.position!==void 0,morphNormals:G.morphAttributes.normal!==void 0,morphColors:G.morphAttributes.color!==void 0,morphTargetsCount:F,morphTextureStride:W,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:k.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:Tt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:pe&&k.map.isVideoTexture===!0&&lr.getTransfer(k.map.colorSpace)===Sr,premultipliedAlpha:k.premultipliedAlpha,doubleSided:k.side===Ac,flipSided:k.side===ls,useDepthPacking:k.depthPacking>=0,depthPacking:k.depthPacking||0,index0AttributeName:k.index0AttributeName,extensionDerivatives:Pe&&k.extensions.derivatives===!0,extensionFragDepth:Pe&&k.extensions.fragDepth===!0,extensionDrawBuffers:Pe&&k.extensions.drawBuffers===!0,extensionShaderTextureLOD:Pe&&k.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:k.customProgramCacheKey()}}function v(k){const D=[];if(k.shaderID?D.push(k.shaderID):(D.push(k.customVertexShaderID),D.push(k.customFragmentShaderID)),k.defines!==void 0)for(const U in k.defines)D.push(U),D.push(k.defines[U]);return k.isRawShaderMaterial===!1&&(E(D,k),w(D,k),D.push(t.outputColorSpace)),D.push(k.customProgramCacheKey),D.join()}function E(k,D){k.push(D.precision),k.push(D.outputColorSpace),k.push(D.envMapMode),k.push(D.envMapCubeUVHeight),k.push(D.mapUv),k.push(D.alphaMapUv),k.push(D.lightMapUv),k.push(D.aoMapUv),k.push(D.bumpMapUv),k.push(D.normalMapUv),k.push(D.displacementMapUv),k.push(D.emissiveMapUv),k.push(D.metalnessMapUv),k.push(D.roughnessMapUv),k.push(D.anisotropyMapUv),k.push(D.clearcoatMapUv),k.push(D.clearcoatNormalMapUv),k.push(D.clearcoatRoughnessMapUv),k.push(D.iridescenceMapUv),k.push(D.iridescenceThicknessMapUv),k.push(D.sheenColorMapUv),k.push(D.sheenRoughnessMapUv),k.push(D.specularMapUv),k.push(D.specularColorMapUv),k.push(D.specularIntensityMapUv),k.push(D.transmissionMapUv),k.push(D.thicknessMapUv),k.push(D.combine),k.push(D.fogExp2),k.push(D.sizeAttenuation),k.push(D.morphTargetsCount),k.push(D.morphAttributeCount),k.push(D.numDirLights),k.push(D.numPointLights),k.push(D.numSpotLights),k.push(D.numSpotLightMaps),k.push(D.numHemiLights),k.push(D.numRectAreaLights),k.push(D.numDirLightShadows),k.push(D.numPointLightShadows),k.push(D.numSpotLightShadows),k.push(D.numSpotLightShadowsWithMaps),k.push(D.numLightProbes),k.push(D.shadowMapType),k.push(D.toneMapping),k.push(D.numClippingPlanes),k.push(D.numClipIntersection),k.push(D.depthPacking)}function w(k,D){l.disableAll(),D.isWebGL2&&l.enable(0),D.supportsVertexTextures&&l.enable(1),D.instancing&&l.enable(2),D.instancingColor&&l.enable(3),D.matcap&&l.enable(4),D.envMap&&l.enable(5),D.normalMapObjectSpace&&l.enable(6),D.normalMapTangentSpace&&l.enable(7),D.clearcoat&&l.enable(8),D.iridescence&&l.enable(9),D.alphaTest&&l.enable(10),D.vertexColors&&l.enable(11),D.vertexAlphas&&l.enable(12),D.vertexUv1s&&l.enable(13),D.vertexUv2s&&l.enable(14),D.vertexUv3s&&l.enable(15),D.vertexTangents&&l.enable(16),D.anisotropy&&l.enable(17),D.alphaHash&&l.enable(18),D.batching&&l.enable(19),k.push(l.mask),l.disableAll(),D.fog&&l.enable(0),D.useFog&&l.enable(1),D.flatShading&&l.enable(2),D.logarithmicDepthBuffer&&l.enable(3),D.skinning&&l.enable(4),D.morphTargets&&l.enable(5),D.morphNormals&&l.enable(6),D.morphColors&&l.enable(7),D.premultipliedAlpha&&l.enable(8),D.shadowMapEnabled&&l.enable(9),D.useLegacyLights&&l.enable(10),D.doubleSided&&l.enable(11),D.flipSided&&l.enable(12),D.useDepthPacking&&l.enable(13),D.dithering&&l.enable(14),D.transmission&&l.enable(15),D.sheen&&l.enable(16),D.opaque&&l.enable(17),D.pointsUvs&&l.enable(18),D.decodeVideoTexture&&l.enable(19),k.push(l.mask)}function N(k){const D=x[k.type];let U;if(D){const O=ns[D];U=QO.clone(O.uniforms)}else U=k.uniforms;return U}function A(k,D){let U;for(let O=0,q=u.length;O<q;O++){const R=u[O];if(R.cacheKey===D){U=R,++U.usedTimes;break}}return U===void 0&&(U=new gUe(t,D,k,a),u.push(U)),U}function C(k){if(--k.usedTimes===0){const D=u.indexOf(k);u[D]=u[u.length-1],u.pop(),k.destroy()}}function T(k){c.remove(k)}function L(){c.dispose()}return{getParameters:b,getProgramCacheKey:v,getUniforms:N,acquireProgram:A,releaseProgram:C,releaseShaderCache:T,programs:u,dispose:L}}function _Ue(){let t=new WeakMap;function e(a){let o=t.get(a);return o===void 0&&(o={},t.set(a,o)),o}function n(a){t.delete(a)}function r(a,o,l){t.get(a)[o]=l}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function wUe(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 WV(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 qV(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,g,p,x,y,b){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:g,material:p,groupOrder:x,renderOrder:f.renderOrder,z:y,group:b},t[e]=v):(v.id=f.id,v.object=f,v.geometry=g,v.material=p,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=y,v.group=b),e++,v}function l(f,g,p,x,y,b){const v=o(f,g,p,x,y,b);p.transmission>0?r.push(v):p.transparent===!0?i.push(v):n.push(v)}function c(f,g,p,x,y,b){const v=o(f,g,p,x,y,b);p.transmission>0?r.unshift(v):p.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,g){n.length>1&&n.sort(f||wUe),r.length>1&&r.sort(g||WV),i.length>1&&i.sort(g||WV)}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 SUe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new qV,t.set(r,[o])):i>=a.length?(o=new qV,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function MUe(){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 Ie,color:new Yt};break;case"SpotLight":n={position:new Ie,direction:new Ie,color:new Yt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Ie,color:new Yt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Ie,skyColor:new Yt,groundColor:new Yt};break;case"RectAreaLight":n={color:new Yt,position:new Ie,halfWidth:new Ie,halfHeight:new Ie};break}return t[e.id]=n,n}}}function EUe(){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 sn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new sn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new sn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let AUe=0;function NUe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function TUe(t,e){const n=new MUe,r=EUe(),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 Ie);const a=new Ie,o=new vr,l=new vr;function c(d,f){let g=0,p=0,x=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let y=0,b=0,v=0,E=0,w=0,N=0,A=0,C=0,T=0,L=0,k=0;d.sort(NUe);const D=f===!0?Math.PI:1;for(let O=0,q=d.length;O<q;O++){const R=d[O],G=R.color,Y=R.intensity,V=R.distance,K=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)g+=G.r*Y*D,p+=G.g*Y*D,x+=G.b*Y*D;else if(R.isLightProbe){for(let J=0;J<9;J++)i.probe[J].addScaledVector(R.sh.coefficients[J],Y);k++}else if(R.isDirectionalLight){const J=n.get(R);if(J.color.copy(R.color).multiplyScalar(R.intensity*D),R.castShadow){const X=R.shadow,F=r.get(R);F.shadowBias=X.bias,F.shadowNormalBias=X.normalBias,F.shadowRadius=X.radius,F.shadowMapSize=X.mapSize,i.directionalShadow[y]=F,i.directionalShadowMap[y]=K,i.directionalShadowMatrix[y]=R.shadow.matrix,N++}i.directional[y]=J,y++}else if(R.isSpotLight){const J=n.get(R);J.position.setFromMatrixPosition(R.matrixWorld),J.color.copy(G).multiplyScalar(Y*D),J.distance=V,J.coneCos=Math.cos(R.angle),J.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),J.decay=R.decay,i.spot[v]=J;const X=R.shadow;if(R.map&&(i.spotLightMap[T]=R.map,T++,X.updateMatrices(R),R.castShadow&&L++),i.spotLightMatrix[v]=X.matrix,R.castShadow){const F=r.get(R);F.shadowBias=X.bias,F.shadowNormalBias=X.normalBias,F.shadowRadius=X.radius,F.shadowMapSize=X.mapSize,i.spotShadow[v]=F,i.spotShadowMap[v]=K,C++}v++}else if(R.isRectAreaLight){const J=n.get(R);J.color.copy(G).multiplyScalar(Y),J.halfWidth.set(R.width*.5,0,0),J.halfHeight.set(0,R.height*.5,0),i.rectArea[E]=J,E++}else if(R.isPointLight){const J=n.get(R);if(J.color.copy(R.color).multiplyScalar(R.intensity*D),J.distance=R.distance,J.decay=R.decay,R.castShadow){const X=R.shadow,F=r.get(R);F.shadowBias=X.bias,F.shadowNormalBias=X.normalBias,F.shadowRadius=X.radius,F.shadowMapSize=X.mapSize,F.shadowCameraNear=X.camera.near,F.shadowCameraFar=X.camera.far,i.pointShadow[b]=F,i.pointShadowMap[b]=K,i.pointShadowMatrix[b]=R.shadow.matrix,A++}i.point[b]=J,b++}else if(R.isHemisphereLight){const J=n.get(R);J.skyColor.copy(R.color).multiplyScalar(Y*D),J.groundColor.copy(R.groundColor).multiplyScalar(Y*D),i.hemi[w]=J,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]=x;const U=i.hash;(U.directionalLength!==y||U.pointLength!==b||U.spotLength!==v||U.rectAreaLength!==E||U.hemiLength!==w||U.numDirectionalShadows!==N||U.numPointShadows!==A||U.numSpotShadows!==C||U.numSpotMaps!==T||U.numLightProbes!==k)&&(i.directional.length=y,i.spot.length=v,i.rectArea.length=E,i.point.length=b,i.hemi.length=w,i.directionalShadow.length=N,i.directionalShadowMap.length=N,i.pointShadow.length=A,i.pointShadowMap.length=A,i.spotShadow.length=C,i.spotShadowMap.length=C,i.directionalShadowMatrix.length=N,i.pointShadowMatrix.length=A,i.spotLightMatrix.length=C+T-L,i.spotLightMap.length=T,i.numSpotLightShadowsWithMaps=L,i.numLightProbes=k,U.directionalLength=y,U.pointLength=b,U.spotLength=v,U.rectAreaLength=E,U.hemiLength=w,U.numDirectionalShadows=N,U.numPointShadows=A,U.numSpotShadows=C,U.numSpotMaps=T,U.numLightProbes=k,i.version=AUe++)}function u(d,f){let g=0,p=0,x=0,y=0,b=0;const v=f.matrixWorldInverse;for(let E=0,w=d.length;E<w;E++){const N=d[E];if(N.isDirectionalLight){const A=i.directional[g];A.direction.setFromMatrixPosition(N.matrixWorld),a.setFromMatrixPosition(N.target.matrixWorld),A.direction.sub(a),A.direction.transformDirection(v),g++}else if(N.isSpotLight){const A=i.spot[x];A.position.setFromMatrixPosition(N.matrixWorld),A.position.applyMatrix4(v),A.direction.setFromMatrixPosition(N.matrixWorld),a.setFromMatrixPosition(N.target.matrixWorld),A.direction.sub(a),A.direction.transformDirection(v),x++}else if(N.isRectAreaLight){const A=i.rectArea[y];A.position.setFromMatrixPosition(N.matrixWorld),A.position.applyMatrix4(v),l.identity(),o.copy(N.matrixWorld),o.premultiply(v),l.extractRotation(o),A.halfWidth.set(N.width*.5,0,0),A.halfHeight.set(0,N.height*.5,0),A.halfWidth.applyMatrix4(l),A.halfHeight.applyMatrix4(l),y++}else if(N.isPointLight){const A=i.point[p];A.position.setFromMatrixPosition(N.matrixWorld),A.position.applyMatrix4(v),p++}else if(N.isHemisphereLight){const A=i.hemi[b];A.direction.setFromMatrixPosition(N.matrixWorld),A.direction.transformDirection(v),b++}}}return{setup:c,setupView:u,state:i}}function KV(t,e){const n=new TUe(t,e),r=[],i=[];function a(){r.length=0,i.length=0}function o(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:o,pushShadow:l}}function CUe(t,e){let n=new WeakMap;function r(a,o=0){const l=n.get(a);let c;return l===void 0?(c=new KV(t,e),n.set(a,[c])):o>=l.length?(c=new KV(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class kUe extends Tg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=p4e,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 PUe extends Tg{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 jUe=`void main() {
  7449. gl_Position = vec4( position, 1.0 );
  7450. }`,RUe=`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 DUe(t,e,n){let r=new p2;const i=new sn,a=new sn,o=new ur,l=new kUe({depthPacking:g4e}),c=new PUe,u={},d=n.maxTextureSize,f={[Dd]:ls,[ls]:Dd,[Ac]:Ac},g=new Od({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new sn},radius:{value:4}},vertexShader:jUe,fragmentShader:RUe}),p=g.clone();p.defines.HORIZONTAL_PASS=1;const x=new Ta;x.setAttribute("position",new Ds(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Bo(x,g),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=xQ;let v=this.type;this.render=function(A,C,T){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||A.length===0)return;const L=t.getRenderTarget(),k=t.getActiveCubeFace(),D=t.getActiveMipmapLevel(),U=t.state;U.setBlending(pd),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);const O=v!==yc&&this.type===yc,q=v===yc&&this.type!==yc;for(let R=0,G=A.length;R<G;R++){const Y=A[R],V=Y.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",Y,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;i.copy(V.mapSize);const K=V.getFrameExtents();if(i.multiply(K),a.copy(V.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/K.x),i.x=a.x*K.x,V.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/K.y),i.y=a.y*K.y,V.mapSize.y=a.y)),V.map===null||O===!0||q===!0){const X=this.type!==yc?{minFilter:oa,magFilter:oa}:{};V.map!==null&&V.map.dispose(),V.map=new _f(i.x,i.y,X),V.map.texture.name=Y.name+".shadowMap",V.camera.updateProjectionMatrix()}t.setRenderTarget(V.map),t.clear();const J=V.getViewportCount();for(let X=0;X<J;X++){const F=V.getViewport(X);o.set(a.x*F.x,a.y*F.y,a.x*F.z,a.y*F.w),U.viewport(o),V.updateMatrices(Y,X),r=V.getFrustum(),N(C,T,V.camera,Y,this.type)}V.isPointLightShadow!==!0&&this.type===yc&&E(V,T),V.needsUpdate=!1}v=this.type,b.needsUpdate=!1,t.setRenderTarget(L,k,D)};function E(A,C){const T=e.update(y);g.defines.VSM_SAMPLES!==A.blurSamples&&(g.defines.VSM_SAMPLES=A.blurSamples,p.defines.VSM_SAMPLES=A.blurSamples,g.needsUpdate=!0,p.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new _f(i.x,i.y)),g.uniforms.shadow_pass.value=A.map.texture,g.uniforms.resolution.value=A.mapSize,g.uniforms.radius.value=A.radius,t.setRenderTarget(A.mapPass),t.clear(),t.renderBufferDirect(C,null,T,g,y,null),p.uniforms.shadow_pass.value=A.mapPass.texture,p.uniforms.resolution.value=A.mapSize,p.uniforms.radius.value=A.radius,t.setRenderTarget(A.map),t.clear(),t.renderBufferDirect(C,null,T,p,y,null)}function w(A,C,T,L){let k=null;const D=T.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(D!==void 0)k=D;else if(k=T.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 U=k.uuid,O=C.uuid;let q=u[U];q===void 0&&(q={},u[U]=q);let R=q[O];R===void 0&&(R=k.clone(),q[O]=R),k=R}if(k.visible=C.visible,k.wireframe=C.wireframe,L===yc?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,T.isPointLight===!0&&k.isMeshDistanceMaterial===!0){const U=t.properties.get(k);U.light=T}return k}function N(A,C,T,L,k){if(A.visible===!1)return;if(A.layers.test(C.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&k===yc)&&(!A.frustumCulled||r.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,A.matrixWorld);const O=e.update(A),q=A.material;if(Array.isArray(q)){const R=O.groups;for(let G=0,Y=R.length;G<Y;G++){const V=R[G],K=q[V.materialIndex];if(K&&K.visible){const J=w(A,K,L,k);A.onBeforeShadow(t,A,C,T,O,J,V),t.renderBufferDirect(T,null,O,J,A,V),A.onAfterShadow(t,A,C,T,O,J,V)}}}else if(q.visible){const R=w(A,q,L,k);A.onBeforeShadow(t,A,C,T,O,R,null),t.renderBufferDirect(T,null,O,R,A,null),A.onAfterShadow(t,A,C,T,O,R,null)}}const U=A.children;for(let O=0,q=U.length;O<q;O++)N(U[O],C,T,L,k)}}function OUe(t,e,n){const r=n.isWebGL2;function i(){let xe=!1;const ze=new ur;let Pe=null;const Se=new ur(0,0,0,0);return{setMask:function(Ye){Pe!==Ye&&!xe&&(t.colorMask(Ye,Ye,Ye,Ye),Pe=Ye)},setLocked:function(Ye){xe=Ye},setClear:function(Ye,dt,Tt,Et,Zt){Zt===!0&&(Ye*=Et,dt*=Et,Tt*=Et),ze.set(Ye,dt,Tt,Et),Se.equals(ze)===!1&&(t.clearColor(Ye,dt,Tt,Et),Se.copy(ze))},reset:function(){xe=!1,Pe=null,Se.set(-1,0,0,0)}}}function a(){let xe=!1,ze=null,Pe=null,Se=null;return{setTest:function(Ye){Ye?he(t.DEPTH_TEST):pe(t.DEPTH_TEST)},setMask:function(Ye){ze!==Ye&&!xe&&(t.depthMask(Ye),ze=Ye)},setFunc:function(Ye){if(Pe!==Ye){switch(Ye){case WOe:t.depthFunc(t.NEVER);break;case qOe:t.depthFunc(t.ALWAYS);break;case KOe:t.depthFunc(t.LESS);break;case nS:t.depthFunc(t.LEQUAL);break;case XOe:t.depthFunc(t.EQUAL);break;case YOe:t.depthFunc(t.GEQUAL);break;case ZOe:t.depthFunc(t.GREATER);break;case QOe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Pe=Ye}},setLocked:function(Ye){xe=Ye},setClear:function(Ye){Se!==Ye&&(t.clearDepth(Ye),Se=Ye)},reset:function(){xe=!1,ze=null,Pe=null,Se=null}}}function o(){let xe=!1,ze=null,Pe=null,Se=null,Ye=null,dt=null,Tt=null,Et=null,Zt=null;return{setTest:function(Rt){xe||(Rt?he(t.STENCIL_TEST):pe(t.STENCIL_TEST))},setMask:function(Rt){ze!==Rt&&!xe&&(t.stencilMask(Rt),ze=Rt)},setFunc:function(Rt,en,Ln){(Pe!==Rt||Se!==en||Ye!==Ln)&&(t.stencilFunc(Rt,en,Ln),Pe=Rt,Se=en,Ye=Ln)},setOp:function(Rt,en,Ln){(dt!==Rt||Tt!==en||Et!==Ln)&&(t.stencilOp(Rt,en,Ln),dt=Rt,Tt=en,Et=Ln)},setLocked:function(Rt){xe=Rt},setClear:function(Rt){Zt!==Rt&&(t.clearStencil(Rt),Zt=Rt)},reset:function(){xe=!1,ze=null,Pe=null,Se=null,Ye=null,dt=null,Tt=null,Et=null,Zt=null}}}const l=new i,c=new a,u=new o,d=new WeakMap,f=new WeakMap;let g={},p={},x=new WeakMap,y=[],b=null,v=!1,E=null,w=null,N=null,A=null,C=null,T=null,L=null,k=new Yt(0,0,0),D=0,U=!1,O=null,q=null,R=null,G=null,Y=null;const V=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,J=0;const X=t.getParameter(t.VERSION);X.indexOf("WebGL")!==-1?(J=parseFloat(/^WebGL (\d)/.exec(X)[1]),K=J>=1):X.indexOf("OpenGL ES")!==-1&&(J=parseFloat(/^OpenGL ES (\d)/.exec(X)[1]),K=J>=2);let F=null,W={};const ee=t.getParameter(t.SCISSOR_BOX),ie=t.getParameter(t.VIEWPORT),ae=new ur().fromArray(ee),de=new ur().fromArray(ie);function ue(xe,ze,Pe,Se){const Ye=new Uint8Array(4),dt=t.createTexture();t.bindTexture(xe,dt),t.texParameteri(xe,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(xe,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Tt=0;Tt<Pe;Tt++)r&&(xe===t.TEXTURE_3D||xe===t.TEXTURE_2D_ARRAY)?t.texImage3D(ze,0,t.RGBA,1,1,Se,0,t.RGBA,t.UNSIGNED_BYTE,Ye):t.texImage2D(ze+Tt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ye);return dt}const le={};le[t.TEXTURE_2D]=ue(t.TEXTURE_2D,t.TEXTURE_2D,1),le[t.TEXTURE_CUBE_MAP]=ue(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(le[t.TEXTURE_2D_ARRAY]=ue(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),le[t.TEXTURE_3D]=ue(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(nS),Q(!1),ce(k$),he(t.CULL_FACE),se(pd);function he(xe){g[xe]!==!0&&(t.enable(xe),g[xe]=!0)}function pe(xe){g[xe]!==!1&&(t.disable(xe),g[xe]=!1)}function Me(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 re(xe,ze){let Pe=y,Se=!1;if(xe)if(Pe=x.get(ze),Pe===void 0&&(Pe=[],x.set(ze,Pe)),xe.isWebGLMultipleRenderTargets){const Ye=xe.texture;if(Pe.length!==Ye.length||Pe[0]!==t.COLOR_ATTACHMENT0){for(let dt=0,Tt=Ye.length;dt<Tt;dt++)Pe[dt]=t.COLOR_ATTACHMENT0+dt;Pe.length=Ye.length,Se=!0}}else Pe[0]!==t.COLOR_ATTACHMENT0&&(Pe[0]=t.COLOR_ATTACHMENT0,Se=!0);else Pe[0]!==t.BACK&&(Pe[0]=t.BACK,Se=!0);Se&&(n.isWebGL2?t.drawBuffers(Pe):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Pe))}function We(xe){return b!==xe?(t.useProgram(xe),b=xe,!0):!1}const z={[Nh]:t.FUNC_ADD,[POe]:t.FUNC_SUBTRACT,[jOe]:t.FUNC_REVERSE_SUBTRACT};if(r)z[D$]=t.MIN,z[O$]=t.MAX;else{const xe=e.get("EXT_blend_minmax");xe!==null&&(z[D$]=xe.MIN_EXT,z[O$]=xe.MAX_EXT)}const H={[ROe]:t.ZERO,[DOe]:t.ONE,[OOe]:t.SRC_COLOR,[aj]:t.SRC_ALPHA,[BOe]:t.SRC_ALPHA_SATURATE,[UOe]:t.DST_COLOR,[IOe]:t.DST_ALPHA,[LOe]:t.ONE_MINUS_SRC_COLOR,[sj]:t.ONE_MINUS_SRC_ALPHA,[zOe]:t.ONE_MINUS_DST_COLOR,[FOe]:t.ONE_MINUS_DST_ALPHA,[HOe]:t.CONSTANT_COLOR,[$Oe]:t.ONE_MINUS_CONSTANT_COLOR,[VOe]:t.CONSTANT_ALPHA,[GOe]:t.ONE_MINUS_CONSTANT_ALPHA};function se(xe,ze,Pe,Se,Ye,dt,Tt,Et,Zt,Rt){if(xe===pd){v===!0&&(pe(t.BLEND),v=!1);return}if(v===!1&&(he(t.BLEND),v=!0),xe!==kOe){if(xe!==E||Rt!==U){if((w!==Nh||C!==Nh)&&(t.blendEquation(t.FUNC_ADD),w=Nh,C=Nh),Rt)switch(xe){case Sp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case P$:t.blendFunc(t.ONE,t.ONE);break;case j$:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case R$: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 Sp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case P$:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case j$:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case R$:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",xe);break}N=null,A=null,T=null,L=null,k.set(0,0,0),D=0,E=xe,U=Rt}return}Ye=Ye||ze,dt=dt||Pe,Tt=Tt||Se,(ze!==w||Ye!==C)&&(t.blendEquationSeparate(z[ze],z[Ye]),w=ze,C=Ye),(Pe!==N||Se!==A||dt!==T||Tt!==L)&&(t.blendFuncSeparate(H[Pe],H[Se],H[dt],H[Tt]),N=Pe,A=Se,T=dt,L=Tt),(Et.equals(k)===!1||Zt!==D)&&(t.blendColor(Et.r,Et.g,Et.b,Zt),k.copy(Et),D=Zt),E=xe,U=!1}function B(xe,ze){xe.side===Ac?pe(t.CULL_FACE):he(t.CULL_FACE);let Pe=xe.side===ls;ze&&(Pe=!Pe),Q(Pe),xe.blending===Sp&&xe.transparent===!1?se(pd):se(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 Se=xe.stencilWrite;u.setTest(Se),Se&&(u.setMask(xe.stencilWriteMask),u.setFunc(xe.stencilFunc,xe.stencilRef,xe.stencilFuncMask),u.setOp(xe.stencilFail,xe.stencilZFail,xe.stencilZPass)),_e(xe.polygonOffset,xe.polygonOffsetFactor,xe.polygonOffsetUnits),xe.alphaToCoverage===!0?he(t.SAMPLE_ALPHA_TO_COVERAGE):pe(t.SAMPLE_ALPHA_TO_COVERAGE)}function Q(xe){O!==xe&&(xe?t.frontFace(t.CW):t.frontFace(t.CCW),O=xe)}function ce(xe){xe!==NOe?(he(t.CULL_FACE),xe!==q&&(xe===k$?t.cullFace(t.BACK):xe===TOe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):pe(t.CULL_FACE),q=xe}function Ce(xe){xe!==R&&(K&&t.lineWidth(xe),R=xe)}function _e(xe,ze,Pe){xe?(he(t.POLYGON_OFFSET_FILL),(G!==ze||Y!==Pe)&&(t.polygonOffset(ze,Pe),G=ze,Y=Pe)):pe(t.POLYGON_OFFSET_FILL)}function Ee(xe){xe?he(t.SCISSOR_TEST):pe(t.SCISSOR_TEST)}function $(xe){xe===void 0&&(xe=t.TEXTURE0+V-1),F!==xe&&(t.activeTexture(xe),F=xe)}function j(xe,ze,Pe){Pe===void 0&&(F===null?Pe=t.TEXTURE0+V-1:Pe=F);let Se=W[Pe];Se===void 0&&(Se={type:void 0,texture:void 0},W[Pe]=Se),(Se.type!==xe||Se.texture!==ze)&&(F!==Pe&&(t.activeTexture(Pe),F=Pe),t.bindTexture(xe,ze||le[xe]),Se.type=xe,Se.texture=ze)}function ne(){const xe=W[F];xe!==void 0&&xe.type!==void 0&&(t.bindTexture(xe.type,null),xe.type=void 0,xe.texture=void 0)}function be(){try{t.compressedTexImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function we(){try{t.compressedTexImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function ve(){try{t.texSubImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function $e(){try{t.texSubImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Ge(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Xe(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function ut(){try{t.texStorage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function He(){try{t.texStorage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function me(){try{t.texImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Je(){try{t.texImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Ke(xe){ae.equals(xe)===!1&&(t.scissor(xe.x,xe.y,xe.z,xe.w),ae.copy(xe))}function Ze(xe){de.equals(xe)===!1&&(t.viewport(xe.x,xe.y,xe.z,xe.w),de.copy(xe))}function ct(xe,ze){let Pe=f.get(ze);Pe===void 0&&(Pe=new WeakMap,f.set(ze,Pe));let Se=Pe.get(xe);Se===void 0&&(Se=t.getUniformBlockIndex(ze,xe.name),Pe.set(xe,Se))}function te(xe,ze){const Se=f.get(ze).get(xe);d.get(ze)!==Se&&(t.uniformBlockBinding(ze,Se,xe.__bindingPointIndex),d.set(ze,Se))}function Fe(){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,W={},p={},x=new WeakMap,y=[],b=null,v=!1,E=null,w=null,N=null,A=null,C=null,T=null,L=null,k=new Yt(0,0,0),D=0,U=!1,O=null,q=null,R=null,G=null,Y=null,ae.set(0,0,t.canvas.width,t.canvas.height),de.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:pe,bindFramebuffer:Me,drawBuffers:re,useProgram:We,setBlending:se,setMaterial:B,setFlipSided:Q,setCullFace:ce,setLineWidth:Ce,setPolygonOffset:_e,setScissorTest:Ee,activeTexture:$,bindTexture:j,unbindTexture:ne,compressedTexImage2D:be,compressedTexImage3D:we,texImage2D:me,texImage3D:Je,updateUBOMapping:ct,uniformBlockBinding:te,texStorage2D:ut,texStorage3D:He,texSubImage2D:ve,texSubImage3D:$e,compressedTexSubImage2D:Ge,compressedTexSubImage3D:Xe,scissor:Ke,viewport:Ze,reset:Fe}}function LUe(t,e,n,r,i,a,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,g=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let y;const b=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function E($,j){return v?new OffscreenCanvas($,j):oS("canvas")}function w($,j,ne,be){let we=1;if(($.width>be||$.height>be)&&(we=be/Math.max($.width,$.height)),we<1||j===!0)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap){const ve=j?sS:Math.floor,$e=ve(we*$.width),Ge=ve(we*$.height);y===void 0&&(y=E($e,Ge));const Xe=ne?E($e,Ge):y;return Xe.width=$e,Xe.height=Ge,Xe.getContext("2d").drawImage($,0,0,$e,Ge),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+$e+"x"+Ge+")."),Xe}else return"data"in $&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),$;return $}function N($){return fj($.width)&&fj($.height)}function A($){return l?!1:$.wrapS!==Fo||$.wrapT!==Fo||$.minFilter!==oa&&$.minFilter!==so}function C($,j){return $.generateMipmaps&&j&&$.minFilter!==oa&&$.minFilter!==so}function T($){t.generateMipmap($)}function L($,j,ne,be,we=!1){if(l===!1)return j;if($!==null){if(t[$]!==void 0)return t[$];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let ve=j;if(j===t.RED&&(ne===t.FLOAT&&(ve=t.R32F),ne===t.HALF_FLOAT&&(ve=t.R16F),ne===t.UNSIGNED_BYTE&&(ve=t.R8)),j===t.RED_INTEGER&&(ne===t.UNSIGNED_BYTE&&(ve=t.R8UI),ne===t.UNSIGNED_SHORT&&(ve=t.R16UI),ne===t.UNSIGNED_INT&&(ve=t.R32UI),ne===t.BYTE&&(ve=t.R8I),ne===t.SHORT&&(ve=t.R16I),ne===t.INT&&(ve=t.R32I)),j===t.RG&&(ne===t.FLOAT&&(ve=t.RG32F),ne===t.HALF_FLOAT&&(ve=t.RG16F),ne===t.UNSIGNED_BYTE&&(ve=t.RG8)),j===t.RGBA){const $e=we?rS:lr.getTransfer(be);ne===t.FLOAT&&(ve=t.RGBA32F),ne===t.HALF_FLOAT&&(ve=t.RGBA16F),ne===t.UNSIGNED_BYTE&&(ve=$e===Sr?t.SRGB8_ALPHA8:t.RGBA8),ne===t.UNSIGNED_SHORT_4_4_4_4&&(ve=t.RGBA4),ne===t.UNSIGNED_SHORT_5_5_5_1&&(ve=t.RGB5_A1)}return(ve===t.R16F||ve===t.R32F||ve===t.RG16F||ve===t.RG32F||ve===t.RGBA16F||ve===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ve}function k($,j,ne){return C($,ne)===!0||$.isFramebufferTexture&&$.minFilter!==oa&&$.minFilter!==so?Math.log2(Math.max(j.width,j.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?j.mipmaps.length:1}function D($){return $===oa||$===L$||$===_C?t.NEAREST:t.LINEAR}function U($){const j=$.target;j.removeEventListener("dispose",U),q(j),j.isVideoTexture&&x.delete(j)}function O($){const j=$.target;j.removeEventListener("dispose",O),G(j)}function q($){const j=r.get($);if(j.__webglInit===void 0)return;const ne=$.source,be=b.get(ne);if(be){const we=be[j.__cacheKey];we.usedTimes--,we.usedTimes===0&&R($),Object.keys(be).length===0&&b.delete(ne)}r.remove($)}function R($){const j=r.get($);t.deleteTexture(j.__webglTexture);const ne=$.source,be=b.get(ne);delete be[j.__cacheKey],o.memory.textures--}function G($){const j=$.texture,ne=r.get($),be=r.get(j);if(be.__webglTexture!==void 0&&(t.deleteTexture(be.__webglTexture),o.memory.textures--),$.depthTexture&&$.depthTexture.dispose(),$.isWebGLCubeRenderTarget)for(let we=0;we<6;we++){if(Array.isArray(ne.__webglFramebuffer[we]))for(let ve=0;ve<ne.__webglFramebuffer[we].length;ve++)t.deleteFramebuffer(ne.__webglFramebuffer[we][ve]);else t.deleteFramebuffer(ne.__webglFramebuffer[we]);ne.__webglDepthbuffer&&t.deleteRenderbuffer(ne.__webglDepthbuffer[we])}else{if(Array.isArray(ne.__webglFramebuffer))for(let we=0;we<ne.__webglFramebuffer.length;we++)t.deleteFramebuffer(ne.__webglFramebuffer[we]);else t.deleteFramebuffer(ne.__webglFramebuffer);if(ne.__webglDepthbuffer&&t.deleteRenderbuffer(ne.__webglDepthbuffer),ne.__webglMultisampledFramebuffer&&t.deleteFramebuffer(ne.__webglMultisampledFramebuffer),ne.__webglColorRenderbuffer)for(let we=0;we<ne.__webglColorRenderbuffer.length;we++)ne.__webglColorRenderbuffer[we]&&t.deleteRenderbuffer(ne.__webglColorRenderbuffer[we]);ne.__webglDepthRenderbuffer&&t.deleteRenderbuffer(ne.__webglDepthRenderbuffer)}if($.isWebGLMultipleRenderTargets)for(let we=0,ve=j.length;we<ve;we++){const $e=r.get(j[we]);$e.__webglTexture&&(t.deleteTexture($e.__webglTexture),o.memory.textures--),r.remove(j[we])}r.remove(j),r.remove($)}let Y=0;function V(){Y=0}function K(){const $=Y;return $>=c&&console.warn("THREE.WebGLTextures: Trying to use "+$+" texture units while this GPU supports only "+c),Y+=1,$}function J($){const j=[];return j.push($.wrapS),j.push($.wrapT),j.push($.wrapR||0),j.push($.magFilter),j.push($.minFilter),j.push($.anisotropy),j.push($.internalFormat),j.push($.format),j.push($.type),j.push($.generateMipmaps),j.push($.premultiplyAlpha),j.push($.flipY),j.push($.unpackAlignment),j.push($.colorSpace),j.join()}function X($,j){const ne=r.get($);if($.isVideoTexture&&_e($),$.isRenderTargetTexture===!1&&$.version>0&&ne.__version!==$.version){const be=$.image;if(be===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(be.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{he(ne,$,j);return}}n.bindTexture(t.TEXTURE_2D,ne.__webglTexture,t.TEXTURE0+j)}function F($,j){const ne=r.get($);if($.version>0&&ne.__version!==$.version){he(ne,$,j);return}n.bindTexture(t.TEXTURE_2D_ARRAY,ne.__webglTexture,t.TEXTURE0+j)}function W($,j){const ne=r.get($);if($.version>0&&ne.__version!==$.version){he(ne,$,j);return}n.bindTexture(t.TEXTURE_3D,ne.__webglTexture,t.TEXTURE0+j)}function ee($,j){const ne=r.get($);if($.version>0&&ne.__version!==$.version){pe(ne,$,j);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ne.__webglTexture,t.TEXTURE0+j)}const ie={[cj]:t.REPEAT,[Fo]:t.CLAMP_TO_EDGE,[uj]:t.MIRRORED_REPEAT},ae={[oa]:t.NEAREST,[L$]:t.NEAREST_MIPMAP_NEAREST,[_C]:t.NEAREST_MIPMAP_LINEAR,[so]:t.LINEAR,[s4e]:t.LINEAR_MIPMAP_NEAREST,[cb]:t.LINEAR_MIPMAP_LINEAR},de={[b4e]:t.NEVER,[M4e]:t.ALWAYS,[y4e]:t.LESS,[TQ]:t.LEQUAL,[v4e]:t.EQUAL,[S4e]:t.GEQUAL,[_4e]:t.GREATER,[w4e]:t.NOTEQUAL};function ue($,j,ne){if(ne?(t.texParameteri($,t.TEXTURE_WRAP_S,ie[j.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,ie[j.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,ie[j.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,ae[j.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,ae[j.minFilter])):(t.texParameteri($,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri($,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(j.wrapS!==Fo||j.wrapT!==Fo)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri($,t.TEXTURE_MAG_FILTER,D(j.magFilter)),t.texParameteri($,t.TEXTURE_MIN_FILTER,D(j.minFilter)),j.minFilter!==oa&&j.minFilter!==so&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),j.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,de[j.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const be=e.get("EXT_texture_filter_anisotropic");if(j.magFilter===oa||j.minFilter!==_C&&j.minFilter!==cb||j.type===Rc&&e.has("OES_texture_float_linear")===!1||l===!1&&j.type===ub&&e.has("OES_texture_half_float_linear")===!1)return;(j.anisotropy>1||r.get(j).__currentAnisotropy)&&(t.texParameterf($,be.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(j.anisotropy,i.getMaxAnisotropy())),r.get(j).__currentAnisotropy=j.anisotropy)}}function le($,j){let ne=!1;$.__webglInit===void 0&&($.__webglInit=!0,j.addEventListener("dispose",U));const be=j.source;let we=b.get(be);we===void 0&&(we={},b.set(be,we));const ve=J(j);if(ve!==$.__cacheKey){we[ve]===void 0&&(we[ve]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,ne=!0),we[ve].usedTimes++;const $e=we[$.__cacheKey];$e!==void 0&&(we[$.__cacheKey].usedTimes--,$e.usedTimes===0&&R(j)),$.__cacheKey=ve,$.__webglTexture=we[ve].texture}return ne}function he($,j,ne){let be=t.TEXTURE_2D;(j.isDataArrayTexture||j.isCompressedArrayTexture)&&(be=t.TEXTURE_2D_ARRAY),j.isData3DTexture&&(be=t.TEXTURE_3D);const we=le($,j),ve=j.source;n.bindTexture(be,$.__webglTexture,t.TEXTURE0+ne);const $e=r.get(ve);if(ve.version!==$e.__version||we===!0){n.activeTexture(t.TEXTURE0+ne);const Ge=lr.getPrimaries(lr.workingColorSpace),Xe=j.colorSpace===lo?null:lr.getPrimaries(j.colorSpace),ut=j.colorSpace===lo||Ge===Xe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,j.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,j.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ut);const He=A(j)&&N(j.image)===!1;let me=w(j.image,He,!1,d);me=Ee(j,me);const Je=N(me)||l,Ke=a.convert(j.format,j.colorSpace);let Ze=a.convert(j.type),ct=L(j.internalFormat,Ke,Ze,j.colorSpace,j.isVideoTexture);ue(be,j,Je);let te;const Fe=j.mipmaps,xe=l&&j.isVideoTexture!==!0&&ct!==EQ,ze=$e.__version===void 0||we===!0,Pe=k(j,me,Je);if(j.isDepthTexture)ct=t.DEPTH_COMPONENT,l?j.type===Rc?ct=t.DEPTH_COMPONENT32F:j.type===sd?ct=t.DEPTH_COMPONENT24:j.type===Wh?ct=t.DEPTH24_STENCIL8:ct=t.DEPTH_COMPONENT16:j.type===Rc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),j.format===qh&&ct===t.DEPTH_COMPONENT&&j.type!==KO&&j.type!==sd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),j.type=sd,Ze=a.convert(j.type)),j.format===Zp&&ct===t.DEPTH_COMPONENT&&(ct=t.DEPTH_STENCIL,j.type!==Wh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),j.type=Wh,Ze=a.convert(j.type))),ze&&(xe?n.texStorage2D(t.TEXTURE_2D,1,ct,me.width,me.height):n.texImage2D(t.TEXTURE_2D,0,ct,me.width,me.height,0,Ke,Ze,null));else if(j.isDataTexture)if(Fe.length>0&&Je){xe&&ze&&n.texStorage2D(t.TEXTURE_2D,Pe,ct,Fe[0].width,Fe[0].height);for(let Se=0,Ye=Fe.length;Se<Ye;Se++)te=Fe[Se],xe?n.texSubImage2D(t.TEXTURE_2D,Se,0,0,te.width,te.height,Ke,Ze,te.data):n.texImage2D(t.TEXTURE_2D,Se,ct,te.width,te.height,0,Ke,Ze,te.data);j.generateMipmaps=!1}else xe?(ze&&n.texStorage2D(t.TEXTURE_2D,Pe,ct,me.width,me.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,me.width,me.height,Ke,Ze,me.data)):n.texImage2D(t.TEXTURE_2D,0,ct,me.width,me.height,0,Ke,Ze,me.data);else if(j.isCompressedTexture)if(j.isCompressedArrayTexture){xe&&ze&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Pe,ct,Fe[0].width,Fe[0].height,me.depth);for(let Se=0,Ye=Fe.length;Se<Ye;Se++)te=Fe[Se],j.format!==oo?Ke!==null?xe?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Se,0,0,0,te.width,te.height,me.depth,Ke,te.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Se,ct,te.width,te.height,me.depth,0,te.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):xe?n.texSubImage3D(t.TEXTURE_2D_ARRAY,Se,0,0,0,te.width,te.height,me.depth,Ke,Ze,te.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Se,ct,te.width,te.height,me.depth,0,Ke,Ze,te.data)}else{xe&&ze&&n.texStorage2D(t.TEXTURE_2D,Pe,ct,Fe[0].width,Fe[0].height);for(let Se=0,Ye=Fe.length;Se<Ye;Se++)te=Fe[Se],j.format!==oo?Ke!==null?xe?n.compressedTexSubImage2D(t.TEXTURE_2D,Se,0,0,te.width,te.height,Ke,te.data):n.compressedTexImage2D(t.TEXTURE_2D,Se,ct,te.width,te.height,0,te.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):xe?n.texSubImage2D(t.TEXTURE_2D,Se,0,0,te.width,te.height,Ke,Ze,te.data):n.texImage2D(t.TEXTURE_2D,Se,ct,te.width,te.height,0,Ke,Ze,te.data)}else if(j.isDataArrayTexture)xe?(ze&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Pe,ct,me.width,me.height,me.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,me.width,me.height,me.depth,Ke,Ze,me.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ct,me.width,me.height,me.depth,0,Ke,Ze,me.data);else if(j.isData3DTexture)xe?(ze&&n.texStorage3D(t.TEXTURE_3D,Pe,ct,me.width,me.height,me.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,me.width,me.height,me.depth,Ke,Ze,me.data)):n.texImage3D(t.TEXTURE_3D,0,ct,me.width,me.height,me.depth,0,Ke,Ze,me.data);else if(j.isFramebufferTexture){if(ze)if(xe)n.texStorage2D(t.TEXTURE_2D,Pe,ct,me.width,me.height);else{let Se=me.width,Ye=me.height;for(let dt=0;dt<Pe;dt++)n.texImage2D(t.TEXTURE_2D,dt,ct,Se,Ye,0,Ke,Ze,null),Se>>=1,Ye>>=1}}else if(Fe.length>0&&Je){xe&&ze&&n.texStorage2D(t.TEXTURE_2D,Pe,ct,Fe[0].width,Fe[0].height);for(let Se=0,Ye=Fe.length;Se<Ye;Se++)te=Fe[Se],xe?n.texSubImage2D(t.TEXTURE_2D,Se,0,0,Ke,Ze,te):n.texImage2D(t.TEXTURE_2D,Se,ct,Ke,Ze,te);j.generateMipmaps=!1}else xe?(ze&&n.texStorage2D(t.TEXTURE_2D,Pe,ct,me.width,me.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Ke,Ze,me)):n.texImage2D(t.TEXTURE_2D,0,ct,Ke,Ze,me);C(j,Je)&&T(be),$e.__version=ve.version,j.onUpdate&&j.onUpdate(j)}$.__version=j.version}function pe($,j,ne){if(j.image.length!==6)return;const be=le($,j),we=j.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+ne);const ve=r.get(we);if(we.version!==ve.__version||be===!0){n.activeTexture(t.TEXTURE0+ne);const $e=lr.getPrimaries(lr.workingColorSpace),Ge=j.colorSpace===lo?null:lr.getPrimaries(j.colorSpace),Xe=j.colorSpace===lo||$e===Ge?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,j.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,j.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,j.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Xe);const ut=j.isCompressedTexture||j.image[0].isCompressedTexture,He=j.image[0]&&j.image[0].isDataTexture,me=[];for(let Se=0;Se<6;Se++)!ut&&!He?me[Se]=w(j.image[Se],!1,!0,u):me[Se]=He?j.image[Se].image:j.image[Se],me[Se]=Ee(j,me[Se]);const Je=me[0],Ke=N(Je)||l,Ze=a.convert(j.format,j.colorSpace),ct=a.convert(j.type),te=L(j.internalFormat,Ze,ct,j.colorSpace),Fe=l&&j.isVideoTexture!==!0,xe=ve.__version===void 0||be===!0;let ze=k(j,Je,Ke);ue(t.TEXTURE_CUBE_MAP,j,Ke);let Pe;if(ut){Fe&&xe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,ze,te,Je.width,Je.height);for(let Se=0;Se<6;Se++){Pe=me[Se].mipmaps;for(let Ye=0;Ye<Pe.length;Ye++){const dt=Pe[Ye];j.format!==oo?Ze!==null?Fe?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye,0,0,dt.width,dt.height,Ze,dt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye,te,dt.width,dt.height,0,dt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye,0,0,dt.width,dt.height,Ze,ct,dt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye,te,dt.width,dt.height,0,Ze,ct,dt.data)}}}else{Pe=j.mipmaps,Fe&&xe&&(Pe.length>0&&ze++,n.texStorage2D(t.TEXTURE_CUBE_MAP,ze,te,me[0].width,me[0].height));for(let Se=0;Se<6;Se++)if(He){Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,0,0,0,me[Se].width,me[Se].height,Ze,ct,me[Se].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,0,te,me[Se].width,me[Se].height,0,Ze,ct,me[Se].data);for(let Ye=0;Ye<Pe.length;Ye++){const Tt=Pe[Ye].image[Se].image;Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye+1,0,0,Tt.width,Tt.height,Ze,ct,Tt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye+1,te,Tt.width,Tt.height,0,Ze,ct,Tt.data)}}else{Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,0,0,0,Ze,ct,me[Se]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,0,te,Ze,ct,me[Se]);for(let Ye=0;Ye<Pe.length;Ye++){const dt=Pe[Ye];Fe?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye+1,0,0,Ze,ct,dt.image[Se]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Se,Ye+1,te,Ze,ct,dt.image[Se])}}}C(j,Ke)&&T(t.TEXTURE_CUBE_MAP),ve.__version=we.version,j.onUpdate&&j.onUpdate(j)}$.__version=j.version}function Me($,j,ne,be,we,ve){const $e=a.convert(ne.format,ne.colorSpace),Ge=a.convert(ne.type),Xe=L(ne.internalFormat,$e,Ge,ne.colorSpace);if(!r.get(j).__hasExternalTextures){const He=Math.max(1,j.width>>ve),me=Math.max(1,j.height>>ve);we===t.TEXTURE_3D||we===t.TEXTURE_2D_ARRAY?n.texImage3D(we,ve,Xe,He,me,j.depth,0,$e,Ge,null):n.texImage2D(we,ve,Xe,He,me,0,$e,Ge,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),Ce(j)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,be,we,r.get(ne).__webglTexture,0,ce(j)):(we===t.TEXTURE_2D||we>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&we<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,be,we,r.get(ne).__webglTexture,ve),n.bindFramebuffer(t.FRAMEBUFFER,null)}function re($,j,ne){if(t.bindRenderbuffer(t.RENDERBUFFER,$),j.depthBuffer&&!j.stencilBuffer){let be=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(ne||Ce(j)){const we=j.depthTexture;we&&we.isDepthTexture&&(we.type===Rc?be=t.DEPTH_COMPONENT32F:we.type===sd&&(be=t.DEPTH_COMPONENT24));const ve=ce(j);Ce(j)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ve,be,j.width,j.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ve,be,j.width,j.height)}else t.renderbufferStorage(t.RENDERBUFFER,be,j.width,j.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,$)}else if(j.depthBuffer&&j.stencilBuffer){const be=ce(j);ne&&Ce(j)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,be,t.DEPTH24_STENCIL8,j.width,j.height):Ce(j)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,be,t.DEPTH24_STENCIL8,j.width,j.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,j.width,j.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,$)}else{const be=j.isWebGLMultipleRenderTargets===!0?j.texture:[j.texture];for(let we=0;we<be.length;we++){const ve=be[we],$e=a.convert(ve.format,ve.colorSpace),Ge=a.convert(ve.type),Xe=L(ve.internalFormat,$e,Ge,ve.colorSpace),ut=ce(j);ne&&Ce(j)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ut,Xe,j.width,j.height):Ce(j)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ut,Xe,j.width,j.height):t.renderbufferStorage(t.RENDERBUFFER,Xe,j.width,j.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function We($,j){if(j&&j.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(j.depthTexture&&j.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(j.depthTexture).__webglTexture||j.depthTexture.image.width!==j.width||j.depthTexture.image.height!==j.height)&&(j.depthTexture.image.width=j.width,j.depthTexture.image.height=j.height,j.depthTexture.needsUpdate=!0),X(j.depthTexture,0);const be=r.get(j.depthTexture).__webglTexture,we=ce(j);if(j.depthTexture.format===qh)Ce(j)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,be,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,be,0);else if(j.depthTexture.format===Zp)Ce(j)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,be,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,be,0);else throw new Error("Unknown depthTexture format")}function z($){const j=r.get($),ne=$.isWebGLCubeRenderTarget===!0;if($.depthTexture&&!j.__autoAllocateDepthBuffer){if(ne)throw new Error("target.depthTexture not supported in Cube render targets");We(j.__webglFramebuffer,$)}else if(ne){j.__webglDepthbuffer=[];for(let be=0;be<6;be++)n.bindFramebuffer(t.FRAMEBUFFER,j.__webglFramebuffer[be]),j.__webglDepthbuffer[be]=t.createRenderbuffer(),re(j.__webglDepthbuffer[be],$,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,j.__webglFramebuffer),j.__webglDepthbuffer=t.createRenderbuffer(),re(j.__webglDepthbuffer,$,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function H($,j,ne){const be=r.get($);j!==void 0&&Me(be.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ne!==void 0&&z($)}function se($){const j=$.texture,ne=r.get($),be=r.get(j);$.addEventListener("dispose",O),$.isWebGLMultipleRenderTargets!==!0&&(be.__webglTexture===void 0&&(be.__webglTexture=t.createTexture()),be.__version=j.version,o.memory.textures++);const we=$.isWebGLCubeRenderTarget===!0,ve=$.isWebGLMultipleRenderTargets===!0,$e=N($)||l;if(we){ne.__webglFramebuffer=[];for(let Ge=0;Ge<6;Ge++)if(l&&j.mipmaps&&j.mipmaps.length>0){ne.__webglFramebuffer[Ge]=[];for(let Xe=0;Xe<j.mipmaps.length;Xe++)ne.__webglFramebuffer[Ge][Xe]=t.createFramebuffer()}else ne.__webglFramebuffer[Ge]=t.createFramebuffer()}else{if(l&&j.mipmaps&&j.mipmaps.length>0){ne.__webglFramebuffer=[];for(let Ge=0;Ge<j.mipmaps.length;Ge++)ne.__webglFramebuffer[Ge]=t.createFramebuffer()}else ne.__webglFramebuffer=t.createFramebuffer();if(ve)if(i.drawBuffers){const Ge=$.texture;for(let Xe=0,ut=Ge.length;Xe<ut;Xe++){const He=r.get(Ge[Xe]);He.__webglTexture===void 0&&(He.__webglTexture=t.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(l&&$.samples>0&&Ce($)===!1){const Ge=ve?j:[j];ne.__webglMultisampledFramebuffer=t.createFramebuffer(),ne.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ne.__webglMultisampledFramebuffer);for(let Xe=0;Xe<Ge.length;Xe++){const ut=Ge[Xe];ne.__webglColorRenderbuffer[Xe]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ne.__webglColorRenderbuffer[Xe]);const He=a.convert(ut.format,ut.colorSpace),me=a.convert(ut.type),Je=L(ut.internalFormat,He,me,ut.colorSpace,$.isXRRenderTarget===!0),Ke=ce($);t.renderbufferStorageMultisample(t.RENDERBUFFER,Ke,Je,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Xe,t.RENDERBUFFER,ne.__webglColorRenderbuffer[Xe])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(ne.__webglDepthRenderbuffer=t.createRenderbuffer(),re(ne.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(we){n.bindTexture(t.TEXTURE_CUBE_MAP,be.__webglTexture),ue(t.TEXTURE_CUBE_MAP,j,$e);for(let Ge=0;Ge<6;Ge++)if(l&&j.mipmaps&&j.mipmaps.length>0)for(let Xe=0;Xe<j.mipmaps.length;Xe++)Me(ne.__webglFramebuffer[Ge][Xe],$,j,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,Xe);else Me(ne.__webglFramebuffer[Ge],$,j,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,0);C(j,$e)&&T(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ve){const Ge=$.texture;for(let Xe=0,ut=Ge.length;Xe<ut;Xe++){const He=Ge[Xe],me=r.get(He);n.bindTexture(t.TEXTURE_2D,me.__webglTexture),ue(t.TEXTURE_2D,He,$e),Me(ne.__webglFramebuffer,$,He,t.COLOR_ATTACHMENT0+Xe,t.TEXTURE_2D,0),C(He,$e)&&T(t.TEXTURE_2D)}n.unbindTexture()}else{let Ge=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(l?Ge=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ge,be.__webglTexture),ue(Ge,j,$e),l&&j.mipmaps&&j.mipmaps.length>0)for(let Xe=0;Xe<j.mipmaps.length;Xe++)Me(ne.__webglFramebuffer[Xe],$,j,t.COLOR_ATTACHMENT0,Ge,Xe);else Me(ne.__webglFramebuffer,$,j,t.COLOR_ATTACHMENT0,Ge,0);C(j,$e)&&T(Ge),n.unbindTexture()}$.depthBuffer&&z($)}function B($){const j=N($)||l,ne=$.isWebGLMultipleRenderTargets===!0?$.texture:[$.texture];for(let be=0,we=ne.length;be<we;be++){const ve=ne[be];if(C(ve,j)){const $e=$.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ge=r.get(ve).__webglTexture;n.bindTexture($e,Ge),T($e),n.unbindTexture()}}}function Q($){if(l&&$.samples>0&&Ce($)===!1){const j=$.isWebGLMultipleRenderTargets?$.texture:[$.texture],ne=$.width,be=$.height;let we=t.COLOR_BUFFER_BIT;const ve=[],$e=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ge=r.get($),Xe=$.isWebGLMultipleRenderTargets===!0;if(Xe)for(let ut=0;ut<j.length;ut++)n.bindFramebuffer(t.FRAMEBUFFER,Ge.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ge.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ge.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ge.__webglFramebuffer);for(let ut=0;ut<j.length;ut++){ve.push(t.COLOR_ATTACHMENT0+ut),$.depthBuffer&&ve.push($e);const He=Ge.__ignoreDepthValues!==void 0?Ge.__ignoreDepthValues:!1;if(He===!1&&($.depthBuffer&&(we|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&(we|=t.STENCIL_BUFFER_BIT)),Xe&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ge.__webglColorRenderbuffer[ut]),He===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[$e]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[$e])),Xe){const me=r.get(j[ut]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,me,0)}t.blitFramebuffer(0,0,ne,be,0,0,ne,be,we,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ve)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Xe)for(let ut=0;ut<j.length;ut++){n.bindFramebuffer(t.FRAMEBUFFER,Ge.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.RENDERBUFFER,Ge.__webglColorRenderbuffer[ut]);const He=r.get(j[ut]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ge.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ut,t.TEXTURE_2D,He,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ge.__webglMultisampledFramebuffer)}}function ce($){return Math.min(f,$.samples)}function Ce($){const j=r.get($);return l&&$.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&j.__useRenderToTexture!==!1}function _e($){const j=o.render.frame;x.get($)!==j&&(x.set($,j),$.update())}function Ee($,j){const ne=$.colorSpace,be=$.format,we=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||$.format===hj||ne!==eu&&ne!==lo&&(lr.getTransfer(ne)===Sr?l===!1?e.has("EXT_sRGB")===!0&&be===oo?($.format=hj,$.minFilter=so,$.generateMipmaps=!1):j=PQ.sRGBToLinear(j):(be!==oo||we!==xd)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ne)),j}this.allocateTextureUnit=K,this.resetTextureUnits=V,this.setTexture2D=X,this.setTexture2DArray=F,this.setTexture3D=W,this.setTextureCube=ee,this.rebindTextures=H,this.setupRenderTarget=se,this.updateRenderTargetMipmap=B,this.updateMultisampleRenderTarget=Q,this.setupDepthRenderbuffer=z,this.setupFrameBufferTexture=Me,this.useMultisampledRTT=Ce}function IUe(t,e,n){const r=n.isWebGL2;function i(a,o=lo){let l;const c=lr.getTransfer(o);if(a===xd)return t.UNSIGNED_BYTE;if(a===vQ)return t.UNSIGNED_SHORT_4_4_4_4;if(a===_Q)return t.UNSIGNED_SHORT_5_5_5_1;if(a===o4e)return t.BYTE;if(a===l4e)return t.SHORT;if(a===KO)return t.UNSIGNED_SHORT;if(a===yQ)return t.INT;if(a===sd)return t.UNSIGNED_INT;if(a===Rc)return t.FLOAT;if(a===ub)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(a===c4e)return t.ALPHA;if(a===oo)return t.RGBA;if(a===u4e)return t.LUMINANCE;if(a===d4e)return t.LUMINANCE_ALPHA;if(a===qh)return t.DEPTH_COMPONENT;if(a===Zp)return t.DEPTH_STENCIL;if(a===hj)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===h4e)return t.RED;if(a===wQ)return t.RED_INTEGER;if(a===f4e)return t.RG;if(a===SQ)return t.RG_INTEGER;if(a===MQ)return t.RGBA_INTEGER;if(a===wC||a===SC||a===MC||a===EC)if(c===Sr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===wC)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===SC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===MC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===EC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===wC)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===SC)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===MC)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===EC)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===I$||a===F$||a===U$||a===z$)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===I$)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===F$)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===U$)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===z$)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===EQ)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===B$||a===H$)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===B$)return c===Sr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===H$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===$$||a===V$||a===G$||a===W$||a===q$||a===K$||a===X$||a===Y$||a===Z$||a===Q$||a===J$||a===eV||a===tV||a===nV)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===$$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===V$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===G$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===W$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===q$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===K$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===X$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===Y$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===Z$)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===J$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===eV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===tV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===nV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===AC||a===rV||a===iV)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===AC)return c===Sr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===rV)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===iV)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===m4e||a===aV||a===sV||a===oV)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===AC)return l.COMPRESSED_RED_RGTC1_EXT;if(a===aV)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===sV)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===oV)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Wh?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 FUe extends Ns{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class i0 extends Fa{constructor(){super(),this.isGroup=!0,this.type="Group"}}const UUe={type:"move"};class XC{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new i0,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 i0,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ie,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ie),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new i0,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ie,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ie),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,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const y of e.hand.values()){const b=n.getJointPose(y,r),v=this._getHandJoint(u,y);b!==null&&(v.matrix.fromArray(b.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=b.radius),v.visible=b!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&g>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(UUe)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new i0;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class zUe extends Rf{constructor(e,n){super();const r=this;let i=null,a=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,g=null,p=null,x=null;const y=n.getContextAttributes();let b=null,v=null;const E=[],w=[],N=new sn;let A=null;const C=new Ns;C.layers.enable(1),C.viewport=new ur;const T=new Ns;T.layers.enable(2),T.viewport=new ur;const L=[C,T],k=new FUe;k.layers.enable(1),k.layers.enable(2);let D=null,U=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ee){let ie=E[ee];return ie===void 0&&(ie=new XC,E[ee]=ie),ie.getTargetRaySpace()},this.getControllerGrip=function(ee){let ie=E[ee];return ie===void 0&&(ie=new XC,E[ee]=ie),ie.getGripSpace()},this.getHand=function(ee){let ie=E[ee];return ie===void 0&&(ie=new XC,E[ee]=ie),ie.getHandSpace()};function O(ee){const ie=w.indexOf(ee.inputSource);if(ie===-1)return;const ae=E[ie];ae!==void 0&&(ae.update(ee.inputSource,ee.frame,u||o),ae.dispatchEvent({type:ee.type,data:ee.inputSource}))}function q(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",R);for(let ee=0;ee<E.length;ee++){const ie=w[ee];ie!==null&&(w[ee]=null,E[ee].disconnect(ie))}D=null,U=null,e.setRenderTarget(b),p=null,g=null,f=null,i=null,v=null,W.stop(),r.isPresenting=!1,e.setPixelRatio(A),e.setSize(N.width,N.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ee){a=ee,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ee){l=ee,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(ee){u=ee},this.getBaseLayer=function(){return g!==null?g:p},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(ee){if(i=ee,i!==null){if(b=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",q),i.addEventListener("inputsourceschange",R),y.xrCompatible!==!0&&await n.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(N),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ie={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,ie),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),v=new _f(p.framebufferWidth,p.framebufferHeight,{format:oo,type:xd,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let ie=null,ae=null,de=null;y.depth&&(de=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ie=y.stencil?Zp:qh,ae=y.stencil?Wh:sd);const ue={colorFormat:n.RGBA8,depthFormat:de,scaleFactor:a};f=new XRWebGLBinding(i,n),g=f.createProjectionLayer(ue),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),v=new _f(g.textureWidth,g.textureHeight,{format:oo,type:xd,depthTexture:new $Q(g.textureWidth,g.textureHeight,ae,void 0,void 0,void 0,void 0,void 0,void 0,ie),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const le=e.properties.get(v);le.__ignoreDepthValues=g.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),W.setContext(i),W.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function R(ee){for(let ie=0;ie<ee.removed.length;ie++){const ae=ee.removed[ie],de=w.indexOf(ae);de>=0&&(w[de]=null,E[de].disconnect(ae))}for(let ie=0;ie<ee.added.length;ie++){const ae=ee.added[ie];let de=w.indexOf(ae);if(de===-1){for(let le=0;le<E.length;le++)if(le>=w.length){w.push(ae),de=le;break}else if(w[le]===null){w[le]=ae,de=le;break}if(de===-1)break}const ue=E[de];ue&&ue.connect(ae)}}const G=new Ie,Y=new Ie;function V(ee,ie,ae){G.setFromMatrixPosition(ie.matrixWorld),Y.setFromMatrixPosition(ae.matrixWorld);const de=G.distanceTo(Y),ue=ie.projectionMatrix.elements,le=ae.projectionMatrix.elements,he=ue[14]/(ue[10]-1),pe=ue[14]/(ue[10]+1),Me=(ue[9]+1)/ue[5],re=(ue[9]-1)/ue[5],We=(ue[8]-1)/ue[0],z=(le[8]+1)/le[0],H=he*We,se=he*z,B=de/(-We+z),Q=B*-We;ie.matrixWorld.decompose(ee.position,ee.quaternion,ee.scale),ee.translateX(Q),ee.translateZ(B),ee.matrixWorld.compose(ee.position,ee.quaternion,ee.scale),ee.matrixWorldInverse.copy(ee.matrixWorld).invert();const ce=he+B,Ce=pe+B,_e=H-Q,Ee=se+(de-Q),$=Me*pe/Ce*ce,j=re*pe/Ce*ce;ee.projectionMatrix.makePerspective(_e,Ee,$,j,ce,Ce),ee.projectionMatrixInverse.copy(ee.projectionMatrix).invert()}function K(ee,ie){ie===null?ee.matrixWorld.copy(ee.matrix):ee.matrixWorld.multiplyMatrices(ie.matrixWorld,ee.matrix),ee.matrixWorldInverse.copy(ee.matrixWorld).invert()}this.updateCamera=function(ee){if(i===null)return;k.near=T.near=C.near=ee.near,k.far=T.far=C.far=ee.far,(D!==k.near||U!==k.far)&&(i.updateRenderState({depthNear:k.near,depthFar:k.far}),D=k.near,U=k.far);const ie=ee.parent,ae=k.cameras;K(k,ie);for(let de=0;de<ae.length;de++)K(ae[de],ie);ae.length===2?V(k,C,T):k.projectionMatrix.copy(C.projectionMatrix),J(ee,k,ie)};function J(ee,ie,ae){ae===null?ee.matrix.copy(ie.matrixWorld):(ee.matrix.copy(ae.matrixWorld),ee.matrix.invert(),ee.matrix.multiply(ie.matrixWorld)),ee.matrix.decompose(ee.position,ee.quaternion,ee.scale),ee.updateMatrixWorld(!0),ee.projectionMatrix.copy(ie.projectionMatrix),ee.projectionMatrixInverse.copy(ie.projectionMatrixInverse),ee.isPerspectiveCamera&&(ee.fov=hb*2*Math.atan(1/ee.projectionMatrix.elements[5]),ee.zoom=1)}this.getCamera=function(){return k},this.getFoveation=function(){if(!(g===null&&p===null))return c},this.setFoveation=function(ee){c=ee,g!==null&&(g.fixedFoveation=ee),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ee)};let X=null;function F(ee,ie){if(d=ie.getViewerPose(u||o),x=ie,d!==null){const ae=d.views;p!==null&&(e.setRenderTargetFramebuffer(v,p.framebuffer),e.setRenderTarget(v));let de=!1;ae.length!==k.cameras.length&&(k.cameras.length=0,de=!0);for(let ue=0;ue<ae.length;ue++){const le=ae[ue];let he=null;if(p!==null)he=p.getViewport(le);else{const Me=f.getViewSubImage(g,le);he=Me.viewport,ue===0&&(e.setRenderTargetTextures(v,Me.colorTexture,g.ignoreDepthValues?void 0:Me.depthStencilTexture),e.setRenderTarget(v))}let pe=L[ue];pe===void 0&&(pe=new Ns,pe.layers.enable(ue),pe.viewport=new ur,L[ue]=pe),pe.matrix.fromArray(le.transform.matrix),pe.matrix.decompose(pe.position,pe.quaternion,pe.scale),pe.projectionMatrix.fromArray(le.projectionMatrix),pe.projectionMatrixInverse.copy(pe.projectionMatrix).invert(),pe.viewport.set(he.x,he.y,he.width,he.height),ue===0&&(k.matrix.copy(pe.matrix),k.matrix.decompose(k.position,k.quaternion,k.scale)),de===!0&&k.cameras.push(pe)}}for(let ae=0;ae<E.length;ae++){const de=w[ae],ue=E[ae];de!==null&&ue!==void 0&&ue.update(de,ie,u||o)}X&&X(ee,ie),ie.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ie}),x=null}const W=new HQ;W.setAnimationLoop(F),this.setAnimationLoop=function(ee){X=ee},this.dispose=function(){}}}function BUe(t,e){function n(b,v){b.matrixAutoUpdate===!0&&b.updateMatrix(),v.value.copy(b.matrix)}function r(b,v){v.color.getRGB(b.fogColor.value,UQ(t)),v.isFog?(b.fogNear.value=v.near,b.fogFar.value=v.far):v.isFogExp2&&(b.fogDensity.value=v.density)}function i(b,v,E,w,N){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(b,v):v.isMeshToonMaterial?(a(b,v),f(b,v)):v.isMeshPhongMaterial?(a(b,v),d(b,v)):v.isMeshStandardMaterial?(a(b,v),g(b,v),v.isMeshPhysicalMaterial&&p(b,v,N)):v.isMeshMatcapMaterial?(a(b,v),x(b,v)):v.isMeshDepthMaterial?a(b,v):v.isMeshDistanceMaterial?(a(b,v),y(b,v)):v.isMeshNormalMaterial?a(b,v):v.isLineBasicMaterial?(o(b,v),v.isLineDashedMaterial&&l(b,v)):v.isPointsMaterial?c(b,v,E,w):v.isSpriteMaterial?u(b,v):v.isShadowMaterial?(b.color.value.copy(v.color),b.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(b,v){b.opacity.value=v.opacity,v.color&&b.diffuse.value.copy(v.color),v.emissive&&b.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.bumpMap&&(b.bumpMap.value=v.bumpMap,n(v.bumpMap,b.bumpMapTransform),b.bumpScale.value=v.bumpScale,v.side===ls&&(b.bumpScale.value*=-1)),v.normalMap&&(b.normalMap.value=v.normalMap,n(v.normalMap,b.normalMapTransform),b.normalScale.value.copy(v.normalScale),v.side===ls&&b.normalScale.value.negate()),v.displacementMap&&(b.displacementMap.value=v.displacementMap,n(v.displacementMap,b.displacementMapTransform),b.displacementScale.value=v.displacementScale,b.displacementBias.value=v.displacementBias),v.emissiveMap&&(b.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,b.emissiveMapTransform)),v.specularMap&&(b.specularMap.value=v.specularMap,n(v.specularMap,b.specularMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest);const E=e.get(v).envMap;if(E&&(b.envMap.value=E,b.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=v.reflectivity,b.ior.value=v.ior,b.refractionRatio.value=v.refractionRatio),v.lightMap){b.lightMap.value=v.lightMap;const w=t._useLegacyLights===!0?Math.PI:1;b.lightMapIntensity.value=v.lightMapIntensity*w,n(v.lightMap,b.lightMapTransform)}v.aoMap&&(b.aoMap.value=v.aoMap,b.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,b.aoMapTransform))}function o(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform))}function l(b,v){b.dashSize.value=v.dashSize,b.totalSize.value=v.dashSize+v.gapSize,b.scale.value=v.scale}function c(b,v,E,w){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.size.value=v.size*E,b.scale.value=w*.5,v.map&&(b.map.value=v.map,n(v.map,b.uvTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function u(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.rotation.value=v.rotation,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function d(b,v){b.specular.value.copy(v.specular),b.shininess.value=Math.max(v.shininess,1e-4)}function f(b,v){v.gradientMap&&(b.gradientMap.value=v.gradientMap)}function g(b,v){b.metalness.value=v.metalness,v.metalnessMap&&(b.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,b.metalnessMapTransform)),b.roughness.value=v.roughness,v.roughnessMap&&(b.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,b.roughnessMapTransform)),e.get(v).envMap&&(b.envMapIntensity.value=v.envMapIntensity)}function p(b,v,E){b.ior.value=v.ior,v.sheen>0&&(b.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),b.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(b.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,b.sheenColorMapTransform)),v.sheenRoughnessMap&&(b.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,b.sheenRoughnessMapTransform))),v.clearcoat>0&&(b.clearcoat.value=v.clearcoat,b.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(b.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,b.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(b.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===ls&&b.clearcoatNormalScale.value.negate())),v.iridescence>0&&(b.iridescence.value=v.iridescence,b.iridescenceIOR.value=v.iridescenceIOR,b.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(b.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,b.iridescenceMapTransform)),v.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),v.transmission>0&&(b.transmission.value=v.transmission,b.transmissionSamplerMap.value=E.texture,b.transmissionSamplerSize.value.set(E.width,E.height),v.transmissionMap&&(b.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,b.transmissionMapTransform)),b.thickness.value=v.thickness,v.thicknessMap&&(b.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=v.attenuationDistance,b.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(b.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(b.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=v.specularIntensity,b.specularColor.value.copy(v.specularColor),v.specularColorMap&&(b.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,b.specularColorMapTransform)),v.specularIntensityMap&&(b.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,b.specularIntensityMapTransform))}function x(b,v){v.matcap&&(b.matcap.value=v.matcap)}function y(b,v){const E=e.get(v).light;b.referencePosition.value.setFromMatrixPosition(E.matrixWorld),b.nearDistance.value=E.shadow.camera.near,b.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function HUe(t,e,n,r){let i={},a={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(E,w){const N=w.program;r.uniformBlockBinding(E,N)}function u(E,w){let N=i[E.id];N===void 0&&(x(E),N=d(E),i[E.id]=N,E.addEventListener("dispose",b));const A=w.program;r.updateUBOMapping(E,A);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 N=t.createBuffer(),A=E.__size,C=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,N),t.bufferData(t.UNIFORM_BUFFER,A,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,N),N}function f(){for(let E=0;E<l;E++)if(o.indexOf(E)===-1)return o.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],N=E.uniforms,A=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let C=0,T=N.length;C<T;C++){const L=N[C];if(p(L,C,A)===!0){const k=L.__offset,D=Array.isArray(L.value)?L.value:[L.value];let U=0;for(let O=0;O<D.length;O++){const q=D[O],R=y(q);typeof q=="number"?(L.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,k+U,L.__data)):q.isMatrix3?(L.__data[0]=q.elements[0],L.__data[1]=q.elements[1],L.__data[2]=q.elements[2],L.__data[3]=q.elements[0],L.__data[4]=q.elements[3],L.__data[5]=q.elements[4],L.__data[6]=q.elements[5],L.__data[7]=q.elements[0],L.__data[8]=q.elements[6],L.__data[9]=q.elements[7],L.__data[10]=q.elements[8],L.__data[11]=q.elements[0]):(q.toArray(L.__data,U),U+=R.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,k,L.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(E,w,N){const A=E.value;if(N[w]===void 0){if(typeof A=="number")N[w]=A;else{const C=Array.isArray(A)?A:[A],T=[];for(let L=0;L<C.length;L++)T.push(C[L].clone());N[w]=T}return!0}else if(typeof A=="number"){if(N[w]!==A)return N[w]=A,!0}else{const C=Array.isArray(N[w])?N[w]:[N[w]],T=Array.isArray(A)?A:[A];for(let L=0;L<C.length;L++){const k=C[L];if(k.equals(T[L])===!1)return k.copy(T[L]),!0}}return!1}function x(E){const w=E.uniforms;let N=0;const A=16;let C=0;for(let T=0,L=w.length;T<L;T++){const k=w[T],D={boundary:0,storage:0},U=Array.isArray(k.value)?k.value:[k.value];for(let O=0,q=U.length;O<q;O++){const R=U[O],G=y(R);D.boundary+=G.boundary,D.storage+=G.storage}if(k.__data=new Float32Array(D.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=N,T>0){C=N%A;const O=A-C;C!==0&&O-D.boundary<0&&(N+=A-C,k.__offset=N)}N+=D.storage}return C=N%A,C>0&&(N+=A-C),E.__size=N,E.__cache={},this}function y(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 b(E){const w=E.target;w.removeEventListener("dispose",b);const N=o.indexOf(w.__bindingPointIndex);o.splice(N,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function v(){for(const E in i)t.deleteBuffer(i[E]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}class pj{constructor(e={}){const{canvas:n=U4e(),context:r=null,depth:i=!0,stencil:a=!0,alpha:o=!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=o;const p=new Uint32Array(4),x=new Int32Array(4);let y=null,b=null;const v=[],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=la,this._useLegacyLights=!1,this.toneMapping=gd,this.toneMappingExposure=1;const w=this;let N=!1,A=0,C=0,T=null,L=-1,k=null;const D=new ur,U=new ur;let O=null;const q=new Yt(0);let R=0,G=n.width,Y=n.height,V=1,K=null,J=null;const X=new ur(0,0,G,Y),F=new ur(0,0,G,Y);let W=!1;const ee=new p2;let ie=!1,ae=!1,de=null;const ue=new vr,le=new sn,he=new Ie,pe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Me(){return T===null?V:1}let re=r;function We(ge,je){for(let Be=0;Be<ge.length;Be++){const rt=ge[Be],tt=n.getContext(rt,je);if(tt!==null)return tt}return null}try{const ge={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${h2}`),n.addEventListener("webglcontextlost",Fe,!1),n.addEventListener("webglcontextrestored",xe,!1),n.addEventListener("webglcontextcreationerror",ze,!1),re===null){const je=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&je.shift(),re=We(je,ge),re===null)throw We(je)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&re instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),re.getShaderPrecisionFormat===void 0&&(re.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(ge){throw console.error("THREE.WebGLRenderer: "+ge.message),ge}let z,H,se,B,Q,ce,Ce,_e,Ee,$,j,ne,be,we,ve,$e,Ge,Xe,ut,He,me,Je,Ke,Ze;function ct(){z=new J5e(re),H=new W5e(re,z,e),z.init(H),Je=new IUe(re,z,H),se=new OUe(re,z,H),B=new nFe(re),Q=new _Ue,ce=new LUe(re,z,se,Q,H,Je,B),Ce=new K5e(w),_e=new Q5e(w),Ee=new cLe(re,H),Ke=new V5e(re,z,Ee,H),$=new eFe(re,Ee,B,Ke),j=new sFe(re,$,Ee,B),ut=new aFe(re,H,ce),$e=new q5e(Q),ne=new vUe(w,Ce,_e,z,H,Ke,$e),be=new BUe(w,Q),we=new SUe,ve=new CUe(z,H),Xe=new $5e(w,Ce,_e,se,j,g,c),Ge=new DUe(w,j,H),Ze=new HUe(re,B,H,se),He=new G5e(re,z,B,H),me=new tFe(re,z,B,H),B.programs=ne.programs,w.capabilities=H,w.extensions=z,w.properties=Q,w.renderLists=we,w.shadowMap=Ge,w.state=se,w.info=B}ct();const te=new zUe(w,re);this.xr=te,this.getContext=function(){return re},this.getContextAttributes=function(){return re.getContextAttributes()},this.forceContextLoss=function(){const ge=z.get("WEBGL_lose_context");ge&&ge.loseContext()},this.forceContextRestore=function(){const ge=z.get("WEBGL_lose_context");ge&&ge.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(ge){ge!==void 0&&(V=ge,this.setSize(G,Y,!1))},this.getSize=function(ge){return ge.set(G,Y)},this.setSize=function(ge,je,Be=!0){if(te.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}G=ge,Y=je,n.width=Math.floor(ge*V),n.height=Math.floor(je*V),Be===!0&&(n.style.width=ge+"px",n.style.height=je+"px"),this.setViewport(0,0,ge,je)},this.getDrawingBufferSize=function(ge){return ge.set(G*V,Y*V).floor()},this.setDrawingBufferSize=function(ge,je,Be){G=ge,Y=je,V=Be,n.width=Math.floor(ge*Be),n.height=Math.floor(je*Be),this.setViewport(0,0,ge,je)},this.getCurrentViewport=function(ge){return ge.copy(D)},this.getViewport=function(ge){return ge.copy(X)},this.setViewport=function(ge,je,Be,rt){ge.isVector4?X.set(ge.x,ge.y,ge.z,ge.w):X.set(ge,je,Be,rt),se.viewport(D.copy(X).multiplyScalar(V).floor())},this.getScissor=function(ge){return ge.copy(F)},this.setScissor=function(ge,je,Be,rt){ge.isVector4?F.set(ge.x,ge.y,ge.z,ge.w):F.set(ge,je,Be,rt),se.scissor(U.copy(F).multiplyScalar(V).floor())},this.getScissorTest=function(){return W},this.setScissorTest=function(ge){se.setScissorTest(W=ge)},this.setOpaqueSort=function(ge){K=ge},this.setTransparentSort=function(ge){J=ge},this.getClearColor=function(ge){return ge.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor.apply(Xe,arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha.apply(Xe,arguments)},this.clear=function(ge=!0,je=!0,Be=!0){let rt=0;if(ge){let tt=!1;if(T!==null){const yt=T.texture.format;tt=yt===MQ||yt===SQ||yt===wQ}if(tt){const yt=T.texture.type,oe=yt===xd||yt===sd||yt===KO||yt===Wh||yt===vQ||yt===_Q,Ae=Xe.getClearColor(),De=Xe.getClearAlpha(),Oe=Ae.r,ke=Ae.g,st=Ae.b;oe?(p[0]=Oe,p[1]=ke,p[2]=st,p[3]=De,re.clearBufferuiv(re.COLOR,0,p)):(x[0]=Oe,x[1]=ke,x[2]=st,x[3]=De,re.clearBufferiv(re.COLOR,0,x))}else rt|=re.COLOR_BUFFER_BIT}je&&(rt|=re.DEPTH_BUFFER_BIT),Be&&(rt|=re.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),re.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",Fe,!1),n.removeEventListener("webglcontextrestored",xe,!1),n.removeEventListener("webglcontextcreationerror",ze,!1),we.dispose(),ve.dispose(),Q.dispose(),Ce.dispose(),_e.dispose(),j.dispose(),Ke.dispose(),Ze.dispose(),ne.dispose(),te.dispose(),te.removeEventListener("sessionstart",Zt),te.removeEventListener("sessionend",Rt),de&&(de.dispose(),de=null),en.stop()};function Fe(ge){ge.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),N=!0}function xe(){console.log("THREE.WebGLRenderer: Context Restored."),N=!1;const ge=B.autoReset,je=Ge.enabled,Be=Ge.autoUpdate,rt=Ge.needsUpdate,tt=Ge.type;ct(),B.autoReset=ge,Ge.enabled=je,Ge.autoUpdate=Be,Ge.needsUpdate=rt,Ge.type=tt}function ze(ge){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ge.statusMessage)}function Pe(ge){const je=ge.target;je.removeEventListener("dispose",Pe),Se(je)}function Se(ge){Ye(ge),Q.remove(ge)}function Ye(ge){const je=Q.get(ge).programs;je!==void 0&&(je.forEach(function(Be){ne.releaseProgram(Be)}),ge.isShaderMaterial&&ne.releaseShaderCache(ge))}this.renderBufferDirect=function(ge,je,Be,rt,tt,yt){je===null&&(je=pe);const oe=tt.isMesh&&tt.matrixWorld.determinant()<0,Ae=dn(ge,je,Be,rt,tt);se.setMaterial(rt,oe);let De=Be.index,Oe=1;if(rt.wireframe===!0){if(De=$.getWireframeAttribute(Be),De===void 0)return;Oe=2}const ke=Be.drawRange,st=Be.attributes.position;let vt=ke.start*Oe,Ct=(ke.start+ke.count)*Oe;yt!==null&&(vt=Math.max(vt,yt.start*Oe),Ct=Math.min(Ct,(yt.start+yt.count)*Oe)),De!==null?(vt=Math.max(vt,0),Ct=Math.min(Ct,De.count)):st!=null&&(vt=Math.max(vt,0),Ct=Math.min(Ct,st.count));const Nt=Ct-vt;if(Nt<0||Nt===1/0)return;Ke.setup(tt,rt,Ae,Be,De);let Ut,jt=He;if(De!==null&&(Ut=Ee.get(De),jt=me,jt.setIndex(Ut)),tt.isMesh)rt.wireframe===!0?(se.setLineWidth(rt.wireframeLinewidth*Me()),jt.setMode(re.LINES)):jt.setMode(re.TRIANGLES);else if(tt.isLine){let wt=rt.linewidth;wt===void 0&&(wt=1),se.setLineWidth(wt*Me()),tt.isLineSegments?jt.setMode(re.LINES):tt.isLineLoop?jt.setMode(re.LINE_LOOP):jt.setMode(re.LINE_STRIP)}else tt.isPoints?jt.setMode(re.POINTS):tt.isSprite&&jt.setMode(re.TRIANGLES);if(tt.isBatchedMesh)jt.renderMultiDraw(tt._multiDrawStarts,tt._multiDrawCounts,tt._multiDrawCount);else if(tt.isInstancedMesh)jt.renderInstances(vt,Nt,tt.count);else if(Be.isInstancedBufferGeometry){const wt=Be._maxInstanceCount!==void 0?Be._maxInstanceCount:1/0,rn=Math.min(Be.instanceCount,wt);jt.renderInstances(vt,Nt,rn)}else jt.render(vt,Nt)};function dt(ge,je,Be){ge.transparent===!0&&ge.side===Ac&&ge.forceSinglePass===!1?(ge.side=ls,ge.needsUpdate=!0,Qt(ge,je,Be),ge.side=Dd,ge.needsUpdate=!0,Qt(ge,je,Be),ge.side=Ac):Qt(ge,je,Be)}this.compile=function(ge,je,Be=null){Be===null&&(Be=ge),b=ve.get(Be),b.init(),E.push(b),Be.traverseVisible(function(tt){tt.isLight&&tt.layers.test(je.layers)&&(b.pushLight(tt),tt.castShadow&&b.pushShadow(tt))}),ge!==Be&&ge.traverseVisible(function(tt){tt.isLight&&tt.layers.test(je.layers)&&(b.pushLight(tt),tt.castShadow&&b.pushShadow(tt))}),b.setupLights(w._useLegacyLights);const rt=new Set;return ge.traverse(function(tt){const yt=tt.material;if(yt)if(Array.isArray(yt))for(let oe=0;oe<yt.length;oe++){const Ae=yt[oe];dt(Ae,Be,tt),rt.add(Ae)}else dt(yt,Be,tt),rt.add(yt)}),E.pop(),b=null,rt},this.compileAsync=function(ge,je,Be=null){const rt=this.compile(ge,je,Be);return new Promise(tt=>{function yt(){if(rt.forEach(function(oe){Q.get(oe).currentProgram.isReady()&&rt.delete(oe)}),rt.size===0){tt(ge);return}setTimeout(yt,10)}z.get("KHR_parallel_shader_compile")!==null?yt():setTimeout(yt,10)})};let Tt=null;function Et(ge){Tt&&Tt(ge)}function Zt(){en.stop()}function Rt(){en.start()}const en=new HQ;en.setAnimationLoop(Et),typeof self<"u"&&en.setContext(self),this.setAnimationLoop=function(ge){Tt=ge,te.setAnimationLoop(ge),ge===null?en.stop():en.start()},te.addEventListener("sessionstart",Zt),te.addEventListener("sessionend",Rt),this.render=function(ge,je){if(je!==void 0&&je.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;ge.matrixWorldAutoUpdate===!0&&ge.updateMatrixWorld(),je.parent===null&&je.matrixWorldAutoUpdate===!0&&je.updateMatrixWorld(),te.enabled===!0&&te.isPresenting===!0&&(te.cameraAutoUpdate===!0&&te.updateCamera(je),je=te.getCamera()),ge.isScene===!0&&ge.onBeforeRender(w,ge,je,T),b=ve.get(ge,E.length),b.init(),E.push(b),ue.multiplyMatrices(je.projectionMatrix,je.matrixWorldInverse),ee.setFromProjectionMatrix(ue),ae=this.localClippingEnabled,ie=$e.init(this.clippingPlanes,ae),y=we.get(ge,v.length),y.init(),v.push(y),Ln(ge,je,0,w.sortObjects),y.finish(),w.sortObjects===!0&&y.sort(K,J),this.info.render.frame++,ie===!0&&$e.beginShadows();const Be=b.state.shadowsArray;if(Ge.render(Be,ge,je),ie===!0&&$e.endShadows(),this.info.autoReset===!0&&this.info.reset(),Xe.render(y,ge),b.setupLights(w._useLegacyLights),je.isArrayCamera){const rt=je.cameras;for(let tt=0,yt=rt.length;tt<yt;tt++){const oe=rt[tt];Vn(y,ge,oe,oe.viewport)}}else Vn(y,ge,je);T!==null&&(ce.updateMultisampleRenderTarget(T),ce.updateRenderTargetMipmap(T)),ge.isScene===!0&&ge.onAfterRender(w,ge,je),Ke.resetDefaultState(),L=-1,k=null,E.pop(),E.length>0?b=E[E.length-1]:b=null,v.pop(),v.length>0?y=v[v.length-1]:y=null};function Ln(ge,je,Be,rt){if(ge.visible===!1)return;if(ge.layers.test(je.layers)){if(ge.isGroup)Be=ge.renderOrder;else if(ge.isLOD)ge.autoUpdate===!0&&ge.update(je);else if(ge.isLight)b.pushLight(ge),ge.castShadow&&b.pushShadow(ge);else if(ge.isSprite){if(!ge.frustumCulled||ee.intersectsSprite(ge)){rt&&he.setFromMatrixPosition(ge.matrixWorld).applyMatrix4(ue);const oe=j.update(ge),Ae=ge.material;Ae.visible&&y.push(ge,oe,Ae,Be,he.z,null)}}else if((ge.isMesh||ge.isLine||ge.isPoints)&&(!ge.frustumCulled||ee.intersectsObject(ge))){const oe=j.update(ge),Ae=ge.material;if(rt&&(ge.boundingSphere!==void 0?(ge.boundingSphere===null&&ge.computeBoundingSphere(),he.copy(ge.boundingSphere.center)):(oe.boundingSphere===null&&oe.computeBoundingSphere(),he.copy(oe.boundingSphere.center)),he.applyMatrix4(ge.matrixWorld).applyMatrix4(ue)),Array.isArray(Ae)){const De=oe.groups;for(let Oe=0,ke=De.length;Oe<ke;Oe++){const st=De[Oe],vt=Ae[st.materialIndex];vt&&vt.visible&&y.push(ge,oe,vt,Be,he.z,st)}}else Ae.visible&&y.push(ge,oe,Ae,Be,he.z,null)}}const yt=ge.children;for(let oe=0,Ae=yt.length;oe<Ae;oe++)Ln(yt[oe],je,Be,rt)}function Vn(ge,je,Be,rt){const tt=ge.opaque,yt=ge.transmissive,oe=ge.transparent;b.setupLightsView(Be),ie===!0&&$e.setGlobalState(w.clippingPlanes,Be),yt.length>0&&tr(tt,yt,je,Be),rt&&se.viewport(D.copy(rt)),tt.length>0&&gt(tt,je,Be),yt.length>0&&gt(yt,je,Be),oe.length>0&&gt(oe,je,Be),se.buffers.depth.setTest(!0),se.buffers.depth.setMask(!0),se.buffers.color.setMask(!0),se.setPolygonOffset(!1)}function tr(ge,je,Be,rt){if((Be.isScene===!0?Be.overrideMaterial:null)!==null)return;const yt=H.isWebGL2;de===null&&(de=new _f(1,1,{generateMipmaps:!0,type:z.has("EXT_color_buffer_half_float")?ub:xd,minFilter:cb,samples:yt?4:0})),w.getDrawingBufferSize(le),yt?de.setSize(le.x,le.y):de.setSize(sS(le.x),sS(le.y));const oe=w.getRenderTarget();w.setRenderTarget(de),w.getClearColor(q),R=w.getClearAlpha(),R<1&&w.setClearColor(16777215,.5),w.clear();const Ae=w.toneMapping;w.toneMapping=gd,gt(ge,Be,rt),ce.updateMultisampleRenderTarget(de),ce.updateRenderTargetMipmap(de);let De=!1;for(let Oe=0,ke=je.length;Oe<ke;Oe++){const st=je[Oe],vt=st.object,Ct=st.geometry,Nt=st.material,Ut=st.group;if(Nt.side===Ac&&vt.layers.test(rt.layers)){const jt=Nt.side;Nt.side=ls,Nt.needsUpdate=!0,Vt(vt,Be,rt,Ct,Nt,Ut),Nt.side=jt,Nt.needsUpdate=!0,De=!0}}De===!0&&(ce.updateMultisampleRenderTarget(de),ce.updateRenderTargetMipmap(de)),w.setRenderTarget(oe),w.setClearColor(q,R),w.toneMapping=Ae}function gt(ge,je,Be){const rt=je.isScene===!0?je.overrideMaterial:null;for(let tt=0,yt=ge.length;tt<yt;tt++){const oe=ge[tt],Ae=oe.object,De=oe.geometry,Oe=rt===null?oe.material:rt,ke=oe.group;Ae.layers.test(Be.layers)&&Vt(Ae,je,Be,De,Oe,ke)}}function Vt(ge,je,Be,rt,tt,yt){ge.onBeforeRender(w,je,Be,rt,tt,yt),ge.modelViewMatrix.multiplyMatrices(Be.matrixWorldInverse,ge.matrixWorld),ge.normalMatrix.getNormalMatrix(ge.modelViewMatrix),tt.onBeforeRender(w,je,Be,rt,ge,yt),tt.transparent===!0&&tt.side===Ac&&tt.forceSinglePass===!1?(tt.side=ls,tt.needsUpdate=!0,w.renderBufferDirect(Be,je,rt,tt,ge,yt),tt.side=Dd,tt.needsUpdate=!0,w.renderBufferDirect(Be,je,rt,tt,ge,yt),tt.side=Ac):w.renderBufferDirect(Be,je,rt,tt,ge,yt),ge.onAfterRender(w,je,Be,rt,tt,yt)}function Qt(ge,je,Be){je.isScene!==!0&&(je=pe);const rt=Q.get(ge),tt=b.state.lights,yt=b.state.shadowsArray,oe=tt.state.version,Ae=ne.getParameters(ge,tt.state,yt,je,Be),De=ne.getProgramCacheKey(Ae);let Oe=rt.programs;rt.environment=ge.isMeshStandardMaterial?je.environment:null,rt.fog=je.fog,rt.envMap=(ge.isMeshStandardMaterial?_e:Ce).get(ge.envMap||rt.environment),Oe===void 0&&(ge.addEventListener("dispose",Pe),Oe=new Map,rt.programs=Oe);let ke=Oe.get(De);if(ke!==void 0){if(rt.currentProgram===ke&&rt.lightsStateVersion===oe)return Kt(ge,Ae),ke}else Ae.uniforms=ne.getUniforms(ge),ge.onBuild(Be,Ae,w),ge.onBeforeCompile(Ae,w),ke=ne.acquireProgram(Ae,De),Oe.set(De,ke),rt.uniforms=Ae.uniforms;const st=rt.uniforms;return(!ge.isShaderMaterial&&!ge.isRawShaderMaterial||ge.clipping===!0)&&(st.clippingPlanes=$e.uniform),Kt(ge,Ae),rt.needsLights=Re(ge),rt.lightsStateVersion=oe,rt.needsLights&&(st.ambientLightColor.value=tt.state.ambient,st.lightProbe.value=tt.state.probe,st.directionalLights.value=tt.state.directional,st.directionalLightShadows.value=tt.state.directionalShadow,st.spotLights.value=tt.state.spot,st.spotLightShadows.value=tt.state.spotShadow,st.rectAreaLights.value=tt.state.rectArea,st.ltc_1.value=tt.state.rectAreaLTC1,st.ltc_2.value=tt.state.rectAreaLTC2,st.pointLights.value=tt.state.point,st.pointLightShadows.value=tt.state.pointShadow,st.hemisphereLights.value=tt.state.hemi,st.directionalShadowMap.value=tt.state.directionalShadowMap,st.directionalShadowMatrix.value=tt.state.directionalShadowMatrix,st.spotShadowMap.value=tt.state.spotShadowMap,st.spotLightMatrix.value=tt.state.spotLightMatrix,st.spotLightMap.value=tt.state.spotLightMap,st.pointShadowMap.value=tt.state.pointShadowMap,st.pointShadowMatrix.value=tt.state.pointShadowMatrix),rt.currentProgram=ke,rt.uniformsList=null,ke}function mt(ge){if(ge.uniformsList===null){const je=ge.currentProgram.getUniforms();ge.uniformsList=O1.seqWithValue(je.seq,ge.uniforms)}return ge.uniformsList}function Kt(ge,je){const Be=Q.get(ge);Be.outputColorSpace=je.outputColorSpace,Be.batching=je.batching,Be.instancing=je.instancing,Be.instancingColor=je.instancingColor,Be.skinning=je.skinning,Be.morphTargets=je.morphTargets,Be.morphNormals=je.morphNormals,Be.morphColors=je.morphColors,Be.morphTargetsCount=je.morphTargetsCount,Be.numClippingPlanes=je.numClippingPlanes,Be.numIntersection=je.numClipIntersection,Be.vertexAlphas=je.vertexAlphas,Be.vertexTangents=je.vertexTangents,Be.toneMapping=je.toneMapping}function dn(ge,je,Be,rt,tt){je.isScene!==!0&&(je=pe),ce.resetTextureUnits();const yt=je.fog,oe=rt.isMeshStandardMaterial?je.environment:null,Ae=T===null?w.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:eu,De=(rt.isMeshStandardMaterial?_e:Ce).get(rt.envMap||oe),Oe=rt.vertexColors===!0&&!!Be.attributes.color&&Be.attributes.color.itemSize===4,ke=!!Be.attributes.tangent&&(!!rt.normalMap||rt.anisotropy>0),st=!!Be.morphAttributes.position,vt=!!Be.morphAttributes.normal,Ct=!!Be.morphAttributes.color;let Nt=gd;rt.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(Nt=w.toneMapping);const Ut=Be.morphAttributes.position||Be.morphAttributes.normal||Be.morphAttributes.color,jt=Ut!==void 0?Ut.length:0,wt=Q.get(rt),rn=b.state.lights;if(ie===!0&&(ae===!0||ge!==k)){const Yr=ge===k&&rt.id===L;$e.setState(rt,ge,Yr)}let Gt=!1;rt.version===wt.__version?(wt.needsLights&&wt.lightsStateVersion!==rn.state.version||wt.outputColorSpace!==Ae||tt.isBatchedMesh&&wt.batching===!1||!tt.isBatchedMesh&&wt.batching===!0||tt.isInstancedMesh&&wt.instancing===!1||!tt.isInstancedMesh&&wt.instancing===!0||tt.isSkinnedMesh&&wt.skinning===!1||!tt.isSkinnedMesh&&wt.skinning===!0||tt.isInstancedMesh&&wt.instancingColor===!0&&tt.instanceColor===null||tt.isInstancedMesh&&wt.instancingColor===!1&&tt.instanceColor!==null||wt.envMap!==De||rt.fog===!0&&wt.fog!==yt||wt.numClippingPlanes!==void 0&&(wt.numClippingPlanes!==$e.numPlanes||wt.numIntersection!==$e.numIntersection)||wt.vertexAlphas!==Oe||wt.vertexTangents!==ke||wt.morphTargets!==st||wt.morphNormals!==vt||wt.morphColors!==Ct||wt.toneMapping!==Nt||H.isWebGL2===!0&&wt.morphTargetsCount!==jt)&&(Gt=!0):(Gt=!0,wt.__version=rt.version);let mn=wt.currentProgram;Gt===!0&&(mn=Qt(rt,je,tt));let wn=!1,Cn=!1,$t=!1;const on=mn.getUniforms(),un=wt.uniforms;if(se.useProgram(mn.program)&&(wn=!0,Cn=!0,$t=!0),rt.id!==L&&(L=rt.id,Cn=!0),wn||k!==ge){on.setValue(re,"projectionMatrix",ge.projectionMatrix),on.setValue(re,"viewMatrix",ge.matrixWorldInverse);const Yr=on.map.cameraPosition;Yr!==void 0&&Yr.setValue(re,he.setFromMatrixPosition(ge.matrixWorld)),H.logarithmicDepthBuffer&&on.setValue(re,"logDepthBufFC",2/(Math.log(ge.far+1)/Math.LN2)),(rt.isMeshPhongMaterial||rt.isMeshToonMaterial||rt.isMeshLambertMaterial||rt.isMeshBasicMaterial||rt.isMeshStandardMaterial||rt.isShaderMaterial)&&on.setValue(re,"isOrthographic",ge.isOrthographicCamera===!0),k!==ge&&(k=ge,Cn=!0,$t=!0)}if(tt.isSkinnedMesh){on.setOptional(re,tt,"bindMatrix"),on.setOptional(re,tt,"bindMatrixInverse");const Yr=tt.skeleton;Yr&&(H.floatVertexTextures?(Yr.boneTexture===null&&Yr.computeBoneTexture(),on.setValue(re,"boneTexture",Yr.boneTexture,ce)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}tt.isBatchedMesh&&(on.setOptional(re,tt,"batchingTexture"),on.setValue(re,"batchingTexture",tt._matricesTexture,ce));const Ur=Be.morphAttributes;if((Ur.position!==void 0||Ur.normal!==void 0||Ur.color!==void 0&&H.isWebGL2===!0)&&ut.update(tt,Be,mn),(Cn||wt.receiveShadow!==tt.receiveShadow)&&(wt.receiveShadow=tt.receiveShadow,on.setValue(re,"receiveShadow",tt.receiveShadow)),rt.isMeshGouraudMaterial&&rt.envMap!==null&&(un.envMap.value=De,un.flipEnvMap.value=De.isCubeTexture&&De.isRenderTargetTexture===!1?-1:1),Cn&&(on.setValue(re,"toneMappingExposure",w.toneMappingExposure),wt.needsLights&&Ht(un,$t),yt&&rt.fog===!0&&be.refreshFogUniforms(un,yt),be.refreshMaterialUniforms(un,rt,V,Y,de),O1.upload(re,mt(wt),un,ce)),rt.isShaderMaterial&&rt.uniformsNeedUpdate===!0&&(O1.upload(re,mt(wt),un,ce),rt.uniformsNeedUpdate=!1),rt.isSpriteMaterial&&on.setValue(re,"center",tt.center),on.setValue(re,"modelViewMatrix",tt.modelViewMatrix),on.setValue(re,"normalMatrix",tt.normalMatrix),on.setValue(re,"modelMatrix",tt.matrixWorld),rt.isShaderMaterial||rt.isRawShaderMaterial){const Yr=rt.uniformsGroups;for(let Gn=0,Mo=Yr.length;Gn<Mo;Gn++)if(H.isWebGL2){const qn=Yr[Gn];Ze.update(qn,mn),Ze.bind(qn,mn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return mn}function Ht(ge,je){ge.ambientLightColor.needsUpdate=je,ge.lightProbe.needsUpdate=je,ge.directionalLights.needsUpdate=je,ge.directionalLightShadows.needsUpdate=je,ge.pointLights.needsUpdate=je,ge.pointLightShadows.needsUpdate=je,ge.spotLights.needsUpdate=je,ge.spotLightShadows.needsUpdate=je,ge.rectAreaLights.needsUpdate=je,ge.hemisphereLights.needsUpdate=je}function Re(ge){return ge.isMeshLambertMaterial||ge.isMeshToonMaterial||ge.isMeshPhongMaterial||ge.isMeshStandardMaterial||ge.isShadowMaterial||ge.isShaderMaterial&&ge.lights===!0}this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(ge,je,Be){Q.get(ge.texture).__webglTexture=je,Q.get(ge.depthTexture).__webglTexture=Be;const rt=Q.get(ge);rt.__hasExternalTextures=!0,rt.__hasExternalTextures&&(rt.__autoAllocateDepthBuffer=Be===void 0,rt.__autoAllocateDepthBuffer||z.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(ge,je){const Be=Q.get(ge);Be.__webglFramebuffer=je,Be.__useDefaultFramebuffer=je===void 0},this.setRenderTarget=function(ge,je=0,Be=0){T=ge,A=je,C=Be;let rt=!0,tt=null,yt=!1,oe=!1;if(ge){const De=Q.get(ge);De.__useDefaultFramebuffer!==void 0?(se.bindFramebuffer(re.FRAMEBUFFER,null),rt=!1):De.__webglFramebuffer===void 0?ce.setupRenderTarget(ge):De.__hasExternalTextures&&ce.rebindTextures(ge,Q.get(ge.texture).__webglTexture,Q.get(ge.depthTexture).__webglTexture);const Oe=ge.texture;(Oe.isData3DTexture||Oe.isDataArrayTexture||Oe.isCompressedArrayTexture)&&(oe=!0);const ke=Q.get(ge).__webglFramebuffer;ge.isWebGLCubeRenderTarget?(Array.isArray(ke[je])?tt=ke[je][Be]:tt=ke[je],yt=!0):H.isWebGL2&&ge.samples>0&&ce.useMultisampledRTT(ge)===!1?tt=Q.get(ge).__webglMultisampledFramebuffer:Array.isArray(ke)?tt=ke[Be]:tt=ke,D.copy(ge.viewport),U.copy(ge.scissor),O=ge.scissorTest}else D.copy(X).multiplyScalar(V).floor(),U.copy(F).multiplyScalar(V).floor(),O=W;if(se.bindFramebuffer(re.FRAMEBUFFER,tt)&&H.drawBuffers&&rt&&se.drawBuffers(ge,tt),se.viewport(D),se.scissor(U),se.setScissorTest(O),yt){const De=Q.get(ge.texture);re.framebufferTexture2D(re.FRAMEBUFFER,re.COLOR_ATTACHMENT0,re.TEXTURE_CUBE_MAP_POSITIVE_X+je,De.__webglTexture,Be)}else if(oe){const De=Q.get(ge.texture),Oe=je||0;re.framebufferTextureLayer(re.FRAMEBUFFER,re.COLOR_ATTACHMENT0,De.__webglTexture,Be||0,Oe)}L=-1},this.readRenderTargetPixels=function(ge,je,Be,rt,tt,yt,oe){if(!(ge&&ge.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ae=Q.get(ge).__webglFramebuffer;if(ge.isWebGLCubeRenderTarget&&oe!==void 0&&(Ae=Ae[oe]),Ae){se.bindFramebuffer(re.FRAMEBUFFER,Ae);try{const De=ge.texture,Oe=De.format,ke=De.type;if(Oe!==oo&&Je.convert(Oe)!==re.getParameter(re.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const st=ke===ub&&(z.has("EXT_color_buffer_half_float")||H.isWebGL2&&z.has("EXT_color_buffer_float"));if(ke!==xd&&Je.convert(ke)!==re.getParameter(re.IMPLEMENTATION_COLOR_READ_TYPE)&&!(ke===Rc&&(H.isWebGL2||z.has("OES_texture_float")||z.has("WEBGL_color_buffer_float")))&&!st){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}je>=0&&je<=ge.width-rt&&Be>=0&&Be<=ge.height-tt&&re.readPixels(je,Be,rt,tt,Je.convert(Oe),Je.convert(ke),yt)}finally{const De=T!==null?Q.get(T).__webglFramebuffer:null;se.bindFramebuffer(re.FRAMEBUFFER,De)}}},this.copyFramebufferToTexture=function(ge,je,Be=0){const rt=Math.pow(2,-Be),tt=Math.floor(je.image.width*rt),yt=Math.floor(je.image.height*rt);ce.setTexture2D(je,0),re.copyTexSubImage2D(re.TEXTURE_2D,Be,0,0,ge.x,ge.y,tt,yt),se.unbindTexture()},this.copyTextureToTexture=function(ge,je,Be,rt=0){const tt=je.image.width,yt=je.image.height,oe=Je.convert(Be.format),Ae=Je.convert(Be.type);ce.setTexture2D(Be,0),re.pixelStorei(re.UNPACK_FLIP_Y_WEBGL,Be.flipY),re.pixelStorei(re.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Be.premultiplyAlpha),re.pixelStorei(re.UNPACK_ALIGNMENT,Be.unpackAlignment),je.isDataTexture?re.texSubImage2D(re.TEXTURE_2D,rt,ge.x,ge.y,tt,yt,oe,Ae,je.image.data):je.isCompressedTexture?re.compressedTexSubImage2D(re.TEXTURE_2D,rt,ge.x,ge.y,je.mipmaps[0].width,je.mipmaps[0].height,oe,je.mipmaps[0].data):re.texSubImage2D(re.TEXTURE_2D,rt,ge.x,ge.y,oe,Ae,je.image),rt===0&&Be.generateMipmaps&&re.generateMipmap(re.TEXTURE_2D),se.unbindTexture()},this.copyTextureToTexture3D=function(ge,je,Be,rt,tt=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const yt=ge.max.x-ge.min.x+1,oe=ge.max.y-ge.min.y+1,Ae=ge.max.z-ge.min.z+1,De=Je.convert(rt.format),Oe=Je.convert(rt.type);let ke;if(rt.isData3DTexture)ce.setTexture3D(rt,0),ke=re.TEXTURE_3D;else if(rt.isDataArrayTexture)ce.setTexture2DArray(rt,0),ke=re.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}re.pixelStorei(re.UNPACK_FLIP_Y_WEBGL,rt.flipY),re.pixelStorei(re.UNPACK_PREMULTIPLY_ALPHA_WEBGL,rt.premultiplyAlpha),re.pixelStorei(re.UNPACK_ALIGNMENT,rt.unpackAlignment);const st=re.getParameter(re.UNPACK_ROW_LENGTH),vt=re.getParameter(re.UNPACK_IMAGE_HEIGHT),Ct=re.getParameter(re.UNPACK_SKIP_PIXELS),Nt=re.getParameter(re.UNPACK_SKIP_ROWS),Ut=re.getParameter(re.UNPACK_SKIP_IMAGES),jt=Be.isCompressedTexture?Be.mipmaps[0]:Be.image;re.pixelStorei(re.UNPACK_ROW_LENGTH,jt.width),re.pixelStorei(re.UNPACK_IMAGE_HEIGHT,jt.height),re.pixelStorei(re.UNPACK_SKIP_PIXELS,ge.min.x),re.pixelStorei(re.UNPACK_SKIP_ROWS,ge.min.y),re.pixelStorei(re.UNPACK_SKIP_IMAGES,ge.min.z),Be.isDataTexture||Be.isData3DTexture?re.texSubImage3D(ke,tt,je.x,je.y,je.z,yt,oe,Ae,De,Oe,jt.data):Be.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),re.compressedTexSubImage3D(ke,tt,je.x,je.y,je.z,yt,oe,Ae,De,jt.data)):re.texSubImage3D(ke,tt,je.x,je.y,je.z,yt,oe,Ae,De,Oe,jt),re.pixelStorei(re.UNPACK_ROW_LENGTH,st),re.pixelStorei(re.UNPACK_IMAGE_HEIGHT,vt),re.pixelStorei(re.UNPACK_SKIP_PIXELS,Ct),re.pixelStorei(re.UNPACK_SKIP_ROWS,Nt),re.pixelStorei(re.UNPACK_SKIP_IMAGES,Ut),tt===0&&rt.generateMipmaps&&re.generateMipmap(ke),se.unbindTexture()},this.initTexture=function(ge){ge.isCubeTexture?ce.setTextureCube(ge,0):ge.isData3DTexture?ce.setTexture3D(ge,0):ge.isDataArrayTexture||ge.isCompressedArrayTexture?ce.setTexture2DArray(ge,0):ce.setTexture2D(ge,0),se.unbindTexture()},this.resetState=function(){A=0,C=0,T=null,se.reset(),Ke.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return yl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===XO?"display-p3":"srgb",n.unpackColorSpace=lr.workingColorSpace===m2?"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===la?Kh:AQ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Kh?la:eu}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 $Ue extends pj{}$Ue.prototype.isWebGL1Renderer=!0;class t4{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new Yt(e),this.near=n,this.far=r}clone(){return new t4(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class VUe extends Fa{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 GUe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=dj,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=zc()}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=zc()),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=zc()),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 Pa=new Ie;class od{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++)Pa.fromBufferAttribute(this,n),Pa.applyMatrix4(e),this.setXYZ(n,Pa.x,Pa.y,Pa.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Pa.fromBufferAttribute(this,n),Pa.applyNormalMatrix(e),this.setXYZ(n,Pa.x,Pa.y,Pa.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Pa.fromBufferAttribute(this,n),Pa.transformDirection(e),this.setXYZ(n,Pa.x,Pa.y,Pa.z);return this}setX(e,n){return this.normalized&&(n=or(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=or(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=or(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=or(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=pl(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=pl(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=pl(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=pl(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=or(n,this.array),r=or(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=or(n,this.array),r=or(r,this.array),i=or(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=or(n,this.array),r=or(r,this.array),i=or(i,this.array),a=or(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 Ds(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 od(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 WUe extends cs{constructor(e=null,n=1,r=1,i,a,o,l,c,u=oa,d=oa,f,g){super(null,o,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 qUe(t,e){return t.z-e.z}function KUe(t,e){return e.z-t.z}class XUe{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 Ym="batchId",Bu=new vr,XV=new vr,YUe=new vr,YV=new vr,YC=new p2,V_=new go,bh=new wl,Wx=new Ie,ZC=new XUe,ya=new Bo,G_=[];function ZUe(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 o=0;o<r;o++)e.setComponent(a+n,o,t.getComponent(a,o))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class QUe extends Bo{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new Ta,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 WUe(n,e,e,oo,Rc);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 Ds(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Ym,new Ds(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Ym))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Ym}"`);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===Ym)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 go);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,Bu),this.getBoundingBoxAt(i,V_).applyMatrix4(Bu),n.union(V_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new wl);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,Bu),this.getBoundingSphereAt(i,bh).applyMatrix4(Bu),n.union(bh))}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 o=this._reservedRanges,l=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(a=o[o.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,a===null?i.vertexStart=0:i.vertexStart=a.vertexStart+a.vertexCount;const u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.count:i.indexCount=r,a===null?i.indexStart=0:i.indexStart=a.indexStart+a.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const f=this._visibility,g=this._active,p=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),g.push(!0);const y=this._geometryCount;this._geometryCount++,YUe.toArray(x,y*16),p.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new go,sphereInitialized:!1,sphere:new wl});const b=this.geometry.getAttribute(Ym);for(let v=0;v<i.vertexCount;v++)b.setX(i.vertexStart+v,y);return b.needsUpdate=!0,this.setGeometryAt(y,e),y}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(),o=n.getIndex(),l=this._reservedRanges[e];if(i&&o.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===Ym)continue;const x=n.getAttribute(p),y=r.getAttribute(p);ZUe(x,y,c);const b=x.itemSize;for(let v=x.count,E=u;v<E;v++){const w=c+v;for(let N=0;N<b;N++)y.setComponent(w,N,0)}y.needsUpdate=!0}if(i){const p=l.indexStart;for(let x=0;x<o.count;x++)a.setX(p+x,c+o.getX(x));for(let x=o.count,y=l.indexCount;x<y;x++)a.setX(p+x,c);a.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],g=n.getAttribute("position");return f.count=i?o.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,o=this.geometry;if(i.boxInitialized===!1){a.makeEmpty();const l=o.index,c=o.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(Wx.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,o=this.geometry;if(i.sphereInitialized===!1){a.makeEmpty(),this.getBoundingBoxAt(e,V_),V_.getCenter(a.center);const l=o.index,c=o.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)),Wx.fromBufferAttribute(c,p),d=Math.max(d,a.center.distanceToSquared(Wx))}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,o=this._geometryCount;return e>=o||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,o=this._geometryCount,l=this.matrixWorld,c=this.geometry;ya.material=this.material,ya.geometry.index=c.index,ya.geometry.attributes=c.attributes,ya.geometry.boundingBox===null&&(ya.geometry.boundingBox=new go),ya.geometry.boundingSphere===null&&(ya.geometry.boundingSphere=new wl);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=a[u];ya.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,ya.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,ya.geometry.boundingBox),this.getBoundingSphereAt(u,ya.geometry.boundingSphere),ya.raycast(e,G_);for(let f=0,g=G_.length;f<g;f++){const p=G_[f];p.object=this,p.batchId=u,n.push(p)}G_.length=0}ya.material=null,ya.geometry.index=null,ya.geometry.attributes={},ya.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 o=i.getIndex(),l=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,g=this.perObjectFrustumCulled;g&&(YV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),YC.setFromProjectionMatrix(YV,e.isWebGPURenderer?db:yl));let p=0;if(this.sortObjects){XV.copy(this.matrixWorld).invert(),Wx.setFromMatrixPosition(r.matrixWorld).applyMatrix4(XV);for(let b=0,v=c.length;b<v;b++)if(c[b]){this.getMatrixAt(b,Bu),this.getBoundingSphereAt(b,bh).applyMatrix4(Bu);let E=!1;if(g&&(E=!YC.intersectsSphere(bh)),!E){const w=Wx.distanceTo(bh.center);ZC.push(f[b],w)}}const x=ZC.list,y=this.customSort;y===null?x.sort(a.transparent?KUe:qUe):y.call(this,x,r);for(let b=0,v=x.length;b<v;b++){const E=x[b];u[p]=E.start*l,d[p]=E.count,p++}ZC.reset()}else for(let x=0,y=c.length;x<y;x++)if(c[x]){let b=!1;if(g&&(this.getMatrixAt(x,Bu),this.getBoundingSphereAt(x,bh).applyMatrix4(Bu),b=!YC.intersectsSphere(bh)),!b){const v=f[x];u[p]=v.start*l,d[p]=v.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,o){this.onBeforeRender(e,null,i,a,o)}}class hy extends Tg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Yt(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 ZV=new Ie,QV=new Ie,JV=new vr,QC=new ZO,W_=new wl;class JUe extends Fa{constructor(e=new Ta,n=new hy){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++)ZV.fromBufferAttribute(n,i-1),QV.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=ZV.distanceTo(QV);e.setAttribute("lineDistance",new ni(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,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),W_.copy(r.boundingSphere),W_.applyMatrix4(i),W_.radius+=a,e.ray.intersectsSphere(W_)===!1)return;JV.copy(i).invert(),QC.copy(e.ray).applyMatrix4(JV);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new Ie,d=new Ie,f=new Ie,g=new Ie,p=this.isLineSegments?2:1,x=r.index,b=r.attributes.position;if(x!==null){const v=Math.max(0,o.start),E=Math.min(x.count,o.start+o.count);for(let w=v,N=E-1;w<N;w+=p){const A=x.getX(w),C=x.getX(w+1);if(u.fromBufferAttribute(b,A),d.fromBufferAttribute(b,C),QC.distanceSqToSegment(u,d,g,f)>c)continue;g.applyMatrix4(this.matrixWorld);const L=e.ray.origin.distanceTo(g);L<e.near||L>e.far||n.push({distance:L,point:f.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,o.start),E=Math.min(b.count,o.start+o.count);for(let w=v,N=E-1;w<N;w+=p){if(u.fromBufferAttribute(b,w),d.fromBufferAttribute(b,w+1),QC.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,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}}const eG=new Ie,tG=new Ie;class x2 extends JUe{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)eG.fromBufferAttribute(n,i),tG.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+eG.distanceTo(tG);e.setAttribute("lineDistance",new ni(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class eze extends Ta{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new Ie,a=new Ie;if(e.index!==null){const o=e.attributes.position,l=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:l.count,materialIndex:0}]);for(let u=0,d=c.length;u<d;++u){const f=c[u],g=f.start,p=f.count;for(let x=g,y=g+p;x<y;x+=3)for(let b=0;b<3;b++){const v=l.getX(x+b),E=l.getX(x+(b+1)%3);i.fromBufferAttribute(o,v),a.fromBufferAttribute(o,E),nG(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}}else{const o=e.attributes.position;for(let l=0,c=o.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(o,d),a.fromBufferAttribute(o,f),nG(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new ni(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function nG(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 tze extends Tg{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Yt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=NQ,this.normalScale=new sn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=qO,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 nze extends hy{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 XQ extends Fa{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Yt(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 JC=new vr,rG=new Ie,iG=new Ie;class rze{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new sn(512,512),this.map=null,this.mapPass=null,this.matrix=new vr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new p2,this._frameExtents=new sn(1,1),this._viewportCount=1,this._viewports=[new ur(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;rG.setFromMatrixPosition(e.matrixWorld),n.position.copy(rG),iG.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(iG),n.updateMatrixWorld(),JC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(JC),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(JC)}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 aG=new vr,qx=new Ie,ek=new Ie;class ize extends rze{constructor(){super(new Ns(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new sn(4,2),this._viewportCount=6,this._viewports=[new ur(2,1,1,1),new ur(0,1,1,1),new ur(3,1,1,1),new ur(1,1,1,1),new ur(3,0,1,1),new ur(1,0,1,1)],this._cubeDirections=[new Ie(1,0,0),new Ie(-1,0,0),new Ie(0,0,1),new Ie(0,0,-1),new Ie(0,1,0),new Ie(0,-1,0)],this._cubeUps=[new Ie(0,1,0),new Ie(0,1,0),new Ie(0,1,0),new Ie(0,1,0),new Ie(0,0,1),new Ie(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()),qx.setFromMatrixPosition(e.matrixWorld),r.position.copy(qx),ek.copy(r.position),ek.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(ek),r.updateMatrixWorld(),i.makeTranslation(-qx.x,-qx.y,-qx.z),aG.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(aG)}}class aze extends XQ{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 ize}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 sze extends XQ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class oze extends Ta{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 gj extends GUe{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 sG{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(ca(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const oG=new Ie,q_=new Ie;class lze{constructor(e=new Ie,n=new Ie){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){oG.subVectors(e,this.start),q_.subVectors(this.end,this.start);const r=q_.dot(q_);let a=q_.dot(oG)/r;return n&&(a=ca(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 cze extends x2{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 Ta;i.setAttribute("position",new ni(n,3)),i.setAttribute("color",new ni(r,3));const a=new hy({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new Yt,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:h2}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=h2);class Sl{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"),Sl.nextNameID=Sl.nextNameID||0,this.$name.id=`lil-gui-name-${++Sl.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",o=>o.stopPropagation()),this.domElement.addEventListener("keyup",o=>o.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 uze extends Sl{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 xj(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 dze={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:xj,toHexString:xj},fb={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},hze={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=fb.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 fb.toHexString(i)}},fze={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=fb.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 fb.toHexString(i)}},mze=[dze,fb,hze,fze];function pze(t){return mze.find(e=>e.match(t))}class gze extends Sl{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=pze(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=xj(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 tk extends Sl{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 xze extends Sl{constructor(e,n,r,i,a,o){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(a);const l=o!==void 0;this.step(l?o: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 o=!1,l,c,u,d,f;const g=5,p=E=>{l=E.clientX,c=u=E.clientY,o=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",y)},x=E=>{if(o){const w=E.clientX-l,N=E.clientY-c;Math.abs(N)>g?(E.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(w)>g&&y()}if(!o){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},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",y)},b=()=>{this._inputFocused=!0},v=()=>{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",b),this.$input.addEventListener("blur",v)}_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=(v,E,w,N,A)=>(v-E)/(w-E)*(A-N)+N,n=v=>{const E=this.$slider.getBoundingClientRect();let w=e(v,E.left,E.right,this._min,this._max);this._snapClampSetValue(w)},r=v=>{this._setDraggingStyle(!0),n(v.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=v=>{n(v.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let o=!1,l,c;const u=v=>{v.preventDefault(),this._setDraggingStyle(!0),n(v.touches[0].clientX),o=!1},d=v=>{v.touches.length>1||(this._hasScrollBar?(l=v.touches[0].clientX,c=v.touches[0].clientY,o=!0):u(v),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",g))},f=v=>{if(o){const E=v.touches[0].clientX-l,w=v.touches[0].clientY-c;Math.abs(E)>Math.abs(w)?u(v):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g))}else v.preventDefault(),n(v.touches[0].clientX)},g=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g)},p=this._callOnFinishChange.bind(this),x=400;let y;const b=v=>{if(Math.abs(v.deltaX)<Math.abs(v.deltaY)&&this._hasScrollBar)return;v.preventDefault();const w=this._normalizeMouseWheel(v)*this._step;this._snapClampSetValue(this.getValue()+w),this.$input.value=this.getValue(),clearTimeout(y),y=setTimeout(p,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",b,{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 bze extends Sl{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 yze extends Sl{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 vze=`.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 _ze(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 lG=!1;class lS{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:a="Controls",closeFolders:o=!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"),!lG&&l&&(_ze(vze),lG=!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=o}add(e,n,r,i,a){if(Object(r)===r)return new bze(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new xze(this,e,n,r,i,a);case"boolean":return new uze(this,e,n);case"string":return new yze(this,e,n);case"function":return new tk(this,e,n)}console.error(`gui.add failed
  7892. property:`,n,`
  7893. object:`,e,`
  7894. value:`,o)}addColor(e,n,r=1){return new gze(this,e,n,r)}addFolder(e){const n=new lS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof tk||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 tk)){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 nk(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(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(o,l)}c((r=r.apply(t,[])).next())}))}class n4{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 n4(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 r4{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class cG extends r4{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Hu extends r4{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class uG{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class cS{constructor(e){this.lines=[],this.preamble=new uG(-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,o]of Object.entries(i))this.metadata.thumbnails[a]=o;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],o=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 cG(e,c,u,o);case"t0":return new Hu(e,c,o,0);case"t1":return new Hu(e,c,o,1);case"t2":return new Hu(e,c,o,2);case"t3":return new Hu(e,c,o,3);case"t4":return new Hu(e,c,o,4);case"t5":return new Hu(e,c,o,5);case"t6":return new Hu(e,c,o,6);case"t7":return new Hu(e,c,o,7);default:return new r4(e,c,u,o)}}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 o=a[i-1];return o=o.toLowerCase(),this.isAlpha(o)&&(n[o]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof cG){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 o=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new uG(this.layers.length,[],r,o))}}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 o=a.indexOf("thumbnail begin"),l=a.indexOf("thumbnail end");o>-1?r=n4.parse(a.slice(o+15).trim()):r&&(l==-1?r.chars+=a.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}cS.prototype.parseGcode=cS.prototype.parseGCode;const dG={type:"change"},rk={type:"start"},hG={type:"end"},K_=new ZO,fG=new Xu,wze=Math.cos(70*CQ.DEG2RAD);class Sze extends Rf{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Ie,this.cursor=new Ie,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:jm.ROTATE,MIDDLE:jm.DOLLY,RIGHT:jm.PAN},this.touches={ONE:Rm.ROTATE,TWO:Rm.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(H){H.addEventListener("keydown",Me),this._domElementKeyEvents=H},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Me),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(dG),r.update(),a=i.NONE},this.update=(function(){const H=new Ie,se=new wf().setFromUnitVectors(e.up,new Ie(0,1,0)),B=se.clone().invert(),Q=new Ie,ce=new wf,Ce=new Ie,_e=2*Math.PI;return function(Ee=null){const $=r.object.position;H.copy($).sub(r.target),H.applyQuaternion(se),l.setFromVector3(H),r.autoRotate&&a===i.NONE&&D((function(we){return we!==null?2*Math.PI/60*r.autoRotateSpeed*we:2*Math.PI/60/60*r.autoRotateSpeed})(Ee)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let j=r.minAzimuthAngle,ne=r.maxAzimuthAngle;isFinite(j)&&isFinite(ne)&&(j<-Math.PI?j+=_e:j>Math.PI&&(j-=_e),ne<-Math.PI?ne+=_e:ne>Math.PI&&(ne-=_e),l.theta=j<=ne?Math.max(j,Math.min(ne,l.theta)):l.theta>(j+ne)/2?Math.max(j,l.theta):Math.min(ne,l.theta)),l.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,l.phi)),l.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&C||r.object.isOrthographicCamera?l.radius=K(l.radius):l.radius=K(l.radius*u),H.setFromSpherical(l),H.applyQuaternion(B),$.copy(r.target).add(H),r.object.lookAt(r.target),r.enableDamping===!0?(c.theta*=1-r.dampingFactor,c.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(c.set(0,0,0),d.set(0,0,0));let be=!1;if(r.zoomToCursor&&C){let we=null;if(r.object.isPerspectiveCamera){const ve=H.length();we=K(ve*u);const $e=ve-we;r.object.position.addScaledVector(N,$e),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ve=new Ie(A.x,A.y,0);ve.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),be=!0;const $e=new Ie(A.x,A.y,0);$e.unproject(r.object),r.object.position.sub($e).add(ve),r.object.updateMatrixWorld(),we=H.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;we!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(we).add(r.object.position):(K_.origin.copy(r.object.position),K_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(K_.direction))<wze?e.lookAt(r.target):(fG.setFromNormalAndCoplanarPoint(r.object.up,r.target),K_.intersectPlane(fG,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),be=!0);return u=1,C=!1,!!(be||Q.distanceToSquared(r.object.position)>o||8*(1-ce.dot(r.object.quaternion))>o||Ce.distanceToSquared(r.target)>0)&&(r.dispatchEvent(dG),Q.copy(r.object.position),ce.copy(r.object.quaternion),Ce.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",re),r.domElement.removeEventListener("pointerdown",ue),r.domElement.removeEventListener("pointercancel",he),r.domElement.removeEventListener("wheel",pe),r.domElement.removeEventListener("pointermove",le),r.domElement.removeEventListener("pointerup",he),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Me),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 o=1e-6,l=new sG,c=new sG;let u=1;const d=new Ie,f=new sn,g=new sn,p=new sn,x=new sn,y=new sn,b=new sn,v=new sn,E=new sn,w=new sn,N=new Ie,A=new sn;let C=!1;const T=[],L={};function k(){return Math.pow(.95,r.zoomSpeed)}function D(H){c.theta-=H}function U(H){c.phi-=H}const O=(function(){const H=new Ie;return function(se,B){H.setFromMatrixColumn(B,0),H.multiplyScalar(-se),d.add(H)}})(),q=(function(){const H=new Ie;return function(se,B){r.screenSpacePanning===!0?H.setFromMatrixColumn(B,1):(H.setFromMatrixColumn(B,0),H.crossVectors(r.object.up,H)),H.multiplyScalar(se),d.add(H)}})(),R=(function(){const H=new Ie;return function(se,B){const Q=r.domElement;if(r.object.isPerspectiveCamera){const ce=r.object.position;H.copy(ce).sub(r.target);let Ce=H.length();Ce*=Math.tan(r.object.fov/2*Math.PI/180),O(2*se*Ce/Q.clientHeight,r.object.matrix),q(2*B*Ce/Q.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(O(se*(r.object.right-r.object.left)/r.object.zoom/Q.clientWidth,r.object.matrix),q(B*(r.object.top-r.object.bottom)/r.object.zoom/Q.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function G(H){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=H:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function Y(H){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=H:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function V(H){if(!r.zoomToCursor)return;C=!0;const se=r.domElement.getBoundingClientRect(),B=H.clientX-se.left,Q=H.clientY-se.top,ce=se.width,Ce=se.height;A.x=B/ce*2-1,A.y=-Q/Ce*2+1,N.set(A.x,A.y,1).unproject(r.object).sub(r.object.position).normalize()}function K(H){return Math.max(r.minDistance,Math.min(r.maxDistance,H))}function J(H){f.set(H.clientX,H.clientY)}function X(H){x.set(H.clientX,H.clientY)}function F(){if(T.length===1)f.set(T[0].pageX,T[0].pageY);else{const H=.5*(T[0].pageX+T[1].pageX),se=.5*(T[0].pageY+T[1].pageY);f.set(H,se)}}function W(){if(T.length===1)x.set(T[0].pageX,T[0].pageY);else{const H=.5*(T[0].pageX+T[1].pageX),se=.5*(T[0].pageY+T[1].pageY);x.set(H,se)}}function ee(){const H=T[0].pageX-T[1].pageX,se=T[0].pageY-T[1].pageY,B=Math.sqrt(H*H+se*se);v.set(0,B)}function ie(H){if(T.length==1)g.set(H.pageX,H.pageY);else{const B=z(H),Q=.5*(H.pageX+B.x),ce=.5*(H.pageY+B.y);g.set(Q,ce)}p.subVectors(g,f).multiplyScalar(r.rotateSpeed);const se=r.domElement;D(2*Math.PI*p.x/se.clientHeight),U(2*Math.PI*p.y/se.clientHeight),f.copy(g)}function ae(H){if(T.length===1)y.set(H.pageX,H.pageY);else{const se=z(H),B=.5*(H.pageX+se.x),Q=.5*(H.pageY+se.y);y.set(B,Q)}b.subVectors(y,x).multiplyScalar(r.panSpeed),R(b.x,b.y),x.copy(y)}function de(H){const se=z(H),B=H.pageX-se.x,Q=H.pageY-se.y,ce=Math.sqrt(B*B+Q*Q);E.set(0,ce),w.set(0,Math.pow(E.y/v.y,r.zoomSpeed)),G(w.y),v.copy(E)}function ue(H){r.enabled!==!1&&(T.length===0&&(r.domElement.setPointerCapture(H.pointerId),r.domElement.addEventListener("pointermove",le),r.domElement.addEventListener("pointerup",he)),(function(se){T.push(se)})(H),H.pointerType==="touch"?(function(se){switch(We(se),T.length){case 1:switch(r.touches.ONE){case Rm.ROTATE:if(r.enableRotate===!1)return;F(),a=i.TOUCH_ROTATE;break;case Rm.PAN:if(r.enablePan===!1)return;W(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case Rm.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ee(),r.enablePan&&W(),a=i.TOUCH_DOLLY_PAN;break;case Rm.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ee(),r.enableRotate&&F(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(rk)})(H):(function(se){let B;switch(se.button){case 0:B=r.mouseButtons.LEFT;break;case 1:B=r.mouseButtons.MIDDLE;break;case 2:B=r.mouseButtons.RIGHT;break;default:B=-1}switch(B){case jm.DOLLY:if(r.enableZoom===!1)return;(function(Q){V(Q),v.set(Q.clientX,Q.clientY)})(se),a=i.DOLLY;break;case jm.ROTATE:if(se.ctrlKey||se.metaKey||se.shiftKey){if(r.enablePan===!1)return;X(se),a=i.PAN}else{if(r.enableRotate===!1)return;J(se),a=i.ROTATE}break;case jm.PAN:if(se.ctrlKey||se.metaKey||se.shiftKey){if(r.enableRotate===!1)return;J(se),a=i.ROTATE}else{if(r.enablePan===!1)return;X(se),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(rk)})(H))}function le(H){r.enabled!==!1&&(H.pointerType==="touch"?(function(se){switch(We(se),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ie(se),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;ae(se),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(B){r.enableZoom&&de(B),r.enablePan&&ae(B)})(se),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(B){r.enableZoom&&de(B),r.enableRotate&&ie(B)})(se),r.update();break;default:a=i.NONE}})(H):(function(se){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(B){g.set(B.clientX,B.clientY),p.subVectors(g,f).multiplyScalar(r.rotateSpeed);const Q=r.domElement;D(2*Math.PI*p.x/Q.clientHeight),U(2*Math.PI*p.y/Q.clientHeight),f.copy(g),r.update()})(se);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(B){E.set(B.clientX,B.clientY),w.subVectors(E,v),w.y>0?G(k()):w.y<0&&Y(k()),v.copy(E),r.update()})(se);break;case i.PAN:if(r.enablePan===!1)return;(function(B){y.set(B.clientX,B.clientY),b.subVectors(y,x).multiplyScalar(r.panSpeed),R(b.x,b.y),x.copy(y),r.update()})(se)}})(H))}function he(H){(function(se){delete L[se.pointerId];for(let B=0;B<T.length;B++)if(T[B].pointerId==se.pointerId)return void T.splice(B,1)})(H),T.length===0&&(r.domElement.releasePointerCapture(H.pointerId),r.domElement.removeEventListener("pointermove",le),r.domElement.removeEventListener("pointerup",he)),r.dispatchEvent(hG),a=i.NONE}function pe(H){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(H.preventDefault(),r.dispatchEvent(rk),(function(se){V(se),se.deltaY<0?Y(k()):se.deltaY>0&&G(k()),r.update()})(H),r.dispatchEvent(hG))}function Me(H){r.enabled!==!1&&r.enablePan!==!1&&(function(se){let B=!1;switch(se.code){case r.keys.UP:se.ctrlKey||se.metaKey||se.shiftKey?U(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,r.keyPanSpeed),B=!0;break;case r.keys.BOTTOM:se.ctrlKey||se.metaKey||se.shiftKey?U(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,-r.keyPanSpeed),B=!0;break;case r.keys.LEFT:se.ctrlKey||se.metaKey||se.shiftKey?D(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(r.keyPanSpeed,0),B=!0;break;case r.keys.RIGHT:se.ctrlKey||se.metaKey||se.shiftKey?D(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(-r.keyPanSpeed,0),B=!0}B&&(se.preventDefault(),r.update())})(H)}function re(H){r.enabled!==!1&&H.preventDefault()}function We(H){let se=L[H.pointerId];se===void 0&&(se=new sn,L[H.pointerId]=se),se.set(H.pageX,H.pageY)}function z(H){const se=H.pointerId===T[0].pointerId?T[1]:T[0];return L[se.pointerId]}r.domElement.addEventListener("contextmenu",re),r.domElement.addEventListener("pointerdown",ue),r.domElement.addEventListener("pointercancel",he),r.domElement.addEventListener("wheel",pe,{passive:!1}),this.update()}}kt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new sn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},ns.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 YQ extends Od{constructor(e){super({type:"LineMaterial",uniforms:QO.clone(ns.line.uniforms),vertexShader:ns.line.vertexShader,fragmentShader:ns.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 mG=new go,X_=new Ie;class ZQ extends oze{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 ni([-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 ni([-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 gj(n,6,1);return this.setAttribute("instanceStart",new od(r,3,0)),this.setAttribute("instanceEnd",new od(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 gj(n,6,1);return this.setAttribute("instanceColorStart",new od(r,3,0)),this.setAttribute("instanceColorEnd",new od(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 eze(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new go);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),mG.setFromBufferAttribute(n),this.boundingBox.union(mG))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new wl),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,o=e.count;a<o;a++)X_.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(X_)),X_.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(X_));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 pG=new Ie,gG=new Ie,na=new ur,ra=new ur,sl=new ur,ik=new Ie,ak=new vr,ia=new lze,xG=new Ie,Y_=new go,Z_=new wl,ol=new ur;let ll,Ch;function bG(t,e,n){return ol.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),ol.multiplyScalar(1/ol.w),ol.x=Ch/n.width,ol.y=Ch/n.height,ol.applyMatrix4(t.projectionMatrixInverse),ol.multiplyScalar(1/ol.w),Math.abs(Math.max(ol.x,ol.y))}class Mze extends Bo{constructor(e=new ZQ,n=new YQ({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 o=0,l=0,c=n.count;o<c;o++,l+=2)pG.fromBufferAttribute(n,o),gG.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+pG.distanceTo(gG);const a=new gj(i,2,1);return e.setAttribute("instanceDistanceStart",new od(a,1,0)),e.setAttribute("instanceDistanceEnd",new od(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;ll=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;Ch=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),Z_.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*Ch:u=bG(i,Math.max(i.near,Z_.distanceToPoint(ll.origin)),c.resolution),Z_.radius+=u,ll.intersectsSphere(Z_)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),Y_.copy(l.boundingBox).applyMatrix4(o),r?d=.5*Ch:d=bG(i,Math.max(i.near,Y_.distanceToPoint(ll.origin)),c.resolution),Y_.expandByScalar(d),ll.intersectsBox(Y_)!==!1&&(r?(function(f,g){const p=f.matrixWorld,x=f.geometry,y=x.attributes.instanceStart,b=x.attributes.instanceEnd;for(let v=0,E=Math.min(x.instanceCount,y.count);v<E;v++){ia.start.fromBufferAttribute(y,v),ia.end.fromBufferAttribute(b,v),ia.applyMatrix4(p);const w=new Ie,N=new Ie;ll.distanceSqToSegment(ia.start,ia.end,N,w),N.distanceTo(w)<.5*Ch&&g.push({point:N,pointOnLine:w,distance:ll.origin.distanceTo(N),object:f,face:null,faceIndex:v,uv:null,uv1:null})}})(this,n):(function(f,g,p){const x=g.projectionMatrix,y=f.material.resolution,b=f.matrixWorld,v=f.geometry,E=v.attributes.instanceStart,w=v.attributes.instanceEnd,N=Math.min(v.instanceCount,E.count),A=-g.near;ll.at(1,sl),sl.w=1,sl.applyMatrix4(g.matrixWorldInverse),sl.applyMatrix4(x),sl.multiplyScalar(1/sl.w),sl.x*=y.x/2,sl.y*=y.y/2,sl.z=0,ik.copy(sl),ak.multiplyMatrices(g.matrixWorldInverse,b);for(let C=0,T=N;C<T;C++){if(na.fromBufferAttribute(E,C),ra.fromBufferAttribute(w,C),na.w=1,ra.w=1,na.applyMatrix4(ak),ra.applyMatrix4(ak),na.z>A&&ra.z>A)continue;if(na.z>A){const O=na.z-ra.z,q=(na.z-A)/O;na.lerp(ra,q)}else if(ra.z>A){const O=ra.z-na.z,q=(ra.z-A)/O;ra.lerp(na,q)}na.applyMatrix4(x),ra.applyMatrix4(x),na.multiplyScalar(1/na.w),ra.multiplyScalar(1/ra.w),na.x*=y.x/2,na.y*=y.y/2,ra.x*=y.x/2,ra.y*=y.y/2,ia.start.copy(na),ia.start.z=0,ia.end.copy(ra),ia.end.z=0;const L=ia.closestPointToPointParameter(ik,!0);ia.at(L,xG);const k=CQ.lerp(na.z,ra.z,L),D=k>=-1&&k<=1,U=ik.distanceTo(xG)<.5*Ch;if(D&&U){ia.start.fromBufferAttribute(E,C),ia.end.fromBufferAttribute(w,C),ia.start.applyMatrix4(b),ia.end.applyMatrix4(b);const O=new Ie,q=new Ie;ll.distanceSqToSegment(ia.start,ia.end,q,O),p.push({point:q,pointOnLine:O,distance:ll.origin.distanceTo(q),object:f,face:null,faceIndex:C,uv:null,uv1:null})}}})(this,i,n)))}}class Eze extends x2{constructor(e,n,r,i,a=4473924,o=8947848){a=new Yt(a),o=new Yt(o);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:o;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:o;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 Ta;f.setAttribute("position",new ni(c,3)),f.setAttribute("color",new ni(u,3)),super(f,new hy({vertexColors:!0,toneMapped:!1}))}}function Aze(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new Ta,d=[];return d.push(-o,-l,-c,-o,l,-c,-o,l,-c,o,l,-c,o,l,-c,o,-l,-c,o,-l,-c,-o,-l,-c,-o,-l,c,-o,l,c,-o,l,c,o,l,c,o,l,c,o,-l,c,o,-l,c,-o,-l,c,-o,-l,-c,-o,-l,c,-o,l,-c,-o,l,c,o,l,-c,o,l,c,o,-l,-c,o,-l,c),u.setAttribute("position",new ni(d,3)),u})(t,e,n),a=new x2(i,new nze({color:new Yt(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var b0=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,o=0,l=n(new b0.Panel("FPS","#0ff","#002")),c=n(new b0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new b0.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){o++;var d=(performance||Date).now();if(c.update(d-i,200),d>=a+1e3&&(l.update(1e3*o/(d-a),100),a=d,o=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}};b0.Panel=function(t,e,n){var r=1/0,i=0,a=Math.round,o=a(window.devicePixelRatio||1),l=80*o,c=48*o,u=3*o,d=2*o,f=3*o,g=15*o,p=74*o,x=30*o,y=document.createElement("canvas");y.width=l,y.height=c,y.style.cssText="width:80px;height:48px";var b=y.getContext("2d");return b.font="bold "+9*o+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=n,b.fillRect(0,0,l,c),b.fillStyle=e,b.fillText(t,u,d),b.fillRect(f,g,p,x),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(f,g,p,x),{dom:y,update:function(v,E){r=Math.min(r,v),i=Math.max(i,v),b.fillStyle=n,b.globalAlpha=1,b.fillRect(0,0,l,g),b.fillStyle=e,b.fillText(a(v)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),b.drawImage(y,f+o,g,p-o,x,f,g,p-o,x),b.fillRect(f+p-o,g,o,x),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(f+p-o,g,o,a((1-v/E)*x))}}};var Nze=b0;class yG{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new lS,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 lS,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 Tze extends Ta{constructor(e=[new Ie],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 Ie,o=new Ie,l=new sn,c=[],u=[],d=[],f=[];function g(p){const[x,y,b]=(function(v){const E=e[v],w=new Ie,N=new Ie,A=new Ie,C=new Ie;w.copy(E).sub(e[v-1]||E).normalize().add((e[v+1]||E).clone().sub(E).normalize()).normalize();let T=Number.MAX_VALUE;const L=Math.abs(w.x),k=Math.abs(w.y),D=Math.abs(w.z);return L<=T&&(T=L,N.set(1,0,0)),k<=T&&(T=k,N.set(0,1,0)),D<=T&&N.set(0,0,1),C.crossVectors(w,N).normalize(),N.crossVectors(w,C),A.crossVectors(w,N),[E,N,A]})(p);for(let v=0;v<=i;v++){const E=v/i*Math.PI*2,w=Math.sin(E),N=-Math.cos(E);o.x=N*y.x+w*b.x,o.y=N*y.y+w*b.y,o.z=N*y.z+w*b.z,o.normalize(),u.push(o.x,o.y,o.z),a.x=x.x+n*o.x*.5,a.y=x.y+n*o.y*.5,a.z=x.z+r*o.z*.5,c.push(a.x,a.y,a.z)}}(function(){for(let p=0;p<e.length;p++)g(p);g(closed===!1?e.length-1:0),(function(){for(let p=0;p<e.length;p++)for(let x=0;x<=i;x++)l.x=p/e.length,l.y=x/i,d.push(l.x,l.y)})(),(function(){for(let p=1;p<e.length;p++)for(let x=1;x<=i;x++){const y=(i+1)*(p-1)+(x-1),b=(i+1)*p+(x-1),v=(i+1)*p+x,E=(i+1)*(p-1)+x;f.push(y,b,E),f.push(b,v,E)}})()})(),this.setIndex(f),this.setAttribute("position",new ni(c,3)),this.setAttribute("normal",new ni(u,3)),this.setAttribute("uv",new ni(d,2))}}class y0{static get initial(){const e=new y0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const sk={h:0,s:0,l:0};class Ep{constructor(e){var n,r,i,a,o,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=y0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Ep.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new Yt(14737632),this._travelColor=new Yt(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 cS(this.minLayerThreshold),this.scene=new VUe,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new Yt(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=(o=e.renderTravel)!==null&&o!==void 0?o: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 Nze:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new Yt(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new Yt(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new Yt(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[p,x]of Object.entries(e.toolColors))this._toolColors[parseInt(p)]=new Yt(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+h2),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 pj({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 pj({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,p.appendChild(this.canvas)}this.camera=new Ns(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 t4(this._backgroundColor,g,f),this.resize(),this.controls=new Sze(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 Yt(r)}else this._extrusionColor=new Yt(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?Ep.defaultExtrusionColor:this._extrusionColor instanceof Yt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Ep.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new Yt(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new Yt(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new Yt(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new Yt(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 cze(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 sze(13421772,.3*Math.PI),n=new aze(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 i0;return n.name=e,n.quaternion.setFromEuler(new uy(-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=y0.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 nk(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,o,l,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const g of d.commands)if(g.gcode!="g20"){if(g.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const p=g;this.state.t=p.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(g.gcode)>-1){const p=g,x={x:(n=p.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=p.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=p.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=p.params.r)!==null&&a!==void 0?a:this.state.r,e:(o=p.params.e)!==null&&o!==void 0?o: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 y=((u=p.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(g.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(g.gcode=="g2"||g.gcode=="g3"||g.gcode=="g02"||g.gcode=="g03"?this.addArcSegment(f,this.state,x,y,g.gcode=="g2"||g.gcode=="g02"):this.addLineSegment(f,this.state,x,y))}this.state.x=x.x,this.state.y=x.y,this.state.z=x.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const o=.1+.7*n/this.layers.length;a.getHSL(sk),a=new Yt().setHSL(sk.h,sk.s,o)}if(n==this.layers.length-1){const o=(r=this._topLayerColor)!==null&&r!==void 0?r:a,l=(i=this._lastSegmentColor)!==null&&i!==void 0?i:o,c=e.extrusion.splice(-3),u=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,o.getHex(),e.height),this.addTubeLine([...u,...c],l.getHex(),e.height)):(this.addLine(e.extrusion,o.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 Eze(this.buildVolume.x,10,this.buildVolume.y,10));const e=Aze(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 cS(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=y0.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 o=i?e.extrusion:e.travel,l=n.x,c=n.y,u=n.z,d=r.x,f=r.y,g=r.z;let p=r.r,x=r.i,y=r.j;if(p){const G=d-l,Y=f-c,V=Math.sqrt(Math.pow(G/2,2)+Math.pow(Y/2,2));p=Math.max(p,V);const K=Math.pow(G,2)+Math.pow(Y,2),J=Math.pow(p,2)-K/4;let X=Math.sqrt(J/K);(a&&p<0||!a&&p>0)&&(X=-X),x=G/2+Y*X,y=Y/2-G*X}const b=l==d&&c==f,v=l+x,E=c+y,w=Math.sqrt(x*x+y*y),N=Math.atan2(-y,-x),A=Math.atan2(f-E,d-v);let C;b?C=2*Math.PI:(C=a?N-A:A-N,C<0&&(C+=2*Math.PI));let T=w*C/1.8;this.inches&&(T*=25),T<1&&(T=1);let L=C/T;L*=a?-1:1;const k=[];k.push({x:l,y:c,z:u});const D=(u-g)/T;let U=l,O=c,q=u,R=N;for(let G=0;G<T-1;G++)R+=L,U=v+w*Math.cos(R),O=E+w*Math.sin(R),q+=D,k.push({x:U,y:O,z:q});k.push({x:r.x,y:r.y,z:r.z});for(let G=0;G<k.length-1;G++)o.push(k[G].x,k[G].y,k[G].z,k[G+1].x,k[G+1].y,k[G+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new Ta;i.setAttribute("position",new ni(e,3)),this.disposables.push(i);const a=new hy({color:n});this.disposables.push(a);const o=new x2(i,a);(r=this.group)===null||r===void 0||r.add(o)}addTubeLine(e,n,r=.2){let i=[];const a=[];for(let o=0;o<e.length;o+=6){const l=e.slice(o,o+9),c=new Ie(l[0],l[1],l[2]),u=new Ie(l[3],l[4],l[5]),d=new Ie(l[6],l[7],l[8]);i.push(c),u.equals(d)||(i.push(u),a.push(i),i=[])}a.forEach((o=>{var l;const c=new Tze(o,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 ZQ;this.disposables.push(i);const a=new YQ({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const o=new Mze(i,a);(r=this.group)===null||r===void 0||r.add(o)}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=>nk(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 tze({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new QUe(r.length,a,void 0,i);return this.disposables.push(o),(n=this.group)===null||n===void 0||n.add(o),o}_readFromStream(e){var n,r;return nk(this,void 0,void 0,(function*(){const i=e.getReader();let a,o="",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(o+f),o=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 yG(this):typeof this.devMode=="object"&&(this.devGui=new yG(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())}}Ep.defaultExtrusionColor=new Yt("hotpink");function Cze({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=S.useRef(null),a=S.useRef(null),o=S.useRef(null),l=S.useRef(!1),[c,u]=S.useState(!0),[d,f]=S.useState(null),[g,p]=S.useState(!1),[x,y]=S.useState(0),[b,v]=S.useState(0),E=S.useMemo(()=>JSON.stringify(n),[n]);S.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const A=i.current,C=A.parentElement?.getBoundingClientRect();C&&(A.width=C.width,A.height=C.height);const T=n&&n.length>1,L=n?.[0]||"#00ae42",k=new Ep({canvas:A,buildVolume:e,backgroundColor:1710618,extrusionColor:T?n:L,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=k,fetch(t).then(async U=>{if(!U.ok)throw U.status===404&&(await U.json().catch(()=>({}))).detail?.includes("sliced")?(p(!0),new Error("not_sliced")):new Error("Failed to load G-code");return U.text()}).then(U=>{const O=new Set,q=/^(\s*)T(\d+)(\s*;.*)?$/gim;let R;for(;(R=q.exec(U))!==null;){const X=parseInt(R[2],10);X<=15&&O.add(X)}const G=new Map,Y=Array.from(O).sort((X,F)=>X-F);Y.forEach((X,F)=>{G.set(X,F%8)});const V=[];Y.forEach((X,F)=>{const W=n?.[X]||"#00ae42";V[F%8]=W});const K=U.split(`
  8140. `).map(X=>{const F=X.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(F){const W=parseInt(F[2],10);if(W>15)return`; FILTERED: ${X.trim()}`;const ee=G.get(W)??0;return`${F[1]}T${ee}${F[3]||""}`}return X}).join(`
  8141. `);V.length>0&&(k.extrusionColor=V),k.processGCode(K);const J=k.layers?.length||0;v(J),y(J),k.render(),u(!1)}).catch(U=>{U.message!=="not_sliced"&&f(U.message),u(!1)});const D=()=>{if(A.parentElement&&a.current){const U=A.parentElement.getBoundingClientRect();A.width=U.width,A.height=U.height,a.current.resize()}};return window.addEventListener("resize",D),()=>{window.removeEventListener("resize",D),o.current&&cancelAnimationFrame(o.current),a.current&&(a.current.dispose(),a.current=null),l.current=!1}},[t,E]);const w=S.useCallback(A=>{if(!a.current)return;const C=Math.max(1,Math.min(A,b));y(C),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=C,a.current.render())})},[b]),N=A=>{w(parseInt(A.target.value,10))};return s.jsxs("div",{className:`relative flex flex-col h-full ${r}`,children:[s.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("canvas",{ref:i,className:"w-full h-full"}),c&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsxs("div",{className:"text-center",children:[s.jsx(xt,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),g&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsxs("div",{className:"text-center max-w-sm px-4",children:[s.jsx(fce,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),s.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),s.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&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx("div",{className:"text-center text-red-400",children:s.jsx("p",{className:"text-sm",children:d})})})]}),!c&&!d&&!g&&b>0&&s.jsx("div",{className:"mt-4 px-2",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Sd,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("button",{onClick:()=>w(x-1),disabled:x<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(rf,{className:"w-4 h-4"})}),s.jsx("input",{type:"range",min:1,max:b,value:x,onChange:N,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),s.jsx("button",{onClick:()=>w(x+1),disabled:x>=b,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(Zo,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[x," / ",b]})]})})]})}function QQ({archiveId:t,title:e,onClose:n}){const[r,i]=S.useState(null),[a,o]=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(()=>{ye.getArchiveCapabilities(t).then(d=>{o(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),c(!1)}).catch(()=>{o({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}${ye.getArchiveForSlicer(t,d)}`;Ec(f)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:s.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:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:u,children:[s.jsx(qr,{className:"w-4 h-4"}),"Open in Slicer"]}),s.jsx(Ne,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(Bt,{className:"w-5 h-5"})})]})]}),a&&s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[s.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:[s.jsx(vl,{className:"w-4 h-4"}),"3D Model",!a.has_model&&s.jsx("span",{className:"text-xs",children:"(not available)"})]}),s.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:[s.jsx(Ble,{className:"w-4 h-4"}),"G-code Preview",!a.has_gcode&&s.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),s.jsx("div",{className:"flex-1 overflow-hidden p-4",children:l?s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(xt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?s.jsx(AOe,{url:a.has_source?ye.getSource3mfDownloadUrl(t):ye.getArchiveDownload(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):r==="gcode"&&a?s.jsx(Cze,{gcodeUrl:ye.getArchiveGcode(t),filamentColors:a.filament_colors,className:"w-full h-full"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}const kze={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},vG={"A00-W1":"Jade White","A00-Y2":"Sunflower Yellow","A00-R0":"Red","A00-K0":"Black","A00-G1":"Bambu Green","A00-B3":"Cobalt Blue","A00-D0":"Gray","A00-D3":"Dark Gray","A01-W2":"Ivory White","A01-R1":"Scarlet Red","A01-G1":"Grass Green","A01-B3":"Marine Blue","G02-W0":"White","G02-K0":"Black","G02-R0":"Red","G02-D0":"Gray","G02-B0":"Blue","B00-W0":"White","B00-K0":"Black","B00-R0":"Red"},_G={W0:"White",W1:"Jade White",K0:"Black",R0:"Red",B0:"Blue",G0:"Green",G1:"Green",Y0:"Yellow",Y2:"Yellow",D0:"Gray",D1:"Silver",D3:"Dark Gray",A0:"Orange",P0:"Purple",N0:"Brown"};function wG(t,e){if(t&&vG[t])return vG[t];if(t){const n=t.split("-");if(n.length>=2&&_G[n[1]])return _G[n[1]]}return Pze(e)}function Pze(t){if(!t||t.length<6)return"Unknown";const e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16),a=Math.max(n,r,i)/255,o=Math.min(n,r,i)/255,l=(a+o)/2;let c=0,u=0;if(a!==o){const d=a-o;u=l>.5?d/(2-a-o):d/(a+o);const f=n/255,g=r/255,p=i/255;a===f?c=((g-p)/d+(g<p?6:0))/6:a===g?c=((p-f)/d+2)/6:c=((f-g)/d+4)/6}return c=c*360,l<.15?"Black":l>.85?"White":u<.15?l<.4?"Dark Gray":l>.6?"Light Gray":"Gray":c<15||c>=345?"Red":c<45?"Orange":c<70?"Yellow":c<150?"Green":c<200?"Cyan":c<260?"Blue":c<290?"Purple":c<345?"Pink":"Unknown"}function JQ({archiveId:t,archiveName:e,onClose:n,onSuccess:r}){const i=cn(),[a,o]=S.useState(null),[l,c]=S.useState(!1),[u,d]=S.useState(!1),[f,g]=S.useState(kze),[p,x]=S.useState({});S.useEffect(()=>{x({})},[a]),S.useEffect(()=>{const O=q=>{q.key==="Escape"&&n()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[n]);const{data:y,isLoading:b}=ft({queryKey:["printers"],queryFn:ye.getPrinters}),{data:v}=ft({queryKey:["archive-filaments",t],queryFn:()=>ye.getArchiveFilamentRequirements(t)}),{data:E}=ft({queryKey:["printer-status",a],queryFn:()=>ye.getPrinterStatus(a),enabled:!!a}),w=bt({mutationFn:()=>{if(!a)throw new Error("No printer selected");return ye.reprintArchive(t,a,{ams_mapping:D,...f})},onSuccess:()=>{r(),n()}}),N=y?.filter(O=>O.is_active)||[],A=O=>O?`#${O.replace("#","").substring(0,6)}`:"#808080",C=(O,q,R,G)=>{const Y=String.fromCharCode(65+(O>=128?O-128:O));return R?`HT-${Y}`:`AMS-${Y} Slot ${q+1}`},T=(O,q,R)=>O*4+q,L=S.useMemo(()=>{const O=[];if(E?.ams?.forEach(q=>{const R=q.tray.length===1;q.tray.forEach(G=>{if(G.tray_type){const Y=A(G.tray_color);O.push({type:G.tray_type,color:Y,colorName:wG(G.tray_id_name,Y),amsId:q.id,trayId:G.id,isHt:R,isExternal:!1,label:C(q.id,G.id,R),globalTrayId:T(q.id,G.id)})}})}),E?.vt_tray?.tray_type){const q=A(E.vt_tray.tray_color);O.push({type:E.vt_tray.tray_type,color:q,colorName:wG(E.vt_tray.tray_id_name,q),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return O},[E]),k=S.useMemo(()=>{if(!v?.filaments||v.filaments.length===0)return[];const O=G=>G?G.replace("#","").toLowerCase().substring(0,6):"",q=(G,Y,V=40)=>{const K=O(G),J=O(Y);if(!K||!J||K.length<6||J.length<6)return!1;const X=parseInt(K.substring(0,2),16),F=parseInt(K.substring(2,4),16),W=parseInt(K.substring(4,6),16),ee=parseInt(J.substring(0,2),16),ie=parseInt(J.substring(2,4),16),ae=parseInt(J.substring(4,6),16);return Math.abs(X-ee)<=V&&Math.abs(F-ie)<=V&&Math.abs(W-ae)<=V},R=new Set(Object.values(p));return v.filaments.map(G=>{const Y=G.slot_id||0;if(Y>0&&p[Y]!==void 0){const ae=p[Y],de=L.find(ue=>ue.globalTrayId===ae);if(de){const ue=de.type?.toUpperCase()===G.type?.toUpperCase(),le=O(de.color)===O(G.color)||q(de.color,G.color);let he;return ue&&le?he="match":ue?he="type_only":he="mismatch",{...G,loaded:de,hasFilament:!0,typeMatch:ue,colorMatch:le,status:he,isManual:!0}}}const V=L.find(ae=>!R.has(ae.globalTrayId)&&ae.type?.toUpperCase()===G.type?.toUpperCase()&&O(ae.color)===O(G.color)),K=!V&&L.find(ae=>!R.has(ae.globalTrayId)&&ae.type?.toUpperCase()===G.type?.toUpperCase()&&q(ae.color,G.color)),J=!V&&!K&&L.find(ae=>!R.has(ae.globalTrayId)&&ae.type?.toUpperCase()===G.type?.toUpperCase()),X=V||K||J||void 0;X&&R.add(X.globalTrayId);const F=!!X,W=F,ee=!!V||!!K;let ie;return V||K?ie="match":J?ie="type_only":ie="mismatch",{...G,loaded:X,hasFilament:F,typeMatch:W,colorMatch:ee,status:ie,isManual:!1}})},[v,L,p]),D=S.useMemo(()=>{if(k.length===0)return;const O=Math.max(...k.map(R=>R.slot_id||0));if(O<=0)return;const q=new Array(O).fill(-1);return k.forEach(R=>{R.slot_id&&R.slot_id>0&&(q[R.slot_id-1]=R.loaded?.globalTrayId??-1)}),q},[k]),U=k.some(O=>O.status==="mismatch");return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:s.jsx(Mt,{className:"w-full max-w-md",children:s.jsxs(At,{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),s.jsx(Ne,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",s.jsx("span",{className:"text-white",children:e})," to a printer"]}),b?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):N.length===0?s.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):s.jsx("div",{className:"space-y-2 mb-6",children:N.map(O=>s.jsxs("button",{onClick:()=>o(O.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${a===O.id?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[s.jsx("div",{className:`p-2 rounded-lg ${a===O.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:s.jsx(Ei,{className:`w-5 h-5 ${a===O.id?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"text-white font-medium",children:O.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[O.model||"Unknown model"," • ",O.ip_address]})]})]},O.id))}),a&&k.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Filament Check"}),s.jsxs("button",{onClick:async()=>{if(a){c(!0);try{await ye.refreshPrinterStatus(a),await new Promise(O=>setTimeout(O,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:[s.jsx(Gr,{className:`w-3 h-3 ${l?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]}),U?s.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[s.jsx(zn,{className:"w-3 h-3"}),"Type not found"]}):k.some(O=>O.status==="type_only")?s.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[s.jsx(zn,{className:"w-3 h-3"}),"Color mismatch"]}):s.jsxs("span",{className:"text-xs text-bambu-green flex items-center gap-1",children:[s.jsx(Ls,{className:"w-3 h-3"}),"Ready"]})]}),s.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 space-y-2 text-xs",children:k.map((O,q)=>s.jsxs("div",{className:"grid items-center gap-2",style:{gridTemplateColumns:"16px 1fr auto 1fr 16px"},children:[s.jsx("span",{title:`Required: ${O.color}`,children:s.jsx(a3,{className:"w-3 h-3 flex-shrink-0",fill:O.color,stroke:O.color})}),s.jsxs("span",{className:"text-white truncate",children:[O.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",O.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:O.loaded?.globalTrayId??"",onChange:R=>{const G=O.slot_id||0;if(G>0){const Y=R.target.value;x(Y===""?V=>{const K={...V};return delete K[G],K}:V=>({...V,[G]:parseInt(Y,10)}))}},className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${O.status==="match"?"border-bambu-green/50 text-bambu-green":O.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${O.isManual?"ring-1 ring-blue-400/50":""}`,title:O.isManual?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),L.map(R=>s.jsxs("option",{value:R.globalTrayId,className:"bg-bambu-dark text-white",children:[R.label,": ",R.type," (",R.colorName,")"]},R.globalTrayId))]}),O.status==="match"?s.jsx(Ls,{className:"w-3 h-3 text-bambu-green"}):O.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(zn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(zn,{className:"w-3 h-3 text-orange-400"})})]},q))}),U&&s.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]}),a&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("button",{onClick:()=>d(!u),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(hM,{className:"w-4 h-4"}),s.jsx("span",{children:"Print Options"}),u?s.jsx(Tf,{className:"w-4 h-4 ml-auto"}):s.jsx(Ga,{className:"w-4 h-4 ml-auto"})]}),u&&s.jsx("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[{key:"bed_levelling",label:"Bed Levelling",desc:"Auto-level bed before print"},{key:"flow_cali",label:"Flow Calibration",desc:"Calibrate extrusion flow"},{key:"vibration_cali",label:"Vibration Calibration",desc:"Reduce ringing artifacts"},{key:"layer_inspect",label:"First Layer Inspection",desc:"AI inspection of first layer"},{key:"timelapse",label:"Timelapse",desc:"Record timelapse video"}].map(({key:O,label:q,desc:R})=>s.jsxs("label",{className:"flex items-center justify-between cursor-pointer group",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:q}),s.jsx("p",{className:"text-xs text-bambu-gray",children:R})]}),s.jsx("div",{className:`relative w-10 h-5 rounded-full transition-colors ${f[O]?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,onClick:()=>g(G=>({...G,[O]:!G[O]})),children:s.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${f[O]?"translate-x-5":"translate-x-0.5"}`})})]},O))})]}),w.isError&&s.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:w.error.message||"Failed to start print"}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Ne,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Ne,{onClick:()=>w.mutate(),disabled:!a||w.isPending,className:"flex-1",children:w.isPending?s.jsxs(s.Fragment,{children:[s.jsx(xt,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ei,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function jze({onClose:t,initialFiles:e}){const n=cn(),{showToast:r}=hr(),i=S.useRef(null),[a,o]=S.useState(()=>e?.filter(T=>T.name.endsWith(".3mf")).map(T=>({file:T,status:"pending"}))||[]),[l,c]=S.useState(!1),[u,d]=S.useState(),[f,g]=S.useState(null);S.useEffect(()=>{const T=L=>{L.key==="Escape"&&t()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t]);const{data:p}=ft({queryKey:["printers"],queryFn:ye.getPrinters}),x=bt({mutationFn:T=>ye.uploadArchivesBulk(T,u),onSuccess:T=>{g(T),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),o(L=>L.map(k=>{const D=T.results.find(O=>O.filename===k.file.name),U=T.errors.find(O=>O.filename===k.file.name);return D?{...k,status:"success",archiveId:D.id}:U?{...k,status:"error",error:U.error}:k})),T.failed===0?r(`${T.uploaded} file${T.uploaded!==1?"s":""} uploaded`):T.uploaded===0?r(`Failed to upload ${T.failed} file${T.failed!==1?"s":""}`,"error"):r(`${T.uploaded} uploaded, ${T.failed} failed`,"warning")},onError:()=>{o(T=>T.map(L=>({...L,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),y=S.useCallback(T=>{T.preventDefault(),c(!0)},[]),b=S.useCallback(T=>{T.preventDefault(),c(!1)},[]),v=S.useCallback(T=>{T.preventDefault(),c(!1);const L=Array.from(T.dataTransfer.files).filter(k=>k.name.endsWith(".3mf"));L.length>0&&o(k=>[...k,...L.map(D=>({file:D,status:"pending"}))])},[]),E=S.useCallback(T=>{const L=Array.from(T.target.files||[]).filter(k=>k.name.endsWith(".3mf"));L.length>0&&o(k=>[...k,...L.map(D=>({file:D,status:"pending"}))]),i.current&&(i.current.value="")},[]),w=S.useCallback(T=>{o(L=>L.filter((k,D)=>D!==T))},[]),N=()=>{if(a.length===0)return;const T=a.filter(L=>L.status==="pending");T.length!==0&&(o(L=>L.map(k=>k.status==="pending"?{...k,status:"uploading"}:k)),x.mutate(T.map(L=>L.file)))},A=a.filter(T=>T.status==="pending").length,C=x.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Mt,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:s.jsxs(At,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4",children:s.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:y,onDragLeave:b,onDrop:v,children:[s.jsx(qi,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),s.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),s.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),s.jsx(Ne,{variant:"secondary",onClick:()=>i.current?.click(),disabled:C,children:"Browse Files"}),s.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:E})]})}),s.jsxs("div",{className:"px-4 pb-4",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),s.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:T=>d(T.target.value?Number(T.target.value):void 0),disabled:C,children:[s.jsx("option",{value:"",children:"No printer"}),p?.map(T=>s.jsx("option",{value:T.id,children:T.name},T.id))]})]}),a.length>0&&s.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:s.jsx("div",{className:"space-y-2",children:a.map((T,L)=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(bR,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"flex-1 text-white text-sm truncate",children:T.file.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[(T.file.size/(1024*1024)).toFixed(1)," MB"]}),T.status==="pending"&&s.jsx("button",{onClick:()=>w(L),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:C,children:s.jsx(Bt,{className:"w-4 h-4"})}),T.status==="uploading"&&s.jsx(xt,{className:"w-4 h-4 text-bambu-green animate-spin"}),T.status==="success"&&s.jsx(Ar,{className:"w-4 h-4 text-bambu-green"}),T.status==="error"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-red-400",children:T.error}),s.jsx(Aa,{className:"w-4 h-4 text-red-400"})]})]},`${T.file.name}-${L}`))})}),f&&s.jsx("div",{className:"px-4 pb-4",children:s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:[s.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&s.jsxs(s.Fragment,{children:[", ",s.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Ne,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&s.jsx(Ne,{onClick:N,disabled:A===0||C,className:"flex-1",children:C?s.jsxs(s.Fragment,{children:[s.jsx(xt,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(qi,{className:"w-4 h-4"}),"Upload ",A>0&&`(${A})`]})})]})]})})})}const Rze=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],Dze=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function eJ({archive:t,onClose:e,existingTags:n=[]}){S.useEffect(()=>{const ae=de=>{de.key==="Escape"&&e()};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[e]);const r=cn(),[i,a]=S.useState(t.print_name||""),[o,l]=S.useState(t.printer_id),[c,u]=S.useState(t.project_id??null),[d,f]=S.useState(t.notes||""),[g,p]=S.useState(t.tags||""),[x,y]=S.useState(t.failure_reason||""),[b,v]=S.useState(t.status),[E,w]=S.useState(t.quantity??1),[N,A]=S.useState(t.photos||[]),[C,T]=S.useState(!1),[L,k]=S.useState(!1),D=S.useRef(null),U=S.useRef(null),O=S.useRef(null),{data:q}=ft({queryKey:["printers"],queryFn:ye.getPrinters}),{data:R}=ft({queryKey:["projects"],queryFn:()=>ye.getProjects()}),{data:G}=ft({queryKey:["archives"],queryFn:()=>ye.getArchives(void 0,1e3,0),enabled:n.length===0}),Y=n.length>0?n:[...new Set(G?.flatMap(ae=>ae.tags?.split(",").map(de=>de.trim())||[]).filter(Boolean)||[])].sort(),V=g.split(",").map(ae=>ae.trim()).filter(Boolean),K=Y.filter(ae=>!V.includes(ae)),J=ae=>{if(!V.includes(ae)){const de=[...V,ae].join(", ");p(de)}O.current!==null&&clearTimeout(O.current),D.current?.focus()},X=ae=>{const de=V.filter(ue=>ue!==ae).join(", ");p(de)},F=bt({mutationFn:ae=>ye.updateArchive(t.id,ae),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),W=async ae=>{const de=ae.target.files?.[0];if(de){T(!0);try{const ue=await ye.uploadArchivePhoto(t.id,de);A(ue.photos),r.invalidateQueries({queryKey:["archives"]})}catch(ue){console.error("Failed to upload photo:",ue)}finally{T(!1),U.current&&(U.current.value="")}}},ee=async ae=>{try{const de=await ye.deleteArchivePhoto(t.id,ae);A(de.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(de){console.error("Failed to delete photo:",de)}},ie=ae=>{ae.preventDefault();const de={print_name:i||void 0,printer_id:o,project_id:c,notes:d||void 0,tags:g||void 0,quantity:E};b!==t.status&&(de.status=b),b==="failed"||b==="aborted"?de.failure_reason=x||void 0:(t.status==="failed"||t.status==="aborted")&&(de.failure_reason=null),F.mutate(de)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.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:ae=>ae.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:ie,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),s.jsx("input",{type:"text",value:i,onChange:ae=>a(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:"Print name"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),s.jsxs("select",{value:o??"",onChange:ae=>l(ae.target.value?Number(ae.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:[s.jsx("option",{value:"",children:"No printer"}),q?.map(ae=>s.jsx("option",{value:ae.id,children:ae.name},ae.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(ha,{className:"w-4 h-4 inline mr-1"}),"Project"]}),s.jsxs("select",{value:c??"",onChange:ae=>u(ae.target.value?Number(ae.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:[s.jsx("option",{value:"",children:"No project"}),R?.map(ae=>s.jsx("option",{value:ae.id,children:ae.name},ae.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Ice,{className:"w-4 h-4 inline mr-1"}),"Items Printed"]}),s.jsx("input",{type:"number",min:1,value:E,onChange:ae=>w(Math.max(1,parseInt(ae.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of items produced in this print job"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),s.jsx("textarea",{value:d,onChange:ae=>f(ae.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..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),V.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:V.map(ae=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[s.jsx(Rp,{className:"w-3 h-3"}),ae,s.jsx("button",{type:"button",onClick:()=>X(ae),className:"ml-0.5 text-bambu-gray hover:text-white",children:s.jsx(Bt,{className:"w-3 h-3"})})]},ae))}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:D,type:"text",value:g,onChange:ae=>p(ae.target.value),onFocus:()=>{O.current!==null&&clearTimeout(O.current),k(!0)},onBlur:()=>{O.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:V.length>0?"Add more tags...":"Add tags..."}),L&&K.length>0&&s.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:[s.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),s.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:K.map(ae=>s.jsx("button",{type:"button",onClick:()=>J(ae),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:ae},ae))})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),s.jsx("select",{value:b,onChange:ae=>{v(ae.target.value),ae.target.value==="completed"&&y("")},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:Dze.map(ae=>s.jsx("option",{value:ae.value,children:ae.label},ae.value))})]}),(b==="failed"||b==="aborted")&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),s.jsxs("select",{value:x,onChange:ae=>y(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",children:[s.jsx("option",{value:"",children:"Select reason..."}),Rze.map(ae=>s.jsx("option",{value:ae,children:ae},ae))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(kp,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[N.map(ae=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:ye.getArchivePhotoUrl(t.id,ae),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),s.jsx("button",{type:"button",onClick:()=>ee(ae),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(_n,{className:"w-3 h-3 text-white"})})]},ae)),s.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:[s.jsx("input",{ref:U,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:W,className:"hidden",disabled:C}),C?s.jsx(xt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):s.jsx(pr,{className:"w-6 h-6 text-bambu-gray"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Ne,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Ne,{type:"submit",disabled:F.isPending,className:"flex-1",children:[s.jsx(ks,{className:"w-4 h-4"}),F.isPending?"Saving...":"Save"]})]})]})]})})}function tJ({x:t,y:e,items:n,onClose:r}){const i=S.useRef(null),[a,o]=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 b=w=>{i.current&&!i.current.contains(w.target)&&r()},v=w=>{w.key==="Escape"&&r()},E=()=>{r()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",v),document.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",v),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 b=i.current.getBoundingClientRect(),v=window.innerWidth,E=window.innerHeight,w=8;let N=t,A=e;t+b.width>v-w&&(N=Math.max(w,v-b.width-w)),N<w&&(N=w),e+b.height>E-w&&(A=Math.max(w,E-b.height-w)),A<w&&(A=w);const C=180,T=v-N-b.width,L=N;f(T<C&&L>C),u({x:N,y:A,visible:!0})}},[t,e]);const x=(b,v)=>{l.current&&(clearTimeout(l.current),l.current=null);const E=v.getBoundingClientRect(),w=window.innerHeight,N=300,T=w-E.top-8<N&&E.top>N;p(L=>({...L,[b]:T?"bottom":"top"})),o(b)},y=()=>{l.current=window.setTimeout(()=>{o(null)},150)};return s.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((b,v)=>{if(b.divider)return s.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},v);const E=b.submenu&&b.submenu.length>0;return s.jsxs("div",{className:"relative",onMouseEnter:w=>E&&x(v,w.currentTarget),onMouseLeave:()=>E&&y(),children:[s.jsxs("button",{onMouseEnter:w=>E&&x(v,w.currentTarget.parentElement),onClick:()=>{E?o(a===v?null:v):b.disabled||(b.onClick(),r())},disabled:b.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${b.disabled?"text-bambu-gray cursor-not-allowed":b.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${E&&a===v?"bg-bambu-dark-tertiary":""}`,children:[b.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:b.icon}),s.jsx("span",{className:"flex-1",children:b.label}),E&&s.jsx(Zo,{className:"w-4 h-4 text-bambu-gray"})]}),E&&a===v&&s.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[v]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>y(),children:b.submenu.map((w,N)=>s.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&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:w.icon}),w.label]},N))})]},v)})})}function Oze({selectedIds:t,existingTags:e,onClose:n}){const r=cn(),{showToast:i}=hr(),[a,o]=S.useState(""),[l,c]=S.useState(new Set),[u,d]=S.useState("add");S.useEffect(()=>{const y=b=>{b.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const f=bt({mutationFn:async()=>{const y=Array.from(l);let b=0;for(const v of t)try{const E=await ye.getArchive(v),w=E.tags?E.tags.split(",").map(A=>A.trim()).filter(Boolean):[];let N;u==="add"?N=[...new Set([...w,...y])]:N=w.filter(A=>!l.has(A)),await ye.updateArchive(v,{tags:N.join(", ")}),b++}catch(E){throw console.error(`Failed to update archive ${v}:`,E),new Error(`Failed on archive ${v}: ${E instanceof Error?E.message:"Unknown error"}`)}return{count:b,mode:u,tags:y}},onSuccess:({count:y,mode:b,tags:v})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${b==="add"?"Added":"Removed"} ${v.length} tag${v.length!==1?"s":""} ${b==="add"?"to":"from"} ${y} archive${y!==1?"s":""}`),n()},onError:y=>{i(y.message||"Failed to update tags","error")}}),g=y=>{c(b=>{const v=new Set(b);return v.has(y)?v.delete(y):v.add(y),v})},p=()=>{a.trim()&&!l.has(a.trim())&&(c(y=>new Set([...y,a.trim()])),o(""))},x=y=>{y.key==="Enter"&&(y.preventDefault(),p())};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Mt,{className:"w-full max-w-md",children:s.jsxs(At,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Rp,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ne,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),s.jsx(Ne,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&s.jsxs("div",{className:"flex gap-2",children:[s.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:y=>o(y.target.value),onKeyDown:x}),s.jsx(Ne,{size:"sm",variant:"secondary",onClick:p,disabled:!a.trim(),children:s.jsx(pr,{className:"w-4 h-4"})})]}),e.length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(y=>s.jsx("button",{onClick:()=>g(y),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(y)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:y},y))})]}),l.size>0&&s.jsxs("div",{children:[s.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(l).map(y=>s.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:[y,s.jsx("button",{onClick:()=>g(y),className:"hover:opacity-70",children:s.jsx(Bt,{className:"w-3 h-3"})})]},y))})]})]}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Ne,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Ne,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(xt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Rp,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function Lze({selectedIds:t,onClose:e}){const n=cn(),{showToast:r}=hr(),{data:i,isLoading:a}=ft({queryKey:["projects"],queryFn:()=>ye.getProjects()});S.useEffect(()=>{const d=f=>{f.key==="Escape"&&e()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e]);const o=()=>{n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["projects"]}),n.invalidateQueries({queryKey:["project"]}),n.invalidateQueries({queryKey:["project-archives"]})},l=bt({mutationFn:async d=>(await ye.addArchivesToProject(d,t),d),onSuccess:d=>{const f=i?.find(g=>g.id===d);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${f?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=bt({mutationFn:async()=>{for(const d of t)await ye.updateArchive(d,{project_id:null});return t.length},onSuccess:d=>{o(),r(`Removed ${d} archive${d!==1?"s":""} from project`),e()},onError:()=>{r("Failed to remove from project","error")}}),u=l.isPending||c.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Mt,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:s.jsxs(At,{className:"p-0 flex flex-col min-h-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ha,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Assign to Project"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",disabled:u,children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-3 overflow-y-auto min-h-0",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Assign ",t.length," selected archive",t.length!==1?"s":""," to a project"]}),a?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(xt,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):s.jsxs("div",{className:"space-y-2",children:[s.jsxs("button",{onClick:()=>c.mutate(),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/20 flex items-center justify-center shrink-0",children:s.jsx(Sa,{className:"w-4 h-4 text-red-400"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium",children:"Remove from project"}),s.jsx("p",{className:"text-sm text-bambu-gray truncate",children:"Clear project assignment"})]}),c.isPending&&s.jsx(xt,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]}),i&&i.length>0&&s.jsxs("div",{className:"flex items-center gap-2 py-2",children:[s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"or assign to"}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"})]}),i?.map(d=>s.jsxs("button",{onClick:()=>l.mutate(d.id),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[s.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0",style:{backgroundColor:d.color?`${d.color}20`:"rgb(var(--bambu-green) / 0.2)"},children:s.jsx(ha,{className:"w-4 h-4",style:{color:d.color||"rgb(var(--bambu-green))"}})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium truncate",children:d.name}),s.jsxs("p",{className:"text-sm text-bambu-gray truncate",children:[d.archive_count," archive",d.archive_count!==1?"s":"",d.status&&` • ${d.status}`]})]}),l.isPending&&l.variables===d.id&&s.jsx(xt,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]},d.id)),(!i||i.length===0)&&s.jsx("p",{className:"text-center text-bambu-gray py-4",children:"No projects yet. Create one from the Projects page."})]})]}),s.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary shrink-0",children:s.jsx(Ne,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function Ize(t,e){return new Date(t,e+1,0).getDate()}function Fze(t,e){return new Date(t,e,1).getDay()}const Uze=["January","February","March","April","May","June","July","August","September","October","November","December"],zze=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Bze({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,a]=S.useState(r.getMonth()),[o,l]=S.useState(r.getFullYear()),[c,u]=S.useState(null),[d,f]=S.useState(null),g=S.useMemo(()=>{const A=new Map;return t.forEach(C=>{const T=ui(C.completed_at||C.created_at)||new Date,L=`${T.getFullYear()}-${String(T.getMonth()+1).padStart(2,"0")}-${String(T.getDate()).padStart(2,"0")}`,k=A.get(L)||[];k.push(C),A.set(L,k)}),A},[t]),p=Ize(o,i),x=Fze(o,i),y=()=>{i===0?(a(11),l(o-1)):a(i-1)},b=()=>{i===11?(a(0),l(o+1)):a(i+1)},v=()=>{a(r.getMonth()),l(r.getFullYear())},E=[];for(let A=0;A<x;A++)E.push(null);for(let A=1;A<=p;A++)E.push(A);const w=c?g.get(c)||[]:[],N=A=>{A!==c&&f(null),u(A)};return s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("button",{onClick:y,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(rf,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:[Uze[i]," ",o]}),s.jsx("button",{onClick:v,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"})]}),s.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Zo,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:zze.map(A=>s.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:A},A))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:E.map((A,C)=>{if(A===null)return s.jsx("div",{className:"aspect-square"},`empty-${C}`);const T=`${o}-${String(i+1).padStart(2,"0")}-${String(A).padStart(2,"0")}`,L=g.get(T)||[],k=L.length>0,D=A===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),U=T===c,O=L.filter(R=>R.status==="completed").length,q=L.filter(R=>R.status==="failed").length;return s.jsxs("button",{onClick:()=>N(U?null:T),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${U?"bg-bambu-green text-white":D?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":k?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[s.jsx("span",{className:`text-sm font-medium ${D&&!U?"text-bambu-green":""}`,children:A}),k&&s.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[s.jsx("div",{className:`w-2 h-2 rounded-full ${q>0&&O===0?"bg-red-400":q>0?"bg-yellow-400":"bg-green-400"}`}),s.jsx("span",{className:"text-xs font-medium",children:L.length})]})]},A)})}),s.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(A=>{const C=new Date(A.completed_at||A.created_at);return C.getMonth()===i&&C.getFullYear()===o}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(A=>{const C=new Date(A.completed_at||A.created_at);return C.getMonth()===i&&C.getFullYear()===o&&A.status==="completed"}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(A=>{const C=new Date(A.completed_at||A.created_at);return C.getMonth()===i&&C.getFullYear()===o&&A.status==="failed"}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),s.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:c?s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(c+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),w.length>0?s.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:w.map(A=>{const C=A.id===d||A.id===n;return s.jsxs("button",{onClick:()=>{f(A.id),e?.(A)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${C?"":"hover:bg-bambu-dark-tertiary"}`,style:C?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[A.thumbnail_path?s.jsx("img",{src:ye.getArchiveThumbnail(A.id),alt:"",className:"w-12 h-12 rounded object-cover"}):s.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:A.print_name||A.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:A.status==="failed"?"text-red-400":"text-green-400",children:A.status==="failed"?"Failed":"Completed"}),A.filament_color&&s.jsx("div",{className:"flex gap-0.5",children:A.filament_color.split(",").map((T,L)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:T}},L))})]})]})]},A.id)})}):s.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function nJ({archiveId:t,archiveName:e,onClose:n}){const r=ye.getArchiveQRCodeUrl(t,300);S.useEffect(()=>{const a=o=>{o.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 s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-6 flex flex-col items-center",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),s.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:s.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),s.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),s.jsxs(Ne,{onClick:i,className:"w-full",children:[s.jsx(Mi,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function rJ({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,o]=S.useState(0),[l,c]=S.useState(!1);if(S.useEffect(()=>{const p=x=>{x.key==="Escape"&&r(),x.key==="ArrowLeft"&&o(y=>Math.max(0,y-1)),x.key==="ArrowRight"&&o(y=>Math.min(n.length-1,y+1))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r,n.length]),S.useEffect(()=>{a>=n.length&&o(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;const u=n[a],d=ye.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 s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[s.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:p=>p.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:f,children:[s.jsx(Mi,{className:"w-4 h-4"}),"Download"]}),i&&s.jsx(Ne,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:s.jsx(_n,{className:"w-4 h-4"})}),s.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(Bt,{className:"w-6 h-6"})})]})]}),s.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&s.jsx("button",{onClick:()=>o(p=>p-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(rf,{className:"w-8 h-8 text-white"})}),s.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&&s.jsx("button",{onClick:()=>o(p=>p+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(Zo,{className:"w-8 h-8 text-white"})})]}),n.length>1&&s.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((p,x)=>s.jsx("button",{onClick:()=>o(x),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${x===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:s.jsx("img",{src:ye.getArchivePhotoUrl(t,p),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},p))})]}),l&&s.jsx(Qn,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function sa(t){this.content=t}sa.prototype={constructor:sa,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 sa(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 sa(n)},addToStart:function(t,e){return new sa([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new sa(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 sa(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=sa.from(t),t.size?new sa(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=sa.from(t),t.size?new sa(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=sa.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}};sa.from=function(t){if(t instanceof sa)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new sa(e)};function iJ(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 o=0;i.text[o]==a.text[o];o++)n++;return n}if(i.content.size||a.content.size){let o=iJ(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function aJ(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 o=t.child(--i),l=e.child(--a),c=o.nodeSize;if(o==l){n-=c,r-=c;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let u=0,d=Math.min(o.text.length,l.text.length);for(;u<d&&o.text[o.text.length-u-1]==l.text[l.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let u=aJ(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class _t{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 o=0,l=0;l<n;o++){let c=this.content[o],u=l+c.nodeSize;if(u>e&&r(c,i+l,a||null,o)!==!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="",o=!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&&(o?o=!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 _t(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,o=0;o<n;a++){let l=this.content[a],c=o+l.nodeSize;c>e&&((o<e||c>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),i+=l.nodeSize),o=c}return new _t(r,i)}cutByIndex(e,n){return e==n?_t.empty:e==0&&n==this.content.length?this:new _t(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 _t(i,a)}addToStart(e){return new _t([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new _t(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 iJ(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return aJ(this,e,n,r)}findIndex(e){if(e==0)return Q_(0,e);if(e==this.size)return Q_(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?Q_(n+1,a):Q_(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 _t.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new _t(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return _t.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 _t(n||e,r)}static from(e){if(!e)return _t.empty;if(e instanceof _t)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new _t([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}_t.empty=new _t([],0);const ok={index:0,offset:0};function Q_(t,e){return ok.index=t,ok.offset=e,ok}function uS(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(!uS(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!uS(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let gr=class bj{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&&uS(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 bj.none;if(e instanceof bj)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};gr.none=[];class dS extends Error{}class Ot{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=oJ(this.content,e+this.openStart,n);return r&&new Ot(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ot(sJ(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 Ot.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 Ot(_t.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 Ot(e,r,i)}}Ot.empty=new Ot(_t.empty,0,0);function sJ(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||a.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(sJ(a.content,e-i-1,n-i-1)))}function oJ(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),o=t.maybeChild(i);if(a==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=oJ(o.content,e-a-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function Hze(t,e,n){if(n.openStart>t.depth)throw new dS("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new dS("Inconsistent open depths");return lJ(t,e,n,0)}function lJ(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=lJ(t,e,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return Yh(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=$ze(n,t);return Yh(a,uJ(t,o,l,e,r))}else return Yh(a,hS(t,e,r))}function cJ(t,e){if(!e.type.compatibleContent(t.type))throw new dS("Cannot join "+e.type.name+" onto "+t.type.name)}function yj(t,e,n){let r=t.node(n);return cJ(r,e.node(n)),r}function Xh(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 v0(t,e,n,r){let i=(e||t).node(n),a=0,o=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(Xh(t.nodeAfter,r),a++));for(let l=a;l<o;l++)Xh(i.child(l),r);e&&e.depth==n&&e.textOffset&&Xh(e.nodeBefore,r)}function Yh(t,e){return t.type.checkContent(e),t.copy(e)}function uJ(t,e,n,r,i){let a=t.depth>i&&yj(t,e,i+1),o=r.depth>i&&yj(n,r,i+1),l=[];return v0(null,t,i,l),a&&o&&e.index(i)==n.index(i)?(cJ(a,o),Xh(Yh(a,uJ(t,e,n,r,i+1)),l)):(a&&Xh(Yh(a,hS(t,e,i+1)),l),v0(e,n,i,l),o&&Xh(Yh(o,hS(n,r,i+1)),l)),v0(r,null,i,l),new _t(l)}function hS(t,e,n){let r=[];if(v0(null,t,n,r),t.depth>n){let i=yj(t,e,n+1);Xh(Yh(i,hS(t,e,n+1)),r)}return v0(e,null,n,r),new _t(r)}function $ze(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(_t.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class mb{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 gr.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 o=0;o<a.length;o++)a[o].type.spec.inclusive===!1&&(!i||!a[o].isInSet(i.marks))&&(a=a[o--].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 fS(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 o=e;;){let{index:l,offset:c}=o.content.findIndex(a),u=a-c;if(r.push(o,l,i+c),!u||(o=o.child(l),o.isText))break;a=u-1,i+=c+1}return new mb(n,r,a)}static resolveCached(e,n){let r=SG.get(e);if(r)for(let a=0;a<r.elts.length;a++){let o=r.elts[a];if(o.pos==n)return o}else SG.set(e,r=new Vze);let i=r.elts[r.i]=mb.resolve(e,n);return r.i=(r.i+1)%Gze,i}}class Vze{constructor(){this.elts=[],this.i=0}}const Gze=12,SG=new WeakMap;class fS{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Wze=Object.create(null);let bd=class vj{constructor(e,n,r,i=gr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||_t.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&&uS(this.attrs,n||e.defaultAttrs||Wze)&&gr.sameSet(this.marks,r||gr.none)}copy(e=null){return e==this.content?this:new vj(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new vj(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 Ot.empty;let i=this.resolve(e),a=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),u=i.node(o).content.cut(i.pos-l,a.pos-l);return new Ot(u,i.depth-o,a.depth-o)}replace(e,n,r){return Hze(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 mb.resolveCached(this,e)}resolveNoCache(e){return mb.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()+")"),dJ(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=_t.empty,i=0,a=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,a),l=o&&o.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),o=a&&a.matchFragment(this.content,n);return o?o.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=gr.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(!gr.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=_t.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};bd.prototype.text=void 0;class mS extends bd{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):dJ(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 mS(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new mS(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 dJ(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Sf{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new qze(e,n);if(r.next==null)return Sf.empty;let i=hJ(r);r.next&&r.err("Unexpected trailing text");let a=eBe(Jze(i));return tBe(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(o,l){let c=o.matchFragment(e,r);if(c&&(!n||c.validEnd))return _t.from(l.map(u=>u.createAndFill()));for(let u=0;u<o.next.length;u++){let{type:d,next:f}=o.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 o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<a.next.length;o++){let{type:l,next:c}=a.next[o];!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 o=0;o<r.next.length;o++)a+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return a}).join(`
  8142. `)}}Sf.empty=new Sf(!0);class qze{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 hJ(t){let e=[];do e.push(Kze(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Kze(t){let e=[];do e.push(Xze(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Xze(t){let e=Qze(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=Yze(t,e);else break;return e}function MG(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Yze(t,e){let n=MG(t),r=n;return t.eat(",")&&(t.next!="}"?r=MG(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Zze(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let o=n[a];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function Qze(t){if(t.eat("(")){let e=hJ(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=Zze(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 Jze(t){let e=[[]];return i(a(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,c){let u={term:c,to:l};return e[o].push(u),u}function i(o,l){o.forEach(c=>c.to=l)}function a(o,l){if(o.type=="choice")return o.exprs.reduce((c,u)=>c.concat(a(u,l)),[]);if(o.type=="seq")for(let c=0;;c++){let u=a(o.exprs[c],l);if(c==o.exprs.length-1)return u;i(u,l=n())}else if(o.type=="star"){let c=n();return r(l,c),i(a(o.expr,c),c),[r(c)]}else if(o.type=="plus"){let c=n();return i(a(o.expr,l),c),i(a(o.expr,c),c),[r(c)]}else{if(o.type=="opt")return[r(l)].concat(a(o.expr,l));if(o.type=="range"){let c=l;for(let u=0;u<o.min;u++){let d=n();i(a(o.expr,c),d),c=d}if(o.max==-1)i(a(o.expr,c),c);else for(let u=o.min;u<o.max;u++){let d=n();r(c,d),i(a(o.expr,c),d),c=d}return[r(c)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function fJ(t,e){return e-t}function EG(t,e){let n=[];return r(e),n.sort(fJ);function r(i){let a=t[i];if(a.length==1&&!a[0].term)return r(a[0].to);n.push(i);for(let o=0;o<a.length;o++){let{term:l,to:c}=a[o];!l&&n.indexOf(c)==-1&&r(c)}}}function eBe(t){let e=Object.create(null);return n(EG(t,0));function n(r){let i=[];r.forEach(o=>{t[o].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]);EG(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new Sf(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(fJ);a.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return a}}function tBe(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];o.push(c.name),a&&!(c.isText||c.hasRequiredAttrs())&&(a=!1),r.indexOf(u)==-1&&r.push(u)}a&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function mJ(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 pJ(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 gJ(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 xJ(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new rBe(t,r,e[r]);return n}let AG=class bJ{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=xJ(e,r.attrs),this.defaultAttrs=mJ(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==Sf.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:pJ(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new bd(this,this.computeAttrs(e),_t.from(n),gr.setFrom(r))}createChecked(e=null,n,r){return n=_t.from(n),this.checkContent(n),new bd(this,this.computeAttrs(e),n,gr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=_t.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),a=i&&i.fillBefore(_t.empty,!0);return a?new bd(this,e,n.append(a),gr.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){gJ(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:gr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,o)=>r[a]=new bJ(a,n,o));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 nBe(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 rBe{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?nBe(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class b2{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=xJ(e,i.attrs),this.excluded=null;let a=mJ(this.attrs);this.instance=a?new gr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new gr(this,pJ(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new b2(a,i++,n,o)),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){gJ(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class yJ{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=sa.from(e.nodes),n.marks=sa.from(e.marks||{}),this.nodes=AG.compile(this.spec.nodes,this),this.marks=b2.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],o=a.spec.content||"",l=a.spec.marks;if(a.contentMatch=r[o]||(r[o]=Sf.parse(o,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?NG(this,l.split(" ")):l==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],o=a.spec.excludes;a.excluded=o==null?[a]:o==""?[]:NG(this,o.split(" "))}this.nodeFromJSON=i=>bd.fromJSON(this,i),this.markFromJSON=i=>gr.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 AG){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 mS(r,r.defaultAttrs,e,gr.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 NG(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.marks[i],o=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(o=c)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function iBe(t){return t.tag!=null}function aBe(t){return t.style!=null}let _0=class _j{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(iBe(i))this.tags.push(i);else if(aBe(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 CG(this,n,!1);return r.addAll(e,gr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new CG(this,n,!0);return r.addAll(e,gr.none,n.from,n.to),Ot.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(lBe(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let o=a.getAttrs(e);if(o===!1)continue;a.attrs=o||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 o=this.styles[a],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let c=o.getAttrs(n);if(c===!1)continue;o.attrs=c||void 0}return o}}}static schemaRules(e){let n=[];function r(i){let a=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<a)break}n.splice(o,0,i)}for(let i in e.marks){let a=e.marks[i].spec.parseDOM;a&&a.forEach(o=>{r(o=kG(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(o=>{r(o=kG(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new _j(e,_j.schemaRules(e)))}};const vJ={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},sBe={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},_J={ol:!0,ul:!0},pb=1,wj=2,w0=4;function TG(t,e,n){return e!=null?(e?pb:0)|(e==="full"?wj:0):t&&t.whitespace=="pre"?pb|wj:n&~w0}class J_{constructor(e,n,r,i,a,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=gr.none,this.match=a||(o&w0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(_t.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&pb)){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=_t.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(_t.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&&!vJ.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class CG{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,o=TG(null,n.preserveWhitespace,0)|(r?w0:0);i?a=new J_(i.type,i.attrs,gr.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new J_(null,null,gr.none,!0,null,o):a=new J_(e.schema.topNodeType,null,gr.none,!0,null,o),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&wj?"full":this.localPreserveWS||(i.options&pb)>0,{schema:o}=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(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[c]&&this.insertNode(o.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(o.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 o=e.nodeName.toLowerCase(),l;_J.hasOwnProperty(o)&&this.parser.normalizeLists&&oBe(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:sBe.hasOwnProperty(o))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(vJ.hasOwnProperty(o))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],o=r.getPropertyValue(a);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(a,o,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,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(o,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(o&&o.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 o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(o,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let o=this.open,l=0;o>=0;o--){let c=this.nodes[o],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 o=0;o<i.length;o++)n=this.enterInner(i[o],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 o=gr.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):PG(l.type,e.type))&&(o=l.addToSet(o));return a.content.push(e.mark(o)),!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 o=this.top;o.match=o.match&&o.match.matchType(e);let l=TG(e,a,o.options);o.options&w0&&o.content.length==0&&(l|=w0);let c=gr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):PG(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new J_(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|=pb)}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),o=(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(o(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 o(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 oBe(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&_J.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function lBe(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function kG(t){let e={};for(let n in t)e[n]=t[n];return e}function PG(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],o=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&&o(d))return!0}};if(o(i.contentMatch))return!0}}class Df{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=lk(n).createDocumentFragment());let i=r,a=[];return e.forEach(o=>{if(a.length||o.marks.length){let l=0,c=0;for(;l<a.length&&c<o.marks.length;){let u=o.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<o.marks.length;){let u=o.marks[c++],d=this.serializeMark(u,o.isInline,n);d&&(a.push([u,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=L1(lk(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&&L1(lk(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return L1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Df(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=jG(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return jG(e.marks)}}function jG(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function lk(t){return t.document||window.document}const RG=new WeakMap;function cBe(t){let e=RG.get(t);return e===void 0&&RG.set(t,e=uBe(t)),e}function uBe(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 L1(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=cBe(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 o=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let l,c=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let g=f.indexOf(" ");g>0?c.setAttributeNS(f.slice(0,g),f.slice(g+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let g=e[f];if(g===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:p,contentDOM:x}=L1(t,g,n,r);if(c.appendChild(p),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:c,contentDOM:l}}const wJ=65535,SJ=Math.pow(2,16);function dBe(t,e){return t+e*SJ}function DG(t){return t&wJ}function hBe(t){return(t-(t&wJ))/SJ}const MJ=1,EJ=2,I1=4,AJ=8;class Sj{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&AJ)>0}get deletedBefore(){return(this.delInfo&(MJ|I1))>0}get deletedAfter(){return(this.delInfo&(EJ|I1))>0}get deletedAcross(){return(this.delInfo&I1)>0}}class Cs{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Cs.empty)return Cs.empty}recover(e){let n=0,r=DG(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+hBe(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,o=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+o],f=c+u;if(e<=f){let g=u?e==c?-1:e==f?1:n:n,p=c+i+(g<0?0:d);if(r)return p;let x=e==(n<0?c:f)?null:dBe(l/3,e-c),y=e==c?EJ:e==f?MJ:I1;return(n<0?e!=c:e!=f)&&(y|=AJ),new Sj(p,y,x)}i+=d-u}return r?e+i:new Sj(e+i,0,null)}touches(e,n){let r=0,i=DG(n),a=this.inverted?2:1,o=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+o]-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 o=this.ranges[i],l=o-(this.inverted?a:0),c=o+(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 Cs(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Cs.empty:new Cs(e<0?[0,-e,0]:[0,0,e])}}Cs.empty=new Cs([]);class gb{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 gb(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 gb;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 o=this._maps[a],l=o.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 Sj(e,i,null)}}const ck=Object.create(null);class Ca{getMap(){return Cs.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ck[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 ck)throw new RangeError("Duplicate use of step JSON ID "+e);return ck[e]=n,n.prototype.jsonID=e,n}}class fi{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new fi(e,null)}static fail(e){return new fi(null,e)}static fromReplace(e,n,r,i){try{return fi.ok(e.replace(n,r,i))}catch(a){if(a instanceof dS)return fi.fail(a.message);throw a}}}function i4(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(i4(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return _t.fromArray(r)}class ld extends Ca{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 Ot(i4(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return fi.fromReplace(e,this.from,this.to,a)}invert(){return new Ho(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 ld(n.pos,r.pos,this.mark)}merge(e){return e instanceof ld&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ld(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 ld(n.from,n.to,e.markFromJSON(n.mark))}}Ca.jsonID("addMark",ld);class Ho extends Ca{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 Ot(i4(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return fi.fromReplace(e,this.from,this.to,r)}invert(){return new ld(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 Ho(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ho&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ho(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 Ho(n.from,n.to,e.markFromJSON(n.mark))}}Ca.jsonID("removeMark",Ho);class cd extends Ca{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return fi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return fi.fromReplace(e,this.pos,this.pos+1,new Ot(_t.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 cd(this.pos,n.marks[i]);return new cd(this.pos,this.mark)}}return new Mf(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new cd(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 cd(n.pos,e.markFromJSON(n.mark))}}Ca.jsonID("addNodeMark",cd);class Mf extends Ca{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return fi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return fi.fromReplace(e,this.pos,this.pos+1,new Ot(_t.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new cd(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Mf(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 Mf(n.pos,e.markFromJSON(n.mark))}}Ca.jsonID("removeNodeMark",Mf);class Gi extends Ca{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&Mj(e,this.from,this.to)?fi.fail("Structure replace would overwrite content"):fi.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Cs([this.from,this.to-this.from,this.slice.size])}invert(e){return new Gi(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 Gi(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Gi)||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?Ot.empty:new Ot(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Gi(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?Ot.empty:new Ot(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Gi(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 Gi(n.from,n.to,Ot.fromJSON(e,n.slice),!!n.structure)}}Ca.jsonID("replace",Gi);class Ki extends Ca{constructor(e,n,r,i,a,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Mj(e,this.from,this.gapFrom)||Mj(e,this.gapTo,this.to)))return fi.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return fi.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?fi.fromReplace(e,this.from,this.to,r):fi.fail("Content does not fit in gap")}getMap(){return new Cs([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 Ki(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 Ki(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 Ki(n.from,n.to,n.gapFrom,n.gapTo,Ot.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ca.jsonID("replaceAround",Ki);function Mj(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 o=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function fBe(t,e,n,r){let i=[],a=[],o,l;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let g=Math.max(u,e),p=Math.min(u+c.nodeSize,n),x=r.addToSet(f);for(let y=0;y<f.length;y++)f[y].isInSet(x)||(o&&o.to==g&&o.mark.eq(f[y])?o.to=p:i.push(o=new Ho(g,p,f[y])));l&&l.to==g?l.to=p:a.push(l=new ld(g,p,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function mBe(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;a++;let c=null;if(r instanceof b2){let u=o.marks,d;for(;d=r.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(o.marks)&&(c=[r]):c=o.marks;if(c&&c.length){let u=Math.min(l+o.nodeSize,n);for(let d=0;d<c.length;d++){let f=c[d],g;for(let p=0;p<i.length;p++){let x=i[p];x.step==a-1&&f.eq(i[p].style)&&(g=x)}g?(g.to=u,g.step=a):i.push({style:f,from:Math.max(l,e),to:u,step:a})}}}),i.forEach(o=>t.step(new Ho(o.from,o.to,o.style)))}function a4(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),o=[],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)o.push(new Gi(l,d,Ot.empty));else{r=f;for(let g=0;g<u.marks.length;g++)n.allowsMarkType(u.marks[g].type)||t.step(new Ho(l,d,u.marks[g]));if(i&&u.isText&&n.whitespace!="pre"){let g,p=/\r?\n|\r/g,x;for(;g=p.exec(u.text);)x||(x=new Ot(_t.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new Gi(l+g.index,l+g.index+g[0].length,x))}}l=d}if(!r.validEnd){let c=r.fillBefore(_t.empty,!0);t.replace(l,l,new Ot(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function pBe(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function kg(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+i,c=t.$to.indexAfter(r)-a;if(r<t.depth&&o.canReplace(l,c,n))return r;if(r==0||o.type.spec.isolating||!pBe(o,l,c))break;l&&(i=1),c<o.childCount&&(a=1)}return null}function gBe(t,e,n){let{$from:r,$to:i,depth:a}=e,o=r.before(a+1),l=i.after(a+1),c=o,u=l,d=_t.empty,f=0;for(let x=a,y=!1;x>n;x--)y||r.index(x)>0?(y=!0,d=_t.from(r.node(x).copy(d)),f++):c--;let g=_t.empty,p=0;for(let x=a,y=!1;x>n;x--)y||i.after(x+1)<i.end(x)?(y=!0,g=_t.from(i.node(x).copy(g)),p++):u++;t.step(new Ki(c,u,o,l,new Ot(d.append(g),f,p),d.size-f,!0))}function s4(t,e,n=null,r=t){let i=xBe(t,e),a=i&&bBe(r,e);return a?i.map(OG).concat({type:e,attrs:n}).concat(a.map(OG)):null}function OG(t){return{type:t,attrs:null}}function xBe(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.contentMatchAt(r).findWrapping(e);if(!a)return null;let o=a.length?a[0]:e;return n.canReplaceWith(r,i,o)?a:null}function bBe(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.child(r),o=e.contentMatch.findWrapping(a.type);if(!o)return null;let c=(o.length?o[o.length-1]:e).contentMatch;for(let u=r;c&&u<i;u++)c=c.matchType(n.child(u).type);return!c||!c.validEnd?null:o}function yBe(t,e,n){let r=_t.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].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=_t.from(n[o].type.create(n[o].attrs,r))}let i=e.start,a=e.end;t.step(new Ki(i,a,i,a,new Ot(r,0,0),n.length,!0))}function vBe(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,(o,l)=>{let c=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,c)&&_Be(t.doc,t.mapping.slice(a).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!x?u=!1:!p&&x&&(u=!0)}u===!1&&TJ(t,o,l,a),a4(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+o.nodeSize,1);return t.step(new Ki(f,g,f+1,g-1,new Ot(_t.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&NJ(t,o,l,a),!1}})}function NJ(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let c=t.mapping.slice(r).map(n+1+a+o.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function TJ(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+a);t.replaceWith(o,o+1,e.type.schema.text(`
  8145. `))}})}function _Be(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function wBe(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 o=n.create(r,null,i||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,o);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ki(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Ot(_t.from(o),0,0),1,!0))}function Bc(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,d=n-2;u>a;u--,d--){let f=i.node(u),g=i.index(u);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(g,f.childCount),x=r&&r[d+1];x&&(p=p.replaceChild(0,x.type.create(x.attrs)));let y=r&&r[d]||f;if(!f.canReplace(g+1,f.childCount)||!y.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 SBe(t,e,n=1,r){let i=t.doc.resolve(e),a=_t.empty,o=_t.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=_t.from(i.node(l).copy(a));let d=r&&r[u];o=_t.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new Gi(e,e,new Ot(a.append(o),n,n),!0))}function $d(t,e){let n=t.resolve(e),r=n.index();return CJ(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function MBe(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),o=a.type==r?t.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(a.marks))return!1}return n.validEnd}function CJ(t,e){return!!(t&&e&&!t.isLeaf&&MBe(t,e))}function y2(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let a,o,l=r.index(i);if(i==r.depth?(a=r.nodeBefore,o=r.nodeAfter):n>0?(a=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(a=r.node(i).maybeChild(l-1),o=r.node(i+1)),a&&!a.isTextblock&&CJ(a,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function EBe(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,a=t.doc.resolve(e-n),o=a.node().type;if(i&&o.inlineContent){let d=o.whitespace=="pre",f=!!o.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);TJ(t,d.node(),d.before(),l)}o.inlineContent&&a4(t,e+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=t.mapping.slice(l),u=c.map(e-n);if(t.step(new Gi(u,c.map(e+n,-1),Ot.empty,!0)),r===!0){let d=t.doc.resolve(u);NJ(t,d.node(),d.before(),t.steps.length)}return t}function ABe(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 kJ(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 o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,c=r.index(o)+(l>0?1:0),u=r.node(o),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(o+1):r.after(o+1)}return null}function v2(t,e,n=e,r=Ot.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return PJ(i,a,r)?new Gi(e,n,r):new NBe(i,a,r).fit()}function PJ(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class NBe{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=_t.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=_t.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,o=r.depth,l=i.depth;for(;o&&l&&a.childCount==1;)a=a.firstChild.content,o--,l--;let c=new Ot(a,o,l);return e>-1?new Ki(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Gi(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=uk(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:u}=this.frontier[l],d,f=null;if(n==1&&(o?u.matchType(o.type)||(f=u.fillBefore(_t.from(o),!1)):a&&c.compatibleContent(a.type)))return{sliceDepth:r,frontierDepth:l,parent:a,inject:f};if(n==2&&o&&(d=u.findWrapping(o.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=uk(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Ot(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=uk(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Ot(a0(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Ot(a0(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 y=0;y<a.length;y++)this.openFrontierNode(a[y]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:f,type:g}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)d.push(i.child(y));f=f.matchFragment(i)}let p=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let y=l.child(u),b=f.matchType(y.type);if(!b)break;u++,(u>1||c==0||y.content.size)&&(f=b,d.push(jJ(y.mark(g.allowedMarks(y.marks)),u==1?c:0,u==l.childCount?p:-1)))}let x=u==l.childCount;x||(p=-1),this.placed=s0(this.placed,n,_t.from(d)),this.frontier[n].match=f,x&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,b=l;y<p;y++){let v=b.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),b=v.content}this.unplaced=x?e==0?Ot.empty:new Ot(a0(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new Ot(a0(o.content,e,u),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!dk(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)),o=dk(e,n,i,r,a);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=dk(e,l,u,c,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,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=s0(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=s0(this.placed,this.depth,_t.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(_t.empty,!0);n.childCount&&(this.placed=s0(this.placed,this.frontier.length,n))}}function a0(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(a0(t.firstChild.content,e-1,n)))}function s0(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(s0(t.lastChild.content,e-1,n)))}function uk(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function jJ(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,jJ(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(_t.empty,!0)))),t.copy(r)}function dk(t,e,n,r,i){let a=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let l=r.fillBefore(a.content,!0,o);return l&&!TBe(n,a.content,o)?l:null}function TBe(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function CBe(t){return t.spec.defining||t.spec.definingForContent}function kBe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(PJ(i,a,r))return t.step(new Gi(e,n,r));let o=DJ(i,a);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let g=i.depth,p=i.pos-1;g>0;g--,p--){let x=i.node(g).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(g)>-1?l=g:i.before(g)==p&&o.splice(1,0,-g)}let c=o.indexOf(l),u=[],d=r.openStart;for(let g=r.content,p=0;;p++){let x=g.firstChild;if(u.push(x),p==r.openStart)break;g=x.content}for(let g=d-1;g>=0;g--){let p=u[g],x=CBe(p.type);if(x&&!p.sameMarkup(i.node(Math.abs(l)-1)))d=g;else if(x||!p.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let p=(g+d+1)%(r.openStart+1),x=u[p];if(x)for(let y=0;y<o.length;y++){let b=o[(y+c)%o.length],v=!0;b<0&&(v=!1,b=-b);let E=i.node(b-1),w=i.index(b-1);if(E.canReplaceWith(w,w,x.type,x.marks))return t.replace(i.before(b),v?a.after(b):n,new Ot(RJ(r.content,0,r.openStart,p),p,r.openEnd))}}let f=t.steps.length;for(let g=o.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>f));g--){let p=o[g];p<0||(e=i.before(p),n=a.after(p))}}function RJ(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(RJ(a.content,e+1,n,r,a)))}if(e>r){let a=i.contentMatchAt(0),o=a.fillBefore(t).append(t);t=o.append(a.matchFragment(o).fillBefore(_t.empty,!0))}return t}function PBe(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=ABe(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Ot(_t.from(r),0,0))}function jBe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=DJ(r,i);for(let o=0;o<a.length;o++){let l=a[o],c=o==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 o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function DJ(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 Ap extends Ca{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 fi.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 fi.fromReplace(e,this.pos,this.pos+1,new Ot(_t.from(i),0,n.isLeaf?0:1))}getMap(){return Cs.empty}invert(e){return new Ap(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 Ap(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 Ap(n.pos,n.attr,n.value)}}Ca.jsonID("attr",Ap);class xb extends Ca{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 fi.ok(r)}getMap(){return Cs.empty}invert(e){return new xb(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 xb(n.attr,n.value)}}Ca.jsonID("docAttr",xb);let Jp=class extends Error{};Jp=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Jp.prototype=Object.create(Error.prototype);Jp.prototype.constructor=Jp;Jp.prototype.name="TransformError";class OJ{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new gb}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Jp(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=Ot.empty){let i=v2(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Ot(_t.from(r),0,0))}delete(e,n){return this.replace(e,n,Ot.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return kBe(this,e,n,r),this}replaceRangeWith(e,n,r){return PBe(this,e,n,r),this}deleteRange(e,n){return jBe(this,e,n),this}lift(e,n){return gBe(this,e,n),this}join(e,n=1){return EBe(this,e,n),this}wrap(e,n){return yBe(this,e,n),this}setBlockType(e,n=e,r,i=null){return vBe(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return wBe(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Ap(e,n,r)),this}setDocAttribute(e,n){return this.step(new xb(e,n)),this}addNodeMark(e,n){return this.step(new cd(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 gr)n.isInSet(r.marks)&&this.step(new Mf(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new Mf(e,a)),i=a.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return SBe(this,e,n,r),this}addMark(e,n,r){return fBe(this,e,n,r),this}removeMark(e,n,r){return mBe(this,e,n,r),this}clearIncompatible(e,n,r){return a4(this,e,n,r),this}}const hk=Object.create(null);class yn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new RBe(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=Ot.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,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:c,$to:u}=o[l],d=e.mapping.slice(a);e.replaceRange(d.map(c.pos),d.map(u.pos),l?Ot.empty:n),l==0&&FG(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:o,$to:l}=i[a],c=e.mapping.slice(r),u=c.map(o.pos),d=c.map(l.pos);a?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),FG(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new nn(e):ip(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 o=n<0?ip(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):ip(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Os(e.node(0))}static atStart(e){return ip(e,e,0,0,1)||new Os(e)}static atEnd(e){return ip(e,e,e.content.size,e.childCount,-1)||new Os(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=hk[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 hk)throw new RangeError("Duplicate use of selection JSON ID "+e);return hk[e]=n,n.prototype.jsonID=e,n}getBookmark(){return nn.between(this.$anchor,this.$head).getBookmark()}}yn.prototype.visible=!0;class RBe{constructor(e,n){this.$from=e,this.$to=n}}let LG=!1;function IG(t){!LG&&!t.parent.inlineContent&&(LG=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class nn extends yn{constructor(e,n=e){IG(e),IG(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 nn(i.parent.inlineContent?i:r,r)}replace(e,n=Ot.empty){if(super.replace(e,n),n==Ot.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof nn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new _2(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 nn(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 nn(e,n)}}yn.jsonID("text",nn);class _2{constructor(e,n){this.anchor=e,this.head=n}map(e){return new _2(e.map(this.anchor),e.map(this.head))}resolve(e){return nn.between(e.resolve(this.anchor),e.resolve(this.head))}}class Xt 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 Xt(a)}content(){return new Ot(_t.from(this.node),0,0)}eq(e){return e instanceof Xt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new o4(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Xt(e.resolve(n.anchor))}static create(e,n){return new Xt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Xt.prototype.visible=!1;yn.jsonID("node",Xt);class o4{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new _2(r,r):new o4(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Xt.isSelectable(r)?new Xt(n):yn.near(n)}}class Os extends yn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Ot.empty){if(n==Ot.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 Os(e)}map(e){return new Os(e)}eq(e){return e instanceof Os}getBookmark(){return DBe}}yn.jsonID("all",Os);const DBe={map(){return this},resolve(t){return new Os(t)}};function ip(t,e,n,r,i,a=!1){if(e.inlineContent)return nn.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!a&&Xt.isSelectable(l))return Xt.create(t,n-(i<0?l.nodeSize:0))}else{let c=ip(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function FG(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Gi||i instanceof Ki))return;let a=t.mapping.maps[r],o;a.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(yn.near(t.doc.resolve(o),n))}const UG=1,e1=2,zG=4;class OBe extends OJ{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|UG)&~e1,this.storedMarks=null,this}get selectionSet(){return(this.updated&UG)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=e1,this}ensureMarks(e){return gr.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&e1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~e1,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)||gr.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 o=this.doc.resolve(n);a=r==n?o.marks():o.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|=zG,this}get scrolledIntoView(){return(this.updated&zG)>0}}function BG(t,e){return!e||!t?t:t.bind(e)}class o0{constructor(e,n,r){this.name=e,this.init=BG(n.init,r),this.apply=BG(n.apply,r)}}const LBe=[new o0("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new o0("selection",{init(t,e){return t.selection||yn.atStart(e.doc)},apply(t){return t.selection}}),new o0("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new o0("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class fk{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=LBe.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 o0(r.key,r.spec.state,r))})}}class mp{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 o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let c=i?i[o].n:0,u=i?i[o].state:this,d=c<n.length&&l.spec.appendTransaction.call(l,c?n.slice(c):n,u,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<o?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),a=!0}i&&(i[o]={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 mp(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 OBe(this)}static create(e){let n=new fk(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new mp(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 fk(this.schema,e.plugins),r=n.fields,i=new mp(n);for(let a=0;a<r.length;a++){let o=r[a].name;i[o]=this.hasOwnProperty(o)?this[o]: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 fk(e.schema,e.plugins),a=new mp(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=bd.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=yn.fromJSON(a.doc,n.selection);else if(o.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==o.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){a[o.name]=u.fromJSON.call(c,e,n[l],a);return}}a[o.name]=o.init(e,a)}}),a}}function LJ(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=LJ(i,e,{})),n[r]=i}return n}class Fr{constructor(e){this.spec=e,this.props={},e.props&&LJ(e.props,this,this.props),this.key=e.key?e.key.key:IJ("plugin")}getState(e){return e[this.key]}}const mk=Object.create(null);function IJ(t){return t in mk?t+"$"+ ++mk[t]:(mk[t]=0,t+"$")}class Oi{constructor(e="key"){this.key=IJ(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const l4=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function FJ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const UJ=(t,e,n)=>{let r=FJ(t,n);if(!r)return!1;let i=c4(r);if(!i){let o=r.blockRange(),l=o&&kg(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let a=i.nodeBefore;if(KJ(t,i,e,-1))return!0;if(r.parent.content.size==0&&(eg(a,"end")||Xt.isSelectable(a)))for(let o=r.depth;;o--){let l=v2(t.doc,r.before(o),r.after(o),Ot.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(eg(a,"end")?yn.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):Xt.create(c.doc,i.pos-a.nodeSize)),e(c.scrollIntoView())}return!0}if(o==1||r.node(o-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},IBe=(t,e,n)=>{let r=FJ(t,n);if(!r)return!1;let i=c4(r);return i?zJ(t,i,e):!1},FBe=(t,e,n)=>{let r=HJ(t,n);if(!r)return!1;let i=u4(r);return i?zJ(t,i,e):!1};function zJ(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 o=e.nodeAfter,l=o,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=v2(t.doc,a,c,Ot.empty);if(!u||u.from!=a||u instanceof Gi&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(nn.create(d.doc,a)),n(d.scrollIntoView())}return!0}function eg(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 BJ=(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=c4(r)}let o=a&&a.nodeBefore;return!o||!Xt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Xt.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function c4(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 HJ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const $J=(t,e,n)=>{let r=HJ(t,n);if(!r)return!1;let i=u4(r);if(!i)return!1;let a=i.nodeAfter;if(KJ(t,i,e,1))return!0;if(r.parent.content.size==0&&(eg(a,"start")||Xt.isSelectable(a))){let o=v2(t.doc,r.before(),r.after(),Ot.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(eg(a,"start")?yn.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):Xt.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},VJ=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;a=u4(r)}let o=a&&a.nodeAfter;return!o||!Xt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Xt.create(t.doc,a.pos)).scrollIntoView()),!0)};function u4(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 UBe=(t,e)=>{let n=t.selection,r=n instanceof Xt,i;if(r){if(n.node.isTextblock||!$d(t.doc,n.from))return!1;i=n.from}else if(i=y2(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(Xt.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},zBe=(t,e)=>{let n=t.selection,r;if(n instanceof Xt){if(n.node.isTextblock||!$d(t.doc,n.to))return!1;r=n.to}else if(r=y2(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},BBe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&kg(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},GJ=(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 d4(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 HBe=(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),o=d4(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,o.createAndFill());c.setSelection(yn.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},WJ=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Os||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=d4(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,a.createAndFill());l.setSelection(nn.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},qJ=(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(Bc(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&kg(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function $Be(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Xt&&e.selection.node.isBlock)return!r.parentOffset||!Bc(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,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=d4(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),a.unshift(c&&l?{type:l}:null),o=p;break}else{if(p==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof nn||e.selection instanceof Os)&&d.deleteSelection();let f=d.mapping.map(r.pos),g=Bc(d.doc,f,a.length,a);if(g||(a[0]=l?{type:l}:null,g=Bc(d.doc,f,a.length,a)),!g)return!1;if(d.split(f,a.length,a),!c&&u&&r.node(o).type!=l){let p=d.mapping.map(r.before(o)),x=d.doc.resolve(p);l&&r.node(o-1).canReplaceWith(x.index(),x.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return n&&n(d.scrollIntoView()),!0}}const VBe=$Be(),GBe=(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(Xt.create(t.doc,i))),!0)};function WBe(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,a=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(a-1,a)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(a,a+1)||!(i.isTextblock||$d(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,o,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&WBe(t,e,n))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&l.matchType(o[0]||a.type).validEnd){if(n){let p=e.pos+a.nodeSize,x=_t.empty;for(let v=o.length-1;v>=0;v--)x=_t.from(o[v].create(null,x));x=_t.from(i.copy(x));let y=t.tr.step(new Ki(e.pos-1,p,e.pos,p,new Ot(x,1,0),o.length,!0)),b=y.doc.resolve(p+2*o.length);b.nodeAfter&&b.nodeAfter.type==i.type&&$d(y.doc,b.pos)&&y.join(b.pos),n(y.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&&kg(f);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(f,g).scrollIntoView()),!0;if(u&&eg(a,"start",!0)&&eg(i,"end")){let p=i,x=[];for(;x.push(p),!p.isTextblock;)p=p.lastChild;let y=a,b=1;for(;!y.isTextblock;y=y.firstChild)b++;if(p.canReplace(p.childCount,p.childCount,y.content)){if(n){let v=_t.empty;for(let w=x.length-1;w>=0;w--)v=_t.from(x[w].copy(v));let E=t.tr.step(new Ki(e.pos-x.length,e.pos+a.nodeSize,e.pos+b,e.pos+a.nodeSize-b,new Ot(v,x.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function XJ(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(nn.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const qBe=XJ(-1),KBe=XJ(1);function XBe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),l=o&&s4(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function HG(t,e=null){return function(n,r){let i=!1;for(let a=0;a<n.selection.ranges.length&&!i;a++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[a];n.doc.nodesBetween(o,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 o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[o];a.setBlockType(l,c,t,e)}r(a.scrollIntoView())}return!0}}function h4(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}h4(l4,UJ,BJ);h4(l4,$J,VJ);h4(GJ,WJ,qJ,VBe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function YBe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let l=r?n.tr:null;return ZBe(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function ZBe(t,e,n,r=null){let i=!1,a=e,o=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=o.resolve(e.start-2);a=new fS(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new fS(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=s4(a,n,r,e);return l?(t&&QBe(t,e,l,i,n),!0):!1}function QBe(t,e,n,r,i){let a=_t.empty;for(let d=n.length-1;d>=0;d--)a=_t.from(n[d].type.create(n[d].attrs,a));t.step(new Ki(e.start-(r?2:0),e.end,e.start,e.end,new Ot(a,0,0),n.length,!0));let o=0;for(let d=0;d<n.length;d++)n[d].type==i&&(o=d+1);let l=n.length-o,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&&Bc(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function JBe(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return a?n?r.node(a.depth-1).type==t?e8e(e,n,t,a):t8e(e,n,a):!0:!1}}function e8e(t,e,n,r){let i=t.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new Ki(a-1,o,a,o,new Ot(_t.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new fS(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=kg(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return $d(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function t8e(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,x=n.endIndex-1,y=n.startIndex;x>y;x--)p-=i.child(x).nodeSize,r.delete(p-1,p+1);let a=r.doc.resolve(n.start),o=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,o.content.append(c?_t.empty:_t.from(i))))return!1;let f=a.pos,g=f+o.nodeSize;return r.step(new Ki(f-(l?1:0),g+(c?1:0),f+1,g-1,new Ot((l?_t.empty:_t.from(i.copy(_t.empty))).append(c?_t.empty:_t.from(i.copy(_t.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function n8e(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 o=a.startIndex;if(o==0)return!1;let l=a.parent,c=l.child(o-1);if(c.type!=t)return!1;if(n){let u=c.lastChild&&c.lastChild.type==l.type,d=_t.from(u?t.create():null),f=new Ot(_t.from(t.create(null,_t.from(l.type.create(null,d)))),u?3:1,0),g=a.start,p=a.end;n(e.tr.step(new Ki(g-(u?3:1),p,g,p,f,1,!0)).scrollIntoView())}return!0}}const ua=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},tg=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Ej=null;const _c=function(t,e,n){let r=Ej||(Ej=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},r8e=function(){Ej=null},Ef=function(t,e,n,r){return n&&($G(t,e,n,r,-1)||$G(t,e,n,r,1))},i8e=/^(img|br|input|textarea|hr)$/i;function $G(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:co(t))){let o=t.parentNode;if(!o||o.nodeType!=1||fy(t)||i8e.test(t.nodeName)||t.contentEditable=="false")return!1;e=ua(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((a=o.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?co(t):0}else return!1}}function co(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function a8e(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=co(t)}else if(t.parentNode&&!fy(t))e=ua(t),t=t.parentNode;else return null}}function s8e(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&&!fy(t))e=ua(t)+1,t=t.parentNode;else return null}}function o8e(t,e,n){for(let r=e==0,i=e==co(t);r||i;){if(t==n)return!0;let a=ua(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==co(t)}}function fy(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 w2=function(t){return t.focusNode&&Ef(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function kh(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function l8e(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function c8e(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(co(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(co(r.startContainer),r.startOffset)}}}const Pl=typeof navigator<"u"?navigator:null,VG=typeof document<"u"?document:null,Vd=Pl&&Pl.userAgent||"",Aj=/Edge\/(\d+)/.exec(Vd),YJ=/MSIE \d/.exec(Vd),Nj=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Vd),us=!!(YJ||Nj||Aj),yd=YJ?document.documentMode:Nj?+Nj[1]:Aj?+Aj[1]:0,xo=!us&&/gecko\/(\d+)/i.test(Vd);xo&&+(/Firefox\/(\d+)/.exec(Vd)||[0,0])[1];const Tj=!us&&/Chrome\/(\d+)/.exec(Vd),Ma=!!Tj,ZJ=Tj?+Tj[1]:0,Ba=!us&&!!Pl&&/Apple Computer/.test(Pl.vendor),ng=Ba&&(/Mobile\/\w+/.test(Vd)||!!Pl&&Pl.maxTouchPoints>2),ro=ng||(Pl?/Mac/.test(Pl.platform):!1),u8e=Pl?/Win/.test(Pl.platform):!1,Dc=/Android \d/.test(Vd),my=!!VG&&"webkitFontSmoothing"in VG.documentElement.style,d8e=my?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function h8e(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 pc(t,e){return typeof t=="number"?t:t[e]}function f8e(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 GG(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=tg(o);continue}let l=o,c=l==a.body,u=c?h8e(a):f8e(l),d=0,f=0;if(e.top<u.top+pc(r,"top")?f=-(u.top-e.top+pc(i,"top")):e.bottom>u.bottom-pc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+pc(i,"top")-u.top:e.bottom-u.bottom+pc(i,"bottom")),e.left<u.left+pc(r,"left")?d=-(u.left-e.left+pc(i,"left")):e.right>u.right-pc(r,"right")&&(d=e.right-u.right+pc(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let p=l.scrollLeft,x=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let y=l.scrollLeft-p,b=l.scrollTop-x;e={left:e.left-y,top:e.top-b,right:e.right-y,bottom:e.bottom-b}}let g=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:tg(o)}}function m8e(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let a=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(a,o);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:QJ(t.dom)}}function QJ(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=tg(r));return e}function p8e({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;JJ(n,r==0?0:r-e)}function JJ(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 Zm=null;function g8e(t){if(t.setActive)return t.setActive();if(Zm)return t.focus(Zm);let e=QJ(t);t.focus(Zm==null?{get preventScroll(){return Zm={preventScroll:!0},!0}}:void 0),Zm||(Zm=!1,JJ(e,0))}function eee(t,e){let n,r=2e8,i,a=0,o=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=_c(d).getClientRects();else continue;for(let p=0;p<g.length;p++){let x=g[p];if(x.top<=o&&x.bottom>=l){o=Math.max(x.bottom,o),l=Math.min(x.top,l);let y=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(y<r){n=d,r=y,i=y&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,d.nodeType==1&&y&&(a=f+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!c&&x.left<=e.left&&x.right>=e.left&&(c=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(a=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?x8e(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:eee(n,i)}function x8e(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=Gu(r,1);if(a.top!=a.bottom&&f4(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function f4(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function b8e(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function y8e(t,e,n){let{node:r,offset:i}=eee(e,n),a=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();a=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,a)}function v8e(t,e,n,r){let i=-1;for(let a=e,o=!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)&&(!o&&c.left>r.left||c.top>r.top?i=l.posBefore:(!o&&c.right<r.left||c.bottom<r.top)&&(i=l.posAfter),o=!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 tee(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 o=t.childNodes[a];if(o.nodeType==1){let l=o.getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(f4(e,u))return tee(o,e,u)}}if((a=(a+1)%r)==i)break}return t}function _8e(t,e){let n=t.dom.ownerDocument,r,i=0,a=c8e(n,e.left,e.top);a&&({node:r,offset:i}=a);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let u=t.dom.getBoundingClientRect();if(!f4(e,u)||(o=tee(t.dom,e,u),!o))return null}if(Ba)for(let u=o;r&&u;u=tg(u))u.draggable&&(r=void 0);if(o=b8e(o,e),r){if(xo&&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;my&&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=v8e(t,r,i,e))}l==null&&(l=y8e(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function WG(t){return t.top<t.bottom||t.left<t.right}function Gu(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(WG(r))return r}return Array.prototype.find.call(n,WG)||t.getBoundingClientRect()}const w8e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function nee(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),o=my||xo;if(r.nodeType==3)if(o&&(w8e.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=Gu(_c(r,i,i),n);if(xo&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Gu(_c(r,i-1,i-1),-1);if(u.top==c.top){let d=Gu(_c(r,i,i+1),-1);if(d.top!=c.top)return Kx(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++,Kx(Gu(_c(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==co(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return pk(c.getBoundingClientRect(),!1)}if(a==null&&i<co(r)){let c=r.childNodes[i];if(c.nodeType==1)return pk(c.getBoundingClientRect(),!0)}return pk(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==co(r))){let c=r.childNodes[i-1],u=c.nodeType==3?_c(c,co(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Kx(Gu(u,1),!1)}if(a==null&&i<co(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?_c(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return Kx(Gu(u,-1),!0)}return Kx(Gu(r.nodeType==3?_c(r):r,-n),n>=0)}function Kx(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 pk(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 ree(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 S8e(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return ree(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 o=nee(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=_c(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"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const M8e=/[\u0590-\u08ac]/;function E8e(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,l=t.domSelection();return l?!M8e.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:o:ree(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),g=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:y}=t.domSelectionRange(),b=x&&!p.contains(x.nodeType==1?x:x.parentNode)||c==x&&u==y;try{l.collapse(d,f),c&&(c!=d||u!=f)&&l.extend&&l.extend(c,u)}catch{}return g!=null&&(l.caretBidiLevel=g),b}):r.pos==r.start()||r.pos==r.end()}let qG=null,KG=null,XG=!1;function A8e(t,e,n){return qG==e&&KG==n?XG:(qG=e,KG=n,XG=n=="up"||n=="down"?S8e(t,e,n):E8e(t,e,n))}const bo=0,YG=1,Lh=2,jl=3;class py{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=bo,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,o;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(o)+o.size:this.posAtStart}else{let a,o;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>ua(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),o;if(a&&(!n||a.node))if(r&&(o=a.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==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 o=0;o<i.children.length;o++){let l=i.children[o];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 o=this.children[r],l=a+o.size;if(l>e||o instanceof aee){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 iee&&a.side>=0;r--);if(n<=0){let a,o=!0;for(;a=r?this.children[r-1]:null,!(!a||a.dom.parentNode==this.contentDOM);r--,o=!1);return a&&n&&o&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?ua(a.dom)+1:0}}else{let a,o=!0;for(;a=r<this.children.length?this.children[r]:null,!(!a||a.dom.parentNode==this.contentDOM);r++,o=!1);return a&&o&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?ua(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 o=r,l=0;;l++){let c=this.children[l],u=o+c.size;if(i==-1&&e<=u){let d=o+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=o;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=ua(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=ua(f.dom);break}n+=f.size}a==-1&&(a=this.contentDOM.childNodes.length);break}o=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),o=Math.max(e,n);for(let p=0,x=0;p<this.children.length;p++){let y=this.children[p],b=x+y.size;if(a>x&&o<b)return y.setSelection(e-x-y.border,n-x-y.border,r,i);x=b}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((xo||Ba)&&e==n){let{node:p,offset:x}=l;if(p.nodeType==3){if(f=!!(x&&p.nodeValue[x-1]==`
  8147. `),f&&x==p.nodeValue.length)for(let y=p,b;y;y=y.parentNode){if(b=y.nextSibling){b.nodeName=="BR"&&(l=c={node:b.parentNode,offset:ua(b)+1});break}let v=y.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let y=p.childNodes[x-1];f=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(xo&&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&&Ba)&&Ef(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Ef(c.node,c.offset,d.focusNode,d.focusOffset))return;let g=!1;if((u.extend||e==n)&&!(f&&xo)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),g=!0}catch{}}if(!g){if(e>n){let x=l;l=c,c=x}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let a=this.children[i],o=r+a.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+a.border,c=o-a.border;if(e>=l&&n<=c){this.dirty=e==r||n==o?Lh:YG,e==l&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=jl:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?Lh:jl}r=o}this.dirty=Lh}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Lh:YG;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class iee extends py{constructor(e,n,r,i){let a,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,a=this}matchesWidget(e){return this.dirty==bo&&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 N8e extends py{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 Af extends py{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],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=Df.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Af(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&jl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=jl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=bo){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=bo}}slice(e,n,r){let i=Af.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=kj(a,n,o,r)),e>0&&(a=kj(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 vd extends py{constructor(e,n,r,i,a,o,l,c,u){super(e,[],a,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,a,o){let l=a.nodeViews[n.type.name],c,u=l&&l(n,a,()=>{if(!c)return o;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}=Df.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=lee(d,r,n),u?c=new T8e(e,n,r,i,d,f||null,g,u,a,o+1):n.isText?new S2(e,n,r,i,d,g,a):new vd(e,n,r,i,d,f||null,g,a,o+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=()=>_t.empty)}return e}matchesNode(e,n,r){return this.dirty==bo&&e.eq(this.node)&&pS(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,o=a&&a.pos>-1?a:null,l=a&&a.pos<0,c=new k8e(this,o&&o.node,e);R8e(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?gr.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==Lh)&&(o&&this.protectLocalComposition(e,o),see(this.contentDOM,this.children,e),ng&&D8e(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof nn)||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 o=a.nodeValue,l=O8e(this.node.content,o,r-n,i-n);return l<0?null:{node:a,pos:l,text:o}}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 o=new N8e(this,a,n,i);e.input.compositionNodes.push(o),this.children=kj(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==jl||!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=bo}updateOuterDeco(e){if(pS(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=oee(this.dom,this.nodeDOM,Cj(this.outerDeco,this.node,n),Cj(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 ZG(t,e,n,r,i){lee(r,e,t);let a=new vd(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class S2 extends vd{constructor(e,n,r,i,a,o,l){super(e,n,r,i,a,null,o,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==jl||this.dirty!=bo&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=bo||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=bo,!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 S2(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=jl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class aee extends py{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==bo&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class T8e extends vd{constructor(e,n,r,i,a,o,l,c,u,d){super(e,n,r,i,a,o,l,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==jl)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 see(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a<e.length;a++){let o=e[a],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=QG(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof Af){let c=r?r.previousSibling:t.lastChild;see(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=QG(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const S0=function(t){t&&(this.nodeName=t)};S0.prototype=Object.create(null);const Ih=[new S0];function Cj(t,e,n){if(t.length==0)return Ih;let r=n?Ih[0]:new S0,i=[r];for(let a=0;a<t.length;a++){let o=t[a].type.attrs;if(o){o.nodeName&&i.push(r=new S0(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new S0(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 oee(t,e,n,r){if(n==Ih&&r==Ih)return e;let i=e;for(let a=0;a<r.length;a++){let o=r[a],l=n[a];if(a){let c;l&&l.nodeName==o.nodeName&&i!=t&&(c=i.parentNode)&&c.nodeName.toLowerCase()==o.nodeName||(c=document.createElement(o.nodeName),c.pmIsDeco=!0,c.appendChild(i),l=Ih[0]),i=c}C8e(i,l||Ih[0],o)}return i}function C8e(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 lee(t,e,n){return oee(t,t,Ih,Cj(e,n,t.nodeType!=1))}function pS(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 QG(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class k8e{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,o=Math.min(a,e.length);for(;i<o&&(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=bo,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=Af.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,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))a=this.top.children.indexOf(o,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 o=this.top.children[i];return o.dirty==jl&&o.dom==o.contentDOM&&(o.dirty=Lh),o.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,o){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof vd){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!=jl&&pS(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,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Lh,f.updateChildren(i,o+1),f.dirty=bo),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,a,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!pS(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=vd.create(this.top,n,r,i,a,o);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 o=vd.create(this.top,e,n,r,i,a);o.contentDOM&&o.updateChildren(i,a+1),this.top.children.splice(this.index++,0,o),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 iee(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 Af;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof S2)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ba||Ma)&&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 aee(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,o=[];e:for(;i>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Af)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),o.push(l)}}return{index:i,matched:a,matches:o.reverse()}}function j8e(t,e){return t.type.side-e.type.side}function R8e(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 o=0,l=[],c=null;for(let u=0;;){let d,f;for(;o<i.length&&i[o].to==a;){let b=i[o++];b.widget&&(d?(f||(f=[d])).push(b):d=b)}if(d)if(f){f.sort(j8e);for(let b=0;b<f.length;b++)n(f[b],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 b=0;b<l.length;b++)l[b].to<=a&&l.splice(b--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)l.push(i[o++]);let x=a+g.nodeSize;if(g.isText){let b=x;o<i.length&&i[o].from<b&&(b=i[o].from);for(let v=0;v<l.length;v++)l[v].to<b&&(b=l[v].to);b<x&&(c=g.cut(b-a),g=g.cut(0,b-a),x=b,p=-1)}else for(;o<i.length&&i[o].to<x;)o++;let y=g.isInline&&!g.isLeaf?l.filter(b=>!b.inline):l.slice();r(g,y,e.forChild(a,g),p),a=x}}function D8e(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 O8e(t,e,n,r){for(let i=0,a=0;i<t.childCount&&a<=r;){let o=t.child(i++),l=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.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 kj(t,e,n,r,i){let a=[];for(let o=0,l=0;o<t.length;o++){let c=t[o],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 m4(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,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),c,u;if(w2(n)){for(c=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Xt.isSelectable(f)&&i.parent&&!(f.isInline&&o8e(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;u=new Xt(o==g?l:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,g=o;for(let p=0;p<n.rangeCount;p++){let x=n.getRangeAt(p);f=Math.min(f,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(f<0)return null;[c,o]=g==t.state.selection.anchor?[g,f]:[f,g],l=r.resolve(o)}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=p4(t,d,l,f)}return u}function cee(t){return t.editable?t.hasFocus():dee(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Hc(t,e=!1){let n=t.state.selection;if(uee(t,n),!!cee(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ma){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Ef(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)I8e(t);else{let{anchor:r,head:i}=n,a,o;JG&&!(n instanceof nn)&&(n.$from.parent.inlineContent||(a=e7(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=e7(t,n.to))),t.docView.setSelection(r,i,t,e),JG&&(a&&t7(a),o&&t7(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&L8e(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const JG=Ba||Ma&&ZJ<63;function e7(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(Ba&&i&&i.contentEditable=="false")return gk(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return gk(i);if(a)return gk(a)}}function gk(t){return t.contentEditable="true",Ba&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function t7(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function L8e(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(()=>{(!cee(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function I8e(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ua(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&us&&yd<=11&&(n.disabled=!0,n.disabled=!1)}function uee(t,e){if(e instanceof Xt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(n7(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else n7(t)}function n7(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function p4(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||nn.between(e,n,r)}function r7(t){return t.editable&&!t.hasFocus()?!1:dee(t)}function dee(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 F8e(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Ef(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Pj(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 Yu(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function i7(t,e,n){let r=t.state.selection;if(r instanceof nn)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 o=t.state.doc.resolve(i.pos+a.nodeSize*(e<0?-1:1));return Yu(t,new nn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Pj(t.state,e);return i&&i instanceof Xt?Yu(t,i):!1}else if(!(ro&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!a||a.isText)return!1;let l=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?Xt.isSelectable(a)?Yu(t,new Xt(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):my?Yu(t,new nn(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Xt&&r.node.isInline)return Yu(t,new nn(e>0?r.$to:r.$from));{let i=Pj(t.state,e);return i?Yu(t,i):!1}}}function gS(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function M0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Qm(t,e){return e<0?U8e(t):z8e(t)}function U8e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,o=!1;for(xo&&n.nodeType==1&&r<gS(n)&&M0(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(M0(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(hee(n))break;{let l=n.previousSibling;for(;l&&M0(l,-1);)i=n.parentNode,a=ua(l),l=l.previousSibling;if(l)n=l,r=gS(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?jj(t,n,r):i&&jj(t,i,a)}function z8e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=gS(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(M0(l,1))a=n,o=++r;else break}else{if(hee(n))break;{let l=n.nextSibling;for(;l&&M0(l,1);)a=l.parentNode,o=ua(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=gS(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&jj(t,a,o)}function hee(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function B8e(t,e){for(;t&&e==t.childNodes.length&&!fy(t);)e=ua(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 H8e(t,e){for(;t&&!e&&!fy(t);)e=ua(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 jj(t,e,n){if(e.nodeType!=3){let a,o;(o=B8e(e,n))?(e=o,n=0):(a=H8e(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(w2(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&&Hc(t)},50)}function a7(t,e){let n=t.state.doc.resolve(e);if(!(Ma||u8e)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),o=(a.top+a.bottom)/2;if(o>i.top&&o<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),o=(a.top+a.bottom)/2;if(o>i.top&&o<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 s7(t,e,n){let r=t.state.selection;if(r instanceof nn&&!r.empty||n.indexOf("s")>-1||ro&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Pj(t.state,e);if(o&&o instanceof Xt)return Yu(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,l=r instanceof Os?yn.near(o,e):yn.findFrom(o,e);return l?Yu(t,l):!1}return!1}function o7(t,e){if(!(t.state.selection instanceof nn))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 o=t.state.tr;return e<0?o.delete(n.pos-a.nodeSize,n.pos):o.delete(n.pos,n.pos+a.nodeSize),t.dispatch(o),!0}return!1}function l7(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function $8e(t){if(!Ba||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;l7(t,r,"true"),setTimeout(()=>l7(t,r,"false"),20)}return!1}function V8e(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function G8e(t,e){let n=e.keyCode,r=V8e(e);if(n==8||ro&&n==72&&r=="c")return o7(t,-1)||Qm(t,-1);if(n==46&&!e.shiftKey||ro&&n==68&&r=="c")return o7(t,1)||Qm(t,1);if(n==13||n==27)return!0;if(n==37||ro&&n==66&&r=="c"){let i=n==37?a7(t,t.state.selection.from)=="ltr"?-1:1:-1;return i7(t,i,r)||Qm(t,i)}else if(n==39||ro&&n==70&&r=="c"){let i=n==39?a7(t,t.state.selection.from)=="ltr"?1:-1:1;return i7(t,i,r)||Qm(t,i)}else{if(n==38||ro&&n==80&&r=="c")return s7(t,-1,r)||Qm(t,-1);if(n==40||ro&&n==78&&r=="c")return $8e(t)||s7(t,1,r)||Qm(t,1);if(r==(ro?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function g4(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 o=t.someProp("clipboardSerializer")||Df.fromSchema(t.state.schema),l=bee(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=xee[u.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let x=l.createElement(d[p]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
  8148. `);return{dom:c,text:g,slice:e}}function fee(t,e,n,r,i){let a=i.parent.type.spec.code,o,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 Ot(_t.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,x=Df.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let b=o.appendChild(document.createElement("p"));y&&b.appendChild(x.serializeNode(p.text(y,g)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=X8e(n),my&&Y8e(o);let u=o&&o.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=o.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;o=g}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||_0.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!W8e.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Z8e(c7(l,+d[1],+d[2]),d[4]);else if(l=Ot.maxOpen(q8e(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=c7(l,f,g)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const W8e=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function q8e(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,o=[];if(t.forEach(l=>{if(!o)return;let c=i.findWrapping(l.type),u;if(!c)return o=null;if(u=o.length&&a.length&&pee(c,a,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=gee(o[o.length-1],a.length));let d=mee(l,c);o.push(d),i=i.matchType(d.type),a=c}}),o)return _t.from(o)}return t}function mee(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,_t.from(t));return t}function pee(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=pee(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(_t.from(mee(n,t,i+1))))}}function gee(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,gee(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(_t.empty,!0);return t.copy(n.append(r))}function Rj(t,e,n,r,i,a){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(a=0),i<r-1&&(l=Rj(l,e,n,r,i+1,a)),i>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,a<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(_t.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function c7(t,e,n){return e<t.openStart&&(t=new Ot(Rj(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Ot(Rj(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const xee={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 u7=null;function bee(){return u7||(u7=document.implementation.createHTMLDocument("title"))}let xk=null;function K8e(t){let e=window.trustedTypes;return e?(xk||(xk=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),xk.createHTML(t)):t}function X8e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=bee().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&xee[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=K8e(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function Y8e(t){let e=t.querySelectorAll(Ma?"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 Z8e(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:o}=t;for(let l=r.length-2;l>=0;l-=2){let c=n.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;i=_t.from(c.create(r[l+1],i)),a++,o++}return new Ot(i,a,o)}const Ha={},$a={},Q8e={touchstart:!0,touchmove:!0};class J8e{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 e6e(t){for(let e in Ha){let n=Ha[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{n6e(t,r)&&!x4(t,r)&&(t.editable||!(r.type in $a))&&n(t,r)},Q8e[e]?{passive:!0}:void 0)}Ba&&t.dom.addEventListener("input",()=>null),Dj(t)}function ud(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function t6e(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 Dj(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>x4(t,r))})}function x4(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function n6e(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 r6e(t,e){!x4(t,e)&&Ha[e.type]&&(t.editable||!(e.type in $a))&&Ha[e.type](t,e)}$a.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!vee(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Dc&&Ma&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ng&&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,kh(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||G8e(t,n)?n.preventDefault():ud(t,"key")};$a.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};$a.keypress=(t,e)=>{let n=e;if(vee(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||ro&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof nn)||!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",o=>o(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function M2(t){return{left:t.clientX,top:t.clientY}}function i6e(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function b4(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let o=a.depth+1;o>0;o--)if(t.someProp(e,l=>o>a.depth?l(t,n,a.nodeAfter,a.before(o),i,!0):l(t,n,a.node(o),a.before(o),i,!1)))return!0;return!1}function Np(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 a6e(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Xt.isSelectable(r)?(Np(t,new Xt(n)),!0):!1}function s6e(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Xt&&(r=n.node);let a=t.state.doc.resolve(e);for(let o=a.depth+1;o>0;o--){let l=o>a.depth?a.nodeAfter:a.node(o);if(Xt.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(o);break}}return i!=null?(Np(t,Xt.create(t.state.doc,i)),!0):!1}function o6e(t,e,n,r,i){return b4(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?s6e(t,n):a6e(t,n))}function l6e(t,e,n,r){return b4(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function c6e(t,e,n,r){return b4(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||u6e(t,n,r)}function u6e(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Np(t,nn.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let o=a>i.depth?i.nodeAfter:i.node(a),l=i.before(a);if(o.inlineContent)Np(t,nn.create(r,l+1,l+1+o.content.size));else if(Xt.isSelectable(o))Np(t,Xt.create(r,l));else continue;return!0}}function y4(t){return xS(t)}const yee=ro?"metaKey":"ctrlKey";Ha.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=y4(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&i6e(n,t.input.lastClick)&&!n[yee]&&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 o=t.posAtCoords(M2(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new d6e(t,o,n,!!r)):(a=="doubleClick"?l6e:c6e)(t,o.pos,o.inside,n)?n.preventDefault():ud(t,"pointer"))};class d6e{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[yee],this.allowDefault=r.shiftKey;let a,o;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);a=d.parent,o=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 Xt&&u.from<=o&&u.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&xo&&!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)),ud(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(()=>Hc(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(M2(e))),this.updateAllowDefault(e),this.allowDefault||!n?ud(this.view,"pointer"):o6e(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ba&&this.mightDrag&&!this.mightDrag.node.isAtom||Ma&&!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)?(Np(this.view,yn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):ud(this.view,"pointer")}move(e){this.updateAllowDefault(e),ud(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)}}Ha.touchstart=t=>{t.input.lastTouch=Date.now(),y4(t),ud(t,"pointer")};Ha.touchmove=t=>{t.input.lastTouch=Date.now(),ud(t,"pointer")};Ha.contextmenu=t=>y4(t);function vee(t,e){return t.composing?!0:Ba&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const h6e=Dc?5e3:-1;$a.compositionstart=$a.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof nn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),xS(t,!0),t.markCursor=null;else if(xS(t,!e.selection.empty),xo&&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 o=a<0?i.lastChild:i.childNodes[a-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,a=-1}}t.input.composing=!0}_ee(t,h6e)};$a.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++,_ee(t,20))};function _ee(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>xS(t),e))}function wee(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=m6e());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function f6e(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=a8e(e.focusNode,e.focusOffset),r=s8e(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 o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function m6e(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function xS(t,e=!1){if(!(Dc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),wee(t),e||t.docView&&t.docView.dirty){let n=m4(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 p6e(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 bb=us&&yd<15||ng&&d8e<604;Ha.copy=$a.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=bb?null:n.clipboardData,o=r.content(),{dom:l,text:c}=g4(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):p6e(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function g6e(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function x6e(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?yb(t,r.value,null,i,e):yb(t,r.textContent,r.innerHTML,i,e)},50)}function yb(t,e,n,r,i){let a=fee(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||Ot.empty)))return!0;if(!a)return!1;let o=g6e(a),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(a);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function See(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," "):""}$a.paste=(t,e)=>{let n=e;if(t.composing&&!Dc)return;let r=bb?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&yb(t,See(r),r.getData("text/html"),i,n)?n.preventDefault():x6e(t,n)};class Mee{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const b6e=ro?"altKey":"ctrlKey";function Eee(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[b6e]}Ha.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(M2(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Xt?i.to-1:i.to))){if(r&&r.mightDrag)o=Xt.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&&(o=Xt.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=g4(t,l);(!n.dataTransfer.files.length||!Ma||ZJ>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(bb?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",bb||n.dataTransfer.setData("text/plain",u),t.dragging=new Mee(d,Eee(t,n),o)};Ha.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};$a.dragover=$a.dragenter=(t,e)=>e.preventDefault();$a.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(M2(n));if(!i)return;let a=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",x=>{o=x(o,t,!1)}):o=fee(t,See(n.dataTransfer),bb?null:n.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&Eee(t,n));if(t.someProp("handleDrop",x=>x(t,n,o||Ot.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let c=o?kJ(t.state.doc,a.pos,o):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(l){let{node:x}=r;x?x.replace(u):u.deleteSelection()}let d=u.mapping.map(c),f=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,g=u.doc;if(f?u.replaceRangeWith(d,d,o.content.firstChild):u.replaceRange(d,d,o),u.doc.eq(g))return;let p=u.doc.resolve(d);if(f&&Xt.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new Xt(p));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((y,b,v,E)=>x=E),u.setSelection(p4(t,p,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};Ha.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())&&Hc(t)},20))};Ha.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)};Ha.beforeinput=(t,e)=>{if(Ma&&Dc&&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,kh(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 $a)Ha[t]=$a[t];function vb(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 bS{constructor(e,n){this.toDOM=e,this.spec=n||Zh,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new Ia(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof bS&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&vb(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class _d{constructor(e,n){this.attrs=e,this.spec=n||Zh}map(e,n,r,i){let a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=o?null:new Ia(a,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof _d&&vb(this.attrs,e.attrs)&&vb(this.spec,e.spec)}static is(e){return e.type instanceof _d}destroy(){}}class v4{constructor(e,n){this.attrs=e,this.spec=n||Zh}map(e,n,r,i){let a=e.mapResult(n.from+i,1);if(a.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=a.pos?null:new Ia(a.pos-r,o.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 v4&&vb(this.attrs,e.attrs)&&vb(this.spec,e.spec)}destroy(){}}class Ia{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ia(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 Ia(e,e,new bS(n,r))}static inline(e,n,r,i){return new Ia(e,n,new _d(r,i))}static node(e,n,r,i){return new Ia(e,n,new v4(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof _d}get widget(){return this.type instanceof bS}}const ap=[],Zh={};class Rr{constructor(e,n){this.local=e.length?e:ap,this.children=n.length?n:ap}static create(e,n){return n.length?yS(n,e,0,Zh):_a}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 o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!a||a(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,i+l,a)}}map(e,n,r){return this==_a||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Zh)}mapInner(e,n,r,i,a){let o;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,r,i);c&&c.type.valid(n,c)?(o||(o=[])).push(c):a.onRemove&&a.onRemove(this.local[l].spec)}return this.children.length?y6e(this.children,o||[],e,n,r,i,a):o?new Rr(o.sort(Qh),ap):_a}add(e,n){return n.length?this==_a?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=Nee(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,yS(d,l,u+1,Zh)),a+=3}});let o=Aee(a?Tee(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new Rr(o.length?this.local.concat(o).sort(Qh):this.local,i||this.children)}remove(e){return e.length==0||this==_a?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 o,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,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[a+2].removeInner(o,l+1);u!=_a?r[a+2]=u:(r.splice(a,3),a-=3)}if(i.length){for(let a=0,o;a<e.length;a++)if(o=e[a])for(let l=0;l<i.length;l++)i[l].eq(o,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):_a}forChild(e,n){if(this==_a)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,o=a+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<o&&c.to>a&&c.type instanceof _d){let u=Math.max(a,c.from)-a,d=Math.min(o,c.to)-a;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let l=new Rr(i.sort(Qh),ap);return r?new nd([l,r]):l}return r||_a}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 _4(this.localsInner(e))}localsInner(e){if(this==_a)return ap;if(e.inlineContent||!this.local.some(_d.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof _d||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Rr.empty=new Rr([],[]);Rr.removeOverlap=_4;const _a=Rr.empty;class nd{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Zh));return nd.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!=_a&&(a instanceof nd?r=r.concat(a.members):r.push(a))}return nd.from(r)}eq(e){if(!(e instanceof nd)||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 o=0;o<a.length;o++)n.push(a[o])}}return n?_4(r?n:n.sort(Qh)):ap}static from(e){switch(e.length){case 0:return _a;case 1:return e[0];default:return new nd(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 y6e(t,e,n,r,i,a,o){let l=t.slice();for(let u=0,d=a;u<n.maps.length;u++){let f=0;n.maps[u].forEach((g,p,x,y)=>{let b=y-x-(p-g);for(let v=0;v<l.length;v+=3){let E=l[v+1];if(E<0||g>E+d-f)continue;let w=l[v]+d-f;p>=w?l[v+1]=g<=w?-2:-1:g>=d&&b&&(l[v]+=b,l[v+1]+=b)}f+=b}),d=n.maps[u].map(d,-1)}let c=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){c=!0,l[u+1]=-1;continue}let d=n.map(t[u]+a),f=d-i;if(f<0||f>=r.content.size){c=!0;continue}let g=n.map(t[u+1]+a,-1),p=g-i,{index:x,offset:y}=r.content.findIndex(f),b=r.maybeChild(x);if(b&&y==f&&y+b.nodeSize==p){let v=l[u+2].mapInner(n,b,d+1,t[u]+a+1,o);v!=_a?(l[u]=f,l[u+1]=p,l[u+2]=v):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=v6e(l,t,e,n,i,a,o),d=yS(u,r,0,o);e=d.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,g=0;f<d.children.length;f+=3){let p=d.children[f];for(;g<l.length&&l[g]<p;)g+=3;l.splice(g,0,d.children[f],d.children[f+1],d.children[f+2])}}return new Rr(e.sort(Qh),l)}function Aee(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 Ia(i.from+e,i.to+e,i.type))}return n}function v6e(t,e,n,r,i,a,o){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):o.onRemove&&o.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 Nee(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let a=0,o;a<t.length;a++)(o=t[a])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[a]=null);return i}function Tee(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function yS(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=Nee(t,l,c+n);if(u){a=!0;let d=yS(u,l,n+c+1,r);d!=_a&&i.push(c,c+l.nodeSize,d)}});let o=Aee(a?Tee(t):t,-n).sort(Qh);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new Rr(o,i):_a}function Qh(t,e){return t.from-e.from||t.to-e.to}function _4(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),d7(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),d7(e,i,r.copy(a.from,r.to)));break}}}return e}function d7(t,e,n){for(;e<t.length&&Qh(n,t[e])>0;)e++;t.splice(e,0,n)}function bk(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=_a&&e.push(r)}),t.cursorWrapper&&e.push(Rr.create(t.state.doc,[t.cursorWrapper.deco])),nd.from(e)}const _6e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},w6e=us&&yd<=11;class S6e{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 M6e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new S6e,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]);us&&yd<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),w6e&&(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,_6e)),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(r7(this.view)){if(this.suppressingSelectionUpdates)return Hc(this.view);if(us&&yd<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ef(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=tg(a))n.add(a);for(let a=e.anchorNode;a;a=tg(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)&&r7(e)&&!this.ignoreSelectionChange(r),a=-1,o=-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),o=o<0?f.to:Math.max(f.to,o),f.typeOver&&(l=!0))}if(xo&&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||N6e(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&&w2(r)&&(u=m4(e))&&u.eq(yn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Hc(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,o),E6e(e)),this.handleDOMChange(a,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Hc(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(us&&yd<=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 o=i&&i.parentNode==e.target?ua(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=a&&a.parentNode==e.target?ua(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 h7=new WeakMap,f7=!1;function E6e(t){if(!h7.has(t)&&(h7.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=xo,f7)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."),f7=!0}}function m7(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Ef(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function A6e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return m7(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?m7(t,n):null}function N6e(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 T6e(t,e,n){let{node:r,fromOffset:i,toOffset:a,from:o,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}],w2(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Ma&&t.input.lastKeyCode===8)for(let b=a;b>i;b--){let v=r.childNodes[b-1],E=v.pmViewDesc;if(v.nodeName=="BR"&&!E){a=b;break}if(!E||E.size)break}let f=t.state.doc,g=t.someProp("domParser")||_0.fromSchema(t.state.schema),p=f.resolve(o),x=null,y=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:C6e,context:p});if(u&&u[0].pos!=null){let b=u[0].pos,v=u[1]&&u[1].pos;v==null&&(v=b),x={anchor:b+o,head:v+o}}return{doc:y,sel:x,from:o,to:l}}function C6e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ba&&/^(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||Ba&&/^(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 k6e=/^(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 T=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,L=m4(t,T);if(L&&!t.state.selection.eq(L)){if(Ma&&Dc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",D=>D(t,kh(13,"Enter"))))return;let k=t.state.tr.setSelection(L);T=="pointer"?k.setMeta("pointer",!0):T=="key"&&k.scrollIntoView(),a&&k.setMeta("composition",a),t.dispatch(k)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let c=t.state.selection,u=T6e(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),g,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,p="end"):(g=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let x=D6e(f.content,u.doc.content,u.from,g,p);if(x&&t.input.domChangeCount++,(ng&&t.input.lastIOSEnter>Date.now()-225||Dc)&&i.some(T=>T.nodeType==1&&!k6e.test(T.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",T=>T(t,kh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof nn&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))x={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let T=p7(t,t.state.doc,u.sel);if(T&&!T.eq(t.state.selection)){let L=t.state.tr.setSelection(T);a&&L.setMeta("composition",a),t.dispatch(L)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof nn&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),us&&yd<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>u.from&&u.doc.textBetween(x.start-u.from-1,x.start-u.from+1)=="  "&&(x.start--,x.endA--,x.endB--);let y=u.doc.resolveNoCache(x.start-u.from),b=u.doc.resolveNoCache(x.endB-u.from),v=d.resolve(x.start),E=y.sameParent(b)&&y.parent.inlineContent&&v.end()>=x.endA;if((ng&&t.input.lastIOSEnter>Date.now()-225&&(!E||i.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!E&&y.pos<u.doc.content.size&&(!y.sameParent(b)||!y.parent.inlineContent)&&y.pos<b.pos&&!/\S/.test(u.doc.textBetween(y.pos,b.pos,"","")))&&t.someProp("handleKeyDown",T=>T(t,kh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&R6e(d,x.start,x.endA,y,b)&&t.someProp("handleKeyDown",T=>T(t,kh(8,"Backspace")))){Dc&&Ma&&t.domObserver.suppressSelectionUpdates();return}Ma&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),Dc&&!E&&y.start()!=b.start()&&b.parentOffset==0&&y.depth==b.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==x.endA&&(x.endB-=2,b=u.doc.resolveNoCache(x.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(T){return T(t,kh(13,"Enter"))})},20));let w=x.start,N=x.endA,A=T=>{let L=T||t.state.tr.replace(w,N,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let k=p7(t,L.doc,u.sel);k&&!(Ma&&t.composing&&k.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(k.head==w||k.head==L.mapping.map(N)-1)||us&&k.empty&&k.head==w)&&L.setSelection(k)}return a&&L.setMeta("composition",a),L.scrollIntoView()},C;if(E)if(y.pos==b.pos){us&&yd<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Hc(t),20));let T=A(t.state.tr.delete(w,N)),L=d.resolve(x.start).marksAcross(d.resolve(x.endA));L&&T.ensureMarks(L),t.dispatch(T)}else if(x.endA==x.endB&&(C=j6e(y.parent.content.cut(y.parentOffset,b.parentOffset),v.parent.content.cut(v.parentOffset,x.endA-v.start())))){let T=A(t.state.tr);C.type=="add"?T.addMark(w,N,C.mark):T.removeMark(w,N,C.mark),t.dispatch(T)}else if(y.parent.child(y.index()).isText&&y.index()==b.index()-(b.textOffset?0:1)){let T=y.parent.textBetween(y.parentOffset,b.parentOffset),L=()=>A(t.state.tr.insertText(T,w,N));t.someProp("handleTextInput",k=>k(t,w,N,T,L))||t.dispatch(L())}else t.dispatch(A());else t.dispatch(A())}function p7(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:p4(t,e.resolve(n.anchor),e.resolve(n.head))}function j6e(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,o,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],o="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&a.length==1)l=a[0],o="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(_t.from(u).eq(t))return{mark:l,type:o}}function R6e(t,e,n,r,i){if(n-e<=i.pos-r.pos||yk(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 o=t.resolve(yk(a,!0,!0));return!o.parent.isTextblock||o.pos>n||yk(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function yk(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 D6e(t,e,n,r,i){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let c=Math.max(0,a-Math.min(o,l));r-=o+c-a}if(o<a&&t.size<e.size){let c=r<=a&&r>=o?a-r:0;a-=c,a&&a<e.size&&g7(e.textBetween(a-1,a+1))&&(a+=c?1:-1),l=a+(l-o),o=a}else if(l<a){let c=r<=a&&r>=l?a-r:0;a-=c,a&&a<t.size&&g7(t.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-l),l=a}return{start:a,endA:o,endB:l}}function g7(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 Cee{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 J8e,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(_7),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=y7(this),b7(this),this.nodeViews=v7(this),this.docView=ZG(this.state.doc,x7(this),bk(this),this.dom,this),this.domObserver=new M6e(this,(r,i,a,o)=>P6e(this,r,i,a,o)),this.domObserver.start(),e6e(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&&Dj(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(_7),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,o=!1;e.storedMarks&&this.composing&&(wee(this),o=!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=v7(this);L6e(p,this.nodeViews)&&(this.nodeViews=p,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Dj(this),this.editable=y7(this),b7(this);let c=bk(this),u=x7(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))&&(o=!0);let g=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&m8e(this);if(o){this.domObserver.stop();let p=f&&(us||Ma)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&O6e(i.selection,e.selection);if(f){let x=Ma?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=f6e(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=ZG(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&F8e(this))?Hc(this,p):(uee(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&&p8e(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 Xt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&GG(this,n.getBoundingClientRect(),e)}else GG(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 Mee(e.slice,e.move,i<0?void 0:Xt.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 o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(l):l))return i}let a=this.state.plugins;if(a)for(let o=0;o<a.length;o++){let l=a[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(us){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&&g8e(this.dom),Hc(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 _8e(this,e)}coordsAtPos(e,n=1){return nee(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 A8e(this,n||this.state,e)}pasteHTML(e,n){return yb(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return yb(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return g4(this,e)}destroy(){this.docView&&(t6e(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],bk(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,r8e())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return r6e(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ba&&this.root.nodeType===11&&l8e(this.dom.ownerDocument)==this.dom&&A6e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Cee.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function x7(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"),[Ia.node(0,t.state.doc.content.size,e)]}function b7(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:Ia.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function y7(t){return!t.someProp("editable",e=>e(t.state)===!1)}function O6e(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 v7(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 L6e(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 _7(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 Ld={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:"'"},vS={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},I6e=typeof navigator<"u"&&/Mac/.test(navigator.platform),F6e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var da=0;da<10;da++)Ld[48+da]=Ld[96+da]=String(da);for(var da=1;da<=24;da++)Ld[da+111]="F"+da;for(var da=65;da<=90;da++)Ld[da]=String.fromCharCode(da+32),vS[da]=String.fromCharCode(da);for(var vk in Ld)vS.hasOwnProperty(vk)||(vS[vk]=Ld[vk]);function U6e(t){var e=I6e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||F6e&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?vS:Ld)[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 z6e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),B6e=typeof navigator<"u"&&/Win/.test(navigator.platform);function H6e(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,o;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!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))z6e?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),o&&(n="Meta-"+n),a&&(n="Shift-"+n),n}function $6e(t){let e=Object.create(null);for(let n in t)e[H6e(n)]=t[n];return e}function _k(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function V6e(t){return new Fr({props:{handleKeyDown:kee(t)}})}function kee(t){let e=$6e(t);return function(n,r){let i=U6e(r),a,o=e[_k(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[_k(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(B6e&&r.ctrlKey&&r.altKey)&&(a=Ld[r.keyCode])&&a!=i){let l=e[_k(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var G6e=Object.defineProperty,w4=(t,e)=>{for(var n in e)G6e(t,n,{get:e[n],enumerable:!0})};function E2(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 A2=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(([o,l])=>[o,(...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,o=[],l=!!t,c=t||i.tr,u=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),o.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,g])=>[f,(...x)=>{const y=this.buildProps(c,e),b=g(...x)(y);return o.push(b),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,o={tr:t,editor:r,view:a,state:E2({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)(o)]))}};return o}},Pee={};w4(Pee,{blur:()=>W6e,clearContent:()=>q6e,clearNodes:()=>K6e,command:()=>X6e,createParagraphNear:()=>Y6e,cut:()=>Z6e,deleteCurrentNode:()=>Q6e,deleteNode:()=>J6e,deleteRange:()=>eHe,deleteSelection:()=>tHe,enter:()=>nHe,exitCode:()=>rHe,extendMarkRange:()=>iHe,first:()=>aHe,focus:()=>oHe,forEach:()=>lHe,insertContent:()=>cHe,insertContentAt:()=>hHe,joinBackward:()=>pHe,joinDown:()=>mHe,joinForward:()=>gHe,joinItemBackward:()=>xHe,joinItemForward:()=>bHe,joinTextblockBackward:()=>yHe,joinTextblockForward:()=>vHe,joinUp:()=>fHe,keyboardShortcut:()=>wHe,lift:()=>SHe,liftEmptyBlock:()=>MHe,liftListItem:()=>EHe,newlineInCode:()=>AHe,resetAttributes:()=>NHe,scrollIntoView:()=>THe,selectAll:()=>CHe,selectNodeBackward:()=>kHe,selectNodeForward:()=>PHe,selectParentNode:()=>jHe,selectTextblockEnd:()=>RHe,selectTextblockStart:()=>DHe,setContent:()=>OHe,setMark:()=>JHe,setMeta:()=>e$e,setNode:()=>t$e,setNodeSelection:()=>n$e,setTextDirection:()=>r$e,setTextSelection:()=>i$e,sinkListItem:()=>a$e,splitBlock:()=>s$e,splitListItem:()=>o$e,toggleList:()=>l$e,toggleMark:()=>c$e,toggleNode:()=>u$e,toggleWrap:()=>d$e,undoInputRule:()=>h$e,unsetAllMarks:()=>f$e,unsetMark:()=>m$e,unsetTextDirection:()=>p$e,updateAttributes:()=>g$e,wrapIn:()=>x$e,wrapInList:()=>b$e});var W6e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),q6e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),K6e=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:o})=>{t.doc.nodesBetween(a.pos,o.pos,(l,c)=>{if(l.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(c)),g=u.resolve(d.map(c+l.nodeSize)),p=f.blockRange(g);if(!p)return;const x=kg(p);if(l.type.isTextblock){const{defaultType:y}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,y)}(x||x===0)&&e.lift(p,x)})}),!0},X6e=t=>e=>t(e),Y6e=()=>({state:t,dispatch:e})=>WJ(t,e),Z6e=(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 o=r.mapping.map(e);return r.insert(o,a.content),r.setSelection(new nn(r.doc.resolve(Math.max(o-1,0)))),!0},Q6e=()=>({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 gi(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 J6e=t=>({tr:e,state:n,dispatch:r})=>{const i=gi(t,n.schema),a=e.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===i){if(r){const c=a.before(o),u=a.after(o);e.delete(c,u).scrollIntoView()}return!0}return!1},eHe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},tHe=()=>({state:t,dispatch:e})=>l4(t,e),nHe=()=>({commands:t})=>t.keyboardShortcut("Enter"),rHe=()=>({state:t,dispatch:e})=>HBe(t,e);function S4(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function _S(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:S4(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function jee(t,e,n={}){return t.find(r=>r.type===e&&_S(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function w7(t,e,n={}){return!!jee(t,e,n)}function M4(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),!jee([...i.node.marks],e,n)))return;let o=i.index,l=t.start()+i.offset,c=o+1,u=l+i.node.nodeSize;for(;o>0&&w7([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&w7([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function au(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 iHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=au(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=M4(c,a,e);if(f&&f.from<=u&&f.to>=d){const g=nn.create(o,f.from,f.to);n.setSelection(g)}}return!0},aHe=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 Ree(t){return t instanceof nn}function Fh(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Dee(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"?nn.create(t,Fh(0,i,a),Fh(t.content.size,i,a)):nn.create(t,Fh(e,i,a),Fh(e,i,a))}function sHe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function E4(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var oHe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(E4()||sHe())&&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&&!Ree(n.state.selection))return o(),!0;const l=Dee(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),o()),!0},lHe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),cHe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Oee=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&&Oee(r)}return t};function t1(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 Oee(n)}function _b(t,e,n){if(t instanceof bd||t instanceof _t)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 _t.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}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),_b("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new yJ({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=>(o=!0,l=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?_0.fromSchema(c).parseSlice(t1(t),n.parseOptions):_0.fromSchema(c).parse(t1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=_0.fromSchema(e);return n.slice?a.parseSlice(t1(t),n.parseOptions).content:a.parse(t1(t),n.parseOptions)}return _b("",e,n)}function uHe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Gi||i instanceof Ki))return;const a=t.mapping.maps[r];let o=0;a.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(yn.near(t.doc.resolve(o),n))}var dHe=t=>!("type"in t),hHe=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var o;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const c=b=>{a.emit("contentError",{editor:a,error:b,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{_b(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(b){c(b)}try{l=_b(e,a.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:a.options.enableContentCheck})}catch(b){return c(b),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,p=!0;if((dHe(l)?l:[l]).forEach(b=>{b.check(),g=g?b.isText&&b.marks.length===0:!1,p=p?b.isBlock:!1}),d===f&&p){const{parent:b}=r.doc.resolve(d);b.isTextblock&&!b.type.spec.code&&!b.childCount&&(d-=1,f+=1)}let y;if(g){if(Array.isArray(e))y=e.map(b=>b.text||"").join("");else if(e instanceof _t){let b="";e.forEach(v=>{v.text&&(b+=v.text)}),y=b}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,d,f)}else{y=l;const b=r.doc.resolve(d),v=b.node(),E=b.parentOffset===0,w=v.isText||v.isTextblock,N=v.content.size>0;E&&w&&N&&(d=Math.max(0,d-1)),r.replaceWith(d,f,y)}n.updateSelection&&uHe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:y}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:y})}return!0},fHe=()=>({state:t,dispatch:e})=>UBe(t,e),mHe=()=>({state:t,dispatch:e})=>zBe(t,e),pHe=()=>({state:t,dispatch:e})=>UJ(t,e),gHe=()=>({state:t,dispatch:e})=>$J(t,e),xHe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=y2(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},bHe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=y2(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},yHe=()=>({state:t,dispatch:e})=>IBe(t,e),vHe=()=>({state:t,dispatch:e})=>FBe(t,e);function Lee(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function _He(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,o;for(let l=0;l<e.length-1;l+=1){const c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!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))E4()||Lee()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var wHe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=_He(t).split(/-(?!$)/),o=a.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,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 Id(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?gi(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,g)=>{if(f.isText)return;const p=Math.max(r,g),x=Math.min(i,g+f.nodeSize);l.push({node:f,from:p,to:x})});const c=i-r,u=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>_S(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=c}var SHe=(t,e={})=>({state:n,dispatch:r})=>{const i=gi(t,n.schema);return Id(n,i,e)?BBe(n,r):!1},MHe=()=>({state:t,dispatch:e})=>qJ(t,e),EHe=t=>({state:e,dispatch:n})=>{const r=gi(t,e.schema);return JBe(r)(e,n)},AHe=()=>({state:t,dispatch:e})=>GJ(t,e);function N2(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function S7(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 NHe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=N2(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=gi(t,r.schema)),l==="mark"&&(o=au(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,S7(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(g=>{o===g.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,o.create(S7(g.attrs,e))))})})}),c},THe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),CHe=()=>({tr:t,dispatch:e})=>{if(e){const n=new Os(t.doc);t.setSelection(n)}return!0},kHe=()=>({state:t,dispatch:e})=>BJ(t,e),PHe=()=>({state:t,dispatch:e})=>VJ(t,e),jHe=()=>({state:t,dispatch:e})=>GBe(t,e),RHe=()=>({state:t,dispatch:e})=>KBe(t,e),DHe=()=>({state:t,dispatch:e})=>qBe(t,e);function Oj(t,e,n={},r={}){return _b(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var OHe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:l})=>{const{doc:c}=a;if(r.preserveWhitespace!=="full"){const u=Oj(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return o&&a.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function Iee(t,e){const n=au(e,t.schema),{from:r,to:i,empty:a}=t.selection,o=[];a?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,c=>{o.push(...c.marks)});const l=o.find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function Fee(t,e){const n=new OJ(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function LHe(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 IHe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function FHe(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 T2(t){return e=>FHe(e.$from,t)}function qt(t,e,n){return t.config[e]===void 0&&t.parent?qt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?qt(t.parent,e,n):null}):t.config[e]}function A4(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=qt(e,"addExtensions",n);return r?[e,...A4(r())]:e}).flat(10)}function N4(t,e){const n=Df.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Uee(t){return typeof t=="function"}function Yn(t,e=void 0,...n){return Uee(t)?e?t.bind(e)(...n):t(...n):t}function UHe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function rg(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 zee(t){const e=[],{nodeExtensions:n,markExtensions:r}=rg(t),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:i},c=qt(o,"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(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=qt(o,"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:o.name,name:d,attribute:g})})}),e}function Xr(...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 wS(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)=>Xr(n,r),{})}function zHe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function M7(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,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):zHe(n.getAttribute(o.name));return l==null?a:{...a,[o.name]:l}},{});return{...r,...i}}}}function E7(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&UHe(n)?!1:n!=null))}function A7(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 BHe(t,e){var n;const r=zee(t),{nodeExtensions:i,markExtensions:a}=rg(t),o=(n=i.find(u=>qt(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(v=>v.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((v,E)=>{const w=qt(E,"extendNodeSchema",f);return{...v,...w?w(u):{}}},{}),p=E7({...g,content:Yn(qt(u,"content",f)),marks:Yn(qt(u,"marks",f)),group:Yn(qt(u,"group",f)),inline:Yn(qt(u,"inline",f)),atom:Yn(qt(u,"atom",f)),selectable:Yn(qt(u,"selectable",f)),draggable:Yn(qt(u,"draggable",f)),code:Yn(qt(u,"code",f)),whitespace:Yn(qt(u,"whitespace",f)),linebreakReplacement:Yn(qt(u,"linebreakReplacement",f)),defining:Yn(qt(u,"defining",f)),isolating:Yn(qt(u,"isolating",f)),attrs:Object.fromEntries(d.map(A7))}),x=Yn(qt(u,"parseHTML",f));x&&(p.parseDOM=x.map(v=>M7(v,d)));const y=qt(u,"renderHTML",f);y&&(p.toDOM=v=>y({node:v,HTMLAttributes:wS(v,d)}));const b=qt(u,"renderText",f);return b&&(p.toText=b),[u.name,p]})),c=Object.fromEntries(a.map(u=>{const d=r.filter(b=>b.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((b,v)=>{const E=qt(v,"extendMarkSchema",f);return{...b,...E?E(u):{}}},{}),p=E7({...g,inclusive:Yn(qt(u,"inclusive",f)),excludes:Yn(qt(u,"excludes",f)),group:Yn(qt(u,"group",f)),spanning:Yn(qt(u,"spanning",f)),code:Yn(qt(u,"code",f)),attrs:Object.fromEntries(d.map(A7))}),x=Yn(qt(u,"parseHTML",f));x&&(p.parseDOM=x.map(b=>M7(b,d)));const y=qt(u,"renderHTML",f);return y&&(p.toDOM=b=>y({mark:b,HTMLAttributes:wS(b,d)})),[u.name,p]}));return new yJ({topNode:o,nodes:l,marks:c})}function HHe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function T4(t){return t.sort((n,r)=>{const i=qt(n,"priority")||100,a=qt(r,"priority")||100;return i>a?-1:i<a?1:0})}function Bee(t){const e=T4(A4(t)),n=HHe(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 Hee(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
  8150. `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,f)=>{var g;c.isBlock&&u>r&&(l+=a);const p=o?.[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 $He(t,e){const n={from:0,to:t.content.size};return Hee(t,n,e)}function $ee(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function VHe(t,e){const n=gi(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,l=>{a.push(l)});const o=a.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function Vee(t,e){const n=N2(typeof e=="string"?e:e.name,t.schema);return n==="node"?VHe(t,e):n==="mark"?Iee(t,e):{}}function GHe(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function WHe(t){const e=GHe(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,o)=>o!==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 Gee(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const o=[];if(i.ranges.length)i.forEach((l,c)=>{o.push({from:l,to:c})});else{const{from:l,to:c}=n[a];if(l===void 0||c===void 0)return;o.push({from:l,to:c})}o.forEach(({from:l,to:c})=>{const u=e.slice(a).map(l,-1),d=e.slice(a).map(c),f=e.invert().map(u,-1),g=e.invert().map(d);r.push({oldRange:{from:f,to:g},newRange:{from:u,to:d}})})}),WHe(r)}function C4(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=M4(a,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,a)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:a,to:a+i.nodeSize,mark:o})))}),r}var qHe=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,o=null;for(;a>0&&o===null;){const l=i.node(a);l?.type.name===e?o=l:a-=1}return[o,a]};function wk(t,e){return e.nodes[t]||e.marks[t]||null}function F1(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 KHe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,o,l)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{node:i,pos:a,parent:o,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-a))}),n};function Lj(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?au(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>_S(f.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:g})=>{const p=f.pos,x=g.pos;t.doc.nodesBetween(p,x,(y,b)=>{if(!y.isText&&!y.marks.length)return;const v=Math.max(p,b),E=Math.min(x,b+y.nodeSize),w=E-v;o+=w,l.push(...y.marks.map(N=>({mark:N,from:v,to:E})))})}),o===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>_S(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)>=o}function XHe(t,e,n={}){if(!e)return Id(t,null,n)||Lj(t,null,n);const r=N2(e,t.schema);return r==="node"?Id(t,e,n):r==="mark"?Lj(t,e,n):!1}var YHe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=T2(l=>l.type.name===e)(t.selection);if(!a)return!1;const o=t.doc.resolve(a.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},ZHe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function N7(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function T7(t,e){const{nodeExtensions:n}=rg(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=Yn(qt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function C2(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&&(C2(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Wee(t){return t instanceof Xt}function QHe(t,e,n){var r;const{selection:i}=e;let a=null;if(Ree(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:o}=i;return o.some(({$from:l,$to:c})=>{let u=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,c.pos,(d,f,g)=>{if(u)return!1;if(d.isInline){const p=!g||g.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(n));u=p&&x}return!u}),u})}var JHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:l}=a,c=au(t,r.schema);if(i)if(o){const u=Iee(r,c);n.addStoredMark(c.create({...u,...e}))}else l.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(d,f,(g,p)=>{const x=Math.max(p,d),y=Math.min(p+g.nodeSize,f);g.marks.find(v=>v.type===c)?g.marks.forEach(v=>{c===v.type&&n.addMark(x,y,c.create({...v.attrs,...e}))}):n.addMark(x,y,c.create(e))})});return QHe(r,n,c)},e$e=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),t$e=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=gi(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:l})=>HG(a,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>HG(a,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},n$e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Fh(t,0,r.content.size),a=Xt.create(r,i);e.setSelection(a)}return!0},r$e=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=a.from,l=a.to),i&&n.doc.nodesBetween(o,l,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},i$e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,o=nn.atStart(r).from,l=nn.atEnd(r).to,c=Fh(i,o,l),u=Fh(a,o,l),d=nn.create(r,c,u);e.setSelection(d)}return!0},a$e=t=>({state:e,dispatch:n})=>{const r=gi(t,e.schema);return n8e(r)(e,n)};function C7(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 s$e=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:o}=e,{$from:l,$to:c}=a,u=i.extensionManager.attributes,d=F1(u,l.node().type.name,l.node().attrs);if(a instanceof Xt&&a.node.isBlock)return!l.parentOffset||!Bc(o,l.pos)?!1:(r&&(t&&C7(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:LHe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=f&&g?[{type:g,attrs:d}]:void 0,x=Bc(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!x&&Bc(e.doc,e.mapping.map(l.pos),1,g?[{type:g}]:void 0)&&(x=!0,p=g?[{type:g,attrs:d}]:void 0),r){if(x&&(a instanceof nn&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),g&&!f&&!l.parentOffset&&l.parent.type!==g)){const y=e.mapping.map(l.before()),b=e.doc.resolve(y);l.node(-1).canReplaceWith(b.index(),b.index()+1,g)&&e.setNodeMarkup(e.mapping.map(l.before()),g)}t&&C7(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},o$e=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const l=gi(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 v=_t.empty;const E=c.index(-1)?1:c.index(-2)?2:3;for(let L=c.depth-E;L>=c.depth-3;L-=1)v=_t.from(c.node(L).copy(v));const w=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,N={...F1(g,c.node().type.name,c.node().attrs),...e},A=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(N))||void 0;v=v.append(_t.from(l.createAndFill(null,A)||void 0));const C=c.before(c.depth-(E-1));n.replace(C,c.after(-w),new Ot(v,4-E,0));let T=-1;n.doc.nodesBetween(C,n.doc.content.size,(L,k)=>{if(T>-1)return!1;L.isTextblock&&L.content.size===0&&(T=k+1)}),T>-1&&n.setSelection(nn.near(n.doc.resolve(T))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...F1(g,f.type.name,f.attrs),...e},y={...F1(g,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const b=p?[{type:l,attrs:x},{type:p,attrs:y}]:[{type:l,attrs:x}];if(!Bc(n.doc,c.pos,2))return!1;if(i){const{selection:v,storedMarks:E}=r,{splittableMarks:w}=a.extensionManager,N=E||v.$to.parentOffset&&v.$from.marks();if(n.split(c.pos,2,b).scrollIntoView(),!N||!i)return!0;const A=N.filter(C=>w.includes(C.type.name));n.ensureMarks(A)}return!0},Sk=(t,e)=>{const n=T2(o=>o.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&&$d(t.doc,n.pos)&&t.join(n.pos),!0},Mk=(t,e)=>{const n=T2(o=>o.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&&$d(t.doc,r)&&t.join(r),!0},l$e=(t,e,n,r={})=>({editor:i,tr:a,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:g}=i.extensionManager,p=gi(t,o.schema),x=gi(e,o.schema),{selection:y,storedMarks:b}=o,{$from:v,$to:E}=y,w=v.blockRange(E),N=b||y.$to.parentOffset&&y.$from.marks();if(!w)return!1;const A=T2(C=>T7(C.type.name,f))(y);if(w.depth>=1&&A&&w.depth-A.depth<=1){if(A.node.type===p)return u.liftListItem(x);if(T7(A.node.type.name,f)&&p.validContent(A.node.content)&&l)return c().command(()=>(a.setNodeMarkup(A.pos,p),!0)).command(()=>Sk(a,p)).command(()=>Mk(a,p)).run()}return!n||!N||!l?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>Sk(a,p)).command(()=>Mk(a,p)).run():c().command(()=>{const C=d().wrapInList(p,r),T=N.filter(L=>g.includes(L.type.name));return a.ensureMarks(T),C?!0:u.clearNodes()}).wrapInList(p,r).command(()=>Sk(a,p)).command(()=>Mk(a,p)).run()},c$e=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=au(t,r.schema);return Lj(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},u$e=(t,e,n={})=>({state:r,commands:i})=>{const a=gi(t,r.schema),o=gi(e,r.schema),l=Id(r,a,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),l?i.setNode(o,c):i.setNode(a,{...c,...n})},d$e=(t,e={})=>({state:n,commands:r})=>{const i=gi(t,n.schema);return Id(n,i,e)?r.lift(i):r.wrapIn(i,e)},h$e=()=>({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 o=t.tr,l=a.transform;for(let c=l.steps.length-1;c>=0;c-=1)o.step(l.steps[c].invert(l.docs[c]));if(a.text){const c=o.doc.resolve(a.from).marks();o.replaceWith(a.from,a.to,t.schema.text(a.text,c))}else o.delete(a.from,a.to)}return!0}}return!1},f$e=()=>({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},m$e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=au(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&o){let{from:g,to:p}=l;const x=(a=u.marks().find(b=>b.type===c))==null?void 0:a.attrs,y=M4(u,c,x);y&&(g=y.from,p=y.to),n.removeMark(g,p,c)}else f.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,c)});return n.removeStoredMark(c),!0},p$e=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,o;return typeof t=="number"?(a=t,o=t):t&&"from"in t&&"to"in t?(a=t.from,o=t.to):(a=i.from,o=i.to),r&&e.doc.nodesBetween(a,o,(l,c)=>{if(l.isText)return;const u={...l.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},g$e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=N2(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=gi(t,r.schema)),l==="mark"&&(o=au(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let g,p,x,y;n.selection.empty?r.doc.nodesBetween(d,f,(b,v)=>{a&&a===b.type&&(c=!0,x=Math.max(v,d),y=Math.min(v+b.nodeSize,f),g=v,p=b)}):r.doc.nodesBetween(d,f,(b,v)=>{v<d&&a&&a===b.type&&(c=!0,x=Math.max(v,d),y=Math.min(v+b.nodeSize,f),g=v,p=b),v>=d&&v<=f&&(a&&a===b.type&&(c=!0,i&&n.setNodeMarkup(v,void 0,{...b.attrs,...e})),o&&b.marks.length&&b.marks.forEach(E=>{if(o===E.type&&(c=!0,i)){const w=Math.max(v,d),N=Math.min(v+b.nodeSize,f);n.addMark(w,N,o.create({...E.attrs,...e}))}}))}),p&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...p.attrs,...e}),o&&p.marks.length&&p.marks.forEach(b=>{o===b.type&&i&&n.addMark(x,y,o.create({...b.attrs,...e}))}))}),c},x$e=(t,e={})=>({state:n,dispatch:r})=>{const i=gi(t,n.schema);return XBe(i,e)(n,r)},b$e=(t,e={})=>({state:n,dispatch:r})=>{const i=gi(t,n.schema);return YBe(i,e)(n,r)},y$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={}}},k2=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},v$e=(t,e)=>{if(S4(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 n1(t){var e;const{editor:n,from:r,to:i,text:a,rules:o,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=KHe(u)+a;return o.forEach(g=>{if(d)return;const p=v$e(f,g.find);if(!p)return;const x=c.state.tr,y=E2({state:c.state,transaction:x}),b={from:r-(p[0].length-a.length),to:i},{commands:v,chain:E,can:w}=new A2({editor:n,state:y});g.handler({state:y,range:b,match:p,commands:v,chain:E,can:w})===null||!x.steps.length||(g.undoable&&x.setMeta(l,{transform:x,from:r,to:i,text:a}),c.dispatch(x),d=!0)}),d}function _$e(t){const{editor:e,rules:n}=t,r=new Fr({state:{init(){return null},apply(i,a,o){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=N4(_t.from(d),o.schema);const{from:f}=c,g=f+d.length;n1({editor:e,from:f,to:g,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,o,l){return n1({editor:e,from:a,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&n1({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:o}=i.state.selection;return o?n1({editor:e,from:o.pos,to:o.pos,text:`
  8151. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function w$e(t){return Object.prototype.toString.call(t).slice(8,-1)}function r1(t){return w$e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function qee(t,e){const n={...t};return r1(t)&&r1(e)&&Object.keys(e).forEach(r=>{r1(e[r])&&r1(t[r])?n[r]=qee(t[r],e[r]):n[r]=e[r]}),n}var k4=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{...Yn(qt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Yn(qt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>qee(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}},Gd=class Kee extends k4{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 o=i.marks();if(!!!o.find(u=>u?.type.name===n.name))return!1;const c=o.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 S$e(t){return typeof t=="number"}var M$e=class{constructor(t){this.find=t.find,this.handler=t.handler}},E$e=(t,e,n)=>{if(S4(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 A$e(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new A2({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(p,x)=>{var y,b,v,E,w;if((b=(y=p.type)==null?void 0:y.spec)!=null&&b.code||!(p.isText||p.isTextblock||p.isInline))return;const N=(w=(E=(v=p.content)==null?void 0:v.size)!=null?E:p.nodeSize)!=null?w:0,A=Math.max(r,x),C=Math.min(i,x+N);if(A>=C)return;const T=p.isText?p.text||"":p.textBetween(A-x,C-x,void 0,"");E$e(T,a.find,o).forEach(k=>{if(k.index===void 0)return;const D=A+k.index+1,U=D+k[0].length,O={from:n.tr.mapping.map(D),to:n.tr.mapping.map(U)},q=a.handler({state:n,range:O,match:k,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push(q)})}),f.every(p=>p!==null)}var i1=null,N$e=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function T$e(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const c=({state:d,from:f,to:g,rule:p,pasteEvt:x})=>{const y=d.tr,b=E2({state:d,transaction:y});if(!(!A$e({editor:e,state:b,from:Math.max(f-1,0),to:g.b-1,rule:p,pasteEvent:x,dropEvent:l})||!y.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return n.map(d=>new Fr({view(f){const g=x=>{var y;r=(y=f.dom.parentElement)!=null&&y.contains(x.target)?f.dom.parentElement:null,r&&(i1=e)},p=()=>{i1&&(i1=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=i1;p?.isEditable&&setTimeout(()=>{const x=p.state.selection;x&&p.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,g)=>{var p;const x=(p=g.clipboardData)==null?void 0:p.getData("text/html");return o=g,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(f,g,p)=>{const x=f[0],y=x.getMeta("uiEvent")==="paste"&&!i,b=x.getMeta("uiEvent")==="drop"&&!a,v=x.getMeta("applyPasteRules"),E=!!v;if(!y&&!b&&!E)return;if(E){let{text:A}=v;typeof A=="string"?A=A:A=N4(_t.from(A),p.schema);const{from:C}=v,T=C+A.length,L=N$e(A);return c({rule:d,state:p,from:C,to:{b:T},pasteEvt:L})}const w=g.doc.content.findDiffStart(p.doc.content),N=g.doc.content.findDiffEnd(p.doc.content);if(!(!S$e(w)||!N||w===N.b))return c({rule:d,state:p,from:w,to:N,pasteEvt:o})}}))}var P2=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Bee(t),this.schema=BHe(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:wk(e.name,this.schema)},r=qt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return T4([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:wk(r.name,this.schema)},a=[],o=qt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&qt(r,"exitable",i)&&(l.ArrowRight=()=>Gd.handleExit({editor:t,mark:r})),o){const g=Object.fromEntries(Object.entries(o()).map(([p,x])=>[p,()=>x({editor:t})]));l={...l,...g}}const c=V6e(l);a.push(c);const u=qt(r,"addInputRules",i);if(N7(r,t.options.enableInputRules)&&u){const g=u();if(g&&g.length){const p=_$e({editor:t,rules:g}),x=Array.isArray(p)?p:[p];a.push(...x)}}const d=qt(r,"addPasteRules",i);if(N7(r,t.options.enablePasteRules)&&d){const g=d();if(g&&g.length){const p=T$e({editor:t,rules:g});a.push(...p)}}const f=qt(r,"addProseMirrorPlugins",i);if(f){const g=f();a.push(...g)}return a})}get attributes(){return zee(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=rg(this.extensions);return Object.fromEntries(e.filter(n=>!!qt(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:gi(n.name,this.schema)},a=qt(n,"addNodeView",i);if(!a)return[];const o=a();if(!o)return[];const l=(c,u,d,f,g)=>{const p=wS(c,r);return o({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}=rg(this.extensions);return Object.fromEntries(e.filter(n=>!!qt(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:au(n.name,this.schema)},a=qt(n,"addMarkView",i);if(!a)return[];const o=(l,c,u)=>{const d=wS(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{$$e(l,t,f)}})};return[n.name,o]}))}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:wk(e.name,this.schema)};e.type==="mark"&&((n=Yn(qt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=qt(e,"onBeforeCreate",r),a=qt(e,"onCreate",r),o=qt(e,"onUpdate",r),l=qt(e,"onSelectionUpdate",r),c=qt(e,"onTransaction",r),u=qt(e,"onFocus",r),d=qt(e,"onBlur",r),f=qt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),o&&this.editor.on("update",o),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)})}};P2.resolve=Bee;P2.sort=T4;P2.flatten=A4;var C$e={};w4(C$e,{ClipboardTextSerializer:()=>Yee,Commands:()=>Zee,Delete:()=>Qee,Drop:()=>Jee,Editable:()=>ete,FocusEvents:()=>nte,Keymap:()=>rte,Paste:()=>ite,Tabindex:()=>ate,TextDirection:()=>ste,focusEventsPluginKey:()=>tte});var fr=class Xee extends k4{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Xee(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Yee=fr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Fr({key:new Oi("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,o=Math.min(...a.map(d=>d.$from.pos)),l=Math.max(...a.map(d=>d.$to.pos)),c=$ee(n);return Hee(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Zee=fr.create({name:"commands",addCommands(){return{...Pee}}}),Qee=fr.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const a=()=>{var o,l,c,u;if((u=(c=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:c.call(l,t))!=null?u:t.getMeta("y-sync$"))return;const d=Fee(t.before,[t,...e]);Gee(d).forEach(p=>{d.mapping.mapResult(p.oldRange.from).deletedAfter&&d.mapping.mapResult(p.oldRange.to).deletedBefore&&d.before.nodesBetween(p.oldRange.from,p.oldRange.to,(x,y)=>{const b=y+x.nodeSize-2,v=p.oldRange.from<=y&&b<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:y,to:b,newFrom:d.mapping.map(y),newTo:d.mapping.map(b),deletedRange:p.oldRange,newRange:p.newRange,partial:!v,editor:this.editor,transaction:t,combinedTransform:d})})});const g=d.mapping;d.steps.forEach((p,x)=>{var y,b;if(p instanceof Ho){const v=g.slice(x).map(p.from,-1),E=g.slice(x).map(p.to),w=g.invert().map(v,-1),N=g.invert().map(E),A=(y=d.doc.nodeAt(v-1))==null?void 0:y.marks.some(T=>T.eq(p.mark)),C=(b=d.doc.nodeAt(E))==null?void 0:b.marks.some(T=>T.eq(p.mark));this.editor.emit("delete",{type:"mark",mark:p.mark,from:p.from,to:p.to,deletedRange:{from:w,to:N},newRange:{from:v,to:E},partial:!!(C||A),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()}}),Jee=fr.create({name:"drop",addProseMirrorPlugins(){return[new Fr({key:new Oi("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),ete=fr.create({name:"editable",addProseMirrorPlugins(){return[new Fr({key:new Oi("editable"),props:{editable:()=>this.editor.options.editable}})]}}),tte=new Oi("focusEvents"),nte=fr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Fr({key:tte,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}}}})]}}),rte=fr.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:c,doc:u}=l,{empty:d,$anchor:f}=c,{pos:g,parent:p}=f,x=f.parent.isTextblock&&g>0?l.doc.resolve(g-1):f,y=x.parent.type.spec.isolating,b=f.pos-f.parentOffset,v=y&&x.parent.childCount===1?b===f.pos:yn.atStart(u).from===g;return!d||!p.type.isTextblock||p.textContent.length||!v||v&&f.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.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 E4()||Lee()?a:i},addProseMirrorPlugins(){return[new Fr({key:new Oi("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(y=>y.getMeta("composition")))return;const r=t.some(y=>y.docChanged)&&!e.doc.eq(n.doc),i=t.some(y=>y.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:o,to:l}=e.selection,c=yn.atStart(e.doc).from,u=yn.atEnd(e.doc).to;if(a||!(o===c&&l===u)||!C2(n.doc))return;const g=n.tr,p=E2({state:n,transaction:g}),{commands:x}=new A2({editor:this.editor,state:p});if(x.clearNodes(),!!g.steps.length)return g}})]}}),ite=fr.create({name:"paste",addProseMirrorPlugins(){return[new Fr({key:new Oi("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),ate=fr.create({name:"tabindex",addProseMirrorPlugins(){return[new Fr({key:new Oi("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),ste=fr.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=rg(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 Oi("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),k$e=class sp{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 sp(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 sp(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 sp(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,o=this.pos+r+(a?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth)return;const c=new sp(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new sp(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,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const c=o[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(o=>{r&&i.length>0||(o.node.type.name===e&&a.every(c=>n[c]===o.node.attrs[c])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.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 j$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 R$e=class extends y$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=Dee(e,this.options.autofocus);this.editorState=mp.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=j$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=Uee(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(o=>!o.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?[ete,Yee.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Zee,nte,rte,ate,Jee,ite,Qee,ste.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 P2(r,this)}createCommandManager(){this.commandManager=new A2({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Oj(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=Oj(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new Cee(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 o=n.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),l=o?.getMeta("focus"),c=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),c&&this.emit("blur",{editor:this,event:c.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(u=>u.docChanged)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Vee(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return XHe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return N4(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8210. `,textSerializers:n={}}=t||{};return $He(this.state.doc,{blockSeparator:e,textSerializers:{...$ee(this.schema),...n}})}get isEmpty(){return C2(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 k$e(e,this)}get $doc(){return this.$pos(0)}};function ig(t){return new k2({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Yn(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:a}=e,o=r[r.length-1],l=r[0];if(o){const c=l.search(/\S/),u=n.from+l.indexOf(o),d=u+o.length;if(C4(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===t.type&&y!==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+o.length;a.addMark(n.from+c,g,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function ote(t){return new k2({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Yn(t.getAttributes,void 0,r)||{},{tr:a}=e,o=n.from;let l=n.to;const c=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=o+u;d>l?d=l:l=d+r[1].length;const f=r[0][r[0].length-1];a.insertText(f,o+r[0].length-1),a.replaceWith(d,l,c)}else if(r[0]){const u=t.type.isInline?o:o-1;a.insert(u,t.type.create(i)).delete(a.mapping.map(o),a.mapping.map(l))}a.scrollIntoView()},undoable:t.undoable})}function Ij(t){return new k2({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=Yn(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 ag(t){return new k2({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=Yn(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&s4(c,t.type,a);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:g}=e,{splittableMarks:p}=t.editor.extensionManager,x=g||f.$to.parentOffset&&f.$from.marks();if(x){const y=x.filter(b=>p.includes(b.type.name));o.ensureMarks(y)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,a).run()}const d=o.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&$d(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var D$e=t=>"touches"in t,O$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=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.clientX-this.startX,c=o.clientY-this.startY;this.handleResize(l,c)},this.handleTouchMove=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.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 o=this.element.offsetWidth,l=this.element.offsetHeight;this.onCommit(o,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=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=o=>{o.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,D$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"),o=t.includes("left"),l=t.includes("bottom"),c=t.includes("top");return a?r=this.startWidth+e:o&&(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,o;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),(o=this.maxSize)!=null&&o.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 L$e(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Xt){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 I$e={};w4(I$e,{createAtomBlockMarkdownSpec:()=>F$e,createBlockMarkdownSpec:()=>U$e,createInlineMarkdownSpec:()=>H$e,parseAttributes:()=>P4,parseIndentedBlocks:()=>Fj,renderNestedMarkdownContent:()=>R4,serializeAttributes:()=>j4});function P4(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 o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).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 j4(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 F$e(t){const{nodeName:e,name:n,parseAttributes:r=P4,serializeAttributes:i=j4,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(g=>{g in d&&(f[g]=d[g])}),f};return{parseMarkdown:(d,f)=>{const g={...a,...d.attributes};return f.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const g=new RegExp(`^:::${c}(?:\\s|$)`,"m"),p=(f=d.match(g))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(d,f,g){const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(p);if(!x)return;const y=x[1]||"",b=r(y);if(!o.find(E=>!(E in b)))return{type:e,raw:x[0],attributes:b}}},renderMarkdown:d=>{const f=u(d.attrs||{}),g=i(f),p=g?` {${g}}`:"";return`:::${c}${p} :::`}}}function U$e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=P4,serializeAttributes:a=j4,defaultAttributes:o={},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 y=r(f);p=typeof y=="string"?[{type:"text",text:y}]:y}else l==="block"?p=g.parseChildren(f.tokens||[]):p=g.parseInline(f.tokens||[]);const x={...o,...f.attributes};return g.createNode(e,x,p)},markdownTokenizer:{name:e,level:"block",start(f){var g;const p=new RegExp(`^:::${u}`,"m"),x=(g=f.match(p))==null?void 0:g.index;return x!==void 0?x:-1},tokenize(f,g,p){var x;const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),b=f.match(y);if(!b)return;const[v,E=""]=b,w=i(E);let N=1;const A=v.length;let C="";const T=/^:::([\w-]*)(\s.*)?/gm,L=f.slice(A);for(T.lastIndex=0;;){const k=T.exec(L);if(k===null)break;const D=k.index,U=k[1];if(!((x=k[2])!=null&&x.endsWith(":::"))){if(U)N+=1;else if(N-=1,N===0){const O=L.slice(0,D);C=O.trim();const q=f.slice(0,A+D+k[0].length);let R=[];if(C)if(l==="block")for(R=p.blockTokens(O),R.forEach(G=>{G.text&&(!G.tokens||G.tokens.length===0)&&(G.tokens=p.inlineTokens(G.text))});R.length>0;){const G=R[R.length-1];if(G.type==="paragraph"&&(!G.text||G.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||{}),x=a(p),y=x?` {${x}}`:"",b=g.renderChildren(f.content||[],`
  8211. `);return`:::${u}${y}
  8212. ${b}
  8213. :::`}}}function z$e(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,o]=r;e[i]=a||o,r=n.exec(t)}return e}function B$e(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function H$e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=z$e,serializeAttributes:a=B$e,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=g=>{if(!c)return g;const p={};return c.forEach(x=>{x in g&&(p[x]=g[x])}),p},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,p)=>{const x={...o,...g.attributes};if(l)return p.createNode(e,x);const y=r?r(g):g.content||"";return y?p.createNode(e,x,[p.createTextNode(y)]):p.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(g){const p=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),x=g.match(p),y=x?.index;return y!==void 0?y:-1},tokenize(g,p,x){const y=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),b=g.match(y);if(!b)return;let v="",E="";if(l){const[,N]=b;E=N}else{const[,N,A]=b;E=N,v=A||""}const w=i(E.trim());return{type:e,raw:b[0],content:v.trim(),attributes:w}}},renderMarkdown:g=>{let p="";r?p=r(g):g.content&&g.content.length>0&&(p=g.content.filter(v=>v.type==="text").map(v=>v.text).join(""));const x=d(g.attrs||{}),y=a(x),b=y?` ${y}`:"";return l?`[${u}${b}]`:`[${u}${b}]${p}[/${u}]`}}}function Fj(t,e,n){var r,i,a,o;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 x=e.extractItemData(p),{indentLevel:y,mainContent:b}=x;u=`${u}${g}
  8216. `;const v=[b];for(d+=1;d<l.length;){const A=l[d];if(A.trim()===""){const T=l.slice(d+1).findIndex(D=>D.trim()!=="");if(T===-1)break;if((((i=(r=l[d+1+T].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){v.push(A),u=`${u}${A}
  8217. `,d+=1;continue}else break}if((((o=(a=A.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>y)v.push(A),u=`${u}${A}
  8218. `,d+=1;else break}let E;const w=v.slice(1);if(w.length>0){const A=w.map(C=>C.slice(y+f)).join(`
  8219. `);A.trim()&&(e.customNestedParser?E=e.customNestedParser(A):E=n.blockTokens(A))}const N=e.createToken(x,E);c.push(N)}if(c.length!==0)return{items:c,raw:u}}function R4(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...o]=t.content,l=e.renderChildren([a]),c=[`${i}${l}`];return o&&o.length>0&&o.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 $$e(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,o=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!==o)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 fs=class lte extends k4{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new lte(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Nf(t){return new M$e({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=Yn(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:o}=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(C4(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(b=>b===t.type&&b!==x.mark.type)).filter(x=>x.to>f).length)return null;g<n.to&&o.delete(g,n.to),f>n.from&&o.delete(n.from+d,f),u=n.from+d+l.length,o.addMark(n.from+d,u,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}var Ek,k7;function V$e(){return k7||(k7=1,Ek=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 o=a[i];if(!(o==="_owner"&&e.$$typeof)&&!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),Ek}var G$e=V$e();const W$e=wo(G$e);var q$e=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},K$e=({contentComponent:t})=>{const e=iR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function X$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]:coe.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 Y$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=X$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 s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:q$e(e,this.editorContentRef),...n}),t?.contentComponent&&s.jsx(K$e,{contentComponent:t.contentComponent})]})}},Z$e=S.forwardRef((t,e)=>{const n=kr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return kr.createElement(Y$e,{key:n,innerRef:e,...t})}),Q$e=kr.memo(Z$e),J$e=typeof window<"u"?S.useLayoutEffect:S.useEffect,eVe=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 tVe(t){var e;const[n]=S.useState(()=>new eVe(t.editor)),r=eq.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:W$e);return J$e(()=>n.watch(t.editor),[t.editor,n]),S.useDebugValue(r),r}var nVe=!1,Uj=typeof window>"u",rVe=Uj||!!(typeof window<"u"&&window.next),iVe=class cte{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?Uj||rVe?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 R$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 o;return i===((o=n.extensions)==null?void 0:o[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?cte.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 aVe(t={},e=[]){const n=S.useRef(t);n.current=t;const[r]=S.useState(()=>new iVe(n)),i=iR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return S.useDebugValue(i),S.useEffect(r.onRender(e)),tVe({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var sVe=S.createContext({editor:null});sVe.Consumer;var oVe=S.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),lVe=()=>S.useContext(oVe);kr.forwardRef((t,e)=>{const{onDragStart:n}=lVe(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});kr.createContext({markViewContentRef:()=>{}});var SS=(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]},cVe=/^\s*>\s$/,uVe=fs.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return SS("blockquote",{...Xr(this.options.HTMLAttributes,t),children:SS("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[ag({find:cVe,type:this.type})]}}),dVe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,hVe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,fVe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,mVe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,pVe=Gd.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 SS("strong",{...Xr(this.options.HTMLAttributes,t),children:SS("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[ig({find:dVe,type:this.type}),ig({find:fVe,type:this.type})]},addPasteRules(){return[Nf({find:hVe,type:this.type}),Nf({find:mVe,type:this.type})]}}),gVe=/(^|[^`])`([^`]+)`(?!`)$/,xVe=/(^|[^`])`([^`]+)`(?!`)/g,bVe=Gd.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Xr(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[ig({find:gVe,type:this.type})]},addPasteRules(){return[Nf({find:xVe,type:this.type})]}}),Ak=4,yVe=/^```([a-z]+)?[\s\n]$/,vVe=/^~~~([a-z]+)?[\s\n]$/,_Ve=fs.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Ak,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(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Xr(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:Ak,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;if(a.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?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(x=>l+x).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:Ak,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;return a.parent.type!==this.type?!1:o?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 x=0,y=0;const b=u-d;for(let C=0;C<p.length;C+=1){if(y+p[C].length>=b){x=C;break}y+=p[C].length+1}const E=((c=p[x].match(/^ */))==null?void 0:c[0])||"",w=Math.min(E.length,n);if(w===0)return!0;let N=d;for(let C=0;C<x;C+=1)N+=p[C].length+1;return l.delete(N,N+w),u-N<=w&&l.setSelection(nn.create(l.doc,N)),!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 x;const y=((x=p.match(/^ */))==null?void 0:x[0])||"",b=Math.min(y.length,n);return p.slice(b)}).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,o=r.parent.textContent.endsWith(`
  8240. `);return!a||!o?!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[Ij({find:yVe,type:this.type,getAttributes:t=>({language:t[1]})}),Ij({find:vVe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Fr({key:new Oi("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:o,schema:l}=t.state,c=l.text(n.replace(/\r\n?/g,`
  8241. `));return o.replaceSelectionWith(this.type.create({language:a},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(nn.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),wVe=fs.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8242. `):""}),SVe=fs.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",Xr(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:o}=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&&o){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()}}}),MVe=fs.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]}`,Xr(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=>Ij({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),EVe=fs.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Xr(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!L$e(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Wee(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:a,tr:o,dispatch:l})=>{if(l){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(nn.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(Xt.create(o.doc,c.pos)):o.setSelection(nn.create(o.doc,c.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=d?.create();f&&(o.insert(u,f),o.setSelection(nn.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ote({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),AVe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,NVe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,TVe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,CVe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,kVe=Gd.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",Xr(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[ig({find:AVe,type:this.type}),ig({find:TVe,type:this.type})]},addPasteRules(){return[Nf({find:NVe,type:this.type}),Nf({find:CVe,type:this.type})]}});const PVe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",jVe="ελ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",zj="numeric",Bj="ascii",Hj="alpha",E0="asciinumeric",l0="alphanumeric",$j="domain",ute="emoji",RVe="scheme",DVe="slashscheme",Nk="whitespace";function OVe(t,e){return t in e||(e[t]=[]),e[t]}function Uh(t,e,n){e[zj]&&(e[E0]=!0,e[l0]=!0),e[Bj]&&(e[E0]=!0,e[Hj]=!0),e[E0]&&(e[l0]=!0),e[Hj]&&(e[l0]=!0),e[l0]&&(e[$j]=!0),e[ute]&&(e[$j]=!0);for(const r in e){const i=OVe(r,n);i.indexOf(t)<0&&i.push(t)}}function LVe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function rs(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}rs.groups={};rs.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||rs.groups;let i;return e&&e.j?i=e:(i=new rs(e),n&&r&&Uh(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 o=0;o<a-1;o++)i=i.tt(t[o]);return i.tt(t[a-1],e,n,r)},tt(t,e,n,r){r=r||rs.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const a=e;let o,l=i.go(t);if(l?(o=new rs,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new rs,a){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(LVe(o.t,r),n);Uh(a,c,r)}else n&&Uh(a,n,r);o.t=a}return i.j[t]=o,o}};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),P7=(t,e,n,r,i)=>t.ts(e,n,r,i),St=(t,e,n,r,i)=>t.tt(e,n,r,i),vc="WORD",Vj="UWORD",dte="ASCIINUMERICAL",hte="ALPHANUMERICAL",wb="LOCALHOST",Gj="TLD",Wj="UTLD",U1="SCHEME",op="SLASH_SCHEME",D4="NUM",qj="WS",O4="NL",A0="OPENBRACE",N0="CLOSEBRACE",MS="OPENBRACKET",ES="CLOSEBRACKET",AS="OPENPAREN",NS="CLOSEPAREN",TS="OPENANGLEBRACKET",CS="CLOSEANGLEBRACKET",kS="FULLWIDTHLEFTPAREN",PS="FULLWIDTHRIGHTPAREN",jS="LEFTCORNERBRACKET",RS="RIGHTCORNERBRACKET",DS="LEFTWHITECORNERBRACKET",OS="RIGHTWHITECORNERBRACKET",LS="FULLWIDTHLESSTHAN",IS="FULLWIDTHGREATERTHAN",FS="AMPERSAND",US="APOSTROPHE",zS="ASTERISK",Zu="AT",BS="BACKSLASH",HS="BACKTICK",$S="CARET",rd="COLON",L4="COMMA",VS="DOLLAR",cl="DOT",GS="EQUALS",I4="EXCLAMATION",eo="HYPHEN",T0="PERCENT",WS="PIPE",qS="PLUS",KS="POUND",C0="QUERY",F4="QUOTE",fte="FULLWIDTHMIDDLEDOT",U4="SEMI",ul="SLASH",k0="TILDE",XS="UNDERSCORE",mte="EMOJI",YS="SYM";var pte=Object.freeze({__proto__:null,ALPHANUMERICAL:hte,AMPERSAND:FS,APOSTROPHE:US,ASCIINUMERICAL:dte,ASTERISK:zS,AT:Zu,BACKSLASH:BS,BACKTICK:HS,CARET:$S,CLOSEANGLEBRACKET:CS,CLOSEBRACE:N0,CLOSEBRACKET:ES,CLOSEPAREN:NS,COLON:rd,COMMA:L4,DOLLAR:VS,DOT:cl,EMOJI:mte,EQUALS:GS,EXCLAMATION:I4,FULLWIDTHGREATERTHAN:IS,FULLWIDTHLEFTPAREN:kS,FULLWIDTHLESSTHAN:LS,FULLWIDTHMIDDLEDOT:fte,FULLWIDTHRIGHTPAREN:PS,HYPHEN:eo,LEFTCORNERBRACKET:jS,LEFTWHITECORNERBRACKET:DS,LOCALHOST:wb,NL:O4,NUM:D4,OPENANGLEBRACKET:TS,OPENBRACE:A0,OPENBRACKET:MS,OPENPAREN:AS,PERCENT:T0,PIPE:WS,PLUS:qS,POUND:KS,QUERY:C0,QUOTE:F4,RIGHTCORNERBRACKET:RS,RIGHTWHITECORNERBRACKET:OS,SCHEME:U1,SEMI:U4,SLASH:ul,SLASH_SCHEME:op,SYM:YS,TILDE:k0,TLD:Gj,UNDERSCORE:XS,UTLD:Wj,UWORD:Vj,WORD:vc,WS:qj});const gc=/[a-z]/,Xx=new RegExp("\\p{L}","u"),Tk=new RegExp("\\p{Emoji}","u"),xc=/\d/,Ck=/\s/,j7="\r",kk=`
  8245. `,IVe="️",FVe="‍",Pk="";let a1=null,s1=null;function UVe(t=[]){const e={};rs.groups=e;const n=new rs;a1==null&&(a1=R7(PVe)),s1==null&&(s1=R7(jVe)),St(n,"'",US),St(n,"{",A0),St(n,"}",N0),St(n,"[",MS),St(n,"]",ES),St(n,"(",AS),St(n,")",NS),St(n,"<",TS),St(n,">",CS),St(n,"(",kS),St(n,")",PS),St(n,"「",jS),St(n,"」",RS),St(n,"『",DS),St(n,"』",OS),St(n,"<",LS),St(n,">",IS),St(n,"&",FS),St(n,"*",zS),St(n,"@",Zu),St(n,"`",HS),St(n,"^",$S),St(n,":",rd),St(n,",",L4),St(n,"$",VS),St(n,".",cl),St(n,"=",GS),St(n,"!",I4),St(n,"-",eo),St(n,"%",T0),St(n,"|",WS),St(n,"+",qS),St(n,"#",KS),St(n,"?",C0),St(n,'"',F4),St(n,"/",ul),St(n,";",U4),St(n,"~",k0),St(n,"_",XS),St(n,"\\",BS),St(n,"・",fte);const r=Hr(n,xc,D4,{[zj]:!0});Hr(r,xc,r);const i=Hr(r,gc,dte,{[E0]:!0}),a=Hr(r,Xx,hte,{[l0]:!0}),o=Hr(n,gc,vc,{[Bj]:!0});Hr(o,xc,i),Hr(o,gc,o),Hr(i,xc,i),Hr(i,gc,i);const l=Hr(n,Xx,Vj,{[Hj]:!0});Hr(l,gc),Hr(l,xc,a),Hr(l,Xx,l),Hr(a,xc,a),Hr(a,gc),Hr(a,Xx,a);const c=St(n,kk,O4,{[Nk]:!0}),u=St(n,j7,qj,{[Nk]:!0}),d=Hr(n,Ck,qj,{[Nk]:!0});St(n,Pk,d),St(u,kk,c),St(u,Pk,d),Hr(u,Ck,d),St(d,j7),St(d,kk),Hr(d,Ck,d),St(d,Pk,d);const f=Hr(n,Tk,mte,{[ute]:!0});St(f,"#"),Hr(f,Tk,f),St(f,IVe,f);const g=St(f,FVe);St(g,"#"),Hr(g,Tk,f);const p=[[gc,o],[xc,i]],x=[[gc,null],[Xx,l],[xc,a]];for(let y=0;y<a1.length;y++)$u(n,a1[y],Gj,vc,p);for(let y=0;y<s1.length;y++)$u(n,s1[y],Wj,Vj,x);Uh(Gj,{tld:!0,ascii:!0},e),Uh(Wj,{utld:!0,alpha:!0},e),$u(n,"file",U1,vc,p),$u(n,"mailto",U1,vc,p),$u(n,"http",op,vc,p),$u(n,"https",op,vc,p),$u(n,"ftp",op,vc,p),$u(n,"ftps",op,vc,p),Uh(U1,{scheme:!0,ascii:!0},e),Uh(op,{slashscheme:!0,ascii:!0},e),t=t.sort((y,b)=>y[0]>b[0]?1:-1);for(let y=0;y<t.length;y++){const b=t[y][0],E=t[y][1]?{[RVe]:!0}:{[DVe]:!0};b.indexOf("-")>=0?E[$j]=!0:gc.test(b)?xc.test(b)?E[E0]=!0:E[Bj]=!0:E[zj]=!0,P7(n,b,b,E)}return P7(n,"localhost",wb,{ascii:!0}),n.jd=new rs(YS),{start:n,tokens:Object.assign({groups:e},pte)}}function gte(t,e){const n=zVe(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let a=0,o=0;for(;o<r;){let l=t,c=null,u=0,d=null,f=-1,g=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(f=0,g=0,d=l):f>=0&&(f+=n[o].length,g++),u+=n[o].length,a+=n[o].length,o++;a-=f,o-=g,u-=f,i.push({t:d.t,v:e.slice(a-u,a),s:a-u,e:a})}return i}function zVe(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=t.charCodeAt(r+1))<56320||a>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function $u(t,e,n,r,i){let a;const o=e.length;for(let l=0;l<o-1;l++){const c=e[l];t.j[c]?a=t.j[c]:(a=new rs(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new rs(n),a.jr=i.slice(),t.j[e[o-1]]=a,a}function R7(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 o=parseInt(t.substring(r,r+a),10);o>0;o--)n.pop();r+=a}else n.push(t[r]),r++}return e}const Sb={defaultProtocol:"http",events:null,format:D7,formatHref:D7,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function z4(t,e=null){let n=Object.assign({},Sb);t&&(n=Object.assign(n,t instanceof z4?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}z4.prototype={o:Sb,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]:Sb[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 D7(t){return t}function xte(t,e){this.t="token",this.v=t,this.tk=e}xte.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=Sb.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),o={},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 o.href=r,l&&(o.class=l),c&&(o.target=c),u&&(o.rel=u),d&&Object.assign(o,d),{tagName:i,attributes:o,content:a,eventListeners:f}}};function j2(t,e){class n extends xte{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 O7=j2("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),L7=j2("text"),BVe=j2("nl"),o1=j2("url",{isLink:!0,toHref(t=Sb.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==wb&&t[1].t===rd}}),Zs=t=>new rs(t);function HVe({groups:t}){const e=t.domain.concat([FS,zS,Zu,BS,HS,$S,VS,GS,eo,D4,T0,WS,qS,KS,ul,YS,k0,XS]),n=[US,rd,L4,cl,I4,T0,C0,F4,U4,TS,CS,A0,N0,ES,MS,AS,NS,kS,PS,jS,RS,DS,OS,LS,IS],r=[FS,US,zS,BS,HS,$S,VS,GS,eo,A0,N0,T0,WS,qS,KS,C0,ul,YS,k0,XS],i=Zs(),a=St(i,k0);pn(a,r,a),pn(a,t.domain,a);const o=Zs(),l=Zs(),c=Zs();pn(i,t.domain,o),pn(i,t.scheme,l),pn(i,t.slashscheme,c),pn(o,r,a),pn(o,t.domain,o);const u=St(o,Zu);St(a,Zu,u),St(l,Zu,u),St(c,Zu,u);const d=St(a,cl);pn(d,r,a),pn(d,t.domain,a);const f=Zs();pn(u,t.domain,f),pn(f,t.domain,f);const g=St(f,cl);pn(g,t.domain,f);const p=Zs(O7);pn(g,t.tld,p),pn(g,t.utld,p),St(u,wb,p);const x=St(f,eo);St(x,eo,x),pn(x,t.domain,f),pn(p,t.domain,f),St(p,cl,g),St(p,eo,x);const y=St(p,rd);pn(y,t.numeric,O7);const b=St(o,eo),v=St(o,cl);St(b,eo,b),pn(b,t.domain,o),pn(v,r,a),pn(v,t.domain,o);const E=Zs(o1);pn(v,t.tld,E),pn(v,t.utld,E),pn(E,t.domain,o),pn(E,r,a),St(E,cl,v),St(E,eo,b),St(E,Zu,u);const w=St(E,rd),N=Zs(o1);pn(w,t.numeric,N);const A=Zs(o1),C=Zs();pn(A,e,A),pn(A,n,C),pn(C,e,A),pn(C,n,C),St(E,ul,A),St(N,ul,A);const T=St(l,rd),L=St(c,rd),k=St(L,ul),D=St(k,ul);pn(l,t.domain,o),St(l,cl,v),St(l,eo,b),pn(c,t.domain,o),St(c,cl,v),St(c,eo,b),pn(T,t.domain,A),St(T,ul,A),St(T,C0,A),pn(D,t.domain,A),pn(D,e,A),St(D,ul,A);const U=[[A0,N0],[MS,ES],[AS,NS],[TS,CS],[kS,PS],[jS,RS],[DS,OS],[LS,IS]];for(let O=0;O<U.length;O++){const[q,R]=U[O],G=St(A,q);St(C,q,G),St(G,R,A);const Y=Zs(o1);pn(G,e,Y);const V=Zs();pn(G,n),pn(Y,e,Y),pn(Y,n,V),pn(V,e,Y),pn(V,n,V),St(Y,R,A),St(V,R,A)}return St(i,wb,E),St(i,O4,BVe),{start:i,tokens:pte}}function $Ve(t,e,n){let r=n.length,i=0,a=[],o=[];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));)o.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&&(o.push(n[i]),i++);else{o.length>0&&(a.push(jk(L7,e,o)),o=[]),i-=g,d-=g;const p=f.t,x=n.slice(i-d,i);a.push(jk(p,e,x))}}return o.length>0&&a.push(jk(L7,e,o)),a}function jk(t,e,n){const r=n[0].s,i=n[n.length-1].e,a=e.slice(r,i);return new t(a,n)}const VVe=typeof console<"u"&&console&&console.warn||(()=>{}),GVe="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 WVe(){return rs.groups={},Mr.scanner=null,Mr.parser=null,Mr.tokenQueue=[],Mr.pluginQueue=[],Mr.customSchemes=[],Mr.initialized=!1,Mr}function I7(t,e=!1){if(Mr.initialized&&VVe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${GVe}`),!/^[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 qVe(){Mr.scanner=UVe(Mr.customSchemes);for(let t=0;t<Mr.tokenQueue.length;t++)Mr.tokenQueue[t][1]({scanner:Mr.scanner});Mr.parser=HVe(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 B4(t){return Mr.initialized||qVe(),$Ve(Mr.parser.start,t,gte(Mr.scanner.start,t))}B4.scan=gte;function bte(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 z4(n),i=B4(t),a=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&a.push(l.toFormattedObject(r))}return a}var H4="[\0-   ᠎ -\u2029  ]",KVe=new RegExp(H4),XVe=new RegExp(`${H4}$`),YVe=new RegExp(H4,"g");function ZVe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function QVe(t){return new Fr({key:new Oi("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:o}=r,l=Fee(n.doc,[...e]);if(Gee(l).forEach(({newRange:u})=>{const d=IHe(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(!XVe.test(p))return;f=d[0],g=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const p=g.split(KVe).filter(Boolean);if(p.length<=0)return!1;const x=p[p.length-1],y=f.pos+g.lastIndexOf(x);if(!x)return!1;const b=B4(x).map(v=>v.toObject(t.defaultProtocol));if(!ZVe(b))return!1;b.filter(v=>v.isLink).map(v=>({...v,from:y+v.start+1,to:y+v.end+1})).filter(v=>r.schema.marks.code?!r.doc.rangeHasMark(v.from,v.to,r.schema.marks.code):!0).filter(v=>t.validate(v.value)).filter(v=>t.shouldAutoLink(v.value)).forEach(v=>{C4(v.from,v.to,r.doc).some(E=>E.mark.type===t.type)||o.addMark(v.from,v.to,t.type.create({href:v.href}))})}}),!!o.steps.length)return o}})}function JVe(t){return new Fr({key:new Oi("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,a;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;o=f.find(g=>g.nodeName==="A")}if(!o)return!1;const l=Vee(e.state,t.type.name),c=(i=o?.href)!=null?i:l.href,u=(a=o?.target)!=null?a:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),o&&c?(window.open(c,u),!0):!1}}})}function eGe(t){return new Fr({key:new Oi("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:a}=e,{selection:o}=a,{empty:l}=o;if(l)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=bte(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 yh(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(YVe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var yte=Gd.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"){I7(t);return}I7(t.scheme,t.optionalSlashes)})},onDestroy(){WVe()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!yh(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=>!!yh(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=>!!yh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Xr(this.options.HTMLAttributes,t),0]:["a",Xr(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=>!!yh(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=>!!yh(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[Nf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=bte(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!yh(o,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(QVe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!yh(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(JVe({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(eGe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),tGe=yte,nGe=Object.defineProperty,rGe=(t,e)=>{for(var n in e)nGe(t,n,{get:e[n],enumerable:!0})},iGe="listItem",F7="textStyle",U7=/^\s*([-+*])\s$/,vte=fs.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",Xr(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(iGe,this.editor.getAttributes(F7)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=ag({find:U7,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ag({find:U7,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(F7),editor:this.editor})),[t]}}),_te=fs.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Xr(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 o=t.tokens.slice(1),l=e.parseChildren(o);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)=>R4(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)}}}),aGe={};rGe(aGe,{findListItemPos:()=>gy,getNextListDepth:()=>$4,handleBackspace:()=>Kj,handleDelete:()=>Xj,hasListBefore:()=>wte,hasListItemAfter:()=>sGe,hasListItemBefore:()=>Ste,listItemHasSubList:()=>Mte,nextListIsDeeper:()=>Ete,nextListIsHigher:()=>Ate});var gy=(t,e)=>{const{$from:n}=e.selection,r=gi(t,e.schema);let i=null,a=n.depth,o=n.pos,l=null;for(;a>0&&l===null;)i=n.node(a),i.type===r?l=a:(a-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},$4=(t,e)=>{const n=gy(t,e);if(!n)return!1;const[,r]=qHe(e,t,n.$pos.pos+4);return r},wte=(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))},Ste=(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)},Mte=(t,e,n)=>{if(!n)return!1;const r=gi(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},Kj=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Id(t.state,e)&&wte(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(!Id(t.state,e)||!ZHe(t.state))return!1;const r=gy(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Mte(e,t.state,a);return Ste(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Ete=(t,e)=>{const n=$4(t,e),r=gy(t,e);return!r||!n?!1:n>r.depth},Ate=(t,e)=>{const n=$4(t,e),r=gy(t,e);return!r||!n?!1:n<r.depth},Xj=(t,e)=>{if(!Id(t.state,e)||!YHe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Ete(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Ate(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},sGe=(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)},Nte=fr.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&&Xj(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&&Xj(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&&Kj(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&&Kj(t,n,r)&&(e=!0)}),e}}}}),z7=/^(\s*)(\d+)\.\s+(.*)$/,oGe=/^\s/;function lGe(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(z7);if(!a)break;const[,o,l,c]=a,u=o.length;let d=c,f=n+1;const g=[i];for(;f<t.length;){const p=t[f];if(p.match(z7))break;if(p.trim()==="")g.push(p),d+=`
  8250. `,f+=1;else if(p.match(oGe))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 Tte(t,e,n){var r;const i=[];let a=0;for(;a<t.length;){const o=t[a];if(o.indent===e){const l=o.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(y=>y.indent)),x=Tte(g,p,n);u.push({type:"list",ordered:!0,start:g[0].number,items:x,raw:g.map(y=>y.raw).join(`
  8255. `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),a=f}else a+=1}return i}function cGe(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 uGe="listItem",B7="textStyle",H7=/^(\d+)\.\s$/,Cte=fs.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",Xr(this.options.HTMLAttributes,n),0]:["ol",Xr(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?cGe(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,o]=lGe(i);if(a.length===0)return;const l=Tte(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,o).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(uGe,this.editor.getAttributes(B7)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=ag({find:H7,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=ag({find:H7,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(B7)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),dGe=/^\s*(\[([( |x])?\])\s$/,hGe=fs.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",Xr(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 R4(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"),o=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div"),u=d=>{var f,g;l.ariaLabel=((g=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:g.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),a.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const p=n();if(typeof p!="number")return!1;const x=g.doc.nodeAt(p);return g.setNodeMarkup(p,void 0,{...x?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,a.append(l,o),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[ag({find:dGe,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),fGe=fs.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",Xr(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 o=Fj(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 o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(a)},i=Fj(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,o)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:o}),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()}}});fr.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(vte.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(_te.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Nte.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Cte.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(hGe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(fGe.configure(this.options.taskList)),t}});var mGe=fs.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Xr(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()}}}),pGe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,gGe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,xGe=Gd.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",Xr(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[ig({find:pGe,type:this.type})]},addPasteRules(){return[Nf({find:gGe,type:this.type})]}}),bGe=fs.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),kte=Gd.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",Xr(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()}}}),yGe=kte;function vGe(t={}){return new Fr({view(e){return new _Ge(e,t)}})}class _Ge{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=o=>{this[i](o)};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(),o=a.width/i.offsetWidth,l=a.height/i.offsetHeight;if(n){let f=e.nodeBefore,g=e.nodeAfter;if(f||g){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let x=p.getBoundingClientRect(),y=f?x.bottom:x.top;f&&g&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*l;r={left:x.left,right:x.right,top:y-b,bottom:y+b}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*o;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)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"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 o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=kJ(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),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 Ot.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 V4(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!wGe(e)||!SGe(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 o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){a=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let c=e.doc.resolve(i);if(Vr.valid(c))return c}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Xt.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=o,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 V4{constructor(e){this.pos=e}map(e){return new V4(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Vr.valid(n)?new Vr(n):yn.near(n)}}function Pte(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function wGe(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||Pte(i.type))return!0;if(i.inlineContent)return!1}}return!0}function SGe(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||Pte(i.type))return!0;if(i.inlineContent)return!1}}return!0}function MGe(){return new Fr({props:{decorations:TGe,createSelectionBetween(t,e,n){return e.pos==n.pos&&Vr.valid(n)?new Vr(n):null},handleClick:AGe,handleKeyDown:EGe,handleDOMEvents:{beforeinput:NGe}}})}const EGe=kee({ArrowLeft:l1("horiz",-1),ArrowRight:l1("horiz",1),ArrowUp:l1("vert",-1),ArrowDown:l1("vert",1)});function l1(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let o=r.selection,l=e>0?o.$to:o.$from,c=o.empty;if(o instanceof nn){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 AGe(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&&Xt.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Vr(r))),!0)}function NGe(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=_t.empty;for(let o=r.length-1;o>=0;o--)i=_t.from(r[o].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Ot(i,0,0));return a.setSelection(nn.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function TGe(t){if(!(t.selection instanceof Vr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Rr.create(t.doc,[Ia.widget(t.selection.head,e,{key:"gapcursor"})])}var ZS=200,Xi=function(){};Xi.prototype.append=function(e){return e.length?(e=Xi.from(e),!this.length&&e||e.length<ZS&&this.leafAppend(e)||this.length<ZS&&e.leafPrepend(this)||this.appendInner(e)):this};Xi.prototype.prepend=function(e){return e.length?Xi.from(e).append(this):this};Xi.prototype.appendInner=function(e){return new CGe(this,e)};Xi.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Xi.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Xi.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Xi.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)};Xi.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,o){return i.push(e(a,o))},n,r),i};Xi.from=function(e){return e instanceof Xi?e:e&&e.length?new jte(e):Xi.empty};var jte=(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,o,l){for(var c=a;c<o;c++)if(i(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,a,o,l){for(var c=a-1;c>=o;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=ZS)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=ZS)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})(Xi);Xi.empty=new jte([]);var CGe=(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,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(a,l),o)===!1||a>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,a)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(a,l)-l,o+l)===!1||a<l&&this.left.forEachInvertedInner(r,Math.min(i,l),a,o)===!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})(Xi);const kGe=500;class Uo{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 o=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 dl(f.map));let p=f.step.map(i.slice(a)),x;p&&o.maybeStep(p).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],u.push(new dl(x,void 0,void 0,u.length+d.length))),a--,x&&i.appendMap(x,a)}else o.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(a)):f.selection,c=new Uo(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:l}}addTransform(e,n,r,i){let a=[],o=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 dl(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&&(o++,n=void 0),i||(c=g)}let u=o-r.depth;return u>jGe&&(l=PGe(l,u),o-=u),new Uo(l.append(a),o)}remapping(e,n){let r=new gb;return this.items.forEach((i,a)=>{let o=i.mirrorOffset!=null&&a-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new Uo(this.items.append(e.map(n=>new dl(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,o=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;o=Math.min(o,p);let x=a.maps[p];if(g.step){let y=e.steps[p].invert(e.docs[p]),b=g.selection&&g.selection.map(a.slice(c+1,p));b&&l++,r.push(new dl(x,y,b))}else r.push(new dl(x))},i);let u=[];for(let g=n;g<o;g++)u.push(new dl(a.maps[g]));let d=this.items.slice(0,i).append(u).append(r),f=new Uo(d,l);return f.emptyItemCount()>kGe&&(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((o,l)=>{if(l>=e)i.push(o),o.selection&&a++;else if(o.step){let c=o.step.map(n.slice(r)),u=c&&c.getMap();if(r--,u&&n.appendMap(u,r),c){let d=o.selection&&o.selection.map(n.slice(r));d&&a++;let f=new dl(u.invert(),c,d),g,p=i.length-1;(g=i.length&&i[p].merge(f))?i[p]=g:i.push(f)}}else o.map&&r--},this.items.length,0),new Uo(Xi.from(i.reverse()),a)}}Uo.empty=new Uo(Xi.empty,0);function PGe(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class dl{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 dl(n.getMap().invert(),n,this.selection)}}}class Qu{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const jGe=20;function RGe(t,e,n,r){let i=n.getMeta(Jh),a;if(i)return i.historyState;n.getMeta(LGe)&&(t=new Qu(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Jh))return o.getMeta(Jh).redo?new Qu(t.done.addTransform(n,void 0,r,z1(e)),t.undone,$7(n.mapping.maps),t.prevTime,t.prevComposition):new Qu(t.done,t.undone.addTransform(n,void 0,r,z1(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),c=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!DGe(n,t.prevRanges)),u=o?Rk(t.prevRanges,n.mapping):$7(n.mapping.maps);return new Qu(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,z1(e)),Uo.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Qu(t.done.rebased(n,a),t.undone.rebased(n,a),Rk(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Qu(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Rk(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function DGe(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 $7(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,o)=>e.push(a,o));return e}function Rk(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 OGe(t,e,n){let r=z1(e),i=Jh.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),l=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),i,r),c=new Qu(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(o).setMeta(Jh,{redo:n,historyState:c})}let Dk=!1,V7=null;function z1(t){let e=t.plugins;if(V7!=e){Dk=!1,V7=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Dk=!0;break}}return Dk}const Jh=new Oi("history"),LGe=new Oi("closeHistory");function IGe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Fr({key:Jh,state:{init(){return new Qu(Uo.empty,Uo.empty,null,0,-1)},apply(e,n,r){return RGe(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?Dte:r=="historyRedo"?Ote:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Rte(t,e){return(n,r)=>{let i=Jh.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=OGe(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const Dte=Rte(!1,!0),Ote=Rte(!0,!0);fr.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 Oi("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 o=a-i,l=0,c=o;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 FGe=fr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[vGe(this.options)]}});fr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Fr({key:new Oi("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 o=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(c.isText)return;if(!(i>=u&&i<=u+c.nodeSize-1))return!1;o+=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"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";a.push(Ia.node(u,u+c.nodeSize,{class:this.options.className}))}),Rr.create(t,a)}}})]}});var UGe=fr.create({name:"gapCursor",addProseMirrorPlugins(){return[MGe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Yn(qt(t,"allowGapCursor",n)))!=null?e:null}}});fr.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 Oi("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((o,l)=>{const c=r>=l&&r<=l+o.nodeSize,u=!o.isLeaf&&C2(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=Ia.node(l,l+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),Rr.create(t,i)}}})]}});fr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Fr({key:new Oi("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Wee(n.selection)||t.view.dragging?null:Rr.create(n.doc,[Ia.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function G7({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var zGe=fr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Oi(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,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),f=l.content.size,g=u.nodes[n];if(d)return c.insert(f,g.create())},state:{init:(i,a)=>{const o=a.tr.doc.lastChild;return!G7({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!G7({node:o,types:r})}}})]}}),BGe=fr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Dte(t,e),redo:()=>({state:t,dispatch:e})=>Ote(t,e)}},addProseMirrorPlugins(){return[IGe(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()}}}),HGe=fr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(pVe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(uVe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(vte.configure(this.options.bulletList)),this.options.code!==!1&&i.push(bVe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(_Ve.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(wVe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(FGe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(UGe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(SVe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(MVe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(BGe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(EVe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(kVe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(_te.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Nte.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(yte.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Cte.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(mGe.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(xGe.configure(this.options.strike)),this.options.text!==!1&&i.push(bGe.configure(this.options.text)),this.options.underline!==!1&&i.push(kte.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(zGe.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),$Ge=HGe,VGe=fr.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")}}}),GGe=VGe,WGe=20,Lte=(t,e=0)=>{const n=[];return!t.children.length||e>WGe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Lte(r,e+1))}),n},qGe=t=>{if(!t.children.length)return;const e=Lte(t);e&&e.forEach(n=>{var r,i;const a=n.getAttribute("style"),o=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${o};${a}`)})},Ite=Gd.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&qGe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Xr(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}}}}),KGe=fr.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 o=a[0].trim().toLowerCase(),l=a.slice(1).join(":").trim();if(o==="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()}}}),Fte=fr.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 o=a[0].trim().toLowerCase(),l=a.slice(1).join(":").trim();if(o==="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()}}}),XGe=fr.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()}}}),YGe=fr.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()}}}),ZGe=fr.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()}}});fr.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(KGe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Fte.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(XGe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(YGe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(ZGe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Ite.configure(this.options.textStyle)),t}});var QGe=Fte,JGe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,e7e=fs.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",Xr(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,o;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=(o=(a=t.attrs)==null?void 0:a.title)!=null?o:"";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:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,f);break}}),l.src=o.src;const c=new O$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[ote({find:JGe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),t7e=e7e;function Yj({content:t,onChange:e,placeholder:n}){const r=aVe({extensions:[$Ge.configure({heading:!1,codeBlock:!1,code:!1}),yGe,tGe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),GGe.configure({types:["paragraph"]}),Ite,QGe,t7e.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:o})=>{e(o.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:o,isActive:l=!1,children:c,title:u})=>s.jsx("button",{type:"button",onClick:o,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 o=window.prompt("Enter URL:");o&&r.chain().focus().setLink({href:o}).run()};return s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[s.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[s.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:s.jsx(lle,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:s.jsx(Kce,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:s.jsx(Fde,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:s.jsx(SR,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:s.jsx(nW,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:s.jsx(kde,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:s.jsx(Ade,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:s.jsx(Tde,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:a,isActive:r.isActive("link"),title:"Add Link",children:s.jsx(Rb,{className:"w-4 h-4"})}),r.isActive("link")&&s.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:s.jsx(dW,{className:"w-4 h-4"})})]}),s.jsx(Q$e,{editor:r})]})}function Ute({archiveId:t,archiveName:e,onClose:n}){const r=cn(),[i,a]=S.useState(!1),[o,l]=S.useState(null),[c,u]=S.useState({}),{data:d,isLoading:f,error:g}=ft({queryKey:["archive-project-page",t],queryFn:()=>ye.getArchiveProjectPage(t)}),p=bt({mutationFn:A=>ye.updateArchiveProjectPage(t,A),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});S.useEffect(()=>{const A=C=>{C.key==="Escape"&&(o!==null?l(null):i?v():n())};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[o,i,n]);const x=[...d?.model_pictures||[],...d?.profile_pictures||[]],y=()=>{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)},b=()=>{p.mutate(c)},v=()=>{a(!1),u({})},E=A=>{const C=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],T=new DOMParser().parseFromString(A,"text/html"),L=k=>{if(k.nodeType===Node.TEXT_NODE)return k.textContent||"";if(k.nodeType===Node.ELEMENT_NODE){const D=k,U=D.tagName.toLowerCase();if(!C.includes(U))return Array.from(D.childNodes).map(L).join("");let O="";if(U==="a"&&D.getAttribute("href")){const R=D.getAttribute("href");R?.toLowerCase().startsWith("http")&&(O=` href="${R}" target="_blank" rel="noopener noreferrer"`)}if(U==="img"){const R=D.getAttribute("src");if(!R?.toLowerCase().startsWith("http"))return"";O=` src="${R}" style="max-width: 100%; height: auto;"`}const q=Array.from(D.childNodes).map(L).join("");return["br","img"].includes(U)?`<${U}${O} />`:`<${U}${O}>${q}</${U}>`}return""};return Array.from(T.body.childNodes).map(L).join("")},w=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),N=A=>{A.target===A.currentTarget&&n()};return s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:N,children:[s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(is,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&s.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!i&&w&&s.jsxs(Ne,{variant:"ghost",size:"sm",onClick:y,children:[s.jsx(of,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&s.jsxs(s.Fragment,{children:[s.jsx(Ne,{variant:"ghost",size:"sm",onClick:v,children:"Cancel"}),s.jsxs(Ne,{variant:"primary",size:"sm",onClick:b,disabled:p.isPending,children:[s.jsx(ks,{className:"w-4 h-4 mr-1"}),"Save"]})]}),s.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Bt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),g&&s.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!w&&s.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[s.jsx(is,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),s.jsx("p",{children:"No project page data found in this 3MF file."}),s.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&w&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[i?s.jsx("input",{type:"text",value:c.title||"",onChange:A=>u({...c,title:A.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&&s.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),s.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(d3,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.designer||"",onChange:A=>u({...c,designer:A.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(d3,{className:"w-4 h-4"}),s.jsx("span",{children:d.designer}),d.designer_user_id&&s.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:s.jsx(qr,{className:"w-3 h-3"})})]}),d.creation_date&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(Wr,{className:"w-4 h-4"}),s.jsx("span",{children:d.creation_date})]}),i?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(is,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.license||"",onChange:A=>u({...c,license:A.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(is,{className:"w-4 h-4"}),s.jsx("span",{children:d.license})]}),d.origin&&s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?s.jsx(Yj,{content:c.description||"",onChange:A=>u({...c,description:A}),placeholder:"Enter description..."}):s.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)&&s.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{type:"text",value:c.profile_title||"",onChange:A=>u({...c,profile_title:A.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),s.jsx(Yj,{content:c.profile_description||"",onChange:A=>u({...c,profile_description:A}),placeholder:"Profile description..."})]}):s.jsxs(s.Fragment,{children:[d.profile_title&&s.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&s.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&&s.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[s.jsx(jb,{className:"w-4 h-4"}),"Images (",x.length,")"]}),s.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((A,C)=>s.jsx("button",{onClick:()=>l(C),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:s.jsx("img",{src:A.url,alt:A.name,className:"w-full h-full object-cover"})},A.path))})]}),d.design_model_id&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.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:[s.jsx(qr,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),o!==null&&x[o]&&s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>l(null),children:[s.jsx("button",{onClick:A=>{A.stopPropagation(),l(Math.max(0,o-1))},disabled:o===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:s.jsx(rf,{className:"w-6 h-6 text-white"})}),s.jsx("img",{src:x[o].url,alt:x[o].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:A=>A.stopPropagation()}),s.jsx("button",{onClick:A=>{A.stopPropagation(),l(Math.min(x.length-1,o+1))},disabled:o===x.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:s.jsx(Zo,{className:"w-6 h-6 text-white"})}),s.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:s.jsx(Bt,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",x.length]})]})]})}const n7e=[.25,.5,.75,1,1.5,2,3,4];function Jm(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function r7e({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=hr(),a=S.useRef(null),o=S.useRef(null),[l,c]=S.useState(!1),[u,d]=S.useState(0),[f,g]=S.useState(0),[p,x]=S.useState(0),[y,b]=S.useState(0),[v,E]=S.useState(1),[w,N]=S.useState(null),[A,C]=S.useState(null),[T,L]=S.useState(.8),[k,D]=S.useState(!1),{data:U,isLoading:O}=ft({queryKey:["timelapse-info",t],queryFn:()=>ye.getTimelapseInfo(t)}),{data:q}=ft({queryKey:["timelapse-thumbnails",t],queryFn:()=>ye.getTimelapseThumbnails(t,15)}),R=bt({mutationFn:()=>ye.processTimelapse(t,{trimStart:p,trimEnd:y,speed:v,saveMode:"replace"},w||void 0),onSuccess:F=>{i(F.message,"success"),r?.(),n()},onError:F=>{i(F.message||"Processing failed","error")}});S.useEffect(()=>{U?.duration&&y===0&&b(U.duration)},[U?.duration,y]),S.useEffect(()=>{const F=W=>{W.key==="Escape"&&n()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[n]),S.useEffect(()=>{const F=a.current;if(!F)return;const W=()=>{const de=F.currentTime;d(de),de>=y&&(F.currentTime=p)},ee=()=>{g(F.duration),y===0&&b(F.duration)},ie=()=>c(!0),ae=()=>c(!1);return F.addEventListener("timeupdate",W),F.addEventListener("durationchange",ee),F.addEventListener("play",ie),F.addEventListener("pause",ae),()=>{F.removeEventListener("timeupdate",W),F.removeEventListener("durationchange",ee),F.removeEventListener("play",ie),F.removeEventListener("pause",ae)}},[p,y]),S.useEffect(()=>{const F=o.current,W=a.current;!F||!W||!A||(F.currentTime=W.currentTime,F.playbackRate=W.playbackRate,l&&!k?F.play().catch(()=>{}):F.pause())},[l,A,k]),S.useEffect(()=>{o.current&&(o.current.volume=k?0:T)},[T,k]),S.useEffect(()=>{a.current&&(a.current.playbackRate=v),o.current&&(o.current.playbackRate=v)},[v]);const G=S.useCallback(()=>{const F=a.current;F&&(l?F.pause():(F.currentTime<p&&(F.currentTime=p),F.play()))},[l,p]),Y=F=>{const W=a.current;W&&(W.currentTime=Math.max(p,Math.min(y,F)))},V=F=>{const W=F.target.files?.[0];W&&(A&&URL.revokeObjectURL(A),N(W),C(URL.createObjectURL(W)))},K=()=>{A&&URL.revokeObjectURL(A),N(null),C(null)};S.useEffect(()=>()=>{A&&URL.revokeObjectURL(A)},[A]);const J=y-p,X=J/v;return O?s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.jsxs("div",{className:"flex items-center gap-3 text-white",children:[s.jsx(xt,{className:"w-6 h-6 animate-spin"}),"Loading video info..."]})}):s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.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:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(hd,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ne,{variant:"primary",size:"sm",onClick:()=>R.mutate(),disabled:R.isPending,children:R.isPending?s.jsxs(s.Fragment,{children:[s.jsx(xt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(ks,{className:"w-4 h-4"}),"Save"]})}),s.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Bt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx("video",{ref:a,src:e,className:"w-full rounded-lg bg-black",onClick:G,muted:!!A}),!l&&s.jsx("button",{onClick:G,className:"absolute inset-0 flex items-center justify-center bg-black/30 hover:bg-black/40 transition-colors",children:s.jsx("div",{className:"p-4 bg-bambu-green rounded-full",children:s.jsx(Gc,{className:"w-8 h-8 text-white"})})}),A&&s.jsx("audio",{ref:o,src:A,loop:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(tde,{className:"w-4 h-4"}),s.jsx("span",{children:"Trim"}),s.jsxs("span",{className:"ml-auto",children:[Jm(p)," - ",Jm(y)," (",Jm(J),")"]})]}),s.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 flex",children:q?.thumbnails.map((F,W)=>s.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${F})`}},W))}),s.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${p/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(f-y)/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${p/f*100}%`,right:`${(f-y)/f*100}%`}}),s.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white shadow-lg",style:{left:`${u/f*100}%`}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:p,onChange:F=>{const W=parseFloat(F.target.value);W<y-1&&(x(W),a.current&&a.current.currentTime<W&&(a.current.currentTime=W))},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 50% 0 0)"}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:y,onChange:F=>{const W=parseFloat(F.target.value);W>p+1&&b(W)},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 0 0 50%)"}})]}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:u,onChange:F=>Y(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`}),s.jsx("div",{className:"flex items-center justify-center gap-2",children:s.jsx("button",{onClick:G,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(ER,{className:"w-5 h-5 text-white"}):s.jsx(Gc,{className:"w-5 h-5 text-white"})})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(cM,{className:"w-4 h-4"}),s.jsx("span",{children:"Speed"}),s.jsxs("span",{className:"ml-auto",children:[v,"x (output: ",Jm(X),")"]})]}),s.jsx("div",{className:"flex gap-1",children:n7e.map(F=>s.jsxs("button",{onClick:()=>E(F),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${v===F?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[F,"x"]},F))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(u3,{className:"w-4 h-4"}),s.jsx("span",{children:"Music Overlay"})]}),w?s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(u3,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:w.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(w.size/1024/1024).toFixed(1)," MB"]})]}),s.jsx("button",{onClick:()=>D(!k),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:k?s.jsx(Kde,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(Wde,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("input",{type:"range",min:0,max:1,step:.1,value:T,onChange:F=>L(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`}),s.jsx("button",{onClick:K,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:s.jsx(_n,{className:"w-4 h-4 text-red-400"})})]}):s.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:[s.jsx(qi,{className:"w-8 h-8 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),s.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),s.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange:V,className:"hidden"})]})]}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg text-sm space-y-1",children:[s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Original:"})," ",Jm(f)," @ ",U?.width,"x",U?.height]}),s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Output:"})," ",Jm(X)," @ ",v,"x speed",w&&" + music overlay"]})]})]}),R.isPending&&s.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[s.jsx(xt,{className:"w-12 h-12 text-bambu-green animate-spin"}),s.jsx("p",{className:"text-white text-lg",children:"Processing timelapse..."}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"This may take a few moments"})]})]})})}const i7e=[.25,.5,.75,1,1.5,2,3,4];function zte({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:a}){const o=S.useRef(null),[l,c]=S.useState(!0),[u,d]=S.useState(1),[f,g]=S.useState(0),[p,x]=S.useState(0),[y,b]=S.useState(!1);S.useEffect(()=>{const T=o.current;T&&(T.playbackRate=u)},[u]),S.useEffect(()=>{const T=L=>{L.key==="Escape"&&i()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[i]),S.useEffect(()=>{const T=o.current;if(!T)return;const L=()=>g(T.currentTime),k=()=>x(T.duration),D=()=>c(!0),U=()=>c(!1);return T.addEventListener("timeupdate",L),T.addEventListener("durationchange",k),T.addEventListener("play",D),T.addEventListener("pause",U),()=>{T.removeEventListener("timeupdate",L),T.removeEventListener("durationchange",k),T.removeEventListener("play",D),T.removeEventListener("pause",U)}},[]);const v=()=>{const T=o.current;T&&(l?T.pause():T.play())},E=T=>{const L=o.current;L&&(L.currentTime=parseFloat(T.target.value))},w=()=>{const T=o.current;T&&(T.currentTime=Math.max(0,T.currentTime-5))},N=()=>{const T=o.current;T&&(T.currentTime=Math.min(p,T.currentTime+5))},A=T=>{const L=Math.floor(T/60),k=Math.floor(T%60);return`${L}:${k.toString().padStart(2,"0")}`},C=()=>{const T=document.createElement("a");T.href=t,T.download=n,T.click()};return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:[s.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(hd,{className:"w-5 h-5 text-bambu-green"}),e]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>b(!0),children:[s.jsx(qo,{className:"w-4 h-4"}),"Edit"]}),s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:C,children:[s.jsx(Mi,{className:"w-4 h-4"}),"Download"]}),s.jsx("button",{onClick:i,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Bt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"p-4",children:[s.jsx("video",{ref:o,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:v}),s.jsxs("div",{className:"mt-4 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:A(f)}),s.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`}),s.jsx("span",{className:"text-xs text-bambu-gray w-12",children:A(p)})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:w,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:s.jsx(fde,{className:"w-5 h-5 text-bambu-gray"})}),s.jsx("button",{onClick:v,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(ER,{className:"w-5 h-5 text-white"}):s.jsx(Gc,{className:"w-5 h-5 text-white"})}),s.jsx("button",{onClick:N,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:s.jsx(Q1,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),s.jsx("div",{className:"flex gap-1",children:i7e.map(T=>s.jsxs("button",{onClick:()=>d(T),className:`px-2 py-1 text-xs rounded transition-colors ${u===T?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[T,"x"]},T))})]})]})]})]})]}),y&&r&&s.jsx(r7e,{archiveId:r,timelapseSrc:t,onClose:()=>b(!1),onSave:a})]})}const W7={"A00-W1":"Jade White","A00-Y2":"Sunflower Yellow","A00-R0":"Red","A00-K0":"Black","A00-G1":"Bambu Green","A00-B3":"Cobalt Blue","A00-D0":"Gray","A00-D3":"Dark Gray","A01-W2":"Ivory White","A01-R1":"Scarlet Red","A01-G1":"Grass Green","A01-B3":"Marine Blue","G02-W0":"White","G02-K0":"Black","G02-R0":"Red","G02-D0":"Gray","G02-B0":"Blue","B00-W0":"White","B00-K0":"Black","B00-R0":"Red"},q7={W0:"White",W1:"Jade White",K0:"Black",R0:"Red",B0:"Blue",G0:"Green",G1:"Green",Y0:"Yellow",Y2:"Yellow",D0:"Gray",D1:"Silver",D3:"Dark Gray",A0:"Orange",P0:"Purple",N0:"Brown"};function K7(t,e){if(t&&W7[t])return W7[t];if(t){const n=t.split("-");if(n.length>=2&&q7[n[1]])return q7[n[1]]}return a7e(e)}function a7e(t){if(!t||t.length<6)return"Unknown";const e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16),a=Math.max(n,r,i)/255,o=Math.min(n,r,i)/255,l=(a+o)/2;let c=0,u=0;if(a!==o){const d=a-o;u=l>.5?d/(2-a-o):d/(a+o);const f=n/255,g=r/255,p=i/255;a===f?c=((g-p)/d+(g<p?6:0))/6:a===g?c=((p-f)/d+2)/6:c=((f-g)/d+4)/6}return c=c*360,l<.15?"Black":l>.85?"White":u<.15?l<.4?"Dark Gray":l>.6?"Light Gray":"Gray":c<15||c>=345?"Red":c<45?"Orange":c<70?"Yellow":c<150?"Green":c<200?"Cyan":c<260?"Blue":c<290?"Purple":c<345?"Pink":"Unknown"}function G4({archiveId:t,archiveName:e,onClose:n}){const r=cn(),{showToast:i}=hr(),[a,o]=S.useState(null),[l,c]=S.useState("asap"),[u,d]=S.useState(""),[f,g]=S.useState(!1),[p,x]=S.useState(!1),[y,b]=S.useState(!1),[v,E]=S.useState(!1),[w,N]=S.useState({}),{data:A}=ft({queryKey:["printers"],queryFn:()=>ye.getPrinters()}),{data:C}=ft({queryKey:["archive-filaments",t],queryFn:()=>ye.getArchiveFilamentRequirements(t)}),{data:T}=ft({queryKey:["printer-status",a],queryFn:()=>ye.getPrinterStatus(a),enabled:!!a});S.useEffect(()=>{A?.length===1&&!a&&o(A[0].id)},[A,a]),S.useEffect(()=>{N({})},[a]),S.useEffect(()=>{const K=J=>{J.key==="Escape"&&n()};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[n]);const L=K=>K?`#${K.replace("#","").substring(0,6)}`:"#808080",k=(K,J,X,F)=>{const W=String.fromCharCode(65+(K>=128?K-128:K));return X?`HT-${W}`:`AMS-${W} Slot ${J+1}`},D=(K,J,X)=>K*4+J,U=S.useMemo(()=>{const K=[];if(T?.ams?.forEach(J=>{const X=J.tray.length===1;J.tray.forEach(F=>{if(F.tray_type){const W=L(F.tray_color);K.push({type:F.tray_type,color:W,colorName:K7(F.tray_id_name,W),amsId:J.id,trayId:F.id,isHt:X,isExternal:!1,label:k(J.id,F.id,X),globalTrayId:D(J.id,F.id)})}})}),T?.vt_tray?.tray_type){const J=L(T.vt_tray.tray_color);K.push({type:T.vt_tray.tray_type,color:J,colorName:K7(T.vt_tray.tray_id_name,J),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return K},[T]),O=S.useMemo(()=>{if(!C?.filaments||C.filaments.length===0)return[];const K=F=>F?F.replace("#","").toLowerCase().substring(0,6):"",J=(F,W,ee=40)=>{const ie=K(F),ae=K(W);if(!ie||!ae||ie.length<6||ae.length<6)return!1;const de=parseInt(ie.substring(0,2),16),ue=parseInt(ie.substring(2,4),16),le=parseInt(ie.substring(4,6),16),he=parseInt(ae.substring(0,2),16),pe=parseInt(ae.substring(2,4),16),Me=parseInt(ae.substring(4,6),16);return Math.abs(de-he)<=ee&&Math.abs(ue-pe)<=ee&&Math.abs(le-Me)<=ee},X=new Set(Object.values(w));return C.filaments.map(F=>{const W=F.slot_id||0;if(W>0&&w[W]!==void 0){const Me=w[W],re=U.find(We=>We.globalTrayId===Me);if(re){const We=re.type?.toUpperCase()===F.type?.toUpperCase(),z=K(re.color)===K(F.color)||J(re.color,F.color);let H;return We&&z?H="match":We?H="type_only":H="mismatch",{...F,loaded:re,hasFilament:!0,typeMatch:We,colorMatch:z,status:H,isManual:!0}}}const ee=U.find(Me=>!X.has(Me.globalTrayId)&&Me.type?.toUpperCase()===F.type?.toUpperCase()&&K(Me.color)===K(F.color)),ie=!ee&&U.find(Me=>!X.has(Me.globalTrayId)&&Me.type?.toUpperCase()===F.type?.toUpperCase()&&J(Me.color,F.color)),ae=!ee&&!ie&&U.find(Me=>!X.has(Me.globalTrayId)&&Me.type?.toUpperCase()===F.type?.toUpperCase()),de=ee||ie||ae||void 0;de&&X.add(de.globalTrayId);const ue=!!de,le=ue,he=!!ee||!!ie;let pe;return ee||ie?pe="match":ae?pe="type_only":pe="mismatch",{...F,loaded:de,hasFilament:ue,typeMatch:le,colorMatch:he,status:pe,isManual:!1}})},[C,U,w]),q=S.useMemo(()=>{if(O.length===0)return;const K=Math.max(...O.map(X=>X.slot_id||0));if(K<=0)return;const J=new Array(K).fill(-1);return O.forEach(X=>{X.slot_id&&X.slot_id>0&&(J[X.slot_id-1]=X.loaded?.globalTrayId??-1)}),J},[O]),R=C?.filaments&&C.filaments.length>0,G=bt({mutationFn:K=>ye.addToQueue(K),onSuccess:()=>{r.invalidateQueries({queryKey:["queue"]}),i("Added to print queue"),n()},onError:K=>{i(K.message||"Failed to add to queue","error")}}),Y=K=>{if(K.preventDefault(),!a){i("Please select a printer","error");return}const J={printer_id:a,archive_id:t,require_previous_success:f,auto_off_after:p,manual_start:l==="manual",ams_mapping:q};l==="scheduled"&&u&&(J.scheduled_time=new Date(u).toISOString()),G.mutate(J)},V=()=>{const K=new Date;return K.setMinutes(K.getMinutes()+1),K.toISOString().slice(0,16)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:s.jsx(Mt,{className:"w-full max-w-md max-h-[90vh] overflow-y-auto",onClick:K=>K.stopPropagation(),children:s.jsxs(At,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Wr,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:Y,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),s.jsx("p",{className:"text-white font-medium truncate",children:e})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),A?.length===0?s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(Aa,{className:"w-4 h-4"}),"No printers configured"]}):s.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:K=>o(K.target.value?Number(K.target.value):null),required:!0,children:[s.jsx("option",{value:"",children:"Select printer..."}),A?.map(K=>s.jsx("option",{value:K.id,children:K.name},K.id))]})]}),a&&R&&s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>b(!y),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(a3,{className:"w-4 h-4",fill:O.some(K=>K.status==="mismatch")?"#f97316":O.some(K=>K.status==="type_only")?"#facc15":"#00ae42",stroke:"none"}),s.jsx("span",{children:"Filament Mapping"}),O.some(K=>K.status==="mismatch")?s.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):O.some(K=>K.status==="type_only")?s.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):s.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),y?s.jsx(Tf,{className:"w-4 h-4 ml-auto"}):s.jsx(Ga,{className:"w-4 h-4 ml-auto"})]}),y&&s.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Click to change slot assignment"}),s.jsxs("button",{type:"button",onClick:async()=>{if(a){E(!0);try{await ye.refreshPrinterStatus(a),await new Promise(K=>setTimeout(K,500)),await r.refetchQueries({queryKey:["printer-status",a]})}finally{E(!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",disabled:v,children:[s.jsx(Gr,{className:`w-3 h-3 ${v?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),O.map((K,J)=>s.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px 1fr auto 1fr 16px"},children:[s.jsx("span",{title:`Required: ${K.color}`,children:s.jsx(a3,{className:"w-3 h-3",fill:K.color,stroke:K.color})}),s.jsxs("span",{className:"text-white truncate",children:[K.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",K.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:K.loaded?.globalTrayId??"",onChange:X=>{const F=K.slot_id||0;if(F>0){const W=X.target.value;N(W===""?ee=>{const ie={...ee};return delete ie[F],ie}:ee=>({...ee,[F]:parseInt(W,10)}))}},className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${K.status==="match"?"border-bambu-green/50 text-bambu-green":K.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${K.isManual?"ring-1 ring-blue-400/50":""}`,title:K.isManual?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),U.map(X=>s.jsxs("option",{value:X.globalTrayId,className:"bg-bambu-dark text-white",children:[X.label,": ",X.type," (",X.colorName,")"]},X.globalTrayId))]}),K.status==="match"?s.jsx(Ls,{className:"w-3 h-3 text-bambu-green"}):K.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(zn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(zn,{className:"w-3 h-3 text-orange-400"})})]},J))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),s.jsxs("div",{className:"flex gap-2",children:[s.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:[s.jsx(dr,{className:"w-4 h-4"}),"ASAP"]}),s.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:[s.jsx(Wr,{className:"w-4 h-4"}),"Scheduled"]}),s.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:[s.jsx(vR,{className:"w-4 h-4"}),"Queue Only"]})]})]}),l==="scheduled"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),s.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:K=>d(K.target.value),min:V(),required:!0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:K=>g(K.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:p,onChange:K=>x(K.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[s.jsx(Ol,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),s.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."}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Ne,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Ne,{type:"submit",className:"flex-1",disabled:G.isPending||!a||A?.length===0,children:G.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function s7e({archiveIds:t,onClose:e}){S.useEffect(()=>{const a=o=>{o.key==="Escape"&&e()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e]);const{data:n,isLoading:r,error:i}=ft({queryKey:["archive-comparison",t],queryFn:()=>ye.compareArchives(t)});return s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:s.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:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?s.jsxs("div",{className:"text-center py-12 text-red-400",children:[s.jsx(zn,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),s.jsx("p",{children:"Failed to load comparison"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?s.jsx(o7e,{comparison:n}):null}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx(Ne,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function o7e({comparison:t}){return s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.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=>s.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[s.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),s.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))]})}),s.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>s.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[s.jsx("td",{className:"py-2 pr-4 text-sm",children:s.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&s.jsx(zn,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),s.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>s.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??s.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&s.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&s.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[s.jsx(zn,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),s.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>s.jsxs("li",{children:[s.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&s.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[s.jsx(Ls,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[s.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),s.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?s.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>s.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[s.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",s.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):s.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):s.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:s.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function l7e(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function c7e(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 u7e({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:a}){const[o,l]=S.useState(!1),[c,u]=S.useState(t.tags||""),[d,f]=S.useState(t.notes||""),[g,p]=S.useState(t.project_id),[x,y]=S.useState(!1);return s.jsx(Mt,{children:s.jsxs(At,{className:"py-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(eW,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:t.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[s.jsx("span",{children:l7e(t.file_size)}),s.jsx("span",{children:"·"}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(dr,{className:"w-3 h-3"}),c7e(t.uploaded_at)]}),t.source_ip&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsxs("span",{children:["from ",t.source_ip]})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>l(!o),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:o?s.jsx(Tf,{className:"w-5 h-5"}):s.jsx(Ga,{className:"w-5 h-5"})}),s.jsx(Ne,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:g||void 0}),disabled:i,children:i?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(fo,{className:"w-4 h-4"}),"Archive"]})}),s.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:a,children:a?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(_n,{className:"w-4 h-4 text-red-400"})})]})]}),x&&s.jsx(Qn,{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),y(!1)},onCancel:()=>y(!1)}),o&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),s.jsx("input",{type:"text",value:c,onChange:b=>u(b.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),s.jsx("textarea",{value:d,onChange:b=>f(b.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Project"}),s.jsxs("select",{value:g||"",onChange:b=>p(b.target.value?Number(b.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:[s.jsx("option",{value:"",children:"No project"}),e.map(b=>s.jsx("option",{value:b.id,children:b.name},b.id))]})]})]})]})})}function d7e(){const t=cn(),{showToast:e}=hr(),[n,r]=S.useState(!1),[i,a]=S.useState(!1),[o,l]=S.useState(new Set),[c,u]=S.useState(new Set),{data:d,isLoading:f}=ft({queryKey:["pending-uploads"],queryFn:Ex.list,refetchInterval:1e4}),{data:g}=ft({queryKey:["projects"],queryFn:()=>ye.getProjects()}),p=bt({mutationFn:({id:v,data:E})=>Ex.archive(v,E),onMutate:({id:v})=>{l(E=>new Set(E).add(v))},onSettled:(v,E,{id:w})=>{l(N=>{const A=new Set(N);return A.delete(w),A})},onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${v.print_name}`)},onError:v=>{e(v.message||"Failed to archive","error")}}),x=bt({mutationFn:v=>Ex.discard(v),onMutate:v=>{u(E=>new Set(E).add(v))},onSettled:(v,E,w)=>{u(N=>{const A=new Set(N);return A.delete(w),A})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:v=>{e(v.message||"Failed to discard","error")}}),y=bt({mutationFn:Ex.archiveAll,onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${v.archived} files${v.failed>0?`, ${v.failed} failed`:""}`)},onError:v=>{e(v.message||"Failed to archive all","error")}}),b=bt({mutationFn:Ex.discardAll,onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${v.discarded} files`)},onError:v=>{e(v.message||"Failed to discard all","error")}});return f?s.jsx(Mt,{children:s.jsx(At,{className:"py-8 flex justify-center",children:s.jsx(xt,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:s.jsxs("div",{className:"mb-6",children:[s.jsxs(Mt,{className:"border-l-4 border-l-yellow-500",children:[s.jsx(vi,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qi,{className:"w-5 h-5 text-yellow-500"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Pending Uploads (",d.length,")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ne,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:y.isPending,children:y.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(fo,{className:"w-4 h-4"}),"Archive All"]})}),s.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:b.isPending,children:b.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(_n,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),s.jsxs(At,{children:[s.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."}),s.jsx("div",{className:"space-y-3",children:d.map(v=>s.jsx(u7e,{upload:v,projects:g||[],onArchive:(E,w)=>p.mutate({id:E,data:w}),onDiscard:E=>x.mutate(E),isArchiving:o.has(v.id),isDiscarding:c.has(v.id)},v.id))})]})]}),n&&s.jsx(Qn,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${d.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{y.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&s.jsx(Qn,{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:()=>{b.mutate(),a(!1)},onCancel:()=>a(!1)})]})}function QS(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Yx(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function h7e({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o,timeFormat:l="system"}){o&&console.log("ArchiveCard isHighlighted=true for archive:",t.id);const c=cn(),{showToast:u}=hr(),d=gW(),[f,g]=S.useState(!1),[p,x]=S.useState(!1),[y,b]=S.useState(!1),[v,E]=S.useState(!1),[w,N]=S.useState(!1),[A,C]=S.useState(!1),[T,L]=S.useState([]),[k,D]=S.useState(!1),[U,O]=S.useState(!1),[q,R]=S.useState(!1),[G,Y]=S.useState(!1),[V,K]=S.useState(!1),[J,X]=S.useState(null),F=S.useRef(null),W=bt({mutationFn:re=>ye.uploadSource3mf(t.id,re),onSuccess:re=>{c.invalidateQueries({queryKey:["archives"]}),u(`Source 3MF attached: ${re.filename}`)},onError:re=>{u(re.message||"Failed to upload source 3MF","error")}}),ee=bt({mutationFn:()=>ye.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Source 3MF removed")},onError:re=>{u(re.message||"Failed to remove source 3MF","error")}}),ie=bt({mutationFn:()=>ye.scanArchiveTimelapse(t.id),onSuccess:re=>{re.status==="attached"?(c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${re.filename}`)):re.status==="exists"?u("Timelapse already attached"):re.status==="not_found"&&re.available_files&&re.available_files.length>0?(L(re.available_files),C(!0)):u(re.message||"No matching timelapse found","warning")},onError:re=>{u(re.message||"Failed to scan for timelapse","error")}}),ae=bt({mutationFn:re=>ye.selectArchiveTimelapse(t.id,re),onSuccess:re=>{c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${re.filename}`),C(!1),L([])},onError:re=>{u(re.message||"Failed to attach timelapse","error")}}),de=bt({mutationFn:()=>ye.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Archive deleted")},onError:()=>{u("Failed to delete archive","error")}}),ue=bt({mutationFn:()=>ye.toggleFavorite(t.id),onSuccess:re=>{c.invalidateQueries({queryKey:["archives"]}),u(re.is_favorite?"Added to favorites":"Removed from favorites")}}),le=bt({mutationFn:re=>ye.updateArchive(t.id,{project_id:re}),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),c.invalidateQueries({queryKey:["projects"]}),u("Project updated")},onError:()=>{u("Failed to update project","error")}}),he=re=>{re.preventDefault(),X({x:re.clientX,y:re.clientY})},Me=[...t.filename?.toLowerCase().includes(".gcode.")?[{label:"Print",icon:s.jsx(Ei,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Schedule",icon:s.jsx(Wr,{className:"w-4 h-4"}),onClick:()=>Y(!0)},{label:"Open in Bambu Studio",icon:s.jsx(qr,{className:"w-4 h-4"}),onClick:()=>{const re=t.print_name||t.filename||"model",We=`${window.location.origin}${ye.getArchiveForSlicer(t.id,re)}`;Ec(We)}}]:[{label:"Slice",icon:s.jsx(qr,{className:"w-4 h-4"}),onClick:()=>{const re=t.print_name||t.filename||"model",We=`${window.location.origin}${ye.getArchiveForSlicer(t.id,re)}`;Ec(We)}}],{label:"View on MakerWorld",icon:s.jsx(sf,{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:s.jsx(vl,{className:"w-4 h-4"}),onClick:()=>g(!0)},{label:"View Timelapse",icon:s.jsx(hd,{className:"w-4 h-4"}),onClick:()=>N(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(iW,{className:"w-4 h-4"}),onClick:()=>ie.mutate(),disabled:!t.printer_id||!!t.timelapse_path||ie.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(K1,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const re=document.createElement("a");re.href=ye.getSource3mfDownloadUrl(t.id),re.download=`${t.print_name||t.filename}_source.3mf`,re.click()}else F.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(qi,{className:"w-4 h-4"}),onClick:()=>F.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(_n,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx(Mi,{className:"w-4 h-4"}),onClick:()=>{const re=document.createElement("a");re.href=ye.getArchiveDownload(t.id),re.download=`${t.print_name||t.filename}.3mf`,re.click()}},{label:"Copy Download Link",icon:s.jsx(Wo,{className:"w-4 h-4"}),onClick:()=>{const re=`${window.location.origin}${ye.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(re).then(()=>{u("Link copied to clipboard")}).catch(()=>{u("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(rW,{className:"w-4 h-4"}),onClick:()=>D(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(kp,{className:"w-4 h-4"}),onClick:()=>O(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(is,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(lf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>ue.mutate()},{label:"Edit",icon:s.jsx(qo,{className:"w-4 h-4"}),onClick:()=>E(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(ha,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(ha,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const re=[];if(t.project_id&&re.push({label:"Remove from Project",icon:s.jsx(Bt,{className:"w-4 h-4"}),onClick:()=>le.mutate(null)}),!a)re.push({label:"Loading...",icon:s.jsx(xt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const We=a.filter(z=>z.status==="active");We.length===0?re.push({label:"No projects available",icon:s.jsx(ha,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):We.forEach(z=>{re.push({label:z.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:z.color||"#888"}}),onClick:()=>le.mutate(z.id),disabled:t.project_id===z.id})})}return re})()},{label:n?"Deselect":"Select",icon:n?s.jsx(Md,{className:"w-4 h-4"}):s.jsx(Ed,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(_n,{className:"w-4 h-4"}),onClick:()=>b(!0),danger:!0}];return s.jsxs(Mt,{"data-archive-id":t.id,className:`relative flex flex-col group ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,style:o?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,onContextMenu:he,onClick:i?()=>r(t.id):void 0,children:[i&&s.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:re=>{re.stopPropagation(),r(t.id)},children:n?s.jsx(Md,{className:"w-5 h-5 text-bambu-green"}):s.jsx(Ed,{className:"w-5 h-5 text-white"})}),s.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?s.jsx("img",{src:ye.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(jb,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),s.jsx("button",{className:`absolute top-2 left-2 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-all ${d?"opacity-100":"opacity-0 group-hover:opacity-100"} ${i?"left-10":""}`,onClick:re=>{re.stopPropagation();const We=re.currentTarget.getBoundingClientRect();X({x:We.left,y:We.bottom+4})},title:"Right-click for more options",children:s.jsx(pp,{className:"w-5 h-5 text-white"})}),s.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:re=>{re.stopPropagation(),ue.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:s.jsx(lf,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),(t.status==="failed"||t.status==="aborted")&&s.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&&s.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:[s.jsx(Wo,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&s.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>{re.stopPropagation();const We=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",z=`${window.location.origin}${ye.getSource3mfForSlicer(t.id,We)}`;Ec(z)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:s.jsx(K1,{className:"w-4 h-4 text-orange-400"})}),t.timelapse_path&&s.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>{re.stopPropagation(),N(!0)},title:"View timelapse",children:s.jsx(hd,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&s.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:re=>{re.stopPropagation(),O(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[s.jsx(kp,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&s.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})]})]}),s.jsxs(At,{className:"p-4 flex-1 flex flex-col",children:[s.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),s.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:e}),s.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&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${a?.find(re=>re.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(re=>re.id===t.project_id)?.color||"#6b7280"},title:`Project: ${t.project_name}`,children:t.project_name})]}),s.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)&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${Yx(t.print_time_seconds||0)}
  8268. Actual: ${Yx(t.actual_time_seconds||0)}
  8269. Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Yx(t.actual_time_seconds)}`:`Estimated: ${Yx(t.print_time_seconds||0)}`,children:[s.jsx(dr,{className:"w-3 h-3"}),Yx(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&s.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&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(Vc,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(Sd,{className:"w-3 h-3"}),t.total_layers&&s.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&s.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&s.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.object_count!=null&&t.object_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:`${t.object_count} object${t.object_count>1?"s":""}`,children:[s.jsx(vl,{className:"w-3 h-3"}),t.object_count," object",t.object_count>1?"s":""]}),t.filament_type&&s.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[s.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((re,We)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:re},title:re},We))})]})]}),(t.tags||t.notes)&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&s.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:s.jsx(sW,{className:"w-3 h-3"})}),t.tags?.split(",").map((re,We)=>s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:re.trim()},We))]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[s.jsx("span",{children:Op(t.created_at,l)}),s.jsx("span",{children:QS(t.file_size)})]}),s.jsxs("div",{className:"flex gap-1 mt-3",children:[t.filename?.toLowerCase().includes(".gcode.")?s.jsxs(s.Fragment,{children:[s.jsxs(Ne,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>x(!0),children:[s.jsx(Ei,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),s.jsx(Ne,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=t.print_name||t.filename||"model",We=`${window.location.origin}${ye.getArchiveForSlicer(t.id,re)}`;Ec(We)},title:"Open in Bambu Studio",children:s.jsx(qr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):s.jsxs(Ne,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const re=t.print_name||t.filename||"model",We=`${window.location.origin}${ye.getArchiveForSlicer(t.id,re)}`;Ec(We)},title:"Open in Bambu Studio to slice",children:[s.jsx(qr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Slice"})]}),s.jsx(Ne,{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:s.jsx(sf,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),s.jsx(Ne,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>g(!0),title:"3D Preview",children:s.jsx(vl,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Ne,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=document.createElement("a");re.href=ye.getArchiveDownload(t.id),re.download=`${t.print_name||t.filename}.3mf`,re.click()},title:"Download",children:s.jsx(Mi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Ne,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>E(!0),title:"Edit",children:s.jsx(qo,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Ne,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>b(!0),title:"Delete",children:s.jsx(_n,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),v&&s.jsx(eJ,{archive:t,onClose:()=>E(!1)}),f&&s.jsx(QQ,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>g(!1)}),p&&s.jsx(JQ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1),onSuccess:()=>{}}),y&&s.jsx(Qn,{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:()=>{de.mutate(),b(!1)},onCancel:()=>b(!1)}),V&&s.jsx(Qn,{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:()=>{ee.mutate(),K(!1)},onCancel:()=>K(!1)}),J&&s.jsx(tJ,{x:J.x,y:J.y,items:Me,onClose:()=>X(null)}),w&&t.timelapse_path&&s.jsx(zte,{src:ye.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>N(!1),onEdit:()=>{c.invalidateQueries({queryKey:["archives"]}),N(!1)}}),A&&T.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{C(!1),L([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(re=>s.jsxs("button",{onClick:()=>ae.mutate(re.name),disabled:ae.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:[s.jsx(hd,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:re.name}),s.jsxs("p",{className:"text-sm text-gray-400",children:[QS(re.size),re.mtime&&` • ${Op(re.mtime,l)}`]})]})]},re.name))}),s.jsx("div",{className:"p-4 border-t border-gray-700",children:s.jsx(Ne,{variant:"secondary",onClick:()=>{C(!1),L([])},className:"w-full",children:"Cancel"})})]})}),k&&s.jsx(nJ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>D(!1)}),U&&t.photos&&t.photos.length>0&&s.jsx(rJ,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>O(!1),onDelete:async re=>{try{await ye.deleteArchivePhoto(t.id,re),c.invalidateQueries({queryKey:["archives"]}),u("Photo deleted")}catch{u("Failed to delete photo","error")}}}),q&&s.jsx(Ute,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),G&&s.jsx(G4,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>Y(!1)}),s.jsx("input",{ref:F,type:"file",accept:".3mf",className:"hidden",onChange:re=>{const We=re.target.files?.[0];We&&W.mutate(We),re.target.value=""}})]})}function f7e({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o}){const l=cn(),{showToast:c}=hr(),[u,d]=S.useState(!1),[f,g]=S.useState(!1),[p,x]=S.useState(!1),[y,b]=S.useState(!1),[v,E]=S.useState(!1),[w,N]=S.useState(!1),[A,C]=S.useState(!1),[T,L]=S.useState([]),[k,D]=S.useState(!1),[U,O]=S.useState(!1),[q,R]=S.useState(!1),[G,Y]=S.useState(!1),[V,K]=S.useState(null),J=S.useRef(null),X=bt({mutationFn:pe=>ye.uploadSource3mf(t.id,pe),onSuccess:pe=>{l.invalidateQueries({queryKey:["archives"]}),c(`Source 3MF attached: ${pe.filename}`)},onError:pe=>{c(pe.message||"Failed to upload source 3MF","error")}}),F=bt({mutationFn:()=>ye.deleteSource3mf(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Source 3MF removed")},onError:pe=>{c(pe.message||"Failed to remove source 3MF","error")}}),W=bt({mutationFn:()=>ye.scanArchiveTimelapse(t.id),onSuccess:pe=>{pe.status==="attached"?(l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${pe.filename}`)):pe.status==="exists"?c("Timelapse already attached"):pe.status==="not_found"&&pe.available_files&&pe.available_files.length>0?(L(pe.available_files),C(!0)):c(pe.message||"No matching timelapse found","warning")},onError:pe=>{c(pe.message||"Failed to scan for timelapse","error")}}),ee=bt({mutationFn:pe=>ye.selectArchiveTimelapse(t.id,pe),onSuccess:pe=>{l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${pe.filename}`),C(!1),L([])},onError:pe=>{c(pe.message||"Failed to attach timelapse","error")}}),ie=bt({mutationFn:()=>ye.deleteArchive(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Archive deleted")},onError:()=>{c("Failed to delete archive","error")}}),ae=bt({mutationFn:()=>ye.toggleFavorite(t.id),onSuccess:pe=>{l.invalidateQueries({queryKey:["archives"]}),c(pe.is_favorite?"Added to favorites":"Removed from favorites")}}),de=bt({mutationFn:pe=>ye.updateArchive(t.id,{project_id:pe}),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),l.invalidateQueries({queryKey:["projects"]}),c("Project updated")},onError:()=>{c("Failed to update project","error")}}),ue=pe=>{pe.preventDefault(),K({x:pe.clientX,y:pe.clientY})},he=[...t.filename?.toLowerCase().includes(".gcode.")?[{label:"Print",icon:s.jsx(Ei,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Schedule",icon:s.jsx(Wr,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:"Open in Bambu Studio",icon:s.jsx(qr,{className:"w-4 h-4"}),onClick:()=>{const pe=t.print_name||t.filename||"model",Me=`${window.location.origin}${ye.getArchiveForSlicer(t.id,pe)}`;Ec(Me)}}]:[{label:"Slice",icon:s.jsx(qr,{className:"w-4 h-4"}),onClick:()=>{const pe=t.print_name||t.filename||"model",Me=`${window.location.origin}${ye.getArchiveForSlicer(t.id,pe)}`;Ec(Me)}}],{label:"View on MakerWorld",icon:s.jsx(sf,{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:s.jsx(vl,{className:"w-4 h-4"}),onClick:()=>E(!0)},{label:"View Timelapse",icon:s.jsx(hd,{className:"w-4 h-4"}),onClick:()=>N(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(iW,{className:"w-4 h-4"}),onClick:()=>W.mutate(),disabled:!t.printer_id||!!t.timelapse_path||W.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(K1,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const pe=document.createElement("a");pe.href=ye.getSource3mfDownloadUrl(t.id),pe.download=`${t.print_name||t.filename}_source.3mf`,pe.click()}else J.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(qi,{className:"w-4 h-4"}),onClick:()=>J.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(_n,{className:"w-4 h-4"}),onClick:()=>Y(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx(Mi,{className:"w-4 h-4"}),onClick:()=>{const pe=document.createElement("a");pe.href=ye.getArchiveDownload(t.id),pe.download=`${t.print_name||t.filename}.3mf`,pe.click()}},{label:"Copy Download Link",icon:s.jsx(Wo,{className:"w-4 h-4"}),onClick:()=>{const pe=`${window.location.origin}${ye.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(pe).then(()=>{c("Link copied to clipboard")}).catch(()=>{c("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(rW,{className:"w-4 h-4"}),onClick:()=>D(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(kp,{className:"w-4 h-4"}),onClick:()=>O(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(is,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(lf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>ae.mutate()},{label:"Edit",icon:s.jsx(qo,{className:"w-4 h-4"}),onClick:()=>d(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(ha,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(ha,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const pe=[];if(t.project_id&&pe.push({label:"Remove from Project",icon:s.jsx(Bt,{className:"w-4 h-4"}),onClick:()=>de.mutate(null)}),!a)pe.push({label:"Loading...",icon:s.jsx(xt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const Me=a.filter(re=>re.status==="active");Me.length===0?pe.push({label:"No projects available",icon:s.jsx(ha,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):Me.forEach(re=>{pe.push({label:re.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:re.color||"#888"}}),onClick:()=>de.mutate(re.id),disabled:t.project_id===re.id})})}return pe})()},{label:n?"Deselect":"Select",icon:n?s.jsx(Md,{className:"w-4 h-4"}):s.jsx(Ed,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(_n,{className:"w-4 h-4"}),onClick:()=>g(!0),danger:!0}];return s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-archive-id":t.id,className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${n?"bg-bambu-green/10":""}`,style:o?{outline:"4px solid #facc15",outlineOffset:"-4px"}:void 0,onContextMenu:ue,children:[s.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[i&&s.jsx("button",{onClick:()=>r(t.id),children:n?s.jsx(Md,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Ed,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?s.jsx("img",{src:ye.getArchiveThumbnail(t.id),alt:"",className:"w-10 h-10 object-cover rounded"}):s.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:s.jsx(jb,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),s.jsxs("div",{className:"col-span-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-white text-sm truncate",children:t.print_name||t.filename}),t.timelapse_path&&s.jsx("span",{title:"Has timelapse",children:s.jsx(hd,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),t.filament_type&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((pe,Me)=>s.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:pe},title:pe},Me))})]})]}),s.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:e}),s.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:Dp(t.created_at)}),s.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:QS(t.file_size)}),s.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[s.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{const pe=t.print_name||t.filename||"model",Me=`${window.location.origin}${ye.getArchiveForSlicer(t.id,pe)}`;Ec(Me)},title:"Open in Bambu Studio",children:s.jsx(qr,{className:"w-4 h-4"})}),t.makerworld_url&&s.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>window.open(t.makerworld_url,"_blank"),title:"MakerWorld",children:s.jsx(sf,{className:"w-4 h-4"})}),s.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>{const pe=document.createElement("a");pe.href=ye.getArchiveDownload(t.id),pe.download=`${t.print_name||t.filename}.3mf`,pe.click()},title:"Download",children:s.jsx(Mi,{className:"w-4 h-4"})}),s.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>d(!0),title:"Edit",children:s.jsx(qo,{className:"w-4 h-4"})}),s.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>g(!0),title:"Delete",children:s.jsx(_n,{className:"w-4 h-4 text-red-400"})}),s.jsx(Ne,{variant:"ghost",size:"sm",onClick:pe=>{const Me=pe.currentTarget.getBoundingClientRect();K({x:Me.left,y:Me.bottom+4})},title:"More options",children:s.jsx(pp,{className:"w-4 h-4"})})]})]}),u&&s.jsx(eJ,{archive:t,onClose:()=>d(!1)}),v&&s.jsx(QQ,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>E(!1)}),p&&s.jsx(JQ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1),onSuccess:()=>{}}),f&&s.jsx(Qn,{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:()=>{ie.mutate(),g(!1)},onCancel:()=>g(!1)}),G&&s.jsx(Qn,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{F.mutate(),Y(!1)},onCancel:()=>Y(!1)}),V&&s.jsx(tJ,{x:V.x,y:V.y,items:he,onClose:()=>K(null)}),w&&t.timelapse_path&&s.jsx(zte,{src:ye.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>N(!1),onEdit:()=>{l.invalidateQueries({queryKey:["archives"]}),N(!1)}}),A&&T.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{C(!1),L([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(pe=>s.jsxs("button",{onClick:()=>ee.mutate(pe.name),disabled:ee.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors mb-1",children:[s.jsx("div",{className:"font-medium text-white",children:pe.name}),s.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[s.jsx("span",{children:QS(pe.size)}),pe.mtime&&s.jsx("span",{children:Dp(pe.mtime)})]})]},pe.name))})]})}),k&&s.jsx(nJ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>D(!1)}),U&&t.photos&&s.jsx(rJ,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>O(!1),onDelete:async pe=>{try{await ye.deleteArchivePhoto(t.id,pe),l.invalidateQueries({queryKey:["archives"]}),c("Photo deleted")}catch{c("Failed to delete photo","error")}}}),q&&s.jsx(Ute,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),y&&s.jsx(G4,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),s.jsx("input",{ref:J,type:"file",accept:".3mf",className:"hidden",onChange:pe=>{const Me=pe.target.files?.[0];Me&&X.mutate(Me),pe.target.value=""}})]})}const m7e=[{id:"all",label:"All Archives",icon:s.jsx(wce,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:s.jsx(dr,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:s.jsx(Wr,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:s.jsx(Wr,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:s.jsx(lf,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:s.jsx(Aa,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:s.jsx(Wo,{className:"w-4 h-4"})}];function p7e(){const t=cn(),{showToast:e}=hr(),n=S.useRef(null),[r,i]=S.useState(""),[a,o]=S.useState(()=>{const te=localStorage.getItem("archiveFilterPrinter");return te?Number(te):null}),[l,c]=S.useState(()=>localStorage.getItem("archiveFilterMaterial")),[u,d]=S.useState(()=>{const te=localStorage.getItem("archiveFilterColors");return te?new Set(JSON.parse(te)):new Set}),[f,g]=S.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[p,x]=S.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[y,b]=S.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[v,E]=S.useState(()=>localStorage.getItem("archiveFilterTag")),[w,N]=S.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[A,C]=S.useState(!1),[T,L]=S.useState([]),[k,D]=S.useState(!1),[U,O]=S.useState(new Set),[q,R]=S.useState(!1),[G,Y]=S.useState(!1),[V,K]=S.useState(!1),[J,X]=S.useState(!1),[F,W]=S.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[ee,ie]=S.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[ae,de]=S.useState(()=>localStorage.getItem("archiveCollection")||"all"),[ue,le]=S.useState(!1),[he,pe]=S.useState(!1),[Me,re]=S.useState(!1),[We,z]=S.useState(null);S.useEffect(()=>{if(We){const te=setTimeout(()=>{const xe=document.querySelector(`[data-archive-id="${We}"]`);xe&&xe.scrollIntoView({behavior:"smooth",block:"center"})},100),Fe=setTimeout(()=>z(null),5e3);return()=>{clearTimeout(te),clearTimeout(Fe)}}},[We]);const{data:H,isLoading:se}=ft({queryKey:["archives",a],queryFn:()=>ye.getArchives(a||void 0)}),{data:B}=ft({queryKey:["printers"],queryFn:ye.getPrinters}),{data:Q}=ft({queryKey:["projects"],queryFn:()=>ye.getProjects()}),{data:ce}=ft({queryKey:["settings"],queryFn:ye.getSettings}),Ce=ce?.time_format||"system",_e=bt({mutationFn:async te=>(await Promise.all(te.map(Fe=>ye.deleteArchive(Fe))),te.length),onSuccess:te=>{t.invalidateQueries({queryKey:["archives"]}),O(new Set),e(`${te} archive${te!==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",y.toString())},[y]),S.useEffect(()=>{v?localStorage.setItem("archiveFilterTag",v):localStorage.removeItem("archiveFilterTag")},[v]),S.useEffect(()=>{localStorage.setItem("archiveFilterFileType",w)},[w]),S.useEffect(()=>{localStorage.setItem("archiveViewMode",F)},[F]),S.useEffect(()=>{localStorage.setItem("archiveSortBy",ee)},[ee]),S.useEffect(()=>{localStorage.setItem("archiveCollection",ae)},[ae]);const Ee=new Map(B?.map(te=>[te.id,te.name])||[]),$=[...new Set(H?.flatMap(te=>te.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),j=[...new Set(H?.flatMap(te=>te.filament_color?.split(",")||[]).filter(Boolean)||[])],ne=[...new Set(H?.flatMap(te=>te.tags?.split(",").map(Fe=>Fe.trim())||[]).filter(Boolean)||[])].sort(),be=H?.filter(te=>{const Fe=new Date,xe=ui(te.created_at)||new Date(0);let ze=!0;switch(ae){case"recent":ze=Fe.getTime()-xe.getTime()<1440*60*1e3;break;case"this-week":ze=Fe.getTime()-xe.getTime()<10080*60*1e3;break;case"this-month":ze=xe.getMonth()===Fe.getMonth()&&xe.getFullYear()===Fe.getFullYear();break;case"favorites":ze=te.is_favorite===!0;break;case"failed":ze=te.status==="failed"||te.status==="aborted";break;case"duplicates":ze=te.duplicate_count>0;break}const Pe=(te.print_name||te.filename).toLowerCase().includes(r.toLowerCase()),Se=!l||te.filament_type?.split(", ").includes(l),Ye=te.filament_color?.split(",")||[],dt=u.size===0||(f==="or"?Ye.some(Vn=>u.has(Vn)):[...u].every(Vn=>Ye.includes(Vn))),Tt=ae==="favorites"||!p||te.is_favorite,Et=ae==="failed"||!y||te.status!=="failed"&&te.status!=="aborted",Zt=te.tags?.split(",").map(Vn=>Vn.trim())||[],Rt=!v||Zt.includes(v),en=te.filename?.toLowerCase().includes(".gcode.");return ze&&Pe&&Se&&dt&&Tt&&Et&&Rt&&(w==="all"||w==="gcode"&&en||w==="source"&&!en)}).sort((te,Fe)=>{switch(ee){case"date-desc":return(ui(Fe.created_at)?.getTime()||0)-(ui(te.created_at)?.getTime()||0);case"date-asc":return(ui(te.created_at)?.getTime()||0)-(ui(Fe.created_at)?.getTime()||0);case"name-asc":return(te.print_name||te.filename).localeCompare(Fe.print_name||Fe.filename);case"name-desc":return(Fe.print_name||Fe.filename).localeCompare(te.print_name||te.filename);case"size-desc":return Fe.file_size-te.file_size;case"size-asc":return te.file_size-Fe.file_size;default:return 0}}),we=q||U.size>0,ve=te=>{O(Fe=>{const xe=new Set(Fe);return xe.has(te)?xe.delete(te):xe.add(te),xe})},$e=()=>{be&&O(new Set(be.map(te=>te.id)))},Ge=()=>{O(new Set),R(!1)},Xe=te=>{d(Fe=>{const xe=new Set(Fe);return xe.has(te)?xe.delete(te):xe.add(te),xe})},ut=()=>{d(new Set)},He=()=>{i(""),o(null),c(null),x(!1),b(!1),E(null),N("all")},me=r||a||l||p||y||v||w!=="all",Je=S.useCallback(te=>{te.preventDefault(),te.dataTransfer.types.includes("Files")&&D(!0)},[]),Ke=S.useCallback(te=>{te.preventDefault(),te.currentTarget===te.target&&D(!1)},[]),Ze=S.useCallback(te=>{te.preventDefault(),D(!1);const Fe=Array.from(te.dataTransfer.files).filter(xe=>xe.name.endsWith(".3mf"));Fe.length>0?(L(Fe),C(!0)):te.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),ct=S.useCallback(te=>{const Fe=te.target;if(Fe.tagName==="INPUT"||Fe.tagName==="TEXTAREA"||Fe.isContentEditable){te.key==="Escape"&&Fe.blur();return}switch(te.key){case"/":te.preventDefault(),n.current?.focus();break;case"u":case"U":!te.metaKey&&!te.ctrlKey&&(te.preventDefault(),C(!0));break;case"Escape":we&&Ge();break}},[we]);return S.useEffect(()=>(document.addEventListener("keydown",ct),()=>document.removeEventListener("keydown",ct)),[ct]),s.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:Je,onDragLeave:Ke,onDrop:Ze,children:[k&&s.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:s.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[s.jsx(qi,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),s.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),s.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),we&&s.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:[s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:Ge,children:[s.jsx(Bt,{className:"w-4 h-4"}),"Close"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs("span",{className:"text-white font-medium",children:[U.size," selected"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsx(Ne,{variant:"secondary",size:"sm",onClick:$e,children:"Select All"}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>K(!0),children:[s.jsx(Rp,{className:"w-4 h-4"}),"Tags"]}),s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>X(!0),children:[s.jsx(ha,{className:"w-4 h-4"}),"Project"]}),s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>{const te=Array.from(U);Promise.all(te.map(Fe=>ye.toggleFavorite(Fe))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${te.length} archive${te.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[s.jsx(lf,{className:"w-4 h-4"}),"Favorite"]}),s.jsxs(Ne,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>Y(!0),children:[s.jsx(_n,{className:"w-4 h-4"}),"Delete"]})]}),s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),s.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:ae,onChange:te=>de(te.target.value),children:m7e.map(te=>s.jsx("option",{value:te.id,children:te.label},te.id))})]}),s.jsxs("p",{className:"text-bambu-gray",children:[be?.length||0," of ",H?.length||0," prints"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs(Ne,{variant:"secondary",onClick:()=>le(!ue),disabled:he,children:[he?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(X1,{className:"w-4 h-4"}),"Export"]}),ue&&s.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:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:async()=>{le(!1),pe(!0);try{const{blob:te,filename:Fe}=await ye.exportArchives({format:"csv",printerId:a||void 0,status:ae==="failed"?"failed":void 0,search:r||void 0}),xe=URL.createObjectURL(te),ze=document.createElement("a");ze.href=xe,ze.download=Fe,ze.click(),URL.revokeObjectURL(xe),e("Export downloaded")}catch{e("Export failed","error")}finally{pe(!1)}},children:[s.jsx(is,{className:"w-4 h-4"}),"Export as CSV"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{le(!1),pe(!0);try{const{blob:te,filename:Fe}=await ye.exportArchives({format:"xlsx",printerId:a||void 0,status:ae==="failed"?"failed":void 0,search:r||void 0}),xe=URL.createObjectURL(te),ze=document.createElement("a");ze.href=xe,ze.download=Fe,ze.click(),URL.revokeObjectURL(xe),e("Export downloaded")}catch{e("Export failed","error")}finally{pe(!1)}},children:[s.jsx(X1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),U.size>=2&&U.size<=5&&s.jsxs(Ne,{variant:"secondary",onClick:()=>re(!0),children:[s.jsx(gp,{className:"w-4 h-4"}),"Compare (",U.size,")"]}),!we&&s.jsxs(Ne,{variant:"secondary",onClick:()=>R(!0),children:[s.jsx(Md,{className:"w-4 h-4"}),"Select"]}),s.jsxs(Ne,{onClick:()=>C(!0),children:[s.jsx(qi,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),s.jsx(Mt,{className:"mb-6",children:s.jsxs(At,{className:"py-4",children:[s.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[s.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[s.jsx(Ml,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.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:te=>i(te.target.value)})]}),s.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:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(yR,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:te=>o(te.target.value?Number(te.target.value):null),children:[s.jsx("option",{value:"",children:"All Printers"}),B?.map(te=>s.jsx("option",{value:te.id,children:te.name},te.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Vc,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:te=>c(te.target.value||null),children:[s.jsx("option",{value:"",children:"All Materials"}),$.map(te=>s.jsx("option",{value:te,children:te},te))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(K1,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:te=>N(te.target.value),children:[s.jsx("option",{value:"all",children:"All Files"}),s.jsx("option",{value:"gcode",children:"Sliced (GCODE)"}),s.jsx("option",{value:"source",children:"Source Only"})]})]}),s.jsxs("button",{onClick:()=>x(!p),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${p?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:p?"Show all":"Show favorites only",children:[s.jsx(lf,{className:`w-4 h-4 ${p?"fill-yellow-400":""}`}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),s.jsxs("button",{onClick:()=>b(!y),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${y?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:y?"Show failed prints":"Hide failed prints",children:[s.jsx(Aa,{className:"w-4 h-4 "}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),ne.length>0&&s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Rp,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:v||"",onChange:te=>E(te.target.value||null),children:[s.jsx("option",{value:"",children:"All Tags"}),ne.map(te=>s.jsx("option",{value:te,children:te},te))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(ile,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:ee,onChange:te=>ie(te.target.value),children:[s.jsx("option",{value:"date-desc",children:"Newest first"}),s.jsx("option",{value:"date-asc",children:"Oldest first"}),s.jsx("option",{value:"name-asc",children:"Name A-Z"}),s.jsx("option",{value:"name-desc",children:"Name Z-A"}),s.jsx("option",{value:"size-desc",children:"Largest first"}),s.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),s.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[s.jsx("button",{className:`p-2 ${F==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>W("grid"),title:"Grid view",children:s.jsx(wR,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${F==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>W("list"),title:"List view",children:s.jsx(SR,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${F==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>W("calendar"),title:"Calendar view",children:s.jsx(ble,{className:"w-4 h-4"})})]})]}),me&&s.jsxs(Ne,{variant:"ghost",size:"sm",onClick:He,className:"text-bambu-gray hover:text-white",children:[s.jsx(Bt,{className:"w-4 h-4"}),"Reset"]})]}),j.length>0&&s.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),u.size>1&&s.jsx("button",{onClick:()=>g(te=>te==="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()}),s.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:j.map(te=>s.jsx("button",{onClick:()=>Xe(te),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(te)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:te},title:te},te))}),u.size>0&&s.jsxs("button",{onClick:ut,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[s.jsx(Bt,{className:"w-3 h-3"}),"Clear"]})]})]})}),s.jsx(d7e,{}),se?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):be?.length===0?s.jsx(Mt,{children:s.jsxs(At,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):F==="calendar"?s.jsx(Mt,{className:"p-6",children:s.jsx(Bze,{archives:be||[],onArchiveClick:te=>{i(""),W("grid"),z(te.id)},highlightedArchiveId:We})}):F==="grid"?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:be?.map(te=>s.jsx(h7e,{archive:te,printerName:te.printer_id?Ee.get(te.printer_id)||"Unknown":"No Printer",isSelected:U.has(te.id),onSelect:ve,selectionMode:we,projects:Q,isHighlighted:te.id===We,timeFormat:Ce},te.id))}):F==="list"?s.jsx(Mt,{children:s.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[s.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[s.jsx("div",{className:"col-span-1"}),s.jsx("div",{className:"col-span-4",children:"Name"}),s.jsx("div",{className:"col-span-2",children:"Printer"}),s.jsx("div",{className:"col-span-2",children:"Date"}),s.jsx("div",{className:"col-span-1",children:"Size"}),s.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),be?.map(te=>s.jsx(f7e,{archive:te,printerName:te.printer_id?Ee.get(te.printer_id)||"Unknown":"No Printer",isSelected:U.has(te.id),onSelect:ve,selectionMode:we,projects:Q,isHighlighted:te.id===We},te.id))]})}):null,A&&s.jsx(jze,{onClose:()=>{C(!1),L([])},initialFiles:T}),G&&s.jsx(Qn,{title:"Delete Archives",message:`Are you sure you want to delete ${U.size} archive${U.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${U.size}`,variant:"danger",onConfirm:()=>{_e.mutate(Array.from(U)),Y(!1)},onCancel:()=>Y(!1)}),V&&s.jsx(Oze,{selectedIds:Array.from(U),existingTags:ne,onClose:()=>K(!1)}),J&&s.jsx(Lze,{selectedIds:Array.from(U),onClose:()=>X(!1)}),Me&&U.size>=2&&U.size<=5&&s.jsx(s7e,{archiveIds:Array.from(U),onClose:()=>{re(!1),O(new Set),R(!1)}})]})}function g7e(){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 R2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Pg(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function W4(t){return"nodeType"in t}function ms(t){var e,n;return t?Pg(t)?t:W4(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function q4(t){const{Document:e}=ms(t);return t instanceof e}function xy(t){return Pg(t)?!1:t instanceof ms(t).HTMLElement}function Bte(t){return t instanceof ms(t).SVGElement}function jg(t){return t?Pg(t)?t.document:W4(t)?q4(t)?t:xy(t)||Bte(t)?t.ownerDocument:document:document:document}const Rl=R2?S.useLayoutEffect:S.useEffect;function K4(t){const e=S.useRef(t);return Rl(()=>{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 x7e(){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 Mb(t,e){e===void 0&&(e=[t]);const n=S.useRef(t);return Rl(()=>{n.current!==t&&(n.current=t)},e),n}function by(t,e){const n=S.useRef();return S.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function JS(t){const e=K4(t),n=S.useRef(null),r=S.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function Zj(t){const e=S.useRef();return S.useEffect(()=>{e.current=t},[t]),e.current}let Ok={};function yy(t,e){return S.useMemo(()=>{if(e)return e;const n=Ok[t]==null?0:Ok[t]+1;return Ok[t]=n,t+"-"+n},[t,e])}function Hte(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,o)=>{const l=Object.entries(o);for(const[c,u]of l){const d=a[c];d!=null&&(a[c]=d+t*u)}return a},{...e})}}const Tp=Hte(1),Eb=Hte(-1);function b7e(t){return"clientX"in t&&"clientY"in t}function X4(t){if(!t)return!1;const{KeyboardEvent:e}=ms(t.target);return e&&t instanceof e}function y7e(t){if(!t)return!1;const{TouchEvent:e}=ms(t.target);return e&&t instanceof e}function Qj(t){if(y7e(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 b7e(t)?{x:t.clientX,y:t.clientY}:null}const sg=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[sg.Translate.toString(t),sg.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),X7="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function v7e(t){return t.matches(X7)?t:t.querySelector(X7)}const _7e={display:"none"};function w7e(t){let{id:e,value:n}=t;return kr.createElement("div",{id:e,style:_7e},n)}function S7e(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 M7e(){const[t,e]=S.useState("");return{announce:S.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const $te=S.createContext(null);function E7e(t){const e=S.useContext($te);S.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function A7e(){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(o=>{var l;return(l=o[i])==null?void 0:l.call(o,a)})},[t]),e]}const N7e={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. `},T7e={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 C7e(t){let{announcements:e=T7e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=N7e}=t;const{announce:a,announcement:o}=M7e(),l=yy("DndLiveRegion"),[c,u]=S.useState(!1);if(S.useEffect(()=>{u(!0)},[]),E7e(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(w7e,{id:r,value:i.draggable}),kr.createElement(S7e,{id:l,announcement:o}));return n?Tc.createPortal(d,n):d}var wi;(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"})(wi||(wi={}));function eM(){}function tM(t,e){return S.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Vte(){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 Xo=Object.freeze({x:0,y:0});function Gte(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Wte(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function k7e(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function Y7(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 qte(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function Z7(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 Kte=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=Z7(e,e.left,e.top),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=Gte(Z7(c),i);a.push({id:l,data:{droppableContainer:o,value:u}})}}return a.sort(Wte)},P7e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=Y7(e),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=Y7(c),d=i.reduce((g,p,x)=>g+Gte(u[x],p),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:o,value:f}})}}return a.sort(Wte)};function j7e(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),o=i-r,l=a-n;if(r<i&&n<a){const c=e.width*e.height,u=t.width*t.height,d=o*l,f=d/(c+u-d);return Number(f.toFixed(4))}return 0}const R7e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const a of r){const{id:o}=a,l=n.get(o);if(l){const c=j7e(l,e);c>0&&i.push({id:o,data:{droppableContainer:a,value:c}})}}return i.sort(k7e)};function D7e(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function Xte(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Xo}function O7e(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((o,l)=>({...o,top:o.top+t*l.y,bottom:o.bottom+t*l.y,left:o.left+t*l.x,right:o.right+t*l.x}),{...n})}}const L7e=O7e(1);function I7e(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 F7e(t,e,n){const r=I7e(e);if(!r)return t;const{scaleX:i,scaleY:a,x:o,y:l}=r,c=t.left-o-(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 U7e={ignoreTransform:!1};function Rg(t,e){e===void 0&&(e=U7e);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=ms(t).getComputedStyle(t);u&&(n=F7e(n,u,d))}const{top:r,left:i,width:a,height:o,bottom:l,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:l,right:c}}function Q7(t){return Rg(t,{ignoreTransform:!0})}function z7e(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function B7e(t,e){return e===void 0&&(e=ms(t).getComputedStyle(t)),e.position==="fixed"}function H7e(t,e){e===void 0&&(e=ms(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 D2(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(q4(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!xy(i)||Bte(i)||n.includes(i))return n;const a=ms(t).getComputedStyle(i);return i!==t&&H7e(i,a)&&n.push(i),B7e(i,a)?n:r(i.parentNode)}return t?r(t):n}function Yte(t){const[e]=D2(t,1);return e??null}function Lk(t){return!R2||!t?null:Pg(t)?t:W4(t)?q4(t)||t===jg(t).scrollingElement?window:xy(t)?t:null:null}function Zte(t){return Pg(t)?t.scrollX:t.scrollLeft}function Qte(t){return Pg(t)?t.scrollY:t.scrollTop}function Jj(t){return{x:Zte(t),y:Qte(t)}}var Vi;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Vi||(Vi={}));function Jte(t){return!R2||!t?!1:t===document.scrollingElement}function ene(t){const e={x:0,y:0},n=Jte(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,o=t.scrollTop>=r.y,l=t.scrollLeft>=r.x;return{isTop:i,isLeft:a,isBottom:o,isRight:l,maxScroll:r,minScroll:e}}const $7e={x:.2,y:.2};function V7e(t,e,n,r,i){let{top:a,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=$7e);const{isTop:u,isBottom:d,isLeft:f,isRight:g}=ene(t),p={x:0,y:0},x={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+y.height?(p.y=Vi.Backward,x.y=r*Math.abs((e.top+y.height-a)/y.height)):!d&&c>=e.bottom-y.height&&(p.y=Vi.Forward,x.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!g&&l>=e.right-y.width?(p.x=Vi.Forward,x.x=r*Math.abs((e.right-y.width-l)/y.width)):!f&&o<=e.left+y.width&&(p.x=Vi.Backward,x.x=r*Math.abs((e.left+y.width-o)/y.width)),{direction:p,speed:x}}function G7e(t){if(t===document.scrollingElement){const{innerWidth:a,innerHeight:o}=window;return{top:0,left:0,right:a,bottom:o,width:a,height:o}}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 tne(t){return t.reduce((e,n)=>Tp(e,Jj(n)),Xo)}function W7e(t){return t.reduce((e,n)=>e+Zte(n),0)}function q7e(t){return t.reduce((e,n)=>e+Qte(n),0)}function K7e(t,e){if(e===void 0&&(e=Rg),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);Yte(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const X7e=[["x",["left","right"],W7e],["y",["top","bottom"],q7e]];class Y4{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=D2(n),i=tne(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,o,l]of X7e)for(const c of o)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 P0{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 Y7e(t){const{EventTarget:e}=ms(t);return t instanceof e?t:jg(t)}function Ik(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 io;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(io||(io={}));function J7(t){t.preventDefault()}function Z7e(t){t.stopPropagation()}var Rn;(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"})(Rn||(Rn={}));const nne={start:[Rn.Space,Rn.Enter],cancel:[Rn.Esc],end:[Rn.Space,Rn.Enter,Rn.Tab]},Q7e=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Rn.Right:return{...n,x:n.x+25};case Rn.Left:return{...n,x:n.x-25};case Rn.Down:return{...n,y:n.y+25};case Rn.Up:return{...n,y:n.y-25}}};class O2{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 P0(jg(n)),this.windowListeners=new P0(ms(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(io.Resize,this.handleCancel),this.windowListeners.add(io.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(io.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&K7e(r),n(Xo)}handleKeyDown(e){if(X4(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=nne,coordinateGetter:o=Q7e,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}:Xo;this.referenceCoordinates||(this.referenceCoordinates=d);const f=o(e,{active:n,context:r.current,currentCoordinates:d});if(f){const g=Eb(f,d),p={x:0,y:0},{scrollableAncestors:x}=r.current;for(const y of x){const b=e.code,{isTop:v,isRight:E,isLeft:w,isBottom:N,maxScroll:A,minScroll:C}=ene(y),T=G7e(y),L={x:Math.min(b===Rn.Right?T.right-T.width/2:T.right,Math.max(b===Rn.Right?T.left:T.left+T.width/2,f.x)),y:Math.min(b===Rn.Down?T.bottom-T.height/2:T.bottom,Math.max(b===Rn.Down?T.top:T.top+T.height/2,f.y))},k=b===Rn.Right&&!E||b===Rn.Left&&!w,D=b===Rn.Down&&!N||b===Rn.Up&&!v;if(k&&L.x!==f.x){const U=y.scrollLeft+g.x,O=b===Rn.Right&&U<=A.x||b===Rn.Left&&U>=C.x;if(O&&!g.y){y.scrollTo({left:U,behavior:l});return}O?p.x=y.scrollLeft-U:p.x=b===Rn.Right?y.scrollLeft-A.x:y.scrollLeft-C.x,p.x&&y.scrollBy({left:-p.x,behavior:l});break}else if(D&&L.y!==f.y){const U=y.scrollTop+g.y,O=b===Rn.Down&&U<=A.y||b===Rn.Up&&U>=C.y;if(O&&!g.x){y.scrollTo({top:U,behavior:l});return}O?p.y=y.scrollTop-U:p.y=b===Rn.Down?y.scrollTop-A.y:y.scrollTop-C.y,p.y&&y.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,Tp(Eb(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()}}O2.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=nne,onActivation:i}=e,{active:a}=n;const{code:o}=t.nativeEvent;if(r.start.includes(o)){const l=a.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function e9(t){return!!(t&&"distance"in t)}function t9(t){return!!(t&&"delay"in t)}class Z4{constructor(e,n,r){var i;r===void 0&&(r=Y7e(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:o}=a;this.props=e,this.events=n,this.document=jg(o),this.documentListeners=new P0(this.document),this.listeners=new P0(r),this.windowListeners=new P0(ms(o)),this.initialCoordinates=(i=Qj(a))!=null?i:Xo,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(io.Resize,this.handleCancel),this.windowListeners.add(io.DragStart,J7),this.windowListeners.add(io.VisibilityChange,this.handleCancel),this.windowListeners.add(io.ContextMenu,J7),this.documentListeners.add(io.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(t9(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(e9(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(io.Click,Z7e,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(io.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:o,options:{activationConstraint:l}}=a;if(!i)return;const c=(n=Qj(e))!=null?n:Xo,u=Eb(i,c);if(!r&&l){if(e9(l)){if(l.tolerance!=null&&Ik(u,l.tolerance))return this.handleCancel();if(Ik(u,l.distance))return this.handleStart()}if(t9(l)&&Ik(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}e.cancelable&&e.preventDefault(),o(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===Rn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const J7e={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class L2 extends Z4{constructor(e){const{event:n}=e,r=jg(n.target);super(e,J7e,r)}}L2.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 e9e={move:{name:"mousemove"},end:{name:"mouseup"}};var eR;(function(t){t[t.RightClick=2]="RightClick"})(eR||(eR={}));class t9e extends Z4{constructor(e){super(e,e9e,jg(e.event.target))}}t9e.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===eR.RightClick?!1:(r?.({event:n}),!0)}}];const Fk={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class n9e extends Z4{constructor(e){super(e,Fk)}static setup(){return window.addEventListener(Fk.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Fk.move.name,e)};function e(){}}}n9e.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 j0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(j0||(j0={}));var nM;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(nM||(nM={}));function r9e(t){let{acceleration:e,activator:n=j0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:l=nM.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:g}=t;const p=a9e({delta:f,disabled:!a}),[x,y]=x7e(),b=S.useRef({x:0,y:0}),v=S.useRef({x:0,y:0}),E=S.useMemo(()=>{switch(n){case j0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case j0.DraggableRect:return i}},[n,i,c]),w=S.useRef(null),N=S.useCallback(()=>{const C=w.current;if(!C)return;const T=b.current.x*v.current.x,L=b.current.y*v.current.y;C.scrollBy(T,L)},[]),A=S.useMemo(()=>l===nM.TreeOrder?[...u].reverse():u,[l,u]);S.useEffect(()=>{if(!a||!u.length||!E){y();return}for(const C of A){if(r?.(C)===!1)continue;const T=u.indexOf(C),L=d[T];if(!L)continue;const{direction:k,speed:D}=V7e(C,L,E,e,g);for(const U of["x","y"])p[U][k[U]]||(D[U]=0,k[U]=0);if(D.x>0||D.y>0){y(),w.current=C,x(N,o),b.current=D,v.current=k;return}}b.current={x:0,y:0},v.current={x:0,y:0},y()},[e,N,r,y,a,o,JSON.stringify(E),JSON.stringify(p),x,u,A,d,JSON.stringify(g)])}const i9e={x:{[Vi.Backward]:!1,[Vi.Forward]:!1},y:{[Vi.Backward]:!1,[Vi.Forward]:!1}};function a9e(t){let{delta:e,disabled:n}=t;const r=Zj(e);return by(i=>{if(n||!r||!i)return i9e;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Vi.Backward]:i.x[Vi.Backward]||a.x===-1,[Vi.Forward]:i.x[Vi.Forward]||a.x===1},y:{[Vi.Backward]:i.y[Vi.Backward]||a.y===-1,[Vi.Forward]:i.y[Vi.Forward]||a.y===1}}},[n,e,r])}function s9e(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return by(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function o9e(t,e){return S.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,a=i.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,r)}));return[...n,...a]},[]),[t,e])}var Ab;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Ab||(Ab={}));var tR;(function(t){t.Optimized="optimized"})(tR||(tR={}));const n9=new Map;function l9e(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,o]=S.useState(null),{frequency:l,measure:c,strategy:u}=i,d=S.useRef(t),f=b(),g=Mb(f),p=S.useCallback(function(v){v===void 0&&(v=[]),!g.current&&o(E=>E===null?v:E.concat(v.filter(w=>!E.includes(w))))},[g]),x=S.useRef(null),y=by(v=>{if(f&&!n)return n9;if(!v||v===n9||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 N=w.node.current,A=N?new Y4(c(N),N):null;w.rect.current=A,A&&E.set(w.id,A)}return E}return v},[t,a,n,f,c]);return S.useEffect(()=>{d.current=t},[t]),S.useEffect(()=>{f||p()},[n,f]),S.useEffect(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),S.useEffect(()=>{f||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{p(),x.current=null},l))},[l,f,p,...r]),{droppableRects:y,measureDroppableContainers:p,measuringScheduled:a!=null};function b(){switch(u){case Ab.Always:return!1;case Ab.BeforeDragging:return n;default:return!n}}}function rne(t,e){return by(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function c9e(t,e){return rne(t,e)}function u9e(t){let{callback:e,disabled:n}=t;const r=K4(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 I2(t){let{callback:e,disabled:n}=t;const r=K4(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 d9e(t){return new Y4(Rg(t),t)}function r9(t,e,n){e===void 0&&(e=d9e);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 o=u9e({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=I2({callback:a});return Rl(()=>{a(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function h9e(t){const e=rne(t);return Xte(t,e)}const i9=[];function f9e(t){const e=S.useRef(t),n=by(r=>t?r&&r!==i9&&t&&e.current&&t.parentNode===e.current.parentNode?r:D2(t):i9,[t]);return S.useEffect(()=>{e.current=t},[t]),n}function m9e(t){const[e,n]=S.useState(null),r=S.useRef(t),i=S.useCallback(a=>{const o=Lk(a.target);o&&n(l=>l?(l.set(o,Jj(o)),new Map(l)):null)},[]);return S.useEffect(()=>{const a=r.current;if(t!==a){o(a);const l=t.map(c=>{const u=Lk(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,Jj(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=t}return()=>{o(t),o(a)};function o(l){l.forEach(c=>{const u=Lk(c);u?.removeEventListener("scroll",i)})}},[i,t]),S.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,o)=>Tp(a,o),Xo):tne(t):Xo,[t,e])}function a9(t,e){e===void 0&&(e=[]);const n=S.useRef(null);return S.useEffect(()=>{n.current=null},e),S.useEffect(()=>{const r=t!==Xo;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?Eb(t,n.current):Xo}function p9e(t){S.useEffect(()=>{if(!R2)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 g9e(t,e){return S.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=o=>{a(o,e)},n},{}),[t,e])}function ine(t){return S.useMemo(()=>t?z7e(t):null,[t])}const s9=[];function x9e(t,e){e===void 0&&(e=Rg);const[n]=t,r=ine(n?ms(n):null),[i,a]=S.useState(s9);function o(){a(()=>t.length?t.map(c=>Jte(c)?r:new Y4(e(c),c)):s9)}const l=I2({callback:o});return Rl(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function b9e(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return xy(e)?e:t}function y9e(t){let{measure:e}=t;const[n,r]=S.useState(null),i=S.useCallback(u=>{for(const{target:d}of u)if(xy(d)){r(f=>{const g=e(d);return f?{...f,width:g.width,height:g.height}:g});break}},[e]),a=I2({callback:i}),o=S.useCallback(u=>{const d=b9e(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=JS(o);return S.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const v9e=[{sensor:L2,options:{}},{sensor:O2,options:{}}],_9e={current:{}},B1={draggable:{measure:Q7},droppable:{measure:Q7,strategy:Ab.WhileDragging,frequency:tR.Optimized},dragOverlay:{measure:Rg}};class R0 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 w9e={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new R0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:eM},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:B1,measureDroppableContainers:eM,windowRect:null,measuringScheduled:!1},S9e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:eM,draggableNodes:new Map,over:null,measureDroppableContainers:eM},F2=S.createContext(S9e),ane=S.createContext(w9e);function M9e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new R0}}}function E9e(t,e){switch(e.type){case wi.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case wi.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 wi.DragEnd:case wi.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case wi.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new R0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case wi.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const o=new R0(t.droppable.containers);return o.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case wi.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new R0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function A9e(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=S.useContext(F2),a=Zj(r),o=Zj(n?.id);return S.useEffect(()=>{if(!e&&!r&&a&&o!=null){if(!X4(a)||document.activeElement===a.target)return;const l=i.get(o);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=v7e(d);if(f){f.focus();break}}})}},[r,e,i,o,a]),null}function N9e(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function T9e(t){return S.useMemo(()=>({draggable:{...B1.draggable,...t?.draggable},droppable:{...B1.droppable,...t?.droppable},dragOverlay:{...B1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function C9e(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=S.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Rl(()=>{if(!o&&!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=Xte(d,r);if(o||(f.x=0),l||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const g=Yte(u);g&&g.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const sne=S.createContext({...Xo,scaleX:1,scaleY:1});var Ju;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Ju||(Ju={}));const one=S.memo(function(e){var n,r,i,a;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=v9e,collisionDetection:f=R7e,measuring:g,modifiers:p,...x}=e;const y=S.useReducer(E9e,void 0,M9e),[b,v]=y,[E,w]=A7e(),[N,A]=S.useState(Ju.Uninitialized),C=N===Ju.Initialized,{draggable:{active:T,nodes:L,translate:k},droppable:{containers:D}}=b,U=T!=null?L.get(T):null,O=S.useRef({initial:null,translated:null}),q=S.useMemo(()=>{var ze;return T!=null?{id:T,data:(ze=U?.data)!=null?ze:_9e,rect:O}:null},[T,U]),R=S.useRef(null),[G,Y]=S.useState(null),[V,K]=S.useState(null),J=Mb(x,Object.values(x)),X=yy("DndDescribedBy",o),F=S.useMemo(()=>D.getEnabled(),[D]),W=T9e(g),{droppableRects:ee,measureDroppableContainers:ie,measuringScheduled:ae}=l9e(F,{dragging:C,dependencies:[k.x,k.y],config:W.droppable}),de=s9e(L,T),ue=S.useMemo(()=>V?Qj(V):null,[V]),le=xe(),he=c9e(de,W.draggable.measure);C9e({activeNode:T!=null?L.get(T):null,config:le.layoutShiftCompensation,initialRect:he,measure:W.draggable.measure});const pe=r9(de,W.draggable.measure,he),Me=r9(de?de.parentElement:null),re=S.useRef({activatorEvent:null,active:null,activeNode:de,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:L,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),We=D.getNodeFor((n=re.current.over)==null?void 0:n.id),z=y9e({measure:W.dragOverlay.measure}),H=(r=z.nodeRef.current)!=null?r:de,se=C?(i=z.rect)!=null?i:pe:null,B=!!(z.nodeRef.current&&z.rect),Q=h9e(B?null:pe),ce=ine(H?ms(H):null),Ce=f9e(C?We??de:null),_e=x9e(Ce),Ee=N9e(p,{transform:{x:k.x-Q.x,y:k.y-Q.y,scaleX:1,scaleY:1},activatorEvent:V,active:q,activeNodeRect:pe,containerNodeRect:Me,draggingNodeRect:se,over:re.current.over,overlayNodeRect:z.rect,scrollableAncestors:Ce,scrollableAncestorRects:_e,windowRect:ce}),$=ue?Tp(ue,k):null,j=m9e(Ce),ne=a9(j),be=a9(j,[pe]),we=Tp(Ee,ne),ve=se?L7e(se,Ee):null,$e=q&&ve?f({active:q,collisionRect:ve,droppableRects:ee,droppableContainers:F,pointerCoordinates:$}):null,Ge=qte($e,"id"),[Xe,ut]=S.useState(null),He=B?Ee:Tp(Ee,be),me=D7e(He,(a=Xe?.rect)!=null?a:null,pe),Je=S.useRef(null),Ke=S.useCallback((ze,Pe)=>{let{sensor:Se,options:Ye}=Pe;if(R.current==null)return;const dt=L.get(R.current);if(!dt)return;const Tt=ze.nativeEvent,Et=new Se({active:R.current,activeNode:dt,event:Tt,options:Ye,context:re,onAbort(Rt){if(!L.get(Rt))return;const{onDragAbort:Ln}=J.current,Vn={id:Rt};Ln?.(Vn),E({type:"onDragAbort",event:Vn})},onPending(Rt,en,Ln,Vn){if(!L.get(Rt))return;const{onDragPending:gt}=J.current,Vt={id:Rt,constraint:en,initialCoordinates:Ln,offset:Vn};gt?.(Vt),E({type:"onDragPending",event:Vt})},onStart(Rt){const en=R.current;if(en==null)return;const Ln=L.get(en);if(!Ln)return;const{onDragStart:Vn}=J.current,tr={activatorEvent:Tt,active:{id:en,data:Ln.data,rect:O}};Tc.unstable_batchedUpdates(()=>{Vn?.(tr),A(Ju.Initializing),v({type:wi.DragStart,initialCoordinates:Rt,active:en}),E({type:"onDragStart",event:tr}),Y(Je.current),K(Tt)})},onMove(Rt){v({type:wi.DragMove,coordinates:Rt})},onEnd:Zt(wi.DragEnd),onCancel:Zt(wi.DragCancel)});Je.current=Et;function Zt(Rt){return async function(){const{active:Ln,collisions:Vn,over:tr,scrollAdjustedTranslate:gt}=re.current;let Vt=null;if(Ln&&gt){const{cancelDrop:Qt}=J.current;Vt={activatorEvent:Tt,active:Ln,collisions:Vn,delta:gt,over:tr},Rt===wi.DragEnd&&typeof Qt=="function"&&await Promise.resolve(Qt(Vt))&&(Rt=wi.DragCancel)}R.current=null,Tc.unstable_batchedUpdates(()=>{v({type:Rt}),A(Ju.Uninitialized),ut(null),Y(null),K(null),Je.current=null;const Qt=Rt===wi.DragEnd?"onDragEnd":"onDragCancel";if(Vt){const mt=J.current[Qt];mt?.(Vt),E({type:Qt,event:Vt})}})}}},[L]),Ze=S.useCallback((ze,Pe)=>(Se,Ye)=>{const dt=Se.nativeEvent,Tt=L.get(Ye);if(R.current!==null||!Tt||dt.dndKit||dt.defaultPrevented)return;const Et={active:Tt};ze(Se,Pe.options,Et)===!0&&(dt.dndKit={capturedBy:Pe.sensor},R.current=Ye,Ke(Se,Pe))},[L,Ke]),ct=o9e(d,Ze);p9e(d),Rl(()=>{pe&&N===Ju.Initializing&&A(Ju.Initialized)},[pe,N]),S.useEffect(()=>{const{onDragMove:ze}=J.current,{active:Pe,activatorEvent:Se,collisions:Ye,over:dt}=re.current;if(!Pe||!Se)return;const Tt={active:Pe,activatorEvent:Se,collisions:Ye,delta:{x:we.x,y:we.y},over:dt};Tc.unstable_batchedUpdates(()=>{ze?.(Tt),E({type:"onDragMove",event:Tt})})},[we.x,we.y]),S.useEffect(()=>{const{active:ze,activatorEvent:Pe,collisions:Se,droppableContainers:Ye,scrollAdjustedTranslate:dt}=re.current;if(!ze||R.current==null||!Pe||!dt)return;const{onDragOver:Tt}=J.current,Et=Ye.get(Ge),Zt=Et&&Et.rect.current?{id:Et.id,rect:Et.rect.current,data:Et.data,disabled:Et.disabled}:null,Rt={active:ze,activatorEvent:Pe,collisions:Se,delta:{x:dt.x,y:dt.y},over:Zt};Tc.unstable_batchedUpdates(()=>{ut(Zt),Tt?.(Rt),E({type:"onDragOver",event:Rt})})},[Ge]),Rl(()=>{re.current={activatorEvent:V,active:q,activeNode:de,collisionRect:ve,collisions:$e,droppableRects:ee,draggableNodes:L,draggingNode:H,draggingNodeRect:se,droppableContainers:D,over:Xe,scrollableAncestors:Ce,scrollAdjustedTranslate:we},O.current={initial:se,translated:ve}},[q,de,$e,ve,L,H,se,ee,D,Xe,Ce,we]),r9e({...le,delta:k,draggingRect:ve,pointerCoordinates:$,scrollableAncestors:Ce,scrollableAncestorRects:_e});const te=S.useMemo(()=>({active:q,activeNode:de,activeNodeRect:pe,activatorEvent:V,collisions:$e,containerNodeRect:Me,dragOverlay:z,draggableNodes:L,droppableContainers:D,droppableRects:ee,over:Xe,measureDroppableContainers:ie,scrollableAncestors:Ce,scrollableAncestorRects:_e,measuringConfiguration:W,measuringScheduled:ae,windowRect:ce}),[q,de,pe,V,$e,Me,z,L,D,ee,Xe,ie,Ce,_e,W,ae,ce]),Fe=S.useMemo(()=>({activatorEvent:V,activators:ct,active:q,activeNodeRect:pe,ariaDescribedById:{draggable:X},dispatch:v,draggableNodes:L,over:Xe,measureDroppableContainers:ie}),[V,ct,q,pe,v,X,L,Xe,ie]);return kr.createElement($te.Provider,{value:w},kr.createElement(F2.Provider,{value:Fe},kr.createElement(ane.Provider,{value:te},kr.createElement(sne.Provider,{value:me},u)),kr.createElement(A9e,{disabled:l?.restoreFocus===!1})),kr.createElement(C7e,{...l,hiddenTextDescribedById:X}));function xe(){const ze=G?.autoScrollEnabled===!1,Pe=typeof c=="object"?c.enabled===!1:c===!1,Se=C&&!ze&&!Pe;return typeof c=="object"?{...c,enabled:Se}:{enabled:Se}}}),k9e=S.createContext(null),o9="button",P9e="Draggable";function j9e(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=yy(P9e),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:g}=S.useContext(F2),{role:p=o9,roleDescription:x="draggable",tabIndex:y=0}=i??{},b=c?.id===e,v=S.useContext(b?sne:k9e),[E,w]=JS(),[N,A]=JS(),C=g9e(o,e),T=Mb(n);Rl(()=>(f.set(e,{id:e,key:a,node:E,activatorNode:N,data:T}),()=>{const k=f.get(e);k&&k.key===a&&f.delete(e)}),[f,e]);const L=S.useMemo(()=>({role:p,tabIndex:y,"aria-disabled":r,"aria-pressed":b&&p===o9?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,p,y,b,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:L,isDragging:b,listeners:r?void 0:C,node:E,over:g,setNodeRef:w,setActivatorNodeRef:A,transform:v}}function R9e(){return S.useContext(ane)}const D9e="Droppable",O9e={timeout:25};function L9e(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=yy(D9e),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=S.useContext(F2),d=S.useRef({disabled:n}),f=S.useRef(!1),g=S.useRef(null),p=S.useRef(null),{disabled:x,updateMeasurementsFor:y,timeout:b}={...O9e,...i},v=Mb(y??r),E=S.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),p.current=null},b)},[b]),w=I2({callback:E,disabled:x||!o}),N=S.useCallback((L,k)=>{w&&(k&&(w.unobserve(k),f.current=!1),L&&w.observe(L))},[w]),[A,C]=JS(N),T=Mb(e);return S.useEffect(()=>{!w||!A.current||(w.disconnect(),f.current=!1,w.observe(A.current))},[A,w]),S.useEffect(()=>(l({type:wi.RegisterDroppable,element:{id:r,key:a,disabled:n,node:A,rect:g,data:T}}),()=>l({type:wi.UnregisterDroppable,key:a,id:r})),[r]),S.useEffect(()=>{n!==d.current.disabled&&(l({type:wi.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,l]),{active:o,rect:g,isOver:c?.id===r,node:A,over:c,setNodeRef:C}}function U2(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function I9e(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function c1(t){return t!==null&&t>=0}function F9e(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 U9e(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const Q4=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=U2(e,r,n),o=e[i],l=a[i];return!l||!o?null:{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}},u1={scaleX:1,scaleY:1},z9e=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:a,overIndex:o}=t;const l=(e=a[n])!=null?e:r;if(!l)return null;if(i===n){const u=a[o];return u?{x:0,y:n<o?u.top+u.height-(l.top+l.height):u.top-l.top,...u1}:null}const c=B9e(a,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...u1}:i<n&&i>=o?{x:0,y:l.height+c,...u1}:{x:0,y:0,...u1}};function B9e(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 lne="Sortable",cne=kr.createContext({activeIndex:-1,containerId:lne,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Q4,disabled:{draggable:!1,droppable:!1}});function une(t){let{children:e,id:n,items:r,strategy:i=Q4,disabled:a=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=R9e(),f=yy(lne,n),g=l.rect!==null,p=S.useMemo(()=>r.map(C=>typeof C=="object"&&"id"in C?C.id:C),[r]),x=o!=null,y=o?p.indexOf(o.id):-1,b=u?p.indexOf(u.id):-1,v=S.useRef(p),E=!F9e(p,v.current),w=b!==-1&&y===-1||E,N=U9e(a);Rl(()=>{E&&x&&d(p)},[E,p,x,d]),S.useEffect(()=>{v.current=p},[p]);const A=S.useMemo(()=>({activeIndex:y,containerId:f,disabled:N,disableTransforms:w,items:p,overIndex:b,useDragOverlay:g,sortedRects:I9e(p,c),strategy:i}),[y,f,N.draggable,N.droppable,w,p,b,c,g,i]);return kr.createElement(cne.Provider,{value:A},e)}const H9e=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return U2(n,r,i).indexOf(e)},$9e=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:l,previousContainerId:c,transition:u}=t;return!u||!r||l!==a&&i===o?!1:n?!0:o!==i&&e===c},V9e={duration:200,easing:"ease"},dne="transform",G9e=sg.Transition.toString({property:dne,duration:0,easing:"linear"}),W9e={roleDescription:"sortable"};function q9e(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,o]=S.useState(null),l=S.useRef(n);return Rl(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=Rg(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)&&o(d)}}n!==l.current&&(l.current=n)},[e,n,r,i]),S.useEffect(()=>{a&&o(null)},[a]),a}function hne(t){let{animateLayoutChanges:e=$9e,attributes:n,disabled:r,data:i,getNewIndex:a=H9e,id:o,strategy:l,resizeObserverConfig:c,transition:u=V9e}=t;const{items:d,containerId:f,activeIndex:g,disabled:p,disableTransforms:x,sortedRects:y,overIndex:b,useDragOverlay:v,strategy:E}=S.useContext(cne),w=K9e(r,p),N=d.indexOf(o),A=S.useMemo(()=>({sortable:{containerId:f,index:N,items:d},...i}),[f,i,N,d]),C=S.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:T,node:L,isOver:k,setNodeRef:D}=L9e({id:o,data:A,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:U,activatorEvent:O,activeNodeRect:q,attributes:R,setNodeRef:G,listeners:Y,isDragging:V,over:K,setActivatorNodeRef:J,transform:X}=j9e({id:o,data:A,attributes:{...W9e,...n},disabled:w.draggable}),F=g7e(D,G),W=!!U,ee=W&&!x&&c1(g)&&c1(b),ie=!v&&V,ae=ie&&ee?X:null,ue=ee?ae??(l??E)({rects:y,activeNodeRect:q,activeIndex:g,overIndex:b,index:N}):null,le=c1(g)&&c1(b)?a({id:o,items:d,activeIndex:g,overIndex:b}):N,he=U?.id,pe=S.useRef({activeId:he,items:d,newIndex:le,containerId:f}),Me=d!==pe.current.items,re=e({active:U,containerId:f,isDragging:V,isSorting:W,id:o,index:N,items:d,newIndex:pe.current.newIndex,previousItems:pe.current.items,previousContainerId:pe.current.containerId,transition:u,wasDragging:pe.current.activeId!=null}),We=q9e({disabled:!re,index:N,node:L,rect:T});return S.useEffect(()=>{W&&pe.current.newIndex!==le&&(pe.current.newIndex=le),f!==pe.current.containerId&&(pe.current.containerId=f),d!==pe.current.items&&(pe.current.items=d)},[W,le,f,d]),S.useEffect(()=>{if(he===pe.current.activeId)return;if(he!=null&&pe.current.activeId==null){pe.current.activeId=he;return}const H=setTimeout(()=>{pe.current.activeId=he},50);return()=>clearTimeout(H)},[he]),{active:U,activeIndex:g,attributes:R,data:A,rect:T,index:N,newIndex:le,items:d,isOver:k,isSorting:W,isDragging:V,listeners:Y,node:L,overIndex:b,over:K,setNodeRef:F,setActivatorNodeRef:J,setDroppableNodeRef:D,setDraggableNodeRef:G,transform:We??ue,transition:z()};function z(){if(We||Me&&pe.current.newIndex===N)return G9e;if(!(ie&&!X4(O)||!u)&&(W||re))return sg.Transition.toString({...u,property:dne})}}function K9e(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 rM(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 X9e=[Rn.Down,Rn.Right,Rn.Up,Rn.Left],fne=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:l}}=e;if(X9e.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 Rn.Down:r.top<g.top&&c.push(f);break;case Rn.Up:r.top>g.top&&c.push(f);break;case Rn.Left:r.left>g.left&&c.push(f);break;case Rn.Right:r.left<g.left&&c.push(f);break}});const u=P7e({collisionRect:r,droppableRects:i,droppableContainers:c});let d=qte(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const f=a.get(n.id),g=a.get(d),p=g?i.get(g.id):null,x=g?.node.current;if(x&&p&&f&&g){const b=D2(x).some((C,T)=>l[T]!==C),v=mne(f,g),E=Y9e(f,g),w=b||!v?{x:0,y:0}:{x:E?r.width-p.width:0,y:E?r.height-p.height:0},N={x:p.left,y:p.top};return w.x&&w.y?N:Eb(N,w)}}}};function mne(t,e){return!rM(t)||!rM(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function Y9e(t,e){return!rM(t)||!rM(e)||!mne(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function Z9e({item:t,onClose:e}){const n=cn(),{showToast:r}=hr(),[i,a]=S.useState(t.printer_id),o=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&&!o?"scheduled":"asap"),[u,d]=S.useState(()=>t.scheduled_time&&!o?new Date(t.scheduled_time).toISOString().slice(0,16):""),[f,g]=S.useState(t.require_previous_success),[p,x]=S.useState(t.auto_off_after),{data:y}=ft({queryKey:["printers"],queryFn:()=>ye.getPrinters()});S.useEffect(()=>{const w=N=>{N.key==="Escape"&&e()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[e]);const b=bt({mutationFn:w=>ye.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")}}),v=w=>{w.preventDefault();const N={printer_id:i,require_previous_success:f,auto_off_after:p,manual_start:l==="manual"};l==="scheduled"&&u?N.scheduled_time=new Date(u).toISOString():N.scheduled_time=null,b.mutate(N)},E=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsx(Mt,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:s.jsxs(At,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qo,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Queue Item"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:v,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),s.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),y?.length===0?s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(Aa,{className:"w-4 h-4"}),"No printers configured"]}):s.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:y?.map(w=>s.jsx("option",{value:w.id,children:w.name},w.id))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),s.jsxs("div",{className:"flex gap-2",children:[s.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:[s.jsx(dr,{className:"w-4 h-4"}),"ASAP"]}),s.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:[s.jsx(Wr,{className:"w-4 h-4"}),"Scheduled"]}),s.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:[s.jsx(vR,{className:"w-4 h-4"}),"Queue Only"]})]})]}),l==="scheduled"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),s.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})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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"}),s.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:p,onChange:w=>x(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[s.jsx(Ol,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),s.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."}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Ne,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsx(Ne,{type:"submit",className:"flex-1",disabled:b.isPending||y?.length===0,children:b.isPending?"Saving...":"Save Changes"})]})]})]})})})}function pne(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 Q9e(t,e="system"){if(!t)return"ASAP";const n=ui(t);if(!n)return"ASAP";const r=new Date,i=n.getTime()-r.getTime();return i<-6e4?"Overdue":i<0?"Now":i<6e4?"In less than a minute":i<36e5?`In ${Math.round(i/6e4)} min`:i<864e5?`In ${Math.round(i/36e5)} hours`:Op(t,e)}function J9e({status:t}){const e={pending:{icon:dr,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:Gc,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:Sa,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:Bt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r}`,children:[s.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function Uk({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:o,onStart:l,timeFormat:c="system"}){const{attributes:u,listeners:d,setNodeRef:f,transform:g,transition:p,isDragging:x}=hne({id:t.id,disabled:t.status!=="pending"}),y={transform:sg.Transform.toString(g),transition:p},b=t.status==="printing",v=t.status==="pending",E=["completed","failed","skipped","cancelled"].includes(t.status);return s.jsx("div",{ref:f,style:y,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. ${x?"opacity-50 scale-[1.02] shadow-xl z-50":""}
  8277. ${b?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
  8278. `,children:s.jsxs("div",{className:"flex items-center gap-4 p-4",children:[v?s.jsx("div",{...u,...d,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:s.jsx(U0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?s.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]}):s.jsx("div",{className:"w-8"}),s.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?s.jsx("img",{src:ye.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s.jsx(Sd,{className:"w-6 h-6"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),s.jsx(Nc,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:s.jsx(qr,{className:"w-3.5 h-3.5"})})]}),s.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Ei,{className:"w-3.5 h-3.5"}),t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(id,{className:"w-3.5 h-3.5"}),pne(t.print_time_seconds)]}),v&&!t.manual_start&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(dr,{className:"w-3.5 h-3.5"}),Q9e(t.scheduled_time,c)]})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.manual_start&&s.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:[s.jsx(vR,{className:"w-3 h-3"}),"Staged"]}),t.require_previous_success&&s.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&&s.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:[s.jsx(Ol,{className:"w-3 h-3"}),"Auto power off"]})]}),b&&s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&s.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[s.jsx(Aa,{className:"w-3 h-3"}),t.error_message]})]}),s.jsx(J9e,{status:t.status}),s.jsxs("div",{className:"flex items-center gap-1",children:[b&&s.jsx(Ne,{variant:"ghost",size:"sm",onClick:a,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Ole,{className:"w-4 h-4"})}),v&&s.jsxs(s.Fragment,{children:[t.manual_start&&s.jsx(Ne,{variant:"ghost",size:"sm",onClick:l,title:"Start Print",className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10",children:s.jsx(Gc,{className:"w-4 h-4"})}),s.jsx(Ne,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:s.jsx(qo,{className:"w-4 h-4"})}),s.jsx(Ne,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Bt,{className:"w-4 h-4"})})]}),E&&s.jsxs(s.Fragment,{children:[s.jsx(Ne,{variant:"ghost",size:"sm",onClick:o,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:s.jsx(Gr,{className:"w-4 h-4"})}),s.jsx(Ne,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:s.jsx(_n,{className:"w-4 h-4"})})]})]})]})})}function eWe(){const t=cn(),{showToast:e}=hr(),[n,r]=S.useState(null),[i,a]=S.useState(""),[o,l]=S.useState(!1),[c,u]=S.useState(null),[d,f]=S.useState(null),[g,p]=S.useState(null),[x,y]=S.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[b,v]=S.useState(()=>{const ee=localStorage.getItem("queue.historySortAsc");return ee!==null?ee==="true":!1}),[E,w]=S.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[N,A]=S.useState(()=>{const ee=localStorage.getItem("queue.pendingSortAsc");return ee!==null?ee==="true":!0});S.useEffect(()=>{localStorage.setItem("queue.historySortBy",x)},[x]),S.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(b))},[b]),S.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",E)},[E]),S.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(N))},[N]);const C=Vte(tM(L2,{activationConstraint:{distance:8}}),tM(O2,{coordinateGetter:fne})),{data:T}=ft({queryKey:["settings"],queryFn:ye.getSettings}),L=T?.time_format||"system",{data:k,isLoading:D}=ft({queryKey:["queue",n,i],queryFn:()=>ye.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:U}=ft({queryKey:["printers"],queryFn:()=>ye.getPrinters()}),O=bt({mutationFn:ee=>ye.cancelQueueItem(ee),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),q=bt({mutationFn:ee=>ye.removeFromQueue(ee),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),R=bt({mutationFn:ee=>ye.stopQueueItem(ee),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),G=bt({mutationFn:ee=>ye.startQueueItem(ee),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print released to queue")},onError:()=>e("Failed to start print","error")}),Y=bt({mutationFn:ee=>ye.reorderQueue(ee),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),V=bt({mutationFn:async()=>{const ee=k?.filter(ie=>["completed","failed","skipped","cancelled"].includes(ie.status))||[];for(const ie of ee)await ye.removeFromQueue(ie.id);return ee.length},onSuccess:ee=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${ee} history item${ee!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),K=S.useMemo(()=>{const ee=k?.filter(ae=>ae.status==="pending")||[],ie=ae=>{if(!ae.scheduled_time)return 0;const de=new Date(ae.scheduled_time).getTime(),ue=Date.now()+4320*60*60*1e3;return de>ue?0:de};return[...ee].sort((ae,de)=>{let ue;return E==="name"?ue=(ae.archive_name||"").localeCompare(de.archive_name||""):E==="printer"?ue=(ae.printer_name||"").localeCompare(de.printer_name||""):E==="time"?ue=ie(ae)-ie(de):ue=ae.position-de.position,N?ue:-ue})},[k,E,N]),J=k?.filter(ee=>ee.status==="printing")||[],X=S.useMemo(()=>[...k?.filter(ie=>["completed","failed","skipped","cancelled"].includes(ie.status))||[]].sort((ie,ae)=>{let de;return x==="name"?de=(ie.archive_name||"").localeCompare(ae.archive_name||""):x==="printer"?de=(ie.printer_name||"").localeCompare(ae.printer_name||""):de=new Date(ae.completed_at||ae.created_at).getTime()-new Date(ie.completed_at||ie.created_at).getTime(),b?-de:de}),[k,x,b]),F=S.useMemo(()=>K.reduce((ee,ie)=>ee+(ie.print_time_seconds||0),0),[K]),W=ee=>{const{active:ie,over:ae}=ee;if(!ae||ie.id===ae.id)return;const de=K.findIndex(le=>le.id===ie.id),ue=K.findIndex(le=>le.id===ae.id);if(de!==-1&&ue!==-1){const he=U2(K,de,ue).map((pe,Me)=>({id:pe.id,position:Me+1}));Y.mutate(he)}};return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsx("div",{className:"flex items-center justify-between mb-8",children:s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx(nW,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),s.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[s.jsx(Mt,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:s.jsx(At,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:s.jsx(Gc,{className:"w-5 h-5 text-blue-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:J.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),s.jsx(Mt,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:s.jsx(At,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:s.jsx(dr,{className:"w-5 h-5 text-yellow-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:K.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),s.jsx(Mt,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:s.jsx(At,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:s.jsx(id,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:pne(F)}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),s.jsx(Mt,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:s.jsx(At,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:s.jsx(Ar,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:X.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.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:ee=>r(ee.target.value?Number(ee.target.value):null),children:[s.jsx("option",{value:"",children:"All Printers"}),U?.map(ee=>s.jsx("option",{value:ee.id,children:ee.name},ee.id))]}),s.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:ee=>a(ee.target.value),children:[s.jsx("option",{value:"",children:"All Status"}),s.jsx("option",{value:"pending",children:"Pending"}),s.jsx("option",{value:"printing",children:"Printing"}),s.jsx("option",{value:"completed",children:"Completed"}),s.jsx("option",{value:"failed",children:"Failed"}),s.jsx("option",{value:"skipped",children:"Skipped"}),s.jsx("option",{value:"cancelled",children:"Cancelled"})]}),s.jsx("div",{className:"flex-1"}),X.length>0&&s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:[s.jsx(_n,{className:"w-4 h-4"}),"Clear History"]})]}),D?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):k?.length===0?s.jsxs(Mt,{className:"p-12 text-center border-dashed",children:[s.jsx(Wr,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),s.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),s.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.'})]}):s.jsxs("div",{className:"space-y-8",children:[J.length>0&&s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),s.jsx("div",{className:"space-y-3",children:J.map(ee=>s.jsx(Uk,{item:ee,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>p({type:"stop",item:ee}),onRequeue:()=>{},onStart:()=>{},timeFormat:L},ee.id))})]}),K.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(dr,{className:"w-5 h-5 text-yellow-400"}),"Queued",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",K.length," item",K.length!==1?"s":"",")"]}),s.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)"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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:ee=>w(ee.target.value),children:[s.jsx("option",{value:"position",children:"Sort by Position"}),s.jsx("option",{value:"name",children:"Sort by Name"}),s.jsx("option",{value:"printer",children:"Sort by Printer"}),s.jsx("option",{value:"time",children:"Sort by Schedule"})]}),s.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>A(!N),title:N?"Ascending":"Descending",className:"px-2",children:N?s.jsx(Cp,{className:"w-4 h-4"}):s.jsx(F0,{className:"w-4 h-4"})})]})]}),s.jsx(one,{sensors:C,collisionDetection:Kte,onDragEnd:W,children:s.jsx(une,{items:K.map(ee=>ee.id),strategy:z9e,children:s.jsx("div",{className:"space-y-3",children:K.map((ee,ie)=>s.jsx(Uk,{item:ee,position:ie+1,onEdit:()=>u(ee),onCancel:()=>p({type:"cancel",item:ee}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>G.mutate(ee.id),timeFormat:L},ee.id))})})})]}),X.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ar,{className:"w-5 h-5 text-bambu-gray"}),"History",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",X.length," item",X.length!==1?"s":"",")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:x,onChange:ee=>y(ee.target.value),children:[s.jsx("option",{value:"date",children:"Sort by Date"}),s.jsx("option",{value:"name",children:"Sort by Name"}),s.jsx("option",{value:"printer",children:"Sort by Printer"})]}),s.jsx(Ne,{variant:"ghost",size:"sm",onClick:()=>v(!b),title:b?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:b?s.jsx(Cp,{className:"w-4 h-4"}):s.jsx(F0,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"space-y-3",children:X.slice(0,20).map((ee,ie)=>s.jsx(Uk,{item:ee,position:ie+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>p({type:"remove",item:ee}),onStop:()=>{},onRequeue:()=>f(ee),onStart:()=>{},timeFormat:L},ee.id))})]})]}),c&&s.jsx(Z9e,{item:c,onClose:()=>u(null)}),d&&s.jsx(G4,{archiveId:d.archive_id,archiveName:d.archive_name||`Archive #${d.archive_id}`,onClose:()=>f(null)}),g&&s.jsx(Qn,{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"?O.mutate(g.item.id):g.type==="stop"?R.mutate(g.item.id):q.mutate(g.item.id),p(null)},onCancel:()=>p(null)}),o&&s.jsx(Qn,{title:"Clear History",message:`Are you sure you want to remove all ${X.length} item${X.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{V.mutate(),l(!1)},onCancel:()=>l(!1)})]})}function tWe({printDates:t,months:e=3}){const n=S.useRef(null),[r,i]=S.useState(0);S.useEffect(()=>{const E=n.current;if(!E)return;const w=new ResizeObserver(N=>{const A=N[0]?.contentRect.width||0;i(A)});return w.observe(E),()=>w.disconnect()},[]);const{weeks:a,monthLabels:o,printCounts:l}=S.useMemo(()=>{const E={};t.forEach(U=>{const O=U.split("T")[0];E[O]=(E[O]||0)+1});const w=new Date,N=new Date(w);N.setMonth(N.getMonth()-e),N.setDate(N.getDate()-N.getDay());const A=[],C=[];let T=[],L=-1;const k=new Date(N);let D=0;for(;k<=w;)k.getDay()===0&&T.length>0&&(A.push(T),T=[],D++),k.getMonth()!==L&&(C.push({month:k.toLocaleDateString("en-US",{month:"short"}),weekIndex:D}),L=k.getMonth()),T.push(new Date(k)),k.setDate(k.getDate()+1);return T.length>0&&A.push(T),{weeks:A,monthLabels:C,printCounts:E}},[t,e]),c=Math.max(1,...Object.values(l)),u=E=>{if(E===0)return"bg-bambu-dark";const w=E/c;return w<=.25?"bg-bambu-green/30":w<=.5?"bg-bambu-green/50":w<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],f=a.length,g=32,p=2,x=r-g-16,y=f>0?Math.floor((x-(f-1)*p)/f):12,b=Math.max(8,Math.min(20,y)),v=b<=10?10:12;return s.jsx("div",{ref:n,className:"w-full flex justify-center",children:r>0&&s.jsxs("div",{children:[s.jsx("div",{className:"flex mb-1",style:{marginLeft:g+4},children:o.map(({month:E,weekIndex:w},N)=>s.jsx("div",{className:"text-bambu-gray",style:{fontSize:v,marginLeft:N===0?0:`${(w-(o[N-1]?.weekIndex||0))*(b+p)-24}px`},children:E},N))}),s.jsxs("div",{className:"flex",style:{gap:p},children:[s.jsx("div",{className:"flex flex-col",style:{gap:p,marginRight:4,width:g},children:d.map((E,w)=>s.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:g,height:b,fontSize:v,visibility:w%2===1?"visible":"hidden"},children:E},E))}),a.map((E,w)=>s.jsx("div",{className:"flex flex-col",style:{gap:p},children:[0,1,2,3,4,5,6].map(N=>{const A=E.find(k=>k.getDay()===N);if(!A)return s.jsx("div",{style:{width:b,height:b}},N);const C=A.toISOString().split("T")[0],T=l[C]||0,L=C===new Date().toISOString().split("T")[0];return s.jsx("div",{className:`rounded-sm ${u(T)} ${L?"ring-1 ring-white":""}`,style:{width:b,height:b},title:`${A.toLocaleDateString()}: ${T} print${T!==1?"s":""}`},N)})},w))]}),s.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:v},children:[s.jsx("span",{children:"Less"}),s.jsxs("div",{className:"flex",style:{gap:p},children:[s.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:b,height:b}})]}),s.jsx("span",{children:"More"})]})]})})}const d1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function nWe(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 rWe({archives:t,currency:e="$"}){const[n,r]=S.useState("30d"),i=S.useMemo(()=>{const g=nWe(n);return t.filter(p=>(ui(p.completed_at||p.created_at)||new Date(0))>=g)},[t,n]),a=S.useMemo(()=>{const g=new Map;return i.forEach(p=>{const x=ui(p.completed_at||p.created_at)||new Date,y=`${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,"0")}-${String(x.getDate()).padStart(2,"0")}`,b=g.get(y)||{date:y,filament:0,cost:0,prints:0};b.filament+=p.filament_used_grams||0,b.cost+=p.cost||0,b.prints+=1,g.set(y,b)}),Array.from(g.values()).sort((p,x)=>p.date.localeCompare(x.date)).map(p=>({...p,dateLabel:new Date(p.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=S.useMemo(()=>{if(n==="7d"||n==="30d")return a;const g=new Map;return i.forEach(p=>{const x=ui(p.completed_at||p.created_at)||new Date,y=new Date(x);y.setDate(x.getDate()-x.getDay());const b=`${y.getFullYear()}-${String(y.getMonth()+1).padStart(2,"0")}-${String(y.getDate()).padStart(2,"0")}`,v=g.get(b)||{week:b,filament:0,cost:0,prints:0};v.filament+=p.filament_used_grams||0,v.cost+=p.cost||0,v.prints+=1,g.set(b,v)}),Array.from(g.values()).sort((p,x)=>p.week.localeCompare(x.week)).map(p=>({date:p.week,dateLabel:`Week of ${new Date(p.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...p}))},[i,a,n]),l=S.useMemo(()=>{const g=new Map;return i.forEach(p=>{const y=(p.filament_type||"Unknown").split(", ");y.forEach(b=>{const v=(p.filament_used_grams||0)/y.length;g.set(b,(g.get(b)||0)+v)})}),Array.from(g.entries()).map(([p,x])=>({name:p,value:Math.round(x)})).sort((p,x)=>x.value-p.value)},[i]),c=S.useMemo(()=>{const g=new Date,p=[];for(let x=5;x>=0;x--){const y=new Date(g.getFullYear(),g.getMonth()-x,1),b=new Date(g.getFullYear(),g.getMonth()-x+1,0),v=y.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),E=t.filter(w=>{const N=ui(w.completed_at||w.created_at)||new Date(0);return N>=y&&N<=b});p.push({month:v,filament:Math.round(E.reduce((w,N)=>w+(N.filament_used_grams||0),0)),cost:E.reduce((w,N)=>w+(N.cost||0),0),prints:E.length})}return p},[t]),u=n==="7d"||n==="30d"?a:o,d=i.reduce((g,p)=>g+(p.filament_used_grams||0),0),f=i.reduce((g,p)=>g+(p.cost||0),0);return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),s.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>s.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))})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),s.jsx(S1,{width:"100%",height:250,children:s.jsxs(bCe,{data:u,children:[s.jsx("defs",{children:s.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),s.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),s.jsx(Gw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(qw,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),s.jsx(Kw,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),s.jsx(E1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),s.jsx(pZ,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):s.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(S1,{width:160,height:160,children:s.jsxs(gCe,{children:[s.jsx(UY,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((g,p)=>s.jsx(sy,{fill:d1[p%d1.length]},`cell-${p}`))}),s.jsx(E1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),s.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((g,p)=>{const x=l.reduce((b,v)=>b+v.value,0),y=x>0?(g.value/x*100).toFixed(0):0;return s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:d1[p%d1.length]}}),s.jsx("span",{className:"text-white truncate flex-1",children:g.name}),s.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[y,"%"]})]},g.name)})})]}):s.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),s.jsx(S1,{width:"100%",height:200,children:s.jsxs(iCe,{data:c,children:[s.jsx(Gw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(qw,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),s.jsx(Kw,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),s.jsx(E1,{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"]}),s.jsx(tD,{}),s.jsx(GY,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function iWe({id:t,title:e,component:n,isHidden:r,size:i,onToggleVisibility:a,onToggleSize:o}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:g}=hne({id:t}),p={transform:sg.Transform.toString(d),transition:f,opacity:g?.5:1};return r?null:s.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:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.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:s.jsx(U0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),s.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:o,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?s.jsx(Sue,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):s.jsx(pue,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),s.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:s.jsx(lM,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),s.jsx("div",{className:"p-4",children:typeof n=="function"?n(i):n})]})}function aWe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const o=()=>{const N={};return t.forEach(A=>{N[A.id]=A.defaultSize||4}),N},[l,c]=S.useState(()=>{const N=localStorage.getItem(e);if(N)try{const A=JSON.parse(N);return A.sizes||(A.sizes=o()),A}catch{}return{order:t.map(A=>A.id),hidden:t.filter(A=>A.defaultVisible===!1).map(A=>A.id),sizes:o()}}),[u,d]=S.useState(!1);S.useEffect(()=>{const N=()=>d(A=>!A);return window.addEventListener("toggle-hidden-panel",N),()=>window.removeEventListener("toggle-hidden-panel",N)},[]),S.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),S.useEffect(()=>{const A=t.map(C=>C.id).filter(C=>!l.order.includes(C));A.length>0&&c(C=>({...C,order:[...C.order,...A]}))},[t,l.order]);const f=Vte(tM(L2,{activationConstraint:{distance:8}}),tM(O2,{coordinateGetter:fne})),g=N=>{const{active:A,over:C}=N;C&&A.id!==C.id&&c(T=>{const L=T.order.indexOf(A.id),k=T.order.indexOf(C.id);return{...T,order:U2(T.order,L,k)}})},p=N=>{c(A=>({...A,hidden:A.hidden.includes(N)?A.hidden.filter(C=>C!==N):[...A.hidden,N]}))},x=N=>{c(A=>{const C=A.sizes[N]||4,T=C===1?2:C===2?4:1;return{...A,sizes:{...A.sizes,[N]:T}}})},y=()=>{const N={order:t.map(A=>A.id),hidden:t.filter(A=>A.defaultVisible===!1).map(A=>A.id),sizes:o()};c(N),i?.()},b=l.order.map(N=>t.find(A=>A.id===N)).filter(Boolean),v=b.filter(N=>!l.hidden.includes(N.id)),E=b.filter(N=>l.hidden.includes(N.id)),w=a?.({hiddenCount:E.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:y});return s.jsxs("div",{className:"space-y-4",children:[w,!r&&!a&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:y,children:[s.jsx(hg,{className:"w-4 h-4"}),"Reset Layout"]}),E.length>0&&s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[s.jsx(af,{className:"w-4 h-4"}),E.length," Hidden"]})]}),u&&E.length>0&&s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:E.map(N=>s.jsxs("button",{onClick:()=>p(N.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:[s.jsx(af,{className:"w-3 h-3"}),N.title]},N.id))})]}),s.jsx(one,{sensors:f,collisionDetection:Kte,onDragEnd:g,children:s.jsx(une,{items:v.map(N=>N.id),strategy:Q4,children:s.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(N=>s.jsx(iWe,{id:N.id,title:N.title,component:N.component,isHidden:l.hidden.includes(N.id),size:l.sizes[N.id]||2,onToggleVisibility:()=>p(N.id),onToggleSize:()=>x(N.id)},N.id))})})}),v.length===0&&s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx("p",{children:"All widgets are hidden."}),s.jsx(Ne,{className:"mt-4",onClick:y,children:"Reset Layout"})]})]})}function sWe({stats:t,currency:e}){return s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:s.jsx(Vc,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),s.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:s.jsx(dr,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:s.jsx(Vc,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:s.jsx(s3,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:s.jsx(cf,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:s.jsx(s3,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function oWe({stats:t,printerMap:e,size:n=1}){const r=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0,i=n===1?112:n===2?128:144,a=i/2-8,o=a*2*Math.PI;return s.jsxs("div",{className:"flex items-center gap-6",children:[s.jsxs("div",{className:"relative flex-shrink-0",style:{width:i,height:i},children:[s.jsxs("svg",{className:"w-full h-full -rotate-90",children:[s.jsx("circle",{cx:i/2,cy:i/2,r:a,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),s.jsx("circle",{cx:i/2,cy:i/2,r:a,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${r/100*o} ${o}`})]}),s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[r,"%"]})})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ar,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),s.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Sa,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),s.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]}),n>=2&&t?.prints_by_printer&&Object.keys(t.prints_by_printer).length>0&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:"Prints by Printer"}),s.jsx("div",{className:`grid gap-x-6 gap-y-1 ${n===4?"grid-cols-3":"grid-cols-2"}`,style:{width:"fit-content"},children:Object.entries(t.prints_by_printer).map(([l,c])=>s.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[s.jsx("span",{className:"text-bambu-gray truncate max-w-[120px]",children:e.get(l)||`Printer ${l}`}),s.jsx("span",{className:"text-white font-medium",children:c})]},l))})]})]})]})}function lWe({stats:t,printerMap:e,size:n=1}){const r=t?.average_time_accuracy;if(r==null)return s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const a=(Math.min(150,Math.max(50,r))-50)/100*100,l=(x=>x>=95&&x<=105?"#00ae42":x>105?"#3b82f6":"#f97316")(r),c=r-100,u=n===1?112:n===2?128:144,d=u/2-8,f=d*2*Math.PI,g=n===1?3:n===2?6:999,p=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,g):[];return s.jsxs("div",{className:"flex items-center gap-6",children:[s.jsxs("div",{className:"relative flex-shrink-0",style:{width:u,height:u},children:[s.jsxs("svg",{className:"w-full h-full -rotate-90",children:[s.jsx("circle",{cx:u/2,cy:u/2,r:d,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),s.jsx("circle",{cx:u/2,cy:u/2,r:d,fill:"none",stroke:l,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${a/100*f} ${f}`})]}),s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[s.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[r.toFixed(0),"%"]}),s.jsxs("span",{className:`text-xs ${c>=0?"text-blue-400":"text-orange-400"}`,children:[c>=0?"+":"",c.toFixed(0),"%"]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[s.jsx(oW,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{children:"100% = perfect estimate"})]}),p.length>0&&s.jsx("div",{className:`mt-2 ${n===4?"grid grid-cols-3 gap-x-6 gap-y-1":n===2?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,style:{width:"fit-content"},children:p.map(([x,y])=>s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(x)||`Printer ${x}`}),s.jsxs("span",{className:`font-medium ${y>=95&&y<=105?"text-bambu-green":y>105?"text-blue-400":"text-orange-400"}`,children:[y.toFixed(0),"%"]})]},x))})]})]})}function cWe({stats:t,size:e=1}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No filament data available"});const n=Object.entries(t.prints_by_filament_type).sort(([,o],[,l])=>l-o),r=e===1?5:e===2?8:999,i=n.slice(0,r),a=n.length>r;return e===4&&i.length>4?s.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:i.map(([o,l])=>{const c=Math.round(l/(t.total_prints||1)*100);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-white truncate max-w-[120px]",children:o}),s.jsx("span",{className:"text-bambu-gray",children:l})]}),s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:s.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${c}%`}})})]},o)})}):s.jsxs("div",{className:"space-y-3",children:[i.map(([o,l])=>{const c=Math.round(l/(t.total_prints||1)*100);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-white",children:o}),s.jsxs("span",{className:"text-bambu-gray",children:[l," prints"]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:s.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${c}%`}})})]},o)}),a&&s.jsxs("p",{className:"text-xs text-bambu-gray text-center pt-1",children:["+",n.length-r," more types"]})]})}function uWe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return s.jsx(tWe,{printDates:t,months:n})}function dWe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:s.jsx(Ei,{className:"w-4 h-4 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function hWe({archives:t,currency:e}){return!t||t.length===0?s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):s.jsx(rWe,{archives:t,currency:e})}function fWe({size:t=1}){const{data:e,isLoading:n}=ft({queryKey:["failureAnalysis"],queryFn:()=>ye.getFailureAnalysis({days:30})});if(n)return s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!e||e.total_prints===0)return s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data in the last 30 days"});const r=t===1?5:t===2?8:999,i=Object.entries(e.failures_by_reason).sort(([,l],[,c])=>c-l),a=i.slice(0,r),o=i.length>r;return s.jsxs("div",{className:`${t>=2?"flex gap-8":"space-y-4"}`,children:[s.jsxs("div",{className:t>=2?"flex-shrink-0":"",children:[s.jsx("div",{className:"flex items-center gap-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(zn,{className:`w-5 h-5 ${e.failure_rate>20?"text-red-400":e.failure_rate>10?"text-yellow-400":"text-bambu-green"}`}),s.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[e.failure_rate.toFixed(1),"%"]})]})}),s.jsxs("div",{className:"text-sm text-bambu-gray mt-1",children:[e.failed_prints," / ",e.total_prints," prints failed"]}),e.trend&&e.trend.length>=2&&s.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(cW,{className:`w-4 h-4 ${e.trend[e.trend.length-1].failure_rate<e.trend[e.trend.length-2].failure_rate?"text-bambu-green":"text-red-400"}`}),s.jsxs("span",{className:"text-bambu-gray",children:["Last week: ",e.trend[e.trend.length-1].failure_rate.toFixed(1),"%"]})]})})]}),a.length>0&&s.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[s.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?"Failure Reasons":"Top Failure Reasons"}),s.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:a.map(([l,c])=>s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:l||"Unknown"}),s.jsx("span",{className:"text-bambu-gray ml-2",children:c})]},l))}),o&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["+",i.length-r," more reasons"]})]})]})}function mWe(){const{showToast:t}=hr(),[e,n]=S.useState(!1),[r,i]=S.useState(!1),[a,o]=S.useState(0),[l,c]=S.useState(0);S.useEffect(()=>{const w=()=>{try{const A=localStorage.getItem("bambusy-dashboard-layout");if(A){const C=JSON.parse(A);c(C.hidden?.length||0)}}catch{c(0)}};w(),window.addEventListener("storage",w);const N=setInterval(w,500);return()=>{window.removeEventListener("storage",w),clearInterval(N)}},[a]);const{data:u,isLoading:d}=ft({queryKey:["archiveStats"],queryFn:ye.getArchiveStats}),{data:f}=ft({queryKey:["printers"],queryFn:ye.getPrinters}),{data:g}=ft({queryKey:["archives"],queryFn:()=>ye.getArchives(void 0,void 0,1e3,0)}),{data:p}=ft({queryKey:["settings"],queryFn:ye.getSettings}),x=async w=>{i(!1),n(!0);try{const{blob:N,filename:A}=await ye.exportStats({format:w,days:90}),C=URL.createObjectURL(N),T=document.createElement("a");T.href=C,T.download=A,T.click(),URL.revokeObjectURL(C),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},y=p?.currency||"$",b=new Map(f?.map(w=>[String(w.id),w.name])||[]),v=g?.map(w=>w.created_at)||[];if(d)return s.jsx("div",{className:"p-4 md:p-8",children:s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const E=[{id:"quick-stats",title:"Quick Stats",component:s.jsx(sWe,{stats:u,currency:y}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:w=>s.jsx(oWe,{stats:u,printerMap:b,size:w}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:w=>s.jsx(lWe,{stats:u,printerMap:b,size:w}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:w=>s.jsx(cWe,{stats:u,size:w}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:w=>s.jsx(fWe,{size:w}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:w=>s.jsx(uWe,{printDates:v,size:w}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:s.jsx(dWe,{stats:u,printerMap:b}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:s.jsx(hWe,{archives:g||[],currency:y}),defaultSize:4}];return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),s.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[l>0&&s.jsxs(Ne,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[s.jsx(af,{className:"w-4 h-4"}),l," Hidden"]}),s.jsxs(Ne,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),o(w=>w+1),t("Layout reset")},children:[s.jsx(hg,{className:"w-4 h-4"}),"Reset Layout"]}),s.jsxs("div",{className:"relative",children:[s.jsxs(Ne,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(X1,{className:"w-4 h-4"}),"Export Stats"]}),r&&s.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:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>x("csv"),children:[s.jsx(is,{className:"w-4 h-4"}),"Export as CSV"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>x("xlsx"),children:[s.jsx(X1,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),s.jsx(aWe,{widgets:E,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function pWe({plug:t,onEdit:e}){const n=cn(),[r,i]=S.useState(!1),[a,o]=S.useState(!1),[l,c]=S.useState(!1),[u,d]=S.useState(!1),{data:f,isLoading:g,refetch:p}=ft({queryKey:["smart-plug-status",t.id],queryFn:()=>ye.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=ft({queryKey:["printers"],queryFn:ye.getPrinters}),y=x?.find(T=>T.id===t.printer_id),b=bt({mutationFn:T=>ye.controlSmartPlug(t.id,T),onSuccess:()=>{p()}}),v=bt({mutationFn:T=>ye.updateSmartPlug(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),E=bt({mutationFn:()=>ye.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=f?.state==="ON",N=f?.reachable??!1,A=b.isPending,C=()=>{const T=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${T}/`:`http://${T}/`};return s.jsxs(s.Fragment,{children:[s.jsx(Mt,{className:"relative",children:s.jsxs(At,{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${N?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:s.jsx(mo,{className:`w-5 h-5 ${N?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-medium text-white",children:t.name}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1",children:[g?s.jsx(xt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):N?s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(TR,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):s.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[s.jsx(Db,{className:"w-4 h-4"}),s.jsx("span",{children:"Offline"})]}),s.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:[s.jsx(qr,{className:"w-3 h-3"}),"Admin"]})]})]}),y&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),s.jsx("span",{className:"text-sm text-white",children:y.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&s.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:[s.jsx(zh,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&s.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:[s.jsx(Wr,{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}`]})]}),s.jsxs("div",{className:"flex gap-2 mb-3",children:[s.jsxs(Ne,{size:"sm",variant:w?"primary":"secondary",disabled:!N||A,onClick:()=>o(!0),className:"flex-1",children:[A?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(Ol,{className:"w-4 h-4"}),"On"]}),s.jsxs(Ne,{size:"sm",variant:w?"secondary":"primary",disabled:!N||A,onClick:()=>c(!0),className:"flex-1",children:[A?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(uM,{className:"w-4 h-4"}),"Off"]})]}),s.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:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(dM,{className:"w-4 h-4"}),"Automation Settings"]}),s.jsx("span",{children:u?"-":"+"})]}),u&&s.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(wR,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:T=>v.mutate({show_in_switchbar:T.target.checked}),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Enabled"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.enabled,onChange:T=>v.mutate({enabled:T.target.checked}),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto On"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:T=>v.mutate({auto_on:T.target.checked}),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:T=>v.mutate({auto_off:T.target.checked}),className:"sr-only peer"}),s.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&&s.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>v.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:[s.jsx(dr,{className:"w-4 h-4"}),"Time"]}),s.jsxs("button",{onClick:()=>v.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:[s.jsx(fM,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),s.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:T=>v.mutate({off_delay_minutes:parseInt(T.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"})]}):s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),s.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:T=>v.mutate({off_temp_threshold:parseInt(T.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(AR,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Ne,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(_n,{className:"w-4 h-4"})})]})]})]})}),r&&s.jsx(Qn,{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&&s.jsx(Qn,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{b.mutate("on"),o(!1)},onCancel:()=>o(!1)}),l&&s.jsx(Qn,{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:()=>{b.mutate("off"),c(!1)},onCancel:()=>c(!1)})]})}function gWe({plug:t,onClose:e}){const n=cn(),r=!!t,[i,a]=S.useState(t?.name||""),[o,l]=S.useState(t?.ip_address||""),[c,u]=S.useState(t?.username||""),[d,f]=S.useState(t?.password||""),[g,p]=S.useState(t?.printer_id||null),[x,y]=S.useState(null),[b,v]=S.useState(null),[E,w]=S.useState(t?.power_alert_enabled||!1),[N,A]=S.useState(t?.power_alert_high?.toString()||""),[C,T]=S.useState(t?.power_alert_low?.toString()||""),[L,k]=S.useState(t?.schedule_enabled||!1),[D,U]=S.useState(t?.schedule_on_time||""),[O,q]=S.useState(t?.schedule_off_time||""),[R,G]=S.useState(t?.show_in_switchbar||!1),[Y,V]=S.useState(!1),[K,J]=S.useState({scanned:0,total:0}),[X,F]=S.useState([]),W=S.useRef(null),{data:ee}=ft({queryKey:["printers"],queryFn:ye.getPrinters}),{data:ie}=ft({queryKey:["smart-plugs"],queryFn:ye.getSmartPlugs});S.useEffect(()=>{const z=H=>{H.key==="Escape"&&e()};return window.addEventListener("keydown",z),()=>{window.removeEventListener("keydown",z),W.current&&clearInterval(W.current)}},[e]);const ae=async()=>{V(!0),F([]),J({scanned:0,total:0}),v(null);try{await ye.startTasmotaScan();const z=async()=>{try{const H=await ye.getTasmotaScanStatus();J({scanned:H.scanned,total:H.total});const se=await ye.getDiscoveredTasmotaDevices();F(se),H.running||(V(!1),W.current&&(clearInterval(W.current),W.current=null))}catch(H){console.error("Polling error:",H)}};await z(),W.current=setInterval(z,500)}catch(z){V(!1);const H=z instanceof Error?z.message:typeof z=="string"?z:JSON.stringify(z);v(H||"Failed to start scan")}},de=async()=>{try{await ye.stopTasmotaScan()}catch{}V(!1),W.current&&(clearInterval(W.current),W.current=null)},ue=z=>{l(z.ip_address),a(z.name),y(null)},le=bt({mutationFn:()=>ye.testSmartPlugConnection(o,c||null,d||null),onSuccess:z=>{y(z),v(null),!i&&z.device_name&&a(z.device_name)},onError:z=>{y(null),v(z.message)}}),he=bt({mutationFn:z=>ye.createSmartPlug(z),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:z=>{v(z.message)}}),pe=bt({mutationFn:z=>ye.updateSmartPlug(t.id,z),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:z=>{v(z.message)}}),Me=ee?.filter(z=>!ie?.some(se=>se.printer_id===z.id&&se.id!==t?.id)),re=z=>{if(z.preventDefault(),v(null),!i.trim()){v("Name is required");return}if(!o.trim()){v("IP address is required");return}const H={name:i.trim(),ip_address:o.trim(),username:c.trim()||null,password:d.trim()||null,printer_id:g,power_alert_enabled:E,power_alert_high:N?parseFloat(N):null,power_alert_low:C?parseFloat(C):null,schedule_enabled:L,schedule_on_time:D||null,schedule_off_time:O||null,show_in_switchbar:R};r?pe.mutate(H):he.mutate(H)},We=he.isPending||pe.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.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:z=>z.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:re,className:"p-6 space-y-4 overflow-y-auto",children:[b&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:b}),!r&&s.jsxs("div",{className:"space-y-3",children:[Y?s.jsxs(Ne,{type:"button",variant:"secondary",onClick:de,className:"w-full",children:[s.jsx(Bt,{className:"w-4 h-4"}),"Stop Scanning"]}):s.jsxs(Ne,{type:"button",variant:"primary",onClick:ae,className:"w-full",children:[s.jsx(Ml,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),Y&&K.total>0&&s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[s.jsx("span",{children:"Scanning network..."}),s.jsxs("span",{children:[K.scanned," / ",K.total]})]}),s.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${K.scanned/K.total*100}%`}})})]}),X.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",X.length," device(s) - click to select:"]}),s.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:X.map(z=>s.jsxs("button",{type:"button",onClick:()=>ue(z),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:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mo,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:z.name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:z.ip_address})]})]}),z.state&&s.jsxs("span",{className:`flex items-center gap-1 text-xs ${z.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[s.jsx(Ol,{className:"w-3 h-3"}),z.state]})]},z.ip_address))})]}),!Y&&X.length===0&&K.total>0&&s.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:o,onChange:z=>{l(z.target.value),y(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"}),s.jsxs(Ne,{type:"button",variant:"secondary",onClick:()=>le.mutate(),disabled:!o.trim()||le.isPending,children:[le.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(TR,{className:"w-4 h-4"}),"Test"]})]})]}),x&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${x.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:x.success?s.jsxs(s.Fragment,{children:[s.jsx(Ar,{className:"w-5 h-5"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Connected!"}),s.jsxs("p",{className:"text-sm opacity-80",children:[x.device_name&&`Device: ${x.device_name} - `,"State: ",x.state]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Db,{className:"w-5 h-5"}),s.jsx("span",{children:"Connection failed"})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:i,onChange:z=>a(z.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"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),s.jsx("input",{type:"text",value:c,onChange:z=>u(z.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),s.jsx("input",{type:"password",value:d,onChange:z=>f(z.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"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),s.jsxs("select",{value:g??"",onChange:z=>p(z.target.value?Number(z.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:[s.jsx("option",{value:"",children:"No printer (manual control only)"}),Me?.map(z=>s.jsx("option",{value:z.id,children:z.name},z.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(zh,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E,onChange:z=>w(z.target.checked),className:"sr-only peer"}),s.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&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),s.jsx("input",{type:"number",value:N,onChange:z=>A(z.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),s.jsx("input",{type:"number",value:C,onChange:z=>T(z.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"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(dr,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:L,onChange:z=>k(z.target.checked),className:"sr-only peer"}),s.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"})]})]}),L&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),s.jsx("input",{type:"time",value:D,onChange:z=>U(z.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),s.jsx("input",{type:"time",value:O,onChange:z=>q(z.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"})]})]}),s.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."})]})]}),s.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(wR,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white font-medium",children:"Show in Switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:R,onChange:z=>G(z.target.checked),className:"sr-only peer"}),s.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"})]})]})}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Ne,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Ne,{type:"submit",disabled:We,className:"flex-1",children:[We?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(ks,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function $n({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return s.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:s.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 xWe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function bWe({provider:t,onEdit:e}){const n=cn(),[r,i]=S.useState(!1),[a,o]=S.useState(!1),[l,c]=S.useState(null),{data:u}=ft({queryKey:["printers"],queryFn:ye.getPrinters}),d=u?.find(y=>y.id===t.printer_id),f=bt({mutationFn:y=>ye.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=bt({mutationFn:()=>ye.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=bt({mutationFn:()=>ye.testNotificationProvider(t.id),onSuccess:y=>{c(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{c({success:!1,message:y.message})}}),x=y=>y||"";return s.jsxs(s.Fragment,{children:[s.jsx(Mt,{className:"relative",children:s.jsxs(At,{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:s.jsx(zh,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-medium text-white",children:t.name}),s.jsx("p",{className:"text-sm text-bambu-gray",children:xWe[t.provider_type]||t.provider_type})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&s.jsxs("span",{className:"text-xs text-bambu-green hidden sm:inline",children:["Last: ",Dp(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(ui(t.last_error_at)?.getTime()||0)>(ui(t.last_success)?.getTime()||0))&&s.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"}),s.jsx($n,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]})]}),d&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),s.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&s.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),s.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&s.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&s.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&s.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&s.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&s.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&s.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&s.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&s.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&&s.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&&s.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&&s.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&&s.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&&s.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&&s.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[s.jsx(Z1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&s.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[s.jsx(Wr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),s.jsx("div",{className:"mb-3",children:s.jsxs(Ne,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(NR,{className:"w-4 h-4"}),"Send Test Notification"]})}),l&&s.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?s.jsx(Ar,{className:"w-4 h-4"}):s.jsx(Sa,{className:"w-4 h-4"}),s.jsx("span",{children:l.message})]}),s.jsxs("button",{onClick:()=>o(!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:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(dM,{className:"w-4 h-4"}),"Event Settings"]}),a?s.jsx(Tf,{className:"w-4 h-4"}):s.jsx(Ga,{className:"w-4 h-4"})]}),a&&s.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Enabled"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),s.jsx($n,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Started"}),s.jsx($n,{checked:t.on_print_start,onChange:y=>f.mutate({on_print_start:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),s.jsx($n,{checked:t.on_print_complete,onChange:y=>f.mutate({on_print_complete:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),s.jsx($n,{checked:t.on_print_failed,onChange:y=>f.mutate({on_print_failed:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),s.jsx($n,{checked:t.on_print_stopped,onChange:y=>f.mutate({on_print_stopped:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),s.jsx($n,{checked:t.on_print_progress,onChange:y=>f.mutate({on_print_progress:y})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),s.jsx($n,{checked:t.on_printer_offline,onChange:y=>f.mutate({on_printer_offline:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),s.jsx($n,{checked:t.on_printer_error,onChange:y=>f.mutate({on_printer_error:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),s.jsx($n,{checked:t.on_filament_low,onChange:y=>f.mutate({on_filament_low:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),s.jsx($n,{checked:t.on_maintenance_due??!1,onChange:y=>f.mutate({on_maintenance_due:y})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),s.jsx($n,{checked:t.on_ams_humidity_high??!1,onChange:y=>f.mutate({on_ams_humidity_high:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),s.jsx($n,{checked:t.on_ams_temperature_high??!1,onChange:y=>f.mutate({on_ams_temperature_high:y})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),s.jsx($n,{checked:t.on_ams_ht_humidity_high??!1,onChange:y=>f.mutate({on_ams_ht_humidity_high:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),s.jsx($n,{checked:t.on_ams_ht_temperature_high??!1,onChange:y=>f.mutate({on_ams_ht_temperature_high:y})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Z1,{className:"w-4 h-4 text-purple-400"}),s.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),s.jsx($n,{checked:t.quiet_hours_enabled,onChange:y=>f.mutate({quiet_hours_enabled:y})})]}),t.quiet_hours_enabled&&s.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(dr,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Wr,{className:"w-4 h-4 text-emerald-400"}),s.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),s.jsx($n,{checked:t.daily_digest_enabled,onChange:y=>f.mutate({daily_digest_enabled:y})})]}),t.daily_digest_enabled&&s.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(dr,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(AR,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Ne,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(_n,{className:"w-4 h-4"})})]})]})]})}),r&&s.jsx(Qn,{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 l9=[{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 yWe({provider:t,onClose:e}){const n=cn(),r=!!t,[i,a]=S.useState(t?.name||""),[o,l]=S.useState(t?.provider_type||"email"),[c,u]=S.useState(t?.printer_id||null),[d,f]=S.useState(t?.quiet_hours_enabled||!1),[g,p]=S.useState(t?.quiet_hours_start||"22:00"),[x,y]=S.useState(t?.quiet_hours_end||"07:00"),[b,v]=S.useState(t?.daily_digest_enabled||!1),[E,w]=S.useState(t?.daily_digest_time||"08:00"),[N,A]=S.useState(t?.on_print_start??!1),[C,T]=S.useState(t?.on_print_complete??!0),[L,k]=S.useState(t?.on_print_failed??!0),[D,U]=S.useState(t?.on_print_stopped??!0),[O,q]=S.useState(t?.on_print_progress??!1),[R,G]=S.useState(t?.on_printer_offline??!1),[Y,V]=S.useState(t?.on_printer_error??!1),[K,J]=S.useState(t?.on_filament_low??!1),[X,F]=S.useState(t?.on_maintenance_due??!1),[W,ee]=S.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([B,Q])=>[B,String(Q)])):{}),[ie,ae]=S.useState(null),[de,ue]=S.useState(null),{data:le}=ft({queryKey:["printers"],queryFn:ye.getPrinters});S.useEffect(()=>{const B=Q=>{Q.key==="Escape"&&e()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e]);const he=bt({mutationFn:()=>ye.testNotificationConfig({provider_type:o,config:W}),onSuccess:B=>{ae(B),ue(null)},onError:B=>{ae({success:!1,message:B.message})}}),pe=bt({mutationFn:B=>ye.createNotificationProvider(B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{ue(B.message)}}),Me=bt({mutationFn:B=>ye.updateNotificationProvider(t.id,B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{ue(B.message)}}),re=B=>{if(B.preventDefault(),ue(null),!i.trim()){ue("Name is required");return}const Q=H(o);for(const Ce of Q)if(!W[Ce.key]?.trim()){ue(`${Ce.label} is required`);return}const ce={name:i.trim(),provider_type:o,config:W,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?g:null,quiet_hours_end:d?x:null,daily_digest_enabled:b,daily_digest_time:b?E:null,on_print_start:N,on_print_complete:C,on_print_failed:L,on_print_stopped:D,on_print_progress:O,on_printer_offline:R,on_printer_error:Y,on_filament_low:K,on_maintenance_due:X};r?Me.mutate(ce):pe.mutate(ce)},We=pe.isPending||Me.isPending,z=B=>{switch(B){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=>z(B).filter(Q=>Q.required),se=z(o);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:s.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:B=>B.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:re,className:"p-6 space-y-4",children:[de&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:de}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:i,onChange:B=>a(B.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),s.jsx("select",{value:o,onChange:B=>{l(B.target.value),ee({}),ae(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:l9.map(B=>s.jsx("option",{value:B.value,children:B.label},B.value))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:l9.find(B=>B.value===o)?.description})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),se.map(B=>s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[B.label," ",B.required&&"*"]}),B.type==="select"&&B.options?s.jsx("select",{value:W[B.key]||B.options[0]?.value||"",onChange:Q=>{ee({...W,[B.key]:Q.target.value}),ae(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:B.options.map(Q=>s.jsx("option",{value:Q.value,children:Q.label},Q.value))}):s.jsx("input",{type:B.type,value:W[B.key]||"",onChange:Q=>{ee({...W,[B.key]:Q.target.value}),ae(null)},placeholder:B.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"})]},B.key))]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(Ne,{type:"button",variant:"secondary",onClick:()=>{ae(null),he.mutate()},disabled:he.isPending||!W[H(o)[0]?.key],className:"flex-1",children:[he.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(NR,{className:"w-4 h-4"}),"Test Configuration"]})}),ie&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ie.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:ie.success?s.jsxs(s.Fragment,{children:[s.jsx(Ar,{className:"w-5 h-5"}),s.jsx("span",{children:ie.message})]}):s.jsxs(s.Fragment,{children:[s.jsx(Sa,{className:"w-5 h-5"}),s.jsx("span",{children:ie.message})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),s.jsxs("select",{value:c??"",onChange:B=>u(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:[s.jsx("option",{value:"",children:"All printers"}),le?.map(B=>s.jsx("option",{value:B.id,children:B.name},B.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),s.jsx($n,{checked:d,onChange:f})]}),d&&s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),s.jsx("input",{type:"time",value:g,onChange:B=>p(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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),s.jsx("input",{type:"time",value:x,onChange:B=>y(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"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),s.jsx($n,{checked:b,onChange:v})]}),b&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),s.jsx("input",{type:"time",value:E,onChange:B=>w(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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Start"}),s.jsx($n,{checked:N,onChange:A})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Complete"}),s.jsx($n,{checked:C,onChange:T})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Failed"}),s.jsx($n,{checked:L,onChange:k})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Stopped"}),s.jsx($n,{checked:D,onChange:U})]}),s.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:"Progress"}),s.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),s.jsx($n,{checked:O,onChange:q})]})]})]}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Offline"}),s.jsx($n,{checked:R,onChange:G})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Error"}),s.jsx($n,{checked:Y,onChange:V})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),s.jsx($n,{checked:K,onChange:J})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),s.jsx($n,{checked:X,onChange:F})]})]})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Ne,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Ne,{type:"submit",disabled:We,className:"flex-1",children:[We?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(ks,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function vWe({template:t,onClose:e}){const n=cn(),r=S.useRef(null),[i,a]=S.useState(t.title_template),[o,l]=S.useState(t.body_template),[c,u]=S.useState(null),[d,f]=S.useState(!0),{data:g}=ft({queryKey:["template-variables"],queryFn:ye.getTemplateVariables}),p=g?.find(A=>A.event_type===t.event_type),{data:x,isLoading:y}=ft({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>ye.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});S.useEffect(()=>{const A=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[e]);const b=bt({mutationFn:A=>ye.updateNotificationTemplate(t.id,A),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:A=>{u(A.message)}}),v=bt({mutationFn:()=>ye.resetNotificationTemplate(t.id),onSuccess:A=>{a(A.title_template),l(A.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:A=>{u(A.message)}}),E=A=>{if(A.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!o.trim()){u("Body is required");return}b.mutate({title_template:i,body_template:o})},w=A=>{const C=r.current;if(!C)return;const T=C.selectionStart,L=C.selectionEnd,k=o,D=k.substring(0,T),U=k.substring(L),O=D+`{${A}}`+U;l(O),setTimeout(()=>{C.focus();const q=T+A.length+2;C.setSelectionRange(q,q)},0)},N=i!==t.title_template||o!==t.body_template;return s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Bt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("form",{onSubmit:E,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),s.jsx("input",{type:"text",value:i,onChange:A=>a(A.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..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),s.jsx("textarea",{ref:r,value:o,onChange:A=>l(A.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&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:p.variables.map(A=>s.jsxs("button",{type:"button",onClick:()=>w(A),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:[s.jsx(pr,{className:"w-3 h-3"}),A]},A))}),s.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(af,{className:"w-4 h-4"}),"Live Preview"]}),s.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&s.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:y?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[s.jsx(xt,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),s.jsx("div",{className:"text-white font-medium",children:x.title})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),s.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):s.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[s.jsxs(Ne,{type:"button",variant:"ghost",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-orange-400 hover:text-orange-300",children:[v.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(hg,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ne,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsxs(Ne,{onClick:E,disabled:b.isPending||!N,children:[b.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(ks,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const _We={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"},wWe={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 SWe({onClose:t}){const e=cn(),{showToast:n}=hr(),[r,i]=S.useState(7),[a,o]=S.useState(null),[l,c]=S.useState(!1),{data:u}=ft({queryKey:["settings"],queryFn:ye.getSettings}),d=u?.time_format||"system",{data:f,isLoading:g,refetch:p,isRefetching:x}=ft({queryKey:["notification-logs",r,l],queryFn:()=>ye.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:y}=ft({queryKey:["notification-log-stats",r],queryFn:()=>ye.getNotificationLogStats(r)}),b=bt({mutationFn:()=>ye.clearNotificationLogs(30),onSuccess:E=>{n(E.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:E=>{n(`Failed to clear logs: ${E.message}`,"error")}}),v=E=>{const w=ui(E);if(!w)return"";const A=new Date().getTime()-w.getTime();return A<6e4?"Just now":A<36e5?`${Math.floor(A/6e4)}m ago`:A<864e5?`${Math.floor(A/36e5)}h ago`:w.toLocaleDateString()+" "+mhe(w,d)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.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:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Y1,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),y&&s.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:s.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[s.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",s.jsx("span",{className:"text-white font-medium",children:y.total})," notifications"]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(Ar,{className:"w-4 h-4"}),y.success_count," sent"]}),y.failure_count>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Sa,{className:"w-4 h-4"}),y.failure_count," failed"]})]})}),s.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[s.jsxs("select",{value:r,onChange:E=>i(Number(E.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:[s.jsx("option",{value:1,children:"Last 24 hours"}),s.jsx("option",{value:7,children:"Last 7 days"}),s.jsx("option",{value:30,children:"Last 30 days"}),s.jsx("option",{value:90,children:"Last 90 days"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l,onChange:E=>c(E.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),s.jsx("div",{className:"flex-1"}),s.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>p(),disabled:x,children:[x?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(Gr,{className:"w-4 h-4"}),"Refresh"]}),s.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-red-400 hover:text-red-300",children:[b.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(_n,{className:"w-4 h-4"}),"Clear Old"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:g?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):f&&f.length>0?s.jsx("div",{className:"space-y-2",children:f.map(E=>s.jsx(MWe,{log:E,isExpanded:a===E.id,onToggle:()=>o(a===E.id?null:E.id),formatDate:v,formatFullDate:w=>Op(w,d)},E.id))}):s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(Y1,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm",children:l?"No failed notifications":"No notifications logged"})]})})]})})}function MWe({log:t,isExpanded:e,onToggle:n,formatDate:r,formatFullDate:i}){return s.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:[s.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?s.jsx(Ar,{className:"w-4 h-4 text-bambu-green shrink-0"}):s.jsx(Sa,{className:"w-4 h-4 text-red-400 shrink-0"}),s.jsx("span",{className:`text-xs font-medium ${wWe[t.event_type]||"text-bambu-gray"}`,children:_We[t.event_type]||t.event_type}),s.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&s.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),s.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?s.jsx(Tf,{className:"w-4 h-4 text-bambu-gray shrink-0"}):s.jsx(Ga,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&s.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),s.jsx("p",{className:"text-sm text-white",children:t.title})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),s.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),s.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),s.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[s.jsxs("span",{children:["Provider: ",t.provider_type]}),s.jsxs("span",{children:["Time: ",i(t.created_at)]})]})]})]})}const h1=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:s.jsx(hM,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:s.jsx(zh,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:s.jsx(is,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:s.jsx(mo,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"external_links",labelKey:"backup.categories.externalLinks",defaultLabel:"External Links",icon:s.jsx(Rb,{className:"w-4 h-4"}),default:!0,description:"Sidebar links to external services"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:s.jsx(Ei,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:s.jsx(MR,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:s.jsx(Ad,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:s.jsx(fo,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"},{id:"projects",labelKey:"backup.categories.projects",defaultLabel:"Projects",icon:s.jsx(ha,{className:"w-4 h-4"}),default:!1,description:"Projects, BOM items, and attachments"},{id:"pending_uploads",labelKey:"backup.categories.pendingUploads",defaultLabel:"Pending Uploads",icon:s.jsx(qi,{className:"w-4 h-4"}),default:!1,description:"Virtual printer uploads awaiting review"}];function EWe({onClose:t,onExport:e}){const{t:n}=lg(),[r,i]=S.useState(()=>{const x={};return h1.forEach(y=>{x[y.id]=y.default}),x}),[a,o]=S.useState(!1),[l,c]=S.useState(!1);S.useEffect(()=>{const x=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]);const u=x=>{i(y=>({...y,[x]:!y[x]}))},d=()=>{const x={};h1.forEach(y=>{x[y.id]=!0}),i(x)},f=()=>{const x={};h1.forEach(y=>{x[y.id]=!1}),i(x)},g=Object.values(r).filter(Boolean).length,p=async()=>{c(!0);try{await e({...r,access_codes:a&&r.printers})}finally{c(!1)}};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:l?void 0:t,children:s.jsx(Mt,{className:"w-full max-w-lg",onClick:x=>x.stopPropagation(),children:s.jsxs(At,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:s.jsx(Mi,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),s.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[s.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"})}),s.jsx("span",{className:"text-bambu-gray",children:"|"}),s.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"})})]}),s.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${l?"opacity-50 pointer-events-none":""}`,children:h1.map(x=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[x.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[s.jsx("input",{type:"checkbox",checked:r[x.id],onChange:()=>u(x.id),disabled:l,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),s.jsx("div",{className:`${r[x.id]?"text-bambu-green":"text-bambu-gray"}`,children:x.icon}),s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"text-white text-sm font-medium",children:n(x.labelKey,{defaultValue:x.defaultLabel})}),s.jsx("div",{className:"text-xs text-bambu-gray",children:x.description})]})]},x.id))}),r.archives&&s.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(fo,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[s.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),s.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&&s.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(lp,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),s.jsx($n,{checked:a,onChange:o})]}),a&&s.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[s.jsx(zn,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),s.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:g,defaultValue:`${g} categories selected`})}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Ne,{variant:"secondary",onClick:t,disabled:l,children:n("common.cancel",{defaultValue:"Cancel"})}),s.jsx(Ne,{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?s.jsxs(s.Fragment,{children:[s.jsx(xt,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):s.jsxs(s.Fragment,{children:[s.jsx(Mi,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const c9={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 AWe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=S.useState("options"),[a,o]=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=N=>{N.key==="Escape"&&r!=="restoring"&&t()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[t,r]);const x=w=>{const N=w.target.files?.[0];N&&c(N)},y=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")}}},b=w=>{g(N=>{const A=new Set(N);return A.has(w)?A.delete(w):A.add(w),A})},v=u?.restored?Object.values(u.restored).reduce((w,N)=>w+N,0)+(u.files_restored||0):0,E=u?.total_skipped||0;return s.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:s.jsx(Mt,{className:"w-full max-w-lg",children:s.jsxs(At,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.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?s.jsx(Ar,{className:"w-5 h-5"}):r==="result"&&!u?.success?s.jsx(zn,{className:"w-5 h-5"}):s.jsx(qi,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.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")]}),s.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"&&s.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),r==="options"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("input",{ref:p,type:"file",accept:".json,.zip",className:"hidden",onChange:x}),s.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?s.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[s.jsx(Ar,{className:"w-5 h-5"}),s.jsx("span",{className:"font-medium",children:l.name})]}):s.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[s.jsx(qi,{className:"w-8 h-8"}),s.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),s.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(zn,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-blue-700 dark:text-blue-200",children:[s.jsx("p",{className:"font-medium mb-1",children:"How duplicate handling works:"}),s.jsxs("ul",{className:"text-blue-600 dark:text-blue-200/80 space-y-1 text-xs",children:[s.jsxs("li",{children:[s.jsx("strong",{children:"Printers"})," - matched by serial number"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Smart Plugs"})," - matched by IP address"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Notification Providers"})," - matched by name"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Filaments"})," - matched by name + type + brand"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Archives"})," - matched by content hash (always skipped)"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Pending Uploads"})," - matched by filename"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Settings & Templates"})," - always overwritten"]})]})]})]})}),s.jsx("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-white font-medium flex items-center gap-2",children:[a?s.jsx(Gr,{className:"w-4 h-4 text-orange-400"}):s.jsx(Q1,{className:"w-4 h-4 text-bambu-gray"}),a?"Replace existing data":"Keep existing data"]}),s.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"})]}),s.jsx($n,{checked:a,onChange:o})]})}),a&&s.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(zn,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[s.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."]})]})})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Ne,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),s.jsxs(Ne,{type:"button",onClick:y,disabled:!l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[s.jsx(qi,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&s.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[s.jsx(xt,{className:"w-12 h-12 text-bambu-green animate-spin"}),s.jsx("p",{className:"text-bambu-gray",children:"Processing backup file..."})]}),r==="result"&&u&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 space-y-4 max-h-[400px] overflow-y-auto",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"p-3 rounded-lg bg-bambu-green/10 border border-bambu-green/30",children:[s.jsx("div",{className:"text-2xl font-bold text-bambu-green",children:v}),s.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Restored"})]}),s.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[s.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:E}),s.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),u.restored&&Object.entries(u.restored).some(([,w])=>w>0)&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(Ar,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),s.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,w])=>w>0).map(([w,N])=>s.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[s.jsx("span",{className:"text-white",children:c9[w]||w}),s.jsx("span",{className:"text-bambu-green font-medium",children:N})]},w)),(u.files_restored||0)>0&&s.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[s.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),s.jsx("span",{className:"text-bambu-green font-medium",children:u.files_restored})]})]})]}),u.skipped&&Object.entries(u.skipped).some(([,w])=>w>0)&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(Q1,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),s.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,w])=>w>0).map(([w,N])=>{const A=u.skipped_details?.[w]||[],C=f.has(w);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>A.length>0&&b(w),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${A.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[s.jsxs("span",{className:"text-white flex items-center gap-2",children:[c9[w]||w,A.length>0&&(C?s.jsx(Tf,{className:"w-3 h-3"}):s.jsx(Ga,{className:"w-3 h-3"}))]}),s.jsx("span",{className:"text-yellow-500 font-medium",children:N})]}),C&&A.length>0&&s.jsxs("div",{className:"mt-1 ml-4 p-2 rounded bg-bambu-dark-tertiary text-xs text-bambu-gray space-y-1",children:[A.slice(0,10).map((T,L)=>s.jsx("div",{children:T},L)),A.length>10&&s.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",A.length-10," more"]})]})]},w)})})]}),v===0&&E===0&&s.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),s.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:s.jsx(Ne,{onClick:t,children:"Close"})})]})]})})})}async function NWe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function TWe(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 CWe(){const t=cn(),[e,n]=S.useState(!1),[r,i]=S.useState(""),[a,o]=S.useState("auto"),[l,c]=S.useState(!1),[u,d]=S.useState("all"),[f,g]=S.useState(!1),[p,x]=S.useState(!1),{data:y,isLoading:b}=ft({queryKey:["spoolman-settings"],queryFn:NWe}),{data:v,isLoading:E,refetch:w}=ft({queryKey:["spoolman-status"],queryFn:ye.getSpoolmanStatus,refetchInterval:3e4}),{data:N}=ft({queryKey:["printers"],queryFn:ye.getPrinters});S.useEffect(()=>{y&&(n(y.spoolman_enabled==="true"),i(y.spoolman_url||""),o(y.spoolman_sync_mode||"auto"),g(!0))},[y]),S.useEffect(()=>{if(!f||!y)return;if(y.spoolman_enabled==="true"!==e||(y.spoolman_url||"")!==r||(y.spoolman_sync_mode||"auto")!==a){const G=setTimeout(()=>{A.mutate()},500);return()=>clearTimeout(G)}},[e,r,a,f]);const A=bt({mutationFn:()=>TWe({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=bt({mutationFn:ye.connectSpoolman,onSuccess:()=>{w()}}),T=bt({mutationFn:ye.disconnectSpoolman,onSuccess:()=>{w()}}),L=bt({mutationFn:ye.syncAllPrintersAms,onSuccess:R=>{R.success}}),k=bt({mutationFn:R=>ye.syncPrinterAms(R),onSuccess:R=>{R.success}}),D=()=>{u==="all"?L.mutate():k.mutate(u)},U=L.isPending||k.isPending,O=u==="all"?L.data:k.data,q=u==="all"?L.isSuccess:k.isSuccess;return b?s.jsxs(Mt,{children:[s.jsx(vi,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Pp,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),s.jsx(At,{children:s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):s.jsxs(Mt,{children:[s.jsx(vi,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Pp,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),A.isPending&&s.jsx(xt,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&s.jsx(Ls,{className:"w-4 h-4 text-bambu-green"})]})}),s.jsxs(At,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),s.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(wd,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-xs text-blue-300",children:[s.jsx("p",{className:"font-medium mb-1",children:"How Sync Works"}),s.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[s.jsx("li",{children:"Only official Bambu Lab spools with RFID are synced"}),s.jsx("li",{children:"New spools are auto-created in Spoolman on first sync"}),s.jsx("li",{children:"Non-Bambu Lab spools (third-party, refilled) are skipped"})]}),s.jsx("p",{className:"font-medium mt-2 mb-1",children:"Linking Existing Spools"}),s.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".'})]})]})}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable Spoolman"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e,onChange:R=>n(R.target.checked),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),s.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),s.jsxs("select",{value:a,onChange:R=>o(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:[s.jsx("option",{value:"auto",children:"Automatic"}),s.jsx("option",{value:"manual",children:"Manual Only"})]}),s.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&&s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),E?s.jsx(xt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):v?.connected?s.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[s.jsx(Ls,{className:"w-4 h-4"}),"Connected"]}):s.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[s.jsx(Bt,{className:"w-4 h-4"}),"Disconnected"]})]}),s.jsx("div",{className:"flex gap-2",children:v?.connected?s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(eue,{className:"w-4 h-4"}),"Disconnect"]}):s.jsxs(Ne,{size:"sm",onClick:()=>C.mutate(),disabled:C.isPending||!r,children:[C.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(jp,{className:"w-4 h-4"}),"Connect"]})})]}),C.isError&&s.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}),v?.connected&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.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:[s.jsx("option",{value:"all",children:"All Printers"}),N?.map(R=>s.jsx("option",{value:R.id,children:R.name},R.id))]}),s.jsx(Ga,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:D,disabled:U,children:[U?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(Gr,{className:"w-4 h-4"}),"Sync"]})]})]}),q&&O&&s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx("div",{className:`p-2 rounded text-sm ${O.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:O.success?`Synced ${O.synced_count} spool${O.synced_count!==1?"s":""} successfully`:`Synced ${O.synced_count} spool${O.synced_count!==1?"s":""} with ${O.errors.length} error${O.errors.length!==1?"s":""}`}),O.skipped_count>0&&s.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(zn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{className:"font-medium",children:[O.skipped_count," spool",O.skipped_count!==1?"s":""," skipped"]})]}),O.skipped_count>5&&s.jsx("button",{onClick:()=>x(!p),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:p?"Show less":"Show all"})]}),s.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(p?O.skipped:O.skipped.slice(0,5)).map((R,G)=>s.jsxs("li",{className:"flex items-center gap-2",children:[R.color&&s.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${R.color}`}}),s.jsx("span",{children:R.location}),s.jsxs("span",{className:"text-amber-300/60",children:["- ",R.reason]})]},G)),!p&&O.skipped_count>5&&s.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",O.skipped_count-5," more"]})]})]}),O.errors.length>0&&s.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[s.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),s.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:O.errors.map((R,G)=>s.jsx("li",{children:R},G))})]})]})]})]})]})}function kWe({link:t,onClose:e}){const n=cn(),{mode:r}=fg(),i=!!t,a=S.useRef(null),[o,l]=S.useState(t?.name||""),[c,u]=S.useState(t?.url||""),[d,f]=S.useState(t?.icon||"link"),[g,p]=S.useState(!!t?.custom_icon),[x,y]=S.useState(t?.custom_icon?ye.getExternalLinkIconUrl(t.id):null),[b,v]=S.useState(null),[E,w]=S.useState(null);S.useEffect(()=>{const U=O=>{O.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const N=bt({mutationFn:async U=>{const O=await ye.createExternalLink(U);return b?await ye.uploadExternalLinkIcon(O.id,b):O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{w(U.message)}}),A=bt({mutationFn:async U=>{let O=await ye.updateExternalLink(t.id,U);return b?O=await ye.uploadExternalLinkIcon(t.id,b):!g&&t?.custom_icon&&(O=await ye.deleteExternalLinkIcon(t.id)),O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{w(U.message)}}),C=U=>{const O=U.target.files?.[0];if(O){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(O.type)){w("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(O.size>1024*1024){w("Image file must be less than 1MB");return}v(O),p(!0);const R=new FileReader;R.onload=G=>{y(G.target?.result)},R.readAsDataURL(O)}},T=()=>{v(null),y(null),p(!1),a.current&&(a.current.value="")},L=U=>{if(U.preventDefault(),w(null),!o.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 O={name:o.trim(),url:c.trim(),icon:d};i?A.mutate(O):N.mutate(O)},k=N.isPending||A.isPending,D=mM(d);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:U=>U.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:g&&x?s.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):s.jsx(D,{className:"w-5 h-5"})}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:L,className:"p-6 space-y-4",children:[E&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:E}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:o,onChange:U=>l(U.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),s.jsx("input",{type:"text",value:c,onChange:U=>u(U.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"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),s.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),s.jsx("input",{ref:a,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:C}),g&&x?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:x,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),s.jsx("button",{type:"button",onClick:T,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:s.jsx(_n,{className:"w-4 h-4"})})]}):s.jsxs(Ne,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[s.jsx(qi,{className:"w-4 h-4"}),"Upload"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!g&&s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),s.jsx(che,{value:d,onChange:f})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Ne,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Ne,{type:"submit",disabled:k,className:"flex-1",children:[k?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(ks,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function PWe(){const t=cn(),[e,n]=S.useState(!1),[r,i]=S.useState(null),[a,o]=S.useState(null),[l,c]=S.useState(null),{data:u,isLoading:d}=ft({queryKey:["external-links"],queryFn:ye.getExternalLinks}),f=bt({mutationFn:E=>ye.deleteExternalLink(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),g=bt({mutationFn:E=>ye.reorderExternalLinks(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=(E,w)=>{c(w),E.dataTransfer.effectAllowed="move"},x=E=>{E.preventDefault(),E.dataTransfer.dropEffect="move"},y=(E,w)=>{if(E.preventDefault(),l===null||l===w||!u)return;const N=u.map(L=>L.id),A=N.indexOf(l),C=N.indexOf(w);if(A===-1||C===-1)return;const T=[...N];T.splice(A,1),T.splice(C,0,l),g.mutate(T),c(null)},b=E=>{o(E)},v=()=>{a&&(f.mutate(a.id),o(null))};return s.jsxs(s.Fragment,{children:[s.jsxs(Mt,{children:[s.jsx(vi,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(jp,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),s.jsxs(Ne,{size:"sm",onClick:()=>n(!0),children:[s.jsx(pr,{className:"w-4 h-4"}),"Add Link"]})]})}),s.jsxs(At,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?s.jsx("div",{className:"space-y-2",children:u.map(E=>{const w=mM(E.icon);return s.jsxs("div",{draggable:!0,onDragStart:N=>p(N,E.id),onDragOver:x,onDrop:N=>y(N,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:[s.jsx(U0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:s.jsx(w,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-white font-medium truncate",children:E.name}),s.jsx(qr,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),s.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:E.url})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.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:s.jsx(qo,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>b(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:s.jsx(_n,{className:"w-4 h-4"})})]})]},E.id)})}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(jp,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:"No external links configured"}),s.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&s.jsx(kWe,{link:r,onClose:()=>{n(!1),i(null)}}),a&&s.jsx(Qn,{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:v,onCancel:()=>o(null)})]})}function jWe(){const t=cn(),{showToast:e}=hr(),[n,r]=S.useState(!1),[i,a]=S.useState(""),[o,l]=S.useState("immediate"),[c,u]=S.useState("3DPrinter-X1-Carbon"),[d,f]=S.useState(!1),[g,p]=S.useState(null),{data:x,isLoading:y}=ft({queryKey:["virtual-printer-settings"],queryFn:x1.getSettings,refetchInterval:1e4}),{data:b}=ft({queryKey:["virtual-printer-models"],queryFn:x1.getModels});S.useEffect(()=>{x&&(r(x.enabled),l(x.mode),u(x.model))},[x]);const v=bt({mutationFn:L=>x1.updateSettings(L),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated"),p(null)},onError:L=>{e(L.message||"Failed to update settings","error"),x&&(r(x.enabled),l(x.mode),u(x.model)),p(null)}}),E=()=>{const L=!n;if(L&&!i&&!x?.access_code_set){e("Please set an access code first","error");return}r(L),p("toggle"),v.mutate({enabled:L,access_code:i||void 0,mode:o})},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"),v.mutate({access_code:i}),a("")},N=L=>{l(L),p("mode"),v.mutate({mode:L})},A=L=>{u(L),p("model"),v.mutate({model:L})};if(y)return s.jsx(Mt,{children:s.jsx(At,{className:"py-8 flex justify-center",children:s.jsx(xt,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const C=x?.status,T=C?.running||!1;return s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsx("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:s.jsxs(Mt,{children:[s.jsx(vi,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ei,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Virtual Printer"})]}),C&&s.jsxs("div",{className:`flex items-center gap-2 text-sm ${T?"text-green-400":"text-bambu-gray"}`,children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${T?"bg-green-400 animate-pulse":"bg-gray-500"}`}),T?"Running":"Stopped"]})]})}),s.jsxs(At,{className:"space-y-4",children:[s.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."}),s.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-medium",children:"Enable Virtual Printer"}),s.jsx("div",{className:"text-sm text-bambu-gray",children:T?'Visible as "Bambuddy" in slicer discovery':"Not visible to slicers"})]}),s.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:s.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${n?"translate-x-6":""}`})})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Printer Model"}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:"Select which printer model to emulate."}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:c,onChange:L=>A(L.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:b?.models&&Object.entries(b.models).sort(([,L],[,k])=>L.localeCompare(k)).map(([L,k])=>s.jsx("option",{value:L,children:k},L))}),s.jsx(Ga,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),n&&T&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[s.jsx(wd,{className:"w-3 h-3 inline mr-1"}),"Changing the model will restart the virtual printer"]})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Access Code"}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:x?.access_code_set?s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(Ls,{className:"w-4 h-4"}),"Access code is set"]}):s.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[s.jsx(zn,{className:"w-4 h-4"}),"No access code set - required to enable"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx("input",{type:d?"text":"password",value:i,onChange:L=>a(L.target.value),placeholder:x?.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"}),s.jsx("button",{onClick:()=>f(!d),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:d?s.jsx(lM,{className:"w-4 h-4"}):s.jsx(af,{className:"w-4 h-4"})})]}),s.jsx(Ne,{onClick:w,disabled:!i||g==="accessCode",variant:"primary",children:g==="accessCode"?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):"Save"})]}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["Must be exactly 8 characters. Used by slicers to authenticate.",i&&s.jsxs("span",{className:i.length===8?"text-green-400":"text-yellow-400",children:[" ","(",i.length,"/8)"]})]})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Archive Mode"}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{onClick:()=>N("immediate"),disabled:g==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="immediate"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[s.jsx("div",{className:"text-white font-medium",children:"Immediate"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive files as soon as they are uploaded"})]}),s.jsxs("button",{onClick:()=>N("queue"),disabled:g==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="queue"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[s.jsx("div",{className:"text-white font-medium",children:"Queue for Review"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Review and tag files before archiving"})]})]})]})]})]})}),s.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[s.jsx(Mt,{className:"border-l-4 border-l-yellow-500",children:s.jsx(At,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(zn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"text-white font-medium mb-2",children:"Setup Required"}),s.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."}),s.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:[s.jsx(qr,{className:"w-4 h-4"}),"Read the setup guide before enabling"]})]})]})})}),s.jsx(Mt,{children:s.jsx(At,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(wd,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:s.jsx("strong",{className:"text-white",children:"How it works:"})}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[s.jsx("li",{children:"Complete the setup guide for your platform"}),s.jsx("li",{children:"Enable the virtual printer and set an access code"}),s.jsx("li",{children:'In Bambu Studio or OrcaSlicer, go to "Add Printer"'}),s.jsx("li",{children:'The "Bambuddy" printer should appear in the discovery list'}),s.jsx("li",{children:"Connect using the access code you set"}),s.jsx("li",{children:'When you "print" to Bambuddy, the 3MF file is archived instead'})]})]})]})})}),C&&T&&s.jsxs(Mt,{children:[s.jsx(vi,{children:s.jsx("h3",{className:"text-md font-semibold text-white",children:"Status Details"})}),s.jsx(At,{children:s.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Printer Name"}),s.jsx("div",{className:"text-white",children:C.name})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Model"}),s.jsx("div",{className:"text-white",children:C.model_name||C.model})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Serial Number"}),s.jsx("div",{className:"text-white font-mono",children:C.serial})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Mode"}),s.jsx("div",{className:"text-white capitalize",children:C.mode})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Pending Files"}),s.jsx("div",{className:"text-white",children:C.pending_files})]})]})})]})]})]})}const RWe={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 DWe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function c0(t,e,n=0){if(n>5)return"...";if(e.$ref)return c0(t,DWe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const a=c0(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?[c0(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,a]of Object.entries(e.properties))r[i]=c0(t,a,n+1);return r}return{};default:return null}}function OWe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[a,o]=S.useState(!1),[l,c]=S.useState({}),[u,d]=S.useState(""),[f,g]=S.useState(null),[p,x]=S.useState(!1),[y,b]=S.useState(!1);S.useEffect(()=>{if(a&&n.parameters){const L={};for(const k of n.parameters)k.schema?.default!==void 0&&(L[k.name]=String(k.schema.default));c(k=>({...L,...k}))}},[a,n.parameters]),S.useEffect(()=>{if(a&&n.requestBody?.content?.["application/json"]?.schema&&!u){const L=n.requestBody.content["application/json"].schema,k=c0(r,L);d(JSON.stringify(k,null,2))}},[a,n.requestBody,r,u]);const E=(()=>{const L=[];for(const k of n.parameters||[])if(k.in==="path"||k.required){const D=l[k.name];(D===void 0||D==="")&&L.push(k.name)}return L})(),w=async()=>{if(E.length>0){g({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${E.join(", ")}`,duration:0});return}x(!0),g(null);try{let L=t;const k=new URLSearchParams;for(const X of n.parameters||[]){const F=l[X.name];F!==void 0&&F!==""&&(X.in==="path"?L=L.replace(`{${X.name}}`,encodeURIComponent(F)):X.in==="query"&&k.append(X.name,F))}const D=k.toString(),U=`${L}${D?`?${D}`:""}`,O={"Content-Type":"application/json"};i&&(O["X-API-Key"]=i);const q={method:e.toUpperCase(),headers:O};["post","put","patch"].includes(e)&&u&&(q.body=u);const R=performance.now(),G=await fetch(U,q),Y=Math.round(performance.now()-R),V={};G.headers.forEach((X,F)=>{V[F]=X});let K;G.headers.get("content-type")?.includes("application/json")?K=await G.json():K=await G.text(),g({status:G.status,statusText:G.statusText,headers:V,body:K,duration:Y})}catch(L){g({status:0,statusText:"Network Error",headers:{},body:L instanceof Error?L.message:"Unknown error",duration:0})}finally{x(!1)}},N=async()=>{if(f){const L=typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2);try{await navigator.clipboard.writeText(L),b(!0),setTimeout(()=>b(!1),2e3)}catch{const k=document.createElement("textarea");k.value=L,k.style.position="fixed",k.style.left="-999999px",document.body.appendChild(k),k.select(),document.execCommand("copy"),document.body.removeChild(k),b(!0),setTimeout(()=>b(!1),2e3)}}},A=(n.parameters||[]).filter(L=>L.in==="path"),C=(n.parameters||[]).filter(L=>L.in==="query"),T=["post","put","patch"].includes(e)&&n.requestBody;return s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>o(!a),className:"w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left",children:[a?s.jsx(Ga,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):s.jsx(Zo,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${RWe[e]||"bg-gray-500/20 text-gray-400"}`,children:e}),s.jsx("code",{className:"text-sm text-white font-mono flex-1 truncate",children:t}),n.summary&&s.jsx("span",{className:"text-sm text-bambu-gray truncate max-w-[40%]",children:n.summary})]}),a&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50",children:[n.description&&s.jsx("p",{className:"text-sm text-bambu-gray",children:n.description}),A.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Path Parameters"}),s.jsx("div",{className:"space-y-2",children:A.map(L=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[L.name,L.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),s.jsx("input",{type:"text",value:l[L.name]||"",onChange:k=>c(D=>({...D,[L.name]:k.target.value})),placeholder:L.description||L.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"})]},L.name))})]}),C.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Query Parameters"}),s.jsx("div",{className:"space-y-2",children:C.map(L=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[L.name,L.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),L.schema?.enum?s.jsxs("select",{value:l[L.name]||"",onChange:k=>c(D=>({...D,[L.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:[s.jsx("option",{value:"",children:"-- Select --"}),L.schema.enum.map(k=>s.jsx("option",{value:k,children:k},k))]}):s.jsx("input",{type:"text",value:l[L.name]||"",onChange:k=>c(D=>({...D,[L.name]:k.target.value})),placeholder:L.description||L.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"})]},L.name))})]}),T&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Request Body"}),s.jsx("textarea",{value:u,onChange:L=>d(L.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..."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Ne,{onClick:w,disabled:p,children:[p?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(Gc,{className:"w-4 h-4"}),"Execute"]}),E.length>0&&s.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[s.jsx(Aa,{className:"w-3 h-3"}),"Fill in: ",E.join(", ")]})]}),f&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h4",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Response",s.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]}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[f.duration,"ms"]})]}),s.jsx(Ne,{variant:"secondary",size:"sm",onClick:N,children:y?s.jsx(Ar,{className:"w-3 h-3 text-green-400"}):s.jsx(Wo,{className:"w-3 h-3"})})]}),s.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 LWe({apiKey:t=""}){const[e,n]=S.useState(null),[r,i]=S.useState(!0),[a,o]=S.useState(null),[l,c]=S.useState(new Set),[u,d]=S.useState("");if(S.useEffect(()=>{async function b(){try{const v=await fetch("/openapi.json");if(!v.ok)throw new Error("Failed to fetch OpenAPI schema");const E=await v.json();n(E)}catch(v){o(v instanceof Error?v.message:"Unknown error")}finally{i(!1)}}b()},[]),r)return s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(a||!e)return s.jsx(Mt,{children:s.jsx(At,{className:"py-8",children:s.jsxs("div",{className:"text-center text-red-400",children:[s.jsx(Aa,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),s.jsx("p",{children:"Failed to load API schema"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a})]})})});const f={};for(const[b,v]of Object.entries(e.paths))for(const[E,w]of Object.entries(v)){if(E==="parameters")continue;const N=w.tags||["Other"];for(const A of N)f[A]||(f[A]=[]),f[A].push({path:b,method:E,spec:w})}const g=Object.entries(f).map(([b,v])=>{if(!u)return{tag:b,endpoints:v};const E=v.filter(({path:w,method:N,spec:A})=>{const C=u.toLowerCase();return w.toLowerCase().includes(C)||N.toLowerCase().includes(C)||(A.summary?.toLowerCase()||"").includes(C)||(A.description?.toLowerCase()||"").includes(C)});return{tag:b,endpoints:E}}).filter(({endpoints:b})=>b.length>0).sort((b,v)=>b.tag.localeCompare(v.tag)),p=b=>{c(v=>{const E=new Set(v);return E.has(b)?E.delete(b):E.add(b),E})},x=()=>{c(new Set(g.map(b=>b.tag)))},y=()=>{c(new Set)};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("div",{className:"flex-1",children:s.jsx("input",{type:"text",value:u,onChange:b=>d(b.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"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ne,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),s.jsx(Ne,{variant:"secondary",size:"sm",onClick:y,children:"Collapse All"}),s.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[s.jsx(qr,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[g.reduce((b,v)=>b+v.endpoints.length,0)," endpoints in ",g.length," categories"]}),s.jsx("div",{className:"space-y-3",children:g.map(({tag:b,endpoints:v})=>s.jsxs(Mt,{children:[s.jsx("button",{onClick:()=>p(b),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left",children:s.jsxs("div",{className:"flex items-center gap-2",children:[l.has(b)?s.jsx(Ga,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Zo,{className:"w-5 h-5 text-bambu-gray"}),s.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:b.replace(/-/g," ")}),s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:v.length})]})}),l.has(b)&&s.jsx(At,{className:"pt-0 space-y-2",children:v.map(({path:E,method:w,spec:N})=>s.jsx(OWe,{path:E,method:w,spec:N,schema:e,apiKey:t},`${w}-${E}`))})]},b))})]})}function IWe(){const t=cn(),{t:e,i18n:n}=lg(),{showToast:r,showPersistentToast:i,dismissToast:a}=hr(),{mode:o,darkStyle:l,darkBackground:c,darkAccent:u,lightStyle:d,lightBackground:f,lightAccent:g,setDarkStyle:p,setDarkBackground:x,setDarkAccent:y,setLightStyle:b,setLightBackground:v,setLightAccent:E}=fg(),[w,N]=S.useState(null),[A,C]=S.useState(!1),[T,L]=S.useState(null),[k,D]=S.useState(!1),[U,O]=S.useState(null),[q,R]=S.useState(null),[G,Y]=S.useState(!1),[V,K]=S.useState(xW()),[J,X]=S.useState("general"),[F,W]=S.useState(!1),[ee,ie]=S.useState(""),[ae,de]=S.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[ue,le]=S.useState(null),[he,pe]=S.useState(null),[Me,re]=S.useState(""),[We,z]=S.useState(!1),[H,se]=S.useState(!1),[B,Q]=S.useState(null),[ce,Ce]=S.useState(!1),[_e,Ee]=S.useState(!1),[$,j]=S.useState(!1),[ne,be]=S.useState(!1),we=Re=>{K(Re),hhe(Re)},ve=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:$e,isLoading:Ge}=ft({queryKey:["settings"],queryFn:ye.getSettings}),{data:Xe,isLoading:ut}=ft({queryKey:["smart-plugs"],queryFn:ye.getSmartPlugs}),{data:He,isLoading:me}=ft({queryKey:["smart-plugs-energy",Xe?.map(Re=>Re.id)],queryFn:async()=>{if(!Xe||Xe.length===0)return null;const Re=await Promise.all(Xe.filter(yt=>yt.enabled).map(async yt=>{try{const oe=await ye.getSmartPlugStatus(yt.id);return{plug:yt,status:oe}}catch{return{plug:yt,status:null}}}));let ge=0,je=0,Be=0,rt=0,tt=0;for(const{status:yt}of Re)yt?.reachable&&yt.energy&&(tt++,yt.energy.power!=null&&(ge+=yt.energy.power),yt.energy.today!=null&&(je+=yt.energy.today),yt.energy.yesterday!=null&&(Be+=yt.energy.yesterday),yt.energy.total!=null&&(rt+=yt.energy.total));return{totalPower:ge,totalToday:je,totalYesterday:Be,totalLifetime:rt,reachableCount:tt,totalPlugs:Xe.filter(yt=>yt.enabled).length}},enabled:J==="plugs"&&!!Xe&&Xe.length>0,refetchInterval:J==="plugs"?1e4:!1}),{data:Je,isLoading:Ke}=ft({queryKey:["notification-providers"],queryFn:ye.getNotificationProviders}),{data:Ze,isLoading:ct}=ft({queryKey:["api-keys"],queryFn:ye.getAPIKeys}),te=bt({mutationFn:Re=>ye.createAPIKey(Re),onSuccess:Re=>{le(Re.key||null),W(!1),ie(""),t.invalidateQueries({queryKey:["api-keys"]}),r("API key created")},onError:Re=>{r(`Failed to create API key: ${Re.message}`,"error")}}),Fe=bt({mutationFn:Re=>ye.deleteAPIKey(Re),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),r("API key deleted")},onError:Re=>{r(`Failed to delete API key: ${Re.message}`,"error")}}),{data:xe}=ft({queryKey:["printers"],queryFn:ye.getPrinters}),{data:ze,isLoading:Pe}=ft({queryKey:["notification-templates"],queryFn:ye.getNotificationTemplates}),{data:Se}=ft({queryKey:["virtual-printer-settings"],queryFn:x1.getSettings,refetchInterval:1e4}),Ye=Se?.status?.running??!1,{data:dt}=ft({queryKey:["ffmpeg-status"],queryFn:ye.checkFfmpeg}),{data:Tt}=ft({queryKey:["version"],queryFn:ye.getVersion}),{data:Et,refetch:Zt,isRefetching:Rt}=ft({queryKey:["updateCheck"],queryFn:ye.checkForUpdates,staleTime:300*1e3}),{data:en,refetch:Ln}=ft({queryKey:["updateStatus"],queryFn:ye.getUpdateStatus,refetchInterval:Re=>{const ge=Re.state.data;return ge?.status==="downloading"||ge?.status==="installing"?1e3:!1}}),Vn=bt({mutationFn:ye.applyUpdate,onSuccess:Re=>{Re.is_docker?r(Re.message,"error"):Ln()}}),[tr,gt]=S.useState(null),Vt=bt({mutationFn:ye.testAllNotificationProviders,onSuccess:Re=>{gt(Re),t.invalidateQueries({queryKey:["notification-providers"]}),Re.failed===0?r(`All ${Re.tested} providers tested successfully!`,"success"):r(`${Re.success}/${Re.tested} providers succeeded`,Re.failed>0?"error":"success")},onError:Re=>{r(`Failed to test providers: ${Re.message}`,"error")}}),Qt=bt({mutationFn:async Re=>{if(!Xe)return{success:0,failed:0};const ge=Xe.filter(Be=>Be.enabled),je=await Promise.all(ge.map(async Be=>{try{return await ye.controlSmartPlug(Be.id,Re),{success:!0}}catch{return{success:!1}}}));return{success:je.filter(Be=>Be.success).length,failed:je.filter(Be=>!Be.success).length}},onSuccess:(Re,ge)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),Re.failed===0?r(`All ${Re.success} plugs turned ${ge}`,"success"):r(`${Re.success} plugs turned ${ge}, ${Re.failed} failed`,"error")},onError:Re=>{r(`Failed: ${Re.message}`,"error")}}),mt=S.useRef(null),Kt=S.useRef(!0);S.useEffect(()=>{$e&&!w&&(N($e),setTimeout(()=>{Kt.current=!1},100))},[$e,w]);const dn=bt({mutationFn:ye.updateSettings,onSuccess:Re=>{t.setQueryData(["settings"],Re),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:Re=>{r(`Failed to save: ${Re.message}`,"error")}});S.useEffect(()=>{if(!(Kt.current||!w||!$e||!($e.auto_archive!==w.auto_archive||$e.save_thumbnails!==w.save_thumbnails||$e.capture_finish_photo!==w.capture_finish_photo||$e.default_filament_cost!==w.default_filament_cost||$e.currency!==w.currency||$e.energy_cost_per_kwh!==w.energy_cost_per_kwh||$e.energy_tracking_mode!==w.energy_tracking_mode||$e.check_updates!==w.check_updates||$e.notification_language!==w.notification_language||$e.telemetry_enabled!==w.telemetry_enabled||$e.ams_humidity_good!==w.ams_humidity_good||$e.ams_humidity_fair!==w.ams_humidity_fair||$e.ams_temp_good!==w.ams_temp_good||$e.ams_temp_fair!==w.ams_temp_fair||$e.ams_history_retention_days!==w.ams_history_retention_days||$e.date_format!==w.date_format||$e.time_format!==w.time_format||$e.default_printer_id!==w.default_printer_id||$e.ftp_retry_enabled!==w.ftp_retry_enabled||$e.ftp_retry_count!==w.ftp_retry_count||$e.ftp_retry_delay!==w.ftp_retry_delay||$e.ftp_timeout!==w.ftp_timeout)))return mt.current&&clearTimeout(mt.current),mt.current=setTimeout(()=>{const ge={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,ftp_retry_enabled:w.ftp_retry_enabled,ftp_retry_count:w.ftp_retry_count,ftp_retry_delay:w.ftp_retry_delay,ftp_timeout:w.ftp_timeout};dn.mutate(ge)},500),()=>{mt.current&&clearTimeout(mt.current)}},[w,$e,dn]);const Ht=S.useCallback((Re,ge)=>{N(je=>je?{...je,[Re]:ge}:null)},[]);return Ge||!w?s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"mb-8",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),s.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>X("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${J==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:"General"}),s.jsxs("button",{onClick:()=>X("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${J==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(mo,{className:"w-4 h-4"}),"Smart Plugs",Xe&&Xe.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Xe.length})]}),s.jsxs("button",{onClick:()=>X("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${J==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(zh,{className:"w-4 h-4"}),"Notifications",Je&&Je.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Je.length})]}),s.jsxs("button",{onClick:()=>X("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${J==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Qle,{className:"w-4 h-4"}),"Filament"]}),s.jsxs("button",{onClick:()=>X("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${J==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(lp,{className:"w-4 h-4"}),"API Keys",Ze&&Ze.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ze.length})]}),s.jsxs("button",{onClick:()=>X("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${J==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Ei,{className:"w-4 h-4"}),"Virtual Printer",s.jsx("span",{className:`w-2 h-2 rounded-full ${Ye?"bg-green-400":"bg-gray-500"}`})]})]}),J==="general"&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[s.jsxs(Mt,{children:[s.jsx(vi,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),s.jsxs(At,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(sf,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),s.jsx("select",{value:n.language,onChange:Re=>n.changeLanguage(Re.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:dU.map(Re=>s.jsxs("option",{value:Re.code,children:[Re.nativeName," (",Re.name,")"]},Re.code))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),s.jsx("select",{value:V,onChange:Re=>we(Re.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:B0.map(Re=>s.jsx("option",{value:Re.to,children:e(Re.labelKey)},Re.id))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),s.jsxs("select",{value:w.date_format||"system",onChange:Re=>Ht("date_format",Re.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:[s.jsx("option",{value:"system",children:"System Default"}),s.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),s.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),s.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),s.jsxs("select",{value:w.time_format||"system",onChange:Re=>Ht("time_format",Re.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:[s.jsx("option",{value:"system",children:"System Default"}),s.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),s.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),s.jsxs("select",{value:w.default_printer_id??"",onChange:Re=>Ht("default_printer_id",Re.target.value?Number(Re.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:[s.jsx("option",{value:"",children:"No default (ask each time)"}),xe?.map(Re=>s.jsx("option",{value:Re.id,children:Re.name},Re.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Sidebar order"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:ve,children:[s.jsx(hg,{className:"w-4 h-4"}),"Reset"]})]})]})]}),s.jsxs(Mt,{children:[s.jsx(vi,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(MR,{className:"w-5 h-5"}),"Appearance"]})}),s.jsxs(At,{className:"space-y-6",children:[s.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${o==="dark"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Dark Mode",o==="dark"&&s.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),s.jsxs("select",{value:c,onChange:Re=>{x(Re.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:[s.jsx("option",{value:"neutral",children:"Neutral"}),s.jsx("option",{value:"warm",children:"Warm"}),s.jsx("option",{value:"cool",children:"Cool"}),s.jsx("option",{value:"oled",children:"OLED Black"}),s.jsx("option",{value:"slate",children:"Slate Blue"}),s.jsx("option",{value:"forest",children:"Forest Green"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),s.jsxs("select",{value:u,onChange:Re=>{y(Re.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:[s.jsx("option",{value:"green",children:"Green"}),s.jsx("option",{value:"teal",children:"Teal"}),s.jsx("option",{value:"blue",children:"Blue"}),s.jsx("option",{value:"orange",children:"Orange"}),s.jsx("option",{value:"purple",children:"Purple"}),s.jsx("option",{value:"red",children:"Red"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),s.jsxs("select",{value:l,onChange:Re=>{p(Re.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:[s.jsx("option",{value:"classic",children:"Classic"}),s.jsx("option",{value:"glow",children:"Glow"}),s.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),s.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${o==="light"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Light Mode",o==="light"&&s.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),s.jsxs("select",{value:f,onChange:Re=>{v(Re.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:[s.jsx("option",{value:"neutral",children:"Neutral"}),s.jsx("option",{value:"warm",children:"Warm"}),s.jsx("option",{value:"cool",children:"Cool"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),s.jsxs("select",{value:g,onChange:Re=>{E(Re.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:[s.jsx("option",{value:"green",children:"Green"}),s.jsx("option",{value:"teal",children:"Teal"}),s.jsx("option",{value:"blue",children:"Blue"}),s.jsx("option",{value:"orange",children:"Orange"}),s.jsx("option",{value:"purple",children:"Purple"}),s.jsx("option",{value:"red",children:"Red"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),s.jsxs("select",{value:d,onChange:Re=>{b(Re.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:[s.jsx("option",{value:"classic",children:"Classic"}),s.jsx("option",{value:"glow",children:"Glow"}),s.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Toggle between dark and light mode using the sun/moon icon in the sidebar."})]})]}),s.jsxs(Mt,{children:[s.jsx(vi,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),s.jsxs(At,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Auto-archive prints"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.auto_archive,onChange:Re=>Ht("auto_archive",Re.target.checked),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Save thumbnails"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.save_thumbnails,onChange:Re=>Ht("save_thumbnails",Re.target.checked),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Capture finish photo"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.capture_finish_photo,onChange:Re=>Ht("capture_finish_photo",Re.target.checked),className:"sr-only peer"}),s.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&&dt&&!dt.installed&&s.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsx(zn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),s.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",s.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",s.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]})]}),s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[s.jsxs(Mt,{children:[s.jsx(vi,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),s.jsxs(At,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),s.jsx("input",{type:"number",step:"0.01",min:"0",value:w.default_filament_cost,onChange:Re=>Ht("default_filament_cost",parseFloat(Re.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),s.jsxs("select",{value:w.currency,onChange:Re=>Ht("currency",Re.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:[s.jsx("option",{value:"USD",children:"USD ($)"}),s.jsx("option",{value:"EUR",children:"EUR (€)"}),s.jsx("option",{value:"GBP",children:"GBP (£)"}),s.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),s.jsx("option",{value:"JPY",children:"JPY (¥)"}),s.jsx("option",{value:"CNY",children:"CNY (¥)"}),s.jsx("option",{value:"CAD",children:"CAD ($)"}),s.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),s.jsx("input",{type:"number",step:"0.01",min:"0",value:w.energy_cost_per_kwh,onChange:Re=>Ht("energy_cost_per_kwh",parseFloat(Re.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),s.jsxs("select",{value:w.energy_tracking_mode||"total",onChange:Re=>Ht("energy_tracking_mode",Re.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:[s.jsx("option",{value:"print",children:"Prints Only"}),s.jsx("option",{value:"total",children:"Total Consumption"})]}),s.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"})]})]})]}),s.jsxs(Mt,{children:[s.jsx(vi,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),s.jsxs(At,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(xR,{className:"w-4 h-4 text-blue-400"}),s.jsx("span",{className:"font-medium",children:"Humidity"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:w.ams_humidity_good??40,onChange:Re=>Ht("ams_humidity_good",parseInt(Re.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"}),s.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:w.ams_humidity_fair??60,onChange:Re=>Ht("ams_humidity_fair",parseInt(Re.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"}),s.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),s.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(fM,{className:"w-4 h-4 text-orange-400"}),s.jsx("span",{className:"font-medium",children:"Temperature"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:w.ams_temp_good??28,onChange:Re=>Ht("ams_temp_good",parseFloat(Re.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"}),s.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:w.ams_temp_fair??35,onChange:Re=>Ht("ams_temp_fair",parseFloat(Re.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"}),s.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(Pp,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"font-medium",children:"History Retention"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Keep sensor history for"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"365",value:w.ams_history_retention_days??30,onChange:Re=>Ht("ams_history_retention_days",parseInt(Re.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"}),s.jsx("span",{className:"text-bambu-gray",children:"days"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Older humidity and temperature data will be automatically deleted"})]})]})]}),s.jsxs(Mt,{children:[s.jsx(vi,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Gr,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),s.jsxs(At,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Retry FTP operations when printer WiFi is unreliable. Applies to 3MF downloads, print uploads, timelapse downloads, and firmware updates."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable retry"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically retry failed FTP operations"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.ftp_retry_enabled??!0,onChange:Re=>Ht("ftp_retry_enabled",Re.target.checked),className:"sr-only peer"}),s.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.ftp_retry_enabled&&s.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry attempts"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"10",value:w.ftp_retry_count??3,onChange:Re=>Ht("ftp_retry_count",Math.min(10,Math.max(1,parseInt(Re.target.value)||3))),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"}),s.jsx("span",{className:"text-bambu-gray",children:"times"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of retry attempts before giving up (1-10)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry delay"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"30",value:w.ftp_retry_delay??2,onChange:Re=>Ht("ftp_retry_delay",Math.min(30,Math.max(1,parseInt(Re.target.value)||2))),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"}),s.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Wait time between retries (1-30)"})]})]}),s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Connection timeout"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"10",max:"120",value:w.ftp_timeout??30,onChange:Re=>Ht("ftp_timeout",Math.min(120,Math.max(10,parseInt(Re.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"}),s.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Socket timeout for slow connections. Increase for A1/A1 Mini printers with weak WiFi (10-120)"})]})]})]})]}),s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[s.jsx(PWe,{}),s.jsxs(Mt,{children:[s.jsx(vi,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),s.jsxs(At,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Check for updates"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.check_updates,onChange:Re=>Ht("check_updates",Re.target.checked),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-white",children:e("settings.telemetry")}),s.jsxs("button",{onClick:()=>j(!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:[s.jsx(wd,{className:"w-3 h-3"}),e("settings.telemetryLearnMore")]})]}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e("settings.telemetryDescription")})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.telemetry_enabled,onChange:Re=>Ht("telemetry_enabled",Re.target.checked),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Current version"}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",Tt?.version||"..."]})]}),s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>Zt(),disabled:Rt,children:[Rt?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(Gr,{className:"w-4 h-4"}),"Check now"]})]}),Et?.update_available?s.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",Et.latest_version]}),Et.release_name&&Et.release_name!==Et.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:Et.release_name})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Et.release_notes&&s.jsx("button",{onClick:()=>be(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),Et.release_url&&s.jsx("a",{href:Et.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:s.jsx(qr,{className:"w-4 h-4"})})]})]}),en?.status==="downloading"||en?.status==="installing"?s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(xt,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:en.message})]}),s.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${en.progress}%`}})})]}):en?.status==="complete"?s.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:en.message}):en?.status==="error"?s.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:en.error||en.message}):Et?.is_docker?s.jsxs("div",{className:"mt-3 p-3 bg-bambu-dark-tertiary rounded-lg",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Update via Docker Compose:"}),s.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"})]}):s.jsxs(Ne,{className:"mt-3",onClick:()=>Vn.mutate(),disabled:Vn.isPending,children:[Vn.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(Mi,{className:"w-4 h-4"}),"Install Update"]})]}):Et?.error?s.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: ",Et.error]}):Et&&!Et.update_available?s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),s.jsxs(Mt,{children:[s.jsx(vi,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),s.jsxs(At,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Backup Data"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>Ce(!0),children:[s.jsx(Mi,{className:"w-4 h-4"}),"Export"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Restore Backup"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>Ee(!0),children:[s.jsx(qi,{className:"w-4 h-4"}),"Restore"]})]}),s.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>z(!0),children:[s.jsx(_n,{className:"w-4 h-4"}),"Clear"]})]})}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),s.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."})]}),s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>se(!0),children:[s.jsx(_n,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),J==="plugs"&&s.jsxs("div",{className:"max-w-4xl",children:[s.jsxs("div",{className:"flex items-start justify-between mb-6",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(mo,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),s.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."})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[Xe&&Xe.filter(Re=>Re.enabled).length>1&&s.jsxs(s.Fragment,{children:[s.jsxs(Ne,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>Q("on"),disabled:Qt.isPending,title:"Turn all plugs on",children:[Qt.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(Ol,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),s.jsxs(Ne,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>Q("off"),disabled:Qt.isPending,title:"Turn all plugs off",children:[Qt.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(uM,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),s.jsxs(Ne,{className:"whitespace-nowrap",onClick:()=>{L(null),C(!0)},children:[s.jsx(pr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),Xe&&Xe.length>0&&s.jsxs(Mt,{className:"mb-6",children:[s.jsx(vi,{children:s.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[s.jsx(cf,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",me&&s.jsx(xt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),s.jsx(At,{children:He?s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(cf,{className:"w-3 h-3"}),"Current Power"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[He.totalPower.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[He.reachableCount,"/",He.totalPlugs," plugs online"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(Wr,{className:"w-3 h-3"}),"Today"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[He.totalToday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),w&&w.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(He.totalToday*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(uW,{className:"w-3 h-3"}),"Yesterday"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[He.totalYesterday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),w&&w.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(He.totalYesterday*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(s3,{className:"w-3 h-3"}),"Total"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[He.totalLifetime.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),w&&w.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(He.totalLifetime*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]})]}):me?null:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),ut?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Xe&&Xe.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Xe.map(Re=>s.jsx(pWe,{plug:Re,onEdit:ge=>{L(ge),C(!0)}},Re.id))}):s.jsx(Mt,{children:s.jsx(At,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(mo,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),s.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),s.jsxs(Ne,{onClick:()=>{L(null),C(!0)},children:[s.jsx(pr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),J==="notifications"&&s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(zh,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>Y(!0),children:[s.jsx(Y1,{className:"w-4 h-4"}),"Log"]}),Je&&Je.length>0&&s.jsxs(Ne,{size:"sm",variant:"secondary",onClick:()=>{gt(null),Vt.mutate()},disabled:Vt.isPending,children:[Vt.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(NR,{className:"w-4 h-4"}),"Test All"]}),s.jsxs(Ne,{size:"sm",onClick:()=>{O(null),D(!0)},children:[s.jsx(pr,{className:"w-4 h-4"}),"Add"]})]})]}),s.jsx(Mt,{className:"mb-4",children:s.jsx(At,{className:"py-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm font-medium",children:e("settings.notificationLanguage")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),s.jsx("select",{value:w.notification_language||"en",onChange:Re=>Ht("notification_language",Re.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:dU.map(Re=>s.jsx("option",{value:Re.code,children:Re.nativeName},Re.code))})]})})}),tr&&s.jsx(Mt,{className:"mb-4",children:s.jsxs(At,{className:"py-3",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),s.jsx("button",{onClick:()=>gt(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(Ar,{className:"w-4 h-4"}),tr.success," passed"]}),tr.failed>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Sa,{className:"w-4 h-4"}),tr.failed," failed"]})]}),tr.results.filter(Re=>!Re.success).length>0&&s.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:tr.results.filter(Re=>!Re.success).map(Re=>s.jsxs("div",{className:"text-xs text-red-400",children:[s.jsxs("span",{className:"font-medium",children:[Re.provider_name,":"]})," ",Re.message]},Re.provider_id))})]})}),Ke?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Je&&Je.length>0?s.jsx("div",{className:"space-y-3",children:Je.map(Re=>s.jsx(bWe,{provider:Re,onEdit:ge=>{O(ge),D(!0)}},Re.id))}):s.jsx(Mt,{children:s.jsx(At,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(zh,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),s.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),s.jsxs(Ne,{size:"sm",onClick:()=>{O(null),D(!0)},children:[s.jsx(pr,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[s.jsx(is,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),Pe?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(xt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):ze&&ze.length>0?s.jsx("div",{className:"space-y-2",children:ze.map(Re=>s.jsx(Mt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>R(Re),children:s.jsx(At,{className:"py-2.5 px-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium text-sm truncate",children:Re.name}),s.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:Re.title_template})]}),s.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:ge=>{ge.stopPropagation(),R(Re)},children:s.jsx(AR,{className:"w-4 h-4 text-bambu-gray"})})]})})},Re.id))}):s.jsx(Mt,{children:s.jsx(At,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(is,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),J==="apikeys"&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(lp,{className:"w-5 h-5 text-bambu-green"}),"API Keys"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Create API keys for external integrations and webhooks."})]}),s.jsxs(Ne,{size:"sm",onClick:()=>W(!0),className:"flex-shrink-0",children:[s.jsx(pr,{className:"w-4 h-4"}),"Create Key"]})]}),ue&&s.jsx(Mt,{className:"mb-6 border-bambu-green",children:s.jsx(At,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Ar,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-white font-medium mb-1",children:"API Key Created Successfully"}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Copy this key now - it won't be shown again!"}),s.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[s.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:ue}),s.jsx(Ne,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(ue);else{const Re=document.createElement("textarea");Re.value=ue,Re.style.position="fixed",Re.style.left="-999999px",document.body.appendChild(Re),Re.select(),document.execCommand("copy"),document.body.removeChild(Re)}r("Key copied to clipboard")}catch{r("Failed to copy key","error")}},children:s.jsx(Wo,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>{re(ue),r("Key added to API Browser")},children:"Use in API Browser"}),s.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>le(null),children:"Dismiss"})]})]})]})})}),F&&s.jsxs(Mt,{className:"mb-6",children:[s.jsx(vi,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),s.jsxs(At,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Key Name"}),s.jsx("input",{type:"text",value:ee,onChange:Re=>ie(Re.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Permissions"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ae.can_read_status,onChange:Re=>de(ge=>({...ge,can_read_status:Re.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:"Read Status"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"View printer status and queue"})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ae.can_queue,onChange:Re=>de(ge=>({...ge,can_queue:Re.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:"Manage Queue"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Add and remove items from print queue"})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ae.can_control_printer,onChange:Re=>de(ge=>({...ge,can_control_printer:Re.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:"Control Printer"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Pause, resume, and stop prints"})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsxs(Ne,{onClick:()=>te.mutate({name:ee||"Unnamed Key",...ae}),disabled:te.isPending,children:[te.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(pr,{className:"w-4 h-4"}),"Create Key"]}),s.jsx(Ne,{variant:"secondary",onClick:()=>W(!1),children:"Cancel"})]})]})]}),ct?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Ze&&Ze.length>0?s.jsx("div",{className:"space-y-3",children:Ze.map(Re=>s.jsx(Mt,{children:s.jsx(At,{className:"py-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(lp,{className:`w-5 h-5 ${Re.enabled?"text-bambu-green":"text-bambu-gray"}`}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:Re.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[Re.key_prefix,"••••••••",Re.last_used&&` · Last used: ${Dp(Re.last_used)}`]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex gap-1 text-xs",children:[Re.can_read_status&&s.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),Re.can_queue&&s.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),Re.can_control_printer&&s.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:"Control"})]}),s.jsx(Ne,{variant:"secondary",size:"sm",onClick:()=>pe(Re.id),children:s.jsx(_n,{className:"w-4 h-4 text-red-400"})})]})]})})},Re.id))}):s.jsx(Mt,{children:s.jsx(At,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(lp,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No API keys"}),s.jsx("p",{className:"text-sm mb-4",children:"Create an API key to integrate with external services."}),s.jsxs(Ne,{onClick:()=>W(!0),children:[s.jsx(pr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),s.jsxs(Mt,{className:"mt-6",children:[s.jsx(vi,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),s.jsxs(At,{className:"space-y-3 text-sm",children:[s.jsxs("p",{className:"text-bambu-gray",children:["Use your API key in the ",s.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header."]}),s.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-blue-400",children:"GET"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),s.jsx("span",{className:"text-bambu-gray",children:" - Get all printer status"})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-blue-400",children:"GET"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),s.jsx("span",{className:"text-bambu-gray",children:" - Get specific printer status"})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-green-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),s.jsx("span",{className:"text-bambu-gray",children:" - Add to print queue"})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-orange-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),s.jsx("span",{className:"text-bambu-gray",children:" - Pause print"})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-orange-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),s.jsx("span",{className:"text-bambu-gray",children:" - Resume print"})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-red-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),s.jsx("span",{className:"text-bambu-gray",children:" - Stop print"})]})]})]})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(sf,{className:"w-5 h-5 text-bambu-green"}),"API Browser"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Explore and test all available API endpoints."})]}),s.jsx(Mt,{className:"mb-4",children:s.jsxs(At,{className:"py-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"API Key for Testing"}),s.jsx("input",{type:"text",value:Me,onChange:Re=>re(Re.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"}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["This key will be sent as ",s.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header with requests."]})]})}),s.jsx(LWe,{apiKey:Me})]})]}),J==="virtual-printer"&&s.jsx(jWe,{}),J==="filament"&&s.jsx("div",{className:"max-w-2xl",children:s.jsx(CWe,{})}),he!==null&&s.jsx(Qn,{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:()=>{Fe.mutate(he),pe(null)},onCancel:()=>pe(null)}),A&&s.jsx(gWe,{plug:T,onClose:()=>{C(!1),L(null)}}),k&&s.jsx(yWe,{provider:U,onClose:()=>{D(!1),O(null)}}),q&&s.jsx(vWe,{template:q,onClose:()=>R(null)}),G&&s.jsx(SWe,{onClose:()=>Y(!1)}),We&&s.jsx(Qn,{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()=>{z(!1);try{const Re=await ye.clearNotificationLogs(30);r(Re.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>z(!1)}),H&&s.jsx(Qn,{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:()=>{se(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>se(!1)}),B&&s.jsx(Qn,{title:`Turn All Plugs ${B==="on"?"On":"Off"}`,message:`This will turn ${B==="on"?"ON":"OFF"} all ${Xe?.filter(Re=>Re.enabled).length||0} enabled smart plugs. ${B==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${B==="on"?"On":"Off"}`,variant:B==="off"?"danger":"warning",onConfirm:()=>{const Re=B;Q(null),Qt.mutate(Re)},onCancel:()=>Q(null)}),ce&&s.jsx(EWe,{onClose:()=>Ce(!1),onExport:async Re=>{Ce(!1);const ge="backup-progress",je=Re.archives;je&&i(ge,e("backup.preparing",{defaultValue:"Preparing backup..."}),"loading");try{const{blob:Be,filename:rt}=await ye.exportBackup(Re);je&&a(ge);const tt=URL.createObjectURL(Be),yt=document.createElement("a");yt.href=tt,yt.download=rt,yt.click(),URL.revokeObjectURL(tt),r(e("backup.downloaded",{defaultValue:"Backup downloaded"}),"success")}catch{je&&a(ge),r(e("backup.failed",{defaultValue:"Failed to create backup"}),"error")}}}),_e&&s.jsx(AWe,{onClose:()=>Ee(!1),onRestore:async(Re,ge)=>await ye.importBackup(Re,ge),onSuccess:()=>{N(null),Kt.current=!0,t.invalidateQueries()}}),$&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>j(!1),children:s.jsxs(Mt,{className:"w-full max-w-lg",onClick:Re=>Re.stopPropagation(),children:[s.jsxs(vi,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(lde,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.telemetryInfoTitle")})]}),s.jsx("button",{onClick:()=>j(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs(At,{className:"space-y-4",children:[s.jsx("p",{className:"text-bambu-gray text-sm",children:e("settings.telemetryInfoIntro")}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoCollected")}),s.jsxs("ul",{className:"space-y-2 text-sm",children:[s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoItem1")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoItem2")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoItem3")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoItem4")})]})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoNotCollected")}),s.jsxs("ul",{className:"space-y-2 text-sm",children:[s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Sa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoNotItem1")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Sa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoNotItem2")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Sa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoNotItem3")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Sa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoNotItem4")})]})]})]}),s.jsx("p",{className:"text-bambu-gray text-xs border-t border-bambu-dark-tertiary pt-4",children:e("settings.telemetryInfoFooter")}),s.jsx(Ne,{onClick:()=>j(!1),className:"w-full",children:e("common.close")})]})]})}),ne&&Et?.release_notes&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>be(!1),children:s.jsxs(Mt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:Re=>Re.stopPropagation(),children:[s.jsxs(vi,{className:"flex flex-row items-center justify-between shrink-0",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",Et.latest_version]}),Et.release_name&&Et.release_name!==Et.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray",children:Et.release_name})]}),s.jsx("button",{onClick:()=>be(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsx(At,{className:"overflow-y-auto flex-1",children:s.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:Et.release_notes})}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[Et.release_url&&s.jsx("a",{href:Et.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:s.jsxs(Ne,{variant:"secondary",className:"w-full",children:[s.jsx(qr,{className:"w-4 h-4"}),"View on GitHub"]})}),s.jsx(Ne,{onClick:()=>be(!1),className:"flex-1",children:"Close"})]})]})})]})}const gne=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},FWe=t=>t.startsWith("HH")?"HF":"S",UWe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},nR=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 zk({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){const l=FWe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&a?a():e()};return s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?s.jsx(Md,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Ed,{className:"w-4 h-4"})}),s.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:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:gne(t.k_value)}),s.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),o&&s.jsx("span",{title:"Has note",children:s.jsx(sW,{className:"w-3 h-3 text-yellow-500"})}),s.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[l," ",c]})]}),o&&s.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:o,children:["Note: ",o.length>50?o.substring(0,50)+"...":o]})]}),!r&&n&&s.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:s.jsx(Wo,{className:"w-4 h-4"})})]})}function Bk({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:a="",initialNoteKey:o=null,onClose:l,onSave:c,onSaveNote:u}){const{showToast:d}=hr(),[f,g]=S.useState(t?.name||""),[p,x]=S.useState(t?.k_value?gne(t.k_value):"0.020"),[y,b]=S.useState(t?.filament_id||""),[v,E]=S.useState(t?.nozzle_id?UWe(t.nozzle_id):"HH00"),[w,N]=S.useState(t?.nozzle_diameter||n),[A,C]=S.useState(t?[t.extruder_id]:i?[0,1]:[0]),[T,L]=S.useState(!1),[k,D]=S.useState({current:0,total:0}),[U,O]=S.useState(a),q=kr.useMemo(()=>{const X=new Map;for(const F of r)if(F.filament_id&&!X.has(F.filament_id)){const W=nR(F.name||"");X.set(F.filament_id,{id:F.filament_id,name:W||F.filament_id})}return Array.from(X.values()).sort((F,W)=>F.name.localeCompare(W.name))},[r]),R=bt({mutationFn:X=>(console.log("[KProfile] Calling API..."),ye.setKProfile(e,X)),onSuccess:X=>{if(console.log("[KProfile] Save success:",X),d("K-profile saved"),u&&U!==a){let F;U===""&&o?F=o:t&&t.slot_id>0?F=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:F=`name_${f}_${y}`,u(F,U)}L(!0),setTimeout(()=>{L(!1),c()},2500)},onError:X=>{console.error("[KProfile] Save error:",X),d(X.message,"error"),L(!1)}}),G=bt({mutationFn:X=>(console.log("[KProfile] Deleting profile..."),ye.deleteKProfile(e,X)),onSuccess:X=>{console.log("[KProfile] Delete success:",X),d("K-profile deleted"),L(!0),setTimeout(()=>{L(!1),l()},4e3)},onError:X=>{console.error("[KProfile] Delete error:",X),d(X.message,"error"),L(!1)}}),[Y,V]=S.useState(!1),K=()=>{t&&G.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})},J=async X=>{if(X.preventDefault(),i&&!t&&A.length===0){d("Please select at least one extruder","error");return}const F=parseFloat(p).toFixed(6),W=`${v}-${w}`;if(t||A.length===1){const ie={name:f,k_value:F,filament_id:y,nozzle_id:W,nozzle_diameter:w,extruder_id:t?t.extruder_id:A[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",ie),R.mutate(ie);return}L(!0),D({current:1,total:A.length});const ee=A.map(ie=>({name:f,k_value:F,filament_id:y,nozzle_id:W,nozzle_diameter:w,extruder_id:ie,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${ee.length} profiles in batch:`,ee);try{if(await ye.setKProfilesBatch(e,ee),d(`K-profile saved to ${A.length} extruders`),u&&U){const ie=`name_${f}_${y}`;u(ie,U)}}catch(ie){console.error("[KProfile] Failed to save batch:",ie),d("Failed to save K-profiles","error"),L(!1),D({current:0,total:0});return}D({current:A.length,total:A.length}),setTimeout(()=>{L(!1),D({current:0,total:0}),c()},3e3)};return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[s.jsxs(Mt,{className:"w-full max-w-md relative",children:[T&&s.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:k.total>1?`Saving to extruder ${k.current}/${k.total}...`:"Syncing with printer..."}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),s.jsxs(At,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),s.jsx("button",{onClick:l,className:"text-bambu-gray hover:text-white transition-colors",disabled:T,children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:J,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),s.jsx("input",{type:"text",value:f,onChange:X=>g(X.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),s.jsx("input",{type:"text",inputMode:"decimal",value:p,onChange:X=>{const F=X.target.value;(F===""||/^\d*\.?\d*$/.test(F))&&x(F)},onBlur:X=>{const F=parseFloat(X.target.value);isNaN(F)||x((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}),s.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),s.jsxs("select",{value:y,onChange:X=>{const F=X.target.value;if(b(F),!t&&F&&!f){const W=q.find(ee=>ee.id===F);W&&g(`${v==="HH00"?"HF":"S"} ${W.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:[s.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&s.jsx("option",{value:t.filament_id,children:q.find(X=>X.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&q.map(X=>s.jsx("option",{value:X.id,children:X.name},X.id))]}),!t&&q.length===0&&s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),s.jsxs("select",{value:v,onChange:X=>{const F=X.target.value;if(E(F),!t&&y&&!f){const W=q.find(ee=>ee.id===y);W&&g(`${F==="HS00"?"HF":"S"} ${W.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:[s.jsx("option",{value:"HH00",children:"High Flow"}),s.jsx("option",{value:"HS00",children:"Standard"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),s.jsxs("select",{value:w,onChange:X=>N(X.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:[s.jsx("option",{value:"0.2",children:"0.2mm"}),s.jsx("option",{value:"0.4",children:"0.4mm"}),s.jsx("option",{value:"0.6",children:"0.6mm"}),s.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?s.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"}):s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:A.includes(1),onChange:X=>{X.target.checked?C([...A,1]):C(A.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"}),s.jsx("span",{className:"text-white",children:"Left"})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:A.includes(0),onChange:X=>{X.target.checked?C([...A,0]):C(A.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"}),s.jsx("span",{className:"text-white",children:"Right"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),s.jsx("textarea",{value:U,onChange:X=>O(X.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),s.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&s.jsx(Ne,{type:"button",variant:"secondary",onClick:()=>V(!0),disabled:G.isPending||T,className:"text-red-500 hover:bg-red-500/10",children:G.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(_n,{className:"w-4 h-4"})}),s.jsx(Ne,{type:"button",variant:"secondary",onClick:l,disabled:T,className:"flex-1",children:"Cancel"}),s.jsxs(Ne,{type:"submit",disabled:R.isPending||T,className:"flex-1",children:[R.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(cM,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),Y&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:s.jsx(Mt,{className:"w-full max-w-sm",children:s.jsxs(At,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:s.jsx(_n,{className:"w-5 h-5 text-red-500"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),s.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",s.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Ne,{variant:"secondary",onClick:()=>V(!1),className:"flex-1",children:"Cancel"}),s.jsxs(Ne,{onClick:()=>{V(!1),K()},disabled:G.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[G.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(_n,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const f1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function zWe(){const{showToast:t}=hr(),[e,n]=S.useState(null),[r,i]=S.useState(()=>localStorage.getItem(f1.NOZZLE_DIAMETER)||"0.4"),[a,o]=S.useState(null),[l,c]=S.useState(!1),[u,d]=S.useState(null),[f,g]=S.useState(""),[p,x]=S.useState("all"),[y,b]=S.useState("all"),[v,E]=S.useState(()=>localStorage.getItem(f1.SORT_OPTION)||"name"),[w,N]=S.useState(!1),[A,C]=S.useState(new Set),[T,L]=S.useState(!1),[k,D]=S.useState(!1),U=B=>`${B.slot_id}_${B.extruder_id}`;S.useEffect(()=>{localStorage.setItem(f1.NOZZLE_DIAMETER,r)},[r]),S.useEffect(()=>{localStorage.setItem(f1.SORT_OPTION,v)},[v]);const{data:O,isLoading:q}=ft({queryKey:["printers"],queryFn:ye.getPrinters}),{data:R,isLoading:G,isFetching:Y,error:V,refetch:K}=ft({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const B=await ye.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",B?.profiles?.length||0,"profiles"),B},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:J}=ft({queryKey:["kprofiles",e,"0.4"],queryFn:()=>ye.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:X,refetch:F}=ft({queryKey:["kprofile-notes",e],queryFn:()=>ye.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),W=V?.message?.includes("not connected");S.useEffect(()=>{if(!e&&O&&O.length>0){const B=O.find(Q=>Q.is_active);B&&n(B.id)}},[e,O]),S.useEffect(()=>{if(e){const B=setTimeout(()=>{K()},150);return()=>clearTimeout(B)}},[e,r]);const ee=O?.filter(B=>B.is_active)||[],ie=kr.useMemo(()=>R?.profiles?R.profiles.filter(Q=>{const ce=f.toLowerCase(),Ce=!ce||Q.name.toLowerCase().includes(ce)||Q.filament_id.toLowerCase().includes(ce),_e=p==="all"||p==="left"&&Q.extruder_id===1||p==="right"&&Q.extruder_id===0,Ee=y==="all"||y==="hf"&&Q.nozzle_id.startsWith("HH")||y==="s"&&Q.nozzle_id.startsWith("HS");return Ce&&_e&&Ee}).sort((Q,ce)=>{switch(v){case"k_value":return parseFloat(Q.k_value)-parseFloat(ce.k_value);case"filament":return nR(Q.name).localeCompare(nR(ce.name));case"name":default:return Q.name.localeCompare(ce.name)}}):[],[R?.profiles,f,p,y,v]),ae=O?.find(B=>B.id===e),de=ae?.nozzle_count===2;S.useEffect(()=>{const B=Q=>{Q.target instanceof HTMLInputElement||Q.target instanceof HTMLTextAreaElement||Q.target instanceof HTMLSelectElement||a||l||u||(Q.key==="r"||Q.key==="R"?(Q.preventDefault(),K()):Q.key==="n"||Q.key==="N"?(Q.preventDefault(),c(!0)):Q.key==="Escape"&&w&&(Q.preventDefault(),N(!1),C(new Set)))};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[a,l,u,w,K]);const ue=S.useCallback(()=>{if(!R?.profiles||R.profiles.length===0){t("No profiles to export","error");return}const B={version:1,exported_at:new Date().toISOString(),printer:ae?.name||"Unknown",nozzle_diameter:r,profiles:R.profiles.map(_e=>({name:_e.name,k_value:_e.k_value,filament_id:_e.filament_id,nozzle_id:_e.nozzle_id,nozzle_diameter:_e.nozzle_diameter,extruder_id:_e.extruder_id}))},Q=new Blob([JSON.stringify(B,null,2)],{type:"application/json"}),ce=URL.createObjectURL(Q),Ce=document.createElement("a");Ce.href=ce,Ce.download=`kprofiles_${ae?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Ce),Ce.click(),document.body.removeChild(Ce),URL.revokeObjectURL(ce),t(`Exported ${R.profiles.length} profiles`)},[R?.profiles,ae,r,t]),le=S.useCallback(()=>{const B=document.createElement("input");B.type="file",B.accept=".json",B.onchange=async Q=>{const ce=Q.target.files?.[0];if(ce)try{const Ce=await ce.text(),_e=JSON.parse(Ce);if(!_e.profiles||!Array.isArray(_e.profiles)){t("Invalid file format","error");return}let Ee=0;for(const $ of _e.profiles)if(!(!$.name||!$.k_value||!$.filament_id))try{await ye.setKProfile(e,{name:$.name,k_value:parseFloat($.k_value).toFixed(6),filament_id:$.filament_id,nozzle_id:$.nozzle_id||`HH00-${r}`,nozzle_diameter:$.nozzle_diameter||r,extruder_id:$.extruder_id??0,slot_id:0}),Ee++,await new Promise(j=>setTimeout(j,500))}catch(j){console.error("Failed to import profile:",$.name,j)}t(`Imported ${Ee} of ${_e.profiles.length} profiles`),K()}catch(Ce){console.error("Import error:",Ce),t("Failed to parse import file","error")}},B.click()},[e,r,t,K]),he=S.useCallback(B=>{C(Q=>{const ce=new Set(Q);return ce.has(B)?ce.delete(B):ce.add(B),ce})},[]),pe=S.useCallback(()=>{C(new Set(ie.map(B=>U(B))))},[ie,U]),Me=S.useCallback(()=>{A.size!==0&&L(!0)},[A.size]),re=S.useCallback(async()=>{const B=ie.filter(ce=>A.has(U(ce)));D(!0);let Q=0;for(const ce of B)try{await ye.deleteKProfile(e,{slot_id:ce.slot_id,extruder_id:ce.extruder_id,nozzle_id:ce.nozzle_id,nozzle_diameter:ce.nozzle_diameter,filament_id:ce.filament_id,setting_id:ce.setting_id}),Q++,await new Promise(Ce=>setTimeout(Ce,300))}catch(Ce){console.error("Failed to delete profile:",ce.name,Ce)}t(`Deleted ${Q} profiles`),D(!1),L(!1),N(!1),C(new Set),K()},[e,A,ie,t,K,U]),We=S.useCallback(B=>{const Q=[];return B.setting_id&&Q.push(B.setting_id),Q.push(`slot_${B.slot_id}_${B.filament_id}_${B.extruder_id}`),Q.push(`name_${B.name}_${B.filament_id}`),Q},[]),z=S.useCallback(async(B,Q)=>{if(e)try{await ye.setKProfileNote(e,B,Q),F()}catch(ce){console.error("Failed to save note:",ce),t("Failed to save note","error")}},[e,F,t]),H=S.useCallback(B=>{if(!X?.notes)return{note:"",key:null};const Q=We(B);for(const ce of Q)if(X.notes[ce])return{note:X.notes[ce],key:ce};return{note:"",key:null}},[X,We]),se=S.useCallback(B=>H(B).note,[H]);return q?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!O||O.length===0?s.jsx(Mt,{children:s.jsxs(At,{className:"py-12 text-center",children:[s.jsx(Aa,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),s.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):ee.length===0?s.jsx(Mt,{children:s.jsxs(At,{className:"py-12 text-center",children:[s.jsx(Ei,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),s.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):s.jsxs(s.Fragment,{children:[Y&&!G&&s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[s.jsx(xt,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[s.jsxs("div",{className:"flex-1 min-w-48",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),s.jsx("select",{value:e||"",onChange:B=>n(parseInt(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",children:ee.map(B=>s.jsx("option",{value:B.id,children:B.name},B.id))})]}),s.jsxs("div",{className:"w-32",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),s.jsxs("select",{value:r,onChange:B=>i(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",children:[s.jsx("option",{value:"0.2",children:"0.2mm"}),s.jsx("option",{value:"0.4",children:"0.4mm"}),s.jsx("option",{value:"0.6",children:"0.6mm"}),s.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsxs(Ne,{variant:"secondary",onClick:()=>K(),disabled:Y,children:[s.jsx(Gr,{className:`w-4 h-4 ${Y?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Ne,{onClick:()=>c(!0),children:[s.jsx(pr,{className:"w-4 h-4"}),"Add Profile"]})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[s.jsxs("div",{className:"flex-1 min-w-48 relative",children:[s.jsx(Ml,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:f,onChange:B=>g(B.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"})]}),de&&s.jsx("div",{className:"w-36",children:s.jsxs("select",{value:p,onChange:B=>x(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",children:[s.jsx("option",{value:"all",children:"All Extruders"}),s.jsx("option",{value:"left",children:"Left Only"}),s.jsx("option",{value:"right",children:"Right Only"})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:y,onChange:B=>b(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",children:[s.jsx("option",{value:"all",children:"All Flow"}),s.jsx("option",{value:"hf",children:"HF Only"}),s.jsx("option",{value:"s",children:"S Only"})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:v,onChange:B=>E(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",children:[s.jsx("option",{value:"name",children:"Sort: Name"}),s.jsx("option",{value:"k_value",children:"Sort: K-Value"}),s.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[s.jsxs(Ne,{variant:"secondary",onClick:ue,disabled:!R?.profiles?.length,title:"Export profiles to JSON",children:[s.jsx(Mi,{className:"w-4 h-4"}),"Export"]}),s.jsxs(Ne,{variant:"secondary",onClick:le,title:"Import profiles from JSON",children:[s.jsx(qi,{className:"w-4 h-4"}),"Import"]}),s.jsx("div",{className:"flex-1"}),w?s.jsxs(s.Fragment,{children:[s.jsxs(Ne,{variant:"secondary",onClick:pe,title:"Select all visible profiles",children:[s.jsx(Md,{className:"w-4 h-4"}),"Select All"]}),s.jsxs(Ne,{variant:"secondary",onClick:Me,disabled:A.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${A.size} selected profiles`,children:[s.jsx(_n,{className:"w-4 h-4"}),"Delete (",A.size,")"]}),s.jsxs(Ne,{variant:"secondary",onClick:()=>{N(!1),C(new Set)},children:[s.jsx(Bt,{className:"w-4 h-4"}),"Cancel"]})]}):s.jsxs(Ne,{variant:"secondary",onClick:()=>N(!0),disabled:!ie.length,title:"Enter selection mode for bulk delete",children:[s.jsx(Md,{className:"w-4 h-4"}),"Select"]})]}),G?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):W?s.jsx(Mt,{children:s.jsxs(At,{className:"py-12 text-center",children:[s.jsx(Db,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),s.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),s.jsxs(Ne,{variant:"secondary",onClick:()=>K(),children:[s.jsx(Gr,{className:"w-4 h-4"}),"Retry"]})]})}):ie.length>0?de?s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),s.jsx("div",{className:"space-y-1",children:ie.filter(B=>B.extruder_id===1).map(B=>s.jsx(zk,{profile:B,onEdit:()=>o(B),onCopy:()=>d(B),selectionMode:w,isSelected:A.has(U(B)),onToggleSelect:()=>he(U(B)),note:se(B)},U(B)))})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),s.jsx("div",{className:"space-y-1",children:ie.filter(B=>B.extruder_id===0).map(B=>s.jsx(zk,{profile:B,onEdit:()=>o(B),onCopy:()=>d(B),selectionMode:w,isSelected:A.has(U(B)),onToggleSelect:()=>he(U(B)),note:se(B)},U(B)))})]})]}):s.jsx("div",{className:"space-y-1",children:ie.map(B=>s.jsx(zk,{profile:B,onEdit:()=>o(B),onCopy:()=>d(B),selectionMode:w,isSelected:A.has(U(B)),onToggleSelect:()=>he(U(B)),note:se(B)},U(B)))}):f||p!=="all"||y!=="all"?s.jsx(Mt,{children:s.jsxs(At,{className:"py-12 text-center",children:[s.jsx(Ml,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),s.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):s.jsx(Mt,{children:s.jsxs(At,{className:"py-12 text-center",children:[s.jsx(cM,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),s.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),s.jsxs(Ne,{onClick:()=>c(!0),children:[s.jsx(pr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:B,key:Q}=H(a);return s.jsx(Bk,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:J?.profiles||R?.profiles,isDualNozzle:de,initialNote:B,initialNoteKey:Q,onSaveNote:z,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),o(null),K()},onSave:()=>{o(null),K()}})})(),l&&e&&s.jsx(Bk,{printerId:e,nozzleDiameter:r,existingProfiles:J?.profiles||R?.profiles,isDualNozzle:de,onSaveNote:z,onClose:()=>{c(!1),K()},onSave:()=>{c(!1),K()}}),u&&e&&s.jsx(Bk,{printerId:e,nozzleDiameter:r,existingProfiles:J?.profiles||R?.profiles,isDualNozzle:de,onSaveNote:z,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),K()},onSave:()=>{d(null),K()}}),T&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Mt,{className:"w-full max-w-sm",children:s.jsxs(At,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:s.jsx(_n,{className:"w-5 h-5 text-red-500"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),s.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",s.jsx("span",{className:"text-white font-medium",children:A.size})," selected profiles from the printer?"]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Ne,{variant:"secondary",onClick:()=>L(!1),disabled:k,className:"flex-1",children:"Cancel"}),s.jsxs(Ne,{onClick:re,disabled:k,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[k?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(_n,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function J4(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),o=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:o,layerHeight:c,filamentType:d}}function Nb(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function BWe(t){const e=ui(t);if(!e)return"";const r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),a=Math.floor(r/36e5),o=Math.floor(r/864e5);return i<1?"Just now":i<60?`${i}m ago`:a<24?`${a}h ago`:o<7?`${o}d ago`:e.toLocaleDateString()}function HWe({onSuccess:t}){const{showToast:e}=hr(),[n,r]=S.useState("email"),[i,a]=S.useState(""),[o,l]=S.useState(""),[c,u]=S.useState(""),[d,f]=S.useState(""),[g,p]=S.useState("global"),x=bt({mutationFn:()=>ye.cloudLogin(i,o,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")}),y=bt({mutationFn:()=>ye.cloudVerify(i,c),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>e(w.message,"error")}),b=bt({mutationFn:()=>ye.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>e(w.message,"error")}),v=w=>{w.preventDefault(),n==="email"?x.mutate():n==="code"?y.mutate():n==="token"&&b.mutate()},E=x.isPending||y.isPending||b.isPending;return s.jsx(Mt,{className:"max-w-md mx-auto",children:s.jsxs(At,{children:[s.jsxs("div",{className:"text-center mb-6",children:[s.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:s.jsx(oM,{className:"w-6 h-6 text-bambu-green"})}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),s.jsxs("form",{onSubmit:v,className:"space-y-4",children:[n==="email"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),s.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),s.jsx("input",{type:"password",value:o,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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),s.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:[s.jsx("option",{value:"global",children:"Global"}),s.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),s.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"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),s.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})]}),s.jsxs("div",{className:"flex gap-2",children:[n==="code"&&s.jsx(Ne,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),s.jsxs(Ne,{type:"submit",disabled:E,className:"flex-1",children:[E?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(PU,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx(lp,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx(PU,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function ep({label:t,value:e,options:n,onChange:r}){const[i,a]=S.useState(!1),o=n.find(l=>l.value===e);return s.jsxs("div",{className:"relative",children:[s.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:[s.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),s.jsx("span",{children:o?.label||"All"}),s.jsx(Ga,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),s.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=>s.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:[s.jsx("span",{children:l.label}),l.count!==void 0&&s.jsx("span",{className:"text-bambu-gray text-xs",children:l.count})]},l.value))})]})]})}function $We(){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?s.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:s.jsx(Cp,{className:"w-5 h-5"})}):null}function Hk({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o}){const l=J4(t.name),c=Nb(t.setting_id);return s.jsxs("div",{className:"flex items-center gap-2 group",children:[s.jsx("button",{onClick:e,disabled:o,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":o?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!o?"cursor-pointer":""}`,children:s.jsxs("div",{className:"flex items-center gap-2",children:[i&&a!==void 0&&s.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&&s.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),s.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),l.filamentType&&t.type==="filament"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.filamentType}),l.layerHeight&&t.type==="process"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.layerHeight}),l.printer&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.printer})]})}),s.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:s.jsx(Wo,{className:"w-4 h-4"})})]})}function rR(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+" "+rR(i,e+1)).join(`,
  8286. `)+`
  8287. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
  8288. `+r.map(([a,o])=>n+" "+JSON.stringify(a)+": "+rR(o,e+1)).join(`,
  8289. `)+`
  8290. `+n+"}"}return String(t)}function VWe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=hr(),o=cn(),[l,c]=S.useState(!1),{data:u,isLoading:d}=ft({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>ye.getCloudSettingDetail(t.setting_id)}),f=bt({mutationFn:()=>ye.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),o.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:x=>a(x.message,"error")}),g=Nb(t.setting_id),p=J4(t.name,u?.setting?.inherits);return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(Mt,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:s.jsxs(At,{className:"p-0 flex flex-col min-h-0 flex-1",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),g&&s.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[s.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),p.printer&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"•"}),s.jsx("span",{children:p.printer})]})]})]}),s.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:d?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?s.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:rR(u)}):s.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),l?s.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[s.jsx(zn,{className:"w-5 h-5"}),s.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),s.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ne,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),s.jsxs(Ne,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):s.jsx(_n,{className:"w-4 h-4"}),"Delete"]})]})]}):s.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ne,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),s.jsxs(Ne,{variant:"secondary",onClick:r,children:[s.jsx(Wo,{className:"w-4 h-4"}),"Duplicate"]}),g&&s.jsxs(s.Fragment,{children:[s.jsxs(Ne,{variant:"secondary",onClick:i,disabled:d||!u,children:[s.jsx(qo,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Ne,{variant:"danger",onClick:()=>c(!0),children:s.jsx(_n,{className:"w-4 h-4"})})]})]})})]})})})}function xne(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function bne(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function GWe({onClose:t,onApply:e}){const{showToast:n}=hr(),[r,i]=S.useState(xne),[a,o]=S.useState("all"),[l,c]=S.useState(null),[u,d]=S.useState(""),[f,g]=S.useState(""),[p,x]=S.useState("{}"),[y,b]=S.useState(null),[v,E]=S.useState(null),w=a==="all"?r:r.filter(O=>O.type===a),N=O=>{i(O),bne(O)},A=O=>{const q=r.filter(R=>R.id!==O);N(q),E(null),n("Template deleted")},C=O=>{c(O.id),d(O.name),g(O.description),x(JSON.stringify(O.settings,null,2)),b(null)},T=()=>{if(!(!l||!u.trim()))try{const O=JSON.parse(p),q=r.map(R=>R.id===l?{...R,name:u.trim(),description:f.trim(),settings:O}:R);N(q),c(null),n("Template updated")}catch(O){b(O.message)}},L=()=>{c(null),d(""),g(""),x("{}"),b(null)},k=O=>{const q=r.map(R=>R.id===O?{...R,showInModal:!R.showInModal}:R);N(q)},D={filament:{label:"Filament",icon:gR,color:"text-amber-400"},print:{label:"Process",icon:dM,color:"text-blue-400"},printer:{label:"Printer",icon:Ei,color:"text-purple-400"}},U=v?r.find(O=>O.id===v):null;return S.useEffect(()=>{const O=q=>{q.key==="Escape"&&(v?E(null):l?L():t())};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[v,l,t]),s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[U&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:s.jsx(Mt,{className:"w-full max-w-md",children:s.jsxs(At,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:s.jsx(zn,{className:"w-6 h-6 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),s.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',s.jsx("span",{className:"font-medium",children:U.name}),'"?']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ne,{variant:"secondary",onClick:()=>E(null),className:"flex-1",children:"Cancel"}),s.jsxs(Ne,{onClick:()=>A(v),className:"flex-1 bg-red-500 hover:bg-red-600",children:[s.jsx(_n,{className:"w-4 h-4"}),"Delete"]})]})]})})}),s.jsx(Mt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:s.jsxs(At,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(z0,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(O=>s.jsx("button",{onClick:()=>o(O),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===O?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:O==="all"?"All":D[O].label},O))]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:w.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(z0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:"No templates yet"}),s.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):s.jsx("div",{className:"space-y-2",children:w.map(O=>{const q=D[O.type],R=q.icon;return l===O.id?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[s.jsx("input",{type:"text",value:u,onChange:G=>d(G.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}),s.jsx("input",{type:"text",value:f,onChange:G=>g(G.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"})]}),s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),s.jsx("textarea",{value:p,onChange:G=>{x(G.target.value),b(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 ${y?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),y&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:y})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Ne,{size:"sm",onClick:T,disabled:!u.trim(),children:[s.jsx(ks,{className:"w-4 h-4"}),"Save"]}),s.jsx(Ne,{size:"sm",variant:"secondary",onClick:L,children:"Cancel"})]})]},O.id):s.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:[s.jsx(R,{className:`w-5 h-5 ${q.color} flex-shrink-0`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:O.name}),s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:O.description})]}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(O.settings).length," fields"]}),s.jsx("button",{onClick:()=>k(O.id),className:`p-1 transition-colors ${O.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:O.showInModal?"Shown in modals":"Hidden in modals",children:O.showInModal?s.jsx(af,{className:"w-4 h-4"}):s.jsx(lM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>e(O),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),s.jsx("button",{onClick:()=>C(O),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:s.jsx(qo,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E(O.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:s.jsx(_n,{className:"w-4 h-4"})})]},O.id)})})})]})})]})}function yne({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[a,o]=S.useState("changes"),[l,c]=S.useState(""),u=S.useMemo(()=>{const p=new Set([...Object.keys(e),...Object.keys(n)]),x=[];for(const y of p){if(y==="inherits"||y==="version")continue;const b=e[y],v=n[y],E=y in e,w=y in n;let N;!E&&w?N="added":E&&!w?N="removed":JSON.stringify(b)!==JSON.stringify(v)?N="changed":N="same",x.push({key:y,left:b,right:v,status:N})}return x.sort((y,b)=>{const v={changed:0,added:1,removed:2,same:3};return v[y.status]!==v[b.status]?v[y.status]-v[b.status]:y.key.localeCompare(b.key)})},[e,n]),d=S.useMemo(()=>{let p=[...u];if(a==="changes"&&(p=p.filter(x=>x.status!=="same")),l){const x=l.toLowerCase();p=p.filter(y=>y.key.toLowerCase().includes(x)||String(y.left).toLowerCase().includes(x)||String(y.right).toLowerCase().includes(x))}return p},[u,a,l]),f=S.useMemo(()=>({added:u.filter(p=>p.status==="added").length,removed:u.filter(p=>p.status==="removed").length,changed:u.filter(p=>p.status==="changed").length,same:u.filter(p=>p.status==="same").length}),[u]),g=p=>{if(p===void 0)return"—";if(p===null)return"null";if(Array.isArray(p))return p.length===0?"[]":p.length===1?String(p[0]):p.join(", ");if(typeof p=="object")return JSON.stringify(p);const x=String(p);if(x.includes("\\n")||x.length>100){const y=x.split("\\n").length;if(y>1)return`[${y} lines of G-code/script]`;if(x.length>100)return x.substring(0,100)+"…"}return x};return S.useEffect(()=>{const p=x=>{x.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsx(Mt,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:s.jsxs(At,{className:"p-0 flex flex-col min-h-0 flex-1",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(gp,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(Bt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),s.jsx("p",{className:"text-white font-medium truncate",children:r})]}),s.jsxs("div",{className:"text-center",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),s.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(pr,{className:"w-3.5 h-3.5"}),f.added," added"]}),s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(c3,{className:"w-3.5 h-3.5"}),f.removed," removed"]}),s.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[s.jsx(i3,{className:"w-3.5 h-3.5"}),f.changed," changed"]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[s.jsx(rN,{className:"w-3.5 h-3.5"}),f.same," same"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Ml,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.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&&s.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>o("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"}),s.jsx("button",{onClick:()=>o("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"})]})]})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(rN,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:a==="changes"?"No differences found":"No fields match the search"})]}):s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:s.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[s.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),s.jsx("th",{className:"text-left p-3 w-1/3",children:r}),s.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),s.jsx("tbody",{children:d.map(p=>{const x={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[p.status],y={added:s.jsx(pr,{className:"w-3.5 h-3.5 text-green-400"}),removed:s.jsx(c3,{className:"w-3.5 h-3.5 text-red-400"}),changed:s.jsx(i3,{className:"w-3.5 h-3.5 text-amber-400"}),same:s.jsx(rN,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[p.status];return s.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${x}`,children:[s.jsx("td",{className:"p-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[y,s.jsx("span",{className:"text-sm text-white font-mono",children:p.key})]})}),s.jsx("td",{className:"p-3",children:s.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)})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${p.status==="added"?"text-green-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(p.right)})})]},p.key)})})]})})]})})})}function WWe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=hr(),i=cn(),a=!!e?.setting_id,[o,l]=S.useState("common"),[c,u]=S.useState(e?.type||"filament"),[d,f]=S.useState(e?.name?a?e.name:`${e.name} (Copy)`:""),[g,p]=S.useState(e?.base_id||""),[x,y]=S.useState(""),[b,v]=S.useState(e?.setting||{inherits:""}),[E,w]=S.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[N,A]=S.useState(null),[C,T]=S.useState(""),[L,k]=S.useState(!1),[D,U]=S.useState(""),[O,q]=S.useState(!1),[R,G]=S.useState(xne),[Y,V]=S.useState(!1),[K,J]=S.useState(""),[X,F]=S.useState(""),[W,ee]=S.useState(!0),[ie,ae]=S.useState(null),[de,ue]=S.useState(!1),le=S.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),he=S.useMemo(()=>le.filter(me=>Nb(me.setting_id)),[le]),{data:pe}=ft({queryKey:["cloudFields",c],queryFn:()=>ye.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:Me}=ft({queryKey:["allPresetDetails",c,he.map(me=>me.setting_id).join(",")],queryFn:async()=>{const me={};for(let Ke=0;Ke<he.length;Ke+=5){const Ze=he.slice(Ke,Ke+5);(await Promise.all(Ze.map(async te=>{try{const Fe=await ye.getCloudSettingDetail(te.setting_id);return{id:te.setting_id,detail:Fe}}catch{return null}}))).forEach(te=>{te&&(me[te.id]=te.detail)})}return me},enabled:he.length>0,staleTime:1e3*60*10}),{data:re,isLoading:We}=ft({queryKey:["cloudSettingDetail",g],queryFn:()=>ye.getCloudSettingDetail(g),enabled:!!g});S.useEffect(()=>{o!=="json"&&w(JSON.stringify(b,null,2))},[b,o]);const z=S.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(Je=>!Nb(Je.setting_id)).sort((Je,Ke)=>Je.name.localeCompare(Ke.name)),[n,c]);S.useEffect(()=>{if(!g)return;const me=z.find(Je=>Je.setting_id===g);me&&(y(me.name),a||(v({inherits:me.name}),w(JSON.stringify({inherits:me.name},null,2))))},[g,z,a]);const H=S.useMemo(()=>{const me=pe?.fields||[],Je=new Set(me.map(te=>te.key)),Ke=new Set,Ze=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);Me&&Object.values(Me).forEach(te=>{te?.setting&&Object.keys(te.setting).forEach(Fe=>{!Je.has(Fe)&&!Ze.has(Fe)&&Ke.add(Fe)})}),Object.keys(b).forEach(te=>{!Je.has(te)&&!Ze.has(te)&&Ke.add(te)});const ct=Array.from(Ke).sort().map(te=>({key:te,label:te.replace(/_/g," ").replace(/\b\w/g,Fe=>Fe.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...me,...ct]},[pe,Me,b]),se=H.filter(me=>me.label.toLowerCase().includes(C.toLowerCase())||me.key.toLowerCase().includes(C.toLowerCase())),B=()=>{if(D.trim()){const me=D.trim().toLowerCase().replace(/\s+/g,"_");Q(me,""),U(""),q(!1),r(`Field "${me}" added`)}},Q=(me,Je)=>{v(Ke=>{const Ze={...Ke};return Je===""||Je===void 0?delete Ze[me]:Ze[me]=Je,Ze})},ce=me=>{v(Je=>({...Je,...me.settings})),ae(me.name),r("Template applied")},Ce=()=>{if(!K.trim())return;const me={...b};if(delete me.inherits,Object.keys(me).length===0){r("No overrides to save","error");return}const Je={id:Date.now().toString(),name:K.trim(),description:X.trim()||"Custom template",type:c,settings:me,showInModal:W},Ke=[...R,Je];G(Ke),bne(Ke),V(!1),J(""),F(""),ee(!0),r("Template saved")},_e=S.useMemo(()=>R.filter(me=>me.type===c&&me.showInModal),[c,R]),Ee=me=>{w(me);try{const Je=JSON.parse(me);v(Je),A(null)}catch(Je){A(Je.message)}},$=me=>{me.preventDefault(),k(!1);const Je=me.dataTransfer.files[0];if(Je&&Je.name.endsWith(".json")){const Ke=new FileReader;Ke.onload=Ze=>{try{const ct=Ze.target?.result,te=JSON.parse(ct),Fe=te.setting||te;v(xe=>({...xe,...Fe})),w(JSON.stringify({...b,...Fe},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},Ke.readAsText(Je)}},j=bt({mutationFn:()=>{const me={...b},Je=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";me[Je]=`"${d}"`;const Ke={type:c,name:d,base_id:g,setting:me};return ye.createCloudSetting(Ke)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:me=>r(me.message,"error")}),ne=bt({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return ye.updateCloudSetting(e.setting_id,{name:d,setting:b})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:me=>r(me.message,"error")}),be=a?ne:j,we=re?.setting?.inherits,ve=we?z.find(me=>me.name===we):void 0,{data:$e}=ft({queryKey:["cloudSettingDetail",ve?.setting_id],queryFn:()=>ye.getCloudSettingDetail(ve.setting_id),enabled:!!ve?.setting_id}),Ge=S.useMemo(()=>{const me=$e?.setting||{},Je=re?.setting||{},Ke=g&&Me?.[g]?.setting?Me[g].setting:{};return{...me,...Je,...Ke}},[g,re,$e,Me]),Xe=me=>{if(me==null)return"";if(Array.isArray(me)){const Je=[...new Set(me.map(Ke=>String(Ke)))];return Je.length===1?Je[0]:me.join(", ")}return String(me)},ut=me=>{const Je=b[me.key],Ke=Ge[me.key],Ze=Xe(Ke),ct=We?"Loading...":Ze||"",te="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(me.type==="boolean"){const Fe=Je==="1"||Je===void 0&&Ke==="1";return s.jsx("button",{type:"button",onClick:()=>Q(me.key,Je==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Fe?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Fe?"translate-x-3.5":"translate-x-0.5"}`})})}return me.type==="select"?s.jsxs("select",{value:Je||"",onChange:Fe=>Q(me.key,Fe.target.value),className:te,children:[s.jsx("option",{value:"",children:ct}),me.options?.map(Fe=>s.jsx("option",{value:Fe.value,children:Fe.label},Fe.value))]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:me.type==="number"?"number":"text",value:Je!==void 0?String(Je):"",onChange:Fe=>Q(me.key,Fe.target.value),step:me.step,min:me.min,max:me.max,placeholder:ct,className:te}),me.unit&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:me.unit})]})},He=S.useMemo(()=>re?.setting?re.setting:{},[re]);return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:me=>{me.preventDefault(),k(!0)},onDragLeave:()=>k(!1),onDrop:$,children:[de&&g&&s.jsx(yne,{onClose:()=>ue(!1),leftPreset:He,rightPreset:b,leftLabel:`Base: ${x||g}`,rightLabel:`Current: ${d||"New Preset"}`}),s.jsx(Mt,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:s.jsxs(At,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:a?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[g&&s.jsxs("button",{onClick:()=>ue(!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:[s.jsx(gp,{className:"w-4 h-4"}),"Compare"]}),s.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Bt,{className:"w-5 h-5"})})]})]}),L&&s.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:s.jsxs("div",{className:"text-center",children:[s.jsx(qi,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),s.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),s.jsxs("select",{value:c,onChange:me=>{u(me.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:[s.jsx("option",{value:"filament",children:"Filament"}),s.jsx("option",{value:"print",children:"Process"}),s.jsx("option",{value:"printer",children:"Printer"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),s.jsxs("select",{value:g,onChange:me=>p(me.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:[s.jsx("option",{value:"",children:"Select base preset..."}),z.map(me=>s.jsx("option",{value:me.setting_id,children:me.name},me.setting_id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),s.jsx("input",{type:"text",value:d,onChange:me=>f(me.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),x&&s.jsx("div",{className:"text-xs text-bambu-gray",children:s.jsxs("p",{className:"flex items-center gap-1",children:[s.jsx(Ls,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",s.jsx("span",{className:"text-white",children:x}),We&&s.jsx(xt,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[s.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 ${o==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(jU,{className:"w-4 h-4"}),"Common"]}),s.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 ${o==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(SR,{className:"w-4 h-4"}),"All Fields"]}),s.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 ${o==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(Q9,{className:"w-4 h-4"}),"JSON",N&&s.jsx(Aa,{className:"w-3 h-3 text-red-400"})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("button",{onClick:()=>{const me={name:d,type:c,base_id:g,setting:b},Je=new Blob([JSON.stringify(me,null,2)],{type:"application/json"}),Ke=URL.createObjectURL(Je),Ze=document.createElement("a");Ze.href=Ke,Ze.download=`${d||"preset"}.json`,document.body.appendChild(Ze),Ze.click(),document.body.removeChild(Ze),URL.revokeObjectURL(Ke),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:[s.jsx(Mi,{className:"w-4 h-4"}),"Export"]}),s.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:[s.jsx(qi,{className:"w-4 h-4"}),"Import"]}),s.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:me=>{const Je=me.target.files?.[0];if(Je){const Ke=new FileReader;Ke.onload=Ze=>{try{const ct=JSON.parse(Ze.target?.result),te=ct.setting||ct;v(Fe=>({...Fe,...te})),r("File imported")}catch{r("Invalid JSON","error")}},Ke.readAsText(Je)}}})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[o==="common"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(z0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(b).filter(me=>me!=="inherits").length>0&&s.jsxs("button",{onClick:()=>V(!Y),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[s.jsx(ks,{className:"w-3 h-3"}),"Save as template"]})]}),Y&&s.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[s.jsx("input",{type:"text",value:K,onChange:me=>J(me.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}),s.jsx("input",{type:"text",value:X,onChange:me=>F(me.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"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Ne,{size:"sm",onClick:Ce,disabled:!K.trim(),children:[s.jsx(ks,{className:"w-3 h-3"}),"Save"]}),s.jsx(Ne,{size:"sm",variant:"secondary",onClick:()=>V(!1),children:"Cancel"})]}),s.jsxs("button",{onClick:()=>ee(!W),className:`flex items-center gap-1.5 text-xs transition-colors ${W?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[W?s.jsx(af,{className:"w-3.5 h-3.5"}):s.jsx(lM,{className:"w-3.5 h-3.5"}),W?"Show in modals":"Hidden in modals"]})]})]}),ie&&s.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:[s.jsx(Ls,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",s.jsx("span",{className:"font-medium",children:ie})]}),s.jsx("button",{onClick:()=>ae(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:s.jsx(Bt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[_e.map(me=>s.jsxs("button",{onClick:()=>ce(me),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:me.name}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:me.description})]},me.id)),_e.length===0&&s.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."})]}),s.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),s.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:H.slice(0,10).map(me=>s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:me.label}),s.jsx("div",{className:"w-48",children:ut(me)})]},me.key))})]}),Object.keys(b).length>1&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(b).filter(([me])=>me!=="inherits").map(([me,Je])=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[me,": ",String(Je).slice(0,20),s.jsx("button",{onClick:()=>Q(me,void 0),className:"hover:text-white",children:s.jsx(Bt,{className:"w-3 h-3"})})]},me))})]})]}),o==="fields"&&s.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:Me?`${H.length} fields`:"Loading..."})]}),s.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[s.jsx(Ml,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:C,onChange:me=>T(me.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"})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[se.filter(me=>!(me.key in b)).map(me=>{const Je=Ge[me.key],Ke=Xe(Je);return s.jsxs("div",{onClick:()=>{v(Ze=>({...Ze,[me.key]:Ke||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm text-white truncate",children:me.label}),s.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:me.key})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[Ke&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:Ke,children:[Ke.slice(0,20),Ke.length>20?"...":""]}),s.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:s.jsx(pr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},me.key)}),se.filter(me=>!(me.key in b)).length===0&&s.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:C?"No matching fields":"All fields added"})]}),s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:O?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:D,onChange:me=>U(me.target.value),onKeyDown:me=>me.key==="Enter"&&B(),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}),s.jsx(Ne,{size:"sm",onClick:B,disabled:!D.trim(),children:s.jsx(pr,{className:"w-4 h-4"})}),s.jsx(Ne,{size:"sm",variant:"secondary",onClick:()=>{q(!1),U("")},children:s.jsx(Bt,{className:"w-4 h-4"})})]}):s.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:[s.jsx(pr,{className:"w-4 h-4"}),"Add custom field"]})})]}),s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(b).filter(me=>me!=="inherits").length," fields"]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(b).filter(([me])=>me!=="inherits").map(([me,Je])=>{const Ke=H.find(Ze=>Ze.key===me);return s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:Ke?.label||me}),s.jsx("p",{className:"text-xs text-bambu-gray-dark",children:me})]}),s.jsx("button",{onClick:()=>Q(me,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(Bt,{className:"w-4 h-4"})})]}),Ke?ut(Ke):s.jsx("input",{type:"text",value:String(Je),onChange:Ze=>Q(me,Ze.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},me)}),Object.keys(b).filter(me=>me!=="inherits").length===0&&s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(jU,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{className:"text-sm",children:"No overrides yet"}),s.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(b).filter(me=>me!=="inherits").length>0&&s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:s.jsxs("button",{onClick:()=>{V(!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:[s.jsx(ks,{className:"w-4 h-4"}),"Save as template"]})})]})]}),o==="json"&&s.jsxs("div",{className:"space-y-2",children:[N&&s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(Aa,{className:"w-4 h-4"}),N]}),s.jsx("textarea",{value:E,onChange:me=>Ee(me.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 ${N?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[s.jsx(Ne,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsxs(Ne,{onClick:()=>be.mutate(),disabled:be.isPending||!d.trim()||!a&&!g||!!N,className:"flex-1",children:[be.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):a?s.jsx(ks,{className:"w-4 h-4"}):s.jsx(pr,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function qWe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[a,o]=S.useState(""),[l,c]=S.useState("all"),[u,d]=S.useState("all"),[f,g]=S.useState("all"),[p,x]=S.useState("all"),[y,b]=S.useState("all"),[v,E]=S.useState("all"),[w,N]=S.useState(null),[A,C]=S.useState(!1),[T,L]=S.useState(!1),[k,D]=S.useState(null),[U,O]=S.useState(null),[q,R]=S.useState(null),[G,Y]=S.useState(!1),[V,K]=S.useState([null,null]),[J,X]=S.useState(!1),[F,W]=S.useState(null),ee=cn(),ie=S.useMemo(()=>[...t.filament.map(se=>({...se,type:"filament"})),...t.printer.map(se=>({...se,type:"printer"})),...t.process.map(se=>({...se,type:"process"}))].map(se=>({...se,meta:J4(se.name)})),[t]),ae=S.useMemo(()=>{const H=new Set,se=new Set,B=new Set;return ie.forEach(Q=>{Q.meta.nozzle&&H.add(Q.meta.nozzle),Q.meta.filamentType&&se.add(Q.meta.filamentType),Q.meta.layerHeight&&B.add(Q.meta.layerHeight)}),{printers:i.map(Q=>({id:Q.id.toString(),name:Q.name})),nozzles:Array.from(H).sort((Q,ce)=>parseFloat(Q)-parseFloat(ce)),filaments:Array.from(se).sort(),layerHeights:Array.from(B).sort((Q,ce)=>parseFloat(Q)-parseFloat(ce))}},[ie,i]),de=S.useMemo(()=>f==="all"?null:i.find(se=>se.id.toString()===f)?.model||null,[f,i]),ue=S.useMemo(()=>ie.filter(H=>l==="all"||H.type===l).filter(H=>{if(u==="all")return!0;const se=Nb(H.setting_id);return u==="custom"?se:!se}).filter(H=>{if(f==="all"||!de)return!0;const se=H.meta.printer?.toLowerCase()||"",B=de.toLowerCase();return se.includes(B)||B.includes(se)}).filter(H=>p==="all"||H.meta.nozzle===p).filter(H=>y==="all"||H.meta.filamentType===y).filter(H=>v==="all"||H.meta.layerHeight===v).filter(H=>a===""||H.name.toLowerCase().includes(a.toLowerCase())).sort((H,se)=>H.name.localeCompare(se.name)),[ie,l,u,f,de,p,y,v,a]),le=H=>{if(G){const se=V[0]?.setting_id===H.setting_id,B=V[1]?.setting_id===H.setting_id;if(se)K([V[1],null]);else if(B)K([V[0],null]);else if(!V[0])K([H,null]);else if(V[1]){if(V[0].type!==H.type)return;K([V[0],H])}else{if(V[0].type!==H.type)return;K([V[0],H])}}else N(H)},he=H=>{if(V[0]?.setting_id===H.setting_id)return 0;if(V[1]?.setting_id===H.setting_id)return 1},pe=async H=>{try{const se=await ye.getCloudSettingDetail(H.setting_id),B=H.type==="process"?"print":H.type;D({type:B,name:H.name,base_id:se.base_id||"GFSA00",setting:se.setting||{}}),N(null)}catch(se){console.error("Failed to fetch preset details for duplication:",se)}},Me=async H=>{try{ee.removeQueries({queryKey:["cloudSettingDetail",H.setting_id]});const se=await ye.getCloudSettingDetail(H.setting_id),B=H.type==="process"?"print":H.type;O({type:B,name:H.name,base_id:se.base_id||"GFSA00",setting:se.setting||{},setting_id:H.setting_id}),N(null)}catch(se){console.error("Failed to fetch preset details for editing:",se)}},re=()=>{c("all"),d("all"),g("all"),x("all"),b("all"),E("all"),o("")},We=l!=="all"||u!=="all"||f!=="all"||p!=="all"||y!=="all"||v!=="all"||a!=="",z=t.filament.length+t.printer.length+t.process.length;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-4 mb-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Ml,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:a,onChange:H=>o(H.target.value),placeholder:"Search presets...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Ne,{variant:G?"primary":"secondary",onClick:()=>{G?(Y(!1),K([null,null])):Y(!0)},children:[s.jsx(gp,{className:"w-4 h-4"}),G?"Cancel":"Compare"]}),s.jsxs(Ne,{variant:"secondary",onClick:()=>L(!0),children:[s.jsx(z0,{className:"w-4 h-4"}),"Templates"]}),s.jsxs(Ne,{variant:"secondary",onClick:n,disabled:r,children:[s.jsx(Gr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Ne,{onClick:()=>C(!0),children:[s.jsx(pr,{className:"w-4 h-4"}),"New Preset"]})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(yR,{className:"w-4 h-4 text-bambu-gray"}),s.jsx(ep,{label:"Type",value:l,options:[{value:"all",label:"All",count:z},{value:"filament",label:"Filament",count:t.filament.length},{value:"printer",label:"Printer",count:t.printer.length},{value:"process",label:"Process",count:t.process.length}],onChange:H=>c(H)}),s.jsx(ep,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:H=>d(H)}),ae.printers.length>0&&s.jsx(ep,{label:"Printer",value:f,options:[{value:"all",label:"All"},...ae.printers.map(H=>({value:H.id,label:H.name}))],onChange:g}),ae.nozzles.length>0&&s.jsx(ep,{label:"Nozzle",value:p,options:[{value:"all",label:"All"},...ae.nozzles.map(H=>({value:H,label:H}))],onChange:x}),ae.filaments.length>0&&(l==="all"||l==="filament")&&s.jsx(ep,{label:"Filament",value:y,options:[{value:"all",label:"All"},...ae.filaments.map(H=>({value:H,label:H}))],onChange:b}),ae.layerHeights.length>0&&(l==="all"||l==="process")&&s.jsx(ep,{label:"Layer",value:v,options:[{value:"all",label:"All"},...ae.layerHeights.map(H=>({value:H,label:H}))],onChange:E}),We&&s.jsx("button",{onClick:re,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),G&&s.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(gp,{className:"w-5 h-5 text-blue-400"}),s.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),s.jsx("span",{className:"text-bambu-gray",children:V[0]?`Select another ${V[0].type} preset`:"Click two presets of the same type to compare"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${V[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:V[0]?V[0].name:"1. Select first"}),s.jsx(i3,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${V[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:V[1]?V[1].name:"2. Select second"})]}),V[0]&&V[1]&&s.jsxs(Ne,{size:"sm",onClick:async()=>{try{const[H,se]=await Promise.all([ye.getCloudSettingDetail(V[0].setting_id),ye.getCloudSettingDetail(V[1].setting_id)]);W([H.setting||{},se.setting||{}]),X(!0)}catch{}},children:[s.jsx(gp,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(dr,{className:"w-3 h-3"}),"Last synced: ",BWe(e.toISOString())]}),s.jsxs("span",{children:["Showing ",ue.length," of ",z," presets"]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),s.jsx("span",{children:"= My preset (editable)"})]})]}),ue.length===0?s.jsxs("div",{className:"text-center py-16",children:[s.jsx(Sd,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),s.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),We&&s.jsx("button",{onClick:re,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(gR,{className:"w-4 h-4 text-amber-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ue.filter(H=>H.type==="filament").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ue.filter(H=>H.type==="filament").map(H=>s.jsx(Hk,{setting:H,onClick:()=>le(H),onDuplicate:()=>pe(H),compareMode:G,isCompareSelected:he(H)!==void 0,compareIndex:he(H),compareDisabled:G&&!!V[0]&&V[0].type!==H.type},H.setting_id)),ue.filter(H=>H.type==="filament").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(dM,{className:"w-4 h-4 text-blue-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ue.filter(H=>H.type==="process").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ue.filter(H=>H.type==="process").map(H=>s.jsx(Hk,{setting:H,onClick:()=>le(H),onDuplicate:()=>pe(H),compareMode:G,isCompareSelected:he(H)!==void 0,compareIndex:he(H),compareDisabled:G&&!!V[0]&&V[0].type!==H.type},H.setting_id)),ue.filter(H=>H.type==="process").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(Ei,{className:"w-4 h-4 text-purple-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ue.filter(H=>H.type==="printer").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ue.filter(H=>H.type==="printer").map(H=>s.jsx(Hk,{setting:H,onClick:()=>le(H),onDuplicate:()=>pe(H),compareMode:G,isCompareSelected:he(H)!==void 0,compareIndex:he(H),compareDisabled:G&&!!V[0]&&V[0].type!==H.type},H.setting_id)),ue.filter(H=>H.type==="printer").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),w&&s.jsx(VWe,{setting:w,onClose:()=>N(null),onDeleted:()=>N(null),onDuplicate:()=>pe(w),onEdit:()=>Me(w)}),(A||k||U||q)&&s.jsx(WWe,{onClose:()=>{C(!1),D(null),O(null),R(null)},initialData:U||k||(q?{type:q.type,name:"",base_id:"",setting:q.setting}:void 0),allPresets:t}),T&&s.jsx(GWe,{onClose:()=>L(!1),onApply:H=>{R({type:H.type,setting:H.settings}),L(!1)}}),J&&F&&V[0]&&V[1]&&s.jsx(yne,{onClose:()=>{X(!1),W(null)},leftPreset:F[0],rightPreset:F[1],leftLabel:V[0].name,rightLabel:V[1].name})]})}function KWe(){const t=cn(),{showToast:e}=hr(),[n,r]=S.useState("cloud"),[i,a]=S.useState(),{data:o,isLoading:l}=ft({queryKey:["cloudStatus"],queryFn:ye.getCloudStatus}),{data:c=[]}=ft({queryKey:["printers"],queryFn:ye.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:g}=ft({queryKey:["cloudSettings"],queryFn:()=>ye.getCloudSettings(),enabled:!!o?.is_authenticated,retry:!1,staleTime:1e3*60*5});S.useEffect(()=>{g&&a(new Date(g))},[g]);const p=bt({mutationFn:ye.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),x=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return l?s.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsxs("div",{className:"p-6 lg:p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),s.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[s.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:[s.jsx(oM,{className:"w-4 h-4"}),"Cloud Profiles"]}),s.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:[s.jsx(cM,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&s.jsxs(s.Fragment,{children:[o?.is_authenticated&&s.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",s.jsx("span",{className:"text-white",children:o.email})]})]}),s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[s.jsx(cue,{className:"w-4 h-4"}),"Logout"]})]}),o?.is_authenticated?d?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?s.jsx(qWe,{settings:u,lastSyncTime:i,onRefresh:()=>f(),isRefreshing:d,printers:c}):s.jsxs("div",{className:"text-center py-16",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),s.jsx(Ne,{onClick:()=>f(),children:"Retry"})]}):s.jsx(HWe,{onSuccess:x})]}),n==="kprofiles"&&s.jsx(zWe,{}),s.jsx($We,{})]})}const u0={Droplet:gR,Flame:yce,Ruler:Zue,Sparkles:z0,Square:Ed,Cable:gle,Wrench:Ad,Calendar:Wr,Timer:id,Cog:Wle,Fan:J9,Zap:cf,Wind:fW,Thermometer:fM,Layers:Sd,Box:vl,Target:oW,RefreshCw:Gr,Settings:hM,Filter:yR,CircleDot:Rle};function D0(t){return t&&u0[t]||Ad}function tp(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 $k(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 XWe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),a=n.includes("A1MINI"),o=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":o?"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||o?"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":o?"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||o||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||o?"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 YWe({item:t,onPerform:e,onToggle:n}){const r=D0(t.maintenance_type_icon),i=t.interval_type||"hours",o=(()=>{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 ${tp(Math.abs(f),"days")}`:t.is_warning?`Due in ${tp(f,"days")}`:`${tp(f,"days")} left`}else return t.is_due?`Overdue by ${tp(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${tp(t.hours_until_due,"hours")}`:`${tp(t.hours_until_due,"hours")} left`};return s.jsx("div",{className:`rounded-xl border p-4 transition-all ${u()}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.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:[s.jsx(r,{className:`w-5 h-5 ${l()}`}),t.enabled&&(t.is_due||t.is_warning)&&s.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`})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),i==="days"&&s.jsx("span",{title:"Time-based interval",children:s.jsx(Wr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const f=t.maintenance_type_wiki_url||XWe(t.maintenance_type_name,t.printer_model);return f?s.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:s.jsx(qr,{className:"w-3.5 h-3.5"})}):null})()]}),s.jsx("div",{className:"mt-2 mb-1.5",children:s.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${c()}`,style:{width:`${o}%`}})})}),s.jsxs("div",{className:`text-xs flex items-center gap-1 ${l()}`,children:[t.is_due&&s.jsx(zn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&s.jsx(dr,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&s.jsx(Ls,{className:"w-3 h-3"}),d()]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx($n,{checked:t.enabled,onChange:f=>n(t.id,f)}),s.jsxs(Ne,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[s.jsx(hg,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function ZWe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,a]=S.useState(!0),[o,l]=S.useState(!1),[c,u]=S.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((p,x)=>p.is_due&&!x.is_due?-1:!p.is_due&&x.is_due?1:p.is_warning&&!x.is_warning?-1:!p.is_warning&&x.is_warning?1:p.maintenance_type_id-x.maintenance_type_id),f=d.find(p=>p.enabled&&(p.is_due||p.is_warning)),g=()=>{const p=parseFloat(c);!isNaN(p)&&p>=0&&(r(t.printer_id,p),l(!1))};return s.jsxs(Mt,{className:"overflow-hidden",children:[s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),s.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&s.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:[s.jsx(zn,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&s.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:[s.jsx(dr,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&s.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:[s.jsx(Ls,{className:"w-3 h-3"}),"All good"]})]})]}),s.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?s.jsx(Tf,{className:"w-4 h-4"}):s.jsx(Ga,{className:"w-4 h-4"}),i?"Collapse":"Expand"]})]}),s.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:s.jsx(id,{className:"w-4 h-4 text-bambu-gray"})}),o?s.jsxs("div",{className:"flex items-center gap-2",children:[s.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}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),s.jsx(Ne,{size:"sm",onClick:g,children:"Save"}),s.jsx(Ne,{size:"sm",variant:"secondary",onClick:()=>l(!1),children:"Cancel"})]}):s.jsxs("button",{onClick:()=>{u(Math.round(t.total_print_hours).toString()),l(!0)},className:"group",children:[s.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",s.jsx(of,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),s.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const p=D0(f.maintenance_type_icon);return s.jsx(p,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),s.jsxs("div",{children:[s.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),s.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&s.jsx(At,{className:"pt-0 border-t border-bambu-dark-tertiary",children:s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:d.map(p=>s.jsx(YWe,{item:p,onPerform:e,onToggle:n},p.id))})})]})}function QWe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a,onAssignType:o,onRemoveItem:l}){const[c,u]=S.useState(null),[d,f]=S.useState(""),[g,p]=S.useState("hours"),[x,y]=S.useState(!1),[b,v]=S.useState(""),[E,w]=S.useState("100"),[N,A]=S.useState("hours"),[C,T]=S.useState("Wrench"),[L,k]=S.useState(""),[D,U]=S.useState(new Set),[O,q]=S.useState(null),R=S.useMemo(()=>t?t.map(B=>({id:B.printer_id,name:B.printer_name})):[],[t]),G=B=>t?t.filter(Q=>Q.maintenance_items.some(ce=>ce.maintenance_type_id===B)).map(Q=>({printerId:Q.printer_id,printerName:Q.printer_name,itemId:Q.maintenance_items.find(ce=>ce.maintenance_type_id===B)?.id})):[],Y=B=>{if(!t)return[];const Q=new Set(G(B).map(ce=>ce.printerId));return R.filter(ce=>!Q.has(ce.id))},[V,K]=S.useState(null),[J,X]=S.useState(""),[F,W]=S.useState(""),[ee,ie]=S.useState("hours"),[ae,de]=S.useState("Wrench"),[ue,le]=S.useState(""),he=B=>{K(B),X(B.name),W(B.default_interval_hours.toString()),ie(B.interval_type||"hours"),de(B.icon||"Wrench"),le(B.wiki_url||"")},pe=()=>{V&&J.trim()&&parseFloat(F)>0&&(i(V.id,{name:J.trim(),default_interval_hours:parseFloat(F),interval_type:ee,icon:ae,wiki_url:ue.trim()||null}),K(null))},Me=(B,Q,ce)=>{const Ce=parseFloat(d);if(!isNaN(Ce)&&Ce>0){const _e=Math.abs(Ce-Q)<.01?null:Ce;n(B,{custom_interval_hours:_e,custom_interval_type:g!==ce?g:null})}u(null)},re=B=>{B.preventDefault(),b.trim()&&parseFloat(E)>0&&D.size>0&&(r({name:b.trim(),default_interval_hours:parseFloat(E),interval_type:N,icon:C,wiki_url:L.trim()||null},Array.from(D)),v(""),w("100"),A("hours"),k(""),U(new Set),y(!1))},We=B=>{U(Q=>{const ce=new Set(Q);return ce.has(B)?ce.delete(B):ce.add(B),ce})},z=t?.map(B=>({printerId:B.printer_id,printerName:B.printer_name,items:B.maintenance_items.sort((Q,ce)=>Q.maintenance_type_id-ce.maintenance_type_id)})).sort((B,Q)=>B.printerName.localeCompare(Q.printerName))||[],H=e.filter(B=>B.is_system),se=e.filter(B=>!B.is_system);return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),s.jsxs(Ne,{onClick:()=>y(!x),children:[s.jsx(pr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),x&&s.jsx(Mt,{className:"mb-6",children:s.jsx(At,{className:"py-4",children:s.jsxs("form",{onSubmit:re,children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"lg:col-span-2",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Name"}),s.jsx("input",{type:"text",value:b,onChange:B=>v(B.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),s.jsxs("select",{value:N,onChange:B=>{A(B.target.value),B.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:[s.jsx("option",{value:"hours",children:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",N==="days"?"days":"hours",")"]}),s.jsx("input",{type:"number",value:E,onChange:B=>w(B.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"})]})]}),s.jsx("div",{className:"mt-4 flex items-end justify-between",children:s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),s.jsx("div",{className:"flex gap-1",children:Object.keys(u0).map(B=>{const Q=u0[B];return s.jsx("button",{type:"button",onClick:()=>T(B),className:`p-2 rounded-lg transition-colors ${C===B?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:s.jsx(Q,{className:"w-4 h-4"})},B)})})]})}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Documentation Link (optional)"}),s.jsx("input",{type:"url",value:L,onChange:B=>k(B.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/..."})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Assign to Printers"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:R.map(B=>s.jsx("button",{type:"button",onClick:()=>We(B.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${D.has(B.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:B.name},B.id))}),D.size===0&&s.jsx("p",{className:"text-xs text-orange-400 mt-1",children:"Select at least one printer"})]}),s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(Ne,{type:"button",variant:"secondary",onClick:()=>{y(!1),U(new Set)},children:"Cancel"}),s.jsx(Ne,{type:"submit",disabled:!b.trim()||D.size===0,children:"Add Type"})]})]})})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[H.map(B=>{const Q=D0(B.icon),ce=B.interval_type||"hours";return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:s.jsx(Q,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-white truncate",children:B.name}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[ce==="days"?s.jsx(Wr,{className:"w-3 h-3"}):s.jsx(id,{className:"w-3 h-3"}),$k(B.default_interval_hours,ce)]})]})]})},B.id)}),se.map(B=>{const Q=D0(B.icon),ce=B.interval_type||"hours";if(V?.id===B.id)return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx("input",{type:"text",value:J,onChange:j=>X(j.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}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:ee,onChange:j=>ie(j.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:[s.jsx("option",{value:"hours",children:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]}),s.jsx("input",{type:"number",value:F,onChange:j=>W(j.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"})]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(u0).map(j=>{const ne=u0[j];return s.jsx("button",{type:"button",onClick:()=>de(j),className:`p-1.5 rounded transition-colors ${ae===j?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s.jsx(ne,{className:"w-3.5 h-3.5"})},j)})}),s.jsx("input",{type:"url",value:ue,onChange:j=>le(j.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)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ne,{size:"sm",onClick:pe,disabled:!J.trim(),children:"Save"}),s.jsx(Ne,{size:"sm",variant:"secondary",onClick:()=>K(null),children:"Cancel"})]})]})},B.id);const _e=G(B.id),Ee=Y(B.id),$=O===B.id;return s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:s.jsx(Q,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-medium text-white truncate",children:B.name}),s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[ce==="days"?s.jsx(Wr,{className:"w-3 h-3"}):s.jsx(id,{className:"w-3 h-3"}),$k(B.default_interval_hours,ce)]})]}),s.jsxs("button",{onClick:()=>q($?null:B.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${_e.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:`${_e.length} printer(s) assigned - click to manage`,children:[s.jsx(Ei,{className:"w-3 h-3"}),s.jsx("span",{className:"text-xs font-medium",children:_e.length}),s.jsx(Ga,{className:`w-3 h-3 transition-transform ${$?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>he(B),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:s.jsx(of,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm(`Delete "${B.name}"?`)&&a(B.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(_n,{className:"w-4 h-4"})})]}),$&&s.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Assigned to printers:"}),_e.length===0?s.jsx("p",{className:"text-xs text-orange-400",children:"No printers assigned"}):s.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:_e.map(j=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[j.printerName,s.jsx("button",{onClick:()=>j.itemId&&l(j.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},j.printerId))}),Ee.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:"Add:"}),Ee.map(j=>s.jsxs("button",{onClick:()=>o(j.id,B.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:["+ ",j.name]},j.id))]})]})]},B.id)})]})]}),z.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),s.jsx("div",{className:"space-y-4",children:z.map(B=>s.jsx(Mt,{children:s.jsxs(At,{className:"py-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:B.printerName}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:B.items.map(Q=>{const ce=D0(Q.maintenance_type_icon),Ce=e.find(ne=>ne.id===Q.maintenance_type_id),_e=Ce?.default_interval_hours||Q.interval_hours,Ee=Ce?.interval_type||"hours",$=Q.interval_type||"hours",j=c===Q.id;return s.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[s.jsx(ce,{className:"w-4 h-4 text-bambu-gray shrink-0"}),s.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:Q.maintenance_type_name}),j?s.jsxs("div",{className:"flex items-center gap-1",children:[g==="days"?s.jsx(Wr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):s.jsx(id,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),s.jsxs("select",{value:g,onChange:ne=>p(ne.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[s.jsx("option",{value:"hours",children:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]}),s.jsx("input",{type:"number",value:d,onChange:ne=>f(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&Me(Q.id,_e,Ee),ne.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"}),s.jsx(Ne,{size:"sm",onClick:()=>Me(Q.id,_e,Ee),children:"OK"})]}):s.jsxs("button",{onClick:()=>{u(Q.id),f(Q.interval_hours.toString()),p($)},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:[$==="days"?s.jsx(Wr,{className:"w-3 h-3"}):s.jsx(id,{className:"w-3 h-3"}),$k(Q.interval_hours,$),s.jsx(of,{className:"w-3 h-3 text-bambu-gray"})]})]},Q.id)})})]})},B.printerId))})]}),z.length===0&&s.jsx(Mt,{children:s.jsxs(At,{className:"text-center py-12",children:[s.jsx(dr,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),s.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),s.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function JWe(){const t=cn(),{showToast:e}=hr(),[n,r]=S.useState("status"),{data:i,isLoading:a}=ft({queryKey:["maintenanceOverview"],queryFn:ye.getMaintenanceOverview}),{data:o}=ft({queryKey:["maintenanceTypes"],queryFn:ye.getMaintenanceTypes}),l=bt({mutationFn:({id:w,notes:N})=>ye.performMaintenance(w,N),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:w=>{e(w.message,"error")}}),c=bt({mutationFn:({id:w,data:N})=>ye.updateMaintenanceItem(w,N),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:w=>{e(w.message,"error")}}),u=bt({mutationFn:({id:w,data:N})=>ye.updateMaintenanceType(w,N),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:w=>{e(w.message,"error")}}),d=bt({mutationFn:ye.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:w=>{e(w.message,"error")}}),f=bt({mutationFn:({printerId:w,hours:N})=>ye.setPrinterHours(w,N),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:w=>{e(w.message,"error")}}),g=bt({mutationFn:({printerId:w,typeId:N})=>ye.assignMaintenanceType(w,N),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:w=>{e(w.message,"error")}}),p=bt({mutationFn:ye.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:w=>{e(w.message,"error")}}),x=w=>{l.mutate({id:w})},y=(w,N)=>{c.mutate({id:w,data:{enabled:N}})},b=(w,N)=>{f.mutate({printerId:w,hours:N})};if(a)return s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const v=i?.reduce((w,N)=>w+N.due_count,0)||0,E=i?.reduce((w,N)=>w+N.warning_count,0)||0;return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?s.jsxs(s.Fragment,{children:[v>0&&s.jsxs("span",{className:"text-red-400",children:[v," task",v!==1?"s":""," overdue"]}),v>0&&E>0&&" · ",E>0&&s.jsxs("span",{className:"text-amber-400",children:[E," due soon"]}),v===0&&E===0&&s.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[s.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"}),s.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"?s.jsx("div",{className:"space-y-6",children:i&&i.length>0?[...i].sort((w,N)=>{const A=w.due_count*10+w.warning_count,C=N.due_count*10+N.warning_count;return A!==C?C-A:w.printer_name.localeCompare(N.printer_name)}).map(w=>s.jsx(ZWe,{overview:w,onPerform:x,onToggle:y,onSetHours:b},w.printer_id)):s.jsx(Mt,{children:s.jsxs(At,{className:"text-center py-16",children:[s.jsx(Ad,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No printers configured"}),s.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):s.jsx(QWe,{overview:i,types:o||[],onUpdateInterval:(w,N)=>c.mutate({id:w,data:N}),onAddType:async(w,N)=>{const A=await ye.createMaintenanceType(w);for(const C of N)await ye.assignMaintenanceType(C,A.id);t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onUpdateType:(w,N)=>u.mutate({id:w,data:N}),onDeleteType:w=>d.mutate(w),onAssignType:(w,N)=>g.mutate({printerId:w,typeId:N}),onRemoveItem:w=>p.mutate(w)})]})}const u9=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function vne({project:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=S.useState(t?.name||""),[o,l]=S.useState(t?.description||""),[c,u]=S.useState(t?.color||u9[0]),[d,f]=S.useState(t?.target_count?.toString()||""),[g,p]=S.useState(t?.status||"active"),[x,y]=S.useState(t?.tags||""),[b,v]=S.useState(t?.due_date?.split("T")[0]||""),[E,w]=S.useState(t?.priority||"normal"),N=A=>{A.preventDefault(),n({name:i.trim(),description:o.trim()||void 0,color:c,target_count:d?parseInt(d,10):void 0,tags:x.trim()||void 0,due_date:b||void 0,priority:E,...t&&{status:g}})};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:t?"Edit Project":"New Project"})}),s.jsxs("form",{onSubmit:N,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Name"}),s.jsx("input",{type:"text",value:i,onChange:A=>a(A.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Description"}),s.jsx("textarea",{value:o,onChange:A=>l(A.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Color"}),s.jsx("div",{className:"flex gap-2 flex-wrap",children:u9.map(A=>s.jsx("button",{type:"button",onClick:()=>u(A),className:`w-8 h-8 rounded-full transition-transform ${c===A?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:A}},A))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Print Count (optional)"}),s.jsx("input",{type:"number",value:d,onChange:A=>f(A.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Tags (comma-separated)"}),s.jsx("input",{type:"text",value:x,onChange:A=>y(A.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"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Due Date"}),s.jsx("input",{type:"date",value:b,onChange:A=>v(A.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Priority"}),s.jsxs("select",{value:E,onChange:A=>w(A.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:[s.jsx("option",{value:"low",children:"Low"}),s.jsx("option",{value:"normal",children:"Normal"}),s.jsx("option",{value:"high",children:"High"}),s.jsx("option",{value:"urgent",children:"Urgent"})]})]})]}),t&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Status"}),s.jsxs("select",{value:g,onChange:A=>p(A.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:[s.jsx("option",{value:"active",children:"Active"}),s.jsx("option",{value:"completed",children:"Completed"}),s.jsx("option",{value:"archived",children:"Archived"})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Ne,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Ne,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function eqe({project:t,onClick:e,onEdit:n,onDelete:r}){const i=t.progress_percent??0,a=t.status==="completed",o=t.status==="archived",[l,c]=S.useState(!1),d=a?{icon:pR,color:"text-bambu-green",bg:"bg-bambu-green/10"}:o?{icon:fo,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:dr,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:ha,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return s.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:[s.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`}}),s.jsxs("div",{className:"p-5 pl-6",children:[s.jsxs("div",{className:"flex items-start justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("div",{className:`p-2 rounded-lg ${d.bg} flex-shrink-0`,children:s.jsx(d.icon,{className:`w-5 h-5 ${d.color}`})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_count?s.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?s.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&&s.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:"Done"}),o&&s.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&&s.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=t.archives.map(y=>y.filament_type).filter(Boolean).flatMap(y=>y.split(",").map(b=>b.trim())).filter(Boolean),g=[...new Set(f)],p=t.archives.map(y=>y.filament_color).filter(Boolean).flatMap(y=>y.split(",").map(b=>b.trim())).filter(y=>y.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(y)),x=[...new Set(p)];return g.length===0&&x.length===0?null:s.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[g.slice(0,3).map(y=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:y},y)),x.length>0&&s.jsxs("div",{className:"flex items-center gap-0.5",children:[x.slice(0,5).map(y=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:y.startsWith("#")?y:`#${y}`},title:y},y)),x.length>5&&s.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",x.length-5]})]})]})})()]})]}),s.jsxs("div",{className:"relative",onClick:f=>f.stopPropagation(),children:[s.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:s.jsx(pp,{className:"w-4 h-4"})}),l&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>c(!1)}),s.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:[s.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:[s.jsx(of,{className:"w-4 h-4"}),"Edit"]}),s.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:[s.jsx(_n,{className:"w-4 h-4"}),"Delete"]})]})]})]})]}),s.jsx("div",{className:"mb-4",children:t.target_count?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-2",children:[s.jsx("span",{className:"text-bambu-gray",children:"Progress"}),s.jsxs("span",{className:i>=100?"text-bambu-green font-medium":"text-white",children:[t.total_items," / ",t.target_count]})]}),s.jsx("div",{className:"h-2.5 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:s.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`}})}),s.jsxs("div",{className:"text-right text-xs text-bambu-gray/60 mt-1",children:[i.toFixed(0),"% complete"]})]}):t.total_items>0?s.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(fo,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.total_items," item",t.total_items!==1?"s":""," completed"]})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[s.jsx(dr,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.queue_count," in queue"]})]})]}):s.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:"No prints yet"})}),t.archives&&t.archives.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(f=>s.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?s.jsx("img",{src:ye.getArchiveThumbnail(f.id),alt:f.print_name||"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:s.jsx(Vc,{className:"w-6 h-6"})}),f.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:s.jsx(zn,{className:"w-4 h-4 text-white"})})]},f.id))}),t.archive_count>4&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:["+",t.archive_count-4," more"]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[s.jsxs("div",{className:"flex items-center gap-1.5",title:"Total items printed",children:[s.jsx(fo,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.total_items})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",title:"In queue",children:[s.jsx(l3,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.queue_count})]})]}),s.jsx(Zo,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function tqe(){const t=kb(),e=cn(),{showToast:n}=hr(),[r,i]=S.useState(!1),[a,o]=S.useState(),[l,c]=S.useState("active"),[u,d]=S.useState(null),{data:f,isLoading:g}=ft({queryKey:["projects",l==="all"?void 0:l],queryFn:()=>ye.getProjects(l==="all"?void 0:l)}),p=bt({mutationFn:C=>ye.createProject(C),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),n("Project created","success")},onError:C=>{n(C.message,"error")}}),x=bt({mutationFn:({id:C,data:T})=>ye.updateProject(C,T),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),o(void 0),n("Project updated","success")},onError:C=>{n(C.message,"error")}}),y=bt({mutationFn:C=>ye.deleteProject(C),onSuccess:()=>{d(null),n("Project deleted","success"),setTimeout(()=>window.location.reload(),100)},onError:C=>{d(null),n(C.message,"error")}}),b=C=>{a?x.mutate({id:a.id,data:C}):p.mutate(C)},v=C=>{o(C),i(!0)},E=C=>{t(`/projects/${C.id}`)},w=C=>{d(C)},N=()=>{u!==null&&y.mutate(u)},A=f?.reduce((C,T)=>(C[T.status]=(C[T.status]||0)+1,C.all=(C.all||0)+1,C),{})||{};return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:s.jsx(ha,{className:"w-6 h-6 text-bambu-green"})}),"Projects"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and track your 3D printing projects"})]}),s.jsxs(Ne,{onClick:()=>i(!0),className:"sm:w-auto w-full",children:[s.jsx(pr,{className:"w-4 h-4 mr-2"}),"New Project"]})]}),s.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:"Active",icon:dr},{key:"completed",label:"Completed",icon:pR},{key:"archived",label:"Archived",icon:fo},{key:"all",label:"All",icon:ha}].map(({key:C,label:T,icon:L})=>s.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:[s.jsx(L,{className:"w-4 h-4"}),s.jsx("span",{children:T}),A[C]>0&&s.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:A[C]})]},C))}),g?s.jsx("div",{className:"flex items-center justify-center py-20",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(xt,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading projects..."})]})}):f?.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(ha,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:l==="all"?"No projects yet":`No ${l} projects`}),s.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"&&s.jsxs(Ne,{onClick:()=>i(!0),children:[s.jsx(pr,{className:"w-4 h-4 mr-2"}),"Create Your First Project"]})]}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:f?.map(C=>s.jsx(eqe,{project:C,onClick:()=>E(C),onEdit:()=>v(C),onDelete:()=>w(C.id)},C.id))}),u!==null&&s.jsx(Qn,{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:N,onCancel:()=>d(null)}),r&&s.jsx(vne,{project:a,onClose:()=>{i(!1),o(void 0)},onSave:b,isLoading:p.isPending||x.isPending})]})}function nqe(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 rqe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function iqe({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 s.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${n}`,children:t.charAt(0).toUpperCase()+t.slice(1)})}function m1({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-gray"}){return s.jsx(Mt,{children:s.jsx(At,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${i}`,children:s.jsx(t,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:e}),s.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&s.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function aqe({archives:t}){return t.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Vc,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:"No prints in this project yet"})]}):s.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=>s.jsxs(Nc,{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?s.jsx("img",{src:ye.getArchiveThumbnail(e.id),alt:e.print_name||"Print",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s.jsx(Vc,{className:"w-8 h-8"})}),e.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:s.jsx(Sa,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&s.jsx("div",{className:"absolute top-1 right-1",children:s.jsx(Ar,{className:"w-4 h-4 text-bambu-green"})}),s.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:s.jsx("p",{className:"text-xs text-white truncate",children:e.print_name||"Unknown"})})]},e.id))})}function sqe({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 s.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${n}`,children:[t==="urgent"&&s.jsx(zn,{className:"w-3 h-3"}),r]})}function oqe(t){return t?Dp(t,{year:"numeric",month:"short",day:"numeric"}):""}function Vk(t){if(!t)return null;const e=ui(t);if(!e)return null;const 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 lqe(){const{id:t}=sR(),e=kb(),n=cn(),{showToast:r}=hr(),[i,a]=S.useState(!1),[o,l]=S.useState(!1),[c,u]=S.useState(""),[d,f]=S.useState(!1),g=S.useRef(null),p=parseInt(t||"0",10),{data:x,isLoading:y,error:b}=ft({queryKey:["project",p],queryFn:()=>ye.getProject(p),enabled:p>0}),{data:v,isLoading:E}=ft({queryKey:["project-archives",p],queryFn:()=>ye.getProjectArchives(p),enabled:p>0}),{data:w,isLoading:N}=ft({queryKey:["project-bom",p],queryFn:()=>ye.getProjectBOM(p),enabled:p>0}),{data:A,isLoading:C}=ft({queryKey:["project-timeline",p],queryFn:()=>ye.getProjectTimeline(p,20),enabled:p>0}),{data:T}=ft({queryKey:["settings"],queryFn:ye.getSettings}),L=T?.currency||"$",k=T?.time_format||"system",D=bt({mutationFn:j=>ye.updateProject(p,j),onSuccess:()=>{n.invalidateQueries({queryKey:["project",p]}),n.invalidateQueries({queryKey:["projects"]}),a(!1),l(!1),r("Project updated","success")},onError:j=>{r(j.message,"error")}}),U=()=>{u(x?.notes||""),l(!0)},O=()=>{D.mutate({notes:c})},q=()=>{l(!1),u("")},R=async j=>{const ne=j.target.files?.[0];if(ne){f(!0);try{const be=await ye.uploadProjectAttachment(p,ne);n.invalidateQueries({queryKey:["project",p]}),r(`Uploaded: ${be.original_name}`,"success")}catch(be){r(be.message,"error")}finally{f(!1),g.current&&(g.current.value="")}}},G=(j,ne)=>{re({isOpen:!0,title:"Delete Attachment",message:`Are you sure you want to delete "${ne}"?`,onConfirm:async()=>{re(be=>({...be,isOpen:!1}));try{await ye.deleteProjectAttachment(p,j),n.invalidateQueries({queryKey:["project",p]}),r("Attachment deleted","success")}catch(be){r(be.message,"error")}}})},Y=j=>j<1024?`${j} B`:j<1024*1024?`${(j/1024).toFixed(1)} KB`:`${(j/(1024*1024)).toFixed(1)} MB`,[V,K]=S.useState(""),[J,X]=S.useState(1),[F,W]=S.useState(""),[ee,ie]=S.useState(""),[ae,de]=S.useState(""),[ue,le]=S.useState(!1),[he,pe]=S.useState(!1),[Me,re]=S.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),We=bt({mutationFn:j=>ye.createBOMItem(p,j),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]}),K(""),X(1),W(""),ie(""),de(""),le(!1),r("Part added","success")},onError:j=>r(j.message,"error")}),z=bt({mutationFn:({itemId:j,data:ne})=>ye.updateBOMItem(p,j,ne),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]})},onError:j=>r(j.message,"error")}),H=bt({mutationFn:j=>ye.deleteBOMItem(p,j),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]}),r("Part removed","success")},onError:j=>r(j.message,"error")}),se=j=>{j.preventDefault(),V.trim()&&We.mutate({name:V.trim(),quantity_needed:J,unit_price:F?parseFloat(F):void 0,sourcing_url:ee.trim()||void 0,remarks:ae.trim()||void 0})},B=j=>{const ne=j.is_complete?0:j.quantity_needed;z.mutate({itemId:j.id,data:{quantity_acquired:ne}})},Q=(j,ne)=>{re({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${ne}"?`,onConfirm:()=>{re(be=>({...be,isOpen:!1})),H.mutate(j)}})},ce=bt({mutationFn:()=>ye.createTemplateFromProject(p),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:j=>r(j.message,"error")}),Ce=j=>Op(j,k,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(y)return s.jsx("div",{className:"flex items-center justify-center py-24",children:s.jsx(xt,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(b||!x)return s.jsxs("div",{className:"text-center py-24",children:[s.jsx("p",{className:"text-bambu-gray",children:b?`Error: ${b.message}`:"Project not found"}),s.jsx(Ne,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const _e=x.stats,Ee=_e?.progress_percent??0,$=_e&&_e.total_items>0?(_e.completed_prints/_e.total_items*100).toFixed(0):null;return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(Nc,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),s.jsx(Zo,{className:"w-4 h-4"}),s.jsx("span",{className:"text-white",children:x.name})]}),s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:s.jsx(tle,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:x.color||"#6b7280"}}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:x.name}),x.description&&s.jsx("p",{className:"text-bambu-gray mt-1",children:x.description})]})]}),s.jsx(iqe,{status:x.status})]}),s.jsxs(Ne,{onClick:()=>a(!0),children:[s.jsx(of,{className:"w-4 h-4 mr-2"}),"Edit"]})]}),x.target_count&&s.jsx(Mt,{children:s.jsxs(At,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Progress"}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[_e?.completed_prints||0," / ",x.target_count," items"]})]}),s.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Ee,100)}%`,backgroundColor:Ee>=100?"#22c55e":x.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Ee.toFixed(0),"% complete"]}),x.target_count-(_e?.completed_prints||0)>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[x.target_count-(_e?.completed_prints||0)," remaining"]})]})]})}),_e&&s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(m1,{icon:Vc,label:"Total Items",value:_e.total_items,subValue:`${_e.total_archives} print job${_e.total_archives!==1?"s":""}`,color:"text-bambu-green"}),s.jsx(m1,{icon:Ar,label:"Completed",value:_e.completed_prints,subValue:_e.failed_prints>0?`${_e.failed_prints} failed`:$?`${$}% success`:void 0,color:"text-blue-400"}),s.jsx(m1,{icon:dr,label:"Print Time",value:nqe(_e.total_print_time_hours),color:"text-yellow-400"}),s.jsx(m1,{icon:Ei,label:"Filament Used",value:rqe(_e.total_filament_grams),color:"text-purple-400"})]}),_e&&(_e.estimated_cost>0||x.budget)&&s.jsx(Mt,{children:s.jsxs(At,{className:"p-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:"Cost Tracking"}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Filament Cost"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[L,_e.estimated_cost.toFixed(2)]})]}),_e.total_energy_kwh>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Energy"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[_e.total_energy_kwh.toFixed(2)," kWh",_e.total_energy_cost>0&&s.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",L,_e.total_energy_cost.toFixed(2),")"]})]})]}),x.budget&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Budget"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[L,x.budget.toFixed(2)]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Remaining"}),s.jsxs("p",{className:`text-lg font-semibold ${x.budget-_e.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[L,(x.budget-_e.estimated_cost).toFixed(2)]})]})]})]})]})}),x.children&&x.children.length>0&&s.jsx(Mt,{children:s.jsxs(At,{className:"p-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[s.jsx(Mce,{className:"w-5 h-5"}),"Sub-projects (",x.children.length,")"]}),s.jsx("div",{className:"space-y-2",children:x.children.map(j=>s.jsxs(Nc,{to:`/projects/${j.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:j.color||"#6b7280"}}),s.jsx("span",{className:"text-white",children:j.name}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${j.status==="completed"?"bg-bambu-green/20 text-bambu-green":j.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:j.status})]}),j.progress_percent!==null&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[j.progress_percent.toFixed(0),"%"]})]},j.id))})]})}),x.parent_id&&x.parent_name&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(Sd,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),s.jsx(Nc,{to:`/projects/${x.parent_id}`,className:"text-bambu-green hover:underline",children:x.parent_name})]}),(x.tags||x.due_date||x.priority!=="normal")&&s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[x.priority&&x.priority!=="normal"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:"Priority:"}),s.jsx(sqe,{priority:x.priority})]}),x.due_date&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Wr,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-white",children:oqe(x.due_date)}),Vk(x.due_date)&&s.jsxs("span",{className:`text-xs ${Vk(x.due_date).color}`,children:["(",Vk(x.due_date).label,")"]})]}),x.tags&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Rp,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:x.tags.split(",").map((j,ne)=>s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:j.trim()},ne))})]})]}),s.jsx(Mt,{children:s.jsxs(At,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(is,{className:"w-5 h-5"}),"Notes"]}),o?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:q,disabled:D.isPending,children:[s.jsx(Bt,{className:"w-4 h-4 mr-1"}),"Cancel"]}),s.jsxs(Ne,{size:"sm",onClick:O,disabled:D.isPending,children:[D.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin mr-1"}):s.jsx(ks,{className:"w-4 h-4 mr-1"}),"Save"]})]}):s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:U,children:[s.jsx(of,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),o?s.jsx(Yj,{content:c,onChange:u,placeholder:"Add notes about this project..."}):x.notes?s.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:x.notes}}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No notes yet. Click Edit to add notes."})]})}),s.jsx(Mt,{children:s.jsxs(At,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Due,{className:"w-5 h-5"}),"Attachments (",x.attachments?.length||0,")"]}),s.jsxs("div",{children:[s.jsx("input",{ref:g,type:"file",onChange:R,className:"hidden"}),s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>g.current?.click(),disabled:d,children:[d?s.jsx(xt,{className:"w-4 h-4 animate-spin mr-1"}):s.jsx(qi,{className:"w-4 h-4 mr-1"}),"Upload"]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Upload any file: images (PNG, JPG), PDFs, STL files, or documents."}),x.attachments&&x.attachments.length>0?s.jsx("div",{className:"space-y-2",children:x.attachments.map(j=>s.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(bR,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:j.original_name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:Y(j.size)})]})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.jsx("a",{href:ye.getProjectAttachmentUrl(p,j.filename),download:j.original_name,className:"p-2 rounded hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",title:"Download",children:s.jsx(Mi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>G(j.filename,j.original_name),className:"p-2 rounded hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-red-400",title:"Delete",children:s.jsx(_n,{className:"w-4 h-4"})})]})]},j.filename))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No attachments yet. Click Upload to add files."})]})}),s.jsx(Mt,{children:s.jsxs(At,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(aW,{className:"w-5 h-5"}),"Bill of Materials",_e&&_e.bom_total_items>0&&s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",_e.bom_completed_items,"/",_e.bom_total_items," acquired)"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[w&&w.some(j=>j.is_complete)&&s.jsx("button",{onClick:()=>pe(!he),className:`text-xs px-2 py-1 rounded transition-colors ${he?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:he?"Show all":"Hide done"}),!ue&&s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>le(!0),children:[s.jsx(pr,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),ue&&s.jsxs("form",{onSubmit:se,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.jsx("input",{type:"text",value:V,onChange:j=>K(j.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}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"number",value:J,onChange:j=>X(parseInt(j.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"}),s.jsx("input",{type:"number",step:"0.01",value:F,onChange:j=>W(j.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 (${L})`})]})]}),s.jsx("input",{type:"url",value:ee,onChange:j=>ie(j.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)"}),s.jsx("input",{type:"text",value:ae,onChange:j=>de(j.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)"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Ne,{type:"button",variant:"secondary",size:"sm",onClick:()=>le(!1),children:"Cancel"}),s.jsx(Ne,{type:"submit",size:"sm",disabled:!V.trim()||We.isPending,children:We.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin"}):"Add Part"})]})]}),N?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(xt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):w&&w.length>0?s.jsxs("div",{className:"space-y-2",children:[w.filter(j=>!he||!j.is_complete).map(j=>s.jsx("div",{className:`p-3 rounded-lg transition-colors ${j.is_complete?"bg-bambu-green/10":"bg-bambu-dark"}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>B(j),disabled:z.isPending,className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${j.is_complete?"bg-bambu-green border-bambu-green text-white":"border-bambu-gray hover:border-bambu-green"}`,children:j.is_complete&&s.jsx(Ar,{className:"w-3 h-3"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsxs("p",{className:`text-sm font-medium ${j.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[j.name,s.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",j.quantity_needed]})]}),j.unit_price!==null&&s.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[L,(j.unit_price*j.quantity_needed).toFixed(2)]})]}),s.jsx("button",{onClick:()=>Q(j.id,j.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:s.jsx(_n,{className:"w-4 h-4"})})]}),j.sourcing_url&&s.jsxs("a",{href:j.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:ne=>ne.stopPropagation(),children:[s.jsx(qr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:(()=>{try{return new URL(j.sourcing_url).hostname.replace("www.","")}catch{return j.sourcing_url}})()})]}),j.remarks&&s.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:j.remarks})]})]})},j.id)),w.some(j=>j.unit_price!==null)&&s.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[s.jsx("span",{className:"text-bambu-gray",children:"Total cost:"}),s.jsxs("span",{className:"text-white font-medium",children:[L,w.reduce((j,ne)=>j+(ne.unit_price||0)*ne.quantity_needed,0).toFixed(2)]})]})]}):s.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."})]})}),s.jsx(Mt,{children:s.jsxs(At,{className:"p-4",children:[s.jsx("div",{className:"flex items-center justify-between mb-3",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Y1,{className:"w-5 h-5"}),"Activity Timeline"]})}),C?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(xt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):A&&A.length>0?s.jsx("div",{className:"space-y-3",children:A.slice(0,10).map((j,ne)=>s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${j.event_type==="print_completed"?"bg-bambu-green/20 text-bambu-green":j.event_type==="print_failed"?"bg-red-500/20 text-red-400":j.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[j.event_type==="print_completed"&&s.jsx(Ar,{className:"w-4 h-4"}),j.event_type==="print_failed"&&s.jsx(Sa,{className:"w-4 h-4"}),j.event_type==="print_started"&&s.jsx(Ei,{className:"w-4 h-4"}),j.event_type==="queued"&&s.jsx(l3,{className:"w-4 h-4"}),j.event_type==="project_created"&&s.jsx(pr,{className:"w-4 h-4"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white",children:j.title}),j.description&&s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:j.description}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:Ce(j.timestamp)})]})]},ne))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No activity yet."})]})}),!x.is_template&&s.jsx("div",{className:"flex justify-end",children:s.jsxs(Ne,{variant:"secondary",size:"sm",onClick:()=>ce.mutate(),disabled:ce.isPending,children:[ce.isPending?s.jsx(xt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(Wo,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),_e&&(_e.queued_prints>0||_e.in_progress_prints>0)&&s.jsx(Mt,{children:s.jsxs(At,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(l3,{className:"w-5 h-5"}),"Queue"]}),s.jsx(Nc,{to:`/queue?project=${p}`,className:"text-sm text-bambu-green hover:underline",children:"View all"})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[_e.in_progress_prints>0&&s.jsxs("span",{className:"text-yellow-400",children:[_e.in_progress_prints," printing"]}),_e.queued_prints>0&&s.jsxs("span",{className:"text-bambu-gray",children:[_e.queued_prints," queued"]})]})]})}),s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-between mb-4",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Vc,{className:"w-5 h-5"}),"Prints (",v?.length||0,")"]})}),E?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(xt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):s.jsx(aqe,{archives:v||[]})]}),i&&s.jsx(vne,{project:{...x,archive_count:_e?.total_archives||0,total_items:_e?.total_items||0,queue_count:_e?.queued_prints||0,progress_percent:_e?.progress_percent||null,archives:[]},onClose:()=>a(!1),onSave:j=>D.mutate(j),isLoading:D.isPending}),Me.isOpen&&s.jsx(Qn,{title:Me.title,message:Me.message,confirmText:"Delete",variant:"danger",onConfirm:Me.onConfirm,onCancel:()=>re(j=>({...j,isOpen:!1}))})]})}const Gk=5,cqe=2e3,uqe=3e4,dqe=5e3;function hqe(){const{printerId:t}=sR(),e=parseInt(t||"0",10),[n,r]=S.useState("stream"),[i,a]=S.useState(!1),[o,l]=S.useState(!0),[c,u]=S.useState(Date.now()),[d,f]=S.useState(!1),[g,p]=S.useState(!1),[x,y]=S.useState(0),[b,v]=S.useState(!1),[E,w]=S.useState(0),N=S.useRef(null),A=S.useRef(null),C=S.useRef(null),T=S.useRef(null),L=S.useRef(null),{data:k}=ft({queryKey:["printer",e],queryFn:()=>ye.getPrinter(e),enabled:e>0});S.useEffect(()=>(k&&(document.title=`${k.name} - Camera`),()=>{document.title="Bambuddy"}),[k]);const D=S.useRef(!1);S.useEffect(()=>{const X=`/api/v1/printers/${e}/camera/stop`;D.current=!1;const F=()=>{e>0&&!D.current&&(D.current=!0,navigator.sendBeacon(X))},W=()=>{F()};return window.addEventListener("beforeunload",W),()=>{window.removeEventListener("beforeunload",W),N.current&&(N.current.src=""),F()}},[e]),S.useEffect(()=>{if(o&&!d){const F=setTimeout(()=>{l(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(F)}},[n,o,c,d]),S.useEffect(()=>{const X=()=>{const F=!!document.fullscreenElement;p(F),n==="stream"&&!d&&(N.current&&(N.current.src=""),setTimeout(()=>{l(!0),u(Date.now())},200))};return document.addEventListener("fullscreenchange",X),()=>document.removeEventListener("fullscreenchange",X)},[n,d]),S.useEffect(()=>{let X;const F=()=>{clearTimeout(X),X=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(X),window.removeEventListener("resize",F)}},[]),S.useEffect(()=>()=>{C.current&&clearTimeout(C.current),T.current&&clearInterval(T.current),L.current&&clearInterval(L.current)},[]);const U=S.useCallback(()=>{if(x>=Gk){v(!1),a(!0);return}const X=Math.min(cqe*Math.pow(2,x),uqe);v(!0),w(Math.ceil(X/1e3)),T.current=setInterval(()=>{w(F=>F<=1?(T.current&&clearInterval(T.current),0):F-1)},1e3),C.current=setTimeout(()=>{y(F=>F+1),v(!1),l(!0),a(!1),N.current&&(N.current.src=""),u(Date.now())},X)},[x]);S.useEffect(()=>{if(n!=="stream"||o||b||d){L.current&&(clearInterval(L.current),L.current=null);return}return L.current=setInterval(async()=>{try{const X=await fetch(`/api/v1/printers/${e}/camera/status`);if(X.ok){const F=await X.json();(F.stalled||!F.active&&!i)&&(console.log(`Stream issue detected: stalled=${F.stalled}, active=${F.active}, reconnecting...`),L.current&&(clearInterval(L.current),L.current=null),l(!1),U())}}catch{}},dqe),()=>{L.current&&(clearInterval(L.current),L.current=null)}},[n,o,i,b,d,e,U]);const O=()=>{l(!1),n==="stream"&&x<Gk?U():a(!0)},q=()=>{if(l(!1),a(!1),y(0),v(!1),C.current&&clearTimeout(C.current),T.current&&clearInterval(T.current),N.current&&!localStorage.getItem("cameraWindowState")){const X=N.current,F=X.naturalWidth,W=X.naturalHeight;if(F>0&&W>0){const ae=window.outerWidth-window.innerWidth,de=window.outerHeight-window.innerHeight,ue=F+16+ae,le=W+45+16+de;try{window.resizeTo(ue,le)}catch{}}}},R=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},G=X=>{n===X||d||(f(!0),l(!0),a(!1),y(0),v(!1),C.current&&clearTimeout(C.current),T.current&&clearInterval(T.current),N.current&&(N.current.src=""),n==="stream"&&R(),setTimeout(()=>{r(X),u(Date.now()),f(!1)},100))},Y=()=>{d||(f(!0),l(!0),a(!1),y(0),v(!1),C.current&&clearTimeout(C.current),T.current&&clearInterval(T.current),N.current&&(N.current.src=""),n==="stream"&&R(),setTimeout(()=>{u(Date.now()),f(!1)},100))},V=()=>{A.current&&(document.fullscreenElement?document.exitFullscreen():A.current.requestFullscreen())},K=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,J=o||d||b;return e?s.jsxs("div",{ref:A,className:"min-h-screen bg-black flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[s.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(kp,{className:"w-4 h-4"}),k?.name||`Printer ${e}`]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[s.jsx("button",{onClick:()=>G("stream"),disabled:J,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"}),s.jsx("button",{onClick:()=>G("snapshot"),disabled:J,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"})]}),s.jsx("button",{onClick:Y,disabled:J,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:s.jsx(Gr,{className:`w-4 h-4 text-bambu-gray ${J?"animate-spin":""}`})}),s.jsx("button",{onClick:V,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:g?"Exit fullscreen":"Fullscreen",children:g?s.jsx(Eue,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(xue,{className:"w-4 h-4 text-bambu-gray"})})]})]}),s.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:s.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(o||d)&&!b&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsxs("div",{className:"text-center",children:[s.jsx(Gr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),b&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:s.jsxs("div",{className:"text-center p-4",children:[s.jsx(Db,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),s.jsx("p",{className:"text-white mb-2",children:"Connection lost"}),s.jsxs("p",{className:"text-sm text-bambu-gray mb-3",children:["Reconnecting in ",E,"s... (attempt ",x+1,"/",Gk,")"]}),s.jsx("button",{onClick:Y,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:"Reconnect now"})]})}),i&&!b&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:s.jsxs("div",{className:"text-center p-4",children:[s.jsx(zn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),s.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),s.jsx("button",{onClick:Y,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),s.jsx("img",{ref:N,src:K,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:K?O:void 0,onLoad:K?q:void 0},c)]})})]}):s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function fqe(){const{id:t}=sR(),{mode:e}=fg(),{data:n,isLoading:r,error:i}=ft({queryKey:["external-link",t],queryFn:()=>ye.getExternalLink(Number(t)),enabled:!!t});return r?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i||!n?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[s.jsx(zn,{className:"w-12 h-12"}),s.jsx("p",{children:"Link not found"})]}):s.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 Jr({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return s.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[s.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:s.jsx(t,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:e}),s.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function d9({percent:t,color:e="bg-bambu-green"}){return s.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function Vu({title:t,icon:e,children:n}){return s.jsxs(Mt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx(e,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function mqe(){const{t}=lg(),e=cn(),[n,r]=S.useState(null),[i,a]=S.useState(!1),[o,l]=S.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:f}=ft({queryKey:["systemInfo"],queryFn:ye.getSystemInfo,refetchInterval:3e4}),{data:g}=ft({queryKey:["debugLogging"],queryFn:y1.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:p}=ft({queryKey:["settings"],queryFn:ye.getSettings}),x=p?.time_format||"system",y=async()=>{l(!0);try{const w=await y1.setDebugLogging(!g?.enabled);e.setQueryData(["debugLogging"],w)}catch(w){console.error("Failed to toggle debug logging:",w)}finally{l(!1)}},b=async()=>{r(null),a(!0);try{await y1.downloadSupportBundle()}catch(w){r(w instanceof Error?w.message:"Failed to download support bundle")}finally{a(!1)}};if(u)return s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx(xt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return s.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",E=c.memory.percent_used>90?"bg-red-500":c.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return s.jsxs("div",{className:"p-6 space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),s.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),s.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:[s.jsx(Gr,{className:`w-4 h-4 ${f?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),s.jsx(Vu,{title:t("system.application","Application"),icon:vh,children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(Jr,{icon:vh,label:t("system.version","Version"),value:`v${c.app.version}`}),s.jsx(Jr,{icon:dr,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),s.jsx(Jr,{icon:vh,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),s.jsx(Vu,{title:t("support.title","Support & Troubleshooting"),icon:Uce,children:s.jsxs("div",{className:"space-y-4",children:[s.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.")}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${g?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(Z9,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),s.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&&s.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(g.duration_seconds/60),"m ",g.duration_seconds%60,"s)"]})]})]})]}),s.jsxs("button",{onClick:y,disabled:o,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:[o&&s.jsx(xt,{className:"w-4 h-4 animate-spin"}),g?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:s.jsx(Mi,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),s.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&&s.jsx(xt,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&s.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&&s.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:s.jsxs("p",{className:"text-sm text-bambu-gray",children:[s.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),s.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),s.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),s.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),s.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),s.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[s.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),s.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),s.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),s.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),s.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),s.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]})]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),s.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[s.jsxs("li",{children:["• ",t("support.notItem1","Printer names, IPs, serial numbers")]}),s.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),s.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),s.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),s.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),s.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]})]})]})]}),s.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].")})]})]})}),s.jsxs(Vu,{title:t("system.database","Database"),icon:Pp,children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[s.jsx(Jr,{icon:fo,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),s.jsx(Jr,{icon:pR,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),s.jsx(Jr,{icon:Sa,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),s.jsx(Jr,{icon:xt,label:t("system.printing","Printing"),value:c.database.archives_printing,color:"text-yellow-500"})]}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(Jr,{icon:Ei,label:t("system.printers","Printers"),value:c.database.printers}),s.jsx(Jr,{icon:MR,label:t("system.filaments","Filaments"),value:c.database.filaments}),s.jsx(Jr,{icon:ha,label:t("system.projects","Projects"),value:c.database.projects}),s.jsx(Jr,{icon:mo,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[s.jsx(Jr,{icon:dr,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),s.jsx(Jr,{icon:fo,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),s.jsxs(Vu,{title:t("system.connectedPrinters","Connected Printers"),icon:Ei,children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[s.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),s.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?s.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(w=>s.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),s.jsx("span",{className:"font-medium text-white",children:w.name})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[s.jsx("span",{children:w.model}),s.jsx("span",{className:`px-2 py-0.5 rounded ${w.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":w.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:w.state})]})]},w.id))}):s.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),s.jsx(Vu,{title:t("system.storage","Storage"),icon:_R,children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),s.jsxs("span",{className:"text-white",children:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),s.jsx(d9,{percent:c.storage.disk_percent_used,color:v}),s.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),"%)"]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Jr,{icon:fo,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),s.jsx(Jr,{icon:Pp,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted})]})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsx(Vu,{title:t("system.memory","Memory"),icon:yue,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),s.jsxs("span",{className:"text-white",children:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),s.jsx(d9,{percent:c.memory.percent_used,color:E}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),s.jsx(Vu,{title:t("system.cpu","CPU"),icon:Rv,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(Jr,{icon:Rv,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),s.jsx(Jr,{icon:Rv,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),s.jsx(Vu,{title:t("system.systemDetails","System Details"),icon:vh,children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(Jr,{icon:vh,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),s.jsx(Jr,{icon:Rv,label:t("system.architecture","Architecture"),value:c.system.architecture}),s.jsx(Jr,{icon:vh,label:t("system.python","Python"),value:c.system.python_version}),s.jsx(Jr,{icon:dr,label:t("system.bootTime","Boot Time"),value:Op(c.system.boot_time,x)})]})})]})}function pqe(){const t=S.useRef(null),e=S.useRef(null),n=cn(),[r,i]=S.useState(!1),a=S.useRef(new Set),o=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`,N=new WebSocket(w);let A=null;N.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),A=window.setInterval(()=>{N.readyState===WebSocket.OPEN&&N.send(JSON.stringify({type:"ping"}))},3e4)},N.onmessage=C=>{try{const T=JSON.parse(C.data);T.type==="printer_status"&&T.printer_id!==void 0&&T.data?f.current(T):(u.current.push(T),g())}catch{}},N.onclose=C=>{console.log("[WebSocket] Closed",C.code,C.reason),A&&(clearInterval(A),A=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{p()},3e3)},N.onerror=C=>{console.error("[WebSocket] Error",C),N.close()},t.current=N},[]),x=S.useCallback((E,w)=>{const N=l.current.get(E)||{};l.current.set(E,{...N,...w}),c.current||(c.current=window.setTimeout(()=>{const A=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{A.forEach((C,T)=>{n.setQueryData(["printerStatus",T],L=>{const k={...L,...C};return k.wifi_signal==null&&L?.wifi_signal!=null&&(k.wifi_signal=L.wifi_signal),k})})})},100))},[n]),y=S.useCallback(E=>{a.current.add(E),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const w=Array.from(a.current);a.current.clear(),o.current=null;let N=0;w.forEach(A=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[A]})})},N),N+=500})},3e3)},[n]),b=S.useCallback(E=>{switch(E.type){case"printer_status":E.printer_id!==void 0&&E.data&&x(E.printer_id,E.data);break;case"print_start":E.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",E.printer_id]});break;case"print_complete":y("archives"),y("archiveStats");break;case"archive_created":y("archives"),y("archiveStats");break;case"archive_updated":y("archives");break}},[n,y,x]);S.useEffect(()=>{f.current=b},[b]),S.useEffect(()=>(p(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[p]);const v=S.useCallback(E=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(E))},[]);return{isConnected:r,sendMessage:v}}const gqe=new joe({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function xqe({children:t}){return pqe(),s.jsx(s.Fragment,{children:t})}function bqe(){return s.jsx(ahe,{children:s.jsx(xhe,{children:s.jsx(Roe,{client:gqe,children:s.jsx(eoe,{children:s.jsxs(Pse,{children:[s.jsx(es,{path:"/camera/:printerId",element:s.jsx(hqe,{})}),s.jsxs(es,{element:s.jsx(xqe,{children:s.jsx(fhe,{})}),children:[s.jsx(es,{index:!0,element:s.jsx(UCe,{})}),s.jsx(es,{path:"archives",element:s.jsx(p7e,{})}),s.jsx(es,{path:"queue",element:s.jsx(eWe,{})}),s.jsx(es,{path:"stats",element:s.jsx(mWe,{})}),s.jsx(es,{path:"profiles",element:s.jsx(KWe,{})}),s.jsx(es,{path:"maintenance",element:s.jsx(JWe,{})}),s.jsx(es,{path:"projects",element:s.jsx(tqe,{})}),s.jsx(es,{path:"projects/:id",element:s.jsx(lqe,{})}),s.jsx(es,{path:"settings",element:s.jsx(IWe,{})}),s.jsx(es,{path:"system",element:s.jsx(mqe,{})}),s.jsx(es,{path:"external/:id",element:s.jsx(fqe,{})})]})]})})})})})}Oie.createRoot(document.getElementById("root")).render(s.jsx(S.StrictMode,{children:s.jsx(bqe,{})}));